Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#22322 closed Bug (fixed)

inspectdb and managed option, incorrect explanation

Reported by: adrian.klaver@… Owned by: Tim Graham
Component: Documentation Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

https://docs.djangoproject.com/en/1.6/howto/legacy-databases/

"If you wanted to modify existing data on your CENSUS_PERSONS SQL table with Django you’d need to change the managed option highlighted above to True (or simply remove it to let it because True is its default value).

This serves as an explicit opt-in to give your nascent Django project write access to your precious data on a model by model basis.
Changed in Django 1.6:

The behavior by which introspected models are created as unmanaged ones is new in Django 1.6.
"

If you click on the managed link in the above you get:

"If False, no database table creation or deletion operations will be performed for this model. This is useful if the model represents an existing table or a database view that has been created by some other means. This is the only difference when managed=False. All other aspects of model handling are exactly the same as normal. This includes"

My use experience is that managed does not have anything to do with record creation/deletion just model creation/deletion as in the second text above. It would seem the texts should be brought into agreement.

Change History (6)

comment:1 Changed 3 years ago by Tim Graham

Owner: changed from nobody to Tim Graham
Status: newassigned
Triage Stage: UnreviewedAccepted

Yes, the text added in #14305 describes managed incorrectly.

comment:2 Changed 3 years ago by Adrian Klaver <adrian.klaver@…>

FYI this also shows up in the comments section of the models.py generated by inspectedb as:

  • Remove managed = False lines for those models you wish to give write DB access

Thanks for working on this.

comment:3 Changed 3 years ago by Tim Graham

Has patch: set

Pull request for review. I plan to backport this to 1.6 but will remove the bit about table modification since we don't have schema migrations there.

comment:4 Changed 3 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In 9b7ba8af1b4ddb539cd69cbec9645cd873db7624:

Fixed #22322 -- Fixed incorrect explanation of what managed=False does.

refs #14305.

Thanks Adrian Klaver for the report.

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

In c0a9c2f72ac289b2ba8313c6a2c56be5ed94f01d:

[1.6.x] Fixed #22322 -- Fixed incorrect explanation of what managed=False does.

refs #14305.

Thanks Adrian Klaver for the report.

Backport of 9b7ba8af1b4ddb539cd69cbec9645cd873db7624 from master

comment:6 Changed 3 years ago by Tim Graham <timograham@…>

In 7eaf329ad38ff7ea6b47f1b0a3c20ca7a5ad079b:

[1.7.x] Fixed #22322 -- Fixed incorrect explanation of what managed=False does.

refs #14305.

Thanks Adrian Klaver for the report.

Backport of 9b7ba8af1b from master

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