SlideShare a Scribd company logo
1 of 12
Download to read offline
### Easy

1.You have a class defined as

   class Post(models.Model):
      name = models.CharField(max_length=100)
      is_active = models.BooleanField(default=False)

You create multiple objects of this type. If you do
Post.objects.get(is_active=false),

what exceptions is raised?

a. MultipleObjectsReturned
b. ManyObjectsReturned
c. SyntaxError
d. MultipleModelReturned
e. ManyModelReturned

2. Where is the function render_to_response defined?

a. django.views
b. django.shortcuts
c. django.templates
d. django.contrib.templates
e. django.contrib.shortcuts

3. What is the default name for the table created for model named Post
in application blog

a. post_blog



                              Agiliq Info Solutions India Pvt Ltd,
           Flat No. 302, Siri Sampada, Above Food World, Near Madhapur Police Station,
                                    Hyderabad - 500081. India

                       Phone : 040 – 40186297     Email : hello@agiliq.com
b. blog_post
c. postblog
d. blogpost
e. Postblog

4. How do you send a 302 redirect using django?

a. return HttpRedirectResponse()
b. return HttpResponseRedirect()
c. return HttpRedirectResponse(permanent=True)
d. return HttpResponseRedirect(permanent=True)
e. return HttpRedirectResponse

5. In django.contrib.auth, Users passwords are kept in what form?
a. Plain text
b. Hashed
c. Encrypted
d. Hashed then encrypted
3. Encrypted then hashed

6. Which of the following is correct way to find out if a request uses
HTTP POST method?

a. request.is_post() == True
b. request.METHOD == 'post'
c. request.METHOD == 'POST'
d. request.method == 'post'
e. request.method == 'POST'

7. Generic views have access to request context.

a. True
b. False
c. Default is True but can be set to False by GENERIC_REQUEST_CONTEXT in settings.



                           Agiliq Info Solutions India Pvt Ltd,
         Flat No. 302, Siri Sampada, Above Food World, Near Madhapur Police Station,
                                  Hyderabad - 500081. India

                     Phone : 040 – 40186297     Email : hello@agiliq.com
d. Default is False but can be set to True by GENERIC_REQUEST_CONTEXT in settings.
e. Can not be determined without extra information.

8. The current released version of Django is

a. 0.96
b. 1.0
c. 1.1
d. 1.2
e.Vyper logix 2.0

9. Which of these is a correct context_processor?

a.

def featured_posts(request):
  return Post.objects.filter(is_featured=True)

b.

def featured_posts(request):
  return {'featured_posts': Post.objects.filter(is_featured=True)}

c.

def featured_posts(request, response):
  return Post.objects.filter(is_featured=True)

d.

def featured_posts(request, response):
  return {'featured_posts': Post.objects.filter(is_featured=True)}

e.



                           Agiliq Info Solutions India Pvt Ltd,
         Flat No. 302, Siri Sampada, Above Food World, Near Madhapur Police Station,
                                  Hyderabad - 500081. India

                     Phone : 040 – 40186297     Email : hello@agiliq.com
def featured_posts(request, response):
  response.write('featured_posts'= Post.objects.filter(is_featured=True))

10. Which of the following is a valid Middleware?

a.

class LatestPostMiddleware:
   def process_request(request):
      request.latest_post = Post.objects.latest()

b.

class LatestPostMiddleware(django.middlewares.BaseMiddleWare):
   def process_request(request):
      request.latest_post = Post.objects.latest()

c.

class LatestPostMiddleware(django.middlewares.BaseMiddleWare):
   def process_request(request):
      return {'latest_post': Post.objects.latest()}

d.

class LatestPostMiddleware():
   def process_request(request):
      return {'latest_post': Post.objects.latest()}

e.

class LatestPostMiddleware():
   def process_request(request):
      request.write('latest_post'= Post.objects.latest())



                             Agiliq Info Solutions India Pvt Ltd,
          Flat No. 302, Siri Sampada, Above Food World, Near Madhapur Police Station,
                                   Hyderabad - 500081. India

                       Phone : 040 – 40186297         Email : hello@agiliq.com
#Moderate

11. In the model below which line can be removed for the class to work

