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.

Source Distribution

molo.globalsite-7.0.1.tar.gz (8.3 kB view hashes)

Uploaded Source

Built Distribution

molo.globalsite-7.0.1-py2-none-any.whl (12.1 kB view hashes)

Uploaded Python 2

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page