Guest User

Untitled

a guest
Jun 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. #models.py
  2.  
  3. from django.db import models
  4. from django.contrib.auth.models import User
  5. from django.db.models.signals import post_save
  6. from django.urls import reverse
  7.  
  8. class UserProfile(models.Model):
  9. user = models.ForeignKey(User,on_delete=models.CASCADE)
  10. description = models.CharField(max_length=100, default='')
  11. city = models.CharField(max_length=100,default='')
  12. website = models.URLField(default='')
  13. phone = models.IntegerField(default=0)
  14.  
  15. def get_absolute_url(self):
  16. return reverse('profile', kwargs={'pk': self.pk})
  17.  
  18. #views.py
  19. from accounts.models import UserProfile
  20. from django.views.generic.edit import CreateView
  21.  
  22. class RegisterUserView(CreateView):
  23. model = UserProfile
  24. fields=['username','first_name','last_name','email','password1','password2']
  25.  
  26. #urls.py
  27. path('register/',RegisterUserView.as_view() , name='register')
  28.  
  29. FieldError at /accounts/register/
  30.  
  31. Unknown field(s) (last_name, password1, username, email, password2, first_name) specified for UserProfile
  32.  
  33. Request Method: GET
  34. Request URL: http://127.0.0.1:8000/accounts/register/
  35. Django Version: 2.0.6
  36. Exception Type: FieldError
  37. Exception Value:
  38.  
  39. Unknown field(s) (last_name, password1, username, email, password2, first_name) specified for UserProfile
  40.  
  41. Exception Location: /home/gaspar/anaconda3/lib/python3.6/site-packages/django/forms/models.py in __new__, line 266
  42. Python Executable: /home/gaspar/anaconda3/bin/python3
  43. Python Version: 3.6.5
  44. Python Path:
Add Comment
Please, Sign In to add comment