2

I'm new to web development, but have recently been getting going with it pretty fast, using Django (which I'm falling in love with). However, while Django is easy to get going with and pick up quite fast, I'm afraid there are concepts I don't know much about, particularly REST and RESTful web services. I hear those terms thrown around a lot, and I'm assuming are important to modern web apps, and I want to know basically what they mean, when I should use them, and how I should use them (package, plugin, etc.).

My web app consists of the following functionality:

  • Discussion Board which I've implemented so far only using the model layer
  • Messaging which I've implemented so far only using the model layer
  • Payments (not yet implemented)
  • Calendar (not yet implemented)

And that's about it for now. When should I be thinking about REST within these functionalities?

Bowdzone
  • 3,827
  • 11
  • 39
  • 52
rigdonmr
  • 2,662
  • 3
  • 26
  • 40

1 Answers1

1

You could get really in depth with the subject, but when I think of it, I think of the URLs your site will be providing. That, for me at least, is the simple way to think of a RESTful service. I also think it's a good way to get to grips with Django & it's generic views.

Taken your example there of a calendar. A RESTful approach to a calendar app, with django's generic views, might implement URLs like;

# ListView
/calendar

# DetailView for a given item in the calendar
/calendar/<id>  

# UpdateView for an item
/calendar/<id>/update  

# DeleteView for an item
/calendar/<id>/delete  

Beyond that, REST requires you consider the HTTP methods in use, so you should then define what methods your URLs will accept in order to better control the interaction. Furthermore, if you were enforcing the HTTP method on each action, you could write a more generic view which didn't expose the /update or /delete URLs. But I'd consider that a more advanced approach & you may wish to start from a more explicit design.

Once you start to write a consistent structure for your apps then you can easily make generic functions, and expand.

There is a whole load of things you could read on this subject, depending on where you see it going.

If you're thinking of building something that can provide an API then there's already a Django framework for this; http://www.django-rest-framework.org/

But if you're getting started & just want to know more about the concepts, Wikipedia is always a good place to look, and finally this looks like a great example for this subject using Django which should hopefully help you on your way.

To understand the idea of a resource, take a look at this answer

Community
  • 1
  • 1
markwalker_
  • 12,078
  • 7
  • 62
  • 99
  • 1
    It might be more RESTful to say have a "PUT" to /calendar// be update, and a "DELETE" being delete as opposed to having a specific urls for each operation? – Adam Benzan Dec 16 '15 at 00:27
  • Thanks for the feedback. I also hear the term "resource" quite often. Could you also add an example of where "resources" fit in to my given example? – rigdonmr Dec 16 '15 at 00:48