These Django multiple-choice questions and their answers will help you strengthen your grip on the subject of Django. You can prepare for an upcoming exam or job interview with these Django MCQs.
So scroll down and start answering.
A. manage.py --start
B. manage.py startserver --dev
C. manage.py run
D. manage.py runserver
E. manage.py --run
A. A collection of configuration files and individual apps that form a web site.
B. A fork of the official Django repo.
C. A web site that uses the Django framework.
D. A specific piece of functionality that can be used in multiple Django apps.
A. render_to_html
B. response_render
C. render
D. render_to_response
A. (r'^pattern/$', YourView.as_view()),
B. (r'^pattern/$', YourView()),
C. (r'^pattern/$', YourView),
D. (r'^pattern/$', YourView.init()),
A. A good Django app is a fully functioning website that has 100% test coverage.
B. A good Django app provides a small, specific piece of functionality that can be used in any number of Django projects.
C. A good Django app is highly customized and cannot be used in multiple projects.
A. To sync the database schema
B. To configure settings for an app
C. To set the date and time on the server
D. To configure settings for the Django project
A. Python
B. Ruby
C. PHP
D. Javascript
E. Java
A. This file contains site deployment data such as server names and ports.
B. It contains a site map of Django-approved URLs.
C. You run this file when you get obscure 404 Not Found errors in your server logs.
D. It contains URL matching patterns and their corresponding view methods.
E. This file provides an up to date list of how-to URLs for learning Django more easily.
A. manage.py --dev 12.34.56.78:8080
B. manage.py --run 12.34.56.78 8080
C. manage.py runserver 12.34.56.78:8000
D. manage.py run 12.34.56.78:8080
E. manage.py runserver 12.34.56.78:8080
A. In settings.py, add the app to the PROJECT_APPS variable.
B. In settings.py, add the new app to the INSTALLED_APPS variable.
C. Run the `manage.py validate` command, and then start a new shell.
D. No additional action is required, Django notices new apps automatically.
E. Run the `manage.py syncdb` command.
A. manage.py startapp users
B. manage.py --startapp users
C. manage.py --newapp users
D. manage.py newapp users
E. manage.py start users
A. AJP
B. FastCGI
C. SCGI
D. mod_wsgi
A. model = CharField(max_length=255)
B. name = models.CharField(max_len=255)
C. name = models.CharField(max_length=255)
D. name = model.StringField(max_length=auto)
E. model.CharField(max_length=255)
A. to_s( self )
B. __utf_8__
C. __translate__
D. __unicode__
A. Set the field to hidden
B. Create a new Form, don't use a ModelForm
C. You can not do this
D. Use the exclude parameter in the Meta class in your form
A. To define a form based on an existing model
B. To model an input form for a template
C. To specify rules for correct form when writing Django code
A. user = models.ForeignKey(User)
B. models.ForeignKey( self, User )
C. user = models.IntegerKey(User)
D. model = new ForeignKey(User)
A. admin.site( self, User )
B. users.site.register( Admin )
C. admin.register( Users )
D. user.site.register( Admin )
E. admin.site.register( User )
A. The object is created and returned.
B. The Http404 exception is raised.
C. The DatabaseError exception is raised.
D. The MyObject.DoesNotExist exception is raised.
A. in views.py, import timezone
B. In settings.py: USE_TZ=True
C. in views.py, import tz
D. In settings.py: USE_L10N=True
E. in urls.py, import timezone
A. django-admin.py --start myproject
B. django.py --new myproject
C. django.py startproject myproject
D. django-admin.py startproject myproject
E. django.py new myproject
A. User.all_records()
B. Users.objects.all()
C. User.objects
D. User.object.all()
E. User.objects.all()
A. django.helpers
B. django.extras
C. django.contrib
D. django.utilities
E. django.ponies
A. Starts a command line in whatever $SHELL your environment uses.
B. Starts a Django command prompt with your Python environment pre-loaded.
C. Loads a Python command prompt you can use to sync your database schema remotely.
D. Loads a special Pythonic version of the Bash shell.
E. Starts a Python command prompt with your Django environment pre-loaded.
A. def __init__():
B. def Meta():
C. class Meta:
D. def setUp():
E. class __init__:
A. There is no pre_save signal
B. from django.db.models import pre_save
C. from django.db.models.signal import pre_save
D. from django.db.models.signals import pre_save
A. Dijit is Dojo's git interface.
B. Dijit is Dojo’s UI Library.
C. Dijit is Dojo's AMD loader.
D. Dijit is Dojo's interface to the jQuery effects functions.
E. Dijit is Dojo's math library.
A. Checks for errors in your models.
B. Checks for errors in your views.
C. Checks for errors in your settings.py file.
D. Checks for errors in your templates.
E. Checks for errors in your controllers.
A. url(r'^admin/', include(admin.site.urls) ),
B. url(r'^admin/', admin.as_view(), name='admin ),
C. url(r'^admin/', include(admin) ),
D. url(r'^admin/', admin.urls ),
E. admin.autodiscover()
A. Defines the URL prefix where static files will be served from .
B. Defines the location where all static files will be copied by the 'collectstatic' management command, to be served by the production webserver.
C. Defines the location for serving user uploaded files.
D. A project's static assets should be stored here to be served by the development server.
A. {% for d in mydata -%} <p><a href="/users/{{ d.0 }}/">{{ d.1 }}</a></p> {% end -%}
B. {% for d in mydata %} <p><a href="/users/{{ d.0 }}/">{{ d.1 }}</a></p> {% endfor %}
C. {% mydata.each |d| %} <p><a href="/users/{{ d.1 }}/">{{ d.2 }}</a></p> {% end %}
D. {{ for d in mydata }} <p><a href="/users/{{ d[0] }}/">{{ d[1] }}</a></p> {{ endfor }}
E. {% for d in mydata %} <p><a href="/users/{% d.0 %}/">{% d.1 %}</a></p> {% endfor %}
A. Widget.objects.all().aggregate( Avg( 'users' ) )
B. User.objects.all().aggregate( Avg( 'widgets' ) )
C. User.objects.avg( 'widgets' )
D. User.objects.all().aggregate( Sum( 'widgets' ) )
E. User.all().aggregate( Avg( 'widgets' ) ).count()
A. User.objects.filter( last_login__isnull=True )
B. User.objects.filter( last_login=Null )
C. User.objects.filter( last_login=Never )
D. User.objects.filter( last_login__null=True )
E. User.objects.filter( last_login__isnull=False )
A. django-admin.py inspect
B. manage.py inspectdb
C. manage.py inspect
D. manage.py legacydb
E. django-admin.py schemadump
A. User.objects.filter( email__iexact='fred@aol.com' )
B. User.objects.filter( email__matches='fred@aol.com' )
C. User.objects.filter( email__exact='fred@aol.com' )
D. User.objects.filter( email__contains='fred@aol.com' )
E. User.objects.filter( email__icontains='fred@aol.com' )
A. ./manage.py compilemessages
B. ./manage.py compiletranslation
C. ./manage.py translate_files
D. ./manage.py compilei18n
E. ./manage.py i18n_update
A. foo_clean
B. validate_foo
C. clean_foo
D. foo_is_valid
A. foo_clean
B. clean_foo
C. clean_foo_field
D. sanitize_foo
E. validate_foo
A. User.objects.all().order('-name')[:10]
B. User.all().order_by('-name')[10:]
C. User.objects.all().order('-name')[10:]
D. User.objects.all().order_by('-name')[:10]
E. User.objects.all().order_by('name')[:10]
A. created = models.DateTimeField(auto_now=True)
B. created = models.DateTimeField(default=datetime.datetime.now())
C. created = models.CreationTimeField()
D. created = models.DateTimeField(auto_now_add=True, auto_now=True)
E. created = models.DateTimeField(auto_now_add=True)
A. suffix
B. prefix
C. name
D. infix
A. Raise ValidationError in MyForm.clean_<fieldname>()
B. Raise ValidationError in MyForm.clean()
C. Add the error to MyForm.errors in MyForm.clean()
D. Add the error to MyForm._errors in MyForm.clean()
A. fields_display
B. list_filter
C. fields_list
D. auto_list_fields
E. list_display
A. django-admin.py dumpdata myapp
B. ./manage.py schema myapp
C. ./manage.py sql myapp
D. ./manage.py showschema myapp
E. ./manage.py showsql myapp
A. True
B. Always
C. 1
D. Never
E. False
A. form.clean_password
B. form.clean_confirm_password
C. form.sanitize_data
D. form.clean
E. form.validate
A. models.ForeignKey('self')
B. models.ForeignKey('Company')
C. models.ForeignKey('me')
D. models.ForeignKey(Company)
A. django.db.models.fields.files.ImageFieldFile
B. django.db.models.fields.files.ImageFile
C. django.db.models.fields.files.ImageFileField
D. django.db.models.fields.files.ImageFileDescriptor
E. django.db.models.fields.files.ImageField
A. settings.get("SETTING_NAME", default_value)
B. getattr("SETTING_NAME", settings, default=default_value)
C. get_setting("SETTING_NAME", default=default_value)
D. getattr(settings, "SETTING_NAME", default_value)
A. Guido van Rossum and Linus Torvalds
B. Ian Bicking and Jannis Leidel
C. and Armando De La Veloper
D. Eric S. Raymond and Larry Wall
E. Jacob Kaplan-Moss and Adrian Holovaty