0

with this model:

class MyModel(models.Model):
    a = models.BooleanField(default=False)
    b = models.BooleanField(default=False)
    c = models.BooleanField(default=False)

and this admin definition:

class MyModelAdmin(admin.ModelAdmin):
    list_display = (
        'a',
        'b',
        'c',
    )
    list_editable = (
        'a',
        'b',
        'c',
    )

I have a, b and c in one column each. Is there a way to place a, b and c in the same column?

I tried this:

class MyModel(models.Model):
    a = models.BooleanField(default=False)
    b = models.BooleanField(default=False)
    c = models.BooleanField(default=False)

    def all(self):
        return self.a, self.b, self.c

class MyModelAdmin(admin.ModelAdmin):
    list_display = (
        'all',
    )
    list_editable = (
        'all',
    )

and get following error:

"The value of 'list_editable[0]' refers to 'all', which is not an attribute of 'app.MyModel'."

Any suggestions place a, b and c in one column while being able to use "list_editable"?

user2496550
  • 573
  • 1
  • 8
  • 18

1 Answers1

0

If you use creating custom field for this situation and use Django Form / save method, I think will be fix your problem.

here stack overflow answer: link