tags:

views:

976

answers:

1

I want to be able to place an inline inbetween two different fields in a fieldset. You can already do this with foreignkeys, I figured that inlining the class I wanted and defining it to get extra forms would do the trick, but apparently I get a:
"class x" has no ForeignKey to "class y"
error. Is this not something that is supported in Django 1.0? If so, how would I go about fixing the problem, if there isn't a pre-existing solution?

in models.py

class Place(models.Model):
    name = models.CharField(max_length=50)
    address = models.CharField(max_length=80)

class Owner(models.Model):
    name = models.CharField(max_length=100)
    place = models.ForeignKey(Place)
    background = models.TextField()
    license_expiration = models.DateTimeField('license expiration')

in admin.py

class PlaceInline(admin.TabularInline):  
    model = Place  
    extra = 5  

class OwnerAdmin(admin.ModelAdmin):  
    fieldsets = [  
        (None,    {'fields': ['background','place', 'license_expiration']}),  
    ]  
    inlines = [PlaceInline]
+2  A: 

It seems to be impossible in Django admin site itself (you should not include inlined fields in "fields" at all) but you can use JS to move inlined fields wherever you want.

ilvar