Django 3.1.7 Model ManyToMany TiDB Database: Unable to Generate Data Tables Correctly

This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: django3.1.7 model ManyToMany tidb数据库,无法正确生成数据表

| username: TiDBer_lkP2aoJP

To improve efficiency, please provide the following information. A clear problem description can help resolve the issue faster:

[Overview] Python 3.8.3, Django 3.1.7, ManyToMany model, TiDB database, unable to correctly generate data tables

[Application Framework and Development Adaptation Business Logic]
Django 3.1.7 model defines a many-to-many relationship table, but an error occurs during migration

[Background] Operations performed

[Phenomenon] Business and database phenomena

[Problem] Current issue encountered

[Business Impact]

[TiDB Version]

[Attachments] Relevant logs and monitoring

| username: wd0517 | Original post link

There is no Django 3.8 version, please provide the correct version.

TiDB has developed an adapter django-tidb for Django, which currently supports Django 3.2, 4.1, and 4.2 versions.

django django-tidb install command
v4.2.x v4.2.x pip install 'django-tidb>=4.2.0,<4.3.0'
v4.1.x v4.1.x pip install 'django-tidb>=4.1.0,<4.2.0'
v3.2.x v3.2.x pip install 'django-tidb>=3.2.0,<3.3.0'
| username: TiDBer_lkP2aoJP | Original post link

Python 3.8.3, Django version is 3.1.7

| username: wd0517 | Original post link

Can the Django version be upgraded? Django 3.1 stopped being maintained at the end of 2021. Is this a new project?

| username: TiDBer_lkP2aoJP | Original post link

In the short term, it’s not feasible. The project is about to be delivered, and I’m not confident about upgrading the Django version.

| username: wd0517 | Original post link

What error did it report? Is it related to foreign keys? Post the error message so we can take a look. Is settings.DATABASES.ENGINE set to django.db.backends.mysql?

| username: cassblanca | Original post link

It’s about to be delivered, and we just discovered the problem. QA should be held accountable, and the developers are going to get scolded. It seems we can only upgrade. A minor version upgrade shouldn’t be a big issue. Feel free to try it.

| username: TiDBer_lkP2aoJP | Original post link


| username: TiDBer_lkP2aoJP | Original post link

It’s not that serious. We’ve adapted to DM, Kingbase, and Shentong databases, and now the client doesn’t want to buy them and wants to use TiDB instead. :joy:

| username: wd0517 | Original post link

This information is not enough to determine the cause of the problem. It would be helpful to provide a minimal reproducible scenario, including model definition and migration steps.

| username: ShawnYan | Original post link

Error 1072 is a MySQL error indicating that a column does not exist. What is this column assi_id? Is it an issue with the table definition?

Temporary solution: Manually execute the DDL to skip the framework migration step.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.