Commits

David Larlet committed 9503fd6

Add the Twitter example

Comments (0)

Files changed (1)

 * plug it on top of an RDF triple store (probably my next pony)
 * your crazy use-case? ;-)
 
+== A basic Twitter example ==
+
+The complete example is available in source code examples. First let's define some models with URLs from Twitter's API:
+
+{{{
+#!python
+
+class User(Model):
+    name = models.CharField(max_length=50)
+    screen_name = models.CharField(max_length=50)
+    description = models.TextField()
+
+    @staticmethod
+    def get_resource_url_list():
+        return u'http://twitter.com/users/show.json'
+
+class Tweet(Model):
+    text = models.TextField()
+    source = models.CharField(max_length=50)
+    user = models.ForeignKey(User)
+
+    @staticmethod
+    def get_resource_url_list():
+        return u'http://twitter.com/statuses/public_timeline.json'
+}}}
+
+Now we can launch a Django shell and test our models:
+{{{
+#!python
+
+$ python manage.py shell
+>>> from twitter_roa.models import User, Tweet
+>>> tweets = Tweet.objects.all()
+>>> atweet = tweets[0]
+>>> print atweet.text
+Uhm can I get a boyfriend with muscles and no bullshit. Yumm. Xoxo
+>>> print atweet.user.name
+Jacob Maldonado
+
+}}}
+
+It works! But even more interesting, you can use your lovely Django's built-in admin with your new models:
+
+{{http://welldev.org/twitter-roa-admin.png|Tweets in your Django admin}}
+
+Now you'll even be able to clic on users to go to the Django's admin view. And so on.
+
 == Getting started ==
 
 <<toc GettingStarted 3>>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.