-
Notifications
You must be signed in to change notification settings - Fork 293
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
Adds deconstruct methods to the US flavor. #162
Conversation
Format is cribbed from the `deconstruct` method's documentation, which provides clear examples for how to write these methods. To do this, I needed to import the models into the tests, which created some fun namespace problems.
Forgot to mention, this fixes #161. |
Hey @mlissner, this seems to make sense. But wouldn't using the |
I'm not sure if the decorator would be enough. From the example given, which I copied for the changes I used here, it seems like the decorator wouldn't be enough, but I'm really not sure how to figure out when it's essential to have a deconstruct method and when the decorator will suffice. I've been wanting to find time to look into that and do some experimentation, but I haven't been able to find time. (Indeed, here I am working on the weekend already). If you or somebody else can provide me with that direction, I can do the slog of applying the decorator (or the full method) everywhere in the codebase. |
|
||
def test_deconstruct_methods(self): | ||
"""Test the deconstruct method that was added in Django 1.7""" | ||
if django.VERSION > (1, 7): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be >=
? In practice, this shouldn't change anything as all 1.7 releases will probably be greater than (1, 7), but semantically, I think it would be clearer.
Yeah, good call. If we can figure out how to do this properly, I can include that change. |
What do you mean by "do this properly"? |
My previous question about decorator vs full method. On Mon, Aug 10, 2015, 07:26 Claude Paroz notifications@github.com wrote:
|
Theoretically, the tests could be used to check if the decorator is adequate or not. |
I just tried to run your tests without the deconstruct addition (on Django 1.8), and the tests still run fine. Could you maybe tell us the error you encounter in your project? |
I saw this as a potential problem as I was upgrading my project to Django 1.7 and reading the release notes. In there, it says:
At that point I realized that I used localflavor's custom fields, and I checked if there were I'm no expert on what this method does or why it's important, but the docs say it is, so I expect problems during migrations if it's absent. |
@mlissner We just dropped support for Django 1.5 & 1.6 (#170) and we'll probably also drop 1.7 support shortly now that it's unsupported. You can remove the conditional in the tests. As for your outstanding question, the migration documentation says that It looks like we need the
https://docs.djangoproject.com/en/1.9/topics/migrations/#adding-a-deconstruct-method It would be great if you could implement Edit: Change incorrect references about |
@mlissner Just a quick update on this. The US model fields don't need the The task now is to add |
As I understand things, the US models don't need the deconstruct method so I'm closing this PR. I'm keeping #161 open as a reminder that this needs to fixed in the other models. |
After looking that this again, I think the changes in this PR are correct. While it's not strictly required to include the deconstruct method for the case of the US fields, the Django documentation does recommend it. I'm planning to build on this PR to add deconstruct to the other model fields that need them. I've reopened this PR as a reminder for this work. Sorry about the confusion. |
Format is cribbed from the
deconstruct
method's documentation, which provides clear examples for how to write these methods. To do this, I needed to import the models into the tests, which created some fun namespace problems.