python - Addressing a user details when my consumer class has one to one relation with User model -
in application have created consumer
class keeps data in django user
class , adds other characteristics in fields create me. consumer
class connected user
in 1 one relationship. able post data.
but need search , retrieve information based on username
received in request. not able search consumer
class based on username
. please advise how achieve this.
my code given below
class consumer(models.model): user= models.onetoonefield(user) company=models.charfield(max_length=64) street1=models.charfield(max_length=64) street2=models.charfield(max_length=64) city=models.charfield(max_length=64) state=models.charfield(max_length=64) country=models.charfield(max_length=64)
i trying record below
def user_page(request, username): consumer=get_object_or_404(consumer, username=username) # locate record
i following error
cannot resolve keyword 'username' field
i tried user.username=username
well.
avoid using user.username. replace . double underscores __ try instead.
def user_page(request, username): consumer=get_object_or_404(consumer, user__username=username)
Comments
Post a Comment