Django forms, inheritance

18 views
Skip to first unread message

feng yu

unread,
May 24, 2011, 4:40:47 AM5/24/11
to Django users
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?

Reply all
Reply to author
Forward
0 new messages