Hi,
I am trying to modify a blog and article model that will both display
data from a related products model. I read that the way I should do
this is through the ContentTypes framework and generic foreign
relations. I would be grateful for some guidance on how to do this.
I've read the documentation on the
http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/
website, but I am struggling with how to relate it to what I need to
do.
I have something like this presently:
articles/models.py
---------------------------------------
class Article(models.Model):
author = models.ForeignKey(User, related_name='article_author')
headline = models.CharField(max_length=256)
publish_content = models.TextField(blank=True)
...
related_product = models.ManyToManyField('RelatedProduct', null=True,
blank=True)
class RelatedProduct(models.Model):
product_name = models.CharField(max_length=256)
product_link = models.TextField(max_length=512)
blogs/models.py
----------------------------------------
class Blog(models.Model):
name = models.CharField(max_length=128)
long_description = models.TextField()
short_description = models.TextField()
I would like to modify this so that I can have the related products
from articles also available in my Blog class and the related products
table should be the same between Article class and Blog class, i.e. I
do not want to have two instances of the RelatedProduct class.
Thank you for any help you can offer.
Rana
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---