Django Basic Apps

2 December 2007

I’ve been working on abstracting some Django applications from past projects so they can effortlessly be plugged into future projects. I hate writing the same blog application repeatedly, so this is an attempt to make life easier. I think this will be a fun, little suite of plug-n-play Django apps that everyone can benefit from.

Flickr photo

I’m calling this suite Basic Apps with the hopes they’ll live up to their name. They’re freely distributed under the New BSD License and hosted at Google Code. The goal is to use the month of December to get feedback from everyone and finalize the models, so beware of model changes.

The apps I’ll be introducing today include Basic Blog, Basic Places, Basic People, Basic Library, and Basic Profiles. Before you run off keep in mind these are basic apps. You won’t see anything earth shattering. The idea is to be simple and pluggable so when it comes time to add a blog or user profiles to your project you’ve got a jumping off point. That said, I’d like to provide a brief description of each app:

Basic Blog

This is a blog, nothing more nothing less. There is a Post model and a Category model. The dependancies include Django Comments and Django Tagging.

Basic Places

This app stores place information, (gasp!) The models include Place Type, City, Point, and Place. Django Tagging is the only dependancy.

Basic People

This app stores people information. (you’re kidding!) This app has nothing to do with Users. The people that go here are individuals that will never have access to your project. It is used heavily with the library app. The models include Person Type and Person.

Basic Library

This actually contains three apps: Music, Movies, and Books. All three are independent and should be placed independently in your PYTHONPATH. Movies has one model, Movie. Books has two, Book and Publisher. Music has Label, Band, Album, and Song. All three depend on the Basic People app. They all have a Genre model to boot!

Basic Profiles

This app extends the Django User app, providing added user information. The models include Profile, Mobile Service, Link, Service, and Service Type.

All of these apps need Python 2.4 or higher and Django 0.97 or higher. If you have any feature requests or notice any issues please create a ticket on the corresponding Google Code site using the Issues tab. I’ve also started a Django Basic Apps discussion over at Google Groups. Now, let’s build some shit.

Related tags: apps, code, django

Remarks

Xian http://mintchaos.com

Nice. I’ll have actual feedback once I play with them a bit next week.

James Bennett http://www.b-list.org/

Feature request: make it work with Python 2.3.

Austin W

I’ve been following these apps quietly for a little bit. Mostly just Boilerplate which I’ve learned a lot from. I look forward to working with all of them when I get a chance.

On a completely odd side note: Your website is number 3 when you google “New Hampshire Loft”…

Nathan Borror http://www.playgroundblues.com

@James - I thought about it but I just can’t pass up the beautiful decoration syntax in 2.4 :)

@Austin - I hope to have a post sometime next week on Boilerplate. Not much to say but I feel like it too needs a proper introduction. As far as the Googling — it’s funny how dangerous Google juice + <title> can be.

Jeff Croft http://jeffcroft.com/

Wow, these are astonishingly similar to some apps I’ve been putting together at Blue Flavor. Nicely done, sir. I’ll definitely take some bits and pieces. :)

One design suggestion: In my “people” app, which was designed for the exact same reason as yours, I did include an optional ForeignKey field to User. Even though the folks in the People app will generally not be users of your system, it is possible they could be, and if they are, I’d like to have that association. For example, if I used your apps for myse personal site, and had Pro CSS Techniques in my library (for which I am an author), I would be in both People and Users. I think those two pieces of data should be tied together. Just a suggestion. :)

Nathan Borror http://www.playgroundblues.com

@Jeff - It’s a tough call. I had it with a foreign key a while back in another project but noticed it was never used so I took it out in favor if the current iteration. Not really sure what the right answer is — I guess it depends on what you’re doing.

James McEwan http://onezom.com

Very cool, I’ve been planning to rebuild my site in django for the last week, these will no doubt help with the process.

Nathan Borror http://www.playgroundblues.com

I just added downloads for all the apps so as to make it easier for the non-subversion users. However, I highly recommend using a subversion checkout if you plant to contribute. It goes without saying the latest and greatest will be in trunk.

