I got to generic views (CBV's) in part 4 of the Django tutorials and decided instead of overwriting the function views that I would get some practice by creating a new app (polls2). The file structure is identical to the polls app, but obviously the code is different for the generic views and urls now pointing to polls2. I ran migrate and makemigrations. The makemigrations surprised me as it created Question & Choice tables again:
(pyfun) Bruckners-MacBook-Pro:mysite brucknerdevilliers$ python manage.py makemigrations
Migrations for 'polls2':
polls2/migrations/0001_initial.py
- Create model Question
- Create model Choice
(pyfun) Bruckners-MacBook-Pro:mysite brucknerdevilliers$ python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, polls, polls2, sessions
Running migrations:
Applying polls2.0001_initial... OK
So, I looked at the folders and there is only one sqlite3 file. The Database Structure is unchanged and the original data is still intact. The admin page now displays 2 Question tables – the 2nd one contains no data. Also, http://127.0.0.1:8000/polls2/ shows No Questions available.
I have probably messed up with models.py. Any pointers please as how multiple apps can point to the same database?
Regards,
Bruckner de Villiers
+27(0)83 625 1086

No comments:
Post a Comment