この質問は、セレクターの選択における html の正しいレンダリングに関するものです。これが私のコードです:
models.py
from django.db import models
class Test(models.Model):
area = models.FloatField(choices=((0, '0 mm²'), (0.5, '0.5 mm²')), default=0)
ビュー.py
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.forms import ModelForm
from models import Test
class TestForm(ModelForm):
class Meta:
model = Test
def test(request):
form = TestForm()
return render_to_response('test.html', RequestContext(request, {'form': form}))
test.html
{{ form.area }}
{{ form.area|safe }}
{% autoescape off %}{{ form.area }}{% endautoescape %}
上記の 3 つのオプションのいずれも、セレクターの選択をではなく0 mm²として正しく表示することに成功しません0 mm²
。これはどのように解決できますか?