Django creates a table, uses the sqlite database that comes with the Django project , and registers the table with Jdango.admin when it is created. You can manage it in the browser.
In the models.py file of the Django Project :
fromdjango.dbImportModels
# Create your models here.
classAuthor(models. Model):
name= models. Charfield (Max_length= -)
Age= models. Integerfield (default= -)
classarticle(models. Model):
title= models. Charfield (Max_length= $)
content= models. TextField ()
URL= models. Urlfield ()
Portal= models. ImageField ()
author= models. ForeignKey (Author)
Python manage.py makemigrations
Use SQLite to see if the table was actually created successfully:
Python manage.py Createsuperuser
Or
Pycharm
Run-->run manage.py task...-->syncdb
View in Browser
Add the following code to the admin.py :
from Django.contrib Import Admin
from Blog.models Import *
# Register your models here.
Admin.site.register (article)
Admin.site.register (Author)
Http://localhost:8000/admin
User name:adminstrator
Password: 0
Login Successful!
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Django Create data table