Ask Your Question
1

askbot & staticfiles

asked 2011-12-06 15:09:15 -0500

piskvorky gravatar image piskvorky
350 9 4 19

updated 2011-12-06 15:10:53 -0500

First, congrats on the forum upgrade and the new looks :) Parts of the forum appeared in russian to me today, so I assumed something was happening :)

Now, I was integrating askbot into an existing application, merging the settings manually. There were several small issues (askbot uses older django, so some things moved between django.contrib and django.core, some were deprecated etc), but overall no problem. The automated settings.py checks were pretty helpful.

My question is about using askbot together with django.contrib.staticfiles. If I understand correctly, askbot doesn't use staticfiles. Static URLs and directories are hard-coded, and are automatically served by django (btw can this be turned off? i'd prefer to see an error), unless explicitly intercepted by the web server earlier (needs manual configuration with some obscure locations).

Is there any planned support for STATIC_URL, the SERVE_MEDIA flag and the "python manage.py collectstatic" utility? Pretty useful from deployment point of view, IMO.

delete close flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2011-12-06 15:43:57 -0500

Evgeny gravatar image Evgeny flag of Chile
11044 50 84 182
http://askbot.org/

In askbot we use skins: .html templates, stylesheets and javascript, and the idea is that you should be able to switch the skin by configuration in the live settings.

We did not think yet on how to integrate this with the staticfiles approach, maybe there is a way, worth exploring.

link publish delete flag offensive edit

Comments

Ok, thanks Evgeny. Btw skins and static files can be used together, that shouldn't be a problem.

piskvorky ( 2011-12-06 18:01:13 -0500 )edit
1

answered 2011-12-06 18:39:29 -0500

piskvorky gravatar image piskvorky
350 9 4 19

updated 2011-12-06 19:34:23 -0500

My "quick hack" solution, in case anyone finds it useful:

  1. forbid askbot serving static files: in askbot/views/meta.py, make media() raise an exception.
  2. in the askbot application, alias the skins directory as static:

    [askbot-devel/askbot]$ ln -s skins static
    

The second step makes staticfiles automatically recognize and process the askbot static files. Now "manage.py collectstatic" works -- all static files are in a single place, easy to deploy. (Alternative way: add os.path.join(ASKBOT_ROOT, 'skins') to STATICFILES_DIRS in settings.py).

However, askbot urls have media locations hardwired under m/ (not STATIC_URL), so we still need to adjust the web server. For nginx:

3.

    location /qa/m/  { # qa/ = settings.ASKBOT_URL
        expires      7d; # or whatever
        alias /content/of/your/settings.STATIC_ROOT/; # check filesystem permissions!
    }

If anyone finds a better/cleaner way, please let me know.

EDIT: Actually this entire procedure (all three steps) can be replaced by this patch to askbot code: https://github.com/piskvorky/askbot-devel/commit/0118be48b0272147aa63fd8910b99acbfaa52102

link publish delete flag offensive edit

Comments

Hey, this looks cool, we'll get to this tomorrow. Thanks!

Evgeny ( 2011-12-06 20:45:10 -0500 )edit

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Reliable Askbot Hosting

Create your Q&A site at askbot.com. Managed Askbot hosting at just $15/mo. Dedicated hosting, support contracts, consulting services.

create your Q&A site
30 days free trial

Question tools

Follow

subscribe to rss feed

Stats

Asked: 2011-12-06 15:09:15 -0500

Seen: 147 times

Last updated: Dec 06 '11