class Post(models.Model):
   name = models.CharField(max_length = 100)#Line 1
   desc = models.TextField()#Line 2
   post = models.ForeignKey(Blog)#Line 3
   blog = models.ForeignKey(Blog)#Line 4

a. Line 1
b. Line 2
c. Line 3
d. Line 4
e. Either of line 3 or 4

12. Who can access the admin site in Django?

a. user with is_super_user True
b. user with is_staff True
c. user with is_admin True
d. Either of a or b
e. Either of a, b, c

13. Which of the following code is closest to login_required decorator in Django?

a.

def login_required2(request):
  if request.user.is_authenticated():
      return True
  else:



                            Agiliq Info Solutions India Pvt Ltd,
          Flat No. 302, Siri Sampada, Above Food World, Near Madhapur Police Station,
                                   Hyderabad - 500081. India

                       Phone : 040 – 40186297    Email : hello@agiliq.com
return False

  b.

   def login_required2(request, view_func):
     def check_login(request):
         if request.is_authenticated() and request.has_permissions
(request.REQUIRED_PERMISSIONS):
             return view_function(request)
         else:
             return HttpResponseRedirect('/login/')
     return check_login(view_func)

  c.

  def login_required2(request, view_func):
    def check_login(request):
        if request.is_authenticated():
            return view_function(request)
        else:
            return HttpResponseRedirect('/login/')
    return check_login(view_func)

  d.

  def login_required2(view_func):
    def new_func(request):
        if request.user.is_authenticated():
            return view_func(request)
        else:
            return HttpResponseRedirect('/login/')
    return new_func




                              Agiliq Info Solutions India Pvt Ltd,
            Flat No. 302, Siri Sampada, Above Food World, Near Madhapur Police Station,
                                     Hyderabad - 500081. India

                        Phone : 040 – 40186297       Email : hello@agiliq.com
e.

   def login_required2(view_func):
     def new_func(request):
         if request.user.is_authenticated() and request.has_permissions
(request.REQUIRED_PERMISSIONS):
             return view_func(request)
         else:
             return HttpResponseRedirect('/login/')
     return new_func


  14. Which of the following is a valid method to model Many to many relation ship in Django?

  a.

  class Foo(models.Model):
     bar = models.ManyToManyField(Bar)

  class Bar(models.Model):
     foo = models.ManyToManyField(Foo)

  b.

  class Foo(models.Model):
     bar = models.ForeignKey(Bar)

  class Bar(models.Model):
     foo = models.ForeignKey(Foo)

  c.

  class Foo(models.Model):
     bar = models.ManyToManyField(Bar)



                              Agiliq Info Solutions India Pvt Ltd,
            Flat No. 302, Siri Sampada, Above Food World, Near Madhapur Police Station,
                                     Hyderabad - 500081. India

                        Phone : 040 – 40186297     Email : hello@agiliq.com
class Bar(models.Model):
     pass

  d. both B and C

  e. All a, b, c

  15. Which of the following is not included by default in
TEMPLATE_CONTEXT_PROCESSORS

  a. django.core.context_processors.auth
  b. django.core.context_processors.debug
  c. django.core.context_processors.i18n
  d. django.core.context_processors.media
  e. django.core.context_processors.request

  16. Which of these is the currect way to validate uniqueness of a field named "slug" in a form
  subclassing django.form.Forms.

  a.

  def clean(self):
    try:
        Post.objects.get(slug = self.cleaned_data['slug'])
        raise forms.Error(ValidationError, 'This slug already exists')
    except Post.DoesNotExist:
        return self.cleaned_data


  b.

  def clean(self):
    try:



                                Agiliq Info Solutions India Pvt Ltd,
              Flat No. 302, Siri Sampada, Above Food World, Near Madhapur Police Station,
                                       Hyderabad - 500081. India

                          Phone : 040 – 40186297     Email : hello@agiliq.com
Post.objects.get(slug = self.cleaned_data['slug'])
       raise ValidationError('This slug already exists')
     except Post.DoesNotExist:
       return self.cleaned_data

c.

