-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME
28 lines (19 loc) · 1.19 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
This is a simple django module which automatically exposes CRUD (created, read, update, delete) views for your django registered modules. At the moment, here are the steps to use it:
* Include the project on your path
* In your root urls conf file, add a reference like the following:
url(r'^crud/', include(autocrud.urls))
At this point, when you run your server you should be able to make PUT requests to url's like:
http://somewebsite/crud/myapp/create/mymodel
In the PUT requests, you should place the parameters of your model classes. For example, if I have the following model:
class TestModel(models.Model):
number_field = models.IntegerField()
Then, a creation request would look like:
http://somewebsite/crud/myapp/create/testmodel PUT={"number_field":42}
(This returns the newly created object's id in the response)
A read request would look like:
http://somewebsite/crud/myapp/read/testmodel PUT={"id":1}
An update request would look like:
http://somewebsite/crud/myapp/update/testmodel PUT={"id":1, "number_field":43}
And finally, a delete request would look like:
http://somewebsite/crud/myapp/delete/testmodel PUT={"id":1}
Take a look at the test cases for examples of this in operation.