CommandError: One or more models did not validate:
comments.comment: 'site' has a relation with model <class 'django.contrib.sites.models.Site'>, which has either not been installed or is abstract.
How I did this...
1) Install django_comments_xtd in my virtualenv.
2) Adjusted wagtaildemo's base.py as follows...
INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', #'django.contrib.sites', # Wagtail uses its own site management logic 'django.contrib.messages', 'django.contrib.staticfiles',
'south', 'compressor', 'taggit', 'modelcluster', 'django.contrib.admin', # Uncomment the next line to enable admin documentation: 'django.contrib.admindocs', 'wagtail.wagtailcore', 'wagtail.wagtailadmin', 'wagtail.wagtaildocs', 'wagtail.wagtailsnippets', 'wagtail.wagtailusers', 'wagtail.wagtailimages', 'wagtail.wagtailembeds', 'wagtail.wagtailsearch', 'wagtail.wagtailredirects', 'wagtail.wagtailforms', 'django.contrib.sites', 'django.contrib.comments', 'django_comments_xtd', 'demo',)
COMMENTS_APP = "django_comments_xtd"COMMENTS_XTD_MAX_THREAD_LEVEL = 8
url(r'^comments/', include('django_comments_xtd.urls')),
{% load pageurl image_tags %}{% load comments %}{# Individual blog item in a list - used on blog index and home page #}<a class="list-group-item" href="{% pageurl blog %}"> <h4 class="list-group-item-heading">{{ blog.title }}</h4> <p><strong>{{ blog.date|date:"j F Y" }}</strong></p> {% get_comment_count for blog as comment_count %} <p>{{ comment_count }} comments have been posted.</p> {% if blog.search_description or blog.feed_image %} <p class="list-group-item-text"> {% if blog.feed_image %} {% image blog.feed_image width-200 %} {% endif %} {% if blog.search_description %} {{ blog.search_description }} {% endif %} </p> {% endif %}</a>
{% extends "demo/base.html" %}{% load pageurl %}{% load comments %}
{% if self.date %} {% block heading %}<div class="page-header" xmlns="http://www.w3.org/1999/html"> <h2>{{ self.title }} {{ self.date|date:"j F Y" }}</h2></div> {% endblock %}{% endif %}
{% block content %} {% include "demo/includes/carousel.html" with carousel_items=self.carousel_items.all only %}
{% include "demo/includes/body.html" with body=self.body only %}
{% get_comment_list for self as comment_list %} {% for comment in comment_list %} <div style="margin-left:{{ comment.level }}00px; border-left:5px solid #ddd"> <dt id="c{{ comment.id }}" style="background-color: #ddd"> <p>Posted by: {% if comment.url %}<a href="{{ comment.url }}" target="_new">{% endif %}{{ comment.name }}{% if comment.url %}</a>{% endif %} on {{ comment.submit_date }}{% if comment.allow_thread %} - <a href="{{ comment.get_reply_url }}">Reply</a>{% endif %}</p> </dt> <p>{{ comment.comment }}</p> </div>
{% endfor %}
{% render_comment_form for self %}
{% with self.tags.all as tags %} {% if tags %} <div class="page-header"><h3>Tags</h3></div> {% for tag in tags %} <a href="{% pageurl self.blog_index %}?tag={{ tag }}"><button class="btn btn-primary" type="button">{{ tag }}</button></a> {% endfor %} {% endif %} {% endwith %}
{% include "demo/includes/related_links.html" with related_links=self.related_links.all only %}{% endblock %}
manage.py syndb
manage.py migrate
class BlogPage(Page):
body = RichTextField()
tags = ClusterTaggableManager(through=BlogPageTag, blank=True)
date = models.DateField("Post date")
feed_image = models.ForeignKey(
'wagtailimages.Image',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+'
)
indexed_fields = ('body', )
@property
def blog_index(self):
# Find closest ancestor which is a blog index
return self.get_ancestors().type(BlogIndexPage).last()
def get_absolute_url(self):
#print(self.full_url)
return 'http://localhost:8000'+self.url
def get_absolute_url(self):
#print(self.full_url)
if DEBUG:
return 'http://localhost:8000' + self.url
else:
return self.full_url
I think defining get_absolute_url to just return self.url should be sufficient - I'm pretty sure Django doesn't require the domain to be included in the return value.
We should probably define that as standard on all pages within Wagtail, really...
Incidentally, you can fix the http://localhost/ versus http://localhost:8000/ thing by going to 'Sites' within /django-admin/ and setting the port number to 8000. (We try to avoid using full URLs within Wagtail wherever possible, so most of the time there's no need to fiddle with site settings - it's only really if you're running multiple domains on one Wagtail installation that it becomes an issue.)
def get_absolute_url(self):
return self.url