1
我有兩個模型,Client
和PaymentOptions
。方法在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)
在我的admin.py,我只是想,當我創建一個新的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管理來做到這一點。
有沒有人有我的情況的想法?在此先感謝...