writing to my django website via a separate application

29 views
Skip to first unread message

Damon Branch

unread,
Mar 26, 2018, 5:50:49 PM3/26/18
to Django users
Hi,
I'm developing a website which contains a database. I then need to be able to update that database from a separate python application like a desktop or mobile app.
I am new to Django and fairly new to Python (few months).
After reading the introductory materials I'm thinking the way to do this is:

1. Write the website application which can update database entries with a call like ' myModel.Create(info1='blah', info2='blah') '
2. Package this application/website into something like 'django-myWebsite'
3. In my other program/app import my package like 'from django-myWebsite import *'
4. Make calls to the website via my package like ' myModel.Create(info1='blah', info2='blah') '

Is this the right approach/will it work or is there a better way to do it? Also, are there any examples of accessing a django built website through another program?

Thanks - Damon

Larry Martell

unread,
Mar 26, 2018, 6:03:25 PM3/26/18
to django...@googlegroups.com
A bit confused but your saying 'accessing a django built website'
through another program. Do you mean access the server? I do that, and
also access the database, all the time. I have stand alone python
scripts that access the server using python requests or instantiating
one of my server's objects the same way a request from the browser
would. And I have script that access the db, both using the ORM and
with embedded SQL.

Damon Branch

unread,
Mar 26, 2018, 11:31:55 PM3/26/18
to Django users
Hi Larry,
Thanks for answering - yes that is what I mean I want a stand alone program to access the website server and database.
You said you make 'python requests or instantiating one of my server's objects the same way a request from the browser would' - it's good to know that this can be done - it would help me if there were some samples of this - I cannot find any in the django documentation so I'm having to piece it together from various posts/forums - do you know of any good examples/documentation on this please?
Thanks - Damon

Andréas Kühne

unread,
Mar 27, 2018, 5:03:48 AM3/27/18
to django...@googlegroups.com
Hi Damon,

I think you should consider creating an app that can communicate with the django backend via an API - for example using the django rest framework: http://www.django-rest-framework.org/

That way you control everything via the django application itself and you don't need to update your application every time you change something in the code in the models.

You will need to expose your API seperately from the django app itself though.... 

Med vänliga hälsningar,

Andréas

--
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...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4b9de695-5a7a-45f3-a239-0d3b351a7914%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Damon Branch

unread,
Mar 27, 2018, 11:03:22 AM3/27/18
to Django users
Hi Andreas,
I'm going to look into the rest framework today - thanks for the tip, much appreciated!
Damon

On Monday, March 26, 2018 at 5:50:49 PM UTC-4, Damon Branch wrote:
Reply all
Reply to author
Forward
0 new messages