Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for model packages #34

Merged
merged 3 commits into from
Apr 24, 2013
Merged

Add support for model packages #34

merged 3 commits into from
Apr 24, 2013

Conversation

treyhunner
Copy link
Member

Tests and code to fix #7.

Will be merged once working.

register() will place records under given app.
Meta app_label will place both model / records under given app.
@dnozay
Copy link
Contributor

dnozay commented Apr 23, 2013

@treyhunner, this seems good to merge, will wait for you to pull the trigger.

@treyhunner
Copy link
Member Author

I'm not sure this tests the same problem that #7 notes.

It seems like a test of this would structure the models as:

/tests/external/models/__init__.py  # imports everything from model1
/tests/external/models/model1.py

This app is structured this way: https://github.com/thauber/django-schedule/tree/master/schedule/models

@dnozay
Copy link
Contributor

dnozay commented Apr 23, 2013

this is the same problem in fact. when models are defined in another module and get created from models.Model metaclass, it needs to specify app_label to go under the correct app. the tests previously had it a little backwards where ExternalModel1 / ExternalModel3 use app_label rather than mimic directory structure, same behavior however.

@@ -135,9 +143,10 @@ def get_meta_options(self, model):
Returns a dictionary of fields that will be added to
the Meta inner class of the historical record model.
"""
return {
options = {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reasoning behind this style change?

PEP8 doesn't state an opinion on this, but I've always preferred return {...} over x = {...} ; return x.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too many things at once, was looking at issue #26 but failed to revert that part.

@treyhunner
Copy link
Member Author

It wasn't clear to me before that it was testing the same thing. It's definitely clear to me now. The tests seem to properly fail when the code change is reverted.

This looks good for merging to me.

dnozay added a commit that referenced this pull request Apr 24, 2013
Add support for model packages
@dnozay dnozay merged commit e12135f into master Apr 24, 2013
@dnozay dnozay deleted the applabel branch April 24, 2013 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

history property not picked when model class is in a models directory
3 participants