Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django cms - resolving pages url by slug

Is it possible to resolve a page url by its slug? Something like:

from django.core.urlresolvers import reverse
reverse('pages-details-by-slug',{slug:'my-page-slug'})

But I got:

NameError: name 'slug' is not defined

Any help on this?

like image 333
Luke Avatar asked Feb 17 '23 20:02

Luke


1 Answers

Python is not Javascript; dictionary keys need to be quoted.

reverse('pages-details-by-slug', {'slug': 'my-page-slug'})
like image 73
Daniel Roseman Avatar answered Feb 23 '23 15:02

Daniel Roseman