- Author:
- ludvig.ericson
- Posted:
- February 27, 2007
- Language:
- Python
- Version:
- Pre .96
- Score:
- 0 (after 2 ratings)
Sometimes you have to serve null files. This quick hacky generic view lets you do that. The best example of that is robots.txt, I want my robots.txt to always be empty, at least for now.
The other example would be favicon.ico, but that's more often used to actually fill a purpose.
1 2 3 4 | nullFile = lambda r: HttpResponse()
# As you might've figured out, you use it in urls.py with:
# (r'myRegex', 'some.module.nullFile'),
|
More like this
- Template tag - list punctuation for a list of items by shapiromatron 11 months, 2 weeks ago
- JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 11 months, 3 weeks ago
- Serializer factory with Django Rest Framework by julio 1 year, 6 months ago
- Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 7 months ago
- Help text hyperlinks by sa2812 1 year, 7 months ago
Comments
Please login first before commenting.