Working with URLs in Python & Django

First the basics — navigating within your own app. If you’ve got this in your urls.py file:

from django.conf.urls import url
from paths import views

urlpatterns = (
url(r'^some/path/here$', views.path_view, name='path_view'),
)

It would work to write something like return redirect('some/path/here'), but don’t. If you change your mind later and decide you want to pluralize the path to 'some/paths/here, you’d have to go find every place you’d referenced that path in your codebase and change it. So…

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store