#19423: using formfield_overrides to set CharField size causes all admin fields to
use last max_length in model definition
------------------------------+--------------------------------------------
Reporter: joebuyer@… | Owner: nobody
Type: Bug | Status: new
Component: | Version: 1.4
Uncategorized | Keywords: max_length formfield_overrides
Severity: Normal | Has patch: 0
Triage Stage: Unreviewed | UI/UX: 0
Easy pickings: 0 |
------------------------------+--------------------------------------------
Here's my example. See how title and ISBN are defined with max_length of
100 and 14. The override cause both fields to have max_length of 14 with
respect to a user who is editing in the change form - a 15th character
cannot be inserted into the title field.

models.py:

from django.db import models

class Book(models.Model):
title = models.CharField(max_length=100,blank=True, null=True)
ISBN13 = models.CharField(max_length=14,unique=True)
def __unicode__(self):
return self.title


admin.py:

from django.contrib import admin
from django.db import models
from django.forms import TextInput
from books.models import Book

class BookAdmin(admin.ModelAdmin):
formfield_overrides = {
# Django enforces maximum field length of 14 onto 'title' field
when user is editing in the change form
models.CharField: {'widget': TextInput(attrs={'size':'30'})},
}

admin.site.register(Book,BookAdmin)

--
Ticket URL: <https://code.djangoproject.com/ticket/19423>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to django-updates+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Django at Dec 7, 2012 at 7:17 pm
    #19423: using formfield_overrides to set CharField size causes all admin fields to
    use last max_length in model definition
    -------------------------------------+-------------------------------------
    Reporter: joebuyer@… | Owner: nobody
    Type: Bug | Status: new
    Component: Uncategorized | Version: 1.4
    Severity: Normal | Resolution:
    Keywords: max_length | Triage Stage:
    formfield_overrides | Unreviewed
    Has patch: 0 | Needs documentation: 0
    Needs tests: 0 | Patch needs improvement: 0
    Easy pickings: 0 | UI/UX: 0
    -------------------------------------+-------------------------------------
    Changes (by claudep):

    * needs_better_patch: => 0
    * needs_tests: => 0
    * needs_docs: => 0


    Old description:
    Here's my example. See how title and ISBN are defined with max_length of
    100 and 14. The override cause both fields to have max_length of 14 with
    respect to a user who is editing in the change form - a 15th character
    cannot be inserted into the title field.

    models.py:

    from django.db import models

    class Book(models.Model):
    title = models.CharField(max_length=100,blank=True, null=True)
    ISBN13 = models.CharField(max_length=14,unique=True)
    def __unicode__(self):
    return self.title
    admin.py:

    from django.contrib import admin
    from django.db import models
    from django.forms import TextInput
    from books.models import Book

    class BookAdmin(admin.ModelAdmin):
    formfield_overrides = {
    # Django enforces maximum field length of 14 onto 'title' field
    when user is editing in the change form
    models.CharField: {'widget': TextInput(attrs={'size':'30'})},
    }

    admin.site.register(Book,BookAdmin)
    New description:

    Here's my example. See how title and ISBN are defined with max_length of
    100 and 14. The override cause both fields to have max_length of 14 with
    respect to a user who is editing in the change form - a 15th character
    cannot be inserted into the title field.

    models.py:
    {{{
    from django.db import models

    class Book(models.Model):
    title = models.CharField(max_length=100,blank=True, null=True)
    ISBN13 = models.CharField(max_length=14,unique=True)
    def __unicode__(self):
    return self.title
    }}}

    admin.py:
    {{{
    from django.contrib import admin
    from django.db import models
    from django.forms import TextInput
    from books.models import Book

    class BookAdmin(admin.ModelAdmin):
    formfield_overrides = {
    # Django enforces maximum field length of 14 onto 'title' field
    when user is editing in the change form
    models.CharField: {'widget': TextInput(attrs={'size':'30'})},
    }

    admin.site.register(Book,BookAdmin)
    }}}

    --

    --
    Ticket URL: <https://code.djangoproject.com/ticket/19423#comment:1>
    Django <https://code.djangoproject.com/>
    The Web framework for perfectionists with deadlines.

    --
    You received this message because you are subscribed to the Google Groups "Django updates" group.
    To post to this group, send email to django-updates@googlegroups.com.
    To unsubscribe from this group, send email to django-updates+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Django at Dec 7, 2012 at 7:20 pm
    #19423: using formfield_overrides to set CharField size causes all admin fields to
    use last max_length in model definition
    -------------------------------------+-------------------------------------
    Reporter: joebuyer@… | Owner: nobody
    Type: Bug | Status: new
    Component: contrib.admin | Version: master
    Severity: Normal | Resolution:
    Keywords: max_length | Triage Stage: Accepted
    formfield_overrides | Needs documentation: 0
    Has patch: 0 | Patch needs improvement: 0
    Needs tests: 0 | UI/UX: 0
    Easy pickings: 0 |
    -------------------------------------+-------------------------------------
    Changes (by claudep):

    * version: 1.4 => master
    * component: Uncategorized => contrib.admin
    * stage: Unreviewed => Accepted


    --
    Ticket URL: <https://code.djangoproject.com/ticket/19423#comment:2>
    Django <https://code.djangoproject.com/>
    The Web framework for perfectionists with deadlines.

    --
    You received this message because you are subscribed to the Google Groups "Django updates" group.
    To post to this group, send email to django-updates@googlegroups.com.
    To unsubscribe from this group, send email to django-updates+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Django at Dec 7, 2012 at 8:41 pm
    #19423: using formfield_overrides to set CharField size causes all admin fields to
    use last max_length in model definition
    -------------------------------------+-------------------------------------
    Reporter: joebuyer@… | Owner: nobody
    Type: Bug | Status: new
    Component: contrib.admin | Version: master
    Severity: Normal | Resolution:
    Keywords: max_length | Triage Stage: Accepted
    formfield_overrides | Needs documentation: 0
    Has patch: 1 | Patch needs improvement: 0
    Needs tests: 0 | UI/UX: 0
    Easy pickings: 0 |
    -------------------------------------+-------------------------------------
    Changes (by claudep):

    * has_patch: 0 => 1


    --
    Ticket URL: <https://code.djangoproject.com/ticket/19423#comment:3>
    Django <https://code.djangoproject.com/>
    The Web framework for perfectionists with deadlines.

    --
    You received this message because you are subscribed to the Google Groups "Django updates" group.
    To post to this group, send email to django-updates@googlegroups.com.
    To unsubscribe from this group, send email to django-updates+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Django at Dec 7, 2012 at 11:58 pm
    #19423: using formfield_overrides to set CharField size causes all admin fields to
    use last max_length in model definition
    -------------------------------------+-------------------------------------
    Reporter: joebuyer@… | Owner: nobody
    Type: Bug | Status: new
    Component: contrib.admin | Version: master
    Severity: Normal | Resolution:
    Keywords: max_length | Triage Stage: Ready for
    formfield_overrides | checkin
    Has patch: 1 | Needs documentation: 0
    Needs tests: 0 | Patch needs improvement: 0
    Easy pickings: 0 | UI/UX: 0
    -------------------------------------+-------------------------------------
    Changes (by charettes):

    * stage: Accepted => Ready for checkin


    Comment:

    All tests pass on Python 2.7.3/SQlite and the added testcase failed if the
    `django/contrib/admin/options.py` patch is not applied.

    Looks good to me, marking as RFC.

    --
    Ticket URL: <https://code.djangoproject.com/ticket/19423#comment:4>
    Django <https://code.djangoproject.com/>
    The Web framework for perfectionists with deadlines.

    --
    You received this message because you are subscribed to the Google Groups "Django updates" group.
    To post to this group, send email to django-updates@googlegroups.com.
    To unsubscribe from this group, send email to django-updates+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Django at Dec 8, 2012 at 11:47 am
    #19423: using formfield_overrides to set CharField size causes all admin fields to
    use last max_length in model definition
    -------------------------------------+-------------------------------------
    Reporter: joebuyer@… | Owner: nobody
    Type: Bug | Status: closed
    Component: contrib.admin | Version: master
    Severity: Normal | Resolution: fixed
    Keywords: max_length | Triage Stage: Ready for
    formfield_overrides | checkin
    Has patch: 1 | Needs documentation: 0
    Needs tests: 0 | Patch needs improvement: 0
    Easy pickings: 0 | UI/UX: 0
    -------------------------------------+-------------------------------------
    Changes (by Claude Paroz <claude@…>):

    * status: new => closed
    * resolution: => fixed


    Comment:

    In [changeset:"04e6542b5a904762a4e723c9b04ba5650ee9dc2e"]:
    {{{
    #!CommitTicketReference repository=""
    revision="04e6542b5a904762a4e723c9b04ba5650ee9dc2e"
    Fixed #19423 -- Prevented ModelAdmin sharing widgets due to
    formfield_overrides

    Thanks joebuyer at manycycles.com for the report and Simon Charette
    for the review.
    }}}

    --
    Ticket URL: <https://code.djangoproject.com/ticket/19423#comment:5>
    Django <https://code.djangoproject.com/>
    The Web framework for perfectionists with deadlines.

    --
    You received this message because you are subscribed to the Google Groups "Django updates" group.
    To post to this group, send email to django-updates@googlegroups.com.
    To unsubscribe from this group, send email to django-updates+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Django at Dec 8, 2012 at 11:48 am
    #19423: using formfield_overrides to set CharField size causes all admin fields to
    use last max_length in model definition
    -------------------------------------+-------------------------------------
    Reporter: joebuyer@… | Owner: nobody
    Type: Bug | Status: closed
    Component: contrib.admin | Version: master
    Severity: Normal | Resolution: fixed
    Keywords: max_length | Triage Stage: Ready for
    formfield_overrides | checkin
    Has patch: 1 | Needs documentation: 0
    Needs tests: 0 | Patch needs improvement: 0
    Easy pickings: 0 | UI/UX: 0
    -------------------------------------+-------------------------------------

    Comment (by Claude Paroz <claude@…>):

    In [changeset:"fa5460460696863ebd7c8ebae325b4ebce1a777b"]:
    {{{
    #!CommitTicketReference repository=""
    revision="fa5460460696863ebd7c8ebae325b4ebce1a777b"
    [1.5.x] Fixed #19423 -- Prevented ModelAdmin sharing widgets due to
    formfield_overrides

    Thanks joebuyer at manycycles.com for the report and Simon Charette
    for the review.
    Backport of 04e6542b5 from master.
    }}}

    --
    Ticket URL: <https://code.djangoproject.com/ticket/19423#comment:6>
    Django <https://code.djangoproject.com/>
    The Web framework for perfectionists with deadlines.

    --
    You received this message because you are subscribed to the Google Groups "Django updates" group.
    To post to this group, send email to django-updates@googlegroups.com.
    To unsubscribe from this group, send email to django-updates+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdjango-updates @
categoriesdjango, python
postedDec 4, '12 at 6:05p
activeDec 8, '12 at 11:48a
posts7
users1
websitedjangoproject.com

1 user in discussion

Django: 7 posts

People

Translate

site design / logo © 2018 Grokbase