Wednesday, December 4, 2019

Re: good day guys

buenos días, gracias, sí, tengo un súper usuario creado, pero no puedo ejecutar ningún comando que use manage.py  Gracias

On Thu, Dec 5, 2019 at 1:49 AM jose angel encinas ramos <encinasj.angel@gmail.com> wrote:
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 out
below is the view, model, form and the err

#forms
class StudentSignupForm(UserCreationForm):
class Meta(UserCreationForm.Meta):
model = UserRole
@transaction.atomic
def save(self):
user = super().save(commit=False)
user.is_student = True
if commit:
user.save()
return user

class StaffSignupForm(UserCreationForm):
class Meta(UserCreationForm.Meta):
model = UserRole
@transaction.atomic
def save(self):
user = super().save(commit=False)
user.is_staff = True
if commit:
user.save()
return user


#views
class StudentSignUp(CreateView):
model = UserRole
form_class = StudentSignupForm
template_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 = UserRole
form_class = StaffSignupForm
template_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')




#models

class 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.


--
José Ángel Encinas
Ing. Tecnologias de la informacion


Cel:  6622267620 

  
                   Never give up...

--
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.

--
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/CAHLKn73Bt%2BfX6%3DDL0ggcJtFFxNjzieo%2Biux_8XCj%2B0uVzJtkRw%40mail.gmail.com.

No comments:

Post a Comment