Saravanan666/pypi-org huggingface dataset:
Package: django-admin-edit-lock
django-admin-edit-lock:warning: Correct operation relies on cache. Therefore, the current version will be unreliable in cases where the default local-memory cache backend is used, along with multiple application server worker (seehttps://github.com/demestav/django-admin-edit-lock/issues/1).SetupInstall package usingpip:python-mpipinstalldjango-admin-edit-lockAdd it to the installed apps:INSTALLED_APPS=[..."admin_edit_lock",...]ConfigurationThere are two one mandatory settings:ADMIN_EDIT_LOCK_DURATIONDefines how long each edit lock should last. The value is in seconds. For example:ADMIN_EDIT_LOCK_DURATION=60will keep the lock for sixty seconds.The lock is being updated regularly (every 5 seconds) as long as the user is still editing the object. Therefore this value needs to be larger than 5 seconds. This configuration will probably be removed in the future, as it does not really offer any value by being user-configurable. The only case this affects the user is how long the lock will remain after the user finished editing. For example, the user updated the lock at 10:00:00 (i.e. the lock expires at 10:01:00) and the user exits the edit screen (closer tab or saves or navigates back etc.) at 10:00:10. For the remaining 50 seconds, the lock will be there without any real purpose.ADMIN_EDIT_LOCK_MAX_DURATIONDefines for how long a user can keep the same lock. The value is in seconds.This prevents a user to keep the maintain the edit rights of an object indefinitely. This is useful in cases where a user unintentionally keeps the edit screen open and therefore not allowing other users to edit the object.ADMIN_EDIT_LOCK_DISPLAY_OWNERDefines whether to display the username of the user with edit rights, to other users trying to edit the same object. The value isTrueorFalse.:warning: If this is set to True, it raises potential privacy issues.UsageUse theAdminEditLockMixinto enable edit lock on a model.For example:# models.pyfromdjango.dbimportmodelsclassBook(models.Model):name=models.CharField(max_length=100)# admin.pyfromdjango.contribimportadminfromadmin_edit_lock.adminimportAdminEditLockMixinclassBookAdmin(AdminEditLockMixin,admin.ModelAdmin):classMeta:model=BookRoadmapCustomize messagesExtending the lock expiry time through AJAX callOptionally set a limit to how much the lock can be extendedAcknowledgementsThis project is inspired byhttps://github.com/jonasundderwolf/django-admin-locking. This project differentiates by utilizing the Django permissions to decide whether a user can edit or not. Further, this project uses the messages middleware to notify the users of the lock status.
Package: django-admin-edit-mode
django-admin-edit-modeAllows to open django admin in read-only mode by default,
with a special button "Go to edit mode" to open the same change-object page in regular editable mode.Why read-only mode by default is needed ? For some applications, django-admin serves mostly for reading the info.Readonly mode page looks better (cleaner), doesn't allow to make some changes accidentially, and thepage loads quicker(e.g., no need to load a list of choices for the fields).
But you're not going to make admin completely readonly (e.g., by persmissions), becausesometimes you still want to changethe object.
Then you cango to edit mode by clicking the button!Even more suitable edit mode could be on a list page.
For quick multi-object editing you would like to enable changing of some fields on list page
with help oflist_editable. But it will alsways shows you edit mode on list page,
which looks not good (for most times you don't want to change, only look).
This libary provides you with buttons "Go Edit Mode" / "Go Readonly Mode".
Important note: your editable field should not serve as a link to the object, i.e., should not be inlist_display_linksor be the first field oflist_display(the same restriction applies to regular Django'slist_editable).Installationpip install django-admin-edit-modeAdd'django_admin_edit_mode'toINSTALLED_APPS,before'django.contrib.admin'. Order matters for template loading!Add'spurl'toINSTALLED_APPS.Check that'APP_DIRS'isTrueinTEMPLATESsettings.UsageUse the mixins for the model admins you want to have "readonly by default and edit by clicking button" mode:importdjango_admin_edit_mode.admin# Conditional edit mode enabled on edit object page@admin.register(models.Book)classBookAdmin(django_admin_edit_mode.admin.EditModeAdminMixin,admin.ModelAdmin):...# Conditional edit mode enabled on list page@admin.register(models.Author)classAuthorAdmin(django_admin_edit_mode.admin.ConditionalListEditableAdminMixin,admin.ModelAdmin):...list_display=('id','name','description','num_books')# list_editable = ('list_editable', )  # This you would use for "constant" edit modeconditional_list_editable=('list_editable',)
Package: django-admin-enhancer
OverviewA simple django app that provides change and deletion links to FK fields
in the admin while ticket#13163and#13165are not fixed.Note that this apps works with django >= 1.4 only.DisplayselectedUsageThe recommended way to installdjango-admin-enhanceris viapip:pipinstalldjango-admin-enhancerAdd'admin_enhancer'to yourINSTALLED_APPSto avoid gettingTemplateDoesNotExisterrors.Make sure to mixEnhancedModelAdminMixinwhen dealing withdjango.contrib.admin.ModelAdminsubclasses andEnhancedAdminMixinwhen dealing withdjango.contrib.admin.InlineModelAdminat both ends of the
relationship. The mixins are located atadmin_enhancer.admin.If edition and deletion controls appears but the popup is not closed nor
is the select box updated yourModelAdminsubclass referenced by the
field in question is probably not mixed withEnhancedModelAdminMixin.For some examples take a lookhere.Django CMS supportDjango CMS (https://www.django-cms.org/) defines a plugin system to
create pluggable applications; its plugin system relies on standard
Django admin framework so it’s easy toenhanceplugins using this
project.Plugin enhancementTo addadmin_enhancersupport to your own plugins just addadmin_enhancer.EnhancedAdminMixinto plugin class definition....fromadmin_enhancer.adminimportEnhancedAdminMixinclassMyOwnPlugin(EnhancedAdminMixin,CMSPluginBase):name="whatever"...plugin_pool.register_plugin(MyOwnPlugin)Toenhancethird party plugins, unregister original plugin and extend
it with your own base class....fromother.app.cms_pluginsimportThirdPartyPluginfromadmin_enhancer.adminimportEnhancedAdminMixinclassEnhancedThirPartyPlugin(EnhancedAdminMixin,ThirdPartyPlugin):pass...plugin_pool.unregister_plugin(ThirdPartyPlugin)plugin_pool.register_plugin(EnhancedThirPartyPlugin)Page admin supportDjango CMS defines a ModelAdmin for itsPageobject;admin_enhancer.contrib.djangocmsdefines a newModelAdminforPageto enhance it. To install it addadmin_enhancer.contrib.djangocmstoINSTALLED_APPS,afteranydjango-cmsordjango-admin-enhancer-related application.Django Filer supportdjango-filer(https://github.com/stefanfoulis/django-filer) has its
ownenhancedwidget which conflicts withdjango-admin-enhancer; toenhancefiler-based applications, useenhance_excludeattribute on
your ModelAdmin to exclude filer-based fields fromenhancementwhile
allowing other fields to be enriched.cmsplugin_filer(https://github.com/stefanfoulis/cmsplugin-filer)
can be extended to supportdjango-admin-enhancerlike any other
django CMS plugin; for better supportadmin_enhancer.contrib.filerdefines a newModelAdminforThumbnailOptionclass. To install
it addadmin_enhancer.contrib.filertoINSTALLED_APPS,beforeadmin_enhancer.contrib.djangocms.
Package: django-admin-env-notice
django-admin-env-noticeVisually distinguish environments in Django Admin. Based on great advice from post:5 ways to make Django Admin saferbyhakibenita.RequirementsPython 2.7, 3.4+Django 1.9+QuickstartInstall django-admin-env-notice::pip install django-admin-env-noticeAdd it to yourINSTALLED_APPSbeforedjango.contrib.admin:INSTALLED_APPS=(...'django_admin_env_notice','django.contrib.admin',...)Add context processor:TEMPLATES=[{..."OPTIONS":{"context_processors":[..."django_admin_env_notice.context_processors.from_settings",],},},]Set label and color for current environment:ENVIRONMENT_NAME="Production server"ENVIRONMENT_COLOR="#FF2222"Override django admin selector if necessary (default: body), e.g: grappelli:ENVIRONMENT_ADMIN_SELECTOR="grp-header"Optionally, set the environment banner to float over instead of being fixed to the top:ENVIRONMENT_FLOAT=TrueYou can also set the text color (default: white) by setting:ENVIRONMENT_TEXT_COLOR="#00FF00"You can stop showing the banner to unauthenticated users by setting (default:True):ENVIRONMENT_SHOW_TO_UNAUTHENTICATED=FalseScreenshotsRunning TestsDoes the code actually work?source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ toxCreditsTools used in rendering this package:Cookiecuttercookiecutter-djangopackage
Package: django-admin-export-action
Django Admin Export ActionExport action for Django's AdminQuickstartInstall Django Admin Export Action::pipinstalldjango-admin-export-actionInclude it in INSTALLED_APPS::INSTALLED_APPS = [
    # ...
    'admin_export_action',
]Add tourlpatternsinurls.py:path('export_action/',include("admin_export_action.urls",namespace="admin_export_action")),ConfigurationBy default the export action will be added sitewide, which means for every app and every admin registered model.You can disable this behaviour and decide to add manually the export action only for the models you desired:# settings.pyADMIN_EXPORT_ACTION={'ENABLE_SITEWIDE':False}# model adminfromadmin_export_action.adminimportexport_selected_objectsclassMyModelAdmin(models.ModelAdmin):# ...actions=[export_selected_objects,]Convert any value to its xlsx representation can be a nightmare, and you may always find something weird you haven't considered.
In order to let you fix every case, you can define an hook which is called when adding a value to a cell:# settings.pyADMIN_EXPORT_ACTION={'VALUE_TO_XLSX_CELL':'news.admin.my_convert_function'}# admin.pydefmy_convert_function(value):if(value=='convert'):returnTrue,'converted'elif(type(value)==list):returnjson.dumps(value)returnFalse,NoneIf called, the hook is called first, it shoud return a tuplesuccess, value. IfsuccessisTrue, then the returnedvalueis used, otherwise the default conversions are performed.The intermediate admin page used to select the fields to be exported needs the extra context each admin page has. But such context depends on youradmin_siteinstance, for example if you usedjango-batonthe admin site is different from the default one.For this reason you can specify the path for your admin app:# settings.pyADMIN_EXPORT_ACTION={'ADMIN_SITE_PATH':'baton.autodiscover.admin'}This assures the site title and site header ar the ones you see in normal admin pages.UsageGo to an admin page where the export action is enabled, select objects, run the action.In the next page:select the fields you want to exportselect the output formatselect whether to get raw choices values or notselect whether to include table header (field verbose name) or notclick the "Export" buttonFeaturesGeneric or ready to use action to enable export data from Admin.Automatic traversal of model relations.Selection of fields to export.Can export to XSLx, CSV, JSON and HTML.Running TestsDoes the code actually work?cd testapp/app
source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install -r requirements.txt
(myenv) $ python manage.py testSecurityThis project assumes staff users are trusted. There may be ways for users to manipulate this project to get more data access than they should have.CreditsThis project is developed by Otto srl, and originally foked fromfgmacedo/django-export-action
Package: django-admin-exporter
Simple admin actions to download/export selected items in CSV, JSON, XML, etc.Build Status[![Build Status](https://travis-ci.org/RyanBalfanz/django-admin-exporter.png?branch=master)](https://travis-ci.org/RyanBalfanz/django-admin-exporter)
[![Build Status](https://travis-ci.org/RyanBalfanz/django-admin-exporter.png?branch=develop)](https://travis-ci.org/RyanBalfanz/django-admin-exporter)Installpip install django-admin-exporterAddadmin_exporterto your INSTALLED_APPS.Add the vairous exporter actions to individual models or site-wide. See the example project for details.Running the testsmake test
Package: django-admin-ext
Extensions to Django's admin site.Currently Includes:- BaseCustomUrlAdmin: hook to provide additional urls to your model admin.- BaseAjaxModelAdmin: hook to have a form that gets some of it's formfields dynamically depending on a certain field choice.- BaseAjaxModelForm: form to help setup and save dynamic fields basedon other fields chosen.USAGE:Take a look at the example project for a more detailed example.BaseCustomUrlAdmin:- in your ModelAdmin, subclass BaseCustomUrlAdmin and implementthe 'get_custom_urls' functionBaseAjaxModelAdmin:- in your ModelAdmin, subclass BaseAjaxModelAdmin and make sureyour form is pointing to your dynamic form.- there will be a new url that ends with /ajax/ that handles theajax request.- Django's ModelAdmin will only display fields declared in a fieldsetso we make sure the Ajax fields don't display when they don't haveenough data to be present, and that they do display when they do.Because of this, we currently are not respecting any fieldsetsyou might have declared in your ModelAdmin. If you know of agood way to lift this restriction, please submit a patch.BaseAjaxModelForm:- set the ajax_change_field to be the name of the form field whosechange triggers the ajax call OR set the ajax_change_fields to alist of field names whose change triggers the ajax call- in your form, set the dynamic_fields property to return a dictionarywhose keys are the field names and values are the instantiated fields.@propertydef dynamic_fields(self):return {'my_field': CharField(initial="hello world!", label="Greeting"),}when the change field is present either in a forms initial data orsubmitted data, the form will add all your dynamic fields to it, andwhen saving, the form will make sure all your dynamic field valuesare saved to the instance.- make sure the file in djadmin_ext/static/djadmin_ext/admin_ajax.jsis available in your static content.- The ajax call gets the new form and replaces allthe elements with the class of '.module' with the updated form.NOTE: this will blow out any inline forms you have declared, soif you need inline forms, we'd be happy to accept a patch makingit possible.Testing:To test the admin, we wrote selenium tests. The tests will tryto start django's test server, open a firefox browser window,execute the tests and verify the actions on the page behave asexpected.python setup.py test
Package: django-admin-extensions
django-admin-extensionsallows Django developers to add some simple
functionality to the admin site. Extensions include:Add links to the ‘object tools’ button list at the top of model list and
detail pages.Allow for filtering on foreign models (e.g.post__author__id)A bunch of shortcuts for adding links to foreign keys, model searches,
many-to-many relations, truncating fields in the model list, and more.DocumentationDocumentation can be foundon ReadTheDocs.
Package: django-admin-extra-buttons
django-admin-extra-buttonsThis is a full rewriting of the originaldjango-admin-extra-url. It
provides decorators to easily add custom buttons to Django Admin pages and/or add views to any ModelAdminIt allows easy creation of wizards, actions and/or links to external resources
as well as api only views.Three decorators are available:button()to mark a method as extra view and show related buttonlink()This is used for "external" link, where you don't need to invoke local views.view()View only decorator, this adds a new url but do not render any button.choice()Menu like button, can be used to group multiple @views().Installpip install django-admin-extra-buttonsAfter installation add it toINSTALLED_APPSINSTALLED_APPS = (
   ...
   'admin_extra_buttons',
)How to use itfromadmin_extra_buttons.apiimportExtraButtonsMixin,button,confirm_action,link,viewfromadmin_extra_buttons.utilsimportHttpResponseRedirectToReferrerfromdjango.httpimportHttpResponse,JsonResponsefromdjango.contribimportadminfromdjango.views.decorators.clickjackingimportxframe_options_sameoriginfromdjango.views.decorators.csrfimportcsrf_exemptclassMyModelModelAdmin(ExtraButtonsMixin,admin.ModelAdmin):@button(permission='demo.add_demomodel1',change_form=True,html_attrs={'style':'background-color:#88FF88;color:black'})defrefresh(self,request):self.message_user(request,'refresh called')# Optional: returns HttpResponsereturnHttpResponseRedirectToReferrer(request)@button(html_attrs={'style':'background-color:#DC6C6C;color:black'})defconfirm(self,request):def_action(request):passreturnconfirm_action(self,request,_action,"Confirm action","Successfully executed",)@link(href=None,change_list=False,html_attrs={'target':'_new','style':'background-color:var(--button-bg)'})defsearch_on_google(self,button):original=button.context['original']button.label=f"Search '{original.name}' on Google"button.href=f"https://www.google.com/?q={original.name}"@view()defselect2_autocomplete(self,request):returnJsonResponse({})@view(http_basic_auth=True)defapi4(self,request):returnHttpResponse("Basic Authentication allowed")@view(decorators=[csrf_exempt,xframe_options_sameorigin])defpreview(self,request):ifrequest.method=="POST":returnHttpResponse("POST")returnHttpResponse("GET")Project LinksCode:https://github.com/saxix/django-admin-extra-buttonsDocumentation:https://saxix.github.io/django-admin-extra-buttons/Issue Tracker:https://github.com/saxix/django-admin-extra-buttons/issuesDownload Package:https://pypi.org/project/django-admin-extra-buttons/
Package: django-admin-extras
InstallationFor installing graphene, just run this command in your shellpipinstalldjango-admin-extrasSettingsINSTALLED_APPS=(# ...'django_admin_extras',# ...)ExamplesHere is a simple Django model:fromdjango.dbimportmodelsclassTodoList(models.Model):title=models.CharField(max_length=64)def__str__(self):returnself.titleclassTodoItem(models.Model):text=models.CharField(max_length=256)checked=models.BooleanField(default=False)list=models.ForeignKey(TodoList,on_delete=models.CASCADE)def__str__(self):returnself.textHere is a simple Django admin for models above:fromdjango.contribimportadminfromdjango.db.modelsimportQfromdjango_admin_extrasimportInputFilter,custom_titled_filter,custom_view_fieldfrom.modelsimportTodoItemclassTodoItemTextFilter(InputFilter):parameter_name='todoitem__text'title='todo item text'defqueryset(self,request,queryset):ifself.value()isnotNone:q=Q()fortext_partinself.value().split():q&=Q(text__icontains=text_part)returnqueryset.filter(q)@admin.register(TodoItem)classTodoItemAdmin(admin.ModelAdmin):list_display='text','custom_text','checked','custom_bool',list_filter=TodoItemTextFilter,('checked',custom_titled_filter('test title for checked filter')),@custom_view_field(admin_order_field='-text')defcustom_text(self,obj:TodoItem)->str:returnobj.text+' custom'@custom_view_field(boolean=True,short_description='Not checked')defcustom_bool(self,obj:TodoItem)->bool:returnnotobj.checked
Package: django-adminextraviews
django-adminextraviewsMixin for adding class-based views to ModelAdmin.WhyClass-based views are really useful, but it’s difficult to add them to the
admin center. This makes it easy to add class-based views to the Django admin.InstallationInstall django-adminextraviews:pip install django-adminextraviewsUsageAdd theExtraViewsMixinto yourModelAdminand define theextra_viewsattribute.fromadminextraviewsimportExtraViewsMixinclassMyModelAdmin(ExtraViewsMixin,admin.ModelAdmin):extra_views=[('login_as_user',r'(?P<pk>\d+)/login/',LoginAsUserView),]Now you can use it like a normal view, you can reverse it.>>>urlresolvers.reverse('admin:myapp_mymodel_login_as_user',kwargs={'pk':12})'/admin/myapp/mymodel/12/login/'If your view is a subclass ofModelFormMixin(likeCreateView,UpdateView),ExtraViewsMixinwill wrap the form class with the admin
center widgets. It will also set themodelattribute if it’s not set.Changelog1.1.0 (2015-03-24)Allow for use of different models [#1].1.0.0 (2015-03-19)First release on PyPI.
Package: django-admin-fast-search
Your project description goes hereDocumentationThe full documentation is athttps://django-admin-fast-search.readthedocs.io.QuickstartInstall django-admin-fast-search:pip install django-admin-fast-searchAdd it to yourINSTALLED_APPS:INSTALLED_APPS=(...'django_admin_fast_search.apps.DjangoAdminFastSearchConfig',...)Add django-admin-fast-search’s URL patterns:fromdjango_admin_fast_searchimporturlsasdjango_admin_fast_search_urlsurlpatterns=[...url(r'^',include(django_admin_fast_search_urls)),...]FeaturesTODORunning TestsDoes the code actually work?source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ toxDevelopment commandspip install -r requirements_dev.txt
invoke -lCreditsTools used in rendering this package:Cookiecuttercookiecutter-djangopackageHistory0.1.2 (2022-05-30)Add classifiers for Python 3.7, 3.8, 3.9, 3.10Remove support for Python 2, 2.7, 3.5, 3.6Automate publish to PyPi0.1.0 (2021-05-22)First release on PyPI.
Package: django-admin-field
Django ModelAdmin field syntax simplifier.Common django admin field customization syntax for looks like this.class FileAdmin(ModelAdmin)
    list_display = ('name', 'human_size')

    def human_size(self, obj):
        return filesizeformat(obj.size)
    human_size.short_description = 'size'
    human_size.admin_order_field = 'size'This lib allows allows to sorten it and make it reusable.class FileAdmin(ModelAdmin)
    list_display = ('name', 'human_size')
    human_size = AdminField('size', filesizeformat)InheritanceYou can create some reusable fields, for multipy usage.class AdminSizeField(AdminFieldBase):
    DEFAULT_FIELD = 'size'
    method = staticmethod(human_size)


class FileAdmin(ModelAdmin)
    list_display = ('name', 'human_size')
    human_size = AdminSizeField()AttributesBy default, ‘short description’ and ‘admin order field’ will be taken from the
field name. But you can overide it by kwargs.class FileAdmin(ModelAdmin)
    list_display = ('name', 'human_size')
    human_size = AdminField('size', filesizeformat,
        short_description='real size', allow_tags=True)Foreign keysBy default ModelAdmin doesn’t allow you to use foreign keys in list_display.
Feel free to do it with AdminField. It will atomaticaly optain description
and sort field.class UserFileAdmin(ModelAdmin)
    list_display = ('name', 'file__size')
    file__size = AdminField('file__size', filesizeformat)Don’t forget to select related model.class UserFileAdmin(ModelAdmin)
    select_related = ['file']
    list_display = ('name', 'file__size')
    file__size = AdminField('file__size', filesizeformat)

    def queryset(self, request):
        return super(AdminModelSelectRelated, self).queryset(request).select_related(*self.select_related)