Luis A. Borit Guitton Luis A. Borit Guitton - 1 year ago 126
Python Question

int() argument must be a string or a number, not 'SimpleLazyObject' django

I'm passing what is necessary for reach the follow function but this is not working for some reason

Error: TypeError at /follow/1/


def follow(request, pk):
following, created = Following.objects.get_or_create(
return redirect('login')


class Following(models.Model):
follow_from = models.ForeignKey("auth.User",related_name='from_person')
follow_to = models.ForeignKey("auth.User", related_name='to_person')
date_follow = models.DateTimeField(auto_now=True)

def __unicode__(self):
return unicode(self.date_follow)

def __str__(self):
return self.date_follow


<a href="{% url 'follow' %}">


url(r'^follow/(?P<pk>\d+)/$', follow, name='follow'),

Answer Source

follow_from field is a foreign key to the user model. In your filter, you are comparing the ID with an user instance.

Your filter follow_from, should be as it:


But, if you want to compare by id, extract the id from the user instance
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download