You need to add get_context_data method to pass values from Views to Templates. Something like this
class index(FormView):
template_name = 'homepage/columntemplate.html'
form_class = MyForm
def get(self, request, *args, **kwargs):
# you can add your code here which will execute on page load
return super().get(request, *args, **kwargs)
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
brand = Brand.objects.get(pk=randint(1,2))
brand_listing ={'brand' : brand}
# you can add more such parameters you want to pass to the template
# and you can use it like {{brand}}
# and can also use {{form}} in the template if you define form_class (all fields from form can be accessed)
context['brand'] = brand
return context
def post(self, request, *args, **kwargs):
# form = Search(request.GET or None)
form = self.get_form()
if form.is_valid():
# define save method in your Form "MyForm"
form.save()
content = {'form' : form}
return render(request, self.template_name, content)
Hope this helps.
Cheers!