GithubHelp home page GithubHelp logo

djangoauthapi1's Introduction

MasterHead

Coding followers-count

Hi, I'm Rajesh Kumar

I am Full Stack Web and Android App Developer. I am also an Educator. I teach on https://www.youtube.com/user/GeekyShow1 having 400k+ Subscribers.

Tech Stack

Languages

html5 css3 javascript php python dart kotlin

Frontend Framework and Lib

bootstrap tailwind reactjs vuejs material-ui material-design redux reactrouter

Backend Framework and Lib

nodejs expressjs laravel django

Database

mysql mongodb sqlite

Mobile Framework

flutter reactnative

Other

canva firebase wordpress digitalocean netlify postman

Let's Connect

geekyshow1 irenicraj geekyshow geekyshow1 geekyshow1 geekyshows portfolio

My GitHub Stats

geekyshow1 geekyshow1

geekyshow1 followers-count

djangoauthapi1's People

Contributors

geekyshow1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

djangoauthapi1's Issues

Serializer class causes issue saying User() has not attribute password2

Issue Description :

mysite_web  | Attributes are : OrderedDict([('password', 'root'), ('password2', 'root')])
mysite_web  | Internal Server Error: /auth/reset_password/
mysite_web  | Traceback (most recent call last):
mysite_web  |   File "/usr/local/lib/python3.11/site-packages/rest_framework/serializers.py", line 962, in create
mysite_web  |     instance = ModelClass._default_manager.create(**validated_data)
mysite_web  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
mysite_web  |   File "/usr/local/lib/python3.11/site-packages/django/db/models/manager.py", line 87, in manager_method
mysite_web  |     return getattr(self.get_queryset(), name)(*args, **kwargs)
mysite_web  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
mysite_web  |   File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 656, in create
mysite_web  |     obj = self.model(**kwargs)
mysite_web  |           ^^^^^^^^^^^^^^^^^^^^
mysite_web  |   File "/usr/local/lib/python3.11/site-packages/django/db/models/base.py", line 567, in __init__
mysite_web  |     raise TypeError(
mysite_web  | TypeError: User() got unexpected keyword arguments: 'password2'
mysite_web  |
mysite_web  | During handling of the above exception, another exception occurred:

Use update instead of save when saving new password

In below code, we are using .save() method. But as a standard practice, we should rather .update() the password.

class UserChangePasswordSerializer(serializers.Serializer):
  password = serializers.CharField(max_length=255, style={'input_type':'password'}, write_only=True)
  password2 = serializers.CharField(max_length=255, style={'input_type':'password'}, write_only=True)
  class Meta:
    fields = ['password', 'password2']

  def validate(self, attrs):
    password = attrs.get('password')
    password2 = attrs.get('password2')
    user = self.context.get('user')
    if password != password2:
      raise serializers.ValidationError("Password and Confirm Password doesn't match")
    user.set_password(password)
    user.save()
    return attrs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.