uploading images to wagtail

Picture 13

uploading of gifs doesn’t work. JPGs upload but are displayed as broken links.

My static linked image is working although I’m not entirely sure what changed (might be a delay in browser update again). Seems like there’s nothing a good night’s sleep can’t cure sometimes!

Tracing the uploaded images brings me to ~/env/lib/python2.7/static though and that’s a bit of a concern why it’s pointing there instead of my PROJECT_ROOT. Where is my PROJECT_ROOT anyway?

Advertisements

Further Pronunciations

No you don’t just read the alphabets.

If you ever have to hobnob with some programmers at a developer’s party. Or have to impress a coder, you’ve got to speak their language. Like a true blue DJ-ango. Put on some painfully hipster glasses, and repeat after me:

nerd_party_003-590x392

.py is pronounced like pie

__ is pronounced dundle

wsgi is pronounced whisk-gee

 

{% static %} files

Now i’ve finally moved on to creating my own templates within django/wagtail. But first I have a bit of an issue with the static files.

When I attempt to add images in Wagtail,

Picture 12

I get the dreaded Internal Server Error

Internal Server Error
The server encountered an internal error or 
misconfiguration and was unable to complete 
your request.

 

 

 

 

 

 

 

 

Picture 11

 

Additionally, attempting to link to images in my static folder like so:

<p><img src="{% static "its_alive1.gif" %}" alt="Its Alive" /></p>

gives a broken image, although if I navigate to http://username.com/static/image.gif I can see the image in my browser.

Right now my settings.py are as follow:

MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
MEDIA_URL = '/media/'
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')
STATIC_URL = '/home/clarayee/website/static/'
STATICFILES_DIRS = ()

The STATIC_URL is a hard-rooted to test if it makes any difference. Nope, no difference!

Migrations

flock of migrating canada geese birds flying at sunset

Yes, migration! I would like some too! Who doesn’t love to travel?

PK Shiu has an amazing explanation of how South’s migration works here.

looking at my wagweb migrations, I realise:

