I don't know what changed, but updating my SVN in the last week
sometime has fixed the problem that I was having.

The dev trunk and I have a love-hate relationship :)


I would make a note to anybody reading this that if the 'add' view is
being used, you should kick off the code block with a "if 'instance'
in kwargs"

Working code:

  # used in a direct subclass of ModelAdmin
  class ContractForm(forms.ModelForm):
      def __init__(self, *args, **kwargs):
          forms.ModelForm.__init__(self, *args, **kwargs)
          if 'instance' in kwargs:
              contract = kwargs['instance']
              self.fields['locations'].queryset =
Location.objects.filter(company=contract.company)

  # used in a TabularInline of that same ModelAdmin's inlines
  class EventInlineForm(forms.ModelForm):
      def __init__(self, *args, **kwargs):
          forms.ModelForm.__init__(self, *args, **kwargs)
          if 'instance' in kwargs:
              contract = kwargs['instance']
              self.fields['location'].queryset =
Location.objects.filter(company=contract.company)

Thank you, God.  I've been pulling my hair out over this.

Tim
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to