#5731: [newforms-admin] - remove & replace radio_admin
-------------------------------------------------+--------------------------
Reporter: Karen Tracey <[EMAIL PROTECTED]> | Owner: nobody
Status: new | Component: Admin
interface
Version: newforms-admin | Resolution:
Keywords: radio_admin | Stage:
Accepted
Has_patch: 0 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
-------------------------------------------------+--------------------------
Comment (by Karen Tracey <[EMAIL PROTECTED]>):
Attached radio_admin_fields.diff, a patch which removes the old
radio_admin Field attribute and replaces it with
radio_admin_fields in ModelAdmin. Here's some text for the newforms-admin
branch page:
-----
=== Moved radio_admin from the model definition ===
The syntax is now separated from the definition of your models.
An example:
{{{
#!python
# OLD:
class MyModel(models.Model):
field1 = models.ForeignKey(AnotherModel, radio_admin=True)
field2 = models.CharField(max_length=100, radio_admin=models.VERTICAL)
class Admin:
pass
# NEW:
class MyModel_Options(admin.ModelAdmin):
model = MyModel
radio_admin_fields = {'field1': admin.HORIZONTAL, 'field2':
admin.VERTICAL }
}}}
-----
The use of models.HORIZONTAL/VERTICAL was not documented, but it was used
by django.contrib.redirects, so I
maintained the old behavior. I included my best shot at some tests and
doc...what doc I found for the new
scheme is pretty bare bones so I just plunked down a revised version of
the old doc around where it looks
like the doc for ModelAdmin specifics will go.
The second patch, 4080.diff, is a fix needed to make the display of
radio_admin_fields look pretty, but
it's really a separate issue so I split it out from the other patch. The
code fix is part of the proposed
fix for #4080 (the rest of that proposed fix has already been implemented
through fixing some other ticket),
plus 4080.diff fixes the testcases affected by the fix. #4080 was closed
as a dup of #4117, which is a
broader issue, and that one is waiting in design decision needed.
All that is needed for the radio_admin_fields display to look pretty is
for the attrs specified on creation
of the RadioSelect widget to be included on the <ul> generated in the
output -- right now the attrs are only
being included on the individual <li>s. The simple fix proposed by #4080
seems correct to me, so that is what
I used to test with for radio_admin_fields. If some other fix is made for
#4117 then the radio_admin_fields
code might need to change slightly. (The effect of running without any
fix for this issue is that the
RadioSelect list is bulleted, which looks funny, and items are not spaced
as nicely as they could be.)
(There is also the capability to sidestep the whole issue of #4080 by
writing a custom renderer, but ugh,
that would be 99% duplicated code with the default renderer. My
impression was tht capability was added
for cases where the desired output was something other than an unordered
list, which is not the case for
radio_admin_fields, so I did not pursue that path.)
--
Ticket URL: <http://code.djangoproject.com/ticket/5731#comment:2>
Django Code <http://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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---