Django 1.7.5 existing project and Wagtail 1.0b1 addition to the project

167 views
Skip to first unread message

Daniel Vélez

unread,
Jul 14, 2015, 12:43:43 PM7/14/15
to wag...@googlegroups.com
Hi, Thanks for the wonderful work with the wagtail CMS.

I'm currently working in a project that requires in just a section of the page to allow the users to customize the content of a predefined template, so the project decided to use an existing CMS, we picked wagtail and got a few test, but we want to integrate Wagtail to the existing project for further work in the project. Is it possible to do or I have to create the project first from the the 'wagtail start' command?  

Matthew Westcott

unread,
Jul 14, 2015, 2:35:48 PM7/14/15
to wag...@googlegroups.com
Hi Daniel,
Yes, it's possible to integrate Wagtail into an existing Django project, although we don't have any formal documentation for that at the moment. You just need to add wagtail to your project requirements, then add some extra configuration in your settings and urls.py files, using the Wagtail project template <https://github.com/torchbox/wagtail/tree/v1.0rc2/wagtail/project_template/project_name> as a guide. Hopefully it should be easy to spot where the Wagtail-specific settings are, but feel free to ask on here if you have any doubts.

Just one "gotcha" that comes to mind: Wagtail doesn't use the 'django.contrib.sites' middleware, so you may run into problems if your project is reliant on that.

Cheers,
- Matt

Daniel Vélez

unread,
Jul 14, 2015, 4:33:38 PM7/14/15
to wag...@googlegroups.com
Hi Matt, Thanks for the quick answer, I took a look at the link and checked the project template, but I'm getting some error where I cant access my old HTML templates anymore, those are in the project Folder under a folder called 'templates'  ('/home/danielvelez/project_env/Project/Prototype_Python/templates'), but im getting the next:

also I'm using virtualenv 

TemplateDoesNotExist at /

