Appendix D. Finding, Evaluating, and Using Django Applications

It’s fun to write applications in Django, but you don’t always want to make everything yourself. As the framework has grown in popularity, an ecosystem of open source Django-powered applications has sprung up around it. This is boosted by the fact that Django itself is open source; it leads by example, creating an ethic that says, when in doubt, release your application as open source.

Even better, most of these further follow Django’s example in using the unrestrictive BSD/MIT-style license. This can make adoption of those applications an easier sell inside organizations that are shy of the most common open source license, the GNU Public License or GPL. The GPL mandates if a product based on GPL-licensed code is used in an application that gets redistributed (as opposed to merely being offered as a service via the Web, for instance), the code of that application must be publicly released. The BSD/MIT style licenses certainly enable this, but don’t require it. No judgement is implied on the relative merits of the two approaches, but the fact that BSD/MIT-style licenses are more “business friendly” is well accepted, and so the license issue can affect your choices.

Whether it’s something simple such as user-registration features, something more complex such as a full-featured blog engine, or a full-on e-commerce solution for running your Web store, there is likely to be an open source Django application out there that does it. But how do you find it? How can you tell if it’s good? And how can you make using it (and keeping up with updates) as easy as possible?

Where to Look for Applications

Some developers run their own Web sites and/or their own project management systems, and thus you often find Django applications listed in their creator’s blog or personal Trac instance. However, many (if not most) developers congregate at centralized listing sites to achieve higher visibility, and we list some of the more popular such sites here.

  • The DjangoResources page on the Django project wiki: This is where many application authors let the world know about the availability of their application. The direct URL is http://code.djangoproject.com/wiki/DjangoResources.

  • Google Code: With its free hosting and clean interface, Google Code has become a popular spot for Django-powered projects. Searching for projects tagged “django” yields a nice long list.

  • Djangopluggables.com: Relatively new at the time of writing, djangopluggables.com is a nicely designed site that aggregates information on a wide variety of Django applications.

  • DjangoSites.org: This simple directory of Django-powered sites has a “sites with source” category that shows you only the listed sites whose authors have released the source code.

  • GitHub.com: A popular source-repository-and-social-networking site using the Git version control system, which hosts a few Django apps and is growing in popularity along with Git itself.

Just as the ecosystem of Django applications is constantly evolving, so are the best ways to find them. Check withdjango.com for an updated list of links and recommendations.

How to Evaluate Applications

Here are some questions you can ask of a prospective application or project that you’ve found.

  • Is it alive? When were the most recent feature updates or bug fixes? Not every project needs to be updated every week, but a project that last saw activity in a flurry of commits a year ago could have been abandoned. Anything developed against a pre-1.0 release of Django needs to be kept up to date, or it quickly becomes useless.

  • How’s the documentation? Is there documentation? Is it organized and readable? Is it relatively free of red-flag warnings such as “NOTE: This section is out of date!”? Does it seem to be actively maintained? (For example, is the documentation managed via source control and distributed as part of the project download?)

  • Who are the authors? Google the author name(s) to get a sense of how experienced they are and how their work is regarded in the community. If you come up with a lot of helpful replies on the project mailing list, for example, that’s good.

  • How’s the code? If you have some experience as a Python programmer, one of the best ways to get a quick feel for a project is to download its source code and just start reading. Are the source files organized? Are there docstrings that explain the intent and use of functions and methods? Is there a test suite, and does it pass?

  • Is there a community? Many Django projects that were started to fulfill a particular person’s or organization’s needs have grown to have user and development communities of their own. The more complex the application, the more likely that it has its own community of experienced people who can help you solve problems. Not every application needs a vibrant community to be considered viable, of course, but social infrastructure should be present in rough proportion to the complexity of the application.

How to Use Applications

Third-party Django applications, just like yours, are simply Python modules. To use them in a project, simply add a string containing the application’s path (in Python dot-delimited form) to your project’s settings.py in the INSTALLED_APPS setting.

Although you can put them anywhere you want, you essentially have three choices:

  • Embedding: If you only need the application for a single project, you can decide to simply add it inside your project directory alongside your other applications. In some ways this is the simplest approach. The downside comes when you decide you want to start using it in other projects on the same server.

  • Creating a “shared apps” directory: Another option is to create a directory for shared apps—you could call it shared_apps—and add this directory to your Python path. This keeps the third-party code in a single place, but makes it easy to import across projects. To add an application to a given project, you’d simply add its name (no dotted prefix needed) to that project’s INSTALLED_APPS setting.

  • Installing to your site-packages directory: You can also add Django applications to your system-wide Python library, usually found in a directory called site-packages. (Type import sys; sys.path at a Python prompt to find the exact path on your system, as well as the other directories on your Python path.)

If you are following an evolving project, you can work with a checkout from that project’s version control system rather than simply downloading archived files. In that case, you can simply check out the latest version of the code into your project, your shared apps directory, or your system’s site-packages, depending on which of the previous methods you are following. Just keep in mind that you need to use caution when upgrading any such external applications to make sure you don’t break your projects that depend on them.

Sharing Your Own Applications

Hopefully, as you continue progress as a Django application developer, you can find that some of your creations have the potential to be useful to other people. We encourage you to consider releasing these applications under an open source license and to allow other Django users to use them and improve them. Code hosting services such as Google Code, SourceForge, GitHub and others can make it easy for you to get your code out there (without creating a whole new Web site for you to administer). Be sure to tell us, too!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.89.173