Re: Implementing django auth system with relational models

2016-08-18 Thread Shamaila Moazzam
ok thanx @ ludovic coues... i will try this and then tell you regards On Thursday, August 18, 2016 at 2:38:46 AM UTC+5, ludovic coues wrote: > > Ok, sorry, I made a off by one error on the link :) > > Try that: > > # shops/admin.py > from django.contrib import admin > from products.models im

Re: Implementing django auth system with relational models

2016-08-18 Thread ludovic coues
No idea. I've never looked into model managers. Maybe they can help in non-repeating code, maybe they won't work due to the lack of access to the currently logged user. 2016-08-18 12:55 GMT+02:00 M Hashmi : > Ludovic, > > Shouldn't she be using model managers for this? > > Just curious. > > Regard

Re: Implementing django auth system with relational models

2016-08-18 Thread M Hashmi
Ludovic, Shouldn't she be using model managers for this? Just curious. Regards, Mudassar On Wed, Aug 17, 2016 at 2:37 PM, ludovic coues wrote: > Ok, sorry, I made a off by one error on the link :) > > Try that: > > # shops/admin.py > from django.contrib import admin > from products.model

Re: Implementing django auth system with relational models

2016-08-17 Thread ludovic coues
Ok, sorry, I made a off by one error on the link :) Try that: # shops/admin.py from django.contrib import admin from products.models import Product from .models import Shop class ShopAdmin(admin.ModelAdmin): def formfield_for_manytomany(self, db_field, request, **kwargs): if db_field

Re: Implementing django auth system with relational models

2016-08-17 Thread Shamaila Moazzam
shops/admin.py from .models import Shop admin.site.register(Shop) products/admin.py from .models import Product, Variation, ProductImage, Category, ProductFeatured, color_product, size_product class ProductImageInline(admin.TabularInline): model = ProductImage extra = 0 max_num = 10 clas

Re: Implementing django auth system with relational models

2016-08-17 Thread Shamaila Moazzam
On Wednesday, August 17, 2016 at 6:37:51 PM UTC+5, Shamaila Moazzam wrote: > > Hi, > > I am a beginner and please forgive me if my question is not up to the > standard. I've got two models one is Product which is saved in db already > and another one is Shop. I am trying to related both models

Re: Implementing django auth system with relational models

2016-08-17 Thread ludovic coues
Could you share your admin.py file ? You might be interested into this part of the documentation: https://docs.djangoproject.com/en/1.10/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_foreignkey 2016-08-17 17:20 GMT+02:00 Shamaila Moazzam : > @Ludovic there is no error. Just I d

Re: Implementing django auth system with relational models

2016-08-17 Thread Shamaila Moazzam
@Ludovic there is no error. Just I don't want to get all the products pre-populated. I need empty products field and only when user uploads products then it should show me products. Please advise On Wednesday, August 17, 2016 at 6:37:51 PM UTC+5, Shamaila Moazzam wrote: > > Hi, > > I am a beginn

Re: Implementing django auth system with relational models

2016-08-17 Thread Shamaila Moazzam
@Mudassar this is exactly what I need. On Wednesday, August 17, 2016 at 6:37:51 PM UTC+5, Shamaila Moazzam wrote: > > Hi, > > I am a beginner and please forgive me if my question is not up to the > standard. I've got two models one is Product which is saved in db already > and another one is

Re: Implementing django auth system with relational models

2016-08-17 Thread M Hashmi
So what you are saying is that you don't need to get all the products instead only products uploaded by a particular user? This makes sense because you are getting the whole model called with the key so if I am getting your question right you just need to apply some sort of filter to get user relat

Re: Implementing django auth system with relational models

2016-08-17 Thread ludovic coues
Do you have any error with the code you posted ? It look like you already have a foreign key to your user. 2016-08-17 15:33 GMT+02:00 Shamaila Moazzam : > Hi, > > I am a beginner and please forgive me if my question is not up to the > standard. I've got two models one is Product which is saved in

Implementing django auth system with relational models

2016-08-17 Thread Shamaila Moazzam
Hi, I am a beginner and please forgive me if my question is not up to the standard. I've got two models one is Product which is saved in db already and another one is Shop. I am trying to related both models with following code. class Product(models.Model): user = models.ForeignKey(setting