Sunday, June 27, 2021

Re: user profile in Django

You can use the user model, do something like that
class user_register(models.Model):        user = models.OneToOneField(User,on_delete=models.CASCADE)        join_date = models.DateTimeField(default=timezone.now)
To view the user profile, you can do something like this.

def user_profile(request, username):      user = User.objects.get(username=username)      context = {         "user": user      }          return render(request, 'profile.html', context)  
profile.html

{{user.username}}
{{user.first_name}}


On Mon, Jun 28, 2021 at 2:43 AM Samir Areh <samrehonline03@gmail.com> wrote:
Hello
I'm new to django. i want to create a user profile. I want to know the best way to do this. thanks 

--
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/f84c5af2-12f1-41d3-9002-f0bc96f0371fn%40googlegroups.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/CAPCf-y6cWAGpoS8GsxjZuAFQ2tp8aJy0Qj-38YvqHGdm3vEeYg%40mail.gmail.com.

No comments:

Post a Comment