#25127: document how to define models in multiple modules
--------------------------------------+------------------------------------
     Reporter:  keturn                |                    Owner:  palmerev
         Type:  Cleanup/optimization  |                   Status:  assigned
    Component:  Documentation         |                  Version:  1.8
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  1                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  1
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------

Comment (by keturn):

 > You can then import classes directly from the `models` module as you
 normally would.

 Yes, if you import them to `models/__init__.py`, you can import them
 elsewhere as `.models.Robot`, but `.models.robot.Robot` also works if you
 want to take advantage of that structure you created when you split things
 out into multiple models files.

 (which for `robot.Robot` sounds redundant but maybe `from
 .models.synthetics import Robot, Android` would be useful.)

 This is the part I feel most unsure about what to include in the
 documentation, because one hand I think the "There Should Be One Obvious
 Way To Do" it principle applies here, so it seems disadvantageous to go in
 to a lot of "you could import it this way **or** this way **or**..."

 On the other hand, I can also imagine myself coming to this and thinking,
 "wait, if I have to import things as if they were in `myapp.models`
 anyway, then doesn't that sort of defeat the purpose of splitting them
 up?"

--
Ticket URL: <https://code.djangoproject.com/ticket/25127#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.fcbdf36ae623763bc3c780aca8c3c747%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to