Tuesday, May 24, 2011

Django forms, inheritance

Hi all ,i have a question about Django forms in inheritance
this is my models below

class Database(models.Model):
TYPE_CHOICES = (
(u'0',u'Oracle'),
(u'1',u'MySQL'),
)
name = models.CharField(max_length=200,unique=True)
type = models.CharField(max_length=2,choices=TYPE_CHOICES)

class MySQLInfo(Database):
hostname = models.CharField(max_length=200)

class OracleInfo(Database):
maxconnect = models.CharField(max_length=200)

i want to do this,
when i open url:http://10.232.42.91:8000/search/appname/database/
add/
''
if i select 'Oracle'' ,the fields in form will be fields in
Oracle'Info
and also if i select 'MySQL'', the fields in form will be fields in
MySQLInfo

in other words, i just add MySQLInfo or OracleInfo in one page, the
fields showed in form depends on
the value i select in field:'type'

can somebody help me?

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment