Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Django Interview Questions and Answers

Question: How can you add view functions to the urls.py file?
Answer:

The following are the two methods for adding view functions to the urls.py file:

  • By adding the function view: Using this method, you need to import the view as a function. You import the function from the specific view and then add the URL to the urlpattern list.
  • By adding the class-based view: This is an object-oriented approach where you import the class from the views.py file and later add the URL to the urlpattern lists. For this, you will require an inbuilt method for calling the class as a view.
Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook