From the docs you might want to take advantage of the name= parameter
in your URLS setup and do something like {% url 'add_media_action'
%}. Not sure about the quoting, as the docs are vague about quoting
literals.
'''
New in Django 1.0: Please, see the release notes
If you're using named URL patterns, you can refer to the name of the
pattern in the url tag instead of using the path to the view.
'''
It seems like the login_required method may be confusing you:
url(r'^add/$', login_required(views.add_media),
name = 'add_media_action'),
I am guessing the login_required method returns another method that
gets set up into the url data structure, so the reverse code has no
way of knowing about views.add_media anymore. Does that make sense
to you?
Perhaps you can try to step through the code in the debugger. The top-
level method involved in reversing URLs are not super complicated.
You can set a breakpoint in django/core/urlresolver.py to see what's
happening.
Look for this snippet of code (which may be slightly different for
your version of django, but I doubt it's changed too much):
def reverse(self, lookup_view, *args, **kwargs):
if args and kwargs:
raise ValueError("Don't mix *args and **kwargs in call to
reverse()!")
try:
lookup_view = get_callable(lookup_view, True)
except (ImportError, AttributeError), e:
raise NoReverseMatch("Error importing '%s': %s." %
(lookup_view, e))
possibilities = self.reverse_dict.getlist(lookup_view)
for possibility, pattern in possibilities:
for result, params in possibility:
if args:
if len(args) != len(params):
continue
unicode_args = [force_unicode(val) for val in
args]
candidate = result % dict(zip(params,
unicode_args))
else:
if set(kwargs.keys()) != set(params):
continue
unicode_kwargs = dict([(k, force_unicode(v)) for
(k, v) in kwargs.items()])
candidate = result % unicode_kwargs
if re.search(u'^%s' % pattern, candidate, re.UNICODE):
return candidate
raise NoReverseMatch("Reverse for '%s' with arguments '%s' and
keyword "
"arguments '%s' not found." % (lookup_view, args,
kwargs))