index.html
Request Method:GET
Request URL:http://localhost:8000/
Django Version:1.7.5
Exception Type:TemplateDoesNotExist
Exception Value:
index.html
Exception Location:/home/danielvelez/project_env/local/lib/python2.7/site-packages/django/template/loader.py in find_template, line 136
Python Executable:/home/danielvelez/project_env/bin/python
Python Version:2.7.6
Python Path:
['/home/danielvelez/project_env/Project/Prototype_Python',
 '/home/danielvelez/project_env/lib/python2.7',
 '/home/danielvelez/project_env/lib/python2.7/plat-i386-linux-gnu',
 '/home/danielvelez/project_env/lib/python2.7/lib-tk',
 '/home/danielvelez/project_env/lib/python2.7/lib-old',
 '/home/danielvelez/project_env/lib/python2.7/lib-dynload',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-i386-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/home/danielvelez/project_env/local/lib/python2.7/site-packages']
Server time:Tue, 14 Jul 2015 20:19:00 +0000

Template-loader postmortem

Django tried loading these templates, in this order:

  • Using loader django.template.loaders.filesystem.Loader:
    • Using loader django.template.loaders.app_directories.Loader:
      • /home/danielvelez/project_env/local/lib/python2.7/site-packages/django/contrib/admin/templates/index.html (File does not exist)
      • /home/danielvelez/project_env/local/lib/python2.7/site-packages/django/contrib/auth/templates/index.html (File does not exist)
      • /home/danielvelez/project_env/local/lib/python2.7/site-packages/compressor/templates/index.html (File does not exist)
      • /home/danielvelez/project_env/Project/Prototype_Python/core/templates/index.html (File does not exist)
      • /home/danielvelez/project_env/local/lib/python2.7/site-packages/wagtail/wagtailcore/templates/index.html (File does not exist)
      • /home/danielvelez/project_env/local/lib/python2.7/site-packages/wagtail/wagtailadmin/templates/index.html (File does not exist)
      • /home/danielvelez/project_env/local/lib/python2.7/site-packages/wagtail/wagtailsearch/templates/index.html (File does not exist)
      • /home/danielvelez/project_env/local/lib/python2.7/site-packages/wagtail/wagtailimages/templates/index.html (File does not exist)
      • /home/danielvelez/project_env/local/lib/python2.7/site-packages/wagtail/wagtaildocs/templates/index.html (File does not exist)
      • /home/danielvelez/project_env/local/lib/python2.7/site-packages/wagtail/wagtailsnippets/templates/index.html (File does not exist)
      • /home/danielvelez/project_env/local/lib/python2.7/site-packages/wagtail/wagtailusers/templates/index.html (File does not exist)
      • /home/danielvelez/project_env/local/lib/python2.7/site-packages/wagtail/wagtailsites/templates/index.html (File does not exist)
      • /home/danielvelez/project_env/local/lib/python2.7/site-packages/wagtail/wagtailembeds/templates/index.html (File does not exist)
      • /home/danielvelez/project_env/local/lib/python2.7/site-packages/wagtail/wagtailredirects/templates/index.html (File does not exist)
      • /home/danielvelez/project_env/local/lib/python2.7/site-packages/wagtail/wagtailforms/templates/index.html (File does not exist)

    Seems like the processors are not getting to that folder at all, any idea why?

    the TEMPLATES code I got is:

    TEMPLATES = [
        {
            'BACKEND': 'django.template.backends.django.DjangoTemplates',
            'DIRS': [
                os.path.join(BASE_DIR, 'templates'),
            ],
            'APP_DIRS': True,
            'OPTIONS': {
                'context_processors': [
                    'django.template.context_processors.debug',
                    'django.template.context_processors.request',
                    'django.contrib.auth.context_processors.auth',
                    'django.contrib.messages.context_processors.messages',
                ],
            },
        },
    ]

    Matthew Westcott

    unread,
    Jul 14, 2015, 5:07:05 PM7/14/15
    to wag...@googlegroups.com
    Ah, sorry - I overlooked the fact that you're using Django 1.7.x, and the new Wagtail project template is based on Django 1.8. The TEMPLATES setting is a new addition in Django 1.8: https://docs.djangoproject.com/en/1.8/ref/settings/#templates

    You'll probably find it easier to compare against the previous project template from 1.0b1, which was based on Django 1.7:
    https://github.com/torchbox/wagtail/blob/v1.0b2/wagtail/project_template/project_name/settings/base.py

    Looking at the error message, I suspect you've probably removed the TEMPLATE_DIRS setting. Wagtail doesn't care about this setting (it loads its own templates from app directories), so if you put this back to its original value, that should hopefully fix it.

    Cheers,
    - Matt
    > --
    > 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/791a1153-48e2-458f-af40-5503fba774c8%40googlegroups.com.
    > For more options, visit https://groups.google.com/d/optout.

    Daniel Vélez

    unread,
    Jul 14, 2015, 6:19:17 PM7/14/15
    to wag...@googlegroups.com
    Thanks again, It worked like a charm.

    Greetings.
    Daniel Vélez.

    Daniel Vélez

    unread,
    Jul 15, 2015, 11:54:35 AM7/15/15
    to wag...@googlegroups.com
    Hi again, I was going about the custom branding of the wagtail admin interface, and got an idea for the model but I need to add a link to the django admin, is it possible to add the URL link to the django admin in the page creation template from wagtail?

    Greetings.
    Daniel Vélez.

    Matthew Westcott

    unread,
    Jul 16, 2015, 11:08:07 AM7/16/15
    to wag...@googlegroups.com
    Hi Daniel,
    We don't provide any general method of adding extra links to the admin interface (except in the logo and login/welcome messages, where you can insert whatever HTML you like - http://docs.wagtail.io/en/v1.0/advanced_topics/customisation/branding.html), so it really depends where you want to put the link. What exactly are you trying to do?

    - Matt

    Daniel Vélez

    unread,
    Jul 16, 2015, 1:01:50 PM7/16/15
    to wag...@googlegroups.com
    Hi, 
    I just want to get a link for a django-admin redirection, so some admins in the project can access some other features from the model (I got two apps, the original project and a wagtail one)

    Matthew Westcott

    unread,
    Jul 17, 2015, 5:06:51 AM7/17/15
    to wag...@googlegroups.com
    OK, perhaps this would work as a new item in the admin menu - would that achieve what you want? You can do this using the 'register_admin_menu_item' hook: http://docs.wagtail.io/en/v1.0/reference/hooks.html#register-admin-menu-item . Create a 'wagtail_hooks.py' file within one of your apps, containing the following:

    from django.core.urlresolvers import reverse

    from wagtail.wagtailcore import hooks
    from wagtail.wagtailadmin.menu import MenuItem

    @hooks.register('register_admin_menu_item')
    def register_djangoadmin_item():
    return MenuItem('Django admin', '/django-admin/', classnames='icon icon-folder-inverse', order=10000)


    Cheers,
    - Matt
    > --
    > 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/ab98dd4e-b1ca-46b0-af6a-30e1b411ea9c%40googlegroups.com.

    Daniel Vélez

    unread,
    Jul 17, 2015, 3:32:41 PM7/17/15
    to wag...@googlegroups.com
    Thanks Matt, exactly what I was looking for.

    Greetings
    Daniel Vélez.
    Reply all
    Reply to author
    Forward
    0 new messages