How to export and import data and auth information in Django?
<p>I'm working on a project which is already public so there are some <strong>Order</strong> objects and <strong>User</strong> objects in the database (couple of people has registrated and created some orders).</p>

<p>Now I'm changing some things in this project including <strong>Order</strong> model (added some fields like <code>created_time</code> etc.)</p>

<p>So my new database (sqlite3) has very similar schemas compared to old but it's not the same. </p>

<p>How can I add old users and <strong>Order</strong> objects into the new db? Is there some plugin or best practise? </p>

<p>There should be no problem with <strong>Users</strong> because their schema hasn't changed but I suppose that <code>app_users</code> table is not enough to copy.</p>

<pre><code>class Order(models.Model):
    customer = models.ForeignKey(User, related_name='orders', blank=True, null=True)
    first_name = models.CharField(max_length=40,verbose_name=u'Vorname')
    last_name = models.CharField(max_length=40,verbose_name=u'Nachnahme')
    dry_wood = models.PositiveIntegerField(blank=True, null=True, default=0,verbose_name=u'Trockenes Holz')
    wet_wood = models.PositiveIntegerField(blank=True, null=True, default=0,verbose_name=u'Halb trockenes Holz')
    briquette = models.PositiveIntegerField(blank=True, null=True, default=0,verbose_name=u'Brikettes')
    stelinka = models.PositiveIntegerField(blank=True, null=True, default=0,verbose_name=u'Klein Holz')
    street = models.CharField(max_length=200, verbose_name=u'StraÃe', null=True, blank=True)
    number = models.CharField(max_length=40, null=True, blank=True, verbose_name=u'Hausnummer')
    city = models.CharField(max_length=100, verbose_name=u'Stadt', null=True, blank=True)
    psc = models.CharField(max_length=40, null=True, blank=True, verbose_name=u'PLZ')
    telephone = models.CharField(max_length=50, null=True, blank=True, verbose_name=u"Telefon Nummer")
    telephone2 = models.CharField(max_length=50, null=True, blank=True, verbose_name=u'Telefon 2')

    email = models.EmailField(null=True, blank=True,verbose_name=u'Mail')
    time = models.TextField(null=True, blank=True, verbose_name=u'Kommentar')
    price = models.DecimalField(max_digits=20, decimal_places=2, blank=True, null=True)
    text_order = models.TextField(blank=True, null=True, verbose_name=u'Kommentar')
    confirmed = models.BooleanField(default=False, verbose_name=u'PotvrdenÃ¡ zÃ¡kaznÃ­kom')
    done = models.BooleanField(default=False, verbose_name=u'VybavenÃ¡')
    TYPE_CHOICES = (('wholesale', u'VeÄ¾koodber'),
                    ('retail', u'Maloodber'))
    type = models.CharField(max_length=40, choices=TYPE_CHOICES, default='retail')

    created = models.DateTimeField(auto_now_add=True, blank=True, null=True)

    LENGTH_OF_DRY_WOOD_CHOICES = (('1.0','1.0'),
                                  ('0.5', '0.5'),
                                  ('0.33', '0.33'),
                                  ('0.25', '0.25'))

    LENGTH_OF_WET_WOOD_CHOICES = (('1.0','1.0'),
                                  ('0.5', '0.5'),
                                  ('0.33', '0.33'),
                                  ('0.25', '0.25'))

    length_of_dry_wood = models.CharField(max_length=40, choices=LENGTH_OF_DRY_WOOD_CHOICES, default='0.5', null=True, blank=True,verbose_name=u'LÃ¤nge des Holzes (Trockenes Holz)')
    length_of_wet_wood = models.CharField(max_length=40, choices=LENGTH_OF_WET_WOOD_CHOICES, default='0.5', null=True, blank=True,verbose_name=u'LÃ¤nge des Holzes')

    backuped = models.BooleanField(default=False)
    class Meta:
        verbose_name = u'ObjednÃ¡vka'
        verbose_name_plural = u'ObjednÃ¡vky'

    def save(self, *args, **kwargs):
        if self.type == 'retail':
            self.price = Price.calculate_price(self.dry_wood, self.wet_wood, self.briquette, self.stelinka)['total']
        else:
            self.price = 0

        super(Order, self).save(*args, **kwargs)



    def __str__(self):

        return u'ObjednÃ¡vka {} | {} {} | {} â¬ {} {}'.format(self.id, self.first_name, self.last_name, self.price, u'| &gt;&gt;&gt;&gt;&gt;&gt;&gt; NEPOTVRDENÃ &lt;&lt;&lt;&lt;&lt;&lt;&lt;' if not self.confirmed else '',
                                                            u'| &gt;&gt; VYBAVENÃ &lt;&lt;' if self.done else '')

    def __unicode__(self):
        return self.__str__()
</code></pre>

<p>Fixtures can be used for this <a href="https://docs.djangoproject.com/en/dev/howto/initial-data/" rel="nofollow">https://docs.djangoproject.com/en/dev/howto/initial-data/</a>  </p>

<p>To dump the data on local machine </p>

<pre><code>./manage.py dumpdata mytable &gt; databasedump.json 
</code></pre>

<p>and import it on the remote :</p>

<pre><code>./manage.py loaddata databasedump.json
</code></pre>

python django sqlite