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
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/63C629FA-DB68-4CC0-989D-1D346632CD94%40gmail.com.
OK, got it. Changed polls2/views.py to “from polls.models import Choice, Question” instead of “from .models import Choice, Question”. It works, but VSCode doesn’t like “polls.model” – it gives a warning “unresolved import”.
Much obliged,
Bruckner de Villiers
083 625 1086
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
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/63C629FA-DB68-4CC0-989D-1D346632CD94%40gmail.com.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CADZv-jDYH3c%2Brx-d%2BE9C50cCkFnsb80YztQ8V1RXQ_rLEfqojg%40mail.gmail.com.