Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
A Django app and fork of django_preferences allowing the creation of site preferences in the Django admin panel
Provides a singleton view in the Admin panel for Preferences objects and an interface to allow the preferences to be used in code or in templates.
This is a fork and revision of the django_preferences package, which has not been updated in a number of years. The main changes are:
django.contrib.sites
has been removed, which makes for a nicer user experience.pip3 install django3-preferences
preferences
to your INSTALLED_APPS
preferences.context_processors.preferences_context_processor
to your TEMPLATES
> OPTIONS
> context-processors
setting:TEMPLATES = [
{
...
'OPTIONS': {
'context_processors': [
...
'preferences.context_processors.preferences_context_processor',
],
},
},
]
To create preferences for your app, create a Django model with the model inheriting from preferences.models.Preferences.
from django.db import models
from preferences.models import Preferences
class SitePreferences(Preferences):
logged_in_user_can_view = models.BooleanField(default=False)
You can then access these preferences in views or other modules by importing the preferences
module. The preferences are exposed under preferences.<Model_Name>.<Preference_Name>
from preferences import preferences
logged_in_user_can_view = preferences.SitePreferences.logged_in_user_can_view
To manage the preferences in the Admin panel (which is the whole point of installing this package!!), register them in your app's admin.py
:
from django.contrib import admin
from preferences.admin import PreferencesAdmin
from <App_Name>.models import SitePreferences
admin.site.register(SitePreferences, PreferencesAdmin)
Finally, if you've added the context processor in step 3 of the usage section, then you can access your preferences in the template by typing:
{{ preferences.SitePreferences.logged_in_user_can_view }}
Original project: django_preferences
Django 3 revision: Matt Rudge
FAQs
Adds simple preferences to the admin panel on Django 3.1 and above
We found that django3-preferences 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.