I am using forms which get populated by the user. The save method of the forms.py looks like this:
def save(self, commit=True):
instance = super(LocationForm, self).save(commit=False)
if instance.location_id:
instance.save()
else:
new_location=Location.objects.create(name=self.cleaned_data['name'])
instance.location=new_company
instance.save()
return instance
So when I click on update the data gets saved in the database, however I get an error
No URL to redirect to error
views:
class LandingView(CreateView):
model = Review
form_class = LocationForm
template_name="core/index.html"
models.py - I created a get_absolute_url function
from django.core.urlresolvers import reverse
def get_absolute_url(self):
return reverse ('index', args=[str(self.id)])
So in the urls I tried this
url(r'^$', core.views.LandingView.as_view(success_url="success"), name='index'),
However, what do I do if I want it to be redirected to its original page, like 'go back to where I came from' ?
I tried
url(r'^$', core.views.LandingView.as_view(success_url=""), name='index'),
and
url(r'^$', core.views.LandingView.as_view(success_url=reverse('index')), name='index'),
and
url(r'^$', core.views.LandingView.as_view(success_url=reverse("")), name='index'),
But None of these work!
EDIT This url works and I don't need def_get_absolute_url
url(r'^$', core.views.LandingView.as_view(success_url="/"), name='index'),