Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix mega bug #5

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ repos:
hooks:
- id: pytest
name: pytest
entry: pytest -s tests/testproject
entry: pytest -s tests/testproject/testapp -c tests/testproject/pytest.ini
language: system
types: [python]
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
recursive-include src/dalf/static *
recursive-include src/dalf/templates *
57 changes: 54 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![Version](https://img.shields.io/badge/version-0.1.0-orange.svg?style=for-the-badge&logo=semver)
![Version](https://img.shields.io/badge/version-0.1.1-orange.svg?style=for-the-badge&logo=semver)
![Python](https://img.shields.io/badge/python-3.11+-green.svg?style=for-the-badge&logo=python)
![Django](https://img.shields.io/badge/django-5.0.2-green.svg?style=for-the-badge&logo=django)
[![Ruff](https://img.shields.io/endpoint?style=for-the-badge&url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
Expand Down Expand Up @@ -31,6 +31,16 @@ After **Django Admin List Filter**

---

## 2024-07-03

Thanks to my dear friend [Bahattin Çiniç][bahattincinic]’s warning, He realized
that the necessary HTML, CSS, and JavaScript files were missing from the
published package! I quickly fixed this and published a new version. The `0.1.0`
version is a faulty version. I apologize to the users for this confusion.
Thank you. - vigo

---

## Installation

```bash
Expand Down Expand Up @@ -107,7 +117,7 @@ Example `admin.py`:
# admin.py
from dalf.admin import DALFModelAdmin, DALFRelatedOnlyField, DALFRelatedFieldAjax
from django.contrib import admin

from YOURAPP.models import Post

@admin.register(Post)
class PostAdmin(DALFModelAdmin):
Expand All @@ -122,9 +132,27 @@ That’s all... There is also `DALFChoicesField`, you can test it out:

```python
# admin.py
from dalf.admin import DALFModelAdmin, DALFChoicesField, DALFRelatedOnlyField, DALFRelatedFieldAjax
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.contrib.auth.models import User

from dalf.admin import (
DALFModelAdmin,
DALFChoicesField,
DALFRelatedOnlyField,
DALFRelatedFieldAjax,
)

from YOURAPP.models import Post, Category, Tag

# must be registered, must have search_fields, required for `author` field demo.
# this is demo purpose only, you can register/import your own/custom User model
class UserAdmin(BaseUserAdmin):
search_fields = ['username']
ordering = ['username']

admin.site.unregister(User)
admin.site.register(User, UserAdmin)

@admin.register(Post)
class PostAdmin(DALFModelAdmin):
Expand All @@ -133,6 +161,20 @@ class PostAdmin(DALFModelAdmin):
('category', DALFRelatedFieldAjax), # enable ajax completion for category field (FK)
('tags', DALFRelatedOnlyField), # enable ajax completion for tags field (M2M) if posts has any tag!
)

# must be registered, must have search_fields
@admin.register(Category)
class CategoryAdmin(admin.ModelAdmin):
search_fields = ['title',]
ordering = ['title']


# must be registered, must have search_fields
@admin.register(Tag)
class TagAdmin(admin.ModelAdmin):
search_fields = ['name',]
ordering = ['name']

```

### Extras
Expand All @@ -148,6 +190,8 @@ Now add `timezone` field to `Post` model:

```python
# modify models.py, add new ones
# ...

from timezone_field import TimeZoneField # <- add this line

class Post(models.Model):
Expand Down Expand Up @@ -179,6 +223,7 @@ That’s it!

* [Uğur Özyılmazel](https://github.com/vigo) - Creator, maintainer
* [Ehco](https://github.com/Ehco1996) - Contributor
* [Bahattin Çiniç][bahattincinic] - Bug Report!

---

Expand All @@ -203,6 +248,7 @@ pull requests!
Clone the repo somewhere, and install with:

```bash
pip install -r requirements-dev.txt
pip install -e /path/to/dalf
pre-commit install
```
Expand All @@ -229,6 +275,10 @@ rake upload:test # Upload package to test distro

## Change Log

**2024-07-03**

- Now package is working fine :) Thanks to [Bahattin][bahattincinic]!

**2024-06-01**

- Update missing information in the README
Expand Down Expand Up @@ -260,3 +310,4 @@ contributors are expected to adhere to the [code of conduct][coc].
[1]: https://github.com/demiroren-teknoloji/django-admin-autocomplete-list-filter "Deprecated, old package"
[coc]: https://github.com/vigo/django-admin-list-filter/blob/main/CODE_OF_CONDUCT.md
[changelog]: https://github.com/vigo/django-admin-list-filter/blob/main/CHANGELOG.md
[bahattincinic]: https://github.com/bahattincinic