Recently Visited Page Middleware
A Django middleware designed to monitor and fetch recently visited pages for authenticated users.
Installation
Use pip to install the package:
pip install recently-visited-page-middleware
Add the app to your INSTALLED_APPS in your Django project's settings:
INSTALLED_APPS = [
# ...
'recently_visited_page_middleware',
# ...
]
Insert the middleware into your MIDDLEWARE:
MIDDLEWARE = [
# ...
'recently_visited_page_middleware.middleware.RecentlyVisitedPageMiddleware',
# ...
]
Usage
Import the get_recently_visited_urls function into your views:
from recently_visited_page_middleware.utils import get_recently_visited_urls
Class-Based View Example
In your class-based views, use the function to retrieve recently visited pages:
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status
from rest_framework.permissions import IsAuthenticated
class RecentlyVisitedPagesView(APIView):
permission_classes = [IsAuthenticated]
def get(self, request):
user_id = request.user.id
recently_visited_urls = get_recently_visited_urls(user_id)
response_data = {
"status": "success",
"message": "Recently Visited Pages Retrieved Successfully",
"data": recently_visited_urls
}
return Response(response_data, status=status.HTTP_200_OK)
Function-Based View Example
In your function-based views, utilize the function to retrieve recently visited pages:
from rest_framework.decorators import api_view, permission_classes
from rest_framework.response import Response
from rest_framework import status
from rest_framework.permissions import IsAuthenticated
from recently_visited_page_middleware.utils import get_recently_visited_urls
@api_view(['GET'])
@permission_classes([IsAuthenticated])
def recently_visited_pages(request):
user_id = request.user.id
recently_visited_urls = get_recently_visited_urls(user_id)
response_data = {
"status": "success",
"message": "Recently Visited Pages Retrieved Successfully",
"data": recently_visited_urls
}
return Response(response_data, status=status.HTTP_200_OK)
Ensure to configure your cache backend mechanism in your settings.py file. It can be set to various options like Redis, Memcached, FileBasedCache, DatabaseCache, LocMemCache, or DummyCache. For more information on cache backend mechanisms, refer to the Django documentation.
Metadata
Release files for recently-visited-page-middleware 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| recently_visited_page_middleware-0.1.2.tar.gz | 4.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| recently_visited_page_middleware-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.1 kB
Release files / recently_visited_page_middleware-0.1.2.tar.gz
| Download URL | recently_visited_page_middleware-0.1.2.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a869e0552e2ea706bae6e2b2dcede2099451bbc39ebe68bd1514d6a456a218c8
|
|
BLAKE2b-256 checksum How to use checksums |
c9906a2b67303bd2fff2af3f0a2d1e5949394aeddb4d257aa44c3b6faf8cc696
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Release files / recently_visited_page_middleware-0.1.2-py3-none-any.whl
| Download URL | recently_visited_page_middleware-0.1.2-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aee96069194c531d25dc43cee378ba848921eccb5dd757a0c03b1f922bebd23d
|
|
BLAKE2b-256 checksum How to use checksums |
89dc009fffd3632597f44312917db290c2a774ba3d96de638fc7a51bc42e02db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Security for recently-visited-page-middleware 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.