jeudi 14 juin 2018

NOT NULL constraint failed: auth_user.username when i went to pass user in post

when i went to pass user in post the error NOT NULL constraint failed: auth_user.username is prodecte this is my code

class Enseignant(models.Model) :
    user=models.OneToOneField(User,on_delete=models.CASCADE)
    sexe =models.CharField(choices=SEXE,max_length=25)
    numero_telephone=models.CharField(max_length=255,blank=True,null=True)

    def __str__(self):
        return self.user.first_name

class SupprimerEnseignantForm(forms.Form):
    enseignant=forms.ModelChoiceField(Enseignant.objects,widget=forms.Select(
        attrs={
            'class':'form-control'
        }
    ))
    form2=SupprimerEnseignantForm(request.POST or None)




Aucun commentaire:

Enregistrer un commentaire