Tuesday, October 4, 2011

Cannot get django admin's inlines to work

I get <class 'locations.models.Location'> has no ForeignKey to <class
'theater.models.Theater'> each time I try to edit Theater model. I saw
multi-table-inheritance[1] approach but interesting in this one w/o
inheritance. Could you bring an idea how to get Theater's form with
Location model within it?

Code looks like below:

class Location(models.Model):
latitude = models.FloatField()
longitude = models.FloatField()

class Theater(models.Model):
location = models.OneToOneField(Location, related_name="theater")

class LocationInline(admin.StackedInline):
model = Location
can_delete = False

class TheaterAdmin(admin.ModelAdmin):
inlines = [ LocationInline, ]

Thank you!

[1] https://docs.djangoproject.com/en/dev/topics/db/models/#multi-table-inheritance

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment