第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

foreginkey的過濾查詢集

foreginkey的過濾查詢集

慕勒3428872 2022-01-11 16:57:11
員工有兩種類型的銷售和普通員工,在銷售表格中我只想顯示銷售員工
查看完整描述

2 回答

?
回首憶惘然

TA貢獻1847條經(jīng)驗 獲得超11個贊

def __init__(self, user, *args, **kwargs):

    super(BranchesMasterForm, self).__init__(*args, **kwargs)

    self.fields['CompanyName'].queryset = BranchesMaster.objects.filter(user=user)


查看完整回答
反對 回復 2022-01-11
?
慕田峪7331174

TA貢獻1828條經(jīng)驗 獲得超13個贊

你必須在 models.py 中創(chuàng)建兩個類


class Sales(models.model):

    user = models.ForiegnKey(User , on_delete= models.CASCADE)

    { add more attributes if u want } 


class Employee(models.model):

    user = models.ForiegnKey(User , on_delete= models.CASCADE)

    { add more attributes if u want }

之后創(chuàng)建一個名為 forms.py 的新文件


   class SalesForm(forms.Modelform):

       class Meta:

       model = Sales

       fields = [ 'u can insert the fields which u want to show in ur form  ' ]

同樣,您為您的員工制作表單類


NOTE:--

u have to import ur model in your form.py module

and do import--- from django.contrib.auth.models import User

 in ur models.py file  


查看完整回答
反對 回復 2022-01-11
  • 2 回答
  • 0 關(guān)注
  • 122 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號