contrib.auth
There is no defined behavior for the %22DO_NOTHING%22 filter in Django. This could lead to unexpected results if used in a template or view.
.db.utils.ProgrammingError: %22DO_NOTHING%22 is not defined
I'm trying to run a migration in Django, but I get the following error:
<code>django.db.utils.ProgrammingError: %22DO_NOTHING%22 is not defined</code>
The migration file looks like this:
<code># -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-08-18 13:16
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [("myapp", "0004_auto_20170818_1255")]
operations = [migrations.AlterField(model_name="mymodel", name="field1", field=models.ForeignKey(null=True, on_delete=models.DO_NOTHING, related_name="+", to="myapp"))] # noqa</code>
The model it's referring to looks like this (the field in question is <code>field1</code>) :
<code>class MyModel(models.Model):
field1 = models.... # other fields here</code> # noqa
The error is saying that the DO_NOTHING option is not defined – this is likely because it’s not supported in the version of Django you’re using. To fix this, you can either update Django to a newer version, or change the on_delete option to something else that is supported.
Solve Django ‘Handler’ is not defined
This error is caused by a missing import statement in your Django project. You can fix this by adding the following line to your project’s imports section:
from django.contrib.auth.models import User
If you’re using a third-party authentication library, you may need to add its import as well.