def clean_slug(self):
  try:
      Post.objects.get(slug = self.cleaned_data['slug'])
      raise forms.Error(ValidationError, 'This slug already exists')
  except Post.DoesNotExist:
      return self.cleaned_data


d.

def clean_slug(self):
  try:
      Post.objects.get(slug = self.cleaned_data['slug'])
      raise ValidationError('This slug already exists')
  except Post.DoesNotExist:
      return self.cleaned_data

e.

17. To add custom commands to your project setup, you need to,

1. Add management/command/commandname.py to your django app.
2. Add management/command/commandname.py to your django project.
3. Add command/commandname.py to your django app.
4. Add command/commandname.py to your django project.
5. Add management/command/manage.py to yout django project.




                              Agiliq Info Solutions India Pvt Ltd,
           Flat No. 302, Siri Sampada, Above Food World, Near Madhapur Police Station,
                                    Hyderabad - 500081. India

                        Phone : 040 – 40186297     Email : hello@agiliq.com
18.You want to enable caching for Django pages for AnonymousUser, which of these
is a valid way to do this.

a.


MIDDLEWARE_CLASSES = (
  'django.middleware.common.CommonMiddleware',
  'django.middleware.cache.CacheMiddleware',
  'django.contrib.sessions.middleware.SessionMiddleware',
  'django.contrib.auth.middleware.AuthenticationMiddleware',
)

b.

MIDDLEWARE_CLASSES = (
  'django.middleware.common.CommonMiddleware',
  'django.contrib.sessions.middleware.SessionMiddleware',
  'django.middleware.cache.CacheMiddleware',
  'django.contrib.auth.middleware.AuthenticationMiddleware',
)

c.

MIDDLEWARE_CLASSES = (
  'django.middleware.common.CommonMiddleware',
  'django.contrib.sessions.middleware.SessionMiddleware',
  'django.contrib.auth.middleware.AuthenticationMiddleware',
  'django.middleware.cache.CacheMiddleware',
)

d.

MIDDLEWARE_CLASSES = (



                           Agiliq Info Solutions India Pvt Ltd,
         Flat No. 302, Siri Sampada, Above Food World, Near Madhapur Police Station,
                                  Hyderabad - 500081. India

                     Phone : 040 – 40186297     Email : hello@agiliq.com
'django.middleware.cache.CacheMiddleware',
     'django.middleware.common.CommonMiddleware',
     'django.contrib.sessions.middleware.SessionMiddleware',
     'django.contrib.auth.middleware.AuthenticationMiddleware',
)

e.

MIDDLEWARE_CLASSES = (
  'django.middleware.cache.CacheMiddleware',
  'django.middleware.common.CommonMiddleware',
  'django.contrib.sessions.middleware.SessionMiddleware',
)

19.

Consider the urlconf given below

     from django.conf.urls.defaults import *

 urlpatterns = patterns('news.views',
    (r'^articles/2003/$', 'year_archive_2003'),
    (r'^articles/(d{4})/', 'year_archive'),
    (r'^articles/2003/(d{2})/$', 'month_archive_2003'),
    (r'^articles/(d{4})/(d{2})/', 'month_archive'),
    (r'^articles/(d{4})/10/', 'month_archive_october'),
 )
What view is called when accessing /articles/2003/10/

a. year_archive_2003
b. year_archive
c. month_archive_2003
d. month_archive
e. month_archive_october



                             Agiliq Info Solutions India Pvt Ltd,
           Flat No. 302, Siri Sampada, Above Food World, Near Madhapur Police Station,
                                    Hyderabad - 500081. India

                       Phone : 040 – 40186297     Email : hello@agiliq.com
20.

Consider the urlpatterns.

   urlpatterns = patterns('blogapp.views',
      (r'^list/(?P<year>d{4})/(?P<month>[a-z]{3})/$','archive_month'),
   )

Which if the following is a valid view function which will be called on accesing
/list/2009/jun/

a. def archive_month(request):
       ...

b. def archive_month(request, *args):

c. def archive_month(request, **kwargs):

d. def archive_month(request, year, month,):

e. Both c and d


# Hard

