template tag to get form field value
** Allows to get field value in the template. ** First load template tag. Then {% field_value form.field %}
- forms
- field
- value
** Allows to get field value in the template. ** First load template tag. Then {% field_value form.field %}
Want to filter by properties on FK fields? Want to display as filters only FK objects that matter to your model? See comments in the code.
Django's builtin `removetags` filter removes the supplied tags, but leaves the enclosed text alone. Sometimes you need the complete tag, including its content to go away. Example: <h1>Some headline</h1> <p>Some text</p> Applying `removetags:"h1"` to this html results in Some headline <p>Some text</p> while `killtags:"h1"` leaves <p>Some text</p>
Since django insists on throwing a DoesNotExist rather than just returning a None from the far side of a null OneToOneField, I wrote this to have a sane way of getting those fields out without having to try/except all over in my code.
Based on [JSONField](http://djangosnippets.org/snippets/377/) Fork me on [github](https://gist.github.com/667930)!
This small decorator will trace the execution of your code every time it enters or exits a decorated function (by thread) and will insert appropriate indent into the log file along with exception information.
Django tempalte tag that supports {% elif %} branches.
This is an addition to Django's cache_page decorator. I wanted to cache pages for anonymous users but not cache the same page for logged in users. There's middleware to do this at a site-wide level, and it also gives you the ability to partition anonymous users, but then you have to tell Django which pages not to cache with @never_cache.
A simple django-admin filter to replace standar RelatedFilterSpec with one with the "All"/"Null"/"Not null" options. It applies to all relational fields (ForeignKey, ManyToManyField). You can put the code in the `__init__.py` or wherever you want. The `_register_front` idea is copied on [this snippet](http://djangosnippets.org/snippets/1963/)
This very simple templatetag can take event objects from django-event-calendar and create the appropriate URLs to automatically allow users to add events from your website to Google calendar.
I'm on my own personal writing challenge (see 750words.com for inspiration). I needed a way to get a dynamic word count, so I threw this together. Tied into django-basic-blog easily.
Sometimes you may want to check how many queries a specific set of operations is taking. This TestCase decorator allows you to do that.
Usage described in this blog post: [Django: FileField with ContentType and File Size Validation](http://nemesisdesign.net/blog/coding/django-filefield-content-type-size-validation/) Snippet inspired by: [Validate by file content type and size](http://djangosnippets.org/snippets/1303/)
Simple decorator definition to authorize particular IPs access to a view function.
I wanted a way to allow flexible phone number validation while making sure the saved data was uniform. ex. With: RegexFormatField(r'^\(?(?P<area>\d{3})\)?[-\s.]?(?P<local>\d{3})[-\s.]?(?P<subscriber>\d{4})$', format='%(area)s %(local)s-%(subscriber)s') input: (444) 444-4444 444 444-4444 444-444-4444 444.444.4444 4444444444 output: 444 444-4444
3110 snippets posted so far.