Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
django-pagemeta
A simple django package for managing meta tags, og tags, images, and descriptions dynamically.
Readme
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).
pip install django-pagemeta
In settings file
INSTALLED_APPS = [
...
'pagemeta',
...
]
MIDDLEWARE = [
...
'pagemeta.middleware.MetaRequestMiddleware', # for binding meta into the request
...
]
page_url
. Also supports relative url but might varies in different domains.page_url
as default
or DEFAULT
(case insensitive)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>
...
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',
)
...
Create your virtualenv first.
pip install -r requirements.txt
python manage.py test
FAQs
A simple django package for managing meta tags, og tags, images, and descriptions dynamically.
We found that django-pagemeta demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.