Customize Django ContentType -


मेरे पास ऐसा मॉडल है:

  वर्ग अवरुद्धित मॉडल (मॉडल.मॉडेल): नाम = Models.CharField (max_length = 244) content_type = models.ForeignKey (ContentType) object_id = models.PositiveIntegerField () content_object = generic.GenericForeignKey ('content_type', 'object_id') def __unicode __ (स्वयं): return self.name   
  • डीजेंजो व्यवस्थापक में, content_type सभी मॉडलों को प्राप्त करें क्या मैं content_type

  • में object_id में केवल वांछित मॉडलों को दे सकता / सकती हूं, इसके बजाय सूची से चुनने का कोई तरीका है object_id दर्ज करें

पहले से धन्यवाद

यदि आप content_type में केवल कुछ मॉडल चाहते हैं तो आप

  limit_choices = models.Q (app_label = 'myapp', मॉडल = 'मायमोल्ड') का उपयोग कर सकते हैं। Models.Q (app_label = 'myotherapp', model = 'MyModelOtherModel')) content_type = models.ForeignKey (ContentType, limit_choices_to = limit_choices)  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -