Skip to content

Commit

Permalink
Merge pull request #4 from ChogirmaliYigit/unfold
Browse files Browse the repository at this point in the history
(feat): `django-unfold` added for better admin UI ✨
  • Loading branch information
Muhammadali-Akbarov committed Apr 1, 2024
2 parents 13810f8 + e5d2439 commit 9a72368
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
venv/
data/
.vscode/
.idea/
__pycache__/

*.log
*.pot
*.pyc

.env
db.sqlite3
db.sqlite3
18 changes: 17 additions & 1 deletion apps/shop/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
from django.contrib import admin
from unfold.admin import ModelAdmin

from shop.models import CustomOrderModel


admin.site.register(CustomOrderModel)
@admin.register(CustomOrderModel)
class CustomOrderModelAdmin(ModelAdmin):
# The fields to display on objects list in the admin panel
list_display = ("id", "amount",)

# The fields of CustomOrderModel which used to add or update objects in the admin panel
fields = ("amount",)

# The fields which used to sort objects
ordering = ("-amount",)

# The fields to search through objects
search_fields = ("id", "amount",)

# all configurations here:
# https://github.com/unfoldadmin/django-unfold?tab=readme-ov-file#available-unfoldadminmodeladmin-options
14 changes: 14 additions & 0 deletions mysite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
ALLOWED_HOSTS = env.list("ALLOWED_HOSTS")

INSTALLED_APPS = [
"unfold", # before django.contrib.admin
"unfold.contrib.filters", # optional, if special filters are needed
"unfold.contrib.forms", # optional, if special form elements are needed
"unfold.contrib.import_export", # optional, if django-import-export package is used
"unfold.contrib.guardian", # optional, if django-guardian package is used
"unfold.contrib.simple_history", # optional, if django-simple-history package is used

'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
Expand Down Expand Up @@ -113,3 +120,10 @@
]

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

UNFOLD = {
"show_search": True,
"show_all_applications": True,
# to see all configurations, visit here:
# https://github.com/unfoldadmin/django-unfold?tab=readme-ov-file#configuration
}
8 changes: 7 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
drf-yasg==1.21.5
environs==9.5.0
flake8==6.0.0
payme-pkg==2.6.3
payme-pkg>=2.6.*
pip-chill==1.0.1
django-unfold~=0.21.1
Django~=5.0.3
djangorestframework~=3.14.0
django-import-export~=3.3.7
django-guardian~=2.4.0
django-simple-history~=3.5.0

0 comments on commit 9a72368

Please sign in to comment.