Django Flashcards
What does Django emphasize?
Emphasizes the use of individual apps, each of which has its own MTV structure
What is an MTV framework?
Model Template View - Which describes the division of labor in Django.
What is Model in more detail?
Model: builds database tables and handle all interaction with the database.
What is template?
Served in their complete form to the client. Django’s templating allows us to perform some logic and inject data into our HTML documents
What is view?
The views document is somewhat confusingly named, but can be thought of as managing traffic. It is the view’s job to get the right data for the right route delivered in the right form. Views handle the data we deliver to the user to view.
What is the MTV vs MVC framework
Django:
Model - Builds database tables and handles logic that relies on data.
Template - HTML page that gets served to the client
View - Deals with aggregating data that should be returned as part of a template.
MVC:
Model - Builds database tables and may or may not contain some logic
View - HTML page that gets served to the client
Controller - May contain some logic. Receives incoming requests and sends collected data back as part of a template.
What is something to always keep in mind when you are working with building a web application?
You are really working to do something with an http request
Where are all the settings for a project stored and modified?
In Django, this file is called settings.py and this is where you can adjust some security settings, middleware used for the project, etc.
What is urls.py?
URLS.py is the master routing file
List the steps to get a django going
1) virtualenv djangoEnv
2) source djangoEnv/bin/activate
3) pip install Django
4) go to the folder or place you want to create a project
5) django-admin startproject projectname
6) mkdir in the main folder to make an apps directory
7) cd apps to go to the apps
8) touch __init__.py, this allows python interpreter to know that this folder is present and may be accessed. Other python modules can look in this directory and access the files and therefore the code they contain.
9) the manage.py file can be called using one of serverl commands to request a specific operation.
python ../manage.py startapp first_app
10) go to the settings.py which lives inside the main directory, update the installed_apps section.
After an http request goes through settings, where does it go next?
URLs.py