I’d like to use url arguments in views (not templates, I know how to do that).
So is it possible to use them like:
def item_link(self, item):
return mainpage_url_name + "%s/%i" % (item.slug, item.cid)
mainpage_url_name – is of course defined in url patterns (as name variable)
I’m a total newb in Django…
Thanks
First you should use names for your url patterns as documented here.
Then you can use
reverse()to use these names in your views or methods.Following your comments you are using the syndication framework.
Therefore you should make sure that you define
get_absolute_url()for you models, ideally using the permalink decorator (for a clean reversing of your urls).Looking at the example from Django’s docs that should be all that’s necessary.