If I have a Pizza model and a Topping model, with m2m between them, is there some quick elegant way to add to the admin list page for either of them a list filter for all pizzas which contain a certain topping / all toppings that are contained in a certain pizza?
The built-in list_filter doesn't support m2m fields so I'm looking for som...
Is there a natural way to display model methods or properties in the Django admin site? In my case I have base statistics for a character that are part of the model, but other things such as status effects which affect the total calculation for that statistic:
class Character(models.Model):
base_dexterity = models.IntegerField(defa...
Hi
I have this sample model working with the admin
class Author(models.Model):
name = models.CharField(_('Text in here'), max_length=100)
with verbose_name set as ugettext_lazy 'Text in here', but sometimes, depending on the site_id i want to present a diferent verbose name, so I modified the init in this way
def __init__(self, ...
In my Django admin, when I try to view/edit objects from one particular model class the memory usage and CPU rockets up and I have to restart the server. I can view the list of objects fine, but the problem comes when I click on one of the objects. Other models are fine. Working with the object in code (i.e. creating and displaying) is o...
I'm trying to implement Florian's object permissions system from his article on Django Advent, but I'm running into an issue trying to limit the queryset returned to only items the user has permission to edit/view. Florian mentions it in his section on wrapping the admin, but skips over it. I can't see a good way to filter the queryset. ...
Hello
I have a such model:
GENDER_CHOICES = ( ('M', 'Male'), ('F', 'Female') )
class Profile(models.Model):
user = models.ForeignKey(User)
gender = models.CharField(max_length=1, choices=GENDER_CHOICES)
class FrontPage(models.Model):
female = models.ForeignKey(User,related_name="female")
male = models.ForeignKey(User,re...
How can I set a verbose_name for a model's method, so that it might be displayed in the admin's change_view form?
example:
class Article(models.Model):
title = models.CharField(max_length=64)
created_date = models.DateTimeField(....)
def created_weekday(self):
return self.created_date.strftime("%A")
in admin.py:
...
I'm using the admin interface to view invoices and products. To make things easy, I've set the products as inline to invoices, so I will see the related products in the invoice's form. As you can see I'm using a many-to-many relationship.
In models.py:
class Product(models.Model):
name = models.TextField()
price = models.Deci...
I've got two django models (simplified):
class Product(models.Model):
name = models.TextField()
price = models.IntegerField()
class Invoice(models.Model):
company = models.TextField()
customer = models.TextField()
products = models.ManyToManyField(Product)
I would like to see the relevant products as a nice tabl...
I have models that belong to some 'group' (Company class). I want to add users, who will also belong to a one group and should be able to edit/manage/add objects with membership in associated group.
something like:
class Company()
class Something()
company = ForeignKey(Company)
user Microsoft_admin
company = ForeignKey(Company)
...
So my site basically has 2 kinds of ways to login, one of them is for the common users, who get the regular screen that asks them for username and password, the other way its for staff.
The staff login should redirect them to the admin site after logging in, but for some reason the redirect doesnt happen, it stays on the same login page...
Hi,
I want to use django's admin filter on the list page.
The models I have are something like this:
class Location(model):
name = CharField()
class Inquiry(Model):
name = CharFiled()
location = ManyToManyField(Location)
Now I want to filter Inquiries, to display only those that contain relation to specific Location object. ...
Hi,
I want to apply ckeditor on specific textarea in django admin form not on all the text areas.
Like snippet below will apply ckeditor on every textarea present on django form:
class ProjectAdmin(admin.ModelAdmin):
formfield_overrides =
{models.TextField: {'widget': forms.Textarea(attrs={'class':'ckeditor'})}, }
class...
I have this simple Blog model:
class Blog(models.Model):
title = models.CharField(_('title'), max_length=60, blank=True, null=True)
body = models.TextField(_('body'))
user = models.ForeignKey(User)
is_public = models.BooleanField(_('is public'), default = True)
When I insert a blog in admin interface, I get this err...
Hi.
I've been following the Django tutorial, and so far everything's been working as planned.
Except "collapse"ing.
On my admin page, I get the error in my Javascript Console:
Uncaught TypeError: Object #<an Object> has no method 'first' collapse.min.js:1
I'm assuming this is a bug in jQuery, or the collapse script, however my qu...
I have an application in Django 1.2.
Language is selectable (I18N and Locale = True)
When I select the english lang. in the site, the admin works OK. But when I change to any other language this is what happens with date inputs (spanish example):
Correctly, the input accepts the spanish format %d/%m/%Y (Even selecting from the calendar...
In Django admin site, when listing all the objects for a given model, I know we can customize which columns get displayed for a ModelA via list_display
Say that ModelA has a one-to-many relationship with ModelB. I would like to add another column on the listing page for ModelA, where each entry is a URL pointing to all objects of ModelB...
Using the django admin, I would like to be able to specify which models a user sees when he logs in. For a stretch goal, for each model types a user can see, I would like to specify a filter to limit which instances of the model the user can see.
Could someone please provide a pointer for how to go about achieving this?
...
Django's internationalization is very nice (gettext based, LocaleMiddleware), but what is the proper way to translate the model name and the attributes for admin pages? I did not find anything about this in the documentation:
http://docs.djangoproject.com/en/dev/topics/i18n/internationalization/
http://www.djangobook.com/en/2.0/chapter...
My Book model has an author attribute which today is simply a CharField. The value for author should be one of the registered users of my Django site. When creating a new Book object in Django admin, I would like author to be displayed as a combo box showing all registered users. How would I go about achieving this?
...