Wednesday, April 26, 2017 (permalink)
Wednesday, April 29, 2015 (permalink)
I'm pleased to announce the "Early Release" of the Two Scoops of Django: Best Practices for Django 1.8 PDF ebook.Read more ...
Monday, September 15, 2014 (permalink)
Sometimes in the clean(), clean_FOO or save() methods of a Django form, you need to have additional form instance attributes available. A sample case for this is having user_id available. This is a simple example of how to do it in Class-Based Views.
Assuming this form:
from django import 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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
Tuesday, May 22, 2012 (permalink)