Opened 11 months ago

Closed 11 months ago

Last modified 11 months ago

#23362 closed Cleanup/optimization (fixed)

Database Columns as "Attributes"

Reported by: MalikRumi Owned by: nobody
Component: Documentation Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I recently got an Attribute Error which told me that my type object 'Articles' has no attribute 'name'. Well, I thought that was crazy, because 'name' was the very first field on my Articles model. I did some digging in dir() on the shell, only to find out that indeed Articles did not have an attribute 'name'. Digging further, I found that it did have an 'object' called name, but these objects are not Python attributes, or perhaps, only become attributes at runtime. So where did I get the idea that they were?

https://docs.djangoproject.com/en/1.6/intro/tutorial01/
{{{# Access database columns via Python attributes.

p.question

"What's new?"

p.pub_date

datetime.datetime(2012, 2, 26, 13, 0, 0, 775217, tzinfo=<UTC>)}}}

I think this language needs to be clarified. One could argue that the proper interpretation is ‘access database columns as if’, or ‘in the same style as’, rather ‘through their’(nonexistent) Python attributes.

Change History (5)

comment:1 Changed 11 months ago by timgraham

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Type changed from Uncategorized to Cleanup/optimization

How about # Access model field values via Python attributes.?

comment:2 Changed 11 months ago by Tim Graham <timograham@…>

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

In 035f2e699c3f7fbd41bc5ba0a59551e4c3dbdba6:

Fixed #23362 -- Clarified "database columns as attributes" in tutorial.

comment:3 follow-up: Changed 11 months ago by Tim Graham <timograham@…>

In 808722e062ff261af4f24342b15fcf67c37c5cf0:

[1.7.x] Fixed #23362 -- Clarified "database columns as attributes" in tutorial.

Backport of 035f2e699c from master

comment:4 in reply to: ↑ 3 Changed 11 months ago by MalikRumi

Replying to Tim Graham <timograham@…>:

In 808722e062ff261af4f24342b15fcf67c37c5cf0:

[1.7.x] Fixed #23362 -- Clarified "database columns as attributes" in tutorial.

Backport of 035f2e699c from master

I see you've already closed this. Thanks for at least paying attention. I was not ignoring you, just late getting back to the party. This change will probably work, but I'd like to think about it. I reserve the right to change my mind ;-). BTW, before I got into programming, I actually was a writer. I think writing about something is a good way to learn since it forces you (or at least, some people) to actually know what you are talking about. How would I get started?

comment:5 Changed 11 months ago by timgraham

You can read about contributing to Django's documentation in our contributing guide.

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