django-admin

Combining User and UserProfile in the admin

I have been reading up on Django's separation of Users and Profiles, and I have decided to go with a model called UserProfile that is located in an Accounts app as my Profile. The problem is, now I have two separate areas of the admin, one for modifying the User, and one for modifying the User Profile. Is it possible to view the two mo...

How to add a custom filed for LogEntry model in django

I want to add a column 'UserIP' to the logentry model, which will have ipaddress of the admin user.How can I do this? I have been able to add the column.But,I am unable to display this column on admin/admin/logentry/ page. What will I have to do? ...

Django Admin + Filter Horizontal?

I've added filter horizontal filter_horizontal = ('blocked_email_notifications',) To my ModelAdmin, but it's still rendering it as a multiple select widget, rather than the nifty javascript enhanced version. How come? Do I need to add something else? The user model has it defined as blocked_email_notifications = ManyToManyField('Ema...

Django Admin Login Cookie Problem

Hi all, hope you can help We have a peculiar problem with logging in to django admin on our dev server---just surfaced today, sept 1st. When we try to log in using staff usernames and passwords we are returned the following message: "Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, an...

Python/Django AttributeError "Object 'players' has no attribute 'fields'

I am setting up the admin page so that I might be able to use it to add data, players in this case. When you go and attempt to register the Players class in admin.py you get the error described in the question title (object 'players' has no attribute 'fields'). Looking through views.py that I pasted a snippet out of below I don't see wha...

Django: Exposing model method to admin.

Example model: class Contestant(models.Model): first_name = models.CharField(max_length=255) last_name = models.CharField(max_length=255) email = models.EmailField() ... def send_registration_email(self): ... I'd like to be able to expose this method to the admin so that managers can login and manually cal...

Ordering a Many-To-Many field in Django Admin

Here's my setup: from django.contrib.auth.models import User class Product(models.Model): ... email_users = models.ManyToManyField(User, null=True, blank=True) ... [elsewhere] class ProductAdmin(admin.ModelAdmin): list_display = ('name','platform') admin.site.register(Product, ProductAdmin) My main problem is, when I'...

Running a function periodically in Django

Hi, Im writing an app in Django to monitor certain services in a group of servers. I would like to have the views updated periodically. So far I've looked at writing custom admin commands (link here) and have {% ifchanged %} tags in my template. I just wanted to know if this is the best approach or if there is a better way to do it, like...

How to improve display and handling of a large number of inlines in django-admin?

When displaying an inline for a model, if there's a large number of inlines, the change page then loads slowly, and can be hard to navigate through all of them. I'm already using an inline-collapsing trick (found on DjangoSnippets, but the search there is not working so I can't share the link here), but still isn't easy to browse since t...

Prevent memory leaks in this javascript code?

I have a Django admin page for a nested category list like this: I wrote this script to sort the list and present it hierarchically: {% extends "admin/change_list.html" %} {% load i18n %} {% block footer %} <script> (function(){ var rows=document.getElementById('result_list').getElementsByTagName('tr'), table=rows[1].parentN...

django: How to hook save button for Model admin?

I have a Model with a "status" field. When the user users the Admin app to modify an instance, how to I hook onto the "Save" button click so that I could update "status" to a value that's dependent on the logged in user's username? ...

Preserving values in model fields when they no longer meet limit_choices_to criteria

I have an Article model that has a foreign key relationship with Author that needs to use a limit_choices_to because I have over 2,000 possible authors in the database. The problem is that when these authors no longer meet the limit_choices_to criteria (e.g. they become inactive), they disappear from the author field when I edit old arti...

Addtional column in change form in Admin

Hi I need to show a column in admin section when user edits a specific model object(there will be only one object of this model).This column is not part of the model.And this column will show default values of each field of the model,how can I do this? for example - the model has age,name as columns.So, when the user edits,I want to sh...

How to have multiple querysets for a model in Admin

Say I have a Sale model which is use to track sales made, with a sold_on field. I want to have two view in Admin, one showing all Sale and one showing Sale in last week. I cant override ModelAdmin.queryset, as I want to see both the Querysets at different times. What is the best way to do this. ...

A better django datetime filter at the admin panel

Greetings, I would like to know if there is any already developed plugin for Django admin to have a better filter for the given date/datetime to filter between the given date interval instead of "today", "last week" etc.. Thanks ...

Adding custom action to UserModel's Admin page

Is there any possibility to create custom action in admin page for django UserModel? I want automatize adding user to group (like adding him to staff, set some extra values, etc.), and of course create actions that take these changes back. Thanks for your help. ...

How to force-save an "empty"/unchanged django admin inline?

I have some inlines in one of my admin models which have default values which likely won't need to be changed when adding a new instance with "Add another ...". Unfortunately django won't recognize these inline as new objects unless some value has changed. This forces me to add an inline, change an arbitrary value, save, change the value...

In the Django admin is it possible to separate models into sub-models based on groups?

I think this is easiest to understand as an example: I have models Image and ImageType, where and image has exactly one type. The parameters in ImageType would regulate image size, thumbnail size, etc., as photo gallery images might display differently from, say, profile pictures. I want profile images and gallery images to appear as s...

Running manage.py dumpdata on apps with dots in their names

I'm trying to do moving some data from my development machine to a server using dumpdata but ran into a problem. So, say I want to dump the data that belongs to the app django.contrib.auth. django.contrib.auth is in my INSTALLED_APPS. This happens when I run $ python manage.py dumpdata django.contrib.auth Error: Unknown application: dja...

Adding per-object permissions to django admin

Background I'm developing a django app for a vacation rental site. It will have two types of users, renters and property managers. I'd like the property managers to be able to manage their rental properties in the django admin. However, they should only be able to manage their own properties. I realize the default django admin doesn't...