https://github.com/BuildWithLal/django-baseurl
Return a BASE_URL template context for the current request inside Django application.
https://github.com/BuildWithLal/django-baseurl
django django-framework python-library template
Last synced: about 1 month ago
JSON representation
Return a BASE_URL template context for the current request inside Django application.
- Host: GitHub
- URL: https://github.com/BuildWithLal/django-baseurl
- Owner: BuildWithLal
- License: gpl-3.0
- Created: 2017-02-02T16:42:06.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-23T15:43:51.000Z (over 7 years ago)
- Last Synced: 2025-03-03T20:41:10.936Z (about 2 months ago)
- Topics: django, django-framework, python-library, template
- Language: Python
- Size: 18.6 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
#### Site Base URL in Template Context
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 }}
```
This package can be found on PyPi [here](https://pypi.python.org/pypi/django_baseurl)