django-admin

Django admin list filter

I want to add a custom model method to the admin filter, however it fails. Example Foo: class Foo(models.Model): number = models.IntegerField() def big_enough(self): return self.number > 99 now at the admin panel: class FooAdmin(admin.ModelAdmin): list_filter = ('number', 'big_enough') Fails, I get the error...

Django admin - stackedInline single instance

I'm building a site based on a highly customized django admin instance and am running into issues with user profiles as an inline to user_admin long story short regardless of what I set for max_num and extra in the admin.StackedInline instance it allows up to 2 profiles per user - with a blank one in place by default if the user has an ...

Django: Overriding the save() method: how do I call the delete() method of a child class

The setup = I have this class, Transcript: class Transcript(models.Model): body = models.TextField('Body') doPagination = models.BooleanField('Paginate') numPages = models.PositiveIntegerField('Number of Pages') and this class, TranscriptPages(models.Model): class TranscriptPages(models.Model): transcript = mode...

can't override default admin model form django

Hello, I need to add extra validation to my DateField in Admin to make sure the date given is in the future. I have no experience in such a thing, so here's what I've done. 1) I've created custom form field and added validation to it: class PastDateField(forms.DateField): def clean(self, value): """Validates if only date is in t...

Django Admin: Detect if a subset of an object fields has changed and which of them

I need to detect when some of the fields of certain model have changed in the admin, to later send notifications depending on which fields changed and previous/current values of those fields. I tried using a ModelForm and overriding the save() method, but the form's self.cleaned_data and seld.instance already have the new values of the ...

How can I filter the items shown in change list automatically?

I have just recently started using django (and i'm a novice python user as well), so please have some patience with my ignorance. I have installed a django application on my webhost, and I intend to use its admin interface as a multi-user log system (for lab work). There are different 'project's where each 'project' has a number of 'per...

How To Collapse Just One Field in Django Admin?

The django admin allows you to specify fieldsets. You properly structure a tuple that groups different fields together. You can also specify classes for certain groups of fields. One of those classes is collapse, which will hide the field under a collapsable area. This is good for hiding rarely used or advanced fields to keep the UI clea...

Django-Admin Exception Value: 'DeclarativeFieldsMetaclass' object is not iterable

Hi I have one form in forms.py class EmailForm(forms.Form): recipient = forms.CharField(max_length=14, min_length=12, widget=forms.TextInput(attrs=require)) message = forms.CharField(max_length=140, min_length=1, widget=forms.Textarea(attrs={'cols': 30, 'rows': 5})) and my site url is admin.autodiscover() urlpatterns = patterns...

How do I overrride fieldset.html template so that I can pass more arguments

I am overriding the admin fieldset.html template? I need to access the model. I have a table called domain and I need to query the database (Domain.objects.all) get a list of all the domains and pass it to the template. How/where would I do it especially with respect to admin interface. Thanks ...

Django admin, hide a model

Hello At the root page of the admin site where registered models appear, I want to hide several models that are registered to the Django admin. If I directly unregister those, I am not able to add new records as the add new symbol "+" dissapears. How can this be done ? ...

How to display a foreign key fields in the objects listing of the Django admin?

hi i have the following models setup class Player(models.Model): #slug = models.slugField(max_length=200) Player_Name = models.CharField(max_length=100) Nick = models.CharField(max_length=100, blank=True) Jersy_Number = models.IntegerField() Team_id = models.ForeignKey('Team') Postion_Choices = ( ('M', ...

Django App for Academic Journal?

I'm looking a Django app I'm looking for an app that that allows for management and integration of footnotes for articles just wondering if anyone had seen something around... ...

Django admin site auto populate combo box based on input

hi i have to following model class Match(models.Model): Team_one = models.ForeignKey('Team', related_name='Team_one') Team_two = models.ForeignKey('Team', related_name='Team_two') Stadium = models.CharField(max_length=255, blank=True) Start_time = models.DateTimeField(auto_now_add=False, auto_now=False, blank=True...

Django unable to update model

i have the following function to override the default save function in a model match def save(self, *args, **kwargs): if self.Match_Status == "F": Team.objects.filter(pk=self.Team_one.id).update(Played=F('Played')+1) Team.objects.filter(pk=self.Team_two.id).update(Played=F('Played')+1) if self.Winner !="": ...

How to accept localized date format (e.g dd/mm/yy) in a DateField on an admin form ?

Is it possible to customize a django application to have accept localized date format (e.g dd/mm/yy) in a DateField on an admin form ? I have a model class : class MyModel(models.Model): date = models.DateField("Date") And associated admin class class MyModelAdmin(admin.ModelAdmin): pass On django administration ...

Django admin output extra HTML in ModelSite

Ultimately, I want to add an <iframe> to the display of a particular model on Django's admin page. Django is already rendering the form for this model correctly, but I want to add this <iframe> in addition to Django's form. The src attribute needs to involve the primary key for the currently-displayed record. I've learned how to prope...

How to deal with multiple sub-type of one super-type in Django admin

What would be the best solution for adding/editing multiple sub-types. E.g a super-type class Contact with sub-type class Client and sub-type class Supplier. The way shown here works, but when you edit a Contact you get both inlines i.e. sub-type Client AND sub-type Supplier. So even if you only want to add a Client you also get the fi...

Will Django user permissions work for models with inline tabular forms of other models?

I am setting up DJango admin to make a model editable. On the same page I have tabular inline of a child model. Everything works as expected. Now I want to restrict permission on the tabular inline child form. Specifically remove update and delete permissions on it. I have tried removing the permissions for the admin user using the 'u...

Is it possible to alter the table in admin interface with SQL?

In our projects table we have every version of a project. Is it possible to show only those projects where max(version_id) in the admin interface? Thanks! :) Eric ...

Django Admin validation

Hi, I'd like to validate user input with regular expression in Django Admin CharField... How is it possible? Thanks in advance, Etam. ...