https://github.com/timonweb/django-url-or-relative-url-field
A Django model field that supports both absolute and relative URLs.
https://github.com/timonweb/django-url-or-relative-url-field
Last synced: 11 months ago
JSON representation
A Django model field that supports both absolute and relative URLs.
- Host: GitHub
- URL: https://github.com/timonweb/django-url-or-relative-url-field
- Owner: timonweb
- License: mit
- Created: 2018-03-13T14:23:22.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-01-16T21:12:29.000Z (over 2 years ago)
- Last Synced: 2025-04-15T06:12:20.240Z (over 1 year ago)
- Language: Python
- Homepage:
- Size: 8.79 KB
- Stars: 10
- Watchers: 2
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Django URL or Relative URL Field
This package extends default Django URLField to support relative URLs.
## Installation
1. Install the python package django-url-or-relative-url-field from pip:
``pip install django-url-or-relative-url-field``
Alternatively, you can install download or clone this repo and call ``pip install -e .``.
2. Add to INSTALLED_APPS in your **settings.py**:
`'url_or_relative_url_field',`
## Usage
Add field to the model:
```python
from django.db import models
from url_or_relative_url_field.fields import URLOrRelativeURLField
class Redirect(models.Model):
url = URLOrRelativeURLField()
```
Now your model will accept both absolute and relative URLs into the ``url`` field.