None yet




                             Agiliq Info Solutions India Pvt Ltd,
           Flat No. 302, Siri Sampada, Above Food World, Near Madhapur Police Station,
                                    Hyderabad - 500081. India

                       Phone : 040 – 40186297     Email : hello@agiliq.com

More Related Content

Similar to The django quiz

Mp24: The Bachelor, a facebook game
Mp24: The Bachelor, a facebook gameMp24: The Bachelor, a facebook game
Mp24: The Bachelor, a facebook gameMontreal Python
 
Working With The Symfony Admin Generator
Working With The Symfony Admin GeneratorWorking With The Symfony Admin Generator
Working With The Symfony Admin GeneratorJohn Cleveley
 
ACADGILD:: ANDROID LESSON
ACADGILD:: ANDROID LESSON ACADGILD:: ANDROID LESSON
ACADGILD:: ANDROID LESSON Padma shree. T
 
Python Development (MongoSF)
Python Development (MongoSF)Python Development (MongoSF)
Python Development (MongoSF)Mike Dirolf
 
PHP Session - Mcq ppt
PHP Session - Mcq ppt PHP Session - Mcq ppt
PHP Session - Mcq ppt Shaheen Shaikh
 
Designing REST API automation tests in Kotlin
Designing REST API automation tests in KotlinDesigning REST API automation tests in Kotlin
Designing REST API automation tests in KotlinDmitriy Sobko
 
Ruby on rails
Ruby on rails Ruby on rails
Ruby on rails Mohit Jain
 
Modernising Legacy Code
Modernising Legacy CodeModernising Legacy Code
Modernising Legacy CodeSamThePHPDev
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applicationschartjes
 
Invoke dynamite in Java EE with invoke dynamic
Invoke dynamite in Java EE with invoke dynamicInvoke dynamite in Java EE with invoke dynamic
Invoke dynamite in Java EE with invoke dynamicAntoine Sabot-Durand
 
Inside PyMongo - MongoNYC
Inside PyMongo - MongoNYCInside PyMongo - MongoNYC
Inside PyMongo - MongoNYCMike Dirolf
 
4 introduction-php-mvc-cakephp-m4-controllers-slides
4 introduction-php-mvc-cakephp-m4-controllers-slides4 introduction-php-mvc-cakephp-m4-controllers-slides
4 introduction-php-mvc-cakephp-m4-controllers-slidesMasterCode.vn
 
Django Forms: Best Practices, Tips, Tricks
Django Forms: Best Practices, Tips, TricksDjango Forms: Best Practices, Tips, Tricks
Django Forms: Best Practices, Tips, TricksShawn Rider
 
Oops concepts in php
Oops concepts in phpOops concepts in php
Oops concepts in phpCPD INDIA
 
Quality assurance for php projects with PHPStorm
Quality assurance for php projects with PHPStormQuality assurance for php projects with PHPStorm
Quality assurance for php projects with PHPStormMichelangelo van Dam
 
Optimization in django orm
Optimization in django ormOptimization in django orm
Optimization in django ormDenys Levchenko
 
Data Migrations in the App Engine Datastore
Data Migrations in the App Engine DatastoreData Migrations in the App Engine Datastore
Data Migrations in the App Engine DatastoreRyan Morlok
 

Similar to The django quiz (20)

Mp24: The Bachelor, a facebook game
Mp24: The Bachelor, a facebook gameMp24: The Bachelor, a facebook game
Mp24: The Bachelor, a facebook game
 
Working With The Symfony Admin Generator
Working With The Symfony Admin GeneratorWorking With The Symfony Admin Generator
Working With The Symfony Admin Generator
 
ACADGILD:: ANDROID LESSON
ACADGILD:: ANDROID LESSON ACADGILD:: ANDROID LESSON
ACADGILD:: ANDROID LESSON
 
Python Development (MongoSF)
Python Development (MongoSF)Python Development (MongoSF)
Python Development (MongoSF)
 
PHP Session - Mcq ppt
PHP Session - Mcq ppt PHP Session - Mcq ppt
PHP Session - Mcq ppt
 
Designing REST API automation tests in Kotlin
Designing REST API automation tests in KotlinDesigning REST API automation tests in Kotlin
Designing REST API automation tests in Kotlin
 
