django-categories icon indicating copy to clipboard operation
django-categories copied to clipboard

ValueError at /admin/categories/category/add/

Open fission6 opened this issue 9 years ago • 4 comments

When using the Admin to create a new category the following traceback occurs

screen shot 2015-07-10 at 5 01 23 pm

this is the line that is causing issues

decendant_ids = self.instance.get_descendants().values_list('id', flat=True)

versions django==1.8.3 django-mptt==0.7.4 django-categories==1.3 # installed directly from the git repo

Note that using the ORM works: Category(name='whatever').save() works

fission6 avatar Jul 10 '15 21:07 fission6

I'm having this same issue as well. I think it has to do with changes to the django-mptt module (https://github.com/django-mptt/django-mptt). Seems like the error message is part of code that is new to the 0.7.x branch. Unfortunately, if you try to go back to 0.6.x it breaks Django 1.8!

My Python / Django skills are not good enough to fix this. Any help will be apprecited.

esomething avatar Jul 16 '15 21:07 esomething

I'm testing, but this has worked for me.

Line 111 in base.py
-------------------------
decendant_ids = self.instance.get_descendants().values_list('id', flat=True)

to:

if self.instance.pk:
    decendant_ids = self.instance.get_descendants().values_list('id', flat=True)
else:
    decendant_ids = []

https://github.com/callowayproject/django-categories/pull/99

Nekmo avatar Jul 22 '15 15:07 Nekmo

+1

bashu avatar Aug 15 '15 09:08 bashu

yet another +1

johanndt avatar Oct 07 '15 06:10 johanndt