Top 20 Must-Know Django & Web Dev Facts Flashcards
(20 cards)
What pattern does Django use?
Django uses the MTV pattern: Model (data), Template (UI), View (logic/controller).
What is the purpose of manage.py?
manage.py is used to run the server, make migrations, and create apps.
How do you create a new app in Django?
Use the command python manage.py startapp appname.
What do virtual environments do?
Virtual environments keep project dependencies separate.
What does settings.py contain?
settings.py contains app config, DB setup, static paths, etc.
What is the role of urls.py?
urls.py maps URLs to views.
Where is the database structure defined in Django?
Models define database structure in models.py.
What does __str__() do in Django models?
__str__() shows readable object names in the admin.
What does get_absolute_url() return?
get_absolute_url() returns a URL to an object’s detail page.
What do makemigrations and migrate do?
makemigrations creates migration files, migrate applies them.
How do you manage models in the Django admin site?
Register models in admin.py to manage them in the Django admin site.
What does Django’s ORM allow you to do?
Django’s ORM lets you query the database using Python.
What are class-based views in Django?
Class-based views (ListView, DetailView) simplify code reuse.
What is the role of HTML, CSS, and JS?
HTML = structure, CSS = design, JS = interactivity.
What do GET and POST methods do?
GET retrieves data; POST submits data (e.g. forms).
What do sessions do in Django?
Sessions store user-specific data across requests.
How do you access session data?
Use request.session.get(‘key’, default) to access sessions.
How do templates handle loops and conditions?
Templates use {% for %} and {% if %} to loop & conditionally render.
How are static files served in Django?
Static files (CSS, JS) are served using the static() helper in development.
What does it mean that Django is ‘batteries-included’?
Django is ‘batteries-included’—it comes with built-in tools like ORM, admin, routing, and auth.