learning Django
django is all batteries included, meaning it comes with 'bloat' or rather a lot of functionalities that cover most cases. comes with auth, adming panel, sqlite database (dev DB, not for prod). etc...
works by plugging multiples 'apps' together.
each app has Urls, models and views. views are the functions that handle every request (views can return html or json), models model data to what it would look like on a database, urls map urls requests to views.
start a django project by running django-admin startproject project_name.
djangorestframework is very common in the industry for building rest APIs
TODO
- official django tutorial pt4.
- django rest framework tutorial, see installation, example and quickstart guide
most common django commands
the django app is mainly interfaced with the manage.py file
start commands with python manage.py
and then the following args are added:
- makemigration: generates migration files, that specify what changes will be executed in order for the models to be reflected accurately on the DB. this intermediate step is useful for when needing to add some more custom functionality when changing executing the migration.
- migrate: executes necessar ySQL database changes.
- startapp app_name: generates all boiler plate files for a new app
- runserver ?port ?: I think there are some more optional args
- createsuperuser: for adming panel app
URL mapping
each app has a urls.py file where I define the urls for that app.
each pattern maps an url to a view and assign a name to the pattern.
to namespace urls does it really do it automagically by just adding a app_name = "polls"
variable???