Code

Opened 6 years ago

Closed 6 years ago

#7838 closed (fixed)

Type inconsistency in part 2 of the tutorial

Reported by: kratorius Owned by: nobody
Component: Documentation Version: master
Severity: Keywords: doc documentation newforms-admin nfa
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

In the "Customize the admin form" section, we have the following code snippet:

class PollAdmin(admin.ModelAdmin):
    fieldsets = [
        (None,               {'fields': ['question']}),
        ('Date information', {'fields': ['pub_date'], 'classes': 'pub_date'}),
    ]

But that should be:

class PollAdmin(admin.ModelAdmin):
    fieldsets = [
        (None,               {'fields': ['question']}),
        ('Date information', {'fields': ['pub_date'], 'classes': ['collapse']}),
    ]

There are two issues here with the classes attribute:

  • the argument should be collapse, not pub_date
  • and should be an iterable sequence, not a string as in the admin is then rendered as "c o l l a p s e" (iterating over the chars)

Now it's not clear what should be the right behaviour: accept both iterable sequences and strings (by "special casing" them, a if type(sequence) == str: sequence = [sequence] should do the work), or raising some error if the wrong type is passed.

The same error is in the second example of the "Adding related objects" section.

Attachments (2)

7839.diff (1.8 KB) - added by Jan Rademaker <j.rademaker@…> 6 years ago.
Assuming the documentation is wrong; here's the patch I had already written for #7839.
tutorial02.patch (968 bytes) - added by kratorius 6 years ago.
fixes typo in tutorial

Download all attachments as: .zip

Change History (6)

Changed 6 years ago by Jan Rademaker <j.rademaker@…>

Assuming the documentation is wrong; here's the patch I had already written for #7839.

comment:1 Changed 6 years ago by brosner

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to fixed
  • Status changed from new to closed

Whoops didn't see this. I already closed #7839 with a fix. Closing this one too. Fix was in [7983].

comment:2 Changed 6 years ago by kratorius

  • Has patch set
  • Resolution fixed deleted
  • Status changed from closed to reopened

Not completely closed: as I said the classes value should be collapse, not pub_date.

Changed 6 years ago by kratorius

fixes typo in tutorial

comment:3 Changed 6 years ago by brosner

Ah, my bad. Should have read that. Will fix now.

comment:4 Changed 6 years ago by brosner

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [7984]) Fixed #7838 -- Corrected an invalid class name the 'classes' usage in the tutorial. Thanks kratorius for catching this.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.