Do I need to migrate pre-existing code into Django?

52 views
Skip to first unread message

Tyler Meche

unread,
Dec 17, 2013, 4:14:03 PM12/17/13
to django...@googlegroups.com
Hey!

I have recently created a website, using PHP.  No framework or anything else was used, just code.

Now, I need to make an API for this website.  It was suggested that I use Django as a framework.  I was hoping to just be able to make an API in Python, using Django, without having to move my site that was already created into the Django framework and redo it in Python.

Is it possible for me to have my site sitting by itself, and the API for the site in Django?  Or do I need to have my site and the API all in Django?

I am not the most experienced web developer, and I have not used Django before.  I apologize in advance if this is a dumb question.

Thank you in advance for any help that can be given!

Jonathan Baker

unread,
Dec 17, 2013, 4:39:23 PM12/17/13
to django...@googlegroups.com
No, you don't need to migrate your site (although, after using Python and Django you might just want to...). An API should return responses that are generic in format, so any type of client (PHP, C++, Obj-C, etc.) can consume them (without knowing or needing to know what the API is written in).

To get started, check out:
1) Django Rest Framework http://django-rest-framework.org/

JDB


--
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...@googlegroups.com.
To post to this group, send email to django...@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/7c0e2071-a6d9-431c-a357-da9f55987227%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Erik Cederstrand

unread,
Dec 18, 2013, 3:28:02 AM12/18/13
to Django Users
Den 17/12/2013 kl. 22.14 skrev Tyler Meche <tmec...@gmail.com>:

> I have recently created a website, using PHP. No framework or anything else was used, just code.
>
> Now, I need to make an API for this website. It was suggested that I use Django as a framework. I was hoping to just be able to make an API in Python, using Django, without having to move my site that was already created into the Django framework and redo it in Python.
>
> Is it possible for me to have my site sitting by itself, and the API for the site in Django? Or do I need to have my site and the API all in Django?

It’s perfectly possible to build an API in Django on top of an existing database. You can auto-generate the models using inspectdb if you want:https://docs.djangoproject.com/en/dev/howto/legacy-databases/ Use any of the API frameworks already mentioned.

If you want to enable creates, updates and deletes via the API, you need to be very careful to maintain data integrity, business rules, user authentication and authorization, handle cache invalidation and avoid race conditions when running alongside the PHP site.

Kind regards,
Erik
Reply all
Reply to author
Forward
0 new messages