Relative Content

Tag Archive for djangodjango-models

Django migrates data, and an error is reported during the migration, but a table appears in the database, what is going on?

I will connect to three MySQL databases, generally connect to the local database, and then test the database, and there is the online database, if I connect to the local database migration model to generate the migration data successfully, but when I connect to the online database, the field is displayed when the data is migrated (it is a failure during migration), but the corresponding table is generated in the online database, and then I use MySQL When I execute the python manage.py migrate command again, it will show that the table already exists, and it stands to reason that these generated tables will not be recognized by Django, how should this problem be solved?

Django transaction is splitted, even if I use transaction.atomic()

with transaction.atomic(): A.objects.filter( a=a, b=b, c=c, d__range=[start_date, end_date], ).delete() A.objects.bulk_create( [ A( a=a, b=b, c=c, d=d, e=e, f=f, g=g, ) for obj in objs ] ) Query is like BEGIN BEGIN DELETE FROM … COMMIT BEGIN INSERT INTO … COMMIT What I want to do BEGIN DELETE FROM … INSERT INTO COMMIT django django-models 2

Django user_auth how to foreign key one to many

What I’m looking for is that a many users can be part of a tenant, so my idea in the beginning was to foreign key from user to tenant but I can’t found how to do this. This is what I have at the moment: