In this article, the goal is to display the information defined in the models.py file on the management screen by loading it into the admin.py file. Below, as an example, let's define only the name of the profile as a model.
apps/models.py
from django.db import models
class Profile(models.Model):
name = models.CharField(max_length=100)
I made a model called'Profile'in this way.
$ python manage.py makemigrations
make migrations is an image that creates blueprints. When you do this, it will notify you if an error is detected before it is reflected in the database.
$ python manage.py migrate
migrate is a command used to reflect in the database based on the file created by makemigrations.
apps/admin.py
from django.contrib import admin
from .models import Profile
admin.site.register(Profile)
Register the model with admin.site.register ().
Recommended Posts