How to change default URL in Django Photologue

200 views Asked by At

Is it possible to change default URL in Photologue? For example this URL

url(r'^photo/(?P<slug>[\-\d\w]+)/$', PhotoDetailView.as_view(), name='pl-photo')

I want to change on

url(r'^pictures/(?P<slug>[\-\d\w]+)/$', PhotoDetailView.as_view(), name='pl-photo')

In documentation I find only example how to override URL.

1

There are 1 answers

1
Richard Barran On BEST ANSWER

This is not a very elegant solution, but it will work:

In your project's urls.py file, you have already included Photologue's urls:

url(r'^photologue/', include('photologue.urls', namespace='photologue')),

What you can do is write a custom urls.py file, in which you copy-and-paste Photologue's urls.py file - but then you change 'photo' to be pictures.

Note: remember to change the import at the top to from photologue.views import ....

Then include your custom urls.py file in place of including the standard Photologue urls.py file.

Note: it's not a very elegant solution because you are duplicating code - and if you ever upgrade the Photologue version used in your project, you will need to check if the urls.py file has changed.