Learn Django - Build a Custom User Model with Extended Fields

  Рет қаралды 95,795

Very Academy

Very Academy

Күн бұрын

Another Django tutorial, here we are building a custom user model, as more often than not the default Django model wont meet our project needs. This tutorial will take you through building a model manager, building a new user model with extended fields and then show you how to customise the Django admin interface and finally perform some testing the model.
Introduction
====
00:00 Introduction
02:00 Package/Software overview
03:45 Command file
Developing the new model
====
03:59 User model development
05:12 Translation
08:12 AbstracBaseUser
09:20 Required Fields
11:02 PermissionsMixin
12:05 BaseUserManager
12:43 Building the custom model manager - create_user
14:48 Building the custom model manager - create_superuser
17:52 Letting Django know about our new custom user model
Django Admin:
====
21:42 Customising the Django Admin interface
Testing:
====
27:04 Start testing - install coverage
29:28 Start building tests
Code Repository:
github.com/veryacademy/YT-Dja...
SUBSCRIBE to get more free tutorials, courses and code snippets!
/ @veryacademy
Follow us on Facebook
/ veryacademycom-1132321...
Follow use on Twitter:
/ veryacademy

Пікірлер: 166
@syedibrahimbukhari7837
@syedibrahimbukhari7837 2 жыл бұрын
After following and failing at implementing the code form all the other tutorials, your tutorial was really simple, understandable and best of all it worked
@veryacademy
@veryacademy 2 жыл бұрын
Great to hear!
@daidensacha
@daidensacha 2 жыл бұрын
Thanks for the brilliant tutorial. It was exactly what I was looking for, clear, concise, detailed.
@kellystephen1785
@kellystephen1785 3 жыл бұрын
Your Django tutorials are the most detailed tutorials I have seen on KZbin. Thanks for sharing
@veryacademy
@veryacademy 3 жыл бұрын
Thank you, we have a few more gears to go through so please stick around for more detailed and hopefully better quality tutorials
@victormungai
@victormungai 3 жыл бұрын
@@veryacademy You can be sure I will... If the internet was coming down... I'd find a way to scrap your videos first
@SmokeInYourScreen
@SmokeInYourScreen 3 жыл бұрын
I have been looking everywhere for a custom user tutorial. This is really amazing!
@veryacademy
@veryacademy 3 жыл бұрын
Glad you like it!
@h.nazmulhassanrakib5058
@h.nazmulhassanrakib5058 2 жыл бұрын
same to you
@karovda
@karovda 3 жыл бұрын
Everyone has already said this but this is A+ quality. Truly well done!
@veryacademy
@veryacademy 3 жыл бұрын
Thank you, always appreciative. It is exciting because this is not that good - over time much more to come.
@srinivasasowmiyan2272
@srinivasasowmiyan2272 2 жыл бұрын
Thanks for the great work you have put in🙂 Happy that I found your channel 💖
@pgallovich
@pgallovich 3 жыл бұрын
I'm so happy I found this channel. Awesome content! Thank you!
@veryacademy
@veryacademy 3 жыл бұрын
Welcome! Enjoy, any question, if I get time I will happily try and help
@aashayamballi
@aashayamballi 3 жыл бұрын
Custom user model and testing it. This channel is ❤️ 🤓 Thank you 🙏🏼
@veryacademy
@veryacademy 3 жыл бұрын
Seems like a good way to introduce more testing!
@jithinrajmmwayanad4267
@jithinrajmmwayanad4267 2 жыл бұрын
thank you sir evey line is perfectly explained , no words to convey my happiness after grabbing the depth concept
@yasayah7289
@yasayah7289 2 жыл бұрын
Thank you! A 2nd part would be nice, along with admin approval before users can login.
@AHabib1080
@AHabib1080 2 жыл бұрын
Best best best. Thank you sir for making the perfect tutorial that I was looking for.
@yashmore3525
@yashmore3525 3 жыл бұрын
Great tutorial! Waiting for the others!
@wilez493
@wilez493 3 жыл бұрын
You're just the best! gave a like but you deserve more so i subscribed! Thank you and keep it up!!
@veryacademy
@veryacademy 3 жыл бұрын
Thanks William, will try not to let you down 👍 Thanks for the sub
@victormungai
@victormungai 3 жыл бұрын
watching this is just satisfying by itself... Thanks. This tutorial has expanded my thinking.
@veryacademy
@veryacademy 3 жыл бұрын
Thank you Victor for watching so intently.
@CrossMax122
@CrossMax122 3 жыл бұрын
Great Video! I would love, however some follow up video with login/register templates! Of course liked and subscribed :)
@geoafrikana
@geoafrikana Жыл бұрын
This is a superbly done tutorial. Thanks so much.
2 жыл бұрын
Many, many thanks for that! Awesome tutorial!
@veryacademy
@veryacademy 2 жыл бұрын
Glad it was helpful!
@stanycastillo
@stanycastillo 2 жыл бұрын
Great tutorial. Thank you for sharing this valuable information. Regards
@HermannWinter
@HermannWinter Жыл бұрын
Thank you for this tutortial, did not know about the coverage package. 👍
@ayman4047
@ayman4047 Жыл бұрын
you are an artist by instinct
@mgultas
@mgultas Жыл бұрын
This tutorial helped me a lot. Thank you, thank you, thank you.
@veryacademy
@veryacademy Жыл бұрын
Glad it helped! Thank you for the support!
@abdulrehmansohail2384
@abdulrehmansohail2384 2 жыл бұрын
Thanks for Saving my Job
@berk_karaal
@berk_karaal 2 жыл бұрын
Great tutorial, thanks !
@bakhodirrakhmatullayev1903
@bakhodirrakhmatullayev1903 Жыл бұрын
The great job, You saved my life😁
@Chocolanay
@Chocolanay 3 жыл бұрын
nice video bro. Very well explained.
@veryacademy
@veryacademy 3 жыл бұрын
Glad you liked it
@austinhomolka
@austinhomolka 2 жыл бұрын
Great video. Thank you!
@gagandangol467
@gagandangol467 3 жыл бұрын
thank you for these videos,
@veryacademy
@veryacademy 3 жыл бұрын
Thank you Gagan for the positive feedback!
@Desabilitador
@Desabilitador 3 жыл бұрын
Great one!
@veryacademy
@veryacademy 3 жыл бұрын
Thanks João, just keep reminding me if I am getting slack with any of the series that you are watching and need more. I have quite a few on the go!
@konstantingribanov7197
@konstantingribanov7197 2 жыл бұрын
just brilliant! especially about the tests in the end, very useful. If I can ask you a question why you are using an AbstractBaseUser instead of AbstractUser?
@veryacademy
@veryacademy 2 жыл бұрын
This might help: stackoverflow.com/questions/21514354/difference-between-abstractuser-and-abstractbaseuser-in-django
@yasinfakhar9091
@yasinfakhar9091 2 жыл бұрын
you are great man
@ce.joseph
@ce.joseph 11 ай бұрын
Very briliant tutorial Xander. I learnt a lot. How can we use the default auth forms with this custom user
@karnashubham2698
@karnashubham2698 3 жыл бұрын
Hello good sir. First of all, thankyou very much for this informative video, its been a great help. The one thing I'd like to ask is, how could i set the username as username instead of email as username for superuser login?
@rahulkmail
@rahulkmail 2 жыл бұрын
Excellent
@veryacademy
@veryacademy 2 жыл бұрын
Thank you! Cheers!
@kifaru.
@kifaru. 7 ай бұрын
Thanks very much for this wonderful tutorial, I really learnt a lot. I have a question. How do i add the groups and the user permission section in the admin panel?. I realise that the custom AdminUser did not add them. Thanks. I know this reply is 3 years late
@phaniophrero8007
@phaniophrero8007 2 жыл бұрын
Thanks a lot for this tutorial , but I have a question though do you have a tutorial that kind of continues this with sending the email verification , password reset and resend email verification ? I've been following the django-graphql-auth tutorial too , but there I can't customize the register mutation like to have whatever field I want and still to be able to use their functionality of sending email verification, password resets and all of that good things... Do you have some video on that ?
@254_Cyrus
@254_Cyrus 2 жыл бұрын
Hello thanks again for the tutorial Very Academy. Just a quick question, my frontend allows Google and Twitter Sign In's. How can I make the password field nullable when say custommodel.usertype == 'Google'. Meaning when user signs in with Google in the FrontEnd we don't need to store a password for that user. Tried reading the docs but couldn't quite understand how to go about it. Will really appreciate your help. Thanks for the tutorials, keep em coming.
@TK-tg1hx
@TK-tg1hx Жыл бұрын
Thank you sooooooooooooo much!!!!!!!!!!!!!!
@ricosun
@ricosun 2 жыл бұрын
Great Tute!
@veryacademy
@veryacademy 2 жыл бұрын
👍
@anthonychianain2241
@anthonychianain2241 Жыл бұрын
Thanks so much
@jhoanmartinezsilva2609
@jhoanmartinezsilva2609 3 жыл бұрын
Just a huge thank you
@veryacademy
@veryacademy 3 жыл бұрын
No problem
@KrishnaManohar8021
@KrishnaManohar8021 3 жыл бұрын
The sound was good! Implement Token Based Authentication also(Start Django-Rest-Framework(DRF) series)!?
@veryacademy
@veryacademy 3 жыл бұрын
On the way
@josevelez6865
@josevelez6865 3 жыл бұрын
I have seen some code examples for custom user models where in the creation of a custom BaseUserManager class, instead of user.save(), they use user.save(using = self._db). Do you know what that is? I can't find anything in the Django docs about it.
@veryacademy
@veryacademy 3 жыл бұрын
stackoverflow.com/questions/57667334/what-is-the-value-of-self-db-by-default-in-django
@shalomirewole-ojo5335
@shalomirewole-ojo5335 3 жыл бұрын
Please what about the video that deals with linking to this CustomUser model. The signal and AUTH_USER_MODEL stuff?
@ivayloivanov3744
@ivayloivanov3744 3 жыл бұрын
Better than some of these paid tutorials! gj
@veryacademy
@veryacademy 3 жыл бұрын
Thanks
@jocelduatin294
@jocelduatin294 3 жыл бұрын
good day sir! how can I add a default user group for this Custom Django User Mode? thank you.
@ashoksharma7932
@ashoksharma7932 Жыл бұрын
Great! But I have a question that whats difference between AbstractUser and AbstractBaseUser, Can you pls help me out.
@orkhanrustamli2039
@orkhanrustamli2039 3 жыл бұрын
Hi, thanks for videos. One question. I have seen the same thing in default Usermanager of Django in github. I wonder why to check "if extra_fields.get('is_staff') is not True" after setting defaults for them? Maybe I am misunderstood the meaning of "setdefault". As I understood it is to always setting the values of these fields. I just dont understand why to check them again after setting them?
@veryacademy
@veryacademy 3 жыл бұрын
It may just have been something I over looked - good find I will check the code - but, yeah no reason I can think of for doing that 👍
@quadg1893
@quadg1893 Жыл бұрын
Oh, my goodness! If I were a praying man, then my prayers have been answered. I've been performing a lot of "Google Fu" to find how to create a custom User model in order to have new Users enter more information about themselves than just 'username', 'password1', password2', 'email', 'first_name', and 'last_name', and I think I've found it! Thank you so much! (I haven't looked yet but I hope you have a tutorial about building a User authentication form.)
@KevinTempelx
@KevinTempelx 3 жыл бұрын
Up and coming Django channel.
@veryacademy
@veryacademy 3 жыл бұрын
Thanks Kevin, will keep plugging away at Django 👍
@joey4uandme
@joey4uandme 3 ай бұрын
How would you advise me to extend the user model for a shop, the user roles are shop owner or admin, marketers and vendors. Vendors don't post products they just handle orders. Marketers are like regular customer who sell offline so they make orders.
@damianrychlicki9945
@damianrychlicki9945 2 жыл бұрын
If I could I would give this video two thumbs up.
@timothymalahy7880
@timothymalahy7880 3 жыл бұрын
Something I was confused by was the verbose name being done with gettext_lazy. It appears to me that you did the verbose_name based off position in the models.TextField() and models.EmailField() methods rather than explicitly typing verbose_name=gettext_lazy('email address'). Is that correct? right around the 7:00 mark.
@veryacademy
@veryacademy 3 жыл бұрын
Hi Tim, you are right - just looking very quickly - I would be wanting to use verbose_name=_(... for verbose_name
@robertcoffie8789
@robertcoffie8789 3 жыл бұрын
Hi please thanks for the video , please why wasn't password field added to the NewUser() model fields thanks
@veryacademy
@veryacademy 3 жыл бұрын
AbstractUser is a full User model, complete with fields, as an abstract class so that you can inherit from it and add your own profile fields and methods. AbstractBaseUser only contains the authentication functionality, but no actual fields: you have to supply them when you subclass. So using AbstractBaseUser it adds the password fields for us when we migrate
@LcTheSecond
@LcTheSecond 3 жыл бұрын
just add 'password' in fieldsets fieldsets = ( (None, {'fields': ('email', 'user_name', 'first_name', 'password')}), ('Permissões', {'fields': ('is_staff', 'is_active',)}), ('Pessoal', {'fields': ('about',)}), )
@julienboudreau1051
@julienboudreau1051 3 жыл бұрын
@@LcTheSecond This only works when you add 'password'. However, this is not working when using 'password1', 'password2'. I am unable to get it to work in either fieldsets from the tutorial. Is password1 and password2 not included in the AbastractBaseUser?
@computinginfo3187
@computinginfo3187 3 жыл бұрын
Great Vid! Could the fields be case-insensitive? Raise "Already exists" since "John" == "john"
@veryacademy
@veryacademy 3 жыл бұрын
Are you referring to CICharField (docs.djangoproject.com/en/3.0/ref/contrib/postgres/fields/)
@Stack_net
@Stack_net 2 жыл бұрын
it was be great 💖✔✔😎
@NadidLinchestein
@NadidLinchestein 2 жыл бұрын
zsh: command not found: coverage I keep getting error even though I have it installed and I tried so many times but this error just doesn't goes awayyy
@elonmusk2142
@elonmusk2142 3 жыл бұрын
Thnkx bruh!!
@veryacademy
@veryacademy 3 жыл бұрын
Glad you found it useful 👍
@yelinthu7367
@yelinthu7367 2 жыл бұрын
I could not update is_active field to "True" with is_active = models.BooleanField(default=True) in UserAccountManager then Is Active is always shown as false at Django-admin panel . Please guide me that what i need to do
@Neojagz
@Neojagz Жыл бұрын
I.m getting an error django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'users.NewUser' that has not been installed. Please what dod i do?
@georgesmith3022
@georgesmith3022 2 жыл бұрын
If i want to create two new classes, like teachers and students, is it better to subclass newuser or create a one-to-one relationship with newuser class?
@NphiniT
@NphiniT 2 жыл бұрын
I would create a one-to-one relationship and use signals to create the teacher and student classes after new user is created
@omotayoofere5504
@omotayoofere5504 3 жыл бұрын
Great tutorial, however, when I tried to implement with some different user model fields, everything worked perfectly till I tried logging in as a superuser in the admin page, it returned "Please enter the correct reg no and password for a staff account. Note that both fields may be case-sensitive.", even after multiple superusers was created. Kindly assist.
@veryacademy
@veryacademy 3 жыл бұрын
Hey Omotayo, it is a tricky one to suggest based on what you have said. Really sorry - Take it back a few steps and try and see the pattern of working - like you said you added some more fields - so just backward engineer it - takes time but you will get a better understanding
@justinmann8331
@justinmann8331 3 жыл бұрын
Your videos are an absolute blessing! One question, when I go to create my migrations I get: AttributeError saying my custom user model has no attribute 'EMAIL_FIELD'
@justinmann8331
@justinmann8331 3 жыл бұрын
Any ideas?
@justinmann8331
@justinmann8331 3 жыл бұрын
I added the 'EMAIL_FIELD' and set it to the 'email' and new errors come
@veryacademy
@veryacademy 3 жыл бұрын
class User(AbstractUser): """User model.""" username = None email = models.EmailField(unique=True) EMAIL_FIELD = 'email' code above if you are using Abstract user - define the email - you need to add it in the class like above
@marcelk.4371
@marcelk.4371 4 ай бұрын
Still very helpful! Thank you! Is there a chance to have a "change password" for the created users?
@veryacademy
@veryacademy 4 ай бұрын
To implement a feature in Django that allows users to change their passwords, you can follow these steps: Create a Password Change Form: First, you'll need to create a form where users can input their old password, new password, and confirm the new password. Implement a View for Password Change: Create a view that handles the password change process. This view will validate the old password, ensure that the new password meets the required criteria, and update the user's password if everything is valid. Map URLs: Map a URL to the password change view so that users can access it. Add Password Change Link: Add a link or button in your application's interface that directs users to the password change page. Here's an example implementation: Password Change Form (forms.py): python Copy code from django import forms from django.contrib.auth.forms import PasswordChangeForm as DjangoPasswordChangeForm class PasswordChangeForm(DjangoPasswordChangeForm): def __init__(self, user, *args, **kwargs): super().__init__(user, *args, **kwargs) self.fields['old_password'].widget.attrs.update({'class': 'form-control'}) self.fields['new_password1'].widget.attrs.update({'class': 'form-control'}) self.fields['new_password2'].widget.attrs.update({'class': 'form-control'}) Password Change View (views.py): python Copy code from django.contrib.auth import update_session_auth_hash from django.contrib.auth.forms import PasswordChangeForm from django.contrib import messages from django.shortcuts import render, redirect def password_change(request): if request.method == 'POST': form = PasswordChangeForm(request.user, request.POST) if form.is_valid(): user = form.save() update_session_auth_hash(request, user) # Important to update the session hash to prevent logout messages.success(request, 'Your password was successfully updated!') return redirect('password_change') else: form = PasswordChangeForm(request.user) return render(request, 'accounts/password_change.html', {'form': form}) URL Configuration (urls.py): python Copy code from django.urls import path from .views import password_change urlpatterns = [ path('password/change/', password_change, name='password_change'), # other paths... ] Template (password_change.html): html Copy code Password Change Password Change {% csrf_token %} {{ form.as_p }} Change Password Add Link in Template: In your application's template where users manage their account settings, add a link to the password change page: html Copy code Change Password With these steps, users should be able to change their passwords within your Django application. Ensure that you handle error messages and edge cases appropriately in your views and templates. Additionally, consider adding validation logic to ensure strong passwords and secure password change processes.
@EdwardVarner
@EdwardVarner 2 жыл бұрын
What is the point / benefit of using REQUIRED_FIELDS vs null=False when declaring the field?
@veryacademy
@veryacademy 2 жыл бұрын
Explicit can be useful
@mursalrabb6093
@mursalrabb6093 3 жыл бұрын
Great tutorial and thank you so much for it! plus, waiting for a video on using mysql with django and also on multiple databases
@databot3772
@databot3772 3 жыл бұрын
Do you have email confirmation tutorial, awesome classes :D
@veryacademy
@veryacademy 3 жыл бұрын
Think so! - If not I will do again
@omotayoofere87
@omotayoofere87 3 жыл бұрын
While you were writing the tests, you imported the django's "get_user_model", why couldn't we import our custom model to test, since that's what we are actually testing?? Thank you.
@veryacademy
@veryacademy 3 жыл бұрын
Omotayo, without looking - the custom model was called from get_user_model because it is defined in the settings as the user model.
@Chocolanay
@Chocolanay 3 жыл бұрын
I was trying out coverage, however, it does not 'detect' the test I've created for my custom user model. I have two test cases, but coverage reports 0 test run. I was following everything here but I still couldn't make it work. Do you have any idea how can I force coverage to run on the 'app' level if that makes sense... I'm using pipenv not venv. EDIT: Nevermind. Got it. Just added the app name after 'coverage run test appname'
@veryacademy
@veryacademy 3 жыл бұрын
Seems a little strange, likely a naming problem?
@Chocolanay
@Chocolanay 3 жыл бұрын
@@veryacademy I don't really know. I'll explore a bit later. Running the test while specifying every app is troublesome and annoying.
@julienboudreau1051
@julienboudreau1051 3 жыл бұрын
Great tutorial! Anyone know why when I use add_fieldsets the passwords are not showing up in the admin when I go to add a user? It's not implementing the add_fieldsets for the add page but instead just re-using the fieldsets. I have copied the code line by line.
@veryacademy
@veryacademy 3 жыл бұрын
Hi Julien, tricky one to suggest if you have copied line by line. I am half asleep mind. Let me know if you get it sorted.
@julienboudreau1051
@julienboudreau1051 3 жыл бұрын
@@veryacademy I am running a few tests. I am creating a test app to copy your code in its entirety and see what that does. Essentially I can get 'password' to show as a hashed password, but can't seem to access the 'password1' and 'password2' fields that come with the AbstractBaseUser. P.S. Your tutorials are the absolute best online, including all the pay courses. On my way (hopefully) to transitioning career and writing my first application after a year of learning and tutorials - mostly yours.
@julienboudreau1051
@julienboudreau1051 3 жыл бұрын
When I ran your code, it worked. I found the glitch - I was not sub classing UserAdmin instead was using admin.ModelAdmin. Once I changed this, everything is working.
@veryacademy
@veryacademy 3 жыл бұрын
Thanks for letting me know 👍
@josevelez6865
@josevelez6865 3 жыл бұрын
I don't think the formfield_override for 'about' is working. Does it work on yours? A quick google search brings up needing to create a form that extends ModelForm to make it work.
@veryacademy
@veryacademy 3 жыл бұрын
Hi again. Can you point me to the part of the tutorial where you think it is not working please I will take a look. - Ok I tested it on my computer from the repository - everything seem to work - What isnt working on your end?
@josevelez6865
@josevelez6865 3 жыл бұрын
@@veryacademy Around 25:44 it was added but I never saw you test it so I could not confirm if I was doing something wrong or not.
@veryacademy
@veryacademy 3 жыл бұрын
Just an optional field to prompt anyone who needed it that they could extend the table as per normal
@MrKareem722
@MrKareem722 2 жыл бұрын
Thank you for the greate Tutorial, as usual, though I got an error while migrate "django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applied before its dependency NewUser.0001_initial on database 'default'." the app NewUser I am using was already there before I follow your tutorial but I have changed everything as per your steps, and still on sqlite.
@MrKareem722
@MrKareem722 2 жыл бұрын
changed Database to PosgreSQL and problem solved, I am curius about the reason though.
@neharamakanth6796
@neharamakanth6796 3 жыл бұрын
What is the difference between add_fieldsets and fieldsets in Django Admin customization ?Could you please explain about this
@roguesoul62
@roguesoul62 3 жыл бұрын
Fieldsets are rendered when you go to change existing user detail (when you click on user in admin users list page) whereas add_fieldsets are rendered when you are adding new user (when you click “+” or click “add user”)
@neharamakanth8073
@neharamakanth8073 3 жыл бұрын
@@roguesoul62 Thank you so much
@ajinzrathod
@ajinzrathod 3 жыл бұрын
Hey I don't understand one thing. "is_superuser" was not defined in class . But in function , you are using it as other_fields.setdefault('is_superuser', True) How? ------------- I even added "is_superuser" in fields and it is treating it as inbuilt superuser column. ('Permissions', {'fields': ('is_staff', 'is_active', 'is_superuser', )}), I don't get this.
@NphiniT
@NphiniT 2 жыл бұрын
The PermissionsMixin is what sets the is_superuser field.
@kushagraaagnihotri1081
@kushagraaagnihotri1081 2 жыл бұрын
i am unable to login 'Please enter the correct email address and password for a staff account. Note that both fields may be case-sensitive.'
@hasibullahwardak4514
@hasibullahwardak4514 6 ай бұрын
In 22:39 after you add a new user with a password, as the password is not hashed; it doesn't login again.
@mertardaasar4376
@mertardaasar4376 3 жыл бұрын
I am getting an error like "AttributeError: Manager isn't available; 'auth.User' has been swapped for 'Pollapp.NewUser'"
@NphiniT
@NphiniT 2 жыл бұрын
I had a similar error when I was creatnig a custom user in an project. So my initial migrations caused this. Delete the migrations in the other apps using the user model and delete the sqlite file. Then run migrations again. That resolved it for me
@sizu257
@sizu257 2 жыл бұрын
After 16 minutes of tutorial, I realize that is_super_teacher = True.
@veryacademy
@veryacademy 2 жыл бұрын
Thank you. It doesn't always come out good but, I try.
@mohammadg5326
@mohammadg5326 2 жыл бұрын
hi, thanks for this tutorail. I followed all of your step. Found success in it. But there is an error and I cant resolve it. When I try to register a user from admin panel. The user is created but its password is not stored in hash format. Any idea, how can I resolve it?
@abhinaysingh5059
@abhinaysingh5059 2 жыл бұрын
bro i'm facing the same bug, did you find any solution...?
@mohammadg5326
@mohammadg5326 2 жыл бұрын
@@abhinaysingh5059 yeah bro, the make_password method. they store the password in hash
@mohammadg5326
@mohammadg5326 2 жыл бұрын
@@abhinaysingh5059 def create_superuser(self, email, user_name, password, **other_fields): other_fields.setdefault('is_staff', True) other_fields.setdefault('is_superuser', True) other_fields.setdefault('is_active', True) return self.create_user(email, user_name, password, **other_fields) def create_user(self, email, user_name, password, **other_fields): if not email: raise ValueError('Email is Required !!') email = self.normalize_email(email) user = self.model(email=email, user_name=user_name, **other_fields) user.set_password(password) user.save(using=self._db) return user
@what-the-code
@what-the-code 2 жыл бұрын
How to use two field combination as username like firstname_lastname?
@veryacademy
@veryacademy 2 жыл бұрын
It is worth doing that?
@what-the-code
@what-the-code 2 жыл бұрын
@@veryacademy i have legacy table employee detail. Have not any email or username field. I have to combine 2 field to create unique.
@NphiniT
@NphiniT 2 жыл бұрын
@@what-the-code And you think firstname and lastname is unique to every single person?
@prvizpirizaditweb2324
@prvizpirizaditweb2324 2 жыл бұрын
is password field automatically created when we override default User model?
@veryacademy
@veryacademy 2 жыл бұрын
One would imagine that when we override a class we are provided with the original components and can override or add new elements. Sometimes it can be good to be explicit.
@NphiniT
@NphiniT 2 жыл бұрын
Yes it is
@rajughorai3909
@rajughorai3909 3 жыл бұрын
add_fieldsets not showing anything on mine
@veryacademy
@veryacademy 3 жыл бұрын
Hi Raju, I tested the code - seems ok. Just double, triple check your code 👍
@yogeshjadhav5468
@yogeshjadhav5468 3 жыл бұрын
With this method, every user that I create gets all permissions automatically. How can I limit permissions while creating new user?
@derekkroeker4582
@derekkroeker4582 3 жыл бұрын
Have you tried groups?
@yogeshjadhav5468
@yogeshjadhav5468 3 жыл бұрын
@@derekkroeker4582 Thank you for your revert. No i haven't tried groups yet. I am using with DRF. do I need to create users with groups?
@webseries9482
@webseries9482 2 жыл бұрын
Your thumblin bring mw
@veryacademy
@veryacademy 2 жыл бұрын
Sorry I don’t understand?
@tusharhegde
@tusharhegde 11 ай бұрын
I like your voice
@veryacademy
@veryacademy 11 ай бұрын
Thank you
@ac11dc110
@ac11dc110 2 жыл бұрын
6 php devs disliked the video
@geoafrikana
@geoafrikana Жыл бұрын
This is a superbly done tutorial. Thanks so much.
Дарю Самокат Скейтеру !
00:42
Vlad Samokatchik
Рет қаралды 8 МЛН
아이스크림으로 체감되는 요즘 물가
00:16
진영민yeongmin
Рет қаралды 58 МЛН
ЧУТЬ НЕ УТОНУЛ #shorts
00:27
Паша Осадчий
Рет қаралды 6 МЛН
The gist of the the custom user model in Django
10:17
Django road
Рет қаралды 6 М.
Custom User Model with email login (DJANGO)
39:21
CodingWithMitch
Рет қаралды 46 М.
Multiple User Types | Django
21:13
Daniel Roy Greenfeld
Рет қаралды 55 М.
Django Middleware
56:19
Very Academy
Рет қаралды 23 М.
Rest API - Best Practices - Design
15:50
High-Performance Programming
Рет қаралды 101 М.
If __name__ == "__main__" for Python Developers
8:47
Python Simplified
Рет қаралды 388 М.
🚀  TDD, Where Did It All Go Wrong (Ian Cooper)
1:03:55
DevTernity Conference
Рет қаралды 554 М.
Learn Django - Build an Asynchronous Chatroom with Django and Channels
1:31:27
Creating a Custom User Model (Django)
21:57
CodingWithMitch
Рет қаралды 103 М.
Дарю Самокат Скейтеру !
00:42
Vlad Samokatchik
Рет қаралды 8 МЛН