django-admin

Defining ways to visualise admin fields - Django

Hi folks, I'm trying to add graphs to the admin interface, problem is that I have not found any documentation regarding this. I'm sure there are generally accepted ways of customizing the way fields are displayed, and I do not wish to follow any problematic route. Any ideas? Edit: this is a model I'm trying to reproduce! Un...

Overwrite queryset which builds filter sidebar

Hi, I'm writing a hockey database/manager. So I have the following models: class Team(models.Model): name = models.CharField(max_length=60) class Game(models.Model): home_team = models.ForeignKey(Team,related_name='home_team') away_team = models.ForeignKey(Team,related_name='away_team') class SeasonStats(models.Model): tea...

Customizing Django form widgets? - Django

Hi folks, I'm having a little problem here! I have discovered the following as being the globally accepted method for customizing Django admin field. from django import forms from django.utils.safestring import mark_safe class AdminImageWidget(forms.FileInput): """ A ImageField Widget for admin that shows a thumbnail. "...

Email authentication in Django ( strange error )

I have inserted this in settings.py: AUTHENTICATION_BACKENDS = ( 'blog.auth.backends.EmailBackend', 'django.contrib.auth.backends.ModelBackend', ) blog is an application ( correctly installed ), auth is a folder in blog application, backends.py is the file that contain this method: from django.contrib.auth.backends import ModelBacke...

Programmatically sync the db in Django

I'm trying to sync my db from a view, something like this: from django import http from django.core import management def syncdb(request): management.call_command('syncdb') return http.HttpResponse('Database synced.') The issue is, it will block the dev server by asking for user input from the terminal. How can I pass it the ...

Django admin's filter_horizontal (& filter_vertical) not working

I'm trying to use ModelAdmin.filter_horizontal and ModelAdmin.filter_vertical for ManyToMany field instead of select multiple box but all I get is: My model: class Title(models.Model): #... production_companies = models.ManyToManyField(Company, verbose_name="компании-производители") #... My admin: class TitleAdmin(ad...

Django Admin drop down combobox and assigned values

I have several question for the Django Admin feature. Im kind of new in Django so im not sure how to do it. Basically what Im looking to do is when Im adding information on the model. Some of the fields i want them to be combo-boxes with AutoCompleteMode. Also looking for some fields to have the same information, for example if i ha...

Default value for field in Django model

Suppose I have a model: class SomeModel(models.Model): id = models.AutoField(primary_key=True) a = models.IntegerField(max_length=10) b = models.CharField(max_length=7) Currently I am using the default admin to create/edit objects of this type. How do I set the field 'a' to have the same number as id? (default=???) Other...

Default value for hidden field in Django model

I have this Model: class Occurrence(models.Model): id = models.AutoField(primary_key=True, null=True) reference = models.IntegerField(null=True, editable=False) def save(self): self.reference = self.id super(Occurrence, self).save() I want for the reference field to be hidden and at the same time have th...

Django admin - how to make "inlines" collapsible?

Hi, With "fieldsets" you can make it collapsible by specifying the CSS class "collapse". How to do the same with "inlines"? Thank you! ...

Need "starting point" hints about adding "tabbed" interface to Django admin

Hi, I'm new to the web development world - that means I'm new to javaScript/CSS. Now I'm building a web system with Python Django. I'm wondering would you like to give me some hints as the starting point for adding "tabbed" interface to Django admin? For example, there are 3 detail table for a master table, and I want to use 3 differen...

Django Admin Actions missing

One of my Django sites is missing the Django Admin Action bar shown here: http://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/#ref-contrib-admin-actions There is no checkbox next to each row and no Action select box near the top of the page. This is happening on every model. I have several sites running Django 1.1, and the...

Django admin clear button for form

I was wondering if there is a way to put a "Clear Form" button on the admin forms of the apps in django? ...

django admin app error (Model with property field): global name 'full_name' is not defined

This is my model: class Author(models.Model): first_name = models.CharField(max_length=200) last_name = models.CharField(max_length=200) middle_name = models.CharField(max_length=200, blank=True) def __unicode__(self): return full_name def _get_full_name(self): "Returns the person's full name." ...

Sorting related objects in the Django Admin form interface

I am looking to sort the related objects that show up when editing an object using the admin form. So for example, I would like to take the following object: class Person(models.Model): first_name = models.CharField( ... ) last_name = models.CharField( ... ) hero = models.ForeignKey( 'self', null=True, blank=True ) and ed...

Django Admin form - how to show two "fieldsets" horizontally in a form?

Hi, How to show two "fieldsets" horizontally in a form? Note: I don't mean show multiple fields horizontally, but multiple fieldsets. Thank you! ...

Filtering foreign keys with AJAX in Django admin

I have most of this figured out already. I have AJAX returning the region/state/province when a country is selected. The correct foreign key is saved to the database, however, when the record is viewed afterwards the selected state is not shown in the select nor are any states for the selected country. I understand why this is happening ...

Is there a way to get custom Django admin actions to appear on the "change" view in addition to the "change list" view?

I thought for whatever reason this would be easy to do, but I looked deeper and it appears there is no straightforward way to allow users to execute custom admin actions on the "change" view of an instance (i.e. when you are just viewing the edit screen for a single instance, not the list of instances). Am I overlooking an easy way to d...

Editing Django's admin index <div id='module'> tag

I am new to the Django framework. On Django's admin index page I'd like to get rid of the "s" at the end of my model names. Example: <div class="module"> <table summary="Models available in the my application."> <caption><a href="" class="section">My application</a></caption> <tr> <th scope="row"><a ...

How to show raw_id value of a ManyToMany relation in the Django admin?

Hello, I have an app using raw_id on both ForeignKeyField and ManyToManyField. The admin displays the value of the foreign key on the right of the edit box. Unfortunatey, it doesn't work with ManyToMany. I've checked the code and I think that it is the normal behavior. However I would like to know if someone has an easy tip to change t...