This module is comes from the original staticview.py from django. But when you using it, it can looks for static files in your app's subdirectory. So that you can put static files which concerned with your app in a subdirectory of the app. I should say it method only suit for developing, so if you want to deploy your application to apache, you should copy static folder to the real media folder. And if you keep the same structure of the directory, then it'll be very easy. And you can write a little script to automatically do that. But for now, I didn't have written one yet :P
How to use it in urls.py
--------------------------
Here's an example:
(r'^site_media/(.*)$', 'utils.staticview.serve', {'document_root': settings.SITE_MEDIA, 'app_media_folder':'media'}),
It seems just like the original one in django. But there is a new parameter "app_media_folder", it's used for subdirectory name of app. So your django project folder structure maybe seem like this:
/yourproject
/apps
/appone
/media
/css
/img
/js
/media
/css
/img
/js
A simple template filter for taking a list and humanizing it, converting:
`["foo", "bar"]` to `"foo and bar"`
`["foo", "bar", "baz"]` to `"foo, bar and baz"`
`["foo", "bar", "baz", "42"]` to `"foo, bar, baz and 42"`
- filter
- lists
- filters
- humanize
A very basic app centered around a template tag that takes an e-mail address and optional label and returns a link to an e-mail form. This way, you can easily throw e-mail addresses into your template that will automatically link to an e-mail form instead of displaying the e-mail address itself.
The model for this app is extremely simple, with only one field to store the e-mail address. When an e-mail is passed to the email_link template tag, the e-mail address is added to the database if it is not already there. This is stored in the database in order to keep the full e-mail address hidden from the viewer.
To use, simply create an app called 'email_links' (or you can change the name if you also change line 4 of email_extras.py to reflect the change). Then use the models.py and views.py provided. Add a templatetags directory under your app, and add email_extras.py and a blank __init__.py
In your urls.py, add the following to your urlpatterns (subsitute project_name for your own):
`(r'^email/(?P<email_id>[0-9]+)/$', 'project_name.email_links.views.email_form'),`
Create two templates: email_links/email_form.html and email_links/thanks.html (the examples here are extremely basic - make them however you want).
Finally, in a template where you want to provide a link to e-mail someone, first load email_extras:
`{% load email_extras %}`
Then do one of the following:
`{% email_link "[email protected]" %}`
`{% email_link "[email protected]" "E-mail someone" %}`
Both will create a link to the e-mail form. The first will use mask_email (from the snippet by jkocherhans) to create the link. The second will display the second argument "E-mail someone" in the link.
Also note that I've used the Sites add-on to generate the links, but you can easily change this to suit your needs.
I hope all of this makes sense. I'm a bit tired, but wanted to get this up before bed.