how can i get username when he/she signup in django?

neha ameer

i want the username when the user signUp

class SignUp(generic.CreateView):
  form_class = UserCreationForm
  success_url = reverse_lazy('login')
  template_name = 'signup.html'

i need to access the username of the user who has been signed up .

grouchoboy

You can access the post data with request.POST. You can override the post request of the CreateView and add the specific code to do what you want with the username and then continue with the default flow of the CreateView post method/

def post(self, request, *args, **kwargs):
    username = request.POST.get('username')
    # do something with the username
    # and continue
    self.object = None
    return super().post(request, *args, **kwargs)

If you need to use the user after it has been stored in the database you could modify the create method of the serializer instead of modifying the post.

class UserCreationForm:
    def create(self, validated_data):
        user = super().create(validated_data)
        username = user.username
        # do something with the username or the user
        return user

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I get an unknown username given an ID?

How can I get an unknown username given an ID?

How can I get the username of the person executing my program?

How can I get the current user's username in Bash?

django-allauth, how can I only allow signup/login through social?

How I can get a socket.username ? (socket.io)

How can I get my API KEY on the food2fork site after signup?

How Can I Get The Username of The Last Post?

How can I enter email data during signup in Django views

Case insensitive username in Django signup form

How can I get the user's username?

How to get the plain password from the password field in the signup form in Django

How can I get the username of the loged in user on heroku console?

how do i redirect to user profiles upon signup with django

How can I get the username of the logged in user in Django?

How can I fill a field in Django with the username?

How can I give style to django-allauth login/signup default forms?

how can i get username in service context

how I can get the process username

How can I get the username from a python script run with pkexec?

How can i checking username and mail exists in Django

How can I get user by userName in GraphQL?

How can I indicate to browser which input field is the username in a signup form?

How can i get username insted of userid?

How can I get a username from django User Model

how can i add an image in the signup form

how can i get the username from API using flutter?

How can I get username and password from SharedPreferences in Android?

How can I do username in reviews on django?