Buenas tardes, ya creaste un super usuario en django?,
creo que te hace falta correr python manage.py makemigrations
despues python manage.py migrate
intenta eso
El mié., 4 dic. 2019 a las 17:10, Tosin Ayoola (<tosinayoola0@gmail.com>) escribió:
--halo guys, i'm working on a school management system that has multi user (student and staffs), i've created the model, views and form but i'm getting this error which i'm not familiar with. i'll b glad if anyone can help outbelow is the view, model, form and the err#formsclass StudentSignupForm(UserCreationForm):class Meta(UserCreationForm.Meta):model = UserRole@transaction.atomicdef save(self):user = super().save(commit=False)user.is_student = Trueif commit:user.save()return userclass StaffSignupForm(UserCreationForm):class Meta(UserCreationForm.Meta):model = UserRole@transaction.atomicdef save(self):user = super().save(commit=False)user.is_staff = Trueif commit:user.save()return user#viewsclass StudentSignUp(CreateView):model = UserRoleform_class = StudentSignupFormtemplate_name = 'register/signup.html'def get_context_data(self, **kwargs):kwargs['user_type'] = 'student'return super().get_context_data(**kwargs)def student_valid_form(self, student_form):user = student_form.save()login(self.request, user)return redirect('students:student_index')class StaffSignup(CreateView):model = UserRoleform_class = StaffSignupFormtemplate_name = 'register/signup.html'def get_context_data(self, **kwargs):kwargs['user_type'] = 'staff'return super().get_context_data(**kwargs)def staff_valid_form(self, staff_form):user = staff_form.save()login(self.request, user)return redirect('staff:staff_index')#modelsclass UserRole(AbstractUser):is_student = models.BooleanField(default=False)is_staff = models.BooleanField(default=False)
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHLKn71OveFEozZ7J7b%3DGMBgtB7LvurcoOgbDEiTQXX%3DO%3D9zTw%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF3iVr9wFwnFA8OqUJKJWvApxXydDAKc0LVoL32o_LTBtaqTOQ%40mail.gmail.com.
No comments:
Post a Comment