Is there a benefit to passing a string in your url patters vs a function instance? It seems like it could be optimized to not actually load the function until it is needed, but is this in fact true?
from django.conf.urls.defaults import *
from myapp.views import myView
urlpatterns = patterns('',
# as a string
url(r'^as-string/$', "myapp.views.myView"),
# Uploading photos
url(r'^as-instance/$', myView),
)
edit: If it’s true that it doesn’t import until they’re needed, then it would be an optimization for memory, but non-existant functions and other errors would not be raised until you actually try to visit the url.
Of course that isn’t an issue if you write tests though 😉
The main benefit is that when you’re working with the actual callable object you can do things like apply decorators to it in the URLConf. So you can do things like:
etc.
This lets you have decorators which are only applied to a view when you specifically want them to, rather than decorating in the views file and then having to live with it always having that decorator applied.