python - Django reverse url found with arguments but fails with keywords -


this yet question regarding error:

reverse 'datapoints' arguments '()' , keyword arguments '{u'loadid': 5}' not found. 1 pattern(s) tried: [u'loads/datapoints/'] 

i've sifted through scads of related post can't seem figure out what's going on. problem this: in app using url namespaces, view template fails above error when try pass keyword arguments url, works if use position arguments.

this giving me above error:

top-level urls.py:

urlpatterns = patterns('',     url(r'^admin/', include(admin.site.urls)),     ...     url(r'^loads/', include(sig.views.data_loads.urls_data_loads, namespace="loads")),     url(r'^authentication/', include(sig.views.authentication.urls_authentication, namespace="authentication")),     url(r'^account/', include(sig.views.account.urls_account, namespace="account")), ) 

urls.py "loads":

urlpatterns = patterns('',     url(r'^datapoints', views.datapoints.as_view(), name='datapoints') ) 

template.html:

<a href="{% url 'loads:datapoints' loadid=5 %}">points</a> 

then says can't find reverse. based on of related threads i've found, i've tried:
- trying link without quotes, i.e. {% url loads:datapoints ... %} (it fails)
- tried different regex patterns, e.g. url(r'^datapoints(.)*) (still can't find reverse)

i can work around using positional arguments it's bugging me can't figure out. i've used keyword args in apps before, , i'm wondering if screwy because i'm using url namespaces? either or, more likely, i'm doing boneheaded.

edit: adding code datapoints view:

class datapoints(templateview):     template_name = "data_loads/templates/datapoints.html"     def get(self, request):         loadid = request.get["loadid"]         return self.render_to_response({}) 

urlpatterns = patterns('',     url(r'^datapoints', views.datapoints.as_view(), name='datapoints') ) 

your modified url not take parameter 1 before takes loadid.

so behavior seeing correct.

to use kwargs, keep url same , use template doing

<a href="{% url 'loads:datapoints' loadid=5 %}">points</a> 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -