background preloader

Django

Facebook Twitter

Optimizing Django Templates. Scholrly/neo4django - GitHub. Neo4django 0.1.5 Release. Yesterday, we released another major neo4django milestone. You can get it from PyPi or GitHub . Because the library is not feature complete- in particular, the lack of relationship models is a problem for many Neo4j users- the milestone is merely a minor revision number. This milestone is important for a few reasons, however. Performance Focused select_related() We’ve implemented select_related() , a Django QuerySet feature that allows a developer to request the ORM to follow database relations, join the results, and return all data in one query. In a graph database, this is even more important- because, in all likelihood, you’re using a graph approach due to a particularly connected domain model. select_related() enables traversals in a way already familiar to Django developers. Access the returned Person object as you normally would. for f in max . friends . all (): for foaf in f . friends . all (): print foaf . name ...and there won’t be any additional database calls.

Performance Caveats. Django-guardian - per object permissions for Django — django-guardian v1.0.2 documentation. Django Userena - Accounts for your Django application. Learn python & Django. Five Days to a Django Web App: Day Three, Coding - The Daily Build. Thanks for coming back for Day Three! [Note: Sorry this post is a day late. It was all ready to go late yesterday, but some of the code included below triggered a bug either in WordPress or ScribeFire and the whole post got mangled. I managed to resurrect it today from drafts, and I think it's coherent, but if you find some problem with it please drop me a note.] Progress So Far Yesterday we built some mockups, just HTML and CSS — nothing active. Hopefully you’ve had a chance to run your mockups past a couple of people for feedback and ideas. Armed with these mockups, we’re ready to get started coding.

Foundation MySQL First, go to your web host’s control panel and create two MySQL databases for this project. You’ll get an error/warning if the test database exists when you first run tests. Set up the same databases on your local system: bash$ mysql -u root Welcome to the MySQL monitor. Then generate a skeleton for your project: django-admin.py startproject YOURPROJECT. Adding Some Meat bash$ . Django Videos, Tutorials and Screencasts. Django aggregation tutorial — The Uswaretech Blog - Django Web Development. By : Shabda Raaj One of the new and most awaited features with Django 1.1 was aggregation. As usual, Django comes with a very comprehensive documentation for this. Here, I have tried to put this in how-to form. Jump to howtos or Get source on Github.

Essentially, aggregations are nothing but a way to perform an operation on group of rows. In databases, they are represented by operators as sum, avg etc. To do these operations Django added two new methods to querysets. aggregateannotate When you are have a queryset you can do two operations on it, Operate over the rowset to get a single value from it. The thing to notice is that option 1, will create one row from rowset, while option 2 will not change the number of rows in the rowset. In sql terms, aggregate is a operation(SUM, AVG, MIN, MAX), without a group by, while annotate is a operation with a group by on rowset_table.id.

Ok enough talk, on to some actual work. Find the total number of employees. In sql you might want to do something like, Home - django-cms.org. Django Packages : django reusable apps, sites and tools directory. Clemesha/hotdot - GitHub. Using Django's TemplateTags. I've had a number of e-mails about how I include the listing of blog tags and archives by month on the side of my website from people who have obviously built up a blog and now want further integration with their website. Well, it's ultra-simple thanks to a nifty Django feature called template tags. The concept behind template tags is simple - a quick snippet of code in your page templates calls some python code behind the scenes, which does some stuff, and returns either raw HTML code (yuck) or sets new variables in your template context, allowing you to manipulate and display them as you please (cool!) To get started, in the application directory for your blog, create a directory named templatetags and place an empty file in it, named _init.py_.

Now, create a file - in this case we'll call it blogmonths.py_. We need to do a few things in this file: The contents of this file need to be: Next, create a new file named, for example, blogtags.py_ and paste the following into it: Last drinks. The Django Book: Version 2.0 (English) Webdev » Blog Archive » How to implement Drag and Drop lists with Django and Dojo. Pinax. P2P File Sharing Browser Plugin LittleShoot - BitTorrent - Gnutella. Markdown in Python: Using Markdown with Django. Django-gae-rpx - Project Hosting on Google Code.

Django RPX authentication backend that runs on Google App Engine with App Engine Patch. Inspired by django-rpx and django-newrpx but with support for Google App Engine thru App Engine Patch. You can see a live demo running at Note that the site might appear slow at first. The reason seems to be that the app engine unloads instances that haven't been used for some time. Subsequent request have reasonable performance. 20100308 App Engine Patch is dead Note: New announcement from the App Engine Patch project: "app-engine-patch is no longer being updated". 20090618: Version 0.1 released Introduction This is the alpha release of the Django-RPX-GAE-GAE authentication backend.

Known issues/drawbacks that will be fixed No timeout on request to RPX server. Installation instructions Unpack the rpx module in your project. AUTHENTICATION_BACKENDS = ('rpx.backends.RpxBackend', 'django.contrib.auth.backends.ModelBackend') {% load rpx_tags %}{% rpx_iframe next %} DynamicModels - Django - Trac. For an updated information about dynamic models in Django 1.2 and later ​checkout this guide. this works with django 0.96. There are some modification that make it hard to adjust it with django version 1.0 As of [5163], Django models can now be created dynamically at run-time, rather than being defined in a Python source file.

While this may seem useless on the surface, it actually provides a powerful way to prototype a Django project, even by users who don't know a thing about Python! This page lists the basic technique involved in creating models at run-time, as well as some examples of how it could be used. It is not meant to be exhaustive, nor is it meant to be drop-in code for your own project.

The basic technique ¶ Internally, Django uses metaclasses to create models based on a class you provide in your source code. Thankfully, Python treats classes like any other object, so we can force this process to occur even when the class wasn't defined in source. This: Drawbacks ¶ Syncdb ¶ Jespern / django-piston / wiki / Home – Bitbucket. Get the latest version (0.2.3) here. NEW: Discussion group is hosted on Google Groups. A mini-framework for Django for creating RESTful APIs. Piston is a relatively small Django application that lets you create application programming interfaces (API) for your sites. It has several unique features: Ties into Django's internal mechanisms. NB: OAuth ships with piston for now, but you are not required to use it. Documentation But, examples speak louder than documentation: Fully functional example urls.py: And as for handlers.py: And that's all there's to it. Getting Help Piston is well documented and has an ever-growing FAQ.

Go read the Documentation. Fíam » Building a website API with Django. Part 1: API functions. WAPI and django-oauthsp are reaching the point when they are starting to become useful, so I decided it was time to write some articles explaining how they work and how you can use them in your sites. I'm currently using both of them in production at byNotes and I haven't run into any problems for now, but YMMV. This article talks about the principles behind WAPI and walks you trough the creation of a simple API function. Next articles in this series will explain more advanced concepts like custom serializations, user authentication against django.contrib.auth or using OAuth. Design Let's start by talking about the design ideas behind WAPI. My main motivation when I started writing it was abstracting most of the details involved in publishing a web API, since almost 100% of sites have the same requirements: ReSTful resources (sometimes SOAP or XML-RPC), serialization in different formats and user authentication.

WAPI only requires you to write a class. The code Let's move to the code. Youtubize template tag. YouTube Template Filter. oEmbed. HowToUseIt - django-oembed - Project Hosting on Google Code. Of course, first you must add it to your INSTALLED_APPS: INSTALLED_APPS = ( .... 'oembed',) Then in your template, include the oembed tags {% load oembed_tags %} Then, surround something with the oembed tag. Will result in: There is this great video at <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="320" height="222" id="viddlerplayer-e5cb3aac"><param name="movie" value=" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><embed src=" width="320" height="222" type="application/x-shockwave-flash" allowScriptAccess="always" allowFullScreen="true" name="viddlerplayer-e5cb3aac" ></embed></object> There is an optional width and height parameter, that can be invoked thusly: {% oembed 320x240 %}...{% endoembed %}

Djangoappengine - All Buttons Pressed. Deprecation notice: This project has been dead for quite some time. Djangoappengine contains all App Engine backends for Django-nonrel, e.g. the database and email backends. In addition we provide a testapp which contains minimal settings for running Django-nonrel on App Engine. Use it as a starting point if you want to use App Engine as your database for Django-nonrel. We've also published some details in the Django on App Engine blog post. Installation Make sure you've installed the App Engine SDK.

Clone the following (on those pages you can also download a zip file): If you downloaded zip files then now's the time to unzip everything. Copy the following folders into your project (e.g., django-testapp): django-nonrel/django =><project>/django djangotoolbox/djangotoolbox =><project>/djangotoolbox django-autoload/autoload =><project>/autoload django-dbindexer/dbindexer =><project>/dbindexer djangoappengine =><project>/djangoappengine That's it. Management commands Field types QuerySet methods.