utf8-friendly dumpdata management command for yaml (no escape symbols)
This is a YAML version of http://djangosnippets.org/snipptes/2397
- fixtures
- management
- dumpdata
This is a YAML version of http://djangosnippets.org/snipptes/2397
Provide additional context_data in case the submitted form is valid. This can be a message to confirm that the changes are saved.
Usage: `{%formfield form.description rows="3"%}`
Message Exception
Email Validation Snippet.
An improvement to the excellent snippet by guettli [http://djangosnippets.org/snippets/2691/](http://djangosnippets.org/snippets/2691/) Added support for cascading relations when using model inheritance.
A hack to add __in ability to links generated in the Django Admin Filter which will add and remove values instead of only allowing to filter a single value per field. Example ?age_group__in=under25%2C25-35
When work at site api for android client, I found use form to validate user input is too complex, so I write this. usage: @param('param_name', 'default_value', validate_func) def api_func(request): # access cleaned data. param_name = request.DATA['param_name'] JsonResponse is my class. replace with HttpResponse or whatever
[Understanding Python Decorators in 12 Easy Steps!] (http://simeonfranklin.com/blog/2012/jul/1/python-decorators-in-12-steps/)
I wanted to be able to share common code among a subset of views without copy-and-pasting the code or the same function into each view, so I decided to wrap a class around the views so that the common code (i.e. loading a model that each of the views would affect) can go in the __init__ of that class. I created the controller_view function above to allow the urls to access those class methods. It would be called something like this: url(r'^someview$', controller_view(SomeController, 'someview'), name='someview'), Where the SomeController inherits (or is structured like) the Controller class above and implements __init__ and someview as methods. I'm new to Django so it's entirely possible I've missed something that already does this or that makes this unnecessary. If so, let me know so that I can figure out how to do this right, otherwise, hopefully this is helpful to someone else out there.
qwe
Adds a CSV export action to any Django model admin that inherits it.
This snippet is an extension of [i18n base model for translatable content](http://djangosnippets.org/snippets/855/) so all the same usage applies. I have extended this module in several ways to make it more fully featured. * `I18NMixin` can be an additional (via multiple inheritance) or alternative superclass for your models juxtaposed with an `I18NModel`. * Adds a property `_` to access the appropriate I18NModel. `trans` aliases this (or rather vice versa) for template access. * In a call to `.filter` you can query on translated fields by wrapping those fields in a call to i18nQ. I like to import this as _ if I haven't already used that import. * A call to I18NFieldset will return an inline for use in the builtin admin app. I like to call this inline to the assignment to inlines. * If you need abstracted access to the I18N model from a model, I've added a property I18N referring to it. I've been using this with great convenience and stability.
[code] {% get_video_urls url as url_object %} or get object attribute: {% get_video_urls obj "url" as url_object %} {{ url_object }} original url {{ url_object.video_id }} original url or video_id {{ url_object.resource }} youtube, vimeo, None {{ url_object.iframe_url }} original url or iframe_url {{ url_object.js_api_url }} original url or js_api_url [/code]
Custom form widget for rendering an autocomplete (using jQuery UI's autocomplete widget) text input in a template. This arose from the need to have all fields asking for a state to use autocomplete, so I decided to make this.