https://www.youtube.com/watch?v=F5mRW0jo-U4
- python manage.py runserver
SECRET_KEYandDEBUGmodeINSTALLED_APPS(basically components of the Django project)DATABASESSTATIC-- where you see the media files, css etc.- IMPORTANT -- migrate for the DB (https://docs.djangoproject.com/en/2.2/topics/migrations/)
Appsare components of a Django project, not like the app of a phonecreatesuperuserto create a user that is the ADMINcontrib.authandcontrib.adminis the app that does this -startappto create an appAppsshould be narrow in focus
- Create an app --> write the model --> add to
appssection insettings.py makemigrations,migrations-- MUST run always when making changes tomodels.py- Register in
adminto make the products - And le voila! -- You get products in the admin page,
- Create products on the interactive shell
decimal,textetc.- Adding a new field raises questions about its value in the previous rows..
- Everytime with
migrationsyou get a new migrations file!!
- from django.http import HttpResponse
- Must route a url to a view in
urls.py - Can get
requestinfo, likerequest.user
base.html--extends base.html
- From a
viewcan 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
idfield - 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