#8107 closed (fixed)
Invalid HTML output generated for BooleanFields using Python 2.3
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | Internationalization | Version: | dev |
| Severity: | Keywords: | ||
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | yes | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Using ugettext_lazy, the following model results in invalid HTML generated in the admin area.
class Page(models.Model):
"""A simple hierarchical page model"""
STATUS_DRAFT = 0
STATUS_PUBLISHED = 1
STATUSES = (
(STATUS_DRAFT, _('Draft')),
(STATUS_PUBLISHED, _('Published')),
)
title = models.CharField(_('title'), max_length=100)
body = models.TextField(_('body'), blank=True, help_text=_('Only use the enter/return key for creating new paragraphs, try not to use any line breaks.'))
slug = models.SlugField(_('slug'), blank=True)
parent = models.ForeignKey('self', verbose_name=_('parent'), related_name="children", blank=True, null=True)
order = models.PositiveSmallIntegerField(_('order'))
creation_date = models.DateTimeField(_('creation date'), editable=False, default=datetime.now)
publication_date = models.DateTimeField(_('publication date'), editable=False, null=True)
published = models.BooleanField(_('is published'), default=False)
is_folder = models.BooleanField(_('is folder'), default=False)
Generated HTML for the two BooleanFields:
<div class="form-row published"> <input type="checkbox" name="published" id="id_published" /><label for="id_published" class="vCheckboxLabel"><django.utils.functional.__proxy__ object at 0x2aa3374990></label> </div> <div class="form-row is_folder"> <input type="checkbox" name="is_folder" id="id_is_folder" /><label for="id_is_folder" class="vCheckboxLabel"><django.utils.functional.__proxy__ object at 0x2aa3374950></label> </div>
Attachments (1)
Change History (7)
comment:1 by , 17 years ago
comment:2 by , 17 years ago
Forgot to mention that it only happens when using "from django.utils.translation import ugettext_lazy" as opposed to "from django.utils.translation import ugettext".
comment:3 by , 17 years ago
At least I can confirm this is not a problem in Python 2.5... Had been trying to reproduce it without success before noticing it affects 2.3 :P
comment:4 by , 17 years ago
| Has patch: | set |
|---|---|
| Needs tests: | set |
| Triage Stage: | Unreviewed → Accepted |
comment:5 by , 17 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
The admin.py file for this app contains:
from django.contrib import admin from pages.models import Page class PageAdmin(admin.ModelAdmin): list_display = ('title', 'parent', 'order', 'get_absolute_url', 'published', ) def register_models(site): site.register(Page, PageAdmin)