Of course there is :
on the view which responds to your registration form (likely to be where you call authenticate) - you simply test if the username field has been set when the registration is posted - and if not set it to be whatever you want.

Or - in your custom backend you can do the same thing; basically you have code like this :

if not username:
    username = random_digits()

where random_digits is a function you write to generate your random user name/number.

Remember you will need to tell the user what number you have chosen for them.

This isn't really a Django issue to be honest - it is simply code.


On 07/05/18 07:22, lakshitha kumara wrote:

Hello Jeni

Thank you for your reply. yes i dealing with my own custom authentication backend and now i desided to use username as random number Instead of user id if username not set.

Thanks you

On Sunday, May 6, 2018 at 8:13:55 PM UTC+5:30, lakshitha kumara wrote:

    Hello guys

    Is there way to assign username same as user id if username
    passing empty value on registration form. is there way to do that.

    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 [email protected] <mailto:[email protected]>. To post to this group, send email to [email protected] <mailto:[email protected]>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a5474895-5676-449f-834f-4d3ab30594dd%40googlegroups.com <https://groups.google.com/d/msgid/django-users/a5474895-5676-449f-834f-4d3ab30594dd%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.


--
--
Anthony Flury
email : *[email protected]*
Twitter : *@TonyFlury <https://twitter.com/TonyFlury/>*

--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/521987a2-bac7-704e-24ff-0b4c550656f4%40btinternet.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to