# django-activity-log
Forked from :
[scailer/django-user-activity-log](https://github.com/scailer/django-user-activity-log)
__________________________________________________________
## Owner's Expressions :
This django app intended for writing HTTP log to database and/or watch last user activity.
Features:
- DB router for writing logs to another database.
- Filters for ignoring some queries by URL, HTTP methods and response codes.
- Saving anonymous activity as fake user.
- Autocreation log DB (for postgresql)
Install:
[deprecated]:
$ pip install django-user-activity-log
[new library]:
```
pip install django-activity-log
```
settings.py:
```python
INSTALLED_APPS = (
...
'activity_log',
)
MIDDLEWARE_CLASSES = (
...
'activity_log.middleware.ActivityLogMiddleware',
)
# For writing log to another DB
DATABASE_ROUTERS = ['activity_log.router.DatabaseAppsRouter']
DATABASE_APPS_MAPPING = {'activity_log': 'logs'}
# If you set up DATABASE_APPS_MAPPING, but don't set related value in
# DATABASES, it will created automatically using "default" DB settings
# as example.
DATABASES = {
'logs': {
...
},
}
# Create DB automatically (for postgres, and may be mysql).
# We create log database automatically using raw SQL in pre_migrate signal.
# You must insure, that DB user has permissions for creation databases.
# Tested only for postgresql
ACTIVITYLOG_AUTOCREATE_DB = False
# App settings
# Log anonimus actions?
ACTIVITYLOG_ANONIMOUS = True
# Update last activity datetime in user profile. Needs updates for user model.
ACTIVITYLOG_LAST_ACTIVITY = True
# Only this methods will be logged
ACTIVITYLOG_METHODS = ('POST', 'GET')
# List of response statuses, which logged. By default - all logged.
# Don't use with ACTIVITYLOG_EXCLUDE_STATUSES
ACTIVITYLOG_STATUSES = (200, )
# List of response statuses, which ignores. Don't use with ACTIVITYLOG_STATUSES
# ACTIVITYLOG_EXCLUDE_STATUSES = (302, )
# URL substrings, which ignores
ACTIVITYLOG_EXCLUDE_URLS = ('/admin/activity_log/activitylog', )
```
account/models.py:
```python
from django.contrib.auth.models import AbstractUser
from activity_log.models import UserMixin
# Only for LAST_ACTIVITY = True
class User(AbstractUser, UserMixin):
pass
```
$ python manage.py migrate & python manage.py migrate --database=logs
If you use ACTIVITYLOG_AUTOCREATE_DB migrations to logs database
will be run automatically.
__________________________________________________________
## Changelogs of this fork :
#### 1. ```ACTIVITYLOG_MAIN_IP_KEY_VALUE```:
You can set this string in the settings.py file. When you have a specific CDN or there are changes in headers of requests from the user on the frontend side, this key value takes the highest priority to set the IP address from the headers.
#### 2. ```ACTIVITYLOG_MAXIMUM_RECORD_SIZE```:
You can set this integer in the settings.py file.
This constraint controls the number of saved records by removing the oldest records.
#### 3. ```EXCLUDE_IP_LIST```:
You can set this list in the settings.py file.
This is a list of IP addresses that you do not want to log.
#### 4. ```IP_ADDRESS_HEADERS```:
I changed the priority to find the IP address better. When you have a CDN, the previous library saves the IP address of the CDN, which is not useful.
#### 5. ```headers```:
There is a new field in the changelog model that saves headers of requests from the user as a pretty string.
#### 6. ```payload```:
There is a new field in the changelog model that saves the payload of requests from the user as a pretty string.
#### 7. Test on django version 4.0.1:
It works well with Django version 4.0.1.
#### 8. change migration files:
Delete old migrations and create one file to migrate models of this library.
#### 9. IP Management:
In admin panel , Model BlackListIPAdress you can archive or block every ip address would you like with its network address or not.
Repository :
[HosseinSayyedMousavi/django-user-activity-log](https://github.com/HosseinSayyedMousavi/django-user-activity-log/)
Raw data
{
"_id": null,
"home_page": "https://github.com/HosseinSayyedMousavi",
"name": "django-activity-log",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "django, database, user, activity log",
"author": "Hossein SayyedMousavi",
"author_email": "hossein.sayyedmousavi@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/e3/c3/69d75c7a0a37f5398066933c5c55d907ef39bc53618f971dcfc96d9b0085/django_activity_log-2.0.2.tar.gz",
"platform": null,
"description": "# django-activity-log\n\nForked from : \n[scailer/django-user-activity-log](https://github.com/scailer/django-user-activity-log)\n__________________________________________________________\n## Owner's Expressions :\nThis django app intended for writing HTTP log to database and/or watch last user activity.\n\nFeatures:\n- DB router for writing logs to another database.\n- Filters for ignoring some queries by URL, HTTP methods and response codes.\n- Saving anonymous activity as fake user.\n- Autocreation log DB (for postgresql)\n\nInstall:\n\n[deprecated]:\n\n$ pip install django-user-activity-log \n\n[new library]:\n```\npip install django-activity-log \n```\n\nsettings.py:\n\n\n```python\nINSTALLED_APPS = (\n ...\n 'activity_log',\n)\n\nMIDDLEWARE_CLASSES = (\n ...\n 'activity_log.middleware.ActivityLogMiddleware',\n)\n\n# For writing log to another DB\n\nDATABASE_ROUTERS = ['activity_log.router.DatabaseAppsRouter']\nDATABASE_APPS_MAPPING = {'activity_log': 'logs'}\n\n# If you set up DATABASE_APPS_MAPPING, but don't set related value in\n# DATABASES, it will created automatically using \"default\" DB settings\n# as example.\nDATABASES = {\n 'logs': {\n ...\n },\n}\n\n# Create DB automatically (for postgres, and may be mysql).\n# We create log database automatically using raw SQL in pre_migrate signal.\n# You must insure, that DB user has permissions for creation databases. \n# Tested only for postgresql\nACTIVITYLOG_AUTOCREATE_DB = False\n\n# App settings\n\n# Log anonimus actions?\nACTIVITYLOG_ANONIMOUS = True\n\n# Update last activity datetime in user profile. Needs updates for user model.\nACTIVITYLOG_LAST_ACTIVITY = True\n\n# Only this methods will be logged\nACTIVITYLOG_METHODS = ('POST', 'GET')\n\n# List of response statuses, which logged. By default - all logged.\n# Don't use with ACTIVITYLOG_EXCLUDE_STATUSES\nACTIVITYLOG_STATUSES = (200, )\n\n# List of response statuses, which ignores. Don't use with ACTIVITYLOG_STATUSES\n# ACTIVITYLOG_EXCLUDE_STATUSES = (302, )\n\n# URL substrings, which ignores\nACTIVITYLOG_EXCLUDE_URLS = ('/admin/activity_log/activitylog', )\n```\n\naccount/models.py:\n\n```python\nfrom django.contrib.auth.models import AbstractUser\nfrom activity_log.models import UserMixin\n\n# Only for LAST_ACTIVITY = True\nclass User(AbstractUser, UserMixin):\n pass\n```\n\n$ python manage.py migrate & python manage.py migrate --database=logs\n\nIf you use ACTIVITYLOG_AUTOCREATE_DB migrations to logs database \nwill be run automatically.\n\n__________________________________________________________\n## Changelogs of this fork :\n\n#### 1. ```ACTIVITYLOG_MAIN_IP_KEY_VALUE```:\nYou can set this string in the settings.py file. When you have a specific CDN or there are changes in headers of requests from the user on the frontend side, this key value takes the highest priority to set the IP address from the headers.\n\n#### 2. ```ACTIVITYLOG_MAXIMUM_RECORD_SIZE```:\nYou can set this integer in the settings.py file. \nThis constraint controls the number of saved records by removing the oldest records.\n\n#### 3. ```EXCLUDE_IP_LIST```:\nYou can set this list in the settings.py file. \nThis is a list of IP addresses that you do not want to log.\n\n#### 4. ```IP_ADDRESS_HEADERS```:\nI changed the priority to find the IP address better. When you have a CDN, the previous library saves the IP address of the CDN, which is not useful.\n\n#### 5. ```headers```:\nThere is a new field in the changelog model that saves headers of requests from the user as a pretty string.\n\n#### 6. ```payload```:\nThere is a new field in the changelog model that saves the payload of requests from the user as a pretty string.\n\n#### 7. Test on django version 4.0.1:\nIt works well with Django version 4.0.1.\n\n#### 8. change migration files:\nDelete old migrations and create one file to migrate models of this library.\n\n#### 9. IP Management:\nIn admin panel , Model BlackListIPAdress you can archive or block every ip address would you like with its network address or not.\n\nRepository : \n[HosseinSayyedMousavi/django-user-activity-log](https://github.com/HosseinSayyedMousavi/django-user-activity-log/)\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "HTTP queries logger with flexible filters and ip block manager.",
"version": "2.0.2",
"project_urls": {
"Homepage": "https://github.com/HosseinSayyedMousavi"
},
"split_keywords": [
"django",
" database",
" user",
" activity log"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d250bdc12f891ceb7c04a7a75438c4e28a9c94b0c9095063d6325c3c6a35c489",
"md5": "2375961ee5b2527c60f8d95a32c1f622",
"sha256": "42aa399575ae122e0baaccfb83c343834b4db273fdb5a4c571db7dc3561a1e94"
},
"downloads": -1,
"filename": "django_activity_log-2.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2375961ee5b2527c60f8d95a32c1f622",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 9973,
"upload_time": "2024-04-18T12:32:41",
"upload_time_iso_8601": "2024-04-18T12:32:41.141646Z",
"url": "https://files.pythonhosted.org/packages/d2/50/bdc12f891ceb7c04a7a75438c4e28a9c94b0c9095063d6325c3c6a35c489/django_activity_log-2.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e3c369d75c7a0a37f5398066933c5c55d907ef39bc53618f971dcfc96d9b0085",
"md5": "a6c632badfe0508ba3b6d36b5c4868cb",
"sha256": "265349bb21da8a6ada94d1f7d035d56c7d90108effebe937c7bd700fd845c49b"
},
"downloads": -1,
"filename": "django_activity_log-2.0.2.tar.gz",
"has_sig": false,
"md5_digest": "a6c632badfe0508ba3b6d36b5c4868cb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 9751,
"upload_time": "2024-04-18T12:32:42",
"upload_time_iso_8601": "2024-04-18T12:32:42.924055Z",
"url": "https://files.pythonhosted.org/packages/e3/c3/69d75c7a0a37f5398066933c5c55d907ef39bc53618f971dcfc96d9b0085/django_activity_log-2.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-18 12:32:42",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "django-activity-log"
}