I am trying to create a parent model for my products app and I need to 
provide the user reference. I've registered the Shop model with admin.py. 
Now I have problem that when I see in model it shows all the products 
listed before. I only intend to show products added by the shop owner. Also 
I need to register shop using built-in auth system so how do I do that, 
should I add user field in Shop or in Product. To brief in detail following 
are my models. Thanks for your kind help and apologies if as beginner i've 
missed any information or if the question isn't up to standard.

shops/models.py:

class Shop(models.Model):
    #shop_user = models.ForeignKey(settings.USER_AUTH_MODEL, blank=False, 
null=False)
    product = models.ManyToManyField(Product, related_name='myshop',null=
False, blank=True)
    Title = models.CharField(max_length=120, null=False)
    image = models.ImageField(upload_to=image_upload_to_shop, null=True)
    location = models.CharField(max_length=120)




    def __unicode__(self):
        return str(self.Title)


products/models.py:

class Product(models.Model):
    #user = models.ForeignKey(settings.USER_AUTH_MODEL)
    title = models.CharField(max_length=120)
    description = models.TextField(blank=True, null=True)
    price = models.DecimalField(decimal_places=2, max_digits=20)
    publish_date = models.DateTimeField(auto_now=False, auto_now_add=False, 
null=True, blank= True)
    expire_date = models.DateTimeField(auto_now=False, auto_now_add=False, 
null=True, blank=True)
    active = models.BooleanField(default=True)
    categories = models.ManyToManyField('Category', blank=True)
    default = models.ForeignKey('Category', related_name='default_category', 
null=True, blank=True)
    hitcounts = GenericRelation(HitCount, content_type_field='content_type', 
object_id_field='object_pk',)


   def __unicode__(self): #def __str__(self):
        return self.title


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c31416eb-37a7-40b3-98ca-a04258f46330%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to