Advertisement
Guest User

Untitled

a guest
Mar 19th, 2020
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. models.py
  2. class Profile(models.Model):
  3. user = models.OneToOneField(User, on_delete=models.CASCADE, verbose_name='Пользователь', max_length=8)
  4. image = models.ImageField(upload_to='profile_pics', verbose_name='Аватарка')
  5.  
  6. def __str__(self):
  7. return f'{self.user} Profile'
  8. form.py
  9. class ProfileForm(forms.ModelForm):
  10. class Meta:
  11. model = Profile
  12. fields = ['user', 'image']
  13. url.py
  14. path('profile/edit/', Profile_edit.as_view(), name='profile_edit'),
  15.  
  16. views.py
  17. from.models import Profile
  18.  
  19. class Profile_edit(UpdateView):
  20. model = Profile
  21. fields = ['user', 'image']
  22. form_class = ProfileForm
  23. template_name = 'signup/profile_edit.html'
  24. success_url = 'profile'
  25. error:AttributeError: Generic detail view Profile_edit must be called with either an object pk or a slug in the URLconf.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement