Logo F2FInterview

Django Interview Questions

Q   |   QA

The bellow structure has been created by Django1.4

|-- manage.py
`-- myproject
    |-- __init__.py
    |-- settings.py
    |-- urls.py
    `-- wsgi.py

The __init__.py files are required to make Python treat the directories as containing packages; this is done to prevent directories with a common name, such as string, from unintentionally hiding valid modules that occur later on the module search path. In the simplest case, __init__.py can just be an empty file, but it can also execute initialization code for the package or set the __all__ variable, described later.

These scripts are the same in priciple, with the differences, django-admin.py is Django’s command-line utility for administrative tasks.

In addition, manage.py is automatically created in each Django project. manage.py is a thin wrapper around django-admin.py that takes care of two things for you before delegating to django-admin.py:

  • It puts your project’s package on sys.path.
  • It sets the DJANGO_SETTINGS_MODULE environment variable so that it points to your project’s settings.py file. 

The django-admin.py script should be on your system path if you installed Django via its setup.py utility. If it’s not on your path, you can find it in site-packages/django/bin within your Python installation. Consider symlinking it from some place on your path, such as /usr/local/bin.

For Windows users, who do not have symlinking functionality available, you can copy django-admin.py to a location on your existing path or edit the PATH settings (under Settings - Control Panel - System - Advanced - Environment...) to point to its installed location.

Generally, when working on a single Django project, it’s easier to use manage.py. Use django-admin.py with DJANGO_SETTINGS_MODULE, or the --settings command line option, if you need to switch between multiple Django settings files.

django-admin.py <command> [options]
manage.py <command> [options]

Django includes an internal "dispatcher" which provides two pieces of functionality:

  • Pieces of code which want to advertise what they're doing can use the dispatcher to send "signals" which contain information about what's happening.
  • Pieces of code which want to do something whenever a certain event happens can use the dispatcher to "listen" for particular signals, then execute the functions they want when those signals are sent out.

The actual mechanism comes from a third-party library called PyDispatcher, which is bundled with Django and which lives at django.dispatch.dispatcher. To improve performance the API and implementation has been refactored, as described at the end of this document.

Signal.connect(receiver[, sender=None, weak=True, dispatch_uid=None])
  • receiver – The callback function which will be connected to this signal.
  • sender – Specifies a particular sender to receive signals from.

In order to link this F2FInterview's page as Reference on your website or Blog, click on below text area and pres (CTRL-C) to copy the code in clipboard or right click then copy the following lines after that paste into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code: