Friday, January 30, 2015

Re: using Django on an existing mysql schema


On Sat, Jan 31, 2015 at 3:14 AM, Tobias Dacoir <falc410@gmail.com> wrote:
I'm certainly no Django expert, but I'm not sure if you can use the orm and an already existing database.

Yes, you absolutely can. There's even a management command (inspectdb) to help write the wrapper models, and a Meta flag (managed=False) to make sure the migration tools won't touch those models.
 
However the documentation states that you can write all queries yourself, essentially not using the orm. However if you do that, I'm wondering why you want to use Django at all?

Because Django has a lot more than just an ORM. There's a forms layer, authentication tools, and lots more.
 
And pushing business logic into the database sounds like bad design to me (model and controller should be decoupled in MVC like patterns).
 
It depends what logic you're talking about, and what other tools will be using the same database. "MVC" separation like you are describing assumes that the Controller is shared; if you have to re-implement the controller in two languages, then there's a very strong argument to push some of the controller's functionality into the database.

Yours,
Russ Magee %-) 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJxq849XqUqr_HqLBV6x8xcr%3Da9dU5ipT_V4tLyEK%3DgzZCJLqA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment