Tuesday, October 29, 2013

Re: RestFul with Class Based Views best practice

Hi,

You probably want to have a look at django rest framework.
You use can will be easy with it, in particular if you use http://django-rest-framework.org/api-guide/viewsets.html#modelviewset

Regards,
Xavier.

Le 29 oct. 2013 à 20:45, pywebdesign <pywebdesign@gmail.com> a écrit :

Hi,

I am trying to find/develop a best way to name and organize Views class to be consistent and flexible.

I am working on a project witch involve an model called Song. It's kind of a midi song in a database with attibutes about authors, name ... to make it simple.

Now I want web pages that permit to create a new song, edit a song, delete it or simply view it.
I also want a list page that list song by authors, by instrument (a typical search and return a list). the idea is to make the list editable via ajax. people change something on a list and it saves it to the browser when done without quitting the list. Very useful to modify many list at the same time.
There is also a page to create/upload 5 song at a time.

I was searching the best structure for my Class Based View. Right now I came up with this one:

class SongForm
def get_new_song
def post_new_song

def get_modify_song
def put_song

def get_delete_song
def delete_song

class SongListForm
def get_list_song(search infos)

class SongView
get_Song


ok that's about it. It look wrong, one big class and to very small one. I would like some pointer to some best practice to create this kind of CRUD as RESTFUL.

Thank you very much



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/61688c29-1d49-4d1a-9d04-45192d00c78d%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment