django-class-based-views

django class-based views with inline model-form or formset

放肆的年华 提交于 2019-11-26 08:43:59
问题 I have the following models: class Bill(models.Model): date = models.DateTimeField(_(\"Date of bill\"),null=True,blank=True) class Item(models.Model): name = models.CharField(_(\"Name\"),max_length=100) price = models.FloatField(_(\"Price\")) quantity = models.IntegerField(_(\"Quantity\")) bill = models.ForeignKey(\"Bill\",verbose_name=_(\"Bill\"), related_name=\"billitem\") I know that this is possible: from django.forms.models import inlineformset_factory inlineformset_factory(Bill, Item)

<Django object > is not JSON serializable

自闭症网瘾萝莉.ら 提交于 2019-11-26 08:07:10
问题 I have the following code for serializing the queryset; def render_to_response(self, context, **response_kwargs): return HttpResponse(json.simplejson.dumps(list(self.get_queryset())), mimetype=\"application/json\") And following is my get_querset() [{\'product\': <Product: hederello ()>, u\'_id\': u\'9802\', u\'_source\': {u\'code\': u\'23981\', u\'facilities\': [{u\'facility\': {u\'name\': {u\'fr\': u\'G\\xe9n\\xe9ral\', u\'en\': u\'General\'}, u\'value\': {u\'fr\': [u\'bar\', u\'r\