Bryan Veloso skrev: (I am only commenting on the model (database and Django) in this post - I don't really know enough about imports to help you with that bit)
> I have 2 models for an MMORPG control panel I'm building. Each set of > data is within it's own app with related models, etc. So here's my > example. It's run off an existing database so I really can't change > any of the database fields. > It seems some of the tables are not normalized (see below). Are they set in stone? > I have a Character model that imports the Guild model. > > class Character(models.Model): > char_id = models.IntegerField('Character ID', > primary_key=True) > account = models.ForeignKey(Account, unique=True, > db_column='account_id') > char_num = models.IntegerField('Character Slot') > name = models.CharField('Name', maxlength=90) > guild = models.ForeignKey('Guild', > db_column='guild_id') <<<< As far as I can see, this account = models.ForeignKey(Account, unique=True, db_column='account_id') is equivalent to account = models.OneToOneField(Account, db_column='account_id' ) but with a simpler interface ("account.character" rather than "account.character_set.all()[0]". You might want to consider this change - although it might be a bad idea if you envision multiple characters per account int he future. > But the app that contains Guild has another model that is linked to > the Character model. > > class GuildMember(models.Model): > guild = models.ForeignKey(Guild, > db_column='guild_id', unique=True, primary_key=True) > account = models.ForeignKey(Account, > db_column='account_id', unique=True) > character = models.ForeignKey(Character, > db_column='char_id', unique=True) <<<< > The use of "unique=True" here looks wrong. As written, a Guild has at most one Character, and a Character has at most one Guild. Is this really what you want? If so you might again consider using two OneToOneFields. But I suspect you really mean 'unique_together (('guild'),('character')). Anyway, the database design looks quite bad ... the "account" field in GuildMember seems redundant (assuming it points to the account of the character). It is not clear whether Character.guild corresponds to Character.guildmember_set()[0].guild - if they are always the same, the table structure is not normalized. I guess the root cause of your problems is that you cannot easily model a ManyToMany relationship between models in different apps. As Malcolm suggests, the solution is probably to not have two apps. Nis --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---