here ya go:
class InventoryOption (models.Model): id = models.AutoField (primary_key=True) name = models.CharField (max_length=50, blank=False, db_index=True) active = models.IntegerField(blank=False, choices=active_choices) order = models.IntegerField(blank=True, default=0) class InventoryOptionAdmin(admin.ModelAdmin): list_display = ('name','active','order',) search_fields = ['name'] admin.site.register(InventoryOption,InventoryOptionAdmin) class Inventory (models.Model): id = models.AutoField (primary_key=True) Barcode = models.IntegerField(blank=False) Location = models.CharField (max_length=25,blank=False, db_index=True) Sku = models.CharField (max_length=25,blank=False, db_index=True) Quantity = models.DecimalField (blank=False, max_digits=7, default=0,decimal_places=2,help_text='Quanity on barcode') InventoryFunction = models.ForeignKey('AppSettings.InventoryOption', verbose_name=_('InvFunction'), related_name='inv_function',blank=False, null=False) LastTouchedBy = models.ForeignKey(User, unique=False, db_index=True, blank=False) LastUpdated = models.DateTimeField (auto_now_add=True,blank=False, db_index=True,help_text='Auto Filled') @property def touched_by_name(self): return self.LastTouchedBy.get_full_name() @property def inventory_option_name(self): return self.AppSettings.InventoryOption.name class InventoryAdmin(admin.ModelAdmin): list_display = ('Barcode','Sku','Location','inventory_option_name','LastUpdated','touched_by_name',) search_fields = ['Barcode','Location','Sku','LastTouchedBy'] readonly_fields = ['Barcode','Location','Sku','Quantity','InventoryFunction','LastTouchedBy','LastUpdated'] admin.site.register(Inventory,InventoryAdmin) On Feb 3, 8:59 am, Tom Evans <tevans...@googlemail.com> wrote: > On Thu, Feb 3, 2011 at 1:32 PM, Bobby Roberts <tchend...@gmail.com> wrote: > > I'm setting up a foreignkey field in my model as follows: > > > InventoryFunction = > > models.ForeignKey('AppSettings.InventoryOption', > > verbose_name=_('InvFunction'), related_name='InvFunction',blank=False, > > null=False) > > > result from syncdb: > > > scanning.inventory: Accessor for field 'InventoryFunction' clashes > > with related field 'InventoryOption.InvFunction'. Add a related_name > > argument to the definition for 'InventoryFunction'. > > scanning.inventory: Reverse query name for field 'InventoryFunction' > > clashes with related field 'InventoryOption.InvFunction'. Add a > > related_name argument to the definition for 'InventoryFunction'. > > scanning.inventoryhistory: Accessor for field 'InventoryFunction' > > clashes with related field 'InventoryOption.InvFunction'. Add a > > related_name argument to the definition for 'InventoryFunction'. > > scanning.inventoryhistory: Reverse query name for field > > 'InventoryFunction' clashes with related field > > 'InventoryOption.InvFunction'. Add a related_name argument to the > > definition for 'InventoryFunction'. > > > why am i getting these errors when i do have related_name argument > > setup? > > Impossible to tell, since you have omitted half the story. Where is > the definition of InventoryOption, which apparently already has a > field called InvFunction? > > Cheers > > Tom -- 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.