Hi, I'm Daniel Greenfeld, and welcome to my blog. I write about Python, Django, and much more.

My experiences with Django and Python 3

Thursday, July 11, 2013 (permalink)

The following are my notes, observations, and resources on the subject of working with Python 3 (with or without Django).

Recently I've become involved in a couple of Django efforts that used Python 3.3. The quick summary of what I learned is pretty much what I expected: Out ...

Read more ...

EuroPython Intro to Django Workshop

Monday, July 01, 2013 (permalink)

We (myself and Audrey Roy) have been asked to fill in a tutorial session at EuroPython 2013 on the afternoon July 3rd! Therefore, it is my honor to announce our EuroPython Intro to Django Workshop! (see the bottom of this article for registration instructions)

Workshop Description

Bring your laptops and ...

Read more ...

Core Concepts of Django ModelForms

Thursday, June 13, 2013 (permalink)

In my opinion, the concepts behind Django's model forms can be listed in just six (6) bullets. The bullets I've marked in bold at the top are the topic of this blog post, while the two of these that were covered in a previous blog post on Django ...

Read more ...

The Easy Form Views Pattern Controversy

Friday, May 10, 2013 (permalink)

In the summer of 2010 Frank Wiles of Revsys exposed me to what I later called the "Easy Form Views" pattern when creating Django form function views. I used this technique in a variety of places, including Django Packages and the documentation for django-uni-form (which is rebooted as django-crispy-forms). At ...

Read more ...

Filepicker.io and South

Tuesday, April 23, 2013 (permalink)

I've heard good things about filepicker.io, which is a service that makes file uploading a much better experience. Unfortunately, the Django package for filepicker.io doesn't work with South. When I try to create a migration using the filepicker.io field using code like the following...

# products ...
Read more ...

Core Concepts of Django Forms

Friday, March 29, 2013 (permalink)

In my opinion, the concepts behind Django's non-model forms can be listed in just three (3) bullets:

  • Forms render HTML.
  • Forms are "just" Python constructs.
  • Forms validate dictionaries (Python's Key/Value structure).

Let's dig in!

Forms render HTML.

If I construct a Django form:

# myapp/forms.py ...
Read more ...

Overloading Django Form Fields

Wednesday, March 27, 2013 (permalink)

One of the patterns we get positive feedback for mentioning in our book is overloading form fields.

The problem this pattern handles is the use case of when we have a model with a field(s) that allows for blank values, how do we force users to enter values?

For ...

Read more ...

Developer Time

Tuesday, December 04, 2012 (permalink)

This blog post got started with a tweet.

That tweet got retweeted a lot by developers. And system administrators. And database administrators. And any creative type.

As of December 7th, 2012, it had been retweeted over 500 times, a personal best. Obviously I struck a chord that resonated with a ...

Read more ...

Stay with the Django CBV defaults!

Tuesday, November 27, 2012 (permalink)

One virtue of Django Class Based Views (CBVs) is that they come with pretty good default settings. The virtue of this is you can really pare your code down in size and complexity.

For example, here is an implementation of CBVs based on a straight-forward Django model , stuffage.models.Stuff ...

Read more ...

Case Study: URL Design for petcheatsheets.com

Wednesday, November 21, 2012 (permalink)

Backstory: On Saturday, November 17, 2012 Audrey Roy and I decided to participate in the Petcentric hackathon, a Los Angeles area Pet-themed product/coding contest held at Amplify. We arrived a bit late, but armed with Audrey's idea of creating a pet based reference sheet for owners, pet sitters ...

Read more ...

Django GetOrCreateView

Tuesday, October 16, 2012 (permalink)

Today I decided to use the Django class based view (CBV) CreateView, but I wanted to avoid duplications and submit to the view from the front page of a site. The reason was I needed a simple newsletter signup form. This is what I cooked up and should work for ...

Read more ...

Django Requirements 2012-08-15

Wednesday, August 15, 2012 (permalink)

A little over three months ago I blogged about my preferred requirements list. It's now nearly the eve of Django Dash, and I feel it's time to update the list. I'm going to bump the versions on some of the existing packages and add some new ones ...

Read more ...

Deadline for DjangoCon Financial Aid requests is tomorrow!

Thursday, August 02, 2012 (permalink)

For 2012, DjangoCon US has moved to Washington, DC, and everyone is invited! If you need financial support to get there, the Django Software Foundation and PyLadies have paired with a number of forward thinking sponsors to help get you there. All genders are eligible for assistance, so don't ...

Read more ...

Django Update View without slug in the url

Saturday, July 28, 2012 (permalink)

Today I wanted to use the Django Class Based View (CBV) UpdateView but without a slug identifier in the URL. For example, instead of /profiles/pydanny/ I would go to /my-crazy-profile/. Also, I needed to force authentication.

I've done this with Django functional views a few times times, but ...

Read more ...

Django Class Based View: email form with CAPTCHA

Wednesday, May 23, 2012 (permalink)

Yesterday I showed how to implement a simple email form for Django using Class Based Views. Today I'm going to extend yesterday's work to use the excellent RECAPTCHA service to help reduce spam content.

This version requires pip installing the following into your virtualenv.

  • pip install django-crispy-forms so ...
Read more ...

Simple Django email form using CBV

Tuesday, May 22, 2012 (permalink)

Here's a simple FormView Class Based Views for Django. Here is a sample of how to do one as a simple email form. There is no CAPTCHA in this example, that's the topic of a future blog post.

This version requires the following packages pip installed into your ...

Read more ...

10 reasons to go to DjangoCon Europe

Monday, May 14, 2012 (permalink)

You should go to DjangoCon Europe in lovely Zurich, Switzerland. Here are 10 reasons why:

1. Chocolate

So much of what we like about chocolate comes from Switzerland. For example, Milk Chocolate was invented in Switzerland.

2. Keynote speaker: Jacob Kaplan-Moss

Always a great speaker and fun to be around ...

Read more ...

Choosing an API framework for Django

Thursday, May 10, 2012 (permalink)

First off, out of the box, Django lets you construct API responses with a little work. All you need to do is something like this:

# Copied from https://docs.djangoproject.com/en/1.4/topics/class-based-views/#more-than-just-html
from django import http
from django.utils import simplejson as json

class JSONResponseMixin ...
Read more ...

Django Requirements for a project

Wednesday, May 09, 2012 (permalink)

Today I'm starting a new project. I'm working as fast as I can and hope to launch on Friday. What are my package dependencies?

Django==1.4

Unlike my last quick project which was Flask, this effort really falls into Django's sweet spot. I need sessions, forms ...

Read more ...

Join us at DjangoCon Europe!

Tuesday, April 10, 2012 (permalink)

This year in June, the European edition of DjangoCon is going to be held in lovely Zurich, Switzerland. It is my great fortune and delight to announce that Audrey and I will be attending. Hooray!

Needless to say, we're extremely excited. My trip to Europe in 2007 was an ...

Read more ...

django-uni-form end of life

Saturday, February 18, 2012 (permalink)

I started on django-uni-form in January 2009. In order to use Pinax on an internal social network for NASA HQ, we had to render all content, including forms, Section 508 compliant. Rather than rewrite the html for all 50+ forms that existed in the Pinax 0.5.x framework at ...

Read more ...