django-admin

Passing session data to ModelForm inside of ModelAdmin

I'm trying to initialize the form attribute for MyModelAdmin class inside an instance method, as follows: class MyModelAdmin(admin.ModelAdmin): def queryset(self, request): MyModelAdmin.form = MyModelForm(request.user) My goal is to customize the editing form of MyModelForm based on the current session. When I try this ho...

Django: How to set default language in admin on login

I'm saving an user's default language in his user profile and on login I want to set the admin's default language to it. One possibility I was thinking of is using a middleware, but I think if I do it on process_request I will not see an user object there since this is processed AFTER the middleware, so I could only set it after the n...

Django disable editing (but allow adding) in TabularInline view

I want to disable editing ALL objects within a particular TabularInline instance, while still allowing additions and while still allowing editing of the parent model. I have this trivial setup: class SuperviseeAdmin(admin.TabularInline): model = Supervisee class SupervisorAdmin(admin.ModelAdmin): inlines = [SuperviseeAdmin] admin...

User-based model instances filtering in django admin

I'm using django's admin to let users manage model instances of a specific model. Each user should be able to manage only his model instances. (except for administrators which should manage all). How do I filter the objects in the admin's changelist view? Thoughts: I guess the most elegant approach would be to use Object-level permis...

django: check for modeladmin for a given model

How does one check to see if a modeladmin exists for a given model? modeladmins are created by registering a model with the admin.site object. how can one check the site object to see which models have been registered, and with which admin_class? ...

django-admin formfield_for_* change default value per/depending on instance

Hi, I'm trying to change the default value of a foreignkey-formfield to set a Value of an other model depending on the logged in user. But I'm racking my brain on it... This: Changing ForeignKey’s defaults in admin site would an option to change the empty_label, but I need the default_value. #Now I tried the following without errors b...

how can we set safe template tag for admin change_form.html

how can we set safe template tag for admin change_form.html, I want to display HTML data instead of TextArea Input for admin form, I've a django field which is excluded in admin form, that field contains HTML data - which is dynamically generated - u can say reporting data, I want to display that HTML data with safe templatetag below t...

Modify Django admin app index

I want to change the app index page so I add help text to the models themselves, e.g. under each model I want to add help text. I know that I should override AdminSite.app_index. What is the best way to do this? ...

Django: Validation error in Admin

NEWBIE ALERT! background: For the first time, I am writing a model that needs to be validated. I cannot have two Items that have overlapping "date ranges". I have everything working, except when I raise forms.ValidationError, I get the yellow screen of death (debug=true) or a 500 page (debug=false). My question: How can I have an er...

limit choices in the drop down of subcategory based on related category in Django admin

Hi, I have three models as class Category(models.Model): name = models.CharField(max_length=128) class SubCategory(models.Model): category = models.ForeignKey(Category) name = models.CharField(max_length = 400) class Document(models.Model): category = models.ForeignKey(Category, null=True,blank=True,help_t...

django admin foreignKey display troubles

I can't seem to find a solution for the following in the django docs. So for example, i have a field in Class table called department that points to Department database (foreignKey). If I create a admin interface for Class table called ClassAdmin(admin.ModelAdmin). Then i create an entry for Department class. Now automatically, when i ...

Custom widgets using MooTools on Django Admin pages

I have a custom widget that I would like to make available to a Django Admin page. This is easily implemented using the formfield_overrides attribute of a ModelAdmin subclass, and using the Media child class, I can define the necessary JavaScript and CSS for this widget. This works rather well. The only issue is that my custom widget req...

JQuery tablesorter - Second click on column header doesn't resort

I'm using tablesorter in on a table I added to a view in django's admin (although I'm not sure this is relevant). I'm extending the html's header: {% block extrahead %} <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.js"&gt;&lt;/script&gt; <script type="text/javascript" src="http://mysite.com/media/tablesorter...

user model password field default password field in django

Hi, I've created a custom user model in my application. This user model is working fine, but there are a couple of problems I have with it. 1) The change password link in the my register.html page doesn't work? 2) The default password box on the add/edit page for a user is a little unfriendly. Ideally, what I'd like is the two password f...

Django grappelli

Does anyone here use django-grappelli here ? I would like to read some experience of developers or users, if there are common mistake to avoid or why you use or do not use grappelli. Thanks for sharing ...

model not showing up in django admin.

Hi. I have ceated several django apps and stuffs for my own fund and so far everything has been working fine. Now i just created new project (django 1.2.1) and have run into trouble from 1st moments. I created new app - game and new model Game. i created admin.py and put related stuff into it. Ran syncdb and went to check into admi...

** UPDATED ** 'NoneType' object has no attribute 'day'

Hi guy, i dont know where is my error, but Django 1.2.1 is give this error: 'NoneType' object has no attribute 'day' when i try to save form from the Administrator Area models.py from django.db import models from django.contrib.auth.models import User class Editorial(models.Model): titulo = models.CharField(max_length=250,help_t...

Filtering rows withing Admin using a Queryset - Django

Hi folks, I'm trying to find a way to filter down rows of objects within Django Admin, using a queryset. e.g. Person.objects.filter(Q(name='John')|Q(surname='Doe')) I'm finding quite complicated to figure out. Any ideas? ...

How to auto insert the current user when creating an object in django admin?

Hi all, I have a database of articles with a submitter = models.ForeignKey(User, editable=False) Where User is imported as follows: from django.contrib.auth.models import User. I would like to auto insert the current active user to the submitter field when a particular user submits the article. Anyone have any suggestions? ...

Flickr albums in django admin

I want to do the following: Having a model (p.e. a model which handles data about photographic reports) create a section which has a preview of an specific flickr album. The URL will be provided by an URLField (until the first save the preview will not be available). After the first save, it'll show previews of all the images inside th...