forms.py ========================================================================= def CTChoices(): try: mods = models.get_models() mod_list = [] for mod in mods: ok = '%s.%s' % (mod._meta.app_label, mod._meta.object_name) oc = '%s.%s' % (mod._meta.app_label.title(), mod._meta.object_name) rec = (ok,oc) mod_list.append(rec) mod_list.sort() return mod_list except: return [] class CTForm(forms.Form): ct = forms.ChoiceField(choices=CTChoices(), label='Application and Model to upload into') ======================================================================== views.py ======================================================================== def CreateCVSUpload(request, template_name = 'csvloader/Upload.html'): if request.method == 'POST': UploadForm = CsvUploadForm(request.POST, request.FILES,\ prefix='upload') ModelForm = CTForm(request.POST, request.FILES,\ prefix='model') if UploadForm.is_valid() and ModelForm.is_valid(): upload = UploadForm.save(commit=False) (app_label, model) = request.POST.get('model-ct','').split('.') if settings.DEBUG: print '%s -- %s' % (app_label, model) ct = ContentType.objects.get(app_label=app_label, model = model.lower) upload.model = ct upload.save() return HttpResponseRedirect(reverse('csvloader_index')) else: UploadForm = CsvUploadForm(prefix='upload') ModelForm = CTForm(prefix='model') return render_to_response(template_name, { 'forms': [UploadForm, ModelForm] }, context_instance=RequestContext(request) )