Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I have a few fixes for this plugin #5

Open
johnmain opened this issue May 2, 2018 · 0 comments
Open

I have a few fixes for this plugin #5

johnmain opened this issue May 2, 2018 · 0 comments

Comments

@johnmain
Copy link

johnmain commented May 2, 2018

Database creation. There isn't a migration for this plugin so the table doesn't get added.

Here is the script to create the table in SQLite.

CREATE TABLE background_image_backgroundimage ( id INTEGER PRIMARY KEY AUTOINCREMENT, img TEXT );

MySQL
CREATE TABLE background_image_backgroundimage ( id int NOT NULL AUTO_INCREMENT, img varchar(255), PRIMARY KEY (ID) );

Also when there is no image in the Database you get an error on the home page.

Here is a fix for the templatetags/background_image_tags.py file

from django import template
from background_image.models import BackgroundImage

register = template.Library()

def background_image_url():
    """ """
    try:
        return BackgroundImage.objects.get().img.url
    except: 
        return ''

register.simple_tag(background_image_url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant