[Answer]-Correct root url in Django views.py

1👍

Just hide your staging/dev logic into settings.py like this:

DOMAIN = 'www.mysite.com'  # Production DOMAIN    

if os.environ['ENV'] != 'staging':
    DOMAIN = 'localhost:8000'  # Dev DOMAIN

Or add this into the end of your settings.py

from settings_local import *

And define DOMAIN in your settings_local.py:

DOMAIN = 'localhost:8000'

And finally in your view:

from settings import DOMAIN, STATIC_URL

img_url = 'http://{domain}/{static}/img/logo.png'.format(
    domain=DOMAIN, 
    static=STATIC_URL
)

graph.post(
    path = fb_event_path,
    source = urllib2.urlopen(img_url)
)

Leave a comment