I apologize since I tried to reply via gmail. Reposting & expanding part of a solution .
> I've figured a way that I think will work best for me for the model > and form but I'm having trouble with writing the view. Here is my > pseudo code > > models.py > ------------------------- > class baseModel(models.Model): > first_name = models.CharField( max_length=100, > verbose_name='first') > > class form1Model( baseModel): > pass > > class form2Model( baseModel): > pass > ------------------------- The problem with the above definitions is that form2Model and form1Model would point to the *same* database table; that's what you do_not_want. [of course, no table is specified above.] You'd need, at a minimum, something like this: class BaseModel(models.Model): class Meta: abstract = True class Form1Model(BaseModel): # Specify the table to use for Form1Model class Meta(BaseModel.Meta): db_table = 'table1' class Form2Model(BaseModel): # Specify the db table to use for Form2Model class Meta(BaseModel.Meta): db_table = 'table2' #<--- table in db specified here The following should then work for you (after db_sync): > forms.py > ------------------------- > class baseForm(ModelForm): > .... > > class form1( baseForm ): > class Meta(baseForm.Meta): > model = models.Form1Model > > class form2( baseForm ): > class Meta(baseForm.Meta): > model = models.Form2Model > ------------------------- > I'm not sure how to create a view that can be reused. The only > difference is the form name and the 'thank you' page. I thought about > a Decorators but it doesn't seem like that is the right tool to use. > > view.py > ------------------------- > def form1View(request): > > if request.method == 'POST': > form = form1(request.POST) > > if form.is_valid(): > form.save() > return HttpResponseRedirect('/thanksForm1/') # ---># you're missing code for NOT (form.is_valid()) > else: > form = form1() > return render_to_response('form_template.html', {'form': form} ) > I'm guessing here that you want both forms to be processed with the same view function? If the forms are submitted from different pages there are a few ways to do this. 1. (sloppy) Pass a variable from urls.py this will also require rewriting the view: def formView(request, which_form=None): if request.method == 'POST': if not [1, 2].__contains__(which_form): pass # <--- iNone or nvalid form specified else: if which_form==1: form = form1(request.POST) redirect_url='/thanksForm2/' if which_form==2: form = form2(request.POST) redirect_url='/thanksForm2/' if form.is_valid(): form.save() return HttpResponseRedirect(redirect_url) def Form1View(request): formView(request, which_form=1) def Form2View(request): formView(request, which_form=2) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.