Django design-patterns
Django design-patternsDjango design-patterns
Django design-patterns
 
Ruby on rails
Ruby on rails Ruby on rails
Ruby on rails
 
Modernising Legacy Code
Modernising Legacy CodeModernising Legacy Code
Modernising Legacy Code
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applications
 
Invoke dynamite in Java EE with invoke dynamic
Invoke dynamite in Java EE with invoke dynamicInvoke dynamite in Java EE with invoke dynamic
Invoke dynamite in Java EE with invoke dynamic
 
Inside PyMongo - MongoNYC
Inside PyMongo - MongoNYCInside PyMongo - MongoNYC
Inside PyMongo - MongoNYC
 
4 introduction-php-mvc-cakephp-m4-controllers-slides
4 introduction-php-mvc-cakephp-m4-controllers-slides4 introduction-php-mvc-cakephp-m4-controllers-slides
4 introduction-php-mvc-cakephp-m4-controllers-slides
 
Django Forms: Best Practices, Tips, Tricks
Django Forms: Best Practices, Tips, TricksDjango Forms: Best Practices, Tips, Tricks
Django Forms: Best Practices, Tips, Tricks
 
Oops concepts in php
Oops concepts in phpOops concepts in php
Oops concepts in php
 
Quality assurance for php projects with PHPStorm
Quality assurance for php projects with PHPStormQuality assurance for php projects with PHPStorm
Quality assurance for php projects with PHPStorm
 
Django tricks (2)
Django tricks (2)Django tricks (2)
Django tricks (2)
 
Optimization in django orm
Optimization in django ormOptimization in django orm
Optimization in django orm
 
Data Migrations in the App Engine Datastore
Data Migrations in the App Engine DatastoreData Migrations in the App Engine Datastore
Data Migrations in the App Engine Datastore
 
Android sql examples
Android sql examplesAndroid sql examples
Android sql examples
 

Recently uploaded

The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 

Recently uploaded (20)

The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 

