# table django\_content\_type doesn't exists

**URL:** <https://forum.djangoproject.com/t/table-django-content-type-doesnt-exists/10544>\
**Category:** Using the ORM\
**Created:** [November 16, 2021, 8:04pm UTC](https://forum.djangoproject.com/t/table-django-content-type-doesnt-exists/10544 "2021-11-16T20:04:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![azazellooo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/azazellooo/32/5346_2.png) [@azazellooo](https://forum.djangoproject.com/u/azazellooo)\
**Post date:** [November 16, 2021, 8:04pm UTC](https://forum.djangoproject.com/t/table-django-content-type-doesnt-exists/10544/1 "2021-11-16T20:04:28Z")

</div>

I have mysql database and I want to sync it’s table with my django app’s model (only one table from db should be in usage in my app).  
I created model (with help of inspectdb {database-connection-name} {tablename}). Then I run

```auto
./manage.py makemigrations myappname
./manage.py migrate myappname --database=db-connection-name

```

But it througs ProgrammingError: table django\_content\_type doesn’t exists

I supposed it was raised because model of my app depends on django\_content\_type table (contenttypes app), so thats why I run

```auto
./manage.py migrate contenttypes --database=db-connection-name

```

But it alse raises ProgrammingError: table django\_content\_type doesn’t exists .

What should I can do?  
All I need is to sync my app’s model with existing table in db.

Please, help 🙏 🙏

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [November 16, 2021, 8:24pm UTC](https://forum.djangoproject.com/t/table-django-content-type-doesnt-exists/10544/2 "2021-11-16T20:24:17Z")

</div>

It’s not clear to me from your description what the relationship is between your app and this database.

There is no such thing as “syncing a table with a model”. A model is your “in python” representation of a table. They are not two separate entities.

If this is a pre-existing table in a database, you don’t need to use migrate to access it. You define your model with the [`db_table`](https://docs.djangoproject.com/en/3.2/ref/models/options/#db-table) set to the database table and [`managed = False`](https://docs.djangoproject.com/en/3.2/ref/models/options/#managed)

However, aside from that, Django requires a couple tables be created in a database. If you don’t want those tables created in the same database as what your model is using, see [Multiple databases](https://docs.djangoproject.com/en/3.2/topics/db/multi-db/#multiple-databases). The Django database would be the default, and the database with that external table would be a secondary database.

Either way, your first “migrate” should be without any parameters, for Django to create and initialize the tables _it_ needs to work.

---

<div class="post-metadata">

**Author:** ![azazellooo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/azazellooo/32/5346_2.png) [@azazellooo](https://forum.djangoproject.com/u/azazellooo)\
**Post date:** [November 17, 2021, 3:53am UTC](https://forum.djangoproject.com/t/table-django-content-type-doesnt-exists/10544/3 "2021-11-17T03:53:28Z")

</div>

yes, I have 2 databases - one is sqlite (default), second is mysql. I would like to get and work with table rows with help of my app (CRUD) and thats why I created model , and yes, I set db\_table and managed = False.  
before applying migrate myapp, I had applyed migrate admin, auth, sessions, contenttypes, after that all django-app tables are created in Sqlite database.  
Then I “migrate” myapp with flag --database=dbconnectionname

After that those error appiers. Or django-app tables must also be in the second database? Is it possible to not create django-app tables in second db if I “migrate” and sync myapp model to second db ?

---

<div class="post-metadata">

**Author:** ![azazellooo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/azazellooo/32/5346_2.png) [@azazellooo](https://forum.djangoproject.com/u/azazellooo)\
**Post date:** [November 17, 2021, 5:15am UTC](https://forum.djangoproject.com/t/table-django-content-type-doesnt-exists/10544/4 "2021-11-17T05:15:41Z")

</div>

I tryed to create manually ‘django\_content\_type’ table in database and applyed `migrate appname --database=dbconnectionname` and noted that this migration creates new row in table “django\_content\_type” with app\_label = ''admin".  
I supppose “django\_content\_type” is required table, but I don’t know how to avoid creating row with app\_label “admin” while doing `migrate appname --database=dbconnectionname` . Is it possible? Because in this situation another error appears "Table auth\_permissions doesn’t exists ".

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [November 17, 2021, 12:21pm UTC](https://forum.djangoproject.com/t/table-django-content-type-doesnt-exists/10544/5 "2021-11-17T12:21:10Z")

</div>

Let’s take a step back for a moment.

There are _no_ requirements to run `makemigrations` / `migrate` on your secondary database(s). (Actually, there’s no _requirement_ to use it at all - it just makes some things (a lot) easier.)

Those steps are _only_ used if you want Django to manage the database structure.

If you’re working with pre-existing tables, or table schemas that you are managing manually, that’s _not_ the case.

So none of this is necessary. Create the models (`managed = False`) and use them.  
Nothing else needs to be done.

---

<div class="post-metadata">

**Author:** ![jamaly1882](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/jamaly1882/32/11896_2.png) [@jamaly1882](https://forum.djangoproject.com/u/jamaly1882)\
**Post date:** [January 24, 2023, 12:40am UTC](https://forum.djangoproject.com/t/table-django-content-type-doesnt-exists/10544/6 "2023-01-24T00:40:49Z")

</div>

I have the same problem  
django.db.utils.ProgrammingError: (1146, “Table ‘django\_nah.my\_job\_type\_card’ doesn’t exist”)

@KenWhitesell

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [January 24, 2023, 12:44am UTC](https://forum.djangoproject.com/t/table-django-content-type-doesnt-exists/10544/7 "2023-01-24T00:44:01Z")

</div>

If you have a question about an error message that you’d like assistance with, please open up a new topic with all the details including a description of your environment, the commands that you have run, and the complete traceback from the error message you have received.
