Django Tutorial #10 - Authentication

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

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

  • @pdevdat
    @pdevdat 6 месяцев назад +7

    This was the best Django course I found on RUclips that was quick and easy to understand. Thanks a lot! :)

    • @NetNinja
      @NetNinja  6 месяцев назад +1

      Happy to hear that! :)

    • @weeb650
      @weeb650 3 месяца назад

      @@NetNinja can you tell me why logout.html template is not rendering

    • @minixin4993
      @minixin4993 12 дней назад

      @@weeb650 cuz there is no rendering in logout_view func, you have to add it yourself

  • @henrypham8286
    @henrypham8286 4 месяца назад +7

    48:52 note that he added `error_message = None` to account for the UnboundLocalError that would arise when trying to run views.login_view. It's a pretty easy fix since it just deals with variable scope/locality, but it still should have been mentioned in the video.

    • @weeb650
      @weeb650 3 месяца назад

      can you tell me why logout.html template is not rendering

    • @gabegutz1151
      @gabegutz1151 2 месяца назад

      thanks man

  • @UnstableCastle
    @UnstableCastle 28 дней назад

    really helped to through django , the sessions were informative and i was even able to make written notes put of it

  • @muhammadradwan74
    @muhammadradwan74 6 месяцев назад +5

    First of all thanks for your great efforts delivering this course, waiting for other courses and thanks for the NetNinja to support other Devs. At the beginning of this video you said that this is the last chapter of this course, but at the first part of this tutorial you said that at the end you will build an "Inventory Management System", so are there upcoming videos or this is really the last chapter?

  • @py-zc1vv
    @py-zc1vv Месяц назад

    Sire! You are awesome. THANK YOU!

  • @henrymatola592
    @henrymatola592 6 месяцев назад +2

    @NetNinja can you make a tutorial on OOP in Typescript/React 🙏🏽🥺
    ....and .NET 6😁
    Thank you❤️🙌🏽🌹

  • @gabegutz1151
    @gabegutz1151 2 месяца назад

    error_message = None
    Pls note this, guys. Thi sis in login_view
    49:14

  • @luiskingsleytolentino8291
    @luiskingsleytolentino8291 5 месяцев назад +1

    there is error in your code and you don't show the video to fix it, I let AI help me to fix it

    • @SamuelSibarani-nf9vx
      @SamuelSibarani-nf9vx 5 месяцев назад

      what kind of error, importing the views?

    • @ohadamsellem-kj6od
      @ohadamsellem-kj6od 5 месяцев назад

      @@SamuelSibarani-nf9vx
      # Fixed login_view Function:
      def login_view(request):
      error_message = None #---------------------------------------- If the request method is not "POST", error_message is not defined, So Define it as we do here.
      if request.method == "POST":
      username = request.POST.get("username")
      password = request.POST.get("password")
      user = authenticate(request, username=username, password=password)
      if user is not None:
      login(request, user)
      next_url = request.POST.get('next') or request.GET.get('next') or 'home'
      return redirect(next_url)
      else:
      error_message = "Invalid Credentials"
      context = {'error': error_message}
      return render(request, 'accounts/login.html', context )

    • @ohadamsellem-kj6od
      @ohadamsellem-kj6od 5 месяцев назад

      also, login.html body should look like this:

      Login

      {% csrf_token %}
      {% comment %} hidden input {% endcomment %}


      Username



      Password


      Login

      {% if error %}
      {{ error }}
      {% endif %}
      Don't have an account? Register Here

      #-------------------------------------#
      And the styles.css should look like this:
      body{
      font-family: Arial, sans-serif;
      background-color: #f4f4f4;
      margin: 0;
      padding: 0;
      justify-content: center;
      align-content: center;
      display: grid;
      height: 100vh;
      }
      .container{
      background: #fff;
      padding: 20px;
      border-radius: 8px;
      box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
      }
      h2{
      margin-bottom: 20px;
      }
      .form-group{
      margin-bottom: 15px;
      }
      label{
      display: block;
      margin-bottom: 5px;
      }
      input[type="text"],
      input[type="password"] {
      width: 100%;
      padding: 8px;
      box-sizing: border-box;
      }
      button{
      background: #007bff;
      color: #fff;
      border: none;
      padding: 10px 20px;
      cursor: pointer;
      border-radius: 6px;
      }
      button:hover{
      color: red;
      margin-top: 10px;
      }
      .error{
      color: red;
      margin-top: 10px;
      }

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

    @54:14 Did anyone understand this very interesting part? 😵

  • @sidds09
    @sidds09 4 месяца назад

    pls also do DRF.

  • @EthanDeister
    @EthanDeister 4 месяца назад

    "The view ____ didn't return an HttpResponse object. It returned None instead."
    If you are getting this error and your code is exactly the same as the code in the video, you may check your browser's login autofill. It may be trying to autofill and submit the login form with an invalid login that you previously saved in the admin dashboard lecture.

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

    Tq bro 🙏

  • @skewd2528
    @skewd2528 5 месяцев назад +1

    This one was really confusing, I think fully creating the register page first would be easier to understand

  • @hasibulalamprionto2010
    @hasibulalamprionto2010 2 месяца назад

    Django-Ninja Plz :)

  • @elshadsabziyev
    @elshadsabziyev 5 месяцев назад +1

    i was following up the tutorial and overall until this video everyting was fine. But this one is a bit confusing things are done differenlty especialy with routing and classes

  • @mtpcess
    @mtpcess 6 месяцев назад +1

    Only apiece 😊😊😊