Custom Django User Model // DJANGO Tutorial

Поделиться
HTML-код
  • Опубликовано: 27 ноя 2024

Комментарии • 165

  • @CodingEntrepreneurs
    @CodingEntrepreneurs  2 года назад +65

    Should I update this video? It's 2022 -- perhaps it's time? Please comment!

  • @besllu8116
    @besllu8116 5 лет назад +2

    Finally, someone from dev world who is not trolling with soft skill videos, and providing useful content.Well done, Sir.

  • @intruder2.0
    @intruder2.0 Год назад

    2023 and this is still very relevant to me thank you so much

  • @carminetambascia6355
    @carminetambascia6355 7 лет назад +2

    Man, you are making Django even more pupular, making this awesome, great detailed but complete tutorials. Keep going.

  • @halcyon7018
    @halcyon7018 5 лет назад +4

    Justin, you are the man! Really appreciate this upload bra!

  • @luisenriqueortizcastillo2941
    @luisenriqueortizcastillo2941 4 года назад +1

    Really helpful video man. I don't know how this video doesn't have the likes quantity that it deserves !!!!! I just want to tell you that you got a new sub now

  • @simulationcosmos399
    @simulationcosmos399 5 лет назад

    justin i buy your lots of udemy courses and let me tell you one thing..you are the mentor i always wish for..and i call you sir amd you are my teacher and i also wish that someday i will you meet you face to face..thank you sir

  • @irfanshaik1302
    @irfanshaik1302 4 года назад +1

    YOU ARE THE BEST! 👏🏻👏🏻👏🏻👏🏻 That was some goddamn awesome explanation.

  • @ankushpaul9005
    @ankushpaul9005 6 лет назад +2

    just found you sitting here with all i need exactly! i'm so frustrated with this problem from days. well thanks to angels like you on earth to save my a**. appreciate your work again thanks man!

  • @daxitpatel
    @daxitpatel 4 года назад +4

    hey.. best tutorial ever on youtube.. n i can say coding entrepreneur is the best resource to learn django.. ❣️❣️💪🏾

  • @shazkingdom1702
    @shazkingdom1702 5 лет назад +4

    HAHA & AHA 😂 I just had that error a few days ago 25:48
    My learning process is extremely 😁😝 😬 ,..
    1.i get the error
    2.contemplate.. 🤔
    3. get 😞😐 and then a few days..
    4. get frustrated,
    5. erase
    6. try again
    7. then you see related videos / blogs about it.. after a few days / months/ of finally recovering from every failure 😂
    Thank you for this video...:

  • @gcloud8397
    @gcloud8397 7 лет назад +11

    Justin is on fire

  • @bbstaipei
    @bbstaipei 2 года назад

    Back to this episode from 2022, so good 🫰😃

  • @theophiluschimwanda6951
    @theophiluschimwanda6951 3 года назад

    Much appreciation for this video Justin! I learnt a lot

  • @avijitpaul9015
    @avijitpaul9015 3 года назад +1

    After disliking few youtubers,I am feeling fortunate by pressing the like button

  • @nirmalpandey1288
    @nirmalpandey1288 4 года назад

    U deserve millions of subscribers!

  • @nick-hq8oz
    @nick-hq8oz 6 лет назад +3

    if you get "AttributeError: 'Manager' object has no attribute 'get_by_natural_key' " when creating a superuser try including PermissionsMixin and adding it to the User class. Also add "objects = UserManager ()" the class.

    • @a99barnsey
      @a99barnsey 5 лет назад

      add the following to your user model: objects = UserManager()

  • @pulaktandon6271
    @pulaktandon6271 Год назад

    Really Nice and clear explanation!!

  • @supersonic6734
    @supersonic6734 4 года назад

    Wow. This is a brilliant explanation. Wowwwwwwwww.... Thank you very much

  • @AliKhundmiri
    @AliKhundmiri 7 лет назад +6

    Amazing video!! Really helpful.

  • @youtubepremium5422
    @youtubepremium5422 3 года назад

    Thank you so much for ur guides

  • @TheVendemo
    @TheVendemo 4 года назад

    Justin you are the best!

  • @raziakhan9052
    @raziakhan9052 5 лет назад

    Dear sir my name is Mustafa Warsi it very Awesome, I am a YOUR BIG FAN

  • @zhh174
    @zhh174 4 года назад +11

    how you become so expert on django. share your story. we would love to hear

    • @pointerish
      @pointerish 3 года назад

      Like you do with everything in life. Experience, reading docs, dealing with problems and solving those problems. Googling. That's pretty much it.

  • @devshah5041
    @devshah5041 4 года назад

    thank you so much man. respect for your work

  • @darkryanpetroniverse7958
    @darkryanpetroniverse7958 5 лет назад +5

    any tutorial about how to adding logo in admin with name thank you...

  • @conicbrand5931
    @conicbrand5931 4 года назад +1

    Thank You so Much Justin

  • @SkyLib
    @SkyLib 6 лет назад +1

    i love this channel.

  • @sheracore9190
    @sheracore9190 4 года назад

    Tnx for your tutorial U R the best

  • @swiffty1
    @swiffty1 4 года назад +2

    I thought the User had much more than 3 fields. e.g is_active, is_staff, username, email, passwprd, so what's all this about with only 3 fields?
    If the default User model is extended when you use AbstractUser then shouldn't it also inherit the rest of the fields that come with the User model?

  • @jhoniemusic
    @jhoniemusic 4 года назад

    Yes pls, make a vlog of your leanings

  • @omdesale4132
    @omdesale4132 Год назад

    great video

  • @oussamaelhousni5665
    @oussamaelhousni5665 3 года назад

    thnk u, well explain

  • @yusuffarag1149
    @yusuffarag1149 5 лет назад

    You sir, are a lifesaver. Thank you for making this.

  • @renzoprats2370
    @renzoprats2370 4 года назад

    Thank u very much! You helped me a lot, I was getting crazy with this lol. But I have a question, do you have any video that teaches how to work with two forms in the same view ?
    greetings from Brazil!

  • @kaoruhoshino5078
    @kaoruhoshino5078 4 года назад

    really good

  • @kinowesunga563
    @kinowesunga563 6 лет назад

    Great Tutorial!!!

  • @greghalliday4226
    @greghalliday4226 6 лет назад

    This is great. One thing I have been trying to model correctly is the situation where you want to record details of people who may not be users, for example, they may be a supplier contact or an internal contact, the complexity being that they may become a user and that record should be related to the user account. Is there a standard way to handle that?

  • @ruchit.bhatt.87
    @ruchit.bhatt.87 7 лет назад +1

    Any video on AbstractUser instead of AbstractBaseUser ??

  • @binoyudayan8054
    @binoyudayan8054 6 лет назад +1

    Amazing tutorial..!
    I could create a custom model and able to register new users. But after making this change, the admin login is not working?
    Any guess on what could have gone wrong? I'm using django 1.11.12
    Thanks in advance!

    • @rjanik2588
      @rjanik2588 4 года назад

      same here, i cant login to the admin panel with staff user, which was created by superuser

  • @shantanutomar
    @shantanutomar 4 года назад

    Quick ques: Instead of inheriting AbstractBaseUser, can't I inherit AbstractUser since it already has all these boolean fields that we created ? Thanks !

  • @alexissuarezalvarez5622
    @alexissuarezalvarez5622 3 года назад +1

    hi, when I try to delete a user I get the following error: IntegrityError at / admin / userprofile / myuser / 23 / delete /
    FOREIGN KEY constraint failed.
    Has it happened to someone the same?

  • @imransuleiman2684
    @imransuleiman2684 5 лет назад

    Thanks man.

  • @prachinainawa3055
    @prachinainawa3055 4 года назад +1

    Can I watch this in 2020, does it require any changes according to django version?

  • @JonesDTaylor
    @JonesDTaylor 6 лет назад

    Hi Justin
    If I use a third-party authentication service (such as oauth2) to register/login my users with their email and password, do I still need to use the custom User model on this video ?

  • @riadhazzouz6430
    @riadhazzouz6430 5 лет назад

    Can I create two custom users, one for an employee and the other for the company ? The idea is the employee can register and login to create his CV, then the company also can register, login to check CVs.

  • @zhh174
    @zhh174 4 года назад

    everything is working perfectly but i am not able to create staff user by admin page

  • @nusk003
    @nusk003 6 лет назад

    Hello Sir, Can we put a autofield to custom user model???

  • @SaurabhSingh-sm2mt
    @SaurabhSingh-sm2mt 4 года назад

    Thanks a lot man, that really helped a lot. On a side note can you please tell how can i integrate this with a social media login like Facebook or Google.
    Thanks in advance :)

  • @ainaadeshina28
    @ainaadeshina28 4 года назад +1

    hello Justin, your guide was really helpful, please could I reference it in my tutorial?

  • @kaustavsengupta8757
    @kaustavsengupta8757 5 лет назад

    Justin when are you going to put a new update version of this course on Udemy...??..by the I love your django series in udemy

  • @captainobvious7898
    @captainobvious7898 6 месяцев назад

    Not providing a setter for User @property is_staff and is_admin causes UserManager.create_staffuser and UserManager.create_superuser to fail. (Django=5.0.4). Wonder if I should provide a setter for these or if that is a potential security hole (is there some way for a rogue page to change is_admin=True via a User object)

  • @blabla-kk8bl
    @blabla-kk8bl 3 года назад

    can u make a video for django-organization

  • @franciscokloganb
    @franciscokloganb 4 года назад

    I didn't follow your guide, but I did something similar... And it seems correct after seeing your video. My signup, login, logout, remember, email confirmation works... But I can't get password to be reset, using django-allauth! I can't get any information on the web, it has something to do with the reverve not matching for uidb36/key, etc. My custom user does not have a username; Any ideas?

  • @victorpeter1895
    @victorpeter1895 4 года назад

    bro i used pycharm and are install pillow but not work what is problem? and i used sublime when create makemigrations their show "no changes detect" what is problem?

  • @neofit3157
    @neofit3157 7 лет назад +1

    do you have video / how do setting for sublime text editor whith context python/django ?

    • @CodingEntrepreneurs
      @CodingEntrepreneurs  7 лет назад

      +Python My somewhere we do. What are you looking for exactly?

    • @Ca1vema
      @Ca1vema 7 лет назад +1

      All you need to install to successfull use of st3 as python/django "ide" is Anaconda for python and MAYBE, just MAYBE Djanerio for django templates

  • @omdesale4132
    @omdesale4132 Год назад

    I'm trying to inherit custom user to another class but it gets IntegrityError at /admin/User/student/add/
    FOREIGN KEY constraint failed error

  • @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. Someone please shed some light

  • @Omni_G
    @Omni_G 6 лет назад

    Hi, I'm very confused with the whole staff admin thing. Do we not create the regular user? From what I've read staff and admin can log in to the admin side. I'm trying to create a User Model where user can be one of 3 roles:
    - Course Chair
    - Course Creator
    and finally
    - Admin.
    Only Admin can log in to the admin page.
    So in my model, do I do:
    is_course_chair
    or
    is_staff
    or
    nothing?

  • @riteshsinha216
    @riteshsinha216 5 лет назад +1

    How do we add more fields like profile image, city etc during registration.

    • @ruchitmicro8409
      @ruchitmicro8409 5 лет назад +1

      to add image field you have to install Pillow (python's library that handles files) and inside your models.py file you can use models.ImageField(upload_to='media').
      To save it inside the database make sure you have specified your media root and url in settings.py.
      I would suggest you watch a youtube video on how to upload media files in django it is very easy.

  • @syedmujeebh6661
    @syedmujeebh6661 4 года назад

    Hi ,
    How to add a model field that shows today date . This date field should get automatically updated to todays date

  • @ajinzrathod
    @ajinzrathod 3 года назад

    Hey Justin, I want only those users to login in Admin Page who are already logged in.
    And Show 404 otherwise

  • @anindyabhattacharya4878
    @anindyabhattacharya4878 4 года назад +1

    I am always getting this error - "Please enter the correct email address and password for a staff account. Note that both fields may be case-sensitive."

    • @anindyabhattacharya4878
      @anindyabhattacharya4878 4 года назад +1

      @@timetosleep8055 check if you have declared is_staff in the model. If yes then check if you are passing that value to be True for the user u want to create. is_staff = True required for the user to have admin access.

  • @sameergaikwad222
    @sameergaikwad222 4 года назад

    Can you please suggest any third party authentication system that supports this custom user model along with latest 3.11 Django Rest Framework Please.

    • @CodingEntrepreneurs
      @CodingEntrepreneurs  4 года назад

      Django AllAuth and django-rest-auth.readthedocs.io/en/latest/installation.html

  • @dodokwak
    @dodokwak 6 лет назад

    I'm wondering why we can't use email for the field username ( it's not forbidden) and then just go on with the built-in User instead of creating completely new custom User ? Thx in advance.

  • @Kruiger1993
    @Kruiger1993 7 лет назад

    How do you combine it with the HTML file that the question, and why it is not part of your tutorial?

  • @huboy2004
    @huboy2004 4 года назад +1

    Does this still work in 2020 guys ?

  • @torroot4142
    @torroot4142 7 лет назад

    this can be helpfully:
    find . -path "*/migrations/*.py" -not -name "__init__.py" -delete
    find . -path "*/migrations/*.pyc" -delete

  • @prasathsoosaithasan1281
    @prasathsoosaithasan1281 6 лет назад

    Hey justin, all looks good and works except testing. The moment you introduce a custom user model the order in which migrations are executed starts to matter. This is not a problem in that you can fire 1) `python manage.py makemigrations accounts` first, then 2) `python manage.py makemigrations` and finally 3) `python manage.py migrate`. Unfortunately, this breaks django testing. Django testing uses the DiscoverRunner under the hood which will only call plain old 1) `python manage.py makemigrations` and 2) `python manage.py migrate`. Whenever it does so, the error occurs and you cannot workaround this because you cannot control the make migration order. Do you know a solution to this?

  • @carminetambascia6355
    @carminetambascia6355 7 лет назад

    Hey Justin where is gone you video about Django Forms and 1 hour long?I don't mind to pay for it.

  • @ggok1876
    @ggok1876 4 года назад

    can you make a custom password reset view for this model?

  • @razaullah679
    @razaullah679 2 года назад

    Hi, I am learning the Custom Django User Model. All the things work fine but at 40:02 when I am copying the UserAdminCreationForm and UserAdminChangeForm from the website provided, I am getting this error "django.core.exceptions.FieldError: Unknown field(s) (is_active) specified for User". Anyone can provide a solution. Thanks in advance.

  • @theapplianceguruZA
    @theapplianceguruZA 5 лет назад +1

    Hello Sir, Can you please explain to me clearly how can i populate information to update user profile so the form must look exactly like the way it looks on template without changing the form structure, i want info to be on below input fields thank you in advance.

    Edit Profile


    First Name

    Last Name

    E-Mail*

    Website

    Password*

    Confirm Password*

    Country



    Profile Picture

    Select file
    Browse


    About Yourself


    Facebook

    Twitter

    Linkedin

    Google plus

  • @kkbrothers2743
    @kkbrothers2743 4 года назад

    can create multiple superuser?

  • @baljotsinghchoudhary7434
    @baljotsinghchoudhary7434 4 года назад

    can you tell what is the use clean_password method in Userchangeform

  • @aditya-bl5xh
    @aditya-bl5xh 3 года назад

    Get natural key error when creating new superuser, please help

  • @annihilationHaven
    @annihilationHaven 5 лет назад

    Doesn't work. Getting a crazy error that you can't do anything about. django.db.migrations.exceptions.InvalidBasesError: Cannot resolve bases for []

  • @ranjithak4325
    @ranjithak4325 4 года назад

    HI how can i join for your full course ????

  • @scofieldwhitefire8399
    @scofieldwhitefire8399 5 лет назад

    Hello Justin.. I'm having a little challenge here... Tried to modify the codes by adding first name /last name to the form.py and it would not show on the database.. Instead I get the error accounts_myuser.first_name has no such colum first_name
    Please how can I fix this

  • @changeineed2698
    @changeineed2698 7 лет назад

    I am getting an error 'NoneType' object has no attribute 'save' when ever i try creating a new user from the admin .Please help

  • @evgenipetrov3231
    @evgenipetrov3231 5 лет назад

    I am a beginner and my question is: is this valid for Django 3.0?

  • @sinaramezani9014
    @sinaramezani9014 Год назад

    when update this video ?

  • @hamoudarawdh1265
    @hamoudarawdh1265 6 лет назад

    heey after setting the settins to auth_use_model to accounts.use and creating a superuser with email and fullname when i go to admin and sign in it tells me that i enterred the false email or password nd im sure that theyr true , i created anotjer user but the same problem still , i elimnates the auth_user_model from settings and i created a super iser normally it workid when i sign in !!! what should i do please am stuck

  • @peterborinski
    @peterborinski 7 лет назад

    Hi Justin. Quick question:
    At 49:08 I don't understand the field add_fieldsets. Why don't you change that too? And if I warry it in my code, it seems to affect nothing. Why is that field even in there and what does it do?

    • @peterborinski
      @peterborinski 7 лет назад

      And also another questions: Changing the forms also doesn't change anything if I implemented the fieldsets. Why do we have to have the form, if they seem to not affect anything?

    • @CodingEntrepreneurs
      @CodingEntrepreneurs  7 лет назад

      `add_fieldsets` is related to your "add new object" form.
      What do you mean changing the forms doesn't change anything?

    • @Lupo9
      @Lupo9 5 лет назад

      @@CodingEntrepreneurs What determines whether a field is shown in the admin view? For example 45:21, you add full_name to the ChangeForm, and then you add it to fieldsets.
      Does it have to be added in both? What exactly is the point of adding it in the Meta class of the form?
      Because I can just do ' fields = () ' in my form Meta class and it works. Is there something wrong with that?

  • @yogeshjadhav5468
    @yogeshjadhav5468 3 года назад

    With this method, every user that I create gets all permissions automatically. How can I limit permissions while creating new user?

  • @TheMediinaa
    @TheMediinaa 3 года назад

    For some reason my user's username is being displayed as ('username', )
    Anyone else with the same problem?

  • @superbombyman1501
    @superbombyman1501 4 года назад

    CodingEntrepreneurs , how come your Django is so fast and responsive even when it is just a development server. When I do Django, there is still some lags during refreshes while in your video, it's so snappy and responsive like a Single Page Application.

    • @CodingEntrepreneurs
      @CodingEntrepreneurs  4 года назад

      Do you have a lot of apps running? Does your computer have a lot of RAM?

    • @superbombyman1501
      @superbombyman1501 4 года назад

      @@CodingEntrepreneurs well, I do have 16 GB of RAM. Maybe it's all those tabs I open in Chrome. When I'm coding, I oftentimes forget that I'm opening a lot of tabs for reference. Maybe that's what's contributing to the slowdown.

  • @kenafriq
    @kenafriq 2 года назад

    I am getttin this error when i try to migrate django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'accounts.NewUser' that has not been installed.
    The accounts app is installed in the settings under installed apps

  • @piyush__khandelwal6824
    @piyush__khandelwal6824 6 лет назад

    Where do i use that create_staffuser method in modelmanager

  • @DanielTateNZ
    @DanielTateNZ 6 лет назад +1

    Does this work with Django 2.0??? I can't seem to get it working after I finish when I edit the user I get an error... I posted a comment on your tutorial.

    • @sarpk77
      @sarpk77 6 лет назад

      I have the same problem and Ive seen your question also on StackFlow. Have you by chance found any solution to this? Everything was sound up to this point

    • @sarpk77
      @sarpk77 6 лет назад +1

      Ive just found the solution, hope you read this my friend. Ive dropped the database and rebuilt it.- python manage.py sqlflush- and re-ren migrations. eveyrthing works fine. I think it is a problem with adding new fields to the User model

    • @whoisntwhoisit2126
      @whoisntwhoisit2126 6 лет назад

      Django 2.1 will be written completely different and some things are already done for you ect.. so if you are using 2.1+ then you will want to look up a newer tutorial -- but regardless of that -- below
      Yeah, if you change to a custom user model you need to start over with your database, so for one its really smart to start with a custom user model anyways even if very basic, then second important factor is if your data is important then you have to figure out how to copy the data from the old to new database but you will need to "delete" the old so it can make new, also clear every migration folder of everything except the "__init__" file then once you change the model makemigration (appname) and then migrate (appname) and your new model should be up and running if its good.

  • @maxvinella941
    @maxvinella941 6 лет назад

    Is this working with django 2.1? I get foreign key error

  • @raducamman
    @raducamman 6 лет назад

    I have a small issue. I can no longer login in the admin interface with the superuser account. I deleted the database, made new superusers, but the same thing happens. The user is created, but I can't login with it. Any ideas?

    • @abhinavsingh4221
      @abhinavsingh4221 5 лет назад

      Make sure that active field is set to true. Try this: user_object.active = True
      Then
      user_object.save()
      Then try to login.

  • @Dastiny
    @Dastiny 6 лет назад

    I get a
    FOREIGN KEY constraint failed when i try to create or delete a user, can anyone hlep me?

    • @udaysimha5496
      @udaysimha5496 6 лет назад

      user = models.ForeignKey(AuthUser, unique=True,on_delete=models.DO_NOTHING)
      just add on_delete=models.DO_NOTHING as an argument to the call function

  • @HpDopeman
    @HpDopeman 5 лет назад

    FOREIGN KEY CONSTRAINT FAILED?? INTEGRITY ERROR??

  • @susilthapa4367
    @susilthapa4367 4 года назад

    help:
    can not able to login in admin panel

  • @varunajmera
    @varunajmera 6 лет назад

    TypeError: create_superuser() missing 1 required positional argument: 'full_name'

  • @SatishKumar-tr3pz
    @SatishKumar-tr3pz 5 лет назад +2

    Dear coders, You need to notice one thing that staff user can access admin console without permission...
    This is an error, please solve it

  • @sarpk77
    @sarpk77 6 лет назад

    At ruclips.net/video/HshbjK1vDtY/видео.html&t=2660 , after you define the error, shouldn't you be adding the line -user_obj.full_name = full_name- to the create_user function? How did you manage to create a superuser without that line?

  • @fclinuxnova6079
    @fclinuxnova6079 6 лет назад

    Hi, I think we use "if" to announce that user need to type down the email then looking on your code I think it still do the next line of code after alarm the needed of email.
    CodingEntrepreneurs
    ruclips.net/video/HshbjK1vDtY/видео.html

  • @bigfatcrab
    @bigfatcrab 5 лет назад

    Hi, i’m currently making a django base system. I need to create multiple users but with different control to the system. One of these users can only add and view while the others can delete and edit what’s on the system

    • @prikundnani2622
      @prikundnani2622 5 лет назад

      You could add an attribute to the user model called permissions and then adjust the view based on the permissions of the user.