On Tue, Mar 10, 2009 at 9:59 AM, Ramiro Morales <cra...@gmail.com> wrote:
> [...]
> I went to the relevant [2]docs:
>
> """
> If you need to create a relationship on a model that has not yet been
> defined, you can use the name of the model, rather than the model object
> itself::
>
>    class Car(models.Model):
>        manufacturer = models.ForeignKey('Manufacturer')
>        # ...
>
>    class Manufacturer(models.Model):
>        # ...
>
> Note, however, that this only refers to models in the same models.py
> file -- you cannot use a string to reference a model defined in another
> application or imported from elsewhere.
>
> Changed in Django 1.0: Refering models in other applications must
> include the application label.
>
> To refer to models defined in another application, you must instead
> explicitly specify the application label. For example, if the
> Manufacturer model above is defined in another application called
> production, you'd need to use...
> """"
>
> It seems the two last paragraphs (from "Changed in Django 1.0"
> onwards) contradict the paragraph inmediately above them.

Jacob clarified this via IRC: Currently the only scenario when we support
the target model of a a relationship located in another application being
specified in string form is when there are mutually pointing relationships
between that model and the current model (it's the way out of a circular
import trap).

This isn't what one would interpret from reading the above quoted
fragment so, I will open another (but Component=Documentation) ticket
with a patch to fix this.

>
> Supporting this usage might mean we need to insert at least one
> additional django.deb.models.get_apps() call (some of the places where
> it has already been inserted so far have associated comments describing
> doing that as a hack.)
>
> Namely, from the cases reported in the ticket and associated threads it
> seems it would need to be inserted in
>
> django.core.urlresolvers._get_urlconf_module()

Seems the solution is harder that this, and the behavior has changed
since I tested things back in March 6th. Will keep trying to wrap my head
around this, hopefully will be able to attach a patch.

> 2. 
> http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey

-- 
Ramiro Morales
http://rmorales.net

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to