Skip to content

Instantly share code, notes, and snippets.

@marufsiddiqui
Created June 11, 2013 06:37
Show Gist options
  • Select an option

  • Save marufsiddiqui/5754864 to your computer and use it in GitHub Desktop.

Select an option

Save marufsiddiqui/5754864 to your computer and use it in GitHub Desktop.
# Add a class to a form widget # Modify the default queryset of a foreign key fields
def __init__(self, website, *args, **kwargs):
self.website = website
super(PageForm, self).__init__(*args, **kwargs)
# Modify the default queryset of a foreign key fields
self.fields["page_layout"].queryset = Layout.objects.filter(website=website)
# Add a class to a form widget
self.fields['page_layout'].widget.attrs['class'] = 'nc-popup-select'
self.old_url = self.instance.url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment