Posted on May 7, 2008 by michaelangela
So you get the dreaded illegal mix of collations:
Pythoneer » Convert MySQL table to utf8
Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE)
What do you do? Not too bad fortunately. And if you’re working with Django, it’s a little bit easier. Launch the shell with python manage.py shell. Then in the shell do something like [...]
Filed under: cool, django, orm, python, snippet, tip, tool | No Comments »
Posted on April 25, 2008 by michaelangela
Doesn’t work:
ids=request.GET['ids[]‘]
Does work:
ids=request.GET.getlist(’ids[]‘
A typical Facebook friend invite sends the ids to be invited to your site as an array in ‘ids[]‘. Normally, you can pull values out with just request.GET['key']. But since the value of this particular key is an array and not just a string, you can’t (at least I wasn’t able to) just [...]
Filed under: dev, django, facebook, python, snippet, tip | No Comments »
Posted on April 22, 2008 by michaelangela
Django snippets: Referer-checking view decorators
Here are a couple of Django decorators for limiting access to a view based on the request’s HTTP_REFERER. Both raise a Django PermissionDenied exception if the referer test fails (or a referer simply isn’t provided).
The first, referer_matches_hostname, takes a hostname
(and port, if specified) and matches it against the referer’s. [...]
Filed under: deep-linking, dev, django, snippet, tip | No Comments »
Posted on April 22, 2008 by michaelangela
This might be useful but, buyer beware.
Django snippets: FieldLevelPermissionsAdmin
Have you ever needed to customize permissions, for example, allow only some fields for editing by some group of users, display some fields as read-only, and some to hide completely? FieldLevelPermissionsAdmin class does this for newforms-admin branch. Not tested well yet (>100 LOC!).
Filed under: dev, django, snippet | No Comments »
Posted on April 20, 2008 by michaelangela
I have not been able to find any info about 1and1 and http compression. It’s a shame as it really reduces bandwidth, increases transfer speed, etc. Fortunately this little script does a really nice job of it. It’s in PHP and it works a treat on 1and1. With a bit of rewrite magic I should [...]
Filed under: 1and1, gzip, modrewrite, php, snippet, tip, tool | No Comments »
Posted on April 18, 2008 by michaelangela
You can use this to set up a Facebook User within you Django app. This of course uses the middleware which is optional as described here.
Django snippets: Little middleware that create a facebook user
Install **PyFacebook** package.
After make all steps in tutorial above, put this code in your [...]
Filed under: dev, django, facebook, python, snippet, tip | No Comments »