https://www.youtube.com/watch?v=F5mRW0jo-U4
- python manage.py runserver
SECRET_KEY
andDEBUG
modeINSTALLED_APPS
(basically components of the Django project)DATABASES
STATIC
-- where you see the media files, css etc.- IMPORTANT -- migrate for the DB (https://docs.djangoproject.com/en/2.2/topics/migrations/)
Apps
are components of a Django project, not like the app of a phonecreatesuperuser
to create a user that is the ADMINcontrib.auth
andcontrib.admin
is the app that does this -startapp
to create an appApps
should be narrow in focus
- Create an app --> write the model --> add to
apps
section insettings.py
makemigrations
,migrations
-- MUST run always when making changes tomodels.py
- Register in
admin
to make the products - And le voila! -- You get products in the admin page,
- Create products on the interactive shell
decimal
,text
etc.- Adding a new field raises questions about its value in the previous rows..
- Everytime with
migrations
you get a new migrations file!!
- from django.http import HttpResponse
- Must route a url to a view in
urls.py
- Can get
request
info, likerequest.user
base.html
--extends base.html
- From a
view
can pass custom key value pairs to the template - Context variables --> the keys become the variables!
- For loop in a template -- for eg, to enumerate a list
{{forloop.counter}}
- Conditions in a template -- name variables properly!!
- back to Django shell!
- Django gives an autoincrementing
id
field - Loads a product from the DB and then sends to template ro render it out
- Can pass the entire OBJECT -- Awesome!
- Can have templates inside the sub-app