Hi,

given the following models and model form I get the error in the subject, 
apparently because the related model "roomsetup" is defined *after* the 
"RoomsForm" form and is not loaded at the time the form is created.

class rooms(models.Model):
    [.... lots of other fields]
    *room_setup* = models.ForeignKey('roomsetup', verbose_name='Room 
setup', blank=False, default='')

    def __unicode__(self):
        return self.name


class RoomsForm(ModelForm):
    class Meta:
        model = rooms
        fields = ('active', 'location', 'level', *'room_setup'*, 'name', 
'daylight', 'area', 'height', 'notes',)

.... other models and forms...

class roomsetup(models.Model):
    [....lots of fields]

    def __unicode__(self):
        return self.name

If I move the RoomsForm declaration *below* the room setup class, 
everything works fine, but I would like to keep the model and its 
associated form together in my code (this makes sense?).

So is there another  way how can I avoid this situation?

Thanks 
Thomas 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" 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].
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to