1👍
Without seeing your urls.py
it’s hard to say for sure, but I’m guessing your URL pattern has something like:
url(r'^reviews/([\d]+)$', views.show_reviews),
when it needs to have something like:
url(r'^reviews/([\w]+)$', views.show_reviews),
or
url(r'^reviews/(.+)$', views.show_reviews),
Either that or your UserReview
object’s name
field is an int when it should be a string. Perhaps post more of the code?
0👍
I’m assuming name
is a foreign key field and username
is a string that comes from the URL pattern, which django is attempting to convert to a key (integer). Instead of comparing username directly to the foreign key, follow that foreign key using __
and check against the username there.
For example if name
is a foreign key into Django’s built-in User model (django.contrib.auth.models.User) you’d do it like this:
latest_reviews = UserReview.objects.filter(name__username=username)
- [Answer]-Extending the existing User model in Django
- [Answer]-Cookie does not show up in Chrome Developer Tools (Django Python)
- [Answer]-Queryset not displayed in django admin interface
Source:stackexchange.com