@@ -3,54 +3,82 @@ Django Object Actions
3
3
4
4
If you've ever tried making your own admin object tools and you were like me,
5
5
you immediately gave up. Why can't they be as easy as making Django Admin
6
- Actions? Well now they can!
6
+ Actions? Well now they can be.
7
7
8
- This is very similar to [ django-object-tools] , but does not require messing with
9
- your urls.py, does not do anything special with permissions, and uses a subset
10
- of the language you already know from making [ django admin actions] .
8
+ ### Similar Packages
9
+
10
+ Django Object Actions is very similar to [ django-object-tools] , but does not
11
+ require messing with your urls.py, does not do anything special with
12
+ permissions, and uses the same patterns as making [ admin actions] in Django.
11
13
12
14
[ django-object-tools ] : https://github.com/praekelt/django-object-tools
13
- [ django admin actions ] : https://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/#actions-as-modeladmin-methods
15
+ [ admin actions ] : https://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/#actions-as-modeladmin-methods
16
+
14
17
18
+ ## Installation
15
19
16
- Installation
17
- ------------
20
+ Install Django Object Actions. Currently, this has to be done manually.
18
21
19
22
Add ` django_object_actions ` to your ` INSTALLED_APPS ` .
20
23
21
- Or just put the template some place Django can find it.
24
+ ### Alternate Installation
25
+
26
+ Install Django Object Actions. Currently, this has to be done manually.
27
+
28
+ Copy the templates some place Django's template loader [ will find it] .
29
+
30
+ [ will find it ] : https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs
22
31
23
- Example Usage
24
- -------------
32
+ ## Usage
25
33
26
- Tools are defined just like defining actions as modeladmin methods, see: [ django
27
- admin actions] for examples and detailed syntax. The major difference being
28
- the functions you write will take an object instead of a queryset:
34
+ Tools are defined just like defining actions as modeladmin methods, see: [ admin
35
+ actions] for examples and detailed syntax. You can return nothing or an http
36
+ response. The major difference being the functions you write will take an object
37
+ instance instead of a queryset:
29
38
30
39
def toolfunc(self, request, obj)
31
40
32
- They are exposed by putting them in a ` objectactions ` attribute in your
41
+ Tools are exposed by putting them in an ` objectactions ` attribute in your
33
42
modeladmin like:
34
43
35
44
class MyModelAdmin(DjangoObjectActions, admin.ModelAdmin):
36
45
def toolfunc(self, request, obj):
37
46
pass
38
- toolfunc.short_description = "This will be the tooltip of the button"
47
+ toolfunc.label = "This will be the label of the button" # optional
48
+ toolfunc.short_description = "This will be the tooltip of the button" # optional
39
49
40
- objectactions = ('toolfunc',)
50
+ objectactions = ('toolfunc', )
41
51
42
52
Just like actions, you can send a message with ` self.message_user ` . Normally,
43
53
you would do something to the object and go back to the same place, but if you
44
54
return a HttpResponse, it will follow it (hey, just like actions!).
45
55
46
- Limitations: django-object-actions expects these functions to be methods of the
47
- model admin.
56
+ ### Limitations
57
+ django-object-actions expects these functions to be methods of the model admin.
48
58
49
- Development
50
- -----------
59
+ If you provide your own custom change_form.html, you'll also need to manually
60
+ copy in the relevant bits of [ our change form ] .
51
61
52
- Getting started:
62
+ [ our change form ] : https://github.com/texastribune/django-object-actions/blob/master/django_object_actions/templates/django_object_actions/change_form.html
53
63
64
+ ## Development
65
+
66
+ Getting started _ (with virtualenvwrapper)_ :
67
+
68
+ # get a copy of the code
69
+ git clone git@github.com:texastribune/django-object-actions.git
70
+ cd django-object-actions
71
+ # set up your virtualenv
72
+ mkvirtualenv django-object-actions
54
73
pip install -r requirements-dev.txt
74
+ export DJANGO_SETTINGS_MODULE=example_project.settings
75
+ add2virtualenv .
76
+ # start doing stuff
77
+ make test
78
+ make resetdb
79
+ python example_project/manage.py runserver
80
+
81
+ The fixtures will create a user, admin: admin , you can use to log in immediately.
82
+
55
83
56
- Various helpers available as make commands.
84
+ Various helpers are available as make commands.
0 commit comments