-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Manage ForeignKey from Abstract #13
Comments
Hi, this is probably a Django bug. class AbstractModelG(models.Model):
field = models.ForeignKey('ReferencedModelG', on_delete=models.CASCADE)
class Meta:
abstract = True
class RealModelG(AbstractModelG):
other_field = models.CharField(max_length=100)
class ReferencedModelG(models.Model):
field = models.FloatField() with class RealModelG(models.Model):
field = models.ForeignKey('ReferencedModelG', on_delete=models.CASCADE)
other_field = models.CharField(max_length=100)
class ReferencedModelG(models.Model):
field = models.FloatField() Your error reproduces here under py2+django1.11: It tries to read def get_relation_target_field(rel_field):
print(rel_field.related_model)
... you'll see that everything here is a model class, except the failing case, which is still an unresolved string. Another workaround is avoiding textual names: class ReferencedModelG(models.Model):
field = models.FloatField()
class AbstractModelG(models.Model):
# magically works
field = models.ForeignKey(ReferencedModelG, on_delete=models.CASCADE)
class Meta:
abstract = True |
Reported this to django: https://code.djangoproject.com/ticket/29466 |
thanks |
Hi,
I've model like this
with django 11 get_relation_target_field() in utils.py raises exception
This is labelled as # 1.8 compat, so I think someting wrong in previus
PS django-extensions fails too,
The text was updated successfully, but these errors were encountered: