Check the primary key you are passing in the URL while calling the view. 
Key of PersonalInfo need not to be the same as that of MySiteUser



On Saturday, 28 May 2016 23:44:00 UTC+5:30, Dariusz Mysior wrote:
>
> 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
>
> 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+unsubscr...@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/280bd4ac-c84e-458a-935f-275922bac542%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to