Skip to content
This repository has been archived by the owner on Sep 17, 2023. It is now read-only.

02 Create your app

scotwk edited this page May 8, 2015 · 4 revisions

Make your app:

python manage.py startapp note

Modify models.py and admin.py to contain your first model.

note/models.py

class Note(models.Model):
    title = models.CharField(max_length=200)
    body = models.TextField()
    pub_date = models.DateTimeField('date published')

note/admin.py

from django.contrib import admin
from .models import Note

admin.site.register(Note)

Run manage.py to apply changes to the database:

python manage.py makemigrations note
python manage.py migrate

You can now view your new model in the admin at http://localhost:8000/admin. You can create, edit, and delete instances of your model. Try making some new notes (and editing and deleting them too).