1👍
✅
After a lot of digging I found that when pictures in my test-database are missing, the template tag will give a None
value in the image tag src attribute. This caused a request to the server to look for the image on URL /topic/1/None. Somehow, this happened even before the response was send to the client, so that my view received new, wrong, parameters.
This tag in my template on page …/topic/1/ requests the image from …/topic/1/None, sending wrong parameters.
<img src="{{recommendation.user_picture_url}}" />
PS Thanks falsetru for the improvements in the regex
1👍
Use non-greey qualifier (.*?
or .+?
):
urlpatterns = patterns('',
url(r'^topic/(?P<topic>.+?)/$', activities_list, name='activities'),
url(r'^topic/(?P<topic>.+?)/(?P<page>.+?)/$', activities_list, name='activities_page'),
)
For page number, \d+
is more appropriate.
urlpatterns = patterns('',
url(r'^topic/(?P<topic>.*?)/$', activities_list, name='activities'),
url(r'^topic/(?P<topic>.*?)/(?P<page>\d+)/$', activities_list, name='activities_page'),
)
Instead of (?P<topic>.*?)
, you can also use (?P<topic>[^/]+)
- [Answered ]-How to redirect to another page
- [Answered ]-Display JSON as template list in django
- [Answered ]-Giving positions name in django automatically
Source:stackexchange.com