this is my CreateView:
class LampCreateView(CreateView):
model = Lamp
template_name = 'shotmaker/test_cam.html'
success_url = '/shotmaker/'
and its url:
url(r'^camera/create/$', views.LampCreateView.as_view(), name='lamp_create'),
when I try to open the URL I get this:
ValueError at /shotmaker/camera/create/
invalid literal for int() with base 10: 'create'
when I pass pk
into the url:
url(r'^camera/create/(?P<pk>[-\w]+)$', views.LampCreateView.as_view(), name='lamp_create'),
the view opens ok.
Why does it need a pk if this is a CreateView? The pk
is not supposed to exist yet!
If you look at the full traceback, you should be able to see that it is not the
LampCreateView
that is raising the exception.It sounds like you have another url pattern above the
lamp_create
which matches/shotmaker/camera/create/
first. For example:To solve the problem, move the
other_view
url below thelamp_create
url.