Advertisement
Guest User

django_help

a guest
Sep 19th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. models.py:
  2. class UserProfile(models.Model):
  3. user = models.OneToOneField(User)
  4. first_name = models.CharField(max_length=100, blank=True)
  5. last_name = models.CharField(max_length=100, blank=True)
  6. email = models.EmailField(max_length=100, blank=True)
  7. company_name = models.CharField(max_length=100, blank=True, null=True)
  8. website = models.URLField(max_length=100, blank=True, null=True)
  9. phone_number = models.CharField(max_length=100, blank=True, null=True)
  10. fax_number = models.CharField(max_length=100, blank=True, null=True)
  11. country = models.CharField(max_length=100, blank=True, null=True)
  12. address = models.CharField(max_length=100, blank=True, null=True)
  13.  
  14. def __str__(self):
  15. return self.user.username
  16.  
  17. forms.py:
  18. class UserForm(forms.ModelForm):
  19. password = forms.CharField(widget=forms.PasswordInput())
  20.  
  21. class Meta:
  22. model = User
  23. fields = ('username', 'password')
  24.  
  25.  
  26. class UserProfileForm(forms.ModelForm):
  27. class Meta:
  28. model = UserProfile
  29. fields = ('first_name', 'last_name', 'email')
  30.  
  31. class UserProfileForm2(forms.ModelForm):
  32. class Meta:
  33. model = UserProfile
  34. fields = ('company_name', 'website', 'phone_number', 'fax_number',
  35. 'country', 'address')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement