failed to render field for a new added attribute

20 views
Skip to first unread message

Jasper Yang

unread,
Oct 5, 2016, 5:44:47 AM10/5/16
to Django-oscar
hi All:
I'm getting crazy with this little thing.
1)I override StockRecord by adding a new attribute like
/apps/partner/models.py
class StockRecord(AbstractStockRecord):
    num_in_stock_default = models.PositiveIntegerField(
                    _("Number in stock default value"), blank=True, null=True)
make migration and very sure this has been added to database.

2)I add this new attribute to StockRecordForm
apps/dashboard/catalogue/forms.py
class StockRecordForm(CoreStockRecordForm):
    class Meta:
        model = StockRecord
        fields = [
            'partner', 'partner_sku',
            'price_currency', 'price_excl_tax', 'price_retail', 'cost_price',
            'num_in_stock', 'num_in_stock_default', 'low_stock_threshold',
        ]

3)change the template to show this attribute.
templates/dashboard/catalogue/product_update.html
<td>{% include "dashboard/partials/form_field.html" with field=stockrecord_form.num_in_stock_default nolabel=True %}</td>

finally, I get failure with nothing render for this attribute. the html generated for this attribute like this:
<div class="form-group ">      
                <div class="">
                </div>            
        </div>

anything wrong or missed??
and i try to find out in templates/oscar/dashboard/partials/form_field.html and guess it get something wrong within 'render_field'.
but unfortunately, I found little info with this tag. what is 'render_field'? 
{%else%}
{% render_field field class+="form-control" %}
{% endif %}


BR//Jasper
Reply all
Reply to author
Forward
0 new messages