Django snippets

Just in case you’re not subscribed to the Django mailing lists and/or aren’t at PyCon, today I launched a little side project I’ve been working on: djangosnippets.org, a site for Django users to share useful bits of code.

There are still a few things I’m working out (like feeds), but on the whole I’m pretty happy with it :)

Comments

Ryan
February 25, 2007
#

Thanks a million for doing this. I can already tell it’s going to be really, really useful.

Any chance you’re planning to turn on feeds so users can track snippet additions via RSS?

James Bennett
February 25, 2007
#

Yeah. Like I said, I’m still working on feeds. They will happen.

Ryan
February 25, 2007
#

Oh crap, I read right over that in the parentheses. I’m a chump.

Nicola Larosa
February 26, 2007
#

Didn’t look at the code yet, but does Jacob’s CheeseRater use django-registration too? ;-)

Speaking of which, why don’t you take a page from Simon (Willison) and add OpenID support to it? That way we won’t have to register to each and every site over and over again.

Robbin Bonthond
February 26, 2007
#

Thank you very much !

whiteinge
February 26, 2007
#

More thank-you spam: this really will be an amazingly useful resource. Thanks a ton for setting it up, and thanks for making it open source!

David Reynolds
February 26, 2007
#

If you click on a user to see their snippets, you get an error, but now you’ve just fixed it!

Simon Willison
February 26, 2007
#

Right, that’s it - I’m going to have to clean up my OpenID consumer code and release it. Both of these sites are absolutely perfect candidates for OpenID.

David Reynolds
February 26, 2007
#

Still getting errors from time to time…

File “/home/ubernostrum/pylib/cab/models.py”, line 137

original = models.ForeignKey(‘self’, null=True, blank=True,, editable=False,
Baczek
February 26, 2007
#

File “/home/ubernostrum/pylib/cab/models.py”, line 137

original = models.ForeignKey(‘self’, null=True, blank=True,, editable=False,

                                                           ^

SyntaxError: invalid syntax

just a nit ^^

Jeff Triplett
February 26, 2007
#

Very cool James. It would be nice to see why people scored some a 5 and others a 1, any plans to make the scoring public?

Jeff Triplett
February 26, 2007
#

After getting my login and I can now see it’s an up / down system. That makes more sense to me. Good job.

Rubic
February 26, 2007
#

First off: great job! Now for first impressions …

After the initial post, editing the snippet doesn’t permit the author to change the language category.

I used html tags to leave a comment correcting spelling on snippet #8. The comments previewed okay, but don’t render properly.

Do I notified by email if someone leaves comments on my snippet? If not, this would be useful so I can fix any shortcomings. Thanks again!

gkelly
February 26, 2007
#

I’m getting a ‘no cookies’ error message when trying to log in using Safari with my Preferences set to Accept Cookies From Sites I Navigate To. Is the cookie coming from a 3rd party site?

Ludvig Ericson
February 27, 2007
#

James, everybody’s spamming about nonworking code.

Can’t you make one stable version, then subversion the whole source and just develop it locally until it’s stable and release it again then? :-\

Also there are quite a few bugs when it comes to the commenting system. More on that in the Google Code project’s issue tracker.

James Bennett
February 28, 2007
#

Rubic: the comments apply Markdown, but escape the content before handing off to it, in order to prevent cross-site scripting attacks. I’ve updated the preview template to show this, and I’ll probably write a filter which uses Markdown’s “safe” mode to prevent any double-escaping bugs. The lack of language-changing functionality is something I’m working on, but there are tricky issues with making newforms correctly populate the data which I haven’t had time to figure out yet. Comment notification is a wishlist thing that I’ll try to add once Jacob does the comments-app rewrite; right now it involves hacking Django itself, and I don’t feel like doing that when the flexibility I need will show up soon anyway.

gkelly: that’s a Django bug and has been around forever. It’s fairly random and nobody really knows what causes it, including me :(

Ludvig: I’ve responded to every issue that’s been brought to my attention, fixed every reported bug and a couple of feature requests, manually activated a bunch of people whose spam filters ate their registration emails, hacked around some usability things where people weren’t reading the instructions, and the site is literally three days old at this point. The SVN repo has, in that time, gone from somewhere around revision 40 to revision 109. And that’s all been in my spare time while I was doing the PyCon Django sprint and fielding release-related questions on the mailing list. I hate to sound cranky and abrasive, but that’s how I feel after reading your comment; if you don’t like the site or the code, nobody’s forcing you to use either of them.

Alexander Solovyov
March 6, 2007
#

Just two words about sending activation links - address that you set in “From” header in this mails does not exists. So many systems will reject this mails (as my system does).

Maybe you can fix that? Thanks in advance.

Scott Benjamin
March 8, 2007
#

I love it! Well done! Thanks James!

Though I find myself visiting the site everyday just to see the creative people that use django.

monolar
March 8, 2007
#

It would be great if the main starting list of snippets right on the frontpage would list the date or age of a snippet. It is visible on a snippet’s page so the data is there i think.

In fact on the frontpage the list starts with “Latest snippets added” and the list on http://www.djangosnippets.org/snippets/ does show the age. I personally would prefer the date and not the age.

Rating could be more highlighted.

The main list could also show the tags for a snippet. If the main list gets to cluttered this way a filter would be nice like show/hide Tags in lists, same with dates/ages…

What also would be nice is to be able to see how many recommendations a snippet collected.

James Bennett
March 8, 2007
#

In fact on the frontpage the list starts with “Latest snippets added” and the list on http://www.djangosnippets.org/snippets/ does show the age. I personally would prefer the date and not the age.

I’ve added the age on the main page as well. I kind of like the “how long ago” bit, since the detail pages already have the date formatted out in full.

The main list could also show the tags for a snippet. If the main list gets to cluttered this way a filter would be nice like show/hide Tags in lists, same with dates/ages…

Ehh… not so sure about that. The list pages are already pretty hefty on DB queries as they are, adding tags to that might not be a great idea.

What also would be nice is to be able to see how many recommendations a snippet collected.

Shows up on the detail page — that’s what the “score” bit is for. Not sure how to highlight that more clearly, other than making it bold :)

monolar
March 14, 2007
#

Good stuff. The age on the frontpage is very nice now.

I understand that listing tags is heavier on the db and clutters the view. Was just a thought…

Hmm… for some reason i didn’t see the Score bit and - yeah something like boldeing the recommendation part or maybe just two icons (up / down arrows or thumbs up / down symbos).

Thomas
March 14, 2007
#

This is really nice James!! (and very cool)

Would it be possible to get print css that puts the right column text at the bottom?

Also, how about an way to tell the paginator to list all (makes browsing easier when your not sure what your looking for)?

Can’t wait to hear all of the great inspiration you got from PyCon.

Thanks and take care.

Archatas
March 17, 2007
#

I am really happy with django snippets, but there are a couple of things that could be improved. 1. Tags could be shown in a tag cloud instead of normal listing. 2. Code in comments could be also highlighted or at least made of the same size as in the original post, because it’s pretty hard to read it. (3.) Search functionality would be also very helpful. (4.) Ratings could be shown in the lists of snippets as well.

Anyway, well done! It’s useful for all of us to have such a website.

Add a comment

You may use Markdown syntax in your comment, but raw HTML will be removed. By posting a comment here, you are agreeing to the terms of my comment policy.