Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yifaneye/django-sales
👨💼 Django app for displaying referer details based on query parameter and cookie. 👉 pip install django-sales (Please also see https://github.com/yifaneye/django-referer for achieving the same without the use of cookie)
https://github.com/yifaneye/django-sales
context-processor cookie django django-app django-sales middleware python query-parameter
Last synced: 11 days ago
JSON representation
👨💼 Django app for displaying referer details based on query parameter and cookie. 👉 pip install django-sales (Please also see https://github.com/yifaneye/django-referer for achieving the same without the use of cookie)
- Host: GitHub
- URL: https://github.com/yifaneye/django-sales
- Owner: yifaneye
- License: mit
- Created: 2020-10-22T07:54:21.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-11-03T02:21:37.000Z (about 4 years ago)
- Last Synced: 2024-12-07T21:44:18.928Z (about 1 month ago)
- Topics: context-processor, cookie, django, django-app, django-sales, middleware, python, query-parameter
- Language: Python
- Homepage: https://pypi.org/project/django-sales/
- Size: 75.2 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# django-sales
django-sales is a Django app for displaying different contact details based on query parameter (with cookie).
It provides sales, partners and affiliates custom links to send out to the public.
It gives sales, partners and affiliates their opportunity to convert every contact detail on the website to their own.
It thus encourages sales, partners and affiliates to promote the website and the business.## Installation
Use the package manager [pip](https://pip.pypa.io/en/stable/) to install django-sales.
```bash
pip install django-sales
```## Usage
### Step 1. Add sales app (in settings.py file)
```python
INSTALLED_APPS = [
'...',
'django.contrib.staticfiles',
'sales', # here
'myapp',
'...',
]
```Make sure sales app is before all custom apps.
Otherwise, Django will not recognize the 'sales' template tag.### Step 2. Add sales middleware (in settings.py file)
```python
MIDDLEWARE = [
'sales.middleware.sales.SalesMiddleware', # here
'django.middleware.security.SecurityMiddleware',
'...'
]
```### Step 3. Add sales context processors (in settings.py file)
```python
TEMPLATES = [
{
'OPTIONS': {
'context_processors': [
'...',
'django.contrib.messages.context_processors.messages',
'sales.context_processors.sales', # here
],
},
},
]
```### Step 4. Customize sales settings (in settings.py file) (optional)
The defaults are:
```python
SALES_LINK_PARAMETER = 'sales'
SALES_DEFAULT_ID = 1 # ?sales=1
SALES_COOKIE_NAME = 'sales'
SALES_COOKIE_MAX_AGE = 3600 # 1 hour
SALES_MODEL_FROM = 'django.contrib.auth.models'
SALES_MODEL_IMPORT = 'User' # from SALES_MODEL_FROM import SALES_MODEL_IMPORT
```
In version 0.0.1, django-sales makes use of django.contrib.auth.models.User model, which can be easily extended according to your needs. (e.g. Add a phone number field)
From version 0.1.0, django-sales allows developer to specify the Sales model to lookup sales, partners and affiliates.### Step 5. Load sales tag (in any .html file)
```html
{% load static %}
{% load sales %} # here
```### Step 6. Build sales links (in any .html file)
```html
Home
Contact
```### Step 7. Display sales information (in relevant .html files)
```html{{ sales.first_name }} {{ sales.last_name }}
```## Contributing
Pull requests are welcome.## License
[MIT](https://choosealicense.com/licenses/mit/)