After longer than we expected, the shiny new print copies of Two Scoops of Django 1.11 are finally ready. We've shipped all pre-orders, and many of you who ordered it in advance should have the book in your hands. We're delighted by how well it's been ...
When we started the Two Scoops of Django project back in 2012, I never thought it would become a book series. Well, it's turned into just that, and so I'm pleased to announce the "Early Release" or "BETA" release of the Two Scoops of Django: Best Practices for ...
I'm pleased to announce the "Early Release" of the Two Scoops of Django: Best Practices for Django 1.8 PDF ebook.
Sometimes in the
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 ...
In my opinion, the concepts behind Django's non-model forms can be listed in just three (3) bullets:
Let's dig in!
If I construct a Django form:
# myapp/forms.py ...
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 ,
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 ...
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 ...
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 ...
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
pip install django-crispy-formsso ...
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 ...
Content Copyright © 2012-2018 Daniel Greenfeld. Proudly harnessed by Mountain, powered by Flask, and rendered by Frozen Flask, all of which take great advantage of Python.