Monday, October 24, 2016

Re: Running django on demand via my PyQt4 Standalone app

Q1: Is it good idea to start a new QThread who runs the script os.system("web/manage.py runserver")?
No, don't do that.

Q3: If no - what is the best method to start a django server on demand via my PyQt4 App and to stop it?
If the idea is to use django from within a desktop app, you don't need a webserver at all, just import whatever model, view or method you wish to call and call it, no need to go through all the http stack.

Q4: can i share my DB whit django, is this a good idea?
I'm not sure what you mean by this, but one of the features of storing data in a DB as opposed to storing in a file is that multiple users/apps can access it, well even if you were storing everything in a file you could still share it, but then you would need to handle everything yourself.

Q5: can i access from django server my app components class, variable etc. and vice versa ( if the server is running)?
Why not? Did you try? Did you encounter an error?

Q6: can u point me where i can find some documentation or example to get closer to my goal?
Did you went through the django tutorial?

I'm taking a wild guess here and guessing that you would want an ORM to use from your desktop app to access the database, defining python classes and models.
Django is a webframework, but it is not an all or nothing thing, you don't need to use everything, you may just use the ORM, define your models, import them from your application.
As an alternative you may also take a look at sqlalchemy

(I realize that saying "Taking a guess and guessing" is probably not valid english, but is should be. If anyone cares to rephrase that I won't take offence)

Avraham


On Mon, Oct 24, 2016 at 4:20 AM, Dam ian <damian.wilczek.1990@gmail.com> wrote:
Hi,

I work on some Smart Home UI / Controlling system using PyQt4, now I'm in the point where i need a Web Server to share a "Admin Page" to let the user change some Smart Home settings (via web page of course :p ). I searched the internet for a answer / idea and I think that the django server would be the best solution, e.g. like django my "APP" also use a SQLite DB. I need that the server is running only if the user activate the "Admin Mode" and want do some change to the UI / App and only locally.

unfortunately i still learning python and my knowledge is not on the level to do this in the right way and I thought, that maybe someone of you can help me:


Q1: Is it good idea to start a new QThread who runs the script os.system("web/manage.py runserver")?
Q2: If yes - how can i stop the server - maybe through terminating the QThread?
Q3: If no - what is the best method to start a django server on demand via my PyQt4 App and to stop it?
Q4: can i share my DB whit django, is this a good idea?
Q5: can i access from django server my app components class, variable etc. and vice versa ( if the server is running)?
Q6: can u point me where i can find some documentation or example to get closer to my goal?


i know there many ways how to do this ( or not) but I would like to achieve it via the "pythonic way" / best practices
if someone from you can hep me I would be very grateful

Cheers Damian

PS. Sorry for my not best english

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f45e774a-5284-4078-92b2-8813deb9ddd8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFWa6tLA1BPfkQKKiG1mE0f6mqcnaC22nL8webB3tggdSboWHg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment