django-admin

How to access request.user from an admin ModelForm clean method?

I'm doing some stuff on 'clean' on an admin ModelForm: class MyAdminForm(forms.ModelForm): def clean(self): # Some stuff happens... request.user.message_set.create(message="Some stuff happened") class MyAdmin(admin.ModelAdmin): form = MyAdminForm Other than the threadlocals hack - how do I access request.user ...

Django-tinymce not working; Getting a normal textarea instead

I'm trying to use django-tinymce to make fields that are editable through Django's admin with a TinyMCE field. I am using tinymce.models.HTMLField as the field for this. The problem is it's not working. I get a normal textarea. I check the HTML source, and it seems like all the code needed for TinyMCE is there. I also confirmed that the...

How to override django edit_inline/tabular.html for only 1 app?

I can override edit_inline/tabular.html if I save it in my overall template directory ( let's say mysite/templates/admin/edit_inline/tabular.html ) , but when I try to save it with other admin template, like change_form.html ( in mysite/myapp/templates/admin/myapp/mymodel/change_form.html, it doesn't work. Any thoughts? Thanks! ...

How to notify user when django's custom action doesn't behave as expected?

I am writing a custom action for django admin. This action should only work for records having particular state. For example "Approve Blog" custom action should approve user blog only when blog is not approved. And it must not appove rejected blogs. One option is to filter non approved blogs and then approve them. But there are still...

In Django admin, how can I increase the width of the ManyToMany field's widget when using filter_horizontal?

In Django admin, how can I increase the width of the ManyToMany field's widget when using filter_horizontal? ...

How to customize the auth.User Admin page in Django CRUD ?

Hello, I just want to add the subscription date in the User list in the Django CRUD Administration site. How can I do that ? Thank you for your help ...

Extending/Subclassing admin Groups & Users classes in Django

I'd like to extend/subclass admin Groups & Users classes in Django. CourseAdmin group should be doing what admin can do, and they have extra information like email, phone, address. CourseAdmin should be able to create CourseAdmins, Teachers, Courses and Students. Teacher should be able to edit courses and students belong to them. They ...

Adding forgot-password feature to Django admin site

How to add the forgot-password feature to Django admin site? With email/security question options? Is there any plug-in/extension available? ...

Making email field unique with Django User admin.

There was a nearly similar question: http://stackoverflow.com/questions/1160030/how-to-make-email-field-unique-in-model-user-from-contrib-auth-in-django The solution was not perfect: Validating email for uniqueness. The solution provided is rather funny. It disallows modifications to User that leave email intact. How to fix it? Thanks i...

How to prevent Django Admin Users from changing other Admin Users' profile data?

I have Admin User extended/subclassed by Teacher class. How to prevent Teachers from seeing and changing other Teachers' profile data and Teachers are able to change their own records/rows only? Thanks in advance! ...

How to limit queryset/the records to view in Django admin site?

By default Django admin site shows all records of a related model/table for viewing. How can I show only the records that meet certain criteria? ...

How to set django upload_handler in admin?

I'm trying to make a django upload progress bar within the django admin. The application is only a small part of the project, therefor I do not want to set the custom upload handler in the settings.py. The upload_handler can be set with request.upload_handlers.insert(0, UploadProgressHandler(request)) but not within the add_view of the ...

Django app with selectable field types from admin panel?

Looking for some implementation ideas here. I am trying to design a custom polling system for my school, to allow teachers to give students polls to take. I have a Poll model, Question model (with a foreignkey to Poll model), and Choice model (with a foreignkey to the Question model). What I need to be able to do is allow whoever is ad...

Django: Completely custom auth question. Please help.

I'm creating a multiple-tenant application that won't use any of the standard Django Admin (except for internal use which will have access to all tenants... that's simple enough). I'm trying to create an authorization system of my own and I'm not interested in using the standard User model (or any built-in application's model). My applic...

Basic Django - How do view wrappers receive the request, keyword and positional arguments?

In chapter 8 of the Django book there is an example showing a fundamental view wrap method, which receives another view method passed in from any single arbitrary URLconf: def requires_login(view): def new_view(request, *args, **kwargs): if not request.user.is_authenticated(): return HttpResponseRedirect('/accoun...

django admin: text field as an option list

I want to be able to provide a list of possible values when entering a text field in django admin. I have a legacy database so I can't add a new model and reference that. Could I provide something like: possible_values = ['one','two',three'] to the fieldsets tuple, for a particular field in model handler? Sorry for the newbie quest...

Send mail/save draft from Django admin

Hi everybody, I wonder if there is a way to override Django admin's submit_line buttons for a specific model, so that instead of showing the save & save and add another options they show send mail or save draft and actually work... Thanks a million! ...

How do I prevent permission escalation in Django admin when granting "user change" permission?

I have a django site with a large customer base. I would like to give our customer service department the ability to alter normal user accounts, doing things like changing passwords, email addresses, etc. However, if I grant someone the built-in auth | user | Can change user permission, they gain the ability to set the is_superuser flag ...

Having one ModelAmin and using either of two form classes, depending on view that is requested

Suppose I have a model Animal. Animals have a field species which can either be "Lion" or "Dolphin". The AnimalAdmin should have two views, add_lion_view() and add_dolphin_view(), which call the standard add_view() method after making sure that either species is going to be added. I used to do this by setting the an AnimalAdmin instan...

Django - Overriding the Model.create() method?

The Django docs only list examples for overriding save() and delete(). However, I'd like to define some extra processing for my models only when they are created. For anyone familiar with Rails, it would be the equivalent to creating a :before_create filter. Is this possible? ...