Opened 5 years ago

Closed 5 years ago

#20876 closed Cleanup/optimization (fixed)

Change Poll model name in tutorial to Question

Reported by: anonymous Owned by: Tim Graham
Component: Documentation Version: master
Severity: Normal Keywords: afraid-to-commit
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: yes


having the project and the app both be called polls is not helpful. makes it awkward to read and understand for a new django user where exactly things are being put. how the directory / namespace structure fits together.

Change History (15)

comment:1 Changed 5 years ago by Tim Graham

Resolution: needsinfo
Status: newclosed

I assume this is in reference to the tutorial, but the project there is called mysite so I'm not sure what this is asking for.

comment:2 Changed 5 years ago by Russell Keith-Magee

Resolution: needsinfo
Status: closednew
Triage Stage: UnreviewedAccepted

I think the reporter is describing that a project called mysite, with an app called polls, with a model called Poll is asking for trouble -- it would be better to use a completely unrelated name like "survey" for the app, so you are talking about survey.Poll not polls.Poll, making it clear that it's not just a matter of pluralization.

I'm not saying survey is necessarily the best alternative name -- just pointing out that a name other than "polls" would be beneficial.

comment:3 Changed 5 years ago by Dima Kurguzov

After the Two Scoops of Django book I prefer to name apps with a plural version of the main app's model if I don't see another more obvious option.
The polls app's name seems to be clear enough.

comment:4 Changed 5 years ago by Saul Shanabrook

Many of my own apps share the same "problem", (i.e. artists.Artist, 'updates.Update'). I have found this to make sense when an app is really focused on a single model.

Do people consider this an antipattern that we don't want in the tutorial?

comment:5 Changed 5 years ago by Tim Graham

I'm inclined to agree with the last two comments and "won't fix", but I'll leave open for another opinion given that Russ accepted the ticket.

comment:6 Changed 5 years ago by Russell Keith-Magee

I also agree with the previous two comments, and I make use the "plural for app, singular for model" pattern in naming my own apps - but I still think the tutorial should be changed.

We're not talking about general usage here. We're talking about a tutorial. This is the user's first experience with Django. Removing any source of confusion is a good thing. As it currently stands, we're talking about Poll, poll, and polls, and they all refer to different things -- one keystroke difference between all three. It's trivial to misread, or to become confused as to which object you're using. Grammatically (English grammar, not Python), it makes complete sense to say polls.objects.get() - so why doesn't that work? After all, I just defined a Poll object, right? I make a poll, I retrieve from a list of polls, don't I?

Once you've established the basic app/model pattern, *then* you can start introducing the idea of using pluralization in names.

If we're not going to rename the polls app, it definitely warrants a pullout box that gives an overview of the naming scheme, drawing attention to the fact that there are three distinct objects here, all with different roles.

comment:7 Changed 5 years ago by Daniele Procida

Keywords: afraid-to-commit added

I agree that this is an issue. I think that the best solution is to follow the example of the Choicemodel, so that our two models at will look like:

class Question(models.Model):
    question_text = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')

class Choice(models.Model):
    poll = models.ForeignKey(Question)
    choice_text = models.CharField(max_length=200)
    votes = models.IntegerField(default=0)

comment:8 Changed 5 years ago by Rodolfo Sanchez

Owner: changed from nobody to Rodolfo Sanchez
Status: newassigned

comment:9 Changed 5 years ago by Rodolfo Sanchez

Triage Stage: AcceptedReady for checkin

I just made a pull request to this issue at The reason of this is that the patch file is too big to attach it in the ticket track.

comment:10 Changed 5 years ago by Rodolfo Sanchez

Version: 1.5master

comment:11 Changed 5 years ago by Tim Graham

Has patch: set
Triage Stage: Ready for checkinAccepted

Please don't mark your own patch as Ready for checkin. Someone else needs to review it and do that.

comment:12 Changed 5 years ago by Tim Graham

Owner: changed from Rodolfo Sanchez to Tim Graham
Summary: Polls in pollsChange Poll model name in tutorial to Question

Review in progress.

comment:13 Changed 5 years ago by Rodolfo Sanchez

Sorry, I did not see the stage of reviewing and I thought it was that.

comment:14 Changed 5 years ago by Rodolfo Sanchez

the new images are in the pull request

comment:15 Changed 5 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In d34b94b00fa817871939ea6c097621a3e4a87311:

Fixed #20876 -- Changed Poll model name in tutorial to Question

Note: See TracTickets for help on using tickets.
Back to Top