I have a Person model that has a foreign key relationship to Book. Book has a number of fields, but I'm most concerned about "author" (a standard CharField).
With that being said, in my PersonAdmin model, I'd like to display "book.author" using "list_display". I've tried all of the obvious methods for doing so (see below), but nothing...
I've got a model for Orders in a webshop application, with an auto-incrementing primary key and a foreign key to itself, since orders can be split into multiple orders, but the relationship to the original order must be maintained.
class Order(models.Model):
ordernumber = models.AutoField(primary_key=True)
parent_order = models....
Hi All
I'm using the GenerickStackedInline which is a subclass of InlineModelAdmin which goes to ModelAdmin. When I override save_model method... it's not being called.
class LocatedItemStackedInline(generic.GenericStackedInline):
template = "admin/location_app/located_items/stacked.html"
model = LocatedItem
extra = 1
f...
In Django's admin, I want disable the links provided on the "select item to change" page so that users cannot go anywhere to edit the item. (I am going to limit what the users can do with this list to a set of drop down actions - no actual editing of fields).
I see that Django has the ability to choose which fields display the link, ho...
Even after obj.save(), the obj still does not have an id,
so I cannot access or manipulate the m2m records. Just keep getting a "instance needs to have a primary key value before a many-to-many relationship can be used" error.
def save_model(self, request, obj, form, change):
obj.save() # this doesn't work
super(Table2Admin, sel...
I have the following models:
class Foo(models.Model):
field1 = models.IntegerField()
...
class Bar(models.Model):
field1 = models.IntegerField()
...
class Foo_bar(models.Model):
foo = models.ForeignKey(Foo)
bar = models.ForeignKey(Bar)
...
In the admin, I want it so that in the Foo change/add page, you ca...
Hello,
I have a class called News which have a choices field called category.
Each category is also representing by classes with the News class as foreignKey field.
So in admin, when I create a new category instance, I have to create a News, which is represented with a popup.
The main page which represents the category class is the p...
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
...