- Here are all articles tagged Django
Posted on June 8th, 2013 | 472 Comments
I recently updated all the components for my blog. Going to Django 1.5 caused an issue that I had never seen before so I wanted to share the quick way to fix:
SuspiciousOperation: Invalid HTTP_HOST header
If you see that error it is because your ALLOWED_HOSTS setting variable isn't set and you have debug set to False. For a site running on Heroku your ALLOWED_HOSTS should look something this:
ALLOWED_HOSTS = ["maxburstein.herokuapp.com", ".maxburstein.com"]
Having a . before my domain name ...
Posted on June 1st, 2013 | 263 Comments
If you head over to the comment section you'll notice that my comments section now supports Markdown. I also upgraded to Django 1.5 which deprecates the markup module. If you grab the Markdown module you can pretty much add support back for markdown in one line of code.
import markdown form.content = markdown.markdown(form.content, safe_mode='escape') form.save()
If you prefer to use a template filter rather than saving the markdown text you could do something like this:
Posted on May 11th, 2013 | 349 Comments
Early on when developing this blog my goal was to allow for a commenting system that didn't require login of my site or any other third party site to post. This has made me a huge target for spammers. In fact when my site first launched I didn't use recaptcha so I was getting thousands of comments per day and I didn't really have all that much content. However, a majority of these posts never saw the light of day ...
Posted on April 13th, 2013 | 231 Comments
While working on an application I ran in to an issue reading data from a request so I figured I'd share.
I'd say about 99% of the time when you're reading data from a Django request you're either using request.GET or request.POST. I ran into an issue where an app was sending JSON data through an AJAX request via POST. However, Django's request.POST wasn't picking it up which had me kind of confused. My ...
Posted on March 30th, 2013 | 149 Comments
Many websites find it useful to have a search box on their site to enable their users to find content easier. I just wanted to share a simple way that I was able to do it using the Django ORM.
The first step will be to get the user's query then split it into an array for each word.
query = " Django search " #Search query entered by user query = query.split() #Remove excess spaces and split the query into array items
The next ...
My name is Max Burstein and I am a graduate of the University of Central Florida and creator of Live Dota. I enjoy developing large, scalable web applications and I seek to change the world.