from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
 # Adding model 'BlogPage'
 db.create_table(u'wagweb_blogpage', (
 (u'page_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['wagtailcore.Page'], unique=True, primary_key=True)),
 ('body', self.gf('wagtail.wagtailcore.fields.RichTextField')()),
 ('date', self.gf('django.db.models.fields.DateField')()),
 ))
 db.send_create_signal(u'wagweb', ['BlogPage'])

 

There’s BlogPage. Probably why BlogPage is working fine. But where’s my BlogIndexPage?

okay, time to make them migrate that:

[~/website/wagtailweb]# ./manage.py schemamigration wagweb --auto
 + Added model wagweb.BlogIndexPageRelatedLink
 + Added model wagweb.BlogIndexPage
Created 0002_auto__add_blogindexpagerelatedlink__add_blogindexpage.py. You can now apply this migration with: ./manage.py migrate wagweb

Boom!

Following which I will follow instructions and migrate again:

Running migrations for wagweb:
 - Migrating forwards to 0002_auto__add_blogindexpagerelatedlink__add_blogindexpage.
 > wagweb:0002_auto__add_blogindexpagerelatedlink__add_blogindexpage
 - Loading initial data for wagweb.
Installed 0 object(s) from 0 fixture(s)

Andd………?

 

IT WORKS!

bimo

I swear BMO is shouting DJANGO in her heart.

 

 

 

Table Errors

I am no longer getting the Template errors when I click ‘View Live’ although I haven’t done anything in the pass few days. Sometimes I swear my computer does stuff on its own while I’m away.

its_alive1

Right now, Blog Page works, Root Page works. I can publish, save drafts and preview for both.

I’m only getting errors with Blog Index Page.

When I attempt to Publish Blog Index Page I get error

Picture 10

Exception Type: OperationalError at /admin/pages/new/wagweb/blogindexpage/2/
Exception Value: no such table: wagweb_blogindexpage

 

Definitely something to do with my SQlite database right? It’s probably a wrong path somewhere which is causing my SQlite to not find the table.

If i run manage.py migrate from shell,

 raise ImproperlyConfigured('ImportError %s: %s' % (app, e.args[0]))
django.core.exceptions.ImproperlyConfigured: ImportError treebeard: No module named treebeard

Oops! I think I saw this before. So that wasn’t resolve then.

I’m going to very simple try a pip install django-treebeard

running manage.py migrate this time gives me

 File "/home/clarayee/env/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 450, in execute
 return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: table "wagweb_blogpage" already exists

wagweb_blogpage is working fine. I’m not sure why it’s still trying to create a new table for that?

But trying to save draft in my dashboard still returns error no such table.

I’m going to ./manage.py migrate wagweb again to update the database and see if it changes anything.

Running migrations for wagweb:
- Nothing to migrate.
 - Loading initial data for wagweb.
Installed 0 object(s) from 0 fixture(s)

Nothing updated. Error still there. Am reading up on migrations now.

 

 

 

Pronouncing DJANGO

So in the process of complaining to friends about my stupidities, I had accidentally pronounced Django [Di-jang-go]

Yes, with the ‘D’ in capitals.

tumblr_mgjndwFQkS1rxbipho5_250

 

Of course I had to say that to a table of people who knew Spanish, and smoothly proceeded to pretend it was all a huge joke and like duh, i know how it’s read, like DJango [D-J-ango]. 

tumblr_mkhy8t93Mk1s7k6hpo1_500

Note to self: always drop the ‘D’

Thank goodness Python and Wagtail are unmistakable. Wait, they are in English right?

Errors in Wagtail templates

AttributeError at /admin/pages/2/

type object 'BlogIndexPage' has no attribute 'related_links'
Exception Type: AttributeError
Exception Value:
type object 'BlogIndexPage' has no attribute 'related_links'

Hmm… something must be off with my templates. I get this error when I try to access my main page from explorer.

When I click ‘View Live’ on my main page from the dashboard I then get:

TemplateDoesNotExist at /test/

wagweb/blog_page.html

 

Request Method: GET
Request URL: http://username.co/test/

TEST is a virtual env directory I found in my cpanel after hosting helped with the installation of lxml in python2.7. It’s strange though, that the request URL is pointing to the TEST virtualenv which is in python2.6

Furthermore, when I try to Save Draft or Publish a Blog_Index_Page I get a wagtail error without traceback:

Picture 9

lxml installed, no attribute error again!

So my hosting has very kindly installed lxml for Python 2.7 for me.

That fixed my problem of having a mismatched version error and the error with no tree builder found.

Horray!

There is however, still an error with my BlogPageIndex having an AttributeError that only shows up as ‘cannot save draft due to errors’ on my Wagtail interface.

also had the embarrassment of pronouncing Django wrong in a conversation. That quite possibly caused me Internal System Error with missing module ‘shy’.

Unhandled again

oops! I manage to cause an unhandled exception again.

This comes after pip installing Beautiful Soup 4, Beautiful Soup and attempting to install lxml.

A look at ./dispatch.fcgi give the traceback:

File "/home/clarayee/env/lib/python2.7/site-packages/bs4/builder/__init__.py", line 317, in <module>
 from . import _lxml
 File "/home/clarayee/env/lib/python2.7/site-packages/bs4/builder/_lxml.py", line 9, in 
<module>

from lxml import etree
 File "lxml.etree.pyx", line 167, in init lxml.etree (src/lxml/lxml.etree.c:192356)
TypeError: encode() argument 1 must be string without null bytes, not unicode
Content-Type: text/html

 

as suspected! it’s because of the lxml I’ve been messing with.

May be linked to the previous Runtime error with lxml I’ve raised… stay tuned…

RuntimeWarning

RuntimeWarning: compiletime version 2.6 of module ‘lxml.etree’ does not match runtime version 2.7

 

Trying to make sure my bs4 (Beautifulsoup 4) and lxml are properly installed. They are in my system packages but as lxml is installed in python2.6, it does seem like I cannot use it properly with my Python2.7 environment.

Will need hosting to help sort this out for me since I cannot install lxml myself!

 

>>> import bs4
bs4/builder/_lxml.py:9: RuntimeWarning: compiletime version 2.6 of module 'lxml.etree' does not match runtime version 2.7
from lxml import etree
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "bs4/__init__.py", line 30, in <module>
from .builder import builder_registry, ParserRejectedMarkup
File "bs4/builder/__init__.py", line 317, in <module>
from . import _lxml
File "bs4/builder/_lxml.py", line 9, in <module>
from lxml import etree
File "lxml.etree.pyx", line 167, in init lxml.etree (src/lxml/lxml.etree.c:192356)
TypeError: encode() argument 1 must be string without null bytes, not unicode
>>>