title: How to redirect to success after POST method in Django 2
body: <p>I would like to know how a <code>GET</code> OR <code>POST</code> requests can be handled from a FormView class to render a unbound form for <code>GET</code> and POST the form to database for <code>POST</code>  and subsequently redirect to success page (info message).</p>
  
  <p>What template to use for <code>GET</code> and <code>POST</code> methods and how to include message after redirect to success URL? </p>
  
  <p>views.py:</p>
  
  <pre><code>from django.shortcuts import render,redirect,render_to_response,get_object_or_404
  from django.forms import ModelForm
  from django.views import View
  
  from django.views.generic.edit import CreateView
  from .forms import MyPlaceForm
  from .models import Place
  from django.urls.base import reverse_lazy
  
  
  from django.contrib import messages
  
  
  #Ceate your class-based views here.
  class MapView(View):
      def get(self, request):
          'Display map'
          return render(request,template_name='index.html')
  
  # Handling forms with class-based view
  class PlaceFormView(View):
      form_class = MyPlaceForm
      initial = {'key': 'value'}
      template_name = 'name.html'
  
      # Provide Blank Form if GET request
      def get(self, request, *args, **kwargs):
          form = self.form_class(initial=self.initial)
          return render(request, self.template_name, {'form': form})
  
  # Provide a message if POST request
      def post(self, request, *args, **kwargs):
          form = self.form_class(request.POST)
          success_url=reverse_lazy('success')
          if form.is_valid():
              # &lt;process form cleaned data&gt;
  
              messages.add_message(request, messages.INFO, 'Hello world.')
              return reverse_lazy(success_url)
  
          return render(request, self.template_name, {'form': form})
  </code></pre>
  
  <p>urls.py:</p>
  
  <pre><code>from django.contrib import admin
  from django.http import HttpResponse
  from django.urls import path
  from addismap.views import MapView,PlaceFormView
  
  
  urlpatterns=[
      path('map/',MapView.as_view()),
      path('place/', PlaceFormView.as_view(), name='post-place'),
      path('place/success/',PlaceFormView.as_view(), name='success')
  
      ]
  </code></pre>