Don't understand regex-urls and DetailView...

47 views
Skip to first unread message

inoyon artlover KLANGRAUSCH

unread,
Mar 11, 2015, 4:56:15 PM3/11/15
to django-d...@googlegroups.com
I don't understand why this doesn't work and smashes an

'The current URL, lighter, didn't match any of these.'

my models.py

class ShopList(models.Model):
    name = models.CharField(max_length=100, null=True, blank=True)
    description = models.CharField(max_length=100, null=True, blank=True)
    slug = models.SlugField(unique=True, null=True, blank=True)

my views.py

class ProductView(DetailView):
    model = models.ShopList
    template_name = "product.html"

and finally urls.py

url(r'^(P?<slug>\w+)$', views.ProductView.as_view()),

Where is the mistake here????????????

Shai Berger

unread,
Mar 11, 2015, 5:30:03 PM3/11/15
to django-d...@googlegroups.com
On Wednesday 11 March 2015 22:56:15 inoyon artlover KLANGRAUSCH wrote:
>
> url(r'^(P?<slug>\w+)$', views.ProductView.as_view()),
>
> Where is the mistake here????????????

That should be

url(r'^(?P...

The question mark before the P

In the future, please direct questions about using Django to the django-users
mailing list. This list is for discussions about the development of Django
itself.

Thanks,
Shai.

Alexandr Shurigin

unread,
Mar 11, 2015, 5:31:33 PM3/11/15
to django-d...@googlegroups.com, Shai Berger
Use Macros Urls and forget about this type problems :)


-- 
Alexandr Shurigin
Sent with Airmail

Включено 11 марта 2015 г. в 23:30:03, Shai Berger (sh...@platonix.com) написал:

Reply all
Reply to author
Forward
0 new messages