Archive for the 'Django' Category
Pinax Developer Quickstart
Published Sun Mar 2009 inAt PyCon I helped a group of people get a Pinax development environment set up. Many People were not yet familiar with the whole virtualenv and pip workflow, so I thought I would put up the steps I use to get Pinax up.
A simple Django life stream
Published Thu Jul 2008 inAfter reading Ryan Bergs' "The basics of creating a tumblelog with Django" (part1) and (part2), I realized that I wanted a similar tumblog/life stream but I didn't want to have to go through all the work of saving those objects to the database. After all, isn't all that data already stored in their respective systems. And since I am using FriendFeed, which is again duplicating all that data, I don't want to be duplicating it yet another time.
That's when the light bulb went off. Using the FriendFeed API and a bit of caching I can pull in my lifestream from FriendFeed using only a custom tag. So I came up with what I call lifefeed Just add "lifefeed" to your installed apps and you can now do this from any template
{% load lifefeed %}{% load cache %}
{% cache 900 friendfeed %}
{% lifefeed "YOUR FRIEND FEED USERNAME" %}
{% endcache %}
- Consolidate duplicate twitter/pownce/brightkite posts
- Display FriendFeed comments
Intense Debate Import Hack
Published Thu Jun 2008 in
Recently I wanted to try out the Intense Debate commenting system on this blog. I didn't want to lose all the comments that I had already and Intense Debate only supports importing comments from Blogger, etc but not custom blog software. Since I wrote this blog using the Django framework using django.contrib.comments I needed to come up with my own solution.
It only took one Tamper Data request to see how an anonymous comment was posted into the Intense Debate system. A few minutes later I had a script to import my old comments into Intense Debate.
import intenseDebate
intenseDebate.postComment(blogpostid="", acctid="", anonName="", anonEmail="", \
anonURL="", comment="")
- blogpostid is the unique Intense Debate postId. You can find this easily on any Intense Debate powered page using the firebug dom tab. The key to look for is "IDCommentScript".
- acctid is your Intense Debate accountId. This can also be found using the firebug dom tab. The key to look for is "IDWUserWidget.acctid"
- anonName is the name of the commenter
- anonEmail is the commenters email address
- anonURL is the commenters web address
- comment is the text of the comment
This method of importing comments does have it's problems.
- Manual process to get the blogpostid.
- No way of getting the Date/Time into Intense Debate.
Footnote: I don't have a problem with Django comments, especially when paired with django-comment-utils, I just wanted to give Intense Debate a try.
Django in June
Published Thu Jun 2007 inThis is going to be one busy weekend. Friday after work I am going to Coors Field to watch the Rockies vs. the Devil Rays. I am driving straight from the game to DIA to catch the red eye into Logan where I will pick up my rental car and go directly to the Django in June un-conference.
I am really looking forward to this. It will be great to meet some of the great people in the Django community. I also hope to meet some people in Boston that might be interested in helping me populate boston.bardiver.com with some more great bars. To ensure that this happens I will also be bringing with me some BarDiver.com Schwag to give out. ;) Once the conference is done with I will be driving up to New Hampshire to play golf with my Dad on Fathers Day. This should be a lot of fun. This will be the 3rd time I have played this year. After that and a quick visit with my Grandmother, I will be driving back into Boston to catch my flight back to Denver. Sunday night I might actually get 8 hours of sleep before I have to be at work again on Monday morning.BarDiver.com Launches
Published Sat Nov 2006 in
Back in September I said that I was working on a surprise project. Well today I am happy to announce that BarDiver.com has officially launched. BarDiver.com is a community driven search site to help you find local bars that have the features and atmosphere you like.
Copper Conferencing Launches
Published Thu Sep 2006 in
I am proud to release yet another Django powered web site. Copper Conferencing went live last night. (twentystar) and I turned this site out in record time.
I am going to The Future of Web Apps
Published Mon Jul 2006 in
I am going to The Future of Web Apps conference this September and I was wondering if any other Django peeps were going to be there.
django.contrib.auth has changed
Published Wed Jun 2006 in
Error was: cannot import name SESSION_KEY.
A quick tip to anyone who got this error after a recent django/trunk update. You no longer need to from django.contrib.auth.models import SESSION_KEY and there are some new django.contrib.auth methods like "login()" and "authenticate()". The Authentication docs have been updated to reflect this, but I found it easier to just read the changes. It looks like there was also a lot of work done on multiple authentication backends.
Hopefully this will help anyone who's site broke after the latest svn update.
Impact Sports site launches
Published Mon Feb 2006 inThis post is a bit late but I am proud to announce that the Impact Sports Performance website was launched last week.
Impact Sports was a collaboration between (twentystar) and myself. This site completely powered by the Django web framework, unlike the last site we launched, Colorado Ridge, which was backed by Django but used php on the front end. For this project, Django was a complete joy to use. The form processing in Django alone saved me days of work. We even threw in a bit of AJAX (form submiting on the home page) and Scriptaculous (on the facilities page). I can't wait to start on our next project. :)Apology for the community spam
Published Tue Feb 2006 inI sincerely apologize for the Django Community spam. I recently converted Socialist Software to be Django powered and there were some problems with Dreamhost. All seems to be fixed now.
Again, please accept my apologies.Socialist Software now powered by Django
Published Wed Feb 2006 inDon't let the look and feel fool you. Socialist Software is now powered by Django. I modified the new Wordpress K2 theme to work as Django templates and what you see is the result. Some notable things:
- The comments on this site are powered by a modified django/contrib/comments app. The stock app did not support commenter's url's, so I copied the comments app out of django/contrib and into the local projects app dir to make the necessary modifications.
- I wanted to use the django/contrib/redirects app to handle redirects from the old Wordpress site. However since Wordpress uses the query string to pass page, rss feed and tag data Django never caught the 404 necessary to perform the redirect. Instead I had to use mod_rewrite to catch and redirect any links. (This is more of a Wordpress gripe than a Django problem)
- I think it took me longer to migrate the data from the Wordpress database into the Django one than to do anything else. And Django even made that super easy because I didn't have to write sql to insert in the the Django database. The Django database api took care of it all.
- xml rpc capability so I can use desktop blogging tools to make posts.
- a tag cloud
- Upcoming.org integration
- Technorati integration
Using Django with a small team
Published Mon Jan 2006 inUp until recently I have been working on Django based projects all by myself. In last few weeks I have been working with with a designer who does the templates and graphics while I handle the modeling, python and other admin stuff (svn, mysql).
At first things were a little tricky because of our different environments and our constantly having to change the settings.py and urls.py according to each individual machine. You can imagine that this didn't work well with svn because changing the DATABASE_USER param was not really a change that needed to be commited, yet a change to the INSTALLED_APPS does need to be commited. Because the urls and settings files are just python files I can create individual files for each machine that imports all the settings from the 'global' file. For example if Tom has his database names 'coolProject' and Harry has his database set as Cool_Project then we create 2 new files: settingsTom.pyfrom settings import *
DATABASE_NAME = 'coolProject'
DATABASE_USER = 'Tom'
DATABASE_PASSWORD = 'password'
DATABASE_HOST = ''
DATABASE_PORT = ''
ROOT_URLCONF = 'myproject.urlsTom'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates".
"/Users/tom/python/myproject/templates",
)
MEDIA_ROOT = '/Users/tom/python/myproject/site_media/'
MEDIA_URL = 'http://127.0.0.1:8000/site_media/'
from settings import *
DATABASE_NAME = 'cool_project'
DATABASE_USER = 'Harry'
DATABASE_PASSWORD = 'password'
DATABASE_HOST = ''
DATABASE_PORT = ''
ROOT_URLCONF = 'myproject.urlsHarry'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates".
"/Users/harry/workspace/myproject/templates",
)
MEDIA_ROOT = '/Users/harry/python/myproject/site_media/'
MEDIA_URL = 'http://192.168.0.1:8000/site_media/'
from django.conf.urls.defaults import *
from impactsports.urls import *
oldpatterns = urlpatterns
urlpatterns = patterns('',
(r'^impact_media/(?P.*)$', 'django.views.static.serve',
{'document_root': '/home/tom/python/myproject/site_media', 'show_indexes': True}),
)
for pattern in oldpatterns:
urlpatterns.append(pattern)Django mentioned in OnJava.com article about Rails
Published Thu Nov 2005 inDjango was recently mentioned in an article at OnJava.com. It is great to see that Django is on the radar of some people in the industry, but it still does not seem to garnish the same amount of attention as Ruby on Rails. I sometimes wonder why this is, and I have come up with the following.
- Django's lack of a release version. Although this is not true anymore as Django has released 0.9
- Ruby on Rails was first on the scene. Event though Django was being developed at the same time as Ruby on Rails, it was not made public until a while after RoR was already gaining popularity.
- Django's lack of Ajax. RoR is almost synonymous with Ajax, which brings with it a lot of flash and hype and Web 2.0 buzzwords. Don't get me wrong. I am in favor of Ajax but Django lacks the same one to one relationship that RoR and Ajax has. Ajax support in Django is coming but it is still vague as to what it will be.
Django server side file selector
Published Wed Sep 2005 inNote: This is no longer valid. You can now use the meta.FilePathField that is built into Django like this
fieldName = meta.FilePathField(path='/path/to/files', match='re_string', recursive=True)
videoUrl = meta.ServerFileField('/home/user/video')
from django.core import meta
import os
videoDir = '/home/jay/video'
files = os.listdir(videoDir)
theList = []
for f in files:
if os.path.isfile(os.path.join(videoDir,f)):
theList.append(tuple([os.path.join(videoDir,f), f]))
videoChoices = tuple(theList)
class Message(meta.Model):
def __repr__(self):
return self.name
title = meta.CharField(maxlength=200)
video = meta.CharField(maxlength=200, help_text='Select the video', choices=videoChoices ,blank=True)
...
Django and Xinha
Published Fri Jul 2005 inAfter I posted about Django and TinyMce someone on IRC mentioned Xinha. I had not heard of or used Xinha before, so I thought I would give it a shot. Xinha has some really nice features that are not found in TinyMce, however I was a little bit disappointed at the extra configuration that Xinha required. TinyMce also just seemed a bit more polished.
Note that in order to get this to work I had to specify to Xinha the id's of the textarea's that I wanted to be wysiwyg editors. TinyMce was much more flexible in that it can convert every textarea on the page to a wysiwyg editro_editor_url = "/media/js/xinha/"; _editor_lang = "en";
xinha_editors = null;
xinha_init = null;
xinha_config = null;
xinha_plugins = null;
// This contains the names of textareas we will make into Xinha editors
xinha_init = xinha_init ? xinha_init : function()
{
xinha_plugins = xinha_plugins ? xinha_plugins :
[
'CharacterMap',
'ContextMenu',
'FullScreen',
'ListType',
'SpellChecker',
'Stylist',
'SuperClean',
'TableOperations'
];
// THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING :)
if(!HTMLArea.loadPlugins(xinha_plugins, xinha_init)) return;
xinha_editors = xinha_editors ? xinha_editors :
[
'id_description'
];
xinha_config = xinha_config ? xinha_config() : new HTMLArea.Config();
xinha_editors = HTMLArea.makeEditors(xinha_editors, xinha_config, xinha_plugins);
HTMLArea.startEditors(xinha_editors);
}
window.onload = xinha_init;
js = ('/media/js/xinha/init.js','/media/js/xinha/htmlarea.js','/media/js/xinha/description.js'),
meta.TextField('description'),
To change a field of a different id, modify the xinha_editors in the description.js and probably change that files name.
Django on Dreamhost
Published Wed Jul 2005 inAfter lots of googleing and some late night IRC chats I have Django installed and fully working on Dreamhost. The full how to is posted on the Dreamhost Wiki
Django and TinyMce
Published Wed Jul 2005 inI have been experimenting with the Django web framework for the past few days and it is great. It is easy to learn, and what it produces from the amount of code you input is staggaring.
One thing I did find lacking was lack of a wysisyg input field. meta.TextField works great but sometimes users need a little more. At first I wanted to create a meta.HtmlField but after some more thought you can achieve the same results with a meta.TextField and the admin.js param. Before I get into the code here is a screenshot of what we will achieve.
Here's how:
First you will need to download the TinyMce code from http://tinymce.moxiecode.com/download.php
Extract that to somewhere on your system. I used /Users/jay/Sites/javascript
Next you will need to link the TinyMce code into the Django media directory
ln -s /Users/jay/javascript/tinymce/jscripts/tiny_mce /Users/jay/python/django/trunk/django/conf/admin_media/js/tiny_mce
djang-admin.py runserver --settings=myproject.settings.admin
tinyMCE.init({
mode : "textareas",
theme : "default"
});fields = (
meta.CharField('title','title',maxlength=200),
meta.TextField('description','description'),
meta.CharField('location','location',maxlength=200)
)
admin = meta.Admin(
fields = (
(None, {'fields': ('title','description','location')}),
),
js = ('/media/js/tiny_mce/tiny_mce.js','/media/js/tiny_mce/textareas.js'),
)
Latest
Xbox Live Gamercard
-
@jennyjenjen :) what is your score / level ?RT @SEOHolicc: Biking directions on Google. This is awesome! http://googleblog.blogspot.com/2010/03/biking-directions-added-to-google-maps.htmlGràvès — Since that little thing over the vowels is called a "grave" I think thats how I should spell my last name now.@gmcerveny I'm up for #NSCoderNight Denver, but can't be there till after 6:30. Common Grounds?I just got the Mac Heist bundle. 7 fantastic Mac apps worth $260+ for only $20 and got 3 cool bonus apps free! http://bit.ly/heist-it
