0

I have a n existing MySQL database. I want to create a new django application with that database.

I read that I need to run "syncdb" each and every time when add a new model in django. That time adding a new table in database in <database_name>.<table_name> format. And fetching data from that table.

What is the correct method to fetch data from an existing database in django ?

This is my model:

from django.db import models

class Users(models.Model):
    employee_id = models.CharField(max_length=30)
    def __unicode__(self):
        return self.employee_id
3
  • Was the existing database created by django? Commented Feb 8, 2013 at 7:11
  • no ... its not created by django. Its an existing php ( CI ) application Commented Feb 8, 2013 at 7:25
  • 1
    docs.djangoproject.com/en/dev/howto/legacy-databases Commented Feb 8, 2013 at 7:37

1 Answer 1

2

Use the Django model meta options to set db_table and db_column on your Models and Fields respectively. See these links for more info on how to use them: https://docs.djangoproject.com/en/dev/ref/models/options/#db-table https://docs.djangoproject.com/en/dev/ref/models/fields/#db-column

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.