A list of puns related to "Djoser"
Hello!
I'm planning to couple a React frontend with Django REST Framework and I'm wondering how I could implement authentication. I came across two ways which is to use dj-rest-auth + django-allauth or Djoser, both complemented with simplejwt. I'd appreciate some input on this.
dj-rest-auth + django-allauth
Djoser
Hey Fellas,
I'm working on a full-stack web app. Using Vuejs for the frontend and Django and DRF for the backend. I've configured authentication and a custom user model with djoser. Authentication is working but I'm stuck on how to update the user profile(custom user model).
Here is my custom user model.
class CustomUserManager(BaseUserManager):
"""
Custom user model manager where email is the unique identifiers
for authentication instead of usernames.
"""
def create_user(self, username, email, password, **extra_fields):
"""
Create and save a User with the given email and password.
"""
if not email:
raise ValueError(_('The Email must be set'))
email = self.normalize_email(email)
user = self.model(username=username, email=email, **extra_fields)
user.set_password(password)
user.save()
return user
class User(AbstractUser):
email = models.EmailField(verbose_name='email', unique=True, max_length=50)
USERNAME_FIELD = 'username'
gender = models.CharField(max_length=15, choices=GENDER, blank=True)
bio = models.TextField(max_length=300, blank=True)
dob = models.DateField(blank=True, null=True)
created_on = models.DateTimeField(auto_now_add=True, null=True)
semester = models.CharField(max_length=10, choices=SEMESTER, blank=True)
branch = models.CharField(max_length=10, choices=BRANCH, blank=True)
college = models.CharField(max_length=10, choices=COLLEGE, blank=True)
role = models.CharField(max_length=20, default='Student', choices=ROLE)
img = models.ImageField(default="user.svg", upload_to="profile_images", blank=True)
objects = CustomUserManager()
I've made a video about the Step Pyramid Of Djoser, Saqqara Egypt.
I looked into the pre-dynastic cultures and how the first dynasty was formed. I looked into the life of Djoser, how the Pyramid was built and the rest of the funerary complex surrounding it.
I spoke about the earthquake of a magnitude of 5.8 on the Richter scale that hit the area in 1992, damaging the pyramid. The renovations of the pyramid took 14 years to complete, but finally in March 2020 it once again opened its doors to the public.
Join me in my journey in uncovering our ancient past β€οΈ
https://youtu.be/SxL3zuMznmM
Hello I am new to django django rest framework and djoser I was just wondering. How do I use djoser with multiple extended users. Below is my model, serializers and views. I can't really find anything in the internet. And the Djoser documentation doesn't have anything on multiple users. Should I just use the build in token authentication of Django Rest Framework?
Model: I am trying to inherit user with the student model and teacher model (as seen below). I want djoser to use these two model to create the users.
from django.db import models
from django.contrib.auth.models import User
from django.conf import settings
# Create your models here.
class Student(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True, related_name='student')
age = models.IntegerField()
address = models.CharField(max_length=200)
def __str__(self):
return self.user.username
class Teacher(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True, related_name='teacher')
description = models.TextField()
def __str__(self):
return self.user.username
class Course(models.Model):
name = models.CharField(max_length=200)
description = models.TextField()
price = models.FloatField(default=25.00)
def __str__(self):
return self.name
Serializer:
My serializer is not finished yet I still have to override the create and update methods.
from rest_framework import serializers
from api.models import *
from django.contrib.auth.models import User
class StudentSerializer(serializers.ModelSerializer):
class Meta:
model = Student
fields = ('age', 'address')
class StudentUserSerializer(serializers.ModelSerializer):
student = StudentSerializer()
class Meta:
model = User
fields = ('id', 'username', 'email', 'password', 'first_name', 'last_name', 'student')
extra_kwargs = {'password': {'write_only': True, 'required': True}}
class TeacherSerializer(serializers.ModelSerializer):
class Meta:
model = Teacher
fields = ('description', )
class TeacherUserSerializer(serializers.ModelSerializer):
teacher = TeacherSerializer()
class Meta:
model = User
... keep reading on reddit β‘I'm using djoser for Token authentication, how can i get current logged in user in views?
I've made a video about the Step Pyramid Of Djoser, Saqqara Egypt.
I looked into the pre-dynastic cultures and how the first dynasty was formed. I looked into the life of Djoser, how the Pyramid was built and the rest of the funerary complex surrounding it.
I spoke about the earthquake of a magnitude of 5.8 on the Richter scale that hit the area in 1992, damaging the pyramid. The renovations of the pyramid took 14 years to complete, but finally in March 2020 it once again opened its doors to the public.
Join me in my journey in uncovering our ancient past β€οΈ
https://youtu.be/SxL3zuMznmM
I've made a video about the Step Pyramid Of Djoser, Saqqara Egypt.
I looked into the pre-dynastic cultures and how the first dynasty was formed. I looked into the life of Djoser, how the Pyramid was built and the rest of the funerary complex surrounding it.
I spoke about the earthquake of a magnitude of 5.8 on the Richter scale that hit the area in 1992, damaging the pyramid. The renovations of the pyramid took 14 years to complete, but finally in March 2020 it once again opened its doors to the public.
Join me in my journey in uncovering our ancient past β€οΈ
https://youtu.be/SxL3zuMznmM
Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.