Skip to content

Commit a590df6

Browse files
committed
add new admin examples
1 parent 930a18c commit a590df6

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

content/pages/examples/django/django-contrib-admin.markdown

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,49 @@ The admin interface can be heavily customized and the code examples below can
1414
help you understand how to implement some of the trickier parts of customization.
1515

1616

17-
## Example 1 from heritagesites
17+
## Example 1 from django-oscar
18+
[django-oscar](https://github.com/django-oscar/django-oscar/)
19+
([project website](http://oscarcommerce.com/))
20+
is a framework for building e-commerce sites on top of
21+
[Django](/django.html). The code for the project is available open
22+
source under a
23+
[custom license written by Tangent Communications PLC](https://github.com/django-oscar/django-oscar/blob/master/LICENSE).
24+
25+
[**django-oscar/src/oscar/apps/address/admin.py**](https://github.com/django-oscar/django-oscar/blob/master/src/oscar/apps/address/admin.py)
26+
27+
```python
28+
# admin.py
29+
~~from django.contrib import admin
30+
31+
from oscar.core.loading import get_model
32+
33+
34+
~~class UserAddressAdmin(admin.ModelAdmin):
35+
~~ readonly_fields = ('num_orders_as_billing_address', 'num_orders_as_shipping_address')
36+
37+
38+
~~class CountryAdmin(admin.ModelAdmin):
39+
list_display = [
40+
'__str__',
41+
'display_order'
42+
]
43+
list_filter = [
44+
'is_shipping_country'
45+
]
46+
search_fields = [
47+
'name',
48+
'printable_name',
49+
'iso_3166_1_a2',
50+
'iso_3166_1_a3'
51+
]
52+
53+
54+
~~admin.site.register(get_model('address', 'useraddress'), UserAddressAdmin)
55+
~~admin.site.register(get_model('address', 'country'), CountryAdmin)
56+
```
57+
58+
59+
## Example 2 from heritagesites
1860
[heritagesites](https://github.com/Michael-Cantley/heritagesites) is a
1961
[Django](/django.html)-based web app with a [MySQL](/mysql.html)
2062
backend that displays

0 commit comments

Comments
 (0)