python - Unable to validate my app on Django -
i reading django documentation , created first app using command:
python manage.py startapp books
and modified models.py file mentioned in book.
from django.db import models class publisher(models.model): name = models.charfield(max_length=30) address = models.charfield(max_length=50) city = models.charfield(max_length=60) state_province = models.charfield(max_length=30) country = models.charfield(max_length=50) website = models.urlfield() class author(models.model): first_name = models.charfield(max_length=30) last_name = models.charfield(max_length=40) email = models.emailfield() class book(models.model): title = models.charfield(max_length=100) authors = models.manytomanyfield(author) publisher = models.foreignkey(publisher) publication_date = models.datefield()
then added newly created app 'books' installed_apps list in settings.py file. added 'mysite.books' list , python manage.py validate returned following error:
error: no module named books.
i referred 1 of questions stackoverflow creating first app described on djangobook , tried implementing solution changing 'mysite.books' 'books'. now, when run python manage.py validate, following output:
unknown command: 'validate' type 'manage.py help' usage.
you shouldn't use 'mysite.blablabla' on installed apps. use 'books'
installed_apps = (#'mysite.books', 'books')
then type on commend line:
python manage.py makemigrations python manage.py migrate
it create model's tables on db.
in admin.py:
from django.contrib import admin .models import publisher, author, book admin.site.register(publisher) admin.site.register(author) admin.site.register(book)
type on command line create admin account:
python manage.py createsuperuser
then after filling superuser info type on command line
python manage.py runserver
finally go on browser , login: http://127.0.0.1:8000/admin
you see models on admin page. hope helps. happy coding
Comments
Post a Comment