The django quiz

  • 1. ### Easy 1.You have a class defined as class Post(models.Model): name = models.CharField(max_length=100) is_active = models.BooleanField(default=False) You create multiple objects of this type. If you do Post.objects.get(is_active=false), what exceptions is raised? a. MultipleObjectsReturned b. ManyObjectsReturned c. SyntaxError d. MultipleModelReturned e. ManyModelReturned 2. Where is the function render_to_response defined? a. django.views b. django.shortcuts c. django.templates d. django.contrib.templates e. django.contrib.shortcuts 3. What is the default name for the table created for model named Post in application blog a. post_blog Agiliq Info Solutions India Pvt Ltd, Flat No. 302, Siri Sampada, Above Food World, Near Madhapur Police Station, Hyderabad - 500081. India Phone : 040 – 40186297 Email : hello@agiliq.com
  • 2. b. blog_post c. postblog d. blogpost e. Postblog 4. How do you send a 302 redirect using django? a. return HttpRedirectResponse() b. return HttpResponseRedirect() c. return HttpRedirectResponse(permanent=True) d. return HttpResponseRedirect(permanent=True) e. return HttpRedirectResponse 5. In django.contrib.auth, Users passwords are kept in what form? a. Plain text b. Hashed c. Encrypted d. Hashed then encrypted 3. Encrypted then hashed 6. Which of the following is correct way to find out if a request uses HTTP POST method? a. request.is_post() == True b. request.METHOD == 'post' c. request.METHOD == 'POST' d. request.method == 'post' e. request.method == 'POST' 7. Generic views have access to request context. a. True b. False c. Default is True but can be set to False by GENERIC_REQUEST_CONTEXT in settings. Agiliq Info Solutions India Pvt Ltd, Flat No. 302, Siri Sampada, Above Food World, Near Madhapur Police Station, Hyderabad - 500081. India Phone : 040 – 40186297 Email : hello@agiliq.com
  • 3. d. Default is False but can be set to True by GENERIC_REQUEST_CONTEXT in settings. e. Can not be determined without extra information. 8. The current released version of Django is a. 0.96 b. 1.0 c. 1.1 d. 1.2 e.Vyper logix 2.0 9. Which of these is a correct context_processor? a. def featured_posts(request): return Post.objects.filter(is_featured=True) b. def featured_posts(request): return {'featured_posts': Post.objects.filter(is_featured=True)} c. def featured_posts(request, response): return Post.objects.filter(is_featured=True) d. def featured_posts(request, response): return {'featured_posts': Post.objects.filter(is_featured=True)} e. Agiliq Info Solutions India Pvt Ltd, Flat No. 302, Siri Sampada, Above Food World, Near Madhapur Police Station, Hyderabad - 500081. India Phone : 040 – 40186297 Email : hello@agiliq.com
  • 4. def featured_posts(request, response): response.write('featured_posts'= Post.objects.filter(is_featured=True)) 10. Which of the following is a valid Middleware? a. class LatestPostMiddleware: def process_request(request): request.latest_post = Post.objects.latest() b. class LatestPostMiddleware(django.middlewares.BaseMiddleWare): def process_request(request): request.latest_post = Post.objects.latest() c. class LatestPostMiddleware(django.middlewares.BaseMiddleWare): def process_request(request): return {'latest_post': Post.objects.latest()} d. class LatestPostMiddleware(): def process_request(request): return {'latest_post': Post.objects.latest()} e. class LatestPostMiddleware(): def process_request(request): request.write('latest_post'= Post.objects.latest()) Agiliq Info Solutions India Pvt Ltd, Flat No. 302, Siri Sampada, Above Food World, Near Madhapur Police Station, Hyderabad - 500081. India Phone : 040 – 40186297 Email : hello@agiliq.com
  • 5. #Moderate 11. In the model below which line can be removed for the class to work class Post(models.Model): name = models.CharField(max_length = 100)#Line 1 desc = models.TextField()#Line 2 post = models.ForeignKey(Blog)#Line 3 blog = models.ForeignKey(Blog)#Line 4 a. Line 1 b. Line 2 c. Line 3 d. Line 4 e. Either of line 3 or 4 12. Who can access the admin site in Django? a. user with is_super_user True b. user with is_staff True c. user with is_admin True d. Either of a or b e. Either of a, b, c 13. Which of the following code is closest to login_required decorator in Django? a. def login_required2(request): if request.user.is_authenticated(): return True else: Agiliq Info Solutions India Pvt Ltd, Flat No. 302, Siri Sampada, Above Food World, Near Madhapur Police Station, Hyderabad - 500081. India Phone : 040 – 40186297 Email : hello@agiliq.com
  • 6. return False b. def login_required2(request, view_func): def check_login(request): if request.is_authenticated() and request.has_permissions (request.REQUIRED_PERMISSIONS): return view_function(request) else: return HttpResponseRedirect('/login/') return check_login(view_func) c. def login_required2(request, view_func): def check_login(request): if request.is_authenticated(): return view_function(request) else: return HttpResponseRedirect('/login/') return check_login(view_func) d. def login_required2(view_func): def new_func(request): if request.user.is_authenticated(): return view_func(request) else: return HttpResponseRedirect('/login/') return new_func Agiliq Info Solutions India Pvt Ltd, Flat No. 302, Siri Sampada, Above Food World, Near Madhapur Police Station, Hyderabad - 500081. India Phone : 040 – 40186297 Email : hello@agiliq.com
  • 7. e. def login_required2(view_func): def new_func(request): if request.user.is_authenticated() and request.has_permissions (request.REQUIRED_PERMISSIONS): return view_func(request) else: return HttpResponseRedirect('/login/') return new_func 14. Which of the following is a valid method to model Many to many relation ship in Django? a. class Foo(models.Model): bar = models.ManyToManyField(Bar) class Bar(models.Model): foo = models.ManyToManyField(Foo) b. class Foo(models.Model): bar = models.ForeignKey(Bar) class Bar(models.Model): foo = models.ForeignKey(Foo) c. class Foo(models.Model): bar = models.ManyToManyField(Bar) Agiliq Info Solutions India Pvt Ltd, Flat No. 302, Siri Sampada, Above Food World, Near Madhapur Police Station, Hyderabad - 500081. India Phone : 040 – 40186297 Email : hello@agiliq.com
  • 8. class Bar(models.Model): pass d. both B and C e. All a, b, c 15. Which of the following is not included by default in TEMPLATE_CONTEXT_PROCESSORS a. django.core.context_processors.auth b. django.core.context_processors.debug c. django.core.context_processors.i18n d. django.core.context_processors.media e. django.core.context_processors.request 16. Which of these is the currect way to validate uniqueness of a field named "slug" in a form subclassing django.form.Forms. a. def clean(self): try: Post.objects.get(slug = self.cleaned_data['slug']) raise forms.Error(ValidationError, 'This slug already exists') except Post.DoesNotExist: return self.cleaned_data b. def clean(self): try: Agiliq Info Solutions India Pvt Ltd, Flat No. 302, Siri Sampada, Above Food World, Near Madhapur Police Station, Hyderabad - 500081. India Phone : 040 – 40186297 Email : hello@agiliq.com
  • 9. Post.objects.get(slug = self.cleaned_data['slug']) raise ValidationError('This slug already exists') except Post.DoesNotExist: return self.cleaned_data c. def clean_slug(self): try: Post.objects.get(slug = self.cleaned_data['slug']) raise forms.Error(ValidationError, 'This slug already exists') except Post.DoesNotExist: return self.cleaned_data d. def clean_slug(self): try: Post.objects.get(slug = self.cleaned_data['slug']) raise ValidationError('This slug already exists') except Post.DoesNotExist: return self.cleaned_data e. 17. To add custom commands to your project setup, you need to, 1. Add management/command/commandname.py to your django app. 2. Add management/command/commandname.py to your django project. 3. Add command/commandname.py to your django app. 4. Add command/commandname.py to your django project. 5. Add management/command/manage.py to yout django project. Agiliq Info Solutions India Pvt Ltd, Flat No. 302, Siri Sampada, Above Food World, Near Madhapur Police Station, Hyderabad - 500081. India Phone : 040 – 40186297 Email : hello@agiliq.com
  • 10. 18.You want to enable caching for Django pages for AnonymousUser, which of these is a valid way to do this. a. MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.middleware.cache.CacheMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', ) b. MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.cache.CacheMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', ) c. MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.cache.CacheMiddleware', ) d. MIDDLEWARE_CLASSES = ( Agiliq Info Solutions India Pvt Ltd, Flat No. 302, Siri Sampada, Above Food World, Near Madhapur Police Station, Hyderabad - 500081. India Phone : 040 – 40186297 Email : hello@agiliq.com
  • 11. 'django.middleware.cache.CacheMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', ) e. MIDDLEWARE_CLASSES = ( 'django.middleware.cache.CacheMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', ) 19. Consider the urlconf given below from django.conf.urls.defaults import * urlpatterns = patterns('news.views', (r'^articles/2003/$', 'year_archive_2003'), (r'^articles/(d{4})/', 'year_archive'), (r'^articles/2003/(d{2})/$', 'month_archive_2003'), (r'^articles/(d{4})/(d{2})/', 'month_archive'), (r'^articles/(d{4})/10/', 'month_archive_october'), ) What view is called when accessing /articles/2003/10/ a. year_archive_2003 b. year_archive c. month_archive_2003 d. month_archive e. month_archive_october Agiliq Info Solutions India Pvt Ltd, Flat No. 302, Siri Sampada, Above Food World, Near Madhapur Police Station, Hyderabad - 500081. India Phone : 040 – 40186297 Email : hello@agiliq.com
  • 12. 20. Consider the urlpatterns. urlpatterns = patterns('blogapp.views', (r'^list/(?P<year>d{4})/(?P<month>[a-z]{3})/$','archive_month'), ) Which if the following is a valid view function which will be called on accesing /list/2009/jun/ a. def archive_month(request): ... b. def archive_month(request, *args): c. def archive_month(request, **kwargs): d. def archive_month(request, year, month,): e. Both c and d # Hard None yet Agiliq Info Solutions India Pvt Ltd, Flat No. 302, Siri Sampada, Above Food World, Near Madhapur Police Station, Hyderabad - 500081. India Phone : 040 – 40186297 Email : hello@agiliq.com