95👍
When I encountered this problem, it turned out to be because I had added fields to a model, and forgotten to makemigrations
and migrate
.
Normally you get a warning from Django when this is the case, but for some reason I wasn’t getting one.
10👍
In my case, it’s happen in a production system with PostgreSQL and all migrations done.
Set DISABLE_SERVER_SIDE_CURSORS at True fix my errors :
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'USER': 'db_user',
'NAME': 'db_name',
'DISABLE_SERVER_SIDE_CURSORS': True, # <------ Only for PostgreSQL
},
}
- [Django]-Track the number of "page views" or "hits" of an object?
- [Django]-TransactionManagementError "You can't execute queries until the end of the 'atomic' block" while using signals, but only during Unit Testing
- [Django]-Coverage.py warning: No data was collected. (no-data-collected)
3👍
I faced the same issue when I messed with getting it possible to use unmanaged (with managed = False
in model’s Meta
) models in Django unittests.
The solution was to make the models managed when unittests are executed.
To achieve this, I had to apply changes in migration, like this:
migrations.CreateModel(
name='UmnamagedModelName',
fields=[
('uuid', models.TextField(primary_key=True, serialize=False)),
# ...
('csms_updated', models.NullBooleanField()),
],
options={
'db_table': 'umnamage_table_name',
'managed': running_tests(), # <= this function returns True when running tests
},
),
- [Django]-Generating a Random Hex Color in Python
- [Django]-WARNING: Running pip as the 'root' user
- [Django]-Django model field by variable
0👍
I’ve just run into this problem with Django 2.2.28 and it turns out I had an incorrectly named my migration file with a .py.py
extension. Correcting that enabled the tests to run through smoothly.
- [Django]-How to add a new field to a model with new Django migrations?
- [Django]-Multiple ModelAdmins/views for same model in Django admin
- [Django]-Django template and the locals trick