question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: 'NoneType' object has no attribute 'is_descendant_of'

See original GitHub issue

I know, that similar issue was marked as solved few months ago, but I am experiencing this issue now again when using postgres.

Summary

I always get unhandled exeption when creating subpage or when moving some page under another one. It only happens with postgres.

Steps to reproduce

  1. create basic django-cms project following the how to
  2. set up the database connection to use postgresql database (Fedora 25, Postgresql 9.5)
  3. create page “Home” in the admin (BTW, the wizzard, which appears, if there is no page, doesn’t work, as I can’t select the “Create page”)
  4. try to create subpage of the page created in previous step
Internal Server Error: /admin/cms/page/add/
Traceback (most recent call last):
  File "/home/misli/testcms/django-cms-site/lib/python2.7/site-packages/django/core/handlers/base.py", line 149, in get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/misli/testcms/django-cms-site/lib/python2.7/site-packages/django/core/handlers/base.py", line 147, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/misli/testcms/django-cms-site/lib/python2.7/site-packages/django/contrib/admin/options.py", line 541, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "/home/misli/testcms/django-cms-site/lib/python2.7/site-packages/django/utils/decorators.py", line 149, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/home/misli/testcms/django-cms-site/lib/python2.7/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/home/misli/testcms/django-cms-site/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 244, in inner
    return view(request, *args, **kwargs)
  File "/home/misli/testcms/django-cms-site/lib/python2.7/site-packages/cms/admin/pageadmin.py", line 374, in add_view
    return super(PageAdmin, self).add_view(request, form_url, extra_context=extra_context)
  File "/home/misli/testcms/django-cms-site/lib/python2.7/site-packages/django/contrib/admin/options.py", line 1437, in add_view
    return self.changeform_view(request, None, form_url, extra_context)
  File "/home/misli/testcms/django-cms-site/lib/python2.7/site-packages/django/utils/decorators.py", line 67, in _wrapper
    return bound_func(*args, **kwargs)
  File "/home/misli/testcms/django-cms-site/lib/python2.7/site-packages/django/utils/decorators.py", line 149, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/home/misli/testcms/django-cms-site/lib/python2.7/site-packages/django/utils/decorators.py", line 63, in bound_func
    return func.__get__(self, type(self))(*args2, **kwargs2)
  File "/home/misli/testcms/django-cms-site/lib/python2.7/site-packages/django/utils/decorators.py", line 184, in inner
    return func(*args, **kwargs)
  File "/home/misli/testcms/django-cms-site/lib/python2.7/site-packages/django/contrib/admin/options.py", line 1378, in changeform_view
    self.save_model(request, new_object, form, not add)
  File "/home/misli/testcms/django-cms-site/lib/python2.7/site-packages/cms/admin/pageadmin.py", line 167, in save_model
    obj = obj.move(target, pos=position)
  File "/home/misli/testcms/django-cms-site/lib/python2.7/site-packages/cms/models/pagemodel.py", line 1450, in move
    super(Page, self).move(target, pos)
  File "/home/misli/testcms/django-cms-site/lib/python2.7/site-packages/treebeard/mp_tree.py", line 1046, in move
    return MP_MoveHandler(self, target, pos).process()
  File "/home/misli/testcms/django-cms-site/lib/python2.7/site-packages/treebeard/mp_tree.py", line 444, in process
    if self.target.is_descendant_of(self.node):
AttributeError: 'NoneType' object has no attribute 'is_descendant_of'

Environment

  • Python version: 2.7.13
  • Django version: 1.9.12
  • django CMS version: 3.4.2
appdirs==1.4.2
Django==1.9.12
django-classy-tags==0.8.0
django-cms==3.4.2
django-formtools==2.0
django-sekizai==0.10.0
django-treebeard==4.1.0
djangocms-admin-style==1.2.6.2
packaging==16.8
psycopg2==2.6.2
pyparsing==2.1.10
six==1.10.0

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
mislicommented, Mar 12, 2017

Well, it took me some time, but I have finally found it. As I have written in the previous comment, the collation matters. You haven’t encountered this issue, as You probably use en_US.UTF-8 as default collation. But for different locales the default collation is also different. On system with system default locale for example (my case) cs_CZ.UTF-8 the command su - postgres -c "createdb test" creates database as following:

CREATE DATABASE test
  WITH OWNER = postgres
       ENCODING = 'UTF8'
       TABLESPACE = pg_default
       LC_COLLATE = 'cs_CZ.UTF-8'
       LC_CTYPE = 'cs_CZ.UTF-8'
       CONNECTION LIMIT = -1;

It is not wrong. I want all the names, titles, etc. to be sorted correctly (č between c and d, ch between h and i, etc.), but in case of public.cms_page.path the collation should always ensure that 0 is lower than A. Therefore i’d suggest to always use “C”. I’ll create an issue for treebeard, but some note in django-cms documentation would also be nice.

1reaction
mislicommented, Mar 1, 2017

Unfortunately, the result is the same even using the installer. Both creating a subpage or moving a page under another one fails. I’ll try to investigate, why it is happening.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why do I get AttributeError: 'NoneType' object has no attribute ...
NoneType means that instead of an instance of whatever Class or Object you think you're working with, you've actually got None .
Read more >
AttributeError: 'NoneType' object has no attribute 'viewport' #108
Often semshi throws an error when vim gets resized. It might be a conflict with other plugins installed, but it sometimes happens. No...
Read more >
AttributeError: 'NoneType' object has no attribute 'AsValueString
Trying to create a simple script but getting this error. Don't understand why because i can clearly see the value in it. “AttributeError: ......
Read more >
AttributeError: 'NoneType' object has no attribute 'pop'
AttributeError means that there was an Error that had to do with an Attribute request. In general, when you write x.y, y is...
Read more >
AttributeError: 'NoneType' object has no attribute 'getReleases'
Hi there, I am currently trying to get my experiment to integrate with our Biopac shock hardware via parallel port. I am running...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found