Carry on.

Adam Spooner http://adamjspooner.com/

These look great to me!

I know you are keeping them basic … but when you first went back to using Playground Blues I was inspired by your library app and wrote one myself. It does pretty much the same thing, but it gets information from Amazon based on the book title using an ajax call. It allows you to choose which book you meant (via a select), publishes author(s), user ratings, summary, etc. … it even creates a referrer link.

I’d love to add it to the app … though it might be a little bloated. =)

Nathan Borror http://www.playgroundblues.com

@Adam - Love your idea and I’d really like to incorporate that functionality into the Library App. Let me know if you need any assistance.

James McEwan http://onezom.com

Just had a chance to play with some of these. It might be cool to roll the full hcard spec into the Profiles app.

Pradeep Gowda http://www.btbytes.com

Good idea! and code to show for it too. I say fantastic :)

Some more ideas:

I’ll try to study your code and see whether there is anything I can do to add to the list.

Nathan Borror http://www.playgroundblues.com

@Pradeep - I’ve got a few others in the works but I’m trying not to duplicate anything that’s already available. I should have a Basic Photos and Basic Videos app ready in the near future :)

Jamie Pittock http://lifeofsmallbeer.co.uk/

These are great! I love this kind of stuff as a way of learning.

No' http://jehaisleprintemps.net

quick thing you definitely need to do NOW, before it’s too late: label your fields, change your strings, etc. using the i18n function, so anyone can translate your apps in any language and have these applications talking their language. The i18n mechanism is darn simple, and helps so much the non-english-speaking community.

Nathan Borror http://www.playgroundblues.com

@No’ - I’ll be working on that this evening. Thanks for letting me know there are other languages out there :) Us Americans tend to forget.

Empty http://blog.michaeltrier.com

Awesome stuff!! Thanks so much for putting this together. I’ve got a lot of these pieces in a largish app I’m building but some of it I don’t. I always enjoy peeking through someone else’s code.

Yong

Cool stuff. How about a basic patients record app? Have something basic that can scale to do real medical/dental and so on. That would be a killer category app.

Steve Erickson

These are awesome. Thanks for the work. How about an Events/Calendaring basic app too?

Paul

How about a “basic forum” app? Too big to be basic?

Thanks,

paul

Thomas Gautier

Thank you very much for your work. Those apps are great.

I’m just wondering if it wouldn’t be better to have them unicode ready for all of us who are not speaking english as a first language :)

Nathan Borror http://www.playgroundblues.com

Thanks for all the feedback! I’ve released updates for all the apps that take care of some bugs and introduce more template goodies. I’d recommend working with a trunk checkout because the latest bug fixes and goodies will be in there.

@Yong - A patients record app sounds pretty specialized and I’m not very knowledgeable in that area. If you are, you should totally tackle it. I’m sure other people have a need for such an app.

@Steve - Coming soon :)

@Paul - Check out django-forum or counterpoint. I have’t used either one but both look promising.

@Thomas - I’ve filed a ticket on making everything unicode friendly. Look for an update after the weekend.

Thanks again everyone!

Å ime

This is great.

I wonder what would be the most efficient workflow for modifying your basic apps and still keep up with the original changes and enhancements. Letâs say you checkout Basic Blog and decide to make some changes to templates and maybe tweak models a bit. What would be ideal to do? Create a branch, merge manually etc.?

Nathan Borror http://www.playgroundblues.com

@Sime - Good question. If you feel your changes should be merged into trunk, create a new issue in Google Code and attach your changes with a brief explanation. I’ll review them and merge.

My plan is to stabilize the models in the next few weeks. This will represent 1.0 and any further changes will not affect models.

Frits

First: thank you for releasing this.

I’m a complete Django beginner but would like to use your “Basic Blog” to practice. The problem is I can’t get it installed. Can you give a small explanation how to get this working?

(This is how I do it and fail: create new project, add your code as application, edit settings , but when I try to do a syncdb I fail miserbly..)

