1๐
I have done this job. So this is my code:
admin.py
from django.contrib import admin
from myapp.models import Client, Item, Order, Ordering
class ClientAdmin(admin.ModelAdmin):
list_display = ("f_name", "l_name", "m_name", "phone", "city", "address")
list_filter = ["f_name", "l_name", "city"]
class ItemAdmin(admin.ModelAdmin):
list_display = ("name", "type_item", "color", "cost", "is_available_now",
"available_count")
list_filter = ["name", "type_item", "color", "cost", "available_count"]
class OrderingAdmin(admin.ModelAdmin):
list_display = ("id_order", "id_item", "count_items")
list_filter = ["id_order", "id_item", "count_items"]
class OrderingInline(admin.TabularInline):
model = Ordering
fk_name = "id_order"
max_num = 1
class OrderAdmin(admin.ModelAdmin):
list_display = ("id", "id_client", "date_order", "date_taken", "is_paid",
"is_taken")
list_filter = ["date_order", "date_taken", "is_paid", "is_taken"]
inlines = [
OrderingInline,
]
admin.site.register(Item, ItemAdmin)
admin.site.register(Order, OrderAdmin)
admin.site.register(Client, ClientAdmin)
admin.site.register(Ordering, OrderingAdmin)
And what I take:
Thanks to all)))
๐คOleg Klimenko
0๐
Instead of use Order_item
class, you should add a items = models.ManyToManyField(Item)
field into your current Order
class.
- How to manually install modules in qpython
- Restarting the Gunicorn after change in my code
- Best way of giving user's the ability to create their own datastores?
Source:stackexchange.com