Sunday, July 28, 2019

Re: Django inbuilt Model

Hi Soumen,

You could try with 
profiles = Profile.objects.filter(user__username=username)  

I would also suggest changing your model definition to something like
class Profile(models.Model):      user = models.OneToOneField(User, on_delete=models.CASCADE)  
Then you will have exactly one Profile per User and you can also access the Profile from user object with 
user.profile  
FYI, related_name defines the name of reverse relation. So in your case it would mean you can access the profile from a user object with
user.user_model  
Which is probably not what you want..

-Juhana

On Sun, Jul 28, 2019 at 7:49 PM Soumen Khatua <soumenkhatua258@gmail.com> wrote:
Hi Folks,
I Extended Profile Model from dajngo inbuilt User model but Now I want call all the details those are associated with Username in Profile model. I got the username but how i cann call it in Profile model.

Ex:
class Profile(models.Model):
user = models.ForeignKey(User,related_name = 'user_model,..........)

data = Profile.objects.filter(user = username)

But it's not working please help me guys.

Thank You

Regards,
Soumen

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPUw6WY%2BUNTU6UOAKyOxMWg24dAsmc7eB7%3D9kZTDjiukn3%2BKJQ%40mail.gmail.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CABScFx851WQseNsCYf%3DYdW6eAYiPW05EQg-qEk%2B%2BTSZNVAXGuQ%40mail.gmail.com.

No comments:

Post a Comment