Dave Lowe http://davejlowe.com

These are great, Nathan! You rock!

BTW, I hadn’t seen urlpatterns structured like you have them before, and I love it. And since I haven’t had the time to get into tests yet, it’s very nice to see some real-world examples.

Michael

dependencies

Sime

Nathan,

I was thinking more in the line of the end user. Suppose I want to use your Basic App. I do a checkout. Next I want to edit all of the templates and maybe some other minor things. So, I drifted from your app and modified it, so I no longer can do a simple svn up to keep things fresh.

From this point of view, this isn’t completely pluggable. My view of a pluggable app is the one you checkout, optionally do some configuration and don’t touch it anymore, it just works and it is upgradable to the future versions without intervention (given that the API/models/etc are stable and backwards-compatible).

Which prompts me to find a workflow that would allow both. To easily get the latest versions of the Basic Apps while retaining the custom modifications I made. Because this apps are meant to be customized.

So any best practices for this? I was thinking to convert the repos to Git (no need for this but I just prefer both the Git and the decentralized model and the branching is easier) and then keep up with the upstream and later manually merge latest upstream code into any customized altered apps.

I don’t know, maybe I’m missing something obvious here but I don’t think there is some particular easy way to do this, basically everyone will just use what’s best for them.

Nathan Borror http://www.playgroundblues.com

@Frits - I’m going to put a step-by-step tutorial up soon but basically you need to setup a folder called ‘modules’ and add the full path to that folder to your PYTHONPATH variable. Then all you do is plug modules into your settings.py file.

@Dave - Aren’t they pretty :) I’m using a fairly new way of generating urls. James discusses it at length here.

@Sime - This isn’t just a problem with my apps, it’s a problem with anything you choose to manipulate. If you’re willing to make significant changes and diverge from the original intent then you, in a way, “void your warrantee.” An example is all the kids that hacked their iPhone and cried when the new update screwed them. If you want to make a lot of changes maybe you need to write your own version of the app. I’d love to hear your suggestions — they might belong in the main versions.

These apps are meant to get the ball rolling. They’re also learning tools to help people see how apps of this sort are put together using Django. I am by no means trying to build canonical Django apps :)

Sime

@Nathan: Yes, I am aware of that. I was just wondering what methods are people in general using.

Anyway, thanks for this, love all your work. I’m a fan of both you and Wilson Miner. You guys have some serious style, I am inspired by your layouts, CSS methodologies and Django related work.

Nathan Borror http://www.playgroundblues.com

@Sime - Aw shucks, thanks! I’m a fan of Wilson too :)

App altering is definitely a touchy subject. A good example is the Django Comments app. There is so much I want to change about it but I don’t want to screw up my Django install. I ended up just extracting it into my own app.

The only other alternative is relying on Subversion but that obviously won’t get you far. I’ll have to check out Git. Thanks.

(Sorry, my spam filter seems to be nabbing your comments. Apologies.)

Bruce

I really, really like this idea!

But I wonder if a few of the apps might be more generic. For example, People could be a more generic Agent, to encompass organizations as well?

Likewise, Book could be a more generic Document to encompass articles, etc. (and to go back to organizations, a Publisher would just be a related Organization).

I presume all of this would be more seamless when Django supports inheritance, but it might be good to get more generic now and then later add in subclasses?

For reference, I do work with scholarly bibliographic data.

Ken-ichi

Howdy Nathan. I’m a Django noob, and these apps have been insanely helpful to me, both for learning purposes and for actual use. Thanks!

One question I have is how best to install them. I’d like to install them in an ‘apps/’ directory at the root of my site instead of installing them somewhere in the PYTHONPATH, so different sites can use different checkouts of the Basics apps if they need to. However, this causes some scoping problems with lines like “from blog.managers import *” in blog/models.py.

Is there a good way around this that I’m missing? Again, still learning about Django, so I’m betting it’s something obvious…

Remarks are closed.

Remarks have been close for this post.