Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#23362 closed Cleanup/optimization (fixed)

Database Columns as "Attributes"

Reported by: Malik A. Rumi 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 by Tim Graham, 10 years ago

Type: UncategorizedCleanup/optimization

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

comment:2 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: newclosed

In 035f2e699c3f7fbd41bc5ba0a59551e4c3dbdba6:

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

comment:3 by Tim Graham <timograham@…>, 10 years ago

In 808722e062ff261af4f24342b15fcf67c37c5cf0:

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

Backport of 035f2e699c from master

in reply to:  3 comment:4 by Malik A. Rumi, 10 years ago

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 by Tim Graham, 10 years ago

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

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