No video

Creating a Custom User Model (Django)

  Рет қаралды 103,855

CodingWithMitch

CodingWithMitch

Күн бұрын

Пікірлер: 143
@josemadarieta865
@josemadarieta865 4 жыл бұрын
well done. first recent vid that was clear enough to understand while stoned. subscribed
@Rob-cq1nf
@Rob-cq1nf 3 жыл бұрын
thanks, than i watch this
@hitlermugabetashtwin
@hitlermugabetashtwin 3 жыл бұрын
Wow, and it worked first time. This is a first for me. Usually I follow a tutorial, misunderstand the docs for a bit, misunderstand the tutorial, and then stay up until 4am trying to get stuff to work only to give up and get it working within half an hour the following day because I missed some detail.
@AjaySharma-jv6qn
@AjaySharma-jv6qn 4 жыл бұрын
Your voice is so clear in respect to other videos, you are doing good work, keep posting, Good luck from India🙂
@abilashk3193
@abilashk3193 3 жыл бұрын
If anyone wanna learn how Custom User model works. Then this is the best video. **Subscribed
@bsmaheshkumar5328
@bsmaheshkumar5328 3 жыл бұрын
You are the best KZbinr where we can get all things about Django. Thanks a ton buddy.
@Speedstackingboy251
@Speedstackingboy251 4 жыл бұрын
I was on the verge of giving up the project because I don't know how to do this until I saw this and I checked. The explanation is so clear. Thank you for this you earned a sub and a fan
@uln5354
@uln5354 Жыл бұрын
Hey Marky ) Tomorrow's my deadline - here am I! Partially ready (lol). He just gave me hope and I could do it all within a few hours) Dennis, and there was another android guy, taught me a lot.
@TECHINSPEC
@TECHINSPEC 3 жыл бұрын
The best Django tutorials all Over the Internet. Thank you, Sir
@fabrizioalmeida8435
@fabrizioalmeida8435 5 жыл бұрын
tks man, i falow all videos since i find your channel, great leasons tks for all.
@aaqidmasoodi
@aaqidmasoodi 3 жыл бұрын
I am a fan of this channel!! thanks to Dennis Ivy for introducing me to this channel.
@jamikemichelohia2615
@jamikemichelohia2615 4 жыл бұрын
thanks to you i can make custom user, i was asked to do in my freelance and i was used to usercreaton form. insta subscribed
@SammyMsafiri
@SammyMsafiri Ай бұрын
I love your videos. Good job.
@DhineshDk
@DhineshDk 4 жыл бұрын
You are trying to add the field 'date_joined' with 'auto_now_add=True' to account without a default; the database needs something to populate existing rows.
@fataraz7287
@fataraz7287 3 жыл бұрын
Please enter the correct username and password for a staff account. Note that both fields may be case-sensitive.
@fforfun8931
@fforfun8931 4 жыл бұрын
thank you so much brother i was in search of this kind of video.it really put a lot of value to my life thankyou so much.subscribed
@wilez493
@wilez493 3 жыл бұрын
Great job. But bro what about the debug part? you can't skip it like that. how do we correct the code? we need that ginger taste part. Thanks and keep it up!!
@whoisntwhoisit2126
@whoisntwhoisit2126 4 жыл бұрын
Did I miss the part where you dealt with these? Cause mine wont even load server - 3 issues 0 silenced. : (admin.E019) The value of 'filter_horizontal[0]' refers to 'groups', which is not an attribute of 'website.User'. : (admin.E019) The value of 'filter_horizontal[1]' refers to 'user_permissions', which is not an attribute of 'website.User'. : (admin.E116) The value of 'list_filter[3]' refers to 'groups', which does not refer to a Field. Switching to AbstractUser instead of Base seemed to fix it - does that just bring the rest of the previous user model, anything that was not altered, into this user model? Thanks!
@mhammad50
@mhammad50 4 жыл бұрын
thank you I want to add something Instead of implementing the permission methods you could extend PermissionsMixin like this class UserProfile(AbstractBaseUser, PermissionsMixin):
@dikshantghimire6037
@dikshantghimire6037 4 жыл бұрын
@@harshilpatel8525 just add class Account(AbstractBaseUser, PermissionsMixin) and that's it. It will handle all the permissions stuff.
@sahiltrivedi69
@sahiltrivedi69 4 жыл бұрын
Bro you are a legend RESPECT
@joelmiranda5808
@joelmiranda5808 3 жыл бұрын
great tutorial for beginners
@giovanniramospedrozo1494
@giovanniramospedrozo1494 2 жыл бұрын
Hello, can I customize the width of a CharField or ArrayField for example?
@fedotov_aa
@fedotov_aa 2 жыл бұрын
thank u so much for ur videos!!!
@prettycode4028
@prettycode4028 4 жыл бұрын
Your explaining so good! Good luck from Ukraine
@pruthvihingu3733
@pruthvihingu3733 4 жыл бұрын
shows an error django.core.exceptions.FieldDoesNotExist: Account has no field named 'user_email'
@definty
@definty 4 жыл бұрын
When creating the create_user() method VSCode does not like them opening if statements. It was 'Prettier - Code Formatter' extension that was causing the issues.
@kelvinmuriithi
@kelvinmuriithi 4 жыл бұрын
Thank you Mitch. This was so helpful
@FMINSIGHTS
@FMINSIGHTS 4 жыл бұрын
Fantastic Explanation. Waiting for more videos.
@codingwithmitch
@codingwithmitch 4 жыл бұрын
The entire playlist is published
@infinitx1330
@infinitx1330 3 жыл бұрын
This was something I really wanted thanks
@omparikh4426
@omparikh4426 4 жыл бұрын
why user = self.model() in manager? why using=self.__db while saving? why you added password=password for create_superuser but used set_password for create_user(), what's the difference and when to use which?
@lalanet1362
@lalanet1362 3 жыл бұрын
Great questions, I had exactly the same doubts when watching the video. 1. MyAccountManager inherits from BaseUserManager, which itself inherits from models.Manager class. That Manager class has reference to the model it manages stored in self.model, in our case the model is: class 'Account'. So self.model(email=email, username=username) is same as writing Account(email=email, username=username). 2. 'using' parameter specifies in which database to save given instance. This is useful if you have multiple databases and you need to define which database you need for this operation. self._db is None, so when it becomes user.save(using=None), per Django implementation it will use the 'default' database defined in setting.py. If you want to use another database, pass the name of your database like user.save(using='my_database'). 3. When you need to set a password for the user, you should be using set_password method as it hashes the password which is important. As it was mentioned in the video (14:34), he should have called self.create_user(...) instead of self.model inside create_superuser. When you call self.create_user, it takes three arguments: email, username, password. Now when the method gets executed, it will normally set a password with set_password method like you would expect.
@datawithheansell
@datawithheansell 3 жыл бұрын
Thank you for all.
@faisalsalam33
@faisalsalam33 2 жыл бұрын
Thank you so much for this video...
@henrycodingstack6952
@henrycodingstack6952 5 жыл бұрын
Can you add a relationship field from this user model to another existing model. like for example a bank app .when user who can register with the app must have a bank account with d bank so in that case before signup user must have an already existing acct.so we have Account model and a User model so can a OnetoOneField be in this User model with that Account model ?
@olayemii
@olayemii 5 жыл бұрын
Hi Mitch, I followed the tutorial, but some how my Add User view still shows just Username, Password and no email. What am i doing wrong please?
@AdrianGonzalezBlogs
@AdrianGonzalezBlogs 4 жыл бұрын
Has anybody been able to solve this?
@AdrianGonzalezBlogs
@AdrianGonzalezBlogs 4 жыл бұрын
Update: I was able to solve this by adding this on admin.py inside the AccountAdmin class. fieldsets = ( (None, {'fields': ('email', 'password', 'username')}), ('Permissions', {'fields': ('is_admin', 'is_staff')}), ) add_fieldsets = ( (None, { 'classes': ('wide',), 'fields': ('email', 'username', 'password1', 'password2'), }), ) the reference code is from the django docs: docs.djangoproject.com/en/3.0/topics/auth/customizing/#a-full-example
@aliazlanaziz
@aliazlanaziz 4 жыл бұрын
@@AdrianGonzalezBlogs thanks
@rezaulislamtanim6445
@rezaulislamtanim6445 4 жыл бұрын
@@AdrianGonzalezBlogs bro what change did you made with fieldsets? i dont understand
@AdrianGonzalezBlogs
@AdrianGonzalezBlogs 4 жыл бұрын
@@rezaulislamtanim6445 what exactly you don't understand?
@siddharth1278
@siddharth1278 4 жыл бұрын
Great Video! very helpful. Thanks
@architverma1805
@architverma1805 3 жыл бұрын
thanks a lot man
@DenzelHooke
@DenzelHooke 3 жыл бұрын
How does the user variable defined in our create_superuser have access to the Account class
@leonxx9790
@leonxx9790 4 жыл бұрын
Amazing tutorial!! Great job!
@yassinsoltani2725
@yassinsoltani2725 4 жыл бұрын
i can't login django administration after creating a super user why please ? i checked it and it's created but i can't login
@levyrasesemola5904
@levyrasesemola5904 4 жыл бұрын
how did you fix it?
@levyrasesemola5904
@levyrasesemola5904 4 жыл бұрын
@@timetosleep8055 thank you
@user-rm4or1sl4k
@user-rm4or1sl4k 3 жыл бұрын
Hello folks! Notice that you need the superuser's email and not the superuser's name to log in. That was my mistake, hadn't noticed.
@rajendrakumar1195
@rajendrakumar1195 2 жыл бұрын
i have followed the same step and code but after admin login i got the is error " 'Account' object has no attribute 'get_all_permissions' ". how to solve please help me.
@talhashakil8245
@talhashakil8245 4 жыл бұрын
Well done. Thank you soo much
@CaptainStudioOfficial
@CaptainStudioOfficial 3 жыл бұрын
Thanks a lot. This is really helpful
@devmrnecro4215
@devmrnecro4215 3 жыл бұрын
Can anybody elaborate to share the link of the next that he had talked about in the video for adding more things like hashed password and etc....
@rickerp
@rickerp 4 жыл бұрын
Hey Mitch! In 12:33 , couldn't you just use `blank=False` when declaring the field, then it would raise automaticly an exception if it was blank
@rodiihernandez146
@rodiihernandez146 3 жыл бұрын
Niceeee!! hello from Chile.
@alexissuarezalvarez5622
@alexissuarezalvarez5622 3 жыл бұрын
hi, what's the use of using the is_staff functions with the @property decorator?
@EnmanuelMenjivarCortez
@EnmanuelMenjivarCortez 3 жыл бұрын
Thank you a lot, you helped me so much
@motlatsimoea5615
@motlatsimoea5615 4 жыл бұрын
I followed the steps here and created this user model. Difference is that I am not using email in the USERNAME_FIELD. Email is not even required for my model. Second, I have more fields that are required such as first and last name and address. My problem is that when I try to create a superuser, it does not give me the other required fields. instead I get a 'TyperError' telling me that 3 positional arguments are missing. Help anyone.....:-(
@ryanjayantonio8892
@ryanjayantonio8892 Жыл бұрын
are you already solved this problem? can you explain how you solved it ? 🥲
@RSurya99
@RSurya99 3 жыл бұрын
i got an error when i login to myweb/admin it says "not enough values to unpack (expected 4, got 3)"
@pypro
@pypro 5 жыл бұрын
Bro, could you explain how to create custom groups??
@codingwithmitch
@codingwithmitch 5 жыл бұрын
Possibly
@rishabhsidana7063
@rishabhsidana7063 3 жыл бұрын
helped me a lot
@Birlank
@Birlank 2 жыл бұрын
So when I go to create a superuser in the cmd screen, it asks for the email/password but then says failed to provide a username. However, it does not prompt for a user name and followed the steps. Any suggestions?
@piyushgupta9051
@piyushgupta9051 3 жыл бұрын
hello mitch which database are you using because u have used self._db to save the user, i am using mysql database it is creating an error....please reply
@kishanpatel3354
@kishanpatel3354 4 жыл бұрын
While creating superuser I do not have a username field appearing on the cmd line.
@diagknowstech
@diagknowstech 4 жыл бұрын
how about if i want toi create a user which is a staff
@hiteshprajapati603
@hiteshprajapati603 3 жыл бұрын
i am getting programmig error while running django admin page account account relation does not exist what to do
@r.f886
@r.f886 2 жыл бұрын
Thank you very much for the great tutorial But i have a little error in Cmd : ImportError: cannot import name 'BaseUserManger' from 'django.contrib.auth.models' (D:\Django Projects\.........
@georgesmith3022
@georgesmith3022 5 жыл бұрын
excellent!
@maheshbisht2967
@maheshbisht2967 4 жыл бұрын
nailed it sir
@alvarobencosme5348
@alvarobencosme5348 4 жыл бұрын
How customize the admin panel to show permissions and groups in this custom user? thanks!!!
@magzumkalybek2758
@magzumkalybek2758 4 жыл бұрын
Thank you, dude!
@abdullah01015
@abdullah01015 2 жыл бұрын
Heyy, it throws this error at the cmd " TypeError: create_superuser() missing 1 required positional argument: 'username' "
@abdullah01015
@abdullah01015 2 жыл бұрын
The error in my case was that I typed REQUIRED_FIELD instead of REQUIRED_FIELDS. A missing S can Screw up everything!
@priteshjoshi9738
@priteshjoshi9738 4 жыл бұрын
shows an error 'Account' object has no attribute 'USERNAME_FIELD'
@professionalcodder5789
@professionalcodder5789 4 жыл бұрын
USERNAME_FIELD = 'email'
@shirlimotro2375
@shirlimotro2375 4 жыл бұрын
hey, I am working with mysql data base. in the tutorial I see the base_account table was created and contains the columns that we added in the video. how do I fill this table with the data from the registration form ? in my project the table that this info is filled in is the auth_user table thanks !!
@sidalimahmoudi9386
@sidalimahmoudi9386 3 жыл бұрын
Thank you, when I create a super user it does not be added to account table, why ? Same when I create a simple user
@meddoubiha5921
@meddoubiha5921 3 жыл бұрын
same problem did u find a solution ??
@KevinTempelx
@KevinTempelx 3 жыл бұрын
Thanks!
@g4merlin
@g4merlin 3 жыл бұрын
18:45 "TypeError: create_superuser() missing 1 required positional argument: 'username'" i dont know ive checked again all the steps ive reproduced and cant find the error.- i stop here for now tyvm
@infinitx1330
@infinitx1330 3 жыл бұрын
Is it possible to have multiple custom user authentication methods for different users within the same Django app. Like an email and password for one type of user and a pin only for another type of user
@classicguy7813
@classicguy7813 4 жыл бұрын
how to add a department field. We know those fields are already base
@whoisntwhoisit2126
@whoisntwhoisit2126 4 жыл бұрын
I really wish tab and space were the same damn thing, if tab just put 4 spaces it would solve this happening with several other programs too. I was taught specifically to NEVER use tab with python, always use spaces instead, no idea why. To bad not a true standard on something like that. If only one of them didn't work so the other would be used normally, o well what can you do...
@frankandbrendabarrett39
@frankandbrendabarrett39 4 жыл бұрын
Hey Mitch, Great tutorial I am getting the following error when I try to create a superuser at the command line. TypeError: create_superuser() missing 1 required positional argument: 'username' Have I missed something, I have checked the code and cannot find the problem.
@rahulpatel4701
@rahulpatel4701 4 жыл бұрын
same error
@rahulpatel4701
@rahulpatel4701 4 жыл бұрын
make sure it is 'REQUIRED_FIELDS' in my case it was REQUIRED_FIELD so I was getting an error hope this help you
@zigtech5799
@zigtech5799 3 жыл бұрын
Username is what you missing
@MiRaje8086
@MiRaje8086 3 жыл бұрын
thanks for the vid but dam all that white space bothered me so much lol
@orkhangasanov
@orkhangasanov 4 жыл бұрын
Huge thanks!
@90daner
@90daner 3 жыл бұрын
where is the second part sir ??
@looploop6612
@looploop6612 4 жыл бұрын
why not inheritate from User model ?
@user-ky5hd8yo2r
@user-ky5hd8yo2r 4 жыл бұрын
thank you soooooo much
@BboThe123
@BboThe123 3 жыл бұрын
Why in function create_user parameter password=None?
@digitaldata-surveying
@digitaldata-surveying 4 жыл бұрын
thanks
@trippy_b
@trippy_b 3 жыл бұрын
great video! subd!
@shleshaodhekar175
@shleshaodhekar175 4 жыл бұрын
hey, can i do this on already created templates
@deepgojariya4272
@deepgojariya4272 4 жыл бұрын
After creating superuser I am unable to login please helppp
@yasssh7835
@yasssh7835 4 жыл бұрын
Hi, can't we just make a new model with OnetoOne relationship with the User model and add additional fields are per requirement?
@codingwithmitch
@codingwithmitch 4 жыл бұрын
I think that would be fine yes.
@sunnysandhu8922
@sunnysandhu8922 2 жыл бұрын
AttributeError: 'Manager' object has no attribute 'get_by_natural_key'
@KyrenDinh
@KyrenDinh Жыл бұрын
Try this: objects=MyAccountManager() the empty parenthesis needs to be their at the end of the manager name. I forgot to add () and I got the same error as you
@sahajrajmalla
@sahajrajmalla 4 жыл бұрын
what's the difference between custom made user model and django built-in User model sir?
@main_py5853
@main_py5853 4 жыл бұрын
Basically the built in User model is very simple and doesn't have a lot of functionality out of the box. So we make the custom User model to extend the built-in User model
@CaptionThisChallenge_
@CaptionThisChallenge_ 4 жыл бұрын
Legend!!!
@aimranedr6491
@aimranedr6491 3 жыл бұрын
man , I can't understand why i am getting this error : i did literally like you but when i write in cmd "python mange.py createsuperuser" it shows an AttributeError : 'Manager' object has no attribute 'get_by_natural_key'
@KyrenDinh
@KyrenDinh Жыл бұрын
This is because the account class isn't using the account manager correctly. Try this: objects=MyAccountManager() the empty parenthesis needs to be their at the end of the manager name. I forgot to add () and I got the same error as you
@enricospina5201
@enricospina5201 3 жыл бұрын
can someone please give the source code with pastebin or something like that?
@ikhsanrahman9703
@ikhsanrahman9703 4 жыл бұрын
where is password stored? because i didn't see password defined in custom user model
@saiyansuper8020
@saiyansuper8020 3 жыл бұрын
I created a superuser successfully but cannot login to the admin. It says please enter the correct email and password for the staff account.
@danielalba1488
@danielalba1488 3 жыл бұрын
What did you do?
@alexanderconley5164
@alexanderconley5164 3 жыл бұрын
I have the same error too.. any solution?
@JJ-ot3ps
@JJ-ot3ps 2 жыл бұрын
hey Mitch, great video, as a python newbie, I am wondering what does this line of code means: objects = MyAccountManager(), what is object refering to? what does this line mean? thanks!!!
@pamelapricesoullinedancing9369
@pamelapricesoullinedancing9369 4 жыл бұрын
Curious, why is password not included as a field in the Account model?
@user-qv7rw7dq1d
@user-qv7rw7dq1d 4 жыл бұрын
Basically this; why isn't password included?
@whoisntwhoisit2126
@whoisntwhoisit2126 4 жыл бұрын
@@user-qv7rw7dq1d How I understand it, password is a forced requirement already. Just like the "USERNAME_FIELD" is not included, its already "pre-included".
@brahimdevlober3579
@brahimdevlober3579 4 жыл бұрын
File "C:\Users\black-worm\Desktop\mysite\account\models.py", line 14 user=self.model( ^ IndentationError: unindent does not match any outer indentation level where is the mistake i don't knows
@josemadarieta865
@josemadarieta865 4 жыл бұрын
welcome to python ;)
@brahimdevlober3579
@brahimdevlober3579 4 жыл бұрын
@@josemadarieta865 you meant ??
@nishantrao5600
@nishantrao5600 4 жыл бұрын
Self reference @ 15:50
@tonikroos6895
@tonikroos6895 2 жыл бұрын
im getting an error like: You don’t have permission to view or edit anything.
@vvk8698
@vvk8698 3 жыл бұрын
Hi bro I need source code can u pls send for me
@Xiler6969
@Xiler6969 4 жыл бұрын
Link the documentation page you are using dude.
@rubensrojas
@rubensrojas 4 жыл бұрын
Just google it
@ritapravadutta7939
@ritapravadutta7939 4 жыл бұрын
Github link?
@priyanksingh6818
@priyanksingh6818 5 жыл бұрын
Bro, still waiting(from past 1month) for next video
@codingwithmitch
@codingwithmitch 5 жыл бұрын
They've all been published for months codingwithmitch.com/courses/building-a-website-django-python/
@sameergaikwad222
@sameergaikwad222 4 жыл бұрын
moment you pick username in fields of a Model. You lost meaning of entire Custom User model interest. Sorry :)
@hectorviov
@hectorviov 3 жыл бұрын
Why do you sound like the guy from Casually Explained channel?
@codingwithmitch
@codingwithmitch 3 жыл бұрын
That is me
@jessejoseph2643
@jessejoseph2643 4 жыл бұрын
Why the fuck does he leave that much space when creating fields?
@ThePassportPapi
@ThePassportPapi 4 жыл бұрын
If I want to force a user to upload a photo during registration, do I need to use a custom user model? Or is it possible to do that via extending the user model?
@kalenzo78
@kalenzo78 4 жыл бұрын
Validate the registration via front end using JavaScript and add an add event listener on submit button
Custom User Registration Django (AbstractBaseUser and UserCreationForm)
17:04
Custom User Model with email login (DJANGO)
39:21
CodingWithMitch
Рет қаралды 46 М.
At the end of the video, deadpool did this #harleyquinn #deadpool3 #wolverin #shorts
00:15
Anastasyia Prichinina. Actress. Cosplayer.
Рет қаралды 15 МЛН
مسبح السرير #قصير
00:19
سكتشات وحركات
Рет қаралды 11 МЛН
Learn Django - Build a Custom User Model with Extended Fields
39:42
How to extend the User Model in Django with AbstractUser
13:55
Register a New User (Django Rest framework)
15:05
CodingWithMitch
Рет қаралды 81 М.
DO NOT do this in a Software Engineering Interview
7:59
CodingWithMitch
Рет қаралды 9 М.
From Physics Student to Software Engineer
6:22
CodingWithMitch
Рет қаралды 11 М.
Understanding Django Model Relationships
25:56
Pretty Printed
Рет қаралды 94 М.
Custom Django User Model // DJANGO Tutorial
1:04:40
CodingEntrepreneurs
Рет қаралды 156 М.
Learn the basics of Django's Model Managers and Querysets
19:38
Matt Freire
Рет қаралды 44 М.
At the end of the video, deadpool did this #harleyquinn #deadpool3 #wolverin #shorts
00:15
Anastasyia Prichinina. Actress. Cosplayer.
Рет қаралды 15 МЛН