Django-cms and autoblocks -
i working online shop project. in product model, have description field it's empty. somehow description data stored in django-cms , autoblocks. page, can edit description django-cms. in template tag {% autoblock product.slug %}
line description.
in views.py, have 'product' passed context, it's slug field has nothing description. also, if write {{ product.slug }}
, gives me slug.
also googled autoblocks, managed find out it's model:
class autoblock(models.model): composite_id = models.charfield(max_length=150) content = placeholderfield('content') site = models.foreignkey(site) def __unicode__(self): return self.composite_id
all of these fields has nothing description.
im struggling long time find description is. hints appreciated.
edited:
product model:
class hbaseproduct(product): def __init__(self, *args, **kwargs): super(hbaseproduct, self).__init__(*args, **kwargs) image = models.imagefield(upload_to='images/', blank=true, max_length=300, verbose_name=_('image')) position = models.integerfield(default=0, null=false) description = models.textfield(null=true, blank=true)
your description in autoblock.content
, foreignkey
'cms.placeholder'
, in turn holds tree of 'cms.cmsplugin'
models in cmsplugin_set
.
there's no straight-forward way turn placeholder
string (of html) used somewhere else outside of request/response cycle.
your best bet call placeholder.render
context object holds (fake) django request
object. return rendered contents , can store in description
.
Comments
Post a Comment