save file on couchdb with couchdbkit
Save attachment on couchdb document
- upload
- file
- couchdb
- couchdbkit
Save attachment on couchdb document
Iterate through the supplied iterable and return the `attrname` eattribute of each element in the iterable. Useful with the `join` filter
This snippet is based on [#1051](http://djangosnippets.org/snippets/1051/). It adds filtering by existence of at least one related object. It is an example of how to simply subclass the FilterSpec class, in order to build a custom Filter. The comment in the code contains instructions on how to implement it in a real project.
Check email and save
view/admin.py ` def reactor(request): context = { 'email': read_mailbox() } return render_to_response(_lookup_template('dashboard'), context, context_instance=RequestContext(request)) ` **_Design all.js** ` function (doc) { if (doc.doc_type == 'MailArchive') { emit(doc._id, doc); } } ` **reduce.js** `_count`
This is the code we use on bandtastic.me to build a html that sends users to dineromail to pay with. This code builds a form thats ready to send multiple items.
I use this snippet to save images to my imagefields on django models. This uses the very awesome requests library, so install it first pip install requests You probably want to have this be done on a celery queu, if the image is big enough.
The problem with Django's default Radio button widget is that it puts the buttons in a vertical format and the documentation is somewhat silent on how to make them horizontal. If you are dealing with a long list of buttons then veritical is probably the way to go but if you are dealing with "YES/NO" situation or any other boolean choice then you will probably want them horizontal. Basically I just took the code and even the explanation from here: https://wikis.utexas.edu/display/~bm6432/Django-Modifying+RadioSelect+Widget+to+have+horizontal+buttons
This code is for set one register on admin if exist more than 1 register you can not delete it or add more. Only set mymodel
1) Install django-extensions (requires werkzeug) 2) Paste snippet into settings.py 3) manage.py runserver_plus Now you should be able to open files in textmate by clicking the file links in the werkzeug error pages. It will also take you to the correct line number and highlight files that are in your project directory in a different color.
Updating fields that allow for NULLs must take care about those NULLs. Use case: `Message.objects.filter(id=1).update(price=CF('price', 0) + 7)` `Message.objects.filter(id=1).update(status=CF('status') // 's')` Works for postgres. Supposedly works for mysql. Didn't test with other backends.
Useful when you want to keep only one instance of a model to be the default one. This is a decorative way of doing the same as in http://djangosnippets.org/snippets/1830/ Can this be made better as a class decorator (not having to declare explicitly the save method) ?
Register django views
If you use this pattern to track changes in the auth user table: from django.contrib.auth.models import User from reversion.helpers import patch_admin patch_admin(User) you can't see important changes, since a version is created for every login if a user. If you want to get rid of changes which only change unimportant stuff you can use this middleware. This middleware can be used for every model. Just use this pattern in your settings: REVERSION_CLEAN={ 'django.contrib.auth': {'User': ['last_login']}, }
Django-piston have two build-in authentication handlers, the HttpBasicAuthentication and OAuthAuthentication. This snippet give another choice which use the django auth. It can support ajax and normal request.
3110 snippets posted so far.