1👍
?P
is only used when you want a substring matched by the group to accessible via a symbolic group name. See the Python regular expression docs for a more thorough explanation.
Because you aren’t referencing the regular expressions by name, you’ll just want to exclude the ?P
altogether:
url(
r'^deals/(\d{4})/(\d{2})/(.*)/$',
'deals.views.deal_detail',
name='deal_detail'
),
0👍
Also try having just one filter
, Django does sometimes produce odd SQL when chaining queries like that.
instance = Deal.objects.get(publish_date__year=year, publish_date__month=month, slug=slug)
queryset = Deal.objects.filter(publish_date__year=year, publish_date__month=month, slug=slug)
Source:stackexchange.com