#24547: Errors for paths for Model relationships in other apps can be
misleading /
confusing
--------------------------------------+------------------------------------
Reporter: akulakov | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Migrations | Version: master
Severity: Normal | Keywords: error message, warning
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
If a user is creating a relationship to a model in another app, it would
be natural to use a path like: ForeignKey('app2.models.Model2'). This is
consistent with e.g. urlconf where views are referenced like
'myapp.views.my_view', or generally django imports that use dots to
separate elements of a full path.
The error you would get looks like this:
app2.M1.f3: (fields.E300) Field defines a relation with model
'app3.models.M1', which is either not installed, or is abstract.
It might seem like it's not a big deal -- user just has to look at the
docs or google for the error.
However, in some cases it may lead to some loss of time, for example I had
circular foreign key dependencies between models for testing and thought
the error is due to circular references. More generally, django errors can
result from seemingly unrelated causes so if a user starts with a firm
assumption that a full path needs to be given, the error might lead them
to look for all kinds of workarounds to try before coming back to the path
format.
It would be easy for django to check the path and, if there are more than
one dot in path, and specifically if '.models.' is included in path, a
hint should be shown along with the error:
> NOTE: path should be of the form 'myapp.MyModel' and should NOT include
the name of module containing models (which is usually 'models').
--
Ticket URL: <https://code.djangoproject.com/ticket/24547>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/051.528d460b3b31a576d10f4f45e2ed2ef8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.