I have that problem when I change model in view class EditView on PersonalInfo I have response that "Not found personal info that meet your criteria" when I have model = MysiteUser than it is ok but when I change on model = PersonalInfo than it's a problem.
views.py
models.py
-- views.py
from django.contrib.messages.views import SuccessMessageMixin
from django.views.generic import TemplateView, UpdateView
from users.models import MysiteUser, PersonalInfo
class ProfileView(TemplateView):
template_name = 'profile.html'
class EditView(SuccessMessageMixin, UpdateView):
model = PersonalInfo
fields = ['age']
pk_url_kwarg = 'pk'
template_name = 'update_form.html'
success_url = '/myprofile/'
success_message = "Zmiany zostały wprowadzone."
models.py
from django.db import models
from django.contrib.auth.models import AbstractUser
##################################################
class MysiteUser(AbstractUser):
avatar = models.ImageField(upload_to="avatar")
#age = models.IntegerField()
def __str__(self):
return self.username
class PersonalInfo(models.Model):
mysiteuser = models.OneToOneField(MysiteUser)
age = models.IntegerField()
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3c4c78d8-d35c-44dd-a76a-180bd7e80dd1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment