Skip to main content

A Django app which return a BASE_URL template context for the current request.

Project description

A simple Django application which add Site base URL (with port if used any) to template context processor with each reqeust. You can get Site URL in your template files using {{ BASE_URL }}

Tested Environment

Ubuntu 14.04
Python 3.4
Python 2.7
Django 1.10

Installation Using PIP

pip install django-baseurl

Using Source Code (Github)

git clone https://github.com/lalzada/django-baseurl.git

Switch to django-baseurl directory and run command

python setup.py install

Add django_baseurl to INSTALLED_APPS in settings.py

INSTALLED_APPS = [
  ...

  'django_baseurl'
]

Add context processor to TEMPLATES in settings.py

TEMPLATES = [
    {
        ...

        'OPTIONS': {
            'context_processors': [
                ...

                'django_baseurl.context_processors.baseurl'
            ],
        },
    },
]

Usage

Use below template variable inside your template file to get Site base url (with port if used any)

{{ BASE_URL }}

Project details


Release history Release notifications | RSS feed

This version

1.1

Download files

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

Source Distribution

django_baseurl-1.1.tar.gz (14.7 kB view details)

Uploaded Source

File details

Details for the file django_baseurl-1.1.tar.gz.

File metadata

File hashes

Hashes for django_baseurl-1.1.tar.gz
Algorithm Hash digest
SHA256 68031b43129b6999fbe8b2ac202e38e150fdf34ef822accf100b504049bcc57f
MD5 dbf1c4bf3972b323c0ed6839f44036cb
BLAKE2b-256 907a72a47c061352b54bb64a346f477f0a0f813a2e74af6fcc389f9144f4edc2

See more details on using hashes here.

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