Login

Tag "newforms-admin"

Snippet List

Overriding Third-party Admin

With the advent of newforms-admin it's now possible to override admin interfaces without having to change any code in third-party modules. This example shows how to enable a rich-text editor for `django.contrib.flatpages` without touching Django's code at all. (Actual embedding of the editor via Javascript left as an exercise for the reader – plenty of examples of that elsewhere.)

  • admin
  • newforms-admin
  • custom
  • contrib.admin
  • override
  • rich-text
Read More

CustomImageField for Django 1.0 alpha

The venerable CustomImageField, invented by [Scott Barnham](http://scottbarnham.com/blog/2007/07/31/uploading-images-to-a-dynamic-path-with-django/) and rejiggered for newforms-admin by [jamstooks](http://pandemoniumillusion.wordpress.com/2008/08/06/django-imagefield-and-filefield-dynamic-upload-path-in-newforms-admin/#comments). This here is a stab at a [post-Signals-refactor](http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Signalrefactoring) version. Seems to do 'er. Note: This should be pointless once [fs-refactor](http://code.djangoproject.com/ticket/5361) lands.

  • models
  • fields
  • imagefield
  • newforms-admin
  • signals
Read More

Admin Image Widget

A FileField Widget that displays an image instead of a file path if the current file is an image. Could also be used with sorl.thumbnail to generate thumbnail images. **Example** class FileUploadForm(forms.ModelForm): upload = forms.FileField(widget=AdminThumbnailWidget) class Meta: model = FileUpload class FileUploadAdmin(admin.ModelAdmin): form = FileUploadForm admin.site.register(FileUpload, FileUploadAdmin)

  • image
  • newforms-admin
  • widget
  • file
  • nfa
Read More

Creator/updater fields for admin

This ModelAdmin class sets fields for models saved in admin corresponding to the user that created the object and the user that last updated the object. Trivial for the current model, but a little more involved to make it work with inlines. The fields still show up as drop-downs (`select`) in the admin, but I fixed that with a little jQuery: $(function(){ $("select[id*='creator'], select[id*='updater']").each(function(){ var user = $('option:selected', this).text(); $(this).siblings('.add-another').hide(); $(this).hide(); $(this).after(user); }); }); This could easily be subverted, but with trusted users, it makes for a quick and dirty read-only field.

  • admin
  • newforms-admin
Read More

newforms-admin done the old way

If you view Django's admin pages as a convenience for experts, and so don't see the point in heavily modifying it beyond a few simple things like list_display and some ordering or filtering options, you may feel that newforms-admin makes things harder, not easier. ... Well, there's some truth to that, but it turns out that fighting newforms-admin is doomed - too much has changed to make the fight to preserve the old simplicity winnable to any useful extent, so I'm withdrawing this.

  • newforms-admin
Read More

More information about users and groups in user admin

Add-on for auth app of newforms-admin branch, adding more information about users and their groups at user and group list in admin interface. Also, nice example on customization of contributed django admin apps. It adds the following to the user list interface: fields for is_superuser and is_staff, last login time; by default, short names of groups user is in (mousehover to see full names) It adds the following to the to group list interface: list of users in your groups. To enable, just put it somewhere and import it from your main urls.py: import useradmin

  • admin
  • newforms-admin
  • customization
  • users
  • groups
  • roles
  • information
  • nfa
  • supervising
Read More

newforms-admin edit callback-url hook

NOTE: this is for **newforms-admin** I need edit links for items on my site, outside of the django admin -- however, I'm lazy, and don't want to build my own edit forms when there's a perfectly nice admin already there. Trick is, I need to be able to click a link to the django admin edit page for an item, and have it return to the calling page after saving. This chunk of code does the trick (the "real" version extra cruft, naturally) -- the links will bring up the django admin editor, then return to the calling page after saving.

  • newforms
  • admin
  • url
  • newforms-admin
  • newformsadmin
  • edit
  • callback
  • hook
Read More

Generate newforms-admin admin.py file

This is a utility script that scans a models.py file and automatically outputs the corresponding newforms-admin source code - the code that goes into the admin.py file. The purpose is to simplify the migration to newforms-admin. Here is what it outputs: * an import line that lists only the needed classes from the model. * inline editing classes - inheriting from either `admin.TabularInline` or `admin.StackedInline` * admin options classes containing any original `Admin` class contents (`'fields'` is replaced by `'fieldsets'` and the value of `'classes'` is made into a tuple), plus the following fields whose values are determined automatically: `inlines`, `prepopulated_fields`, `filter_horizontal`, `filter_vertical` and `raw_id_fields` * invokations of `admin.site.register` for the generated admin options classes. Example usage of the script (this will generate the admin.py file for the models.py file in the satchmo.product module): >./new-forms-gen.py satchmo.product > admin.py

  • newforms-admin
Read More
Author: NL
  • 16
  • 21

instant 'master' admin site

The newforms-admin branch (to be merged by 0.97, I think) is very nice to work with, separating models from the admin. It is trivial to create an admin site that includes every app that is installed. Note that you also get all your docs for things like template tags, etc.

  • admin
  • newforms-admin
Read More

9 snippets posted so far.