Week 10 Miscellany
Admin inlines for many-to-many fields
As of this week, in the development version of Django it's possible to use admin inlines for many-to-many fields.
If that would be useful for your project, you can switch
from Django==1.1.1 in your requirements.txt
to -e
svn+http://code.djangoproject.com/svn/django/trunk#egg=Django. This
tells pip to get Django straight from the Subversion
repository at code.djangoproject.com. If you do this,
you'll probably want to install, then freeze
your requirements.txt at the installed version
(use pip freeze) so you don't get surprised by unexpected
new changes when you deploy a new virtualenv.
Nice email regex - now don't use it!
Validating email addresses correctly is really hard - even if you
think you've got a very generous regex, chances are good that you're
prohibiting some valid email addresses (for instance, if you
used \w+ to match the part before the @, you're ruling
out quite a few characters that are actually valid in email addresses
(+, ., and some others).
Locking out users with valid email addresses is not a recipe for
happy users! So stick to Django's
built-in forms.EmailField for validating email addresses
and you'll be in better shape.
Feedback on this class
Remember that feedback app I've been demoing stuff on? I did actually intend to use it, and this week I finally got it into usable shape (well, if you don't consider the complete lack of design). It's at http://feedback.dj.goshen.edu.
Please take a couple minutes this week to fill that out and let me know your thoughts on how this class is going, what's been helpful, what could be done better, etc. Thanks!
Basic form review
ModelForms (feedback app)
Useful bits you may need for your project
Allowing users to input formatted text
django-markitup (use ==dev rather than the 0.3.0 release, to get the good stuff from django-markupfield included too. See the documentation).
Image uploads, showing image thumbnails
User registration
Possibilities:
- The old standby: register with an email/password, send confirmation/activation email. Use django-registration for this.
- Use OpenID (allows people to log in with their Google account, a Yahoo account, or any other OpenID provider). Several options here, but I haven't yet used any of them. django-socialauth, django-openid, django-authopenid...
- If you only want GC students logging in, you can authenticate
directly against GC's CAS (Central Authentication Service) server
(thanks Paul O!). To do this, use
the django-cas
reusable app, with a CAS login server
of
https://login.goshen.edu/cas/.
Comments
Use Django's built-in contrib.comments app.