I know that should be do the web server like Apache but sometimes is it nicer (even recommended) to set in some cases the headers in web app directly, to test the behaviour or to make really sure to get the right headers in the response if you don’t have anytime access to the server config’s or a lazy sys-admin.
(This is an imported feed item. You can read the original item at http://Azd325.github.io/blog/2012/03/21/django-setting-headers-in-your-response/)
I work currently on a rating feature, to rate some items and I want to do this in one view to handle the methods POST and GET.
POST should handle the submit request(rate count) of the item
GET should handle the template with the right item to see the current user/ global rate
What we need to rate?
I start to add the first version of the view and I was adding two URL’s one for GET and one for POST. And I what to handle the parameter over the named groups in Django.
What we can to be more explicit?
We can use
The next thing we have to two exact same URL’s the only difference is that the POST needs an extra parameter.
Can we make this parameter optional?
Yeah, we can do it again with
The end solution:
I have one URL for the cases of GET and POST and we create only the URL’s what I need for the rating feature
(This is an imported feed item. You can read the original item at http://Azd325.github.io/blog/2012/03/22/django-pre-validation-with-the-url-dispatcher/)
Classes are great but they are also overused. This talk will describe examples of class overuse taken from real world code and refactor the unnecessary classes, exceptions, and modules out of them.
(This is an imported feed item. You can read the original item at http://Azd325.github.io/blog/2012/03/23/pycon-2012-stop-writing-classes/)
One of my favorite question on Stackoverflow
How do I add an empty directory to a git repository
The solution is:
(This is an imported feed item. You can read the original item at http://Azd325.github.io/blog/2012/05/31/empthy-folder-in-git/)
Do make an optional Foreignkey in Django you have set
(This is an imported feed item. You can read the original item at http://Azd325.github.io/blog/2012/06/08/django-optional-foreignkey/)