title: Attribute error '/posts/' 'Comment' object has no attribute '_mptt_meta'
body: <p>I am following <a href="https://martinfitzpatrick.name/article/django-threaded-comments/" rel="nofollow noreferrer">this</a> example on how to set threaded comments with django_comments and django-mptt.</p>
  
  <p>I have followed most of it and the posted comments are working in admin but I am getting this error 'Comment' object has no attribute '_mptt_meta'. I have tried using a different instances to reference with and tried different objects but I am not sure what the problem might be?</p>
  
  <p>I have a comments app where I am running most of the code from in this example:</p>
  
  <p>comments/models.py:</p>
  
  <pre><code>from django_comments.models import Comment
  from mptt.models import MPTTModel, TreeForeignKey
  
  
  class MPTTComment(MPTTModel, Comment):
  """ Threaded comments - Add support for the parent comment store and MPTT traversal"""
  
  # a link to comment that is being replied, if one exists
  parent = TreeForeignKey('self', null=True, blank=True, related_name='children')
  
  class MPTTMeta:
      # comments on one level will be ordered by date of creation
      order_insertion_by=['submit_date']
  
  class Meta:
      ordering=['tree_id', 'lft']
  </code></pre>
  
  <p>comments/forms.py:</p>
  
  <pre><code> from django import forms
   from django.contrib.admin import widgets
   from django_comments.forms import CommentForm
   from .models import MPTTComment
  
  class MPTTCommentForm(CommentForm):
  parent = forms.ModelChoiceField(queryset=MPTTComment.objects.all(), required=False, widget=forms.HiddenInput)
  
  def get_comment_model(self):
      # Use our custom comment model instead of the built-in one.
      return MPTTComment
  
  def get_comment_create_data(self):
      # Use the data of the superclass, and add in the parent field field
      data = super(MPTTCommentForm, self).get_comment_create_data()
      data['parent'] = self.cleaned_data['parent']
      return data
  </code></pre>
  
  <p>comments/templates/comments/_comments.html</p>
  
  <pre><code>{% load comments %}
  {% load mptt_tags %}
  
  {% get_comment_list for object as comments %}
  {% if comments %}
  {% recursetree comments %}
  &lt;div {% if request.REQUEST.c|add:"0" == node.id %}id="newly_posted_comment"{% endif %}&gt;
  
  
  
  
  
          &lt;a name="c{{ node.id }}"&gt;&lt;/a&gt;
          {{ node.comment }}
          {{ node.user }}
          {{ node.submit_date|timesince }} ago
          &lt;a href="{{ object.get_absolute_url }}#c{{ node.id }}"&gt;#&lt;/a&gt;
  
      {% render_comment_form for object %}
  
  {# recursion! children of a given comment #}
  
  {% if not node.is_leaf_node %}
      {{ children }}
  {% endif %}
  &lt;/div&gt;
  {% endrecursetree %}
  {% endif %}
  {% render_comment_form for object %}
  </code></pre>
  
  <p>comments/templates/comments/form.html</p>
  
  <pre><code>{% load comments i18n %}
  &lt;div class="comment-form" id="comment-form-{{ node.id }}"
   {% if node.id %}
   style="display:none;"
   {% endif %}
  &gt;
  &lt;form action="{% comment_form_target %}" method="post" id="comment-form-{{ node.id }}f"&gt;{% csrf_token %}
  {{ form.object_pk }}
  {{ form.content_type }}
  {{ form.timestamp }}
  {{ form.security_hash }}
  {% if node.id %}    
      &lt;input type="hidden" name="parent" id="parent_id" value="{{ node.id }}" 
   /&gt;
  {% endif %}
  {{ form.comment }}
  &lt;input type="submit"&gt;
  &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I have this tag setup in my posts/index.html template</p>
  
  <pre><code> {% extends 'posts/base.html' %}
   {% block title %} Wiwik | What I Wish I Knew {% endblock %}
   {% load django_markdown %}
  
   {% block body %}
  
   &lt;div class="container-fluid"&gt;
   &lt;div class="main" id="show"&gt;
    {% for post in all_posts %}
   &lt;div class="content"&gt;
  
      &lt;h1 class="fof"&gt;&lt;a href="{% url 'posts:detail' post.id post.post_title|slugify %}"&gt; {{ post.post_title}}&lt;/a&gt; &lt;/h1&gt;
          &lt;p&gt;&lt;strong&gt; Posted by &lt;/strong&gt; &lt;span class="idex"&gt;&lt;a href="{% url 'posts:view_user' username=post.user.username user_id=post.user_id %}"&gt;&lt;strong&gt;{{ post.user.username }}&lt;/strong&gt;&lt;/a&gt;&amp;nbsp;&lt;img src="{{ post.user.profile.avatar.url}}" class="post-thumb"/&gt;&lt;/span&gt;
              &lt;span class="biography cursive"&gt; {{ post.user.profile.bio }}&lt;/span&gt; &lt;br/&gt;&lt;span class="topic"&gt; {{post.category}}&lt;/span&gt;
              &lt;br/&gt;
              &lt;span class="tiny"&gt; on {{post.post_date}} &lt;br/&gt;With {{post.upvote}} Recommendations&lt;/span&gt; &lt;/p&gt;
  
               &lt;a href="{% url 'posts:detail' post.id post.post_title|slugify %}"&gt;
                      {% if post.image %}
                          &lt;img src="{{ post.image.url }}" class="img-responsive" id="mobi"/&gt;
                      {% else %}
                      {% endif %}
              &lt;/a&gt;
              &lt;br/&gt;
  
              &lt;div class="test"&gt;{{ post.post_body|markdown }} &lt;/div&gt;
  
  
             &lt;br/&gt;
  
             &lt;a href="/posts/{{post.id}}/{{post.post_title}}/upvote/" method="post"&gt;&lt;button type="button" class="btn btn-info"&gt; Vote Up| {{ post.upvote }}&lt;/button&gt;&lt;/a&gt; |
             &lt;a href="/posts/{{post.id}}/{{post.post_title}}/down_vote/" method="post"&gt;Vote Down&lt;/a&gt; |
  
            &lt;button class="blab" type="button" style="background:none;border:none;color: #337AB7"&gt;Comments {{ post.comments.count }}&lt;/button&gt;
  
             &lt;br/&gt;
             &lt;br/&gt;
  
             &lt;div class="collapse" id="comm"&gt;
             {% for comment in comment.comments.all reversed %}
             {% if user.is_authenticated or comment.approved_comment %}
                  &lt;h4 class="author"&gt;&lt;strong&gt;{{ comment.author_comments.username }}&lt;/strong&gt;&lt;span class="tiny"&gt;&lt;strong&gt;{{ comment.created_at }}&lt;/strong&gt;&lt;/span&gt;&lt;/h4&gt;
                  &lt;div class="date"&gt;
                      {% if request.user.is_superuser %}
                      {% if not comment.approved_comment %}
                      &lt;a class="btn btn-default" href="{% url 'posts:comment_remove' pk=comment.pk %}"&gt;&lt;span class="glyphicon glyphicon-remove"&gt;&lt;/span&gt;&lt;/a&gt;
                      &lt;a class="btn btn-default" href="{% url 'posts:comment_approve' pk=comment.pk %}"&gt;&lt;span class="glyphicon glyphicon-ok"&gt;&lt;/span&gt;&lt;/a&gt;
                      {% endif %}
                      {% else %}
                      {% endif %}
                  &lt;/div&gt;
                   &lt;p&gt;&lt;span class="text" id="new" &gt;{{ comment.text|linebreaks }}&lt;/span&gt;&lt;/p&gt;
                   &lt;br/&gt;
                  {% endif %}
                  {% endfor %}
                &lt;/div&gt;
  
          &lt;br/&gt;
          &lt;br/&gt;
          &lt;br/&gt;
      &lt;br/&gt;
  
              {% if user.is_authenticated %}
      &lt;h3&gt;Comment&lt;/h3&gt;
            &lt;div id="commentary"&gt; {% with post as object %}{% include "comments/_comments.html" %}{% endwith %}&lt;/div&gt;
          {% else %}
      &lt;a class="btn btn-primary" href="{% url 'posts:login_user' %}"&gt;Add comment&lt;/a&gt;
          &lt;br/&gt;
          &lt;p&gt;Please login to post a comment.&lt;/p&gt;
          {% endif %}
  
  
        &lt;/div&gt;
  {% endfor %}
  &lt;br/&gt;
  &lt;br/&gt;
  &lt;div class="hline"&gt;&lt;/div&gt;
  
  
      &lt;p style="text-align: center;"&gt;WIWIK © 2016&lt;/p&gt;
  &lt;/div&gt;
  
  &lt;/div&gt;
  
  &lt;div class="righto"&gt;
                  &lt;span class="st_twitter_large" displayText="Tweet"&gt;&lt;/span&gt;
                  &lt;span class="st_facebook_large" displayText="Facebook"&gt;
  &lt;/span&gt;
                  &lt;span class="st_linkedin_large" displayText="LinkedIn"&gt;
  &lt;/span&gt;
                  &lt;span class="st_googleplus_large" displayText="Google+"&gt;
  &lt;/span&gt;
                  &lt;span class="st_email_large" displayText="Email"&gt;&lt;/span&gt;
                  &lt;span class="st_sharethis_large" displayText="ShareThis"&gt;
  &lt;/span&gt;
              &lt;/div&gt;
  
  &lt;script&gt;
  $(document).ready(function(){
  $(".blab").click(function(){
      $(this).siblings('.collapse').collapse('show');
      $(this).siblings('.collapse').collapse('hide');
      });
  });
  &lt;/script&gt;
  
  
  {% endblock %}    
  </code></pre>
  
  <p>Extended from posts/base.html below:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
  
  
  &lt;title&gt;{% block title %}Wiwik{% endblock %}&lt;/title&gt;
  {% load staticfiles %}
  {% load comments %}
  &lt;meta name="viewport" content ="width=device-width,initial-scale=1,user-scalable=yes" url=#new /&gt;
  &lt;link rel="shortcut icon" type="image/png" href="{% static 'favicon.ico' %}"/&gt;
  &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"&gt;
  &lt;link href='https://fonts.googleapis.com/css?family=Satisfy|Lato|Belgrano|Amethysta|IM+Fell+Great+Primer+SC|Open+Sans|Lora' rel='stylesheet' type='text/css'&gt;
  &lt;link rel="stylesheet" type="text/css" href="{% static 'posts/style.css' %}"/&gt;
  &lt;script type="text/javascript"&gt;var switchTo5x=true;&lt;/script&gt;
  &lt;script type="text/javascript" src="https://ws.sharethis.com/button/buttons.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="https://ss.sharethis.com/loader.js"&gt;&lt;/script&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;script src="{% static 'posts/js/main.js' %}"&gt;&lt;/script&gt;
  &lt;script language="javascript" type="text/javascript" src="jquery-1.2.6.js"&gt;&lt;/script&gt;
  &lt;script language="javascript" type="text/javascript" src="{% static 'posts/js/truncator.js' %}"&gt;&lt;/script&gt;
  &lt;script language="javascript" type="text/javascript"&gt;
  $(function() {
    $('.test').truncate({max_length: 100});
  });
  &lt;/script&gt;
  
  {% block extrahead %}
  
  {{ block.super }}
  
  {% include "comments/_ajax_comments.html" %}
  
  {% endblock %}
  </code></pre>
  
  <p>The content posts are in the posts app</p>
  
  <p>posts/models.py</p>
  
  <pre><code>class Post(models.Model):
      user = models.ForeignKey(User, default=1)
      post_title = models.CharField(max_length=250)
      post_body = models.TextField(max_length=20000)
      category = models.ForeignKey(Categories, related_name='hats')
      image = models.ImageField(default='static/wiwik.jpg', blank=True)
      email = models.EmailField(default='')
      post_date = models.DateTimeField(default=now)
      upvote = models.IntegerField(default=0)
      down_vote = models.IntegerField(default=0)
  
  
  def get_absolute_url(self):
      return reverse('posts:detail', args=(self,), kwargs={"post_id": self.post_id})
  
  def __str__(self):
      return self.post_title + ' - ' + self.post_body
  
  def __unicode__(self):
      return self.post_title
  </code></pre>
  
  <p>Here is my link to the <a href="http://dpaste.com/3TH3JPW" rel="nofollow noreferrer">stacktrace</a></p>
  
  <p>Any help would be appreciated!</p>