
Django Templates
Template syntax, variables, filters, tags, template inheritance, includes, context processors
1How to display a variable's value in a Django template?
How to display a variable's value in a Django template?
Câu trả lời
Double curly braces {{ variable }} are used to display the value of a variable passed to the template context. Django automatically escapes HTML to prevent XSS attacks. The variable name must exactly match a key in the context dictionary provided by the view.
2What is the role of template tags in Django?
What is the role of template tags in Django?
Câu trả lời
Template tags allow executing logic in templates: loops, conditions, including other templates, and more. They use the {% tag %} syntax and some require a closing tag like {% endfor %} or {% endif %}. They provide programming power while maintaining separation between business logic and presentation.
3How to use the {% for %} tag to iterate over a list of objects?
How to use the {% for %} tag to iterate over a list of objects?
Câu trả lời
The {% for item in list %} syntax allows iterating over each element in a list. Inside the block, the item variable contains the current element. The {% endfor %} tag marks the loop's end. Django also provides special variables like forloop.counter, forloop.first, and forloop.last for iteration logic.
Which filter converts text to uppercase in a Django template?
How does template inheritance work with {% extends %}?
+15 câu hỏi phỏng vấn
Các chủ đề phỏng vấn Django khác
Python Basics
Python OOP
Django Fundamentals
Django Models - Basics
Django Views
Django Forms
Advanced QuerySets
Django Authentication
Django Middleware
Django Admin
Django REST Framework
Django Signals
File Upload
Django Caching
Django Sessions
Django Email
Django Testing
Django Security
Django Deployment
Advanced Django ORM
Django Performance
Django & Celery
Django Channels
Django & GraphQL
Django & Docker
Django in Microservices Ecosystem
Custom Django Commands
Django Internationalization
Django Design Patterns
Django Async & ASGI
Settings & Production Configuration
Observability & Monitoring
Nắm vững Django cho lần phỏng vấn tiếp theo
Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.
Bắt đầu miễn phí