Skip to content

Commit

Permalink
Merge pull request #42 from Viicos/patch-1
Browse files Browse the repository at this point in the history
Update code blocks in README
  • Loading branch information
saxix authored Oct 16, 2024
2 parents 676765e + dfdc61c commit 11deeb6
Showing 1 changed file with 30 additions and 28 deletions.
58 changes: 30 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,39 +59,41 @@ When you use `FilterDepotManager` to save a filter, the call is *idempotent* but
Usage examples
==============


class MyModel(models.Model):
index = models.CharField(max_length=255)
name = models.CharField(max_length=255)
age = models.IntegerField()
flag = models.CharField(default="1", choices=(("0", "Flag 1"), ("1", "Flag 2"))
household = models.ForeignKey('Household')
custom = JSONField(default=dict, blank=True)

class MyModelAdmin(ModelAdmin):
list_filter = (
FilterDepotManager, # needs `adminfilters.depot` app
QueryStringFilter,
DjangoLookupFilter,
("custom", JsonFieldFilter.factory(can_negate=False, options=True)),
("flag", ChoicesFieldComboFilter),
('household', AutoCompleteFilter)
('name', ValueFilter.factory(lookup='istartswith'),
("age", NumberFilter),
)

```python
class MyModel(models.Model):
index = models.CharField(max_length=255)
name = models.CharField(max_length=255)
age = models.IntegerField()
flag = models.CharField(default="1", choices=(("0", "Flag 1"), ("1", "Flag 2"))
household = models.ForeignKey("Household")
custom = JSONField(default=dict, blank=True)


class MyModelAdmin(ModelAdmin):
list_filter = (
FilterDepotManager, # needs `adminfilters.depot` app
QueryStringFilter,
DjangoLookupFilter,
("custom", JsonFieldFilter.factory(can_negate=False, options=True)),
("flag", ChoicesFieldComboFilter),
("household", AutoCompleteFilter)
("name", ValueFilter.factory(lookup="istartswith"),
("age", NumberFilter),
)
```


Run demo app
============

$ git clone https://github.com/saxix/django-adminfilters.git
$ cd django-adminfilters
$ python3 -m venv .venv
$ source .venv/bin/activate
$ make develop
$ make demo

```sh
git clone https://github.com/saxix/django-adminfilters.git
cd django-adminfilters
python3 -m venv .venv
source .venv/bin/activate
make develop
make demo
```

Project links
-------------
Expand Down

0 comments on commit 11deeb6

Please sign in to comment.