Opened 11 years ago
Closed 11 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: | dev |
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 |
Description
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 by , 11 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
comment:2 by , 11 years ago
Resolution: | needsinfo |
---|---|
Status: | closed → new |
Triage Stage: | Unreviewed → Accepted |
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 by , 11 years ago
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 by , 11 years ago
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 by , 11 years ago
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 by , 11 years ago
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 by , 11 years ago
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 Choice
model, so that our two models at https://docs.djangoproject.com/en/1.5/intro/tutorial01/#creating-models 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 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:9 by , 11 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
I just made a pull request to this issue at https://github.com/django/django/pull/1574. The reason of this is that the patch file is too big to attach it in the ticket track.
comment:10 by , 11 years ago
Version: | 1.5 → master |
---|
comment:11 by , 11 years ago
Has patch: | set |
---|---|
Triage Stage: | Ready for checkin → Accepted |
Please don't mark your own patch as Ready for checkin. Someone else needs to review it and do that.
comment:12 by , 11 years ago
Owner: | changed from | to
---|---|
Summary: | Polls in polls → Change Poll model name in tutorial to Question |
Review in progress.
comment:14 by , 11 years ago
the new images are in the pull request https://github.com/django/django/pull/1574.
comment:15 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
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.