Django has several parts:
1. root and apps
Through manage.py use startnewapp to create a new app. Take 'startnewapp polls' for example, this creates a new app in the site's directory and automatically creates SQL commands used by Django, where you run 'migrate' to commit those commands to your database if database is what you'll be using.
On the other hand, setting.py contains some settings you may want to modify in the beginning, such as time zone and register app name and allowed hosts and etc.
And there is urls.py. You should firstly create a urls.py in the app's folder and configure and use 'include' from django.urls to register the urls.py you created manually. ( path('appname', include(('appname.urls','appname'))) )
2.Database
Django has a built-in admin site which admins the databases, run manage.py createsuperuser to create a administrator
While using a database though, whenever you create a new Model in 'app/model.py', you need to run manage.py makemigratitons appname then migrate to the database.
from django.db import models
# Create your models here.
class Question(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField('date punished')
class Choice(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
For each model, use ModelName.objects.all() or ModelName.objects.get(id=1) to get object, and the keys of the gotten objects can be modified directly, then use save() to confirm changes.