django-admin

change list display link in django admin

I am trying to change the link for an object in the django admin list display. Here is what I have so far: class FooModelAdmin(admin.ModelAdmin): fields = ('foo','bar') list_display = ('foo_link','bar') def foo_link(self,obj): return u'<a href="/foos/%s/">%s</a>' % (obj.foo,obj) domain_link.allow_tags = True ...

django admin lost password recovery

I have some data in my dev database (not yest exported to fixtures), so I dont want to run syncdb. However, I have lost my pwd for the admin section of my demo django website (I have not worked on it for a little while) Is the password stored somewhere in the config/settings etc? How can I recover the admin pwd? ...

django multiple select in admin change-list

Hi all, Our product model can have multiple campaigns. Our customers change these campaigns frequently and generally on multiple products. So what we need right now seems that we need to show a multiple select widget on a change-list of Product model where our customers can easily change the campaigns. Any idea on this? Maybe another...

Change row colour in Django Admin List

I want to highlight rows (set the backgorund colour) in the Django Admin page (change_list.html) based on a field in the model called status. What is the best way to do this? I have 3 statuses. Open, Active, Closed. I'd like rows with open to be green, active to be orange and closed to be red. I've found documentation about changing...

Is there a way i can display the drop down tab in django admin generator with tree hierarchy

My Model:: class Category(model.Models): parent = model.ForeignKey('self', blank = True, null = True, related_name = 'children') name =.......... desc = ............ This does work but the admin generator does not show a hierarchical tree menu after insertion of data. Is there any way i can configure admin.py to show a hiera...

How to make Django admin site accessed by non-staff user?

Hello all, I would like to implement a 2nd admin site which provides a subset of feature of the primary admin site. That's possible and described in the Django docs However, I would like to limit access on the primary admin site. Some users can access the 2ndary site but not the primary site. In order to implement that feature, I woul...

Django: If I added new tables to database, how can I query them?

Django: If I added new tables to database, how can I query them? Do I need to create the relevant models first? Or django creates it by itself? More specifically, I installed another django app, it created several database tables in database, and now I want to get some specific data from them? What are the correct approaches? Thank you...

In Django Admin how do I disable the Delete link

I've managed to disable the "Delete selected" action. Easy. But a user can still click on an item and then there's the red Delete link at the bottom. ...

Browser-based strategy game in Django/GAE. Model suggestions?

I'm creating a turn and text-based strategy game in Django on Google App Engine with app-engine-patch. The simplified concept is that each player build can several different units and buildings to improve their base and fight other players for points. My question involves the designing of the Django models, it seems to me that the buil...

Why is Loan undefined when type(self) works just fine?

The following code is being used by the admin to save a Loan object import uuid from django.db import models from django.contrib.auth.models import User from apps.partners.models import Agent # Create your models here. class Loan(models.Model): """ This is our local info about the loan from the LOS """ guid = models.CharField(...

How to add custom control to django admin site?

Hey, I want to add custom buttom to the django admin site, and the users must be administrators, I do not expect you tell me how to do in each step, but please brief write the right approach, if you also can provide some reading URLs, that's gonna be awesome. ...

django admin printer friendly stylesheet

Has anyone got or know if a printer friendly css file is available for the Django Admin site? ...

hook django admin change-list editable save button

Hi all, We are using list-editable list to edit some fields of our model in the change list itself. However, we currently need to hook the save button of the change list to do some stuff on the changed models. Is there a hook for that? Thanks, ...

django admin inlines (and nested inlines) : how can I get this functionality?

I'm a little confused as to why this sort of functionality isn't default in the admin, but maybe someone can give me a few hinters to how to go about it. I have a projects application which keeps track of projects and is to be edited through the admin. Each project has numerous ForeignKey related models (links, flatpages, video, image ...

Django Admin: How do I filter on an integer field for a specific range of values

How do I create a filter in Django Admin to only display records where an integer value lies between two values? For example, if I have a model Person, which has an age attribute, and I only want to display Person records where age is between 45 and 65. ...

How to put custom HTML in changeview of django's admin?

When I describe admin options for a model it's possible to put any method in 'list_display' then we can add 'allow_tags=True' and get HTML. Is there any same options but for 'changeview' form? I can change template for the form but there is some calculation which returns HTML, so It's not good idea to put them all to a template. class O...

Excluding a form field, yet adding it back in with clean()

In the django admin, I have an inline that I want to have the viewing user filled in automatically. During the clean function, it fills in the created_by field with request.user. The problem is that since the created_by field is excluded by the form, the value that gets inserted into cleaned_fields gets ignored apparently. How can I do t...