from django.http import HttpResponse, HttpResponseRedirect
from django.views.generic import View
from django.utils.decorators import method_decorator
from django.template import RequestContext, loader
from django.core.exceptions import PermissionDenied
from django.contrib.auth.decorators import login_required
from django.shortcuts import get_object_or_404, render_to_response, render


class IndexView(View):
    template_name = 'tviit/index.html'

    @method_decorator(login_required(login_url='/login/'))
    def get(self, request, *args, **kwargs):
        context = RequestContext(request, {
        })

        return render(request, self.template_name, context)



from django.http import HttpResponse, HttpResponseRedirect
from django.views.generic import View
from django.utils.decorators import method_decorator
from django.template import RequestContext, loader
from django.core.exceptions import PermissionDenied
from django.contrib.auth.decorators import login_required
from django.shortcuts import get_object_or_404, render_to_response, render
from tviit.models import Tviit, TviitForm


class IndexView(View):


    @method_decorator(login_required(login_url='/login/'))
    def get(self, request, *args, **kwargs):
        template = loader.get_template('tviit/index.html')
        context = {
            'tviit_form': TviitForm,
        }
        return HttpResponse(template.render(context, request))

Add TviitForm into main View
Add TviitForm into main View

  from django.http import HttpResponse, HttpResponseRedirect
  from django.views.generic import View
  from django.utils.decorators import method_decorator
  from django.template import RequestContext, loader
  from django.core.exceptions import PermissionDenied
  from django.contrib.auth.decorators import login_required
  from django.shortcuts import get_object_or_404, render_to_response, render
+ from tviit.models import Tviit, TviitForm
  
  
  class IndexView(View):
-     template_name = 'tviit/index.html'
+ 
  
      @method_decorator(login_required(login_url='/login/'))
      def get(self, request, *args, **kwargs):
-         context = RequestContext(request, {
+         template = loader.get_template('tviit/index.html')
+         context = {
+             'tviit_form': TviitForm,
-         })
+         }
+         return HttpResponse(template.render(context, request))
  
-         return render(request, self.template_name, context)
- 
- 
- 
Add TviitForm into main View
## Code Before:
from django.http import HttpResponse, HttpResponseRedirect
from django.views.generic import View
from django.utils.decorators import method_decorator
from django.template import RequestContext, loader
from django.core.exceptions import PermissionDenied
from django.contrib.auth.decorators import login_required
from django.shortcuts import get_object_or_404, render_to_response, render


class IndexView(View):
    template_name = 'tviit/index.html'

    @method_decorator(login_required(login_url='/login/'))
    def get(self, request, *args, **kwargs):
        context = RequestContext(request, {
        })

        return render(request, self.template_name, context)



## Instruction:
Add TviitForm into main View
## Code After:
from django.http import HttpResponse, HttpResponseRedirect
from django.views.generic import View
from django.utils.decorators import method_decorator
from django.template import RequestContext, loader
from django.core.exceptions import PermissionDenied
from django.contrib.auth.decorators import login_required
from django.shortcuts import get_object_or_404, render_to_response, render
from tviit.models import Tviit, TviitForm


class IndexView(View):


    @method_decorator(login_required(login_url='/login/'))
    def get(self, request, *args, **kwargs):
        template = loader.get_template('tviit/index.html')
        context = {
            'tviit_form': TviitForm,
        }
        return HttpResponse(template.render(context, request))
