Skip to content

Instantly share code, notes, and snippets.

@AstraLuma
Created December 2, 2016 18:56
Show Gist options
  • Select an option

  • Save AstraLuma/b0f64b0f6b5a0d5152eece0e0e776e84 to your computer and use it in GitHub Desktop.

Select an option

Save AstraLuma/b0f64b0f6b5a0d5152eece0e0e776e84 to your computer and use it in GitHub Desktop.
from django import forms
from localflavor.us.forms import USPSSelect
class NoDefaultSelect(forms.Select):
def render_options(self, selected_choices):
opts = super().render_options(selected_choices)
if selected_choices:
opts = "<option disabled selected value style='display:none;'></option>\n" + opts
return opts
class NoDefaultUSPSSelect(USPSSelect, NoDefaultSelect):
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment