Wednesday, September 26, 2012

Admin page not showing rows after adding a ForeignKey self to the model

Hello,

Sorry for the beginner's question, but I have a behaviour which looks like a bug to me and wanted to know if someone could advise me on this.

Error

I have added a models.ForeignKey('self', blank=True) to my model and now I cannot see any row in the admin page, even if the filter shows that there is 0 of 30 selected. Would someone know why?

In more details

I have added "related_prod = models.ForeignKey('self', blank=True)" to my product model and also added the related_prod to the admin fields list. When going into the list of products in the admin page, all products have disappeared. I can still access to the individual product by going to the specific product page (something like admin/product/3) and everything seems to work correctly here, including the new related_prod. Also, I can get the list of products in the shell by doing product.objects.all().

What I'm trying to achieve

What I'm trying to achieve is to have a related product to another one but only in one direction. For instance, I want product A referring to product B, product B referring to product C and product Z refering to product B. The usual ManyToManyField doesn't seems to work here as if I set product A referring to product B, product B will also refer to product A and this is not what I want.

Environment

I'm using Django 1.4 with the latest Satchmo e-commerce platform. I beleive the question isn't really related to Satchmo as it is very specific to Foreignkey.

Regards,
Olivier

--
Equalitea_logo

--
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