1
私はClient
とPaymentOptions
という2つのモデルを持っています。私のadmin.pyでdjangoの管理方法
class Client(models.Model):
name = models.CharField(max_length=50, null=True, unique=False)
contact = models.CharField(max_length=50, null=True, unique=False)
address = models.CharField(max_length=300, null=True, unique=False)
class ClientPaymentOption(models.Model):
name = models.CharField(max_length=30, null=True, unique=False, choices=CARD_TYPE)
action = models.CharField(max_length=30, null=True, unique=False, choices=CLIENT_PAYMENT_OPTION)
percent = models.FloatField(max_length=10, null=True, unique=False)
fixamount = models.FloatField(max_length=20, null=True, unique=False)
itemcharged = models.CharField(max_length=10, null=True, unique=False)
、私はちょうど私が新しいClient
を作成するとき、それはまた、それはClientPaymentOption
だ作成されていたいです。
私は私のadmin.pyでこれを持っている:
admin.site.disable_action('delete_selected')
class ClientAdmin(admin.ModelAdmin):
#display list
list_display = ('name','b_type','banner','logo',
'contact','address','account_type',
'status','currency','color','user',
)
#display fields
fields = ('name','b_type','banner','logo','contact',
'address','account_type','status',
'currency','color','user',
)
pass
admin.site.register(Client, ClientAdmin)
私は、私のviews.pyに
client = Client.objects.create(....)
ClientPaymentOption.objects.create(...., client=client)
これを行っているが、私は、Djangoのadminにこれを行うための任意のアイデアを持っていけません。
誰かが自分の状況について考えていますか?ありがとうございます。