title: Django: combine two ForeignKeys into one field
body: <p>I need to implement the following:</p>
  
  <p>The user shall be presented with a form that will have a drop down choice menu consisting of property names. There are two types of properties: general properties, i.e. properties common for all users and custom properties, i.e. properties that each user has defined prior to that. The models would look something like that:</p>
  
  <pre><code>class GeneralPropertyName(models.Model):
      name = models.CharField(max_length=20)
  
  class CustomPropertyName(models.Model):
      user = models.ForeignKey(User)
      name = models.CharField(max_length=20)
  </code></pre>
  
  <p>The drop down menu should have all general properties and only those custom properties that pertain to the user.</p>
  
  <p>First question: how to define such a model? 
  I need to: 1. somehow unify both properties, 2. take only those items from CustomPropertyName that pertain to the user</p>
  
  <pre><code>class SpecData(models.Model):
      user = models.ForeignKey(User)
      selection_title = models.CharField(max_length=20)
      property = ForeignKey(GeneralPropertyName)  ??UNIFY??? ForeignKey(CustomPropertyName)
  </code></pre>
  
  <p>Second, is there anything special that needs to be done with ModelForm?</p>
  
  <pre><code>class SpecDataForm(ModelForm):
  
      class Meta:
          model = SpecData
  </code></pre>
  
  <p>And the 3rd question is what needs to be done in the view? I will need to use inline formsets since I will have a few dynamic forms like that.</p>
  
  <pre><code>def index(request):
  
      user = User.objects.get(username=request.user.username)
  
      specdataFormSet = inlineformset_factory(User, SpecData, form=SpecDataForm, extra=30)
  
      ...     
  
      specdata_formset = specdataFormSet(instance=user, prefix='specdata_set')
  
      ...
  </code></pre>
  
  <p>Thanks.</p>
  
  <p><strong>EDIT</strong>: Adjusted juliocesar's suggestion to include formsets. Somehow I am getting the following error message: Cannot resolve keyword 'property' into field. Choices are: id, name, selection_title, user</p>
  
  <pre><code>def index(request):
      user = User.objects.get(username=request.user.username) 
      user_specdata_form = UserSpecDataForm(user=user)
      SpecdataFormSet = inlineformset_factory(User, SpecData, form=user_specdata_form, extra=30)
  </code></pre>