Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. class Crew(models.Model):
  2. crew_id = models.AutoField(primary_key=True)
  3. crew_code = models.CharField(max_length=200, null=False, unique=True)
  4. crew_name = models.CharField(max_length=200, null=False)
  5. crew_password = models.CharField(max_length=200, null=False)
  6.  
  7. from django.contrib.auth.hashers import make_password
  8. crew_password = 'take the input if you are using form'
  9. form = FormName(commit=False)
  10. form.crew_password=make_password(crew_password)
  11. form.save()
  12.  
  13. from django.forms import ModelForm, PasswordInput
  14.  
  15. class CrewForm(ModelForm):
  16. class Meta:
  17. model = Crew
  18. fields = '__all__'
  19. widgets = {
  20. 'crew_password': PasswordInput(),
  21. }
  22.  
  23. form.crew_password=make_password(crew_password)
  24. form.save()
  25.  
  26. def save(self, *args, **kwargs):
  27. self.crew_password = make_password(self.crew_password)
  28. super(Crew, self).save(*args, **kwargs)
  29.  
  30. password = forms.CharField(
  31. widget=forms.PasswordInput
  32. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement