Django 1.8 support #297

Merged
merged 10 commits into from Apr 3, 2015

Projects

None yet

6 participants

@kaedroho
Contributor

Addresses #284

This brings Taggit up to speed with Django 1.8 beta 2. There may be more work to do before the final release but this should get us most of the way there.

kaedroho added some commits Mar 14, 2015
@kaedroho kaedroho Don't set .related attribute on Django 1.8+
This has been merged with .rel
255a0ca
@kaedroho kaedroho Added TaggableManager field flags 7f53d48
@kaedroho kaedroho Pass rel into Field constructor 986d9e9
@kaedroho kaedroho Import PathInfo from Django 1.8 location 33babe2
@kaedroho kaedroho .related.model value has changed in Django 1.8
This is because it is now a ForeignObjectRel instead of a RelatedObject

https://code.djangoproject.com/ticket/21414
794d1a0
@kaedroho kaedroho Set __hash__ attribute on _TaggableManager
Django 1.8 adds an __eq__ method to BaseManager. In Python 3.x this makes the default __hash__ method disappear making _TaggableManager unhashable.
Commit: django/django@aa5ef0d

This causes a TypeError in the following code (where the _TaggableManger object gets inserted into a set): https://github.com/django/django/blob/stable/1.8.x/django/db/models/query.py#L1526

This commit manually reinstates the __hash__ method to make _TaggableManager behave the same way it does in previous versions of Django.
1128c64
@kaedroho kaedroho Added Django 1.8 to tox/Travis c4b366c
@kaedroho kaedroho Django 1.8 support for _get_subclasses 39b8b82
@kaedroho
Contributor

All tests are now passing. Travis reports an error with Django 1.8/Python 2.7. This appears to be an issue with installing Django and I've sucessfully run the tests locally on Python 2.7/Django 1.8.

@collinanderson
Contributor

Interesting. The 1.8 issue might be this django/django@bd059e3#commitcomment-10220493

Maybe switching from 1.8.x.zip to 1.8.x.tar.gz might fix it?

Update: Yes, it works, see #298.

@collinanderson
Contributor

We could also change the tag_model property to use get_field() on 1.8 so it doesn't raise a deprecation warning about get_field_by_name.

@collinanderson
Contributor

I started switching the get_field_by_name's but there's too many :). Probably out of scope for this PR.

Update: I've fixed this in #299.

@collinanderson
Contributor

In any case, I tested this, and it at least works on my site :)

@dtiesling dtiesling commented on the diff Mar 17, 2015
taggit/managers.py
@@ -309,13 +339,18 @@ def __lt__(self, other):
return False
def post_through_setup(self, cls):
- self.related = RelatedObject(cls, self.model, self)
+ if RelatedObject is not None: # Django < 1.8
@dtiesling
dtiesling Mar 17, 2015

I'm able to import RelatedObject in django 1.8b2 so this logic is no longer working. Could you use django.VERSION for this instead?

@kaedroho
kaedroho Mar 18, 2015 Contributor

related.py is gone in the latest code: https://github.com/django/django/tree/stable/1.8.x/django/db/models

Maybe it's a .pyc file hanging around from an older version, could you try reinstalling Django?

@collinanderson
collinanderson Mar 18, 2015 Contributor

Interesting. If @dtiesling is running into that problem, I bet others will too. I wonder if we should use the VERSION method just to be safe.

@dtiesling
dtiesling Mar 18, 2015

thanks @kaedroho, you were right it was leftover files from not doing a clean install of django. I agree with @collinanderson I'm sure I won't be the only person to not think to clear out the old django before upgrading.

@kaedroho
kaedroho Mar 26, 2015 Contributor

Fixed in 16f9f4a

@collinanderson collinanderson and 1 other commented on an outdated diff Mar 18, 2015
+ - env: TOXENV=py27-1.5.x
+ - env: TOXENV=py27-1.6.x
+ - env: TOXENV=py27-1.7.x
+ - env: TOXENV=py27-1.8.x
+ - env: TOXENV=py33-1.5.x
+ - env: TOXENV=py33-1.6.x
+ - env: TOXENV=py33-1.7.x
+ - env: TOXENV=py33-1.8.x
+ - env: TOXENV=py34-1.5.x
+ - env: TOXENV=py34-1.6.x
+ - env: TOXENV=py34-1.7.x
+ - env: TOXENV=py34-1.8.x
+ allow_failures:
+ - env: TOXENV=py27-1.8.x
+ - env: TOXENV=py33-1.8.x
+ - env: TOXENV=py34-1.8.x
@collinanderson
collinanderson Mar 18, 2015 Contributor

Do you want to remove or revert the allow_failures commit?

@kaedroho
kaedroho Mar 18, 2015 Contributor

Yes, i'll remove it. Thanks

@collinanderson
Contributor

Also, if you didn't notice, it looks like you need to bring the .tar.gz change back.

@kaedroho
Contributor

Oops, thanks for spotting! (changed all Django versions this time)

@kaedroho kaedroho Never import related.py on Django 1.8
It's possible that this file could exist on some peoples systems, depending on how they updated this Django.

This commit adds a check to make sure we never import related.py on Django 1.8
16f9f4a
@collinanderson
Contributor

This looks good to me, at least :)

@frewsxcv
Collaborator

I'll merge this as soon as 1.8 final is out and i'll push a new taggit release.

@chhantyal

As 1.8 is released (https://www.djangoproject.com/weblog/2015/apr/01/release-18-final/), can we please accept this PR and update PyPi?

@frewsxcv
Collaborator
frewsxcv commented Apr 2, 2015

Has anyone tested this with the final release of 1.8? The new version came out when I was on a flight. I'll look at merging this tomorrow.

@frewsxcv frewsxcv closed this Apr 2, 2015
@frewsxcv frewsxcv reopened this Apr 2, 2015
@frewsxcv
Collaborator
frewsxcv commented Apr 2, 2015

Reopened to rerun the travis tests

@troygrosfield

👍

@frewsxcv
Collaborator
frewsxcv commented Apr 3, 2015

Great work @kaedroho! Thanks! Here is cake

@frewsxcv frewsxcv merged commit 51d7117 into alex:develop Apr 3, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@frewsxcv
Collaborator
frewsxcv commented Apr 3, 2015

0.13.0 has been published

https://pypi.python.org/pypi/django-taggit/0.13.0

let me know if any issues arise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment