This code generates a CSV file for a model. The URL is http://example.com/spreadsheets/app_label/model_name/ (replace spreadsheets for admin, from the URL for the model's admin page.)
This code gives you the ability to authenticate a user by their email address instead of the username. I've also added the ability to authenticate via LDAP.
Some code used from this [snippet](http://www.djangosnippets.org/snippets/74/)
This code works with Django-registration app found here: http://code.google.com/p/django-registration/
If you plan to use this django-registrtion code in your website to allow user registration but do not run your own email server,this snippet can be handy.
It uses gmail server to send out email.
You have to install libgmail module first.
Add two lines to your `settings.py`
GMAIL_USERNAME = '[email protected]'
GMAIL_PASSWORD = 'your_password'
Change models.py - create_inactive_user(...) as given above
template tag for producing tag clouds for a given model, using django-tagging application:
http://code.google.com/p/django-tagging/
Sample: http://skam.webfactional.com/tags/
Usage:
{% tags_cloud_for_model articles.Article as object_list %}
{% tags_cloud_for_model articles.Article as object_list step 6 %}
This is a copy paste job of mediawiki's syntax parser built in Python. You'll probably have to edit it to fit your needs
MediaWiki-style markup
parse(text) -- returns safe-html from wiki markup
code based off of mediawiki
The newforms fields are more capable than the django models fields. In this snippet, we subclass models.IntegerField, and add min_value and max_value.
e.g.
age = MMIntegerField('How old are you?', min_value=13, max_value=120)
I use these helper methods in my unit tests. They turn many simple getting-and-posting tests into one-liners. Definitely a work in progress, and I can't be the only person who has done this sort of thing -- comments are more than welcome.
Does a digg url effect to a string, can be useful for using an item's title in the url,
from this:
.hi's., is (a) $ [test], will it "work"/ \
to this:
his_is_a_test_will_it_work
I understand this isn't a very well made script, I am not very good at string manipulation. But I would be happy if someone would recode it in a faster, more managable way. I recomend saving the rendering.
Basically a clone of the default "wrap" filter. I use it to generate plaintext e-mail that has to be broken at 75 characters.
{% wordwrap 80 %}
Some text here, including other template tags, includes, etc.
{% endwordwrap %}
I prefer this over the {% filter wordwrap:80 %} as my template (e-mail) writers keep screwing it up.
I'm finding this much more efficient (from a coding perspective) than using the `render_to_response` shortcut.
It looks complex, but it's simple to use: just look at the example in the docstring.
Call this script `renderer.py` and chuck it in your project root.
Add a value to the context (inside of this block) for easy access.
Provides a way to stay DRYer in your templates.
**NOTE:** This tag is now in Django core, so if you have Django >0.96 (or SVN) then you do NOT need this.
Simple anti-spam field which will cause the form to raise a `ValidationError` if the value in this field changes. Displays as a CSS hidden `<input type="text" />` field.
If you specify a `class` in the `attrs` of the widget, the default `style="display:none;"` won't be rendered with the widget so that you can use a predefined CSS style to do your hiding instead. You can also cause the widget to be wrapped in an html comment to ensure it is not visible to the end user:
class EmailForm(Form):
email = EmailField()
website = HoneypotField(widget=HoneypotWidget(
attrs={'class':'fish'}, html_comment=True))