Multiple Apps can point to one database.

What happens is that django creates different tables in the database.

It uses this format to create the tables

'appname_modelname'

e.g.  polls_question


Infact, if you  remember earlier on before runnung your first "python
manage.py migrate".  Django told you that you had "unapplied migrations"

When you applied the migrations you might have noticed some other tables
were created in the database. Tables like auth, session, admin, etc



On Wed, 11 Dec 2019, 10:52 am Bruckner de Villiers, <
bruckner.devilli...@gmail.com> wrote:

> 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
>
> --
> 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+unsubscr...@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
> <https://groups.google.com/d/msgid/django-users/63C629FA-DB68-4CC0-989D-1D346632CD94%40gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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+unsubscr...@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.

Reply via email to