'Python django model object showing None and null in template
I have this table.
class MyTable(BaseModel):
key = m.CharField(max_length=20,null=False,unique=True)
pre_json = m.JSONField(blank=True, null=True)
post_json = m.JSONField(blank=True, null=True)
And I use this model through ListView/UpdateView
list view is here.
class MyTableListView(LoginRequiredMixin, ListSearchView):
model = MyTable
form_class = MyTableForm
template_name = 'mytable_list.html'
class MyTableForm(forms.ModelForm):
key = forms.CharField(required=True)
pre_json = forms.JSONField
post_json = forms.JSONField
class Meta:
model = sm.ScenarioWorker
fields = ["key","key","pre_json","post_json"]
in list html template
{{obj.pre_json}}
in edit html template
{% render_field form.pre_json class="form-control" %}
Upper one shows None in template
Lower one shows null in textarea as placeholder.
Why this two are shown? or can I erase these?
I want to stop this.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
