Hi everyone,

Have run into either a bug or a lack of documentation, and wanted to
see the consensus here before posting a ticket.

When using a Model with an string foreign key (ie. for a second model
that appears after the referencing model), there's no way to make a
modelform work if it's placed before the second model.

For example,

from django.db import models
from django.forms import ModelForm

class Foo(models.Model):
        bars = models.ForeignKey('Bar')

class FooForm(ModelForm):
        class Meta:
                model = Foo

class Bar(models.Model):
        ibbity = models.CharField(max_length=255)

Will error with "AttributeError: 'str' object has no attribute
'_meta'"


However, this will work perfectly fine:

class Foo(models.Model):
        bars = models.ForeignKey('Bar')

class Bar(models.Model):
        ibbity = models.CharField(max_length=255)

class FooForm(ModelForm):
        class Meta:
                model = Foo



Why this doesn't work makes sense to me, but it seems like it's either
missing in the docs (I couldn't find anything on this effect), or a
bug (if abstracted keys are ok for Foo, that ok should carry over to
FooForm).

Thoughts?

Thanks,
Steven


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

Reply via email to