Category Archives: django

Django on IIS ValueError at [url]: underlying buffer has been detached

I got a similar error message to this stackoverflow post while running Django on IIS (also forced to do it because of organisational constraints):

ValueError at [url]
underlying buffer has been detached

This error was getting triggered because I had committed a pdb.set_trace() without noticing. It’s a weird one to track down because the page will seem to load normally at first, and then navigating to a subpage will cause the error. Anyway I hope this post helps someone, because googling comes up with f-all helpful.

Chosen selects in the django admin

A frustrating hour wasted and I don’t have enough rep to contribute to this stackoverflow answer, so I’m posting here. To add the jquery chosen widget to the django admin panel (django 1.10, chosen 1.6.2), so that multi select widgets show up properly, you need to do the following: – Get your manytomany set up

class Threat(models.Model):
    name = models.CharField(max_length=300, unique=True)

    def __str__(self):

    class Meta:
        ordering = ['name']

class Species(models.Model): 
    threats = models.ManyToManyField(Threat, blank=True) – Register it in the admin site and add custom js and css

class SpeciesAdmin(admin.ModelAdmin):
    class Media:
        # Put your jquery in - automatically included by django but it appears below the chosen.jquery.min.js, adding it again just seems to shift it above
        js = ('//', 
        css = {'all': ('chosen/chosen.min.css','chosen_admin.css')}, SpeciesAdmin)

chosen_admin.js – Easy, just instantiate chosen as you want

$(document).ready(function() {
    options = {
      search_contains: true, // plus whatever else you want 

chosen_admin.css – This was the annoying bit to pinpoint and fix

.field-threats, .field-threats .related-widget-wrapper {
	overflow: visible !important;	
.chosen-container-multi .chosen-results {
	width: 100%;

Thanks to radtek and bradmontgomery.