Brian, have a look at:
    
https://docs.djangoproject.com/en/1.3/topics/db/models/#abstract-base-classes

> If I understand you correctly, your situation is:
>
> FORM 1  --> [table 1]
> FORM 2  --> [table 2]
>
> where FORM1 and FORM2 are *identical*,
> and TABLE1 and TABLE2 are *identical*  (same structure)
>
> *identical* meaning definition is the same but names are different for
> obvious reasons...


>> You understand the problem correctly.  I'm not sure how to implement
>> your suggestion.

Cool!  Let's implememt your models first:
#----------------------------------------------------
class MyBaseModel(models.Model):
    first_name   = models.CharField( max_length=100,
verbose_name='first')

    class Meta:
        abstract = True


class myModel1(MyBaseModel):

    class Meta(MyBaseModel.Meta):
        db_table = 'table1'


class myModel2(MyBaseModel):

    class Meta(MyBaseModel.Meta):
        db_table = 'table2'


Now let's tackle your forms.

> class abstractForm( ModelForm ):
>     class Meta:
>        model= myModel
>
> class myForm(abstractForm):
>     class Meta(myForm.Meta):
>        model.table_name = 'test_model'

please review:
    https://docs.djangoproject.com/en/1.3/topics/forms/modelforms/#modelform

I believe you're trying to avoid duplicate code (DRY==good!) but
I think you'll be better served writing simpler form code.

#----------------------------------------------------

class Form1(ModelForm):
    class Meta:
        model = MyModel1

class Form2(ModelForm):
    class Meta:
        model = MyModel2

Hope that helps!

-- 
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.

Reply via email to