Is it possible to migrate a web2py system to django while maintaining the same database?

0


Is it possible to migrate a web system in production made in web2py to a redone in django while maintaining the same database? Home I'm having a system done in web2py (in production) and need to redo it in django , keeping the same database . The problem is that django and web2py have different sets of tables for users.
So, the database in production has the web2py user tables, whereas in django several tables are created (with only one user being the one). How can I make django work (with authentication system) using a ready-made database of a system made in web2py? Home Thanks in advance for your attention!


P.S .: the original DB was made in postgreSQL.

    
asked by anonymous 10.04.2018 / 19:30

1 answer

0

Django has a tool called inspectdb that you can create the templates by introspecting the existing database. You can check the output by running this command:

$ python manage.py inspectdb

Save it as a file:

$ python manage.py inspectdb > models.py

Once you have cleaned up your templates, name models.py and place it in the Python package that contains your application. Then add the app within your INSTALLED_APPS definition.

class Person(models.Model):
    id = models.IntegerField(primary_key=True)
    first_name = models.CharField(max_length=70)
    class Meta:
       managed = False
       db_table = 'CENSUS_PERSONS'

Next, perform the appropriate migrations:

$ python manage.py migrate

In addition, you can manually map the bank to models.py , generate a JSON from your legacy bank and finally use the command loaddata to load your database in Django:

$ django-admin loaddata mydata.json

find out more about loaddata and also dumpdata here .

    
24.07.2018 / 07:16