में प्रदर्शित किया जा सकता है मैं एक टेम्पलेट में एक मॉडल प्रॉपर्टी प्रदर्शित करना चाहता हूं, जो इनलाइनफॉर्मसेट_फैक्टरी का उपयोग करता है। क्या यह भी संभव है? मैं किसी भी उदाहरण में नहीं आया है।मॉडल गुणों को टेम्पलेट
मैं अपने टेम्पलेट में 'json_data' प्रदर्शित करने के लिए views.py
RecipeIngredientFormSet = inlineformset_factory(models.Recipe, models.RecipeIngredient, form=forms.RecipeIngredientForm, extra=0)
recipeIngredients = RecipeIngredientFormSet(instance = objRecipe)
मेरे टेम्पलेट में
class RecipeIngredient(models.Model):
recipe = models.ForeignKey(Recipe)
ingredient = models.ForeignKey(Ingredient)
serving_size = models.ForeignKey(ServingSize)
quantity = models.IntegerField()
order = models.IntegerField()
created = models.DateTimeField(auto_now_add = True)
updated = models.DateTimeField(auto_now = True)
def _get_json_data(self):
return u'%s %s' % (self.id, self.ingredient.name)
json_data = property(_get_json_data)
कोशिश कर रहा हूँ, मैं इस है, लेकिन मैं कुछ भी नहीं दिख रहा है
{% for form in recipeIngredients %}
{{ form.json_data }}
{% endfor %}
शांत, धन्यवाद। मुझे घटना के बारे में पता नहीं था। – iJK
मैं हर जगह यह जवाब ढूंढ रहा हूं! बहुत बहुत धन्यवाद, बहुत, WoLPH! – Bobort