Reputation: 4158
so I think I had this figured it out but for some reason I cannot find what I'm doing wrong when this seems so simple. I have a button that once pressed, calls a view and passes along an id.
urlpatterns = patterns('app.views',
# Examples:
url(r'^home', 'home', name='home'),
url(r'^create_modbus_device', 'create_modbus_device', name='create_modbus_device'),
url(r'^create_modbus', 'create_modbus_view', name='create_modbus_view'),
url(r'^create_bacnet', 'create_bacnet_view', name='create_bacnet_view'),
url(r'^add_device/(?P<form_count>\d{4})', 'add_device', name='add_device'),
)
button
<a href="/add_device/1"></a>
view
def add_device(request, form_count=0):
return ..
however django is returning 404 and never calls my view
Upvotes: 2
Views: 37
Reputation: 308779
The pattern \d{4}
matches four digits exactly. Your url /add_device/1
has only one digit, so it doesn't match.
If you want to match one or more digits, change the url pattern to
url(r'^add_device/(?P<form_count>\d+)', 'add_device', name='add_device'),
Upvotes: 2