热门面试题与答案和在线测试
面向面试准备、在线测试、教程与实战练习的学习平台

通过聚焦学习路径、模拟测试和面试实战内容持续提升技能。

WithoutBook 将分主题面试题、在线练习测试、教程和对比指南整合到一个响应式学习空间中。

面试准备

Django 面试题与答案

Test your skills through the online practice test: Django Quiz Online Practice Test

问题 21. What are view functions? Can you directly import a function within the URL?

A view is a middle layer between a model and a template, and it will take the data from the model and pass it to a template. Every application in Django has the view.py file that stores view functions, and these functions take the argument and return the browser-renderable format.

You can easily import view functions in the URL file. To do so, you need to import the view function in the urls.py file and add the desired path required by the browser to call that function.

这有帮助吗? 添加评论 查看评论
 

问题 22. What is the django.shortcuts.render function?

When the webpage is returned as the HttpResponse instead of the simple string by a view function, use the render() function. This function will allow the developers to pass the data dictionary using a template. Then this function will use the templating engine for combining the template along with the data dictionary.

After that, this function will return the HttpResponse with the rendered text that is being returned by the models. In this way, this function will save a lot of time for developers and allow them to use different templating engines.

The basic render Syntax:

render(request, template_name, context=None, content_type=None, status=None, using=None)

这有帮助吗? 添加评论 查看评论
 

问题 23. How can you add view functions to the urls.py file?

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.

这有帮助吗? 添加评论 查看评论
 

问题 24. What does the urls-config file contain?

This config file stores all the URL lists and mapping to their respective view functions. These URLs can be mapped to view functions, class-based views, and url-config of another application.

The default URL list name is urlpatterns, and it contains all the path() or re_path() URL patterns. The project URL comes with the root urls.py file, and with every application, we can also make an isolated urls.py file for that application.

Example:

from django.contrib import adminfrom django.urls import path, includeurlpatterns = [    path('admin/', admin.site.urls),    path(blog/', include('blog.urls')),]

这有帮助吗? 添加评论 查看评论
 

问题 25. What does it mean to say that Django is monolithic?

Django is based on the MVT architecture, and since Django is the controller of the architecture, it has defined some rules that all developers need to follow to execute appropriate files at the right time.

In Django, you get great customizability with implementation. But you are not allowed to make changes to the file names, the predefined lists, and variable names. You have to create the new ones, but you can’t make changes to the predefined variables.

The monolithic behavior helps the developers to understand the project easily. Even if the company changes, the project layout will remain the same. Therefore, developers take less time to understand the code, increasing productivity.

这有帮助吗? 添加评论 查看评论
 

用户评价最有帮助的内容:

版权所有 © 2026,WithoutBook。