'NoneType' object has no attribute '_inc_path'

5,228 views
Skip to first unread message

Shawn McElroy

unread,
Feb 25, 2015, 2:03:54 PM2/25/15
to wag...@googlegroups.com

I am asking this here, because I feel like I am probably just doing something incorrect, rather than seeing a real bug. Basically I am getting this error.

AttributeError at /admin/pages/new/wagtail_articles/articleindex/3/
'NoneType' object has no attribute '_inc_path'
Request Method:         POST
Request URL:            http:
//127.0.0.1:8111/admin/pages/new/wagtail_articles/articleindex/3/
Django Version:        
1.7.4
Exception Type:         AttributeError
Exception Value:        
'NoneType' object has no attribute '_inc_path'
Exception Location:     /home/vagrant/.virtualenvs/skiftio/lib/python3.
4/site-packages/treebeard/mp_tree.py in process, line 361
Python Executable:      /home/vagrant/.virtualenvs/skiftio/bin/python
Python Version:        
3.4.2
Python Path:    
[
'/home/vagrant/skiftio',
 
'/home/vagrant/modules/wagtail_articles',
 
'/usr/local/lib/python34.zip',
 
'/usr/local/lib/python3.4',
 
'/usr/local/lib/python3.4/plat-linux',
 
'/usr/local/lib/python3.4/lib-dynload',
 
'/home/vagrant/.virtualenvs/skiftio/lib/python3.4/site-packages']
Server time:    Wed,
25 Feb 2015 08:56:04 +0000




I have what seems to be a fairly basic setup. I have made my own module I am including via installed apps, which is just a new content type I am calling 'Articles'. I have it installed via pip using 'python setup.py develop'. I get this error, when trying to create an ArticleIndex page which would be a child of the home page, then trying to save. In the model for the Article, I have ArticleIndex, and ArticlePage which are for the parent and child pages respectively. You can see what I have in the models file for the module here: https://github.com/SkiftCreative/wagtail_articles/blob/master/wagtail_articles/models.py


Here is my directory structure:























At first I thought the issue was with one of my templates, but everything seems to work fine. The article_index.html template looks like so:

{% extends "base.html" %}

{% load static wagtailcore_tags %}

{% block body_class %}template-{{ self.get_verbose_name|slugify }}{% endblock %}

{% block breadcrumb %}
    <ul class="breadcrumb" style="margin-bottom: 5px;">
       
<li><a href="{% slugurl homepage %}">Home</a></li>
       
<li class="active">Blog</li>
    </
ul>
{% endblock %}

{% block content %}
    article index
{% endblock %}



 I can't find anything in the docs or in the github issues about this error, or where to go next.

Brett Grace

unread,
Feb 25, 2015, 6:57:23 PM2/25/15
to wag...@googlegroups.com
When you save a page, I believe Wagtail attempts to prevent violations the subpage_types (and parent_page_types) constraints. If I recall correctly, however, if those attributes have an illegal specification, the admin area will blow up with an error similar to what you are seeing.

If you can't pass a class reference to these attributes directly, you need to use the django "app_label.model_name" format so that the system can find your model. In your case, I believe that modifying your code for ArticleIndex in the following way will work:

subpage_types = ('wagtail_articles.ArticlePage',) # 'wagtail_articles' appears to be the app label

You'll need a complementary fix to the "parent_page_type" attribute of the ArticlePage.

In case that doesn't fix it for you, another approach is to run the server in the debugger. You appear to be using PyCharm or IntelliJ, and you can debug and catch exceptions that are emitted from templates. It's definitely a null pointer error of some sort.

Matthew Westcott

unread,
Feb 25, 2015, 7:01:48 PM2/25/15
to wag...@googlegroups.com
Hi Shawn,
This error would suggest that there's an inconsistency at the database level - the record for your article index page claims to have child pages, but no such child pages exist in the database. There's no way of knowing for sure how this occurred - it may have been caused by an earlier error at the point of creating a page, or something being deleted from the database manually. Either way - running the command "./manage.py fixtree" should hopefully fix it.

