From a database I have a text, which must dynamically load a class of my views.
The example as I have at the moment is:
-projectname
-appname
-views.py
-templates
-appname
-index.html
in views.py
class SelectCampaign(View):
def get(self, request, *args, **kwargs):
campaign = Campaign.objects.values('campaign_name').filter(user=request.user)[0]
#this is where I need you to automatically load with varying campaign
generic_class = MyClassCampaignName1()
#example: generic_class = class called MyClassCampaignName1
return generic_class.render_index(request)
class MyClassCampaignName1():
def render_index(self, request, *args, **kwargs):
return render(request, 'appname/index.html', {}, context_instance=RequestContext(request))
The name that brings the database to dynamically load a class with the same name