title: Copy Model Object Id From a Model To Another Model In Django
body: <p>I want to copy data from a model to another model, I found an example <a href="https://stackoverflow.com/questions/10817422/copy-model-object-from-a-model-to-another-in-django">Copy Model Object From a Model To Another In Django</a> but I'm getting an error: </p>
  
  <blockquote>
    <p>AttributeError: 'BigAutoField' object has no attribute 'wid'.</p>
  </blockquote>
  
  <p>I want <code>wid</code> in the tobjects model to get the <code>Id</code> from <code>w_orders</code> model. This is my code:</p>
  
  <p><strong>models.py</strong></p>
  
  <pre><code>class w_orders(models.Model): 
      Id = models.BigAutoField(primary_key=True)
      datedefwo = models.DateField(default=datetime.now)
      datesched = models.DateField(blank=True, null=True)
      datefinished = models.DateField(blank=True, null=True)
      sign = models.BigIntegerField(blank=True, null=True)
      statusid = models.BigIntegerField(blank=True, null=True, default=1, choices=STATUS_CHOICES)
      typeid = models.BigIntegerField(blank=True, null=True, default=1, choices=TYPE_CHOICES)
      comments = models.CharField(max_length=254, blank=True, null=True)
      navid = models.BigIntegerField(blank=True, null=True)
      navkonsid = models.CharField(max_length=12, blank=True, null=True)
      navname = models.CharField(max_length=254, blank=True, null=True)
      navcustadr = models.CharField(max_length=254, blank=True, null=True)
      navdebt = models.FloatField(blank=True, null=True)
      navpropcode = models.CharField(max_length=254, blank=True, null=True)
      navdepcode = models.CharField(max_length=254, blank=True, null=True)
      navphoneno = models.CharField(max_length=254, blank=True, null=True)
      navreasoncomp = models.CharField(max_length=254, blank=True, null=True)
      nightshift = models.BooleanField(default=False)
      priority = models.BigIntegerField(blank=True, null=True)
      stid = models.BigIntegerField(blank=True, null=True)
      mapurl = models.CharField(max_length=254, blank=True, null=True)
  
      def __unicode__(self):
          return self.Id
  
      def save(self, *args, **kwargs):
          super(w_orders, self).save(*args, **kwargs)
          newob = tobjects()
          ...
          newob.save()
  
  
  
  class tobjects(models.Model): 
      oid = models.BigAutoField(primary_key=True)
      wid = models.ForeignKey(w_orders, on_delete=models.CASCADE)
      objtypegisid = models.BigIntegerField(blank=True, null=True, default=1)
      objgisid = models.BigIntegerField(blank=True, null=True, default=1)
      condgenid = models.BigIntegerField(blank=True, null=True, default=1)
      condriskid = models.BigIntegerField(blank=True, null=True, default=1)
      condratsid = models.BigIntegerField(blank=True, null=True, default=1)
      condmhcoverid = models.BigIntegerField(blank=True, null=True, default=1)
      condmhwallid = models.BigIntegerField(blank=True, null=True, default=1)
      condpipehydrsid = models.BigIntegerField(blank=True, null=True, default=1)
      condpipehydreid = models.BigIntegerField(blank=True, null=True, default=1)
      condpipedepvolsid = models.BigIntegerField(blank=True, null=True, default=1)
      condpipedepvoleid = models.BigIntegerField(blank=True, null=True, default=1)
      condpipedepconssid = models.BigIntegerField(blank=True, null=True, default=1)
      condpipedepconseid = models.BigIntegerField(blank=True, null=True, default=1)
      txt = models.CharField(max_length=254, blank=True, null=True)
  
      def __unicode__(self):
          return self.oid
  </code></pre>