django-mptt show "no such column"
<p>I used MPTT to implement a forum which allow posts to latest news.I can't solve this error: "no such column: news_comment.lft"</p>

<p>The app name is news.This is models.py:</p>

<pre><code>from django.db import models
from mptt.models import MPTTModel, TreeForeignKey

class News(models.Model):
    ....

class Comment(MPTTModel):
    ....
    news    = models.ForeignKey(News,related_name='news', null=True)
    parent  = TreeForeignKey('self', null=True, blank=True, related_name='children', db_index=True)

    class MPTTMeta:
        order_insertion_by = ['created']
</code></pre>

<p>this is views.py</p>

<pre><code>def show_news(request,request_id):
    news = News.objects.get(id=request_id)
    comments = Comment.objects.filter(news=news)

    return render(  request,
                'news.html',
                {'news': news,
                 'comments': comments,})
</code></pre>

<p>This is part of news.html</p>

<pre><code>{% block title %}{{news.title}}{% endblock title %}

{% block content %}
&lt;div id='news_info'&gt;
    &lt;h1&gt;{{ news.title }}&lt;/h1&gt;
    &lt;p&gt;{{ news.created}}&lt;/p&gt;
    &lt;p&gt;{{ news.content}}&lt;/p&gt;
&lt;/div&gt;
&lt;div id="comment_list"&gt;
    &lt;h2&gt;Comments&lt;/h2&gt;
    **{% for comment in comments %} -- error here**
        {% if comment.replyto == null %}
            &lt;div class="comment_info"&gt;
             ....
</code></pre>

<p>This is error report:</p>

<pre><code>Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/news/4/

Django Version: 1.10.1
Python Version: 3.5.2
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'news',
 'mptt']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']


Template error:
In template /home/sinoease/Desktop/ross/Project/NewsPortal/news/templates/news.html, error at line 11
   no such column: news_comment.lft   
   1 : {% block title %}{{news.title}}{% endblock title %}
   2 : 
   3 : {% block content %}
   4 :     &lt;div id='news_info'&gt;
   5 :         &lt;h1&gt;{{ news.title }}&lt;/h1&gt;
   6 :         &lt;p&gt;{{ news.created}}&lt;/p&gt;
   7 :         &lt;p&gt;{{ news.content}}&lt;/p&gt;
   8 :     &lt;/div&gt;
   9 :     &lt;div id="comment_list"&gt;
   10 :         &lt;h2&gt;Comments&lt;/h2&gt;
   11 :          {% for comment in comments %} 
   12 :             {% if comment.replyto == null %}
   13 :                 &lt;div class="comment_info"&gt;
   14 :                 &lt;div class="comment_content"&gt;
   15 :                     comment info:{{comment.content}}
   16 :                 &lt;/div&gt;
   17 :                 &lt;div clss="comment_create"&gt;
   18 :                     comment on: {{comment.created}}
   19 :                 &lt;/div&gt;
   20 :                 &lt;a href="{% url 'reply_comment' news.id comment.id %}"&gt;&lt;button&gt;Reply&lt;/button&gt;&lt;/a&gt;                
   21 : 


Traceback:

File "/usr/local/lib/python3.5/dist-packages/django/db/backends/utils.py" in execute
  64.                 return self.cursor.execute(sql, params)

File "/usr/local/lib/python3.5/dist-packages/django/db/backends/sqlite3/base.py" in execute
  337.         return Database.Cursor.execute(self, query, params)

The above exception (no such column: news_comment.lft) was the direct cause of the following exception:

File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py" in inner
  39.             response = get_response(request)

File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/sinoease/Desktop/ross/Project/NewsPortal/news/views.py" in show_news
  17.                    'comments': comments,})

File "/usr/local/lib/python3.5/dist-packages/django/shortcuts.py" in render
  30.     content = loader.render_to_string(template_name, context, request, using=using)

File "/usr/local/lib/python3.5/dist-packages/django/template/loader.py" in render_to_string
  68.     return template.render(context, request)

File "/usr/local/lib/python3.5/dist-packages/django/template/backends/django.py" in render
  66.             return self.template.render(context)

File "/usr/local/lib/python3.5/dist-packages/django/template/base.py" in render
  208.                     return self._render(context)

File "/usr/local/lib/python3.5/dist-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/usr/local/lib/python3.5/dist-packages/django/template/base.py" in render
  994.                 bit = node.render_annotated(context)

File "/usr/local/lib/python3.5/dist-packages/django/template/base.py" in render_annotated
  961.             return self.render(context)

File "/usr/local/lib/python3.5/dist-packages/django/template/loader_tags.py" in render
  61.                 result = self.nodelist.render(context)

File "/usr/local/lib/python3.5/dist-packages/django/template/base.py" in render
  994.                 bit = node.render_annotated(context)

File "/usr/local/lib/python3.5/dist-packages/django/template/base.py" in render_annotated
  961.             return self.render(context)

File "/usr/local/lib/python3.5/dist-packages/django/template/defaulttags.py" in render
  166.             len_values = len(values)

File "/usr/local/lib/python3.5/dist-packages/django/db/models/query.py" in __len__
  238.         self._fetch_all()

File "/usr/local/lib/python3.5/dist-packages/django/db/models/query.py" in _fetch_all
  1087.             self._result_cache = list(self.iterator())

File "/usr/local/lib/python3.5/dist-packages/django/db/models/query.py" in __iter__
  54.         results = compiler.execute_sql()

File "/usr/local/lib/python3.5/dist-packages/django/db/models/sql/compiler.py" in execute_sql
  835.             cursor.execute(sql, params)

File "/usr/local/lib/python3.5/dist-packages/django/db/backends/utils.py" in execute
  79.             return super(CursorDebugWrapper, self).execute(sql, params)

File "/usr/local/lib/python3.5/dist-packages/django/db/backends/utils.py" in execute
  64.                 return self.cursor.execute(sql, params)

File "/usr/local/lib/python3.5/dist-packages/django/db/utils.py" in __exit__
  94.                 six.reraise(dj_exc_type, dj_exc_value, traceback)

File "/usr/local/lib/python3.5/dist-packages/django/utils/six.py" in reraise
  685.             raise value.with_traceback(tb)

File "/usr/local/lib/python3.5/dist-packages/django/db/backends/utils.py" in execute
  64.                 return self.cursor.execute(sql, params)

File "/usr/local/lib/python3.5/dist-packages/django/db/backends/sqlite3/base.py" in execute
  337.         return Database.Cursor.execute(self, query, params)

Exception Type: OperationalError at /news/4/
Exception Value: no such column: news_comment.lft
</code></pre>

<p>Can anyone give me some idea how to fix this problem?Thanks~</p>

<p>MPTT adds fields to models which are using it - it should be enough to run <code>python manage.py makemigrations &lt;your app&gt; &amp;&amp; python manage.py migrate</code> as far as i can remember. The <a href="http://django-mptt.github.io/django-mptt/tutorial.html" rel="nofollow">MTPP Tutorial</a> mentions this in the part <em>Set up your model</em>.</p>

python django django-mptt