Code

Opened 4 years ago

Closed 3 years ago

#13955 closed (invalid)

capitalization of ForeignKey

Reported by: jason@… Owned by: nobody
Component: contrib.admin Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by Alex)

In a Model,

class Report(models.Model):
    report_number = models.CharField('NCAC report number', primary_key=True)

I've set the name for the capitalization of the acronym.

When I use the Model as a ForeignKey,

class RSL(models.Model):
    report_number = models.ForeignKey('Report', null=True)

the capitalization of the field name is lost, it will show up as 'Ncac report number' in the admin view for the RSL database.

Attachments (0)

Change History (6)

comment:1 Changed 4 years ago by Alex

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

I've reformatted the description of this ticket, in the future you can use the "Preview" button to ensure that your message is formatted the way you intended.

comment:2 Changed 4 years ago by ubernostrum

  • Resolution set to invalid
  • Status changed from new to closed

You've set the name for a field. To control how the name of the model itself is displayed, you need to set verbose_name in the model class' Meta declaration, as covered in the documentation.

comment:3 Changed 4 years ago by Jason Mader <jason@…>

  • Resolution invalid deleted
  • Status changed from closed to reopened

comment:4 follow-up: Changed 4 years ago by Jason Mader <jason@…>

I wasn't referring to the verbose_name of the Model, but the field that is included as the primary key of ForeignKey or ManyToManyField.

In the Admin interface if I view the model Report, the field name shows with the capitalization I set. In the view of the RSL model, the same field (the primary key of Report) does not have the same capitalization.

comment:5 in reply to: ↑ 4 Changed 4 years ago by ramiro

Replying to Jason Mader <jason@ncac.gwu.edu>:

I wasn't referring to the verbose_name of the Model, but the field that is included as the primary key of ForeignKey or ManyToManyField.

In the Admin interface if I view the model Report, the field name shows with the capitalization I set. In the view of the RSL model, the same field (the primary key of Report) does not have the same capitalization.

Are you using inlines?. Please post the complete admin setup that is need in addition to your models so people can try to reproduce the issue. It would have been a good idea to post it when you submitted the bug.

comment:6 Changed 3 years ago by ramiro

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

I've implemented a test project with the models and I don't see what you describe when looking the different views related to the RSL model in the admin, in fact I don't see the description of the Report.report_number at all.

I' closing this ticket again with status invalid. Please reopen it only if you are willing to provide the complete models and admin setup plus description of where you are seeing the 'NCAC report number' with the case of 'NCAC' changed. For example, you omitted the required max_length option in the Report.report_number field and the app wouldn't even validate with that error.

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.