Reputation: 13
I am moving my web application from rails to django, I have successfully connected to my PostgreSQL DB with the django application. My question is, do I have to recreate all of the rails models in django (which will create new database tables) or is there a way to use the existing tables as they are? I am looking through documentation but have not found the specific answer I am looking for.
Upvotes: 0
Views: 37
Reputation: 2331
You can say to django that you don't want your table to be created by adding a managed attribute to False on your models Meta.
class MyModel(models.Model):
class Meta:
managed = False
The classes for the models can be created with the inspectdb management command. This command will set the managed attribute to False.
I suggest that you create this model file, remove the managed attribute, et create an initial migrations. You will then manually insert the row for this initial migration on your production database (django_migrations table if I remember correctly) to tell Django that all those tables have already been created.
Upvotes: 1