Hi all,

I try to build a django powered web application which deals with
several entities in the database.
There is one table - call it A -, which is referenced from several
other tables via ForeignKey "fields".
I managed to show the content of the referenced table as an inline,
but as soon as i show the inline in another ModelAdmin, I get the
error, that the table A has no ForeignKey to it's parent model.
There is no need in the database, to create the backwards link from
Adresses to all other relations, that aggregate an adress in A, but
will I have to do this for django?

BTW. I use django 1.4

Thanks in advance four your comments on this,
I attach a small example which shows the error:

<=== models.py ===>
from django.db import models

# Create your models here.

class Servant(models.Model):
        name            = models.CharField( max_length=64 )
        master          = models.ForeignKey( 'Master' )
        god                     = models.BooleanField()
        def __unicode__(self):
                return self.name

class Tools(models.Model):
        name            = models.CharField( max_length=64 )
        owner           = models.ForeignKey( 'Master' )
        whohasit        = models.ForeignKey( 'Servant' )
        def __unicode__(self):
                return self.name

class Master(models.Model):
        name            = models.CharField( max_length=64 )
        # servants      = models.ForeignKey( 'Servant' )
        def __unicode__(self):
                return self.name

<=== admin.py ===>
from mytest.models import *
from django.contrib import admin

class ServantInline(admin.TabularInline):
        model   = Servant
        extra   = 1

class ToolInline(admin.TabularInline):
        model   = Tools

class MasterAdmin(admin.ModelAdmin):
        inlines = [ ServantInline, ToolInline ]

admin.site.register(Master, MasterAdmin)

# these last four lines break the code:
class ToolsAdmin(admin.ModelAdmin):
        inlines = [ ServantInline ]

admin.site.register(Tools, ToolsAdmin)
<=== end of code ===>

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

Reply via email to