I'm following the Wagtail documentation on Snippets to make sure I can get that working before creating my own. But have come across a stumbling block. I have added the model for the adverts in the models.py file and am now creating the demo_tags.py file. Currently it reads -
from django import template
from demo.models import *
register = template.Library()
... #don't know if something is supposed to go in here
# Advert snippets
@register.inclusion_tag('demo/tags/adverts.html', takes_context=True)
def adverts(context):
return {
'adverts': Advert.objects.all(),
'request': context['request'],
}
When I run the development server the from demo.models import *
line creates a InvalidTemplateLibrary
error.
Clearly I'm supposed to change the replace the 'demo' and '*' with something, but what?
Additionally, when it comes to creating the template, called adverts.html, which directory should that be going in? the templatetags one, or with the other blog templates?
Thanks.