Cheers,
- Matt

On 25 Feb 2015, at 19:03, Shawn McElroy <sh...@skift.io> wrote:

>
> I am asking this here, because I feel like I am probably just doing something incorrect, rather than seeing a real bug. Basically I am getting this error.
>
> AttributeError at /admin/pages/new/wagtail_articles/articleindex/3/
> 'NoneType' object has no attribute '_inc_path'
> Request Method: POST
> Request URL: http://127.0.0.1:8111/admin/pages/new/wagtail_articles/articleindex/3/
> Django Version: 1.7.4
> Exception Type: AttributeError
> Exception Value: 'NoneType' object has no attribute '_inc_path'
> Exception Location: /home/vagrant/.virtualenvs/skiftio/lib/python3.4/site-packages/treebeard/mp_tree.py in process, line 361
> Python Executable: /home/vagrant/.virtualenvs/skiftio/bin/python
> Python Version: 3.4.2
> Python Path:
> ['/home/vagrant/skiftio',
> '/home/vagrant/modules/wagtail_articles',
> '/usr/local/lib/python34.zip',
> '/usr/local/lib/python3.4',
> '/usr/local/lib/python3.4/plat-linux',
> '/usr/local/lib/python3.4/lib-dynload',
> '/home/vagrant/.virtualenvs/skiftio/lib/python3.4/site-packages']
> Server time: Wed, 25 Feb 2015 08:56:04 +0000
>
>
>
> I have what seems to be a fairly basic setup. I have made my own module I am including via installed apps, which is just a new content type I am calling 'Articles'. I have it installed via pip using 'python setup.py develop'. I get this error, when trying to create an ArticleIndex page which would be a child of the home page, then trying to save. In the model for the Article, I have ArticleIndex, and ArticlePage which are for the parent and child pages respectively. You can see what I have in the models file for the module here: https://github.com/SkiftCreative/wagtail_articles/blob/master/wagtail_articles/models.py
>
>
> Here is my directory structure:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

Shawn McElroy

unread,
Feb 25, 2015, 7:55:25 PM2/25/15
to wag...@googlegroups.com
Well that sure seemed to work. And it does make sense I belive as I renamed my module after I thought i deleted the child pages. But must have missed one. This fixed it, thanks.

Ala Brazi

unread,
Aug 12, 2015, 2:27:11 PM8/12/15
to Wagtail support
I have the same problem. The solution worked for me too. It occured when I changed the content of the model including the names of the models class. 

Matthew Westcott

unread,
Aug 12, 2015, 2:48:21 PM8/12/15
to wag...@googlegroups.com
If you're renaming models, you'll need to check what the generated migration files are doing, and rewrite them if necessary. Most likely, the Django migration framework can't automatically detect that you're trying to rename a table, and is instead handling it as "drop old table; create new one". If that table contained existing articles, then dropping it is certainly going to cause corruption of the tree, which is why you need './manage.py fixtree' to fix it.

Cheers,
- Matt
> At first I thought the issue was with one of my templates, but everything seems to work fine. The article_index.html template looks like so:
>
> {% extends "base.html" %}
>
> {% load static wagtailcore_tags %}
>
> {% block body_class %}template-{{ self.get_verbose_name|slugify }}{% endblock %}
>
> {% block breadcrumb %}
> <ul class="breadcrumb" style="margin-bottom: 5px;">
> <li><a href="{% slugurl homepage %}">Home</a></li>
> <li class="active">Blog</li>
> </ul>
> {% endblock %}
>
> {% block content %}
> article index
> {% endblock %}
>
>
>
> I can't find anything in the docs or in the github issues about this error, or where to go next.
>
> --
> You received this message because you are subscribed to the Google Groups "Wagtail support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to wagtail+u...@googlegroups.com.
> To post to this group, send email to wag...@googlegroups.com.
> Visit this group at http://groups.google.com/group/wagtail.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/wagtail/eea39a26-83d7-4b98-80af-11c0aee2519f%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
Message has been deleted
0 new messages