PAGE META
Page meta is a Django package allowing to add meta tags, og tags, images, and descriptions dynamically. Meta tags are stored in models and can be managed through Django admin (or any CMS).
Installation
pip install django-pagemeta
In settings file
INSTALLED_APPS = [
...
'pagemeta',
...
]
MIDDLEWARE = [
...
'pagemeta.middleware.MetaRequestMiddleware', # for binding meta into the request
...
]
Creating a Meta tags
- Run the server.
- Go to the Django Admin > Pagemeta > Meta for Pages.
- Create Meta for pages, use full absolute url in
page_url. Also supports relative url but might varies in different domains. - To create default tags for the whole system, use
page_urlasdefaultorDEFAULT(case insensitive)
Usage
Load the meta tags in template
In your template
<head>
...
{{ request.meta }}
...
</head>
Page titles are not rendered through request.meta. To render page title see the below example.
...
<title>{{ request.meta.title }}</title>
...
For conditional titles request.meta_exact will be good. request.meta_exact contains the exact meta tags for the url or None. Whereas request.meta contains default value if no match found.
...
<title>{{ request.meta_exact.title|default:'Default title' }}</title>
...
OR
...
<title>{% if request.meta_exact %}{{ request.meta_exact.title }}{% else %}Title for {{ article }}{% endif %}</title>
...
Set a Custom Meta tags
If you want to set a custom meta tags for specific pages or conditions, you can reassign request.meta with an instance of Meta.
Note: context variable can be overridden if MetaForPage for that url exists
Example code:
class MyView(TemplateView):
...
def get_context_data(self, **kwargs):
...
# adding custom meta
self.request.meta = Meta(
title='custom test',
description='custom description',
image_url='http://image_url_dot_com',
)
...
Contribution
Install requirements
Create your virtualenv first.
pip install -r requirements.txt
Running test cases
python manage.py test
Metadata
Release files for django-pagemeta 1.2.3
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 | Actions |
|---|---|---|---|---|
| django-pagemeta-1.2.3.tar.gz | 12.4 kB | Without provenance | Details for django-pagemeta-1.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_pagemeta-1.2.3-py3-none-any.whl | Python 3 | none | any | Details for django_pagemeta-1.2.3-py3-none-any.whl |
Total release size: 30.9 kB
Release files / django-pagemeta-1.2.3.tar.gz
| Download URL | django-pagemeta-1.2.3.tar.gz |
|---|---|
| Size | 12.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
25297f49539dd78c19ce9634bc33bdee35ec511655982b9eec0553872f148305
|
|
BLAKE2b-256 checksum How to use checksums |
b6f0cc2d81920fbeaa7a3256bef923c7c4ab1718736323b92dfb5c2b127e1f72
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.14
|
Release files / django_pagemeta-1.2.3-py3-none-any.whl
| Download URL | django_pagemeta-1.2.3-py3-none-any.whl |
|---|---|
| Size | 18.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
86a30f21fcf13ba7b9959e7e7151cbd589fea2dab9608fc656c26f6a8418d9f9
|
|
BLAKE2b-256 checksum How to use checksums |
c56c0733334bb06549e6483fb39773dcdd2f0e450383325b692f3de93cdbee2e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.14
|
Security for django-pagemeta 1.2.3
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.