{{{
ValueError: The field DJ_RegLogin.Content.category was declared with a
lazy reference to 'dj_reglogin.category', but app 'dj_reglogin' isn't
installed.
}}}
model.py (Conflict Part)
{{{
class Category(models.Model):
title = models.CharField(max_length=100, db_index=True)
slug = models.SlugField(max_length=100, db_index=True)
class Meta:
verbose_name = 'Category'
verbose_name_plural = 'Categories'
def __str__(self):
return self.title
def get_absolute_url(self):
return reverse('view_blog_category', None, kwargs={'slug':
self.slug})
class Content(models.Model):
title = models.CharField(max_length=100, unique=True)
slug = models.SlugField(max_length=100, unique=True)
body = RichTextField(config_name='default')
posted = models.DateTimeField(db_index=True, auto_now_add=True)
sites = models.ManyToManyField(Site)
ip = models.GenericIPAddressField(editable=False)
category = models.ForeignKey(Category, on_delete=models.CASCADE)
user = models.ForeignKey(User, on_delete=models.CASCADE, null=False,
blank=False, editable=False)
status = models.CharField(max_length=10, choices=STATUS_CHOICES,
default='draft')
def __str__(self):
return self.title
def get_absolute_url(self):
return reverse('view_blog_post', None, kwargs={'slug': self.slug})
}}}
settings.py (Related to issue part)
{{{
INSTALLED_APPS = [
'DJ_RegLogin',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'social_django',
'ckeditor',
'django.contrib.sites',
'django.contrib.flatpages',
'django.contrib.sitemaps',
]
}}}
apps.py
{{{
from django.apps import AppConfig
class DJ_RegLoginConfig(AppConfig):
name = 'DJ_RegLogin'
verbose_name = "Contents"
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31742>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* cc: Adam (Chainz) Johnson (added)
* stage: Unreviewed => Accepted
Comment:
Thanks for the report.
Regression in 9e1b6b8a66af4c2197e5b1b41eb9dbb36e4f6502.
Reproduced at fbe82f82555bc25dccb476c749ca062f0b522be3.
--
Ticket URL: <https://code.djangoproject.com/ticket/31742#comment:1>
Comment (by felixxm):
Potential fix:
{{{
diff --git a/django/db/models/fields/related.py
b/django/db/models/fields/related.py
index d517d7269b..894d931d50 100644
--- a/django/db/models/fields/related.py
+++ b/django/db/models/fields/related.py
@@ -582,7 +582,8 @@ class ForeignObject(RelatedField):
if self.remote_field.parent_link:
kwargs['parent_link'] = self.remote_field.parent_link
if isinstance(self.remote_field.model, str):
- kwargs['to'] = self.remote_field.model.lower()
+ app_label, model_name = self.remote_field.model.split('.')
+ kwargs['to'] = '%s.%s' % (app_label, model_name.lower())
else:
kwargs['to'] = self.remote_field.model._meta.label_lower
# If swappable is True, then see if we're actually pointing to
the target
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31742#comment:2>
Comment (by Adam (Chainz) Johnson):
That fix looks good to me.
--
Ticket URL: <https://code.djangoproject.com/ticket/31742#comment:3>
* owner: nobody => felixxm
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/31742#comment:4>
Comment (by Simon Charette):
Wonder if a longer term solution is to use case insensitive identifier for
app labels as well.
--
Ticket URL: <https://code.djangoproject.com/ticket/31742#comment:5>
Comment (by felixxm):
Replying to [comment:5 Simon Charette]:
> Wonder if a longer term solution is to use case insensitive identifier
for app labels as well.
Maybe, I'm afraid that it will create some regressions, since app labels
were always 🤔 case sensitive in migrations . This small patch should be
fine for backport.
--
Ticket URL: <https://code.djangoproject.com/ticket/31742#comment:6>
Comment (by Simon Charette):
Agreed, safer to stick to the less intrusive backport for the time being.
--
Ticket URL: <https://code.djangoproject.com/ticket/31742#comment:7>
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/13112 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/31742#comment:8>
Comment (by Adam (Chainz) Johnson):
Case insensitive app labels would make sense. PEP8 recommends lowercase
only module names, and using mixing case in filenames can be fraught with
errors between different filesystems where case sensitivity in comparisons
and naming varies widely.
--
Ticket URL: <https://code.djangoproject.com/ticket/31742#comment:9>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"62d85a283500e9abb0e1c9ec53c59be468f056a0" 62d85a2]:
{{{
#!CommitTicketReference repository=""
revision="62d85a283500e9abb0e1c9ec53c59be468f056a0"
Fixed #31742 -- Fixed makemigrations crash on ForeignKey to an app with
mixed case label.
Regression in 9e1b6b8a66af4c2197e5b1b41eb9dbb36e4f6502.
Thanks Ignacio Santolin for the report.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31742#comment:10>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"5263480d7f04ffdb845c37770680d605f1306f7c" 5263480d]:
{{{
#!CommitTicketReference repository=""
revision="5263480d7f04ffdb845c37770680d605f1306f7c"
[3.1.x] Fixed #31742 -- Fixed makemigrations crash on ForeignKey to an app
with mixed case label.
Regression in 9e1b6b8a66af4c2197e5b1b41eb9dbb36e4f6502.
Thanks Ignacio Santolin for the report.
Backport of 62d85a283500e9abb0e1c9ec53c59be468f056a0 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31742#comment:11>