title: Get django ChildInline parent model field values when adding new extra
body: <p>As an other way to reach my objective, described there: <a href="https://stackoverflow.com/questions/26952047/get-django-default-model-field-value-to-be-a-parent-attribute-value">Get django default model field value to be a parent attribute value</a>, that is : set a dynamic  default field value to my inline &quot;localwanted&quot; child field, which equals its parent equivalent &quot;remotewanted&quot;</p>
  <p>i have the following two models:</p>
  <pre><code>#models.py
  class Parent(models.Model):
      id           = UUIDField(primary_key=True)
      remotewanted = models.CharField(max_length=100)
  
  
  class Child(models.Model):
      parent      = models.ForeignKey(Parent)
      localwanted = models.CharField(max_length=100)
      def parent_remotewanted(self):
          return self.parent.remotewanted
  </code></pre>
  <p>If i want localwanted to be &quot;AAA&quot; by default:</p>
  <pre><code>#admin.py
  class ChildForm(forms.ModelForm):
      class Meta:
          model   = Child
          exclude = []
      def __init__(self, *args, **kwargs):
          super(ChildForm, self).__init__(*args, **kwargs)
          self.initial['localwanted']   = &quot;AAA&quot;        
  
  class ChildInline(admin.TabularInline):
      model = Child
      extra = 1
      form  = ChildForm
  
  class ParentAdmin(admin.ModelAdmin):
      exclude = []
      inlines = [ChildInline]
      #list_display, etc
  admin.site.register(Parent,ParentAdmin)
  </code></pre>
  <p>And it works, with extra fields (only one here) displaying : &quot;AAA&quot;</p>
  <h1>BUT</h1>
  <p>If want this default value to be dynamic (that is to be parent-variable), and replace &quot;AAA&quot; by self.instance.parent_remotewanted, as follows (in the ChildForm class):</p>
  <pre><code>    ...
      self.initial['localwanted']   = self.instance.parent_remotewanted.__self__
      ...
  </code></pre>
  <p>It displays nothing.</p>
  <h1>Then</h1>
  <p>Trying to deal directly with Parent.objects, my second attempt <em>ceteris paribus</em>:</p>
  <pre><code>#models.py
  class Child(models.Model):
      parent      = models.ForeignKey(Parent)
      localwanted = models.CharField(max_length=100)
      def parent_identity(self): #&lt;----------------
          return self.parent_id  #&lt;----------------
  
  #admin.py
  class ChildForm(forms.ModelForm):
      class Meta:
          model   = Child
          exclude = []
      def __init__(self, *args, **kwargs):
          super(ChildForm, self).__init__(*args, **kwargs)
          self.initial['localwanted']   = self.instance.parent_identity  #&lt;----------------
  </code></pre>
  <p>My inline field displays the Parent id field correctly. Being a newbie, it's magic for me, because &quot;self.instance.parent_identity&quot; is initially not a string object.</p>
  <pre><code>&gt;&gt;print self.instance.parent_identity
  &lt;bound method Child.parent_identity of &lt;Child: &gt;&gt; #&lt;--what print function gives
  </code></pre>
  <p>Anyway, i believed that i could play with it, but impossible to reach its string representation so as to do something like:</p>
  <pre><code>obj = Parent.objects.get(id=self.instance.parent_identity)
  # or
  obj = Parent.objects.get(id=self.instance.parent_identity.__self__)
  </code></pre>
  <p>Both displays &quot;matching query does not exist&quot; with DEBUG = TEMPLATE_DEBUG = True.
  I begin to realize what the ChildForm <strong>init</strong> function exactly does. And it seems to deal with structures to fulfil more than with effective objects.</p>
  <h1>Questions</h1>
  <p>Is there something to do from here ?
  Is my approach a dead end ?</p>