jpwatts / django-positions

A Django field for custom model ordering.
BSD 3-Clause "New" or "Revised" License
284 stars 71 forks source link

Django 2.0 "'PositionField' object has no attribute 'get_cache_name'" #57

Closed jasonHav closed 6 years ago

jasonHav commented 6 years ago

Hi Guys,

I'm updating an (admittedly inherited) project to Django 2.0 and it uses your Django-positions library.

Since the upgrade, I'm getting the following error when rendering a PositionField:

'PositionField' object has no attribute 'get_cache_name'

I checked Django's side and it looks like that's no longer on IntegerFields (though I may be wrong). Any ideas or tips on where to go from where?

aalemayhu commented 6 years ago

Was going to try out this module but hitting the same issue. Is there any fix for it? Thanks.

jasonHav commented 6 years ago

@scanf I just switched over to the 'django2.0' branch and so far so good.

forrestp commented 6 years ago

hey guys, sorry for the poor communication here- I've worked out most the issues with django 2.0 and now I'm spending a bit of time getting all the tests in working order. All of them are passing except for python3.6-django2.0-mysql and python2.6-django1.11-mysql, I should be able to fix those and cut a release on pypi tomorrow. If not, then definitely by mid next week.

What version of python are you guys running? Right now I only have python3.6 in the CI builds, but I suspect everything will work with 3.5 and 3.4. I'll add those to the build matrix upon request.

jasonHav commented 6 years ago

I saw the commit - definitely was not an easy switch :) I'm on 3.6, and using Postgres (which explains why I've had no issues).

forrestp commented 6 years ago

ok, I got everything working and cut a 0.6.0 release. definitely let me know if there are any problems.

JulianTenschert commented 6 years ago

I've got the same error with multi-table model inheritance, parent_link is set as described in the README.

error:

AttributeError at /admin/courses/imageslide/ 'ImageSlide' object has no attribute '_positioncache'

models.py:

class Slide(models.Model):
    course = models.ForeignKey(Course, on_delete=models.CASCADE, related_name='slides')
    position = PositionField(collection='course', parent_link='slide_ptr_id')

class ImageSlide(Slide):
    image = models.ImageField(upload_to=upload_file_path, max_length=255)

class QuizSlide(Slide):
    question = models.CharField(max_length=255)

Has anyone tried django-positions with Django 2.0 and multi-table model inheritance yet?