Skip to main content

Global site to be used with Molo.

Project description

Molo Global Site

Continuous Integration Code Coverage

Provides code to help with identifying visitors’ country and redirecting them to the relevant country site or the global site using the Molo code base.

Getting Started

Install molo.globalsite package:

pip install molo.globalsite

In your app settings add:

INSTALLED_APPS = (
   'molo.globalsite',
)

MIDDLEWARE = (
   'molo.globalsite.middleware.CountrySiteRedirectMiddleware'
)

# Global Site URL
GLOBAL_SITE_URL = environ.get('GLOBAL_SITE_URL', '')

# A path to geoip database.
GEOIP_PATH = join(dirname(dirname(abspath(__file__))), 'geoip_db')

You can download the geoip database country database from MaxMind or copy it from molo/globalsite/geoip_db.

Add Global site URL in your app urls.py:

urlpatterns += patterns('',
     url(r'^globalsite/', include('molo.globalsite.urls', namespace='molo.globalsite', app_name='molo.globalsite')),
)

Add the HTML block in your country site base template to allow users to change their country site:

{% block country %}
    {% if settings.globalsite.GlobalSiteSettings.show_country %}
        {% trans "Country" %}: {{request.site}}
        <a href="{% url 'molo.globalsite:change_country' %}">{% trans "Change your country" %}</a>
    {% endif %}
{% endblock %}

How users are redirected?

The middleware redirects the user by checking the session and if the country site is set in session it will redirect the user to the country site. If the country site is not in session and the geolocation is activated, it will use user’s IP address to detect their country and redirect the user to the supported country site. However if the detected country is not supported or the geolocation is not activated it will display the list of supported country sites.

GlobalSite Settings

The GlobalSite Settings can be accessed in the CMS under settings -> global site settings.

Activate Global Site: When activated it will set the current site as the global site.

Activate Auto Redirect: When activated it will automatically redirect the users to the country of their choice when accessing the global site.

Activate Geolocation: When activated it will detect user’s country and redirect them to the supported country site. If the detected country is not available it will display the available country sites.

Description: Description will be displayed on the homepage of the global site.

show_country: When activated, the country name will be displayed and users will be able to change their country site.

Country site and Region

Under Global site in CMS you are able to create the region/s of your country sites as well as the country site.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for molo.globalsite, version 7.0.1
Filename, size File type Python version Upload date Hashes
Filename, size molo.globalsite-7.0.1-py2-none-any.whl (12.1 kB) File type Wheel Python version py2 Upload date Hashes View
Filename, size molo.globalsite-7.0.1.tar.gz (8.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page