Use Django to implement my GUI!

750 views
Skip to first unread message

Eugene NGONTANG

unread,
May 13, 2012, 10:14:36 AM5/13/12
to Django users
Hi!

I'm a python developper, but new in django.

I'm devolopping a multi clients-server application.

The server and the clients are communicating via sockets, The server
receive somme states from clients, and display them in the User
interface.
In the other hand, the server has to send a message(packet) to the
client when an event occurs in the GUI, and data are stored in a
database.

Then I choose to make a web interface where data could be viewed and
manipulated. And I discovered Django, which fit all my needs. I tested
and liked the framework.

My questions are:
- Can I override the djando admin methods so that i can not only
customized my views and html page, but also manipulate objects in
database, so that i can do another action when catching an event in
the GUi.
For example, taking the django admin tutorial, I would like to do and
action like sending a message the user choose "add a poll". How can I
do those things? Cause I noticed that method that alter data in data
base are part of django admin module and cannot be overriden

- To achieve what I want, i would like to run my server engine and my
django admin in two separated threads. How do i run my admin module in
a thread? Cause till now i'm using the command line "python manage.py
runserver"

- I also tried to overide tables name, and foreign keys names. Could
you guys provide me a true life example?

- And now in the production step, I would like you guys to tell me
what to choose for serving files. I would like to with your experience
what's better between running a unicorn server or apache with mod_wsgi

I don't know if i'm clear, but i hope. In brief I'd like to use the
django framework features to design my Gui like i want, customize
interactions between the gui and the backend, and choose a good web
server for the production.

Thank you for advance
Message has been deleted

Eugène Ngontang

unread,
May 13, 2012, 12:06:44 PM5/13/12
to django...@googlegroups.com
Yes, I can see tastypie is a good service, that even support REST protocol.

But I'd firt basically implement my gui with django and when i will master well django, i could use tastypie, and turn my server to support REST, it will be a good thing.

But please let's keep using only django for the begining.

Thanks.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/uZMPKqBO1JcJ.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.



--
ngon...@epitech.net
------------------------------------------------------------
Aux hommes il faut un chef, et au chef il faut des hommes!

Alireza Savand

unread,
May 13, 2012, 1:14:32 PM5/13/12
to django...@googlegroups.com
No, i posted django-tastypie not tastypie itself and it's easy to use.
Anyway if i'm implementing GUI based i would make it website, since it's an advantages of SaaS.
But using client app[desktop-app] and a server-app[django] and having multiply client and ... makes maintaining like a nightmare.
All i knew was that, Despite that you asked several question and i just claimed to help in one of them :D

Jani Tiainen

unread,
May 13, 2012, 3:21:11 PM5/13/12
to django...@googlegroups.com
Hi,

There is several ways to achieve what you maybe want to do. One of the simplest way is separate frontend (your userinterface) and server backend. You can build your Django application as a service (xml-rpc, json-rpc, restful). That would give you advantage to choose whatever frontend you like. Of course it would add some overhead.

On Sun, May 13, 2012 at 1:14 PM, Eugene NGONTANG <symp...@gmail.com> wrote:
Hi!

I'm a python developper, but new in django.

I'm devolopping a multi clients-server application.

The server and the clients are communicating via sockets, The server
receive somme states from clients, and display them in the User
interface.
In the other hand, the server has to send a message(packet) to the
client when an event  occurs in the GUI, and data are stored in a
database.


Note that Django is mainly built for web (HTTP protocol based) applications. In such an environment you run two different things: your GUI (usually browser) that is totally ignorant of server side (Django). Then you send request to some URL, Django routes it to some view and view produces again next output to be displayed in GUI (browser again). One of the common functions in the view is database manipulation.
 
Then I choose to make a web interface where data could be viewed and
manipulated. And I discovered Django, which fit all my needs. I tested
and liked the framework.

My questions are:
- Can I override the djando admin methods so that i can not only
customized my views and html page, but also manipulate objects in
database, so that i can do another action when catching an  event in
the GUi.
For example, taking the django admin tutorial, I would like to do and
action like sending a message the user choose "add a poll". How can I
do those things? Cause I noticed that method that alter data in data
base are part of django admin module and cannot be overriden


You shouldn't "fight against admin". If something cannot be done in the admin you usually get a way with writing your own stuff.
 
- To achieve what I want, i would like to run my server engine and my
django admin in two separated threads. How do i run my admin module in
a thread? Cause till now i'm using the command line "python manage.py
runserver

Again your GUI would run "somewhere" (it's not relevant) and it's not concern of Django. It's architecture is designed to be share nothing - which means that you can run several threads/processes of your applications - And those threads/processes are not aware of other existence. And it doesn't matter.
 
- I also tried to overide tables name, and foreign keys names. Could
you guys provide me a true life example?


Err.. Override what and where? And how you tried to do that?
 
- And now in the production step, I would like you guys to tell me
what to choose for serving files. I would like to with your experience
what's better between running a unicorn server or apache with mod_wsgi

I don't know if i'm clear, but i hope. In brief I'd like to use the
django framework features to design my Gui like i want, customize
interactions between the gui and the backend, and choose a good web
server for the production.


No you're definitely not clear. My interpretation is that you want to build (non-http based) GUI using Django as backend server. Even Django isn't exactly designed for such a work it still can do it. 

If it was something else try to split your questions in smaller fragments, perferably with more clearly specified use cases, workflows and samples of the code.
 
Thank you for advance

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.




--
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

Alec Taylor

unread,
May 13, 2012, 4:36:03 PM5/13/12
to django...@googlegroups.com
You could always create a responsive interface—e.g.: using
twitter-bootstrap—and then distribute it onto every platform.

Web (obviously): Django templates or "standard" web frontend—using
e.g.: REST, XMLRPC or JSONRPC—that calls functions and serialises data
in a less data heavy way (on clients' end)
Mobiles: Adobe's open-source PhoneGap
Desktops: Adobe Air, HTML Applications (Windows) and MacGap (OSX) are
all possibilities... however I would recommend checking out Nokia's
open-source Qt, and distributing your product with a renderer. In
essense, you would be distributing your own browser without your page
as homepage, and which can only access what you allow (e.g.:
*.mydomain.com/*). See their webkit-fancybrowser example for an idea
of how this could be done.

John Yeukhon Wong

unread,
May 13, 2012, 8:10:14 PM5/13/12
to django...@googlegroups.com
Maybe pyjs?
Do the GUI part using Python (which renders into javascript), and you can connect it using Django as your backend.

Eugène Ngontang

unread,
May 14, 2012, 4:14:25 AM5/14/12
to django...@googlegroups.com

Thanks Guys for all.
I will carefully look at all your suggestions and see what is better in a production environment.
But the idea of having the possibility to abstract the frontend so that it can be changed is the best i think and was what i intended to do after my server become working and stable.

I want to run server engine(backend) in one thread catching and processing network packets from clients, and my the fronted running in a separated thread rendering data catching gui event.
I first choose to do it with cherrypy but it's not sweet for big projects and the fronted would not be so generic that way.

I then discover django with its features and possibilities.

I hope i will make and implement the best choice with your help.

Thanks and see you soon.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/6hGVZIFjm6QJ.

Eugène Ngontang

unread,
May 14, 2012, 11:18:32 PM5/14/12
to django...@googlegroups.com
Hi Jani!

I haven't seen the last statements of your post, whre you say I'm not really clear and that i'm building a non-http GUI using Django.


OK let's stay on the rendering issue only, and specify things simply. This is a simple description of the architecture I want to set up :

- A Client (not a user interface). Client here means a module which is installed in a remote computer and communicate with the server via socket.

- A server listening from several remote client (Here i'm not talking yet about http request), and receive informatons from them. In fact client must be doing actions and send informations about their actions to the server. In the oder hand data to be processed by each client is pushed/dispatched by the server.

- And admin (not Django Admin, but admin in the sens of my app), destined to be the module allowing use of the application. Then the Admin module is part of the server and will proviede a GUI for manipulating data in the data base. It's in this GUI that users of the application will enter their request, by filling a form or clicking a link for exemple. And data from the GUI could be stored in the data base, while being send to the remote clients (not to be displayed by the client, but to be processed). In the same way, informations comming from those clients to the server have to be diplayed in the GUI.

With a graphical GUI, The server could have a reference to an object representing my GUI, and it will be done.
But I choose a web GUI for view and administration. It's where Django comes.

And my problem is to make my server being running a network thread, receiving data from the GUI(web browser) and sending informations update to the GUI (for web page content).

This is really my issue. If all the actions of my server depended on my GUI request (http request), I could do what I like behind when handling a http request, but while managing http:8080 connexions, the application is running another process/thread on another TCP/UDP port.

And yes I want a web GUI.

Is why I'm looking the best way to achieve that. We can exclude Django web server, as it will not be used in production for the application deployment.

Hope now it's clear for you, and more for the other users.

Thanks!

2012/5/13 Jani Tiainen <red...@gmail.com>



--

Alec Taylor

unread,
May 15, 2012, 3:51:21 AM5/15/12
to django...@googlegroups.com
No reason to do anything crazy like that.

Forget SOCKETS, use HTTP or HTTPS.

Clientside/mobileside/webside build in HTML+CSS+JS.

#win

Jani Tiainen

unread,
May 15, 2012, 6:40:01 AM5/15/12
to django...@googlegroups.com
Hi,

Now it starts to make "sense".

I just wonder why are you trying to build something so extremely
complicated?

What is the rationale behind to have additional middleware layer between
web ui and the server backend?

Wouldn't it be sufficient to have architecture like:

Browser <-> django middleware <-> remote backend

Communication between django middle ware and remote backend should be
built on top of some messaging system, like celery + rabbitmq which
gives you quite standard asyncronous communication between django
middleware and remote backend. Of course you might need to write some
adapters on remote side but that's part of the job.

Only real problem is that if you need to push changes to browser side.
There doesn't exists any really good ways to do that. HTML5 was supposed
to bring websockets to overcome the problem. One big problem is that
only from IE series only IE 10 supports it. All others, FF, Chrome,
Safari has had it for a good while.

There exists also alternative workarounds like Comet, BOSH, push and few
others.

So let
> 2012/5/13 Jani Tiainen <red...@gmail.com <mailto:red...@gmail.com>>
> <mailto:django...@googlegroups.com>.
> To unsubscribe from this group, send email to
> django-users...@googlegroups.com
> <mailto:django-users%2Bunsu...@googlegroups.com>.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
>
>
> --
> Jani Tiainen
>
> - Well planned is half done, and a half done has been sufficient
> before...
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@googlegroups.com>.
> To unsubscribe from this group, send email to
> django-users...@googlegroups.com
> <mailto:django-users%2Bunsu...@googlegroups.com>.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
>
>
> --
> ngon...@epitech.net <mailto:ngon...@epitech.net>
> symp...@gmail.com <mailto:symp...@gmail.com>
> ------------------------------------------------------------
> /*Aux hommes il faut un chef, et au*//* chef il faut des hommes!*/
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

Eugène Ngontang

unread,
May 16, 2012, 12:30:17 AM5/16/12
to django...@googlegroups.com
Hi Jani!

Now you can understand what i meant, but I'm not just try to mec things complicated.

I'm not talking here about my technical implementation, but i'm describing the needs/contraints, and my app architecture to you.

-  The remote clients are at the heart of the software system, since data stored in the database are destined to them (the server push each information to the corresponding host)
- When a client starts, it trys to establish a connection with the server, and if succeed, it retrieves its informations from the server. The server then send back informations conerning the host executing the client (the way server retrieves informations from the data base manager doesn't matter here, it's a technical purpose)
- When a task state changes, it has to notify the server by sending a packet through the network. The GUI (web browser) has then to display the new state.
- When a user of the software wants to create a new task on a host, it uses the GUI for the purpose, and the information has to be sent to the remote corresponding client/host for processing.

Tell in my place, what logic would you adopt. I would like idea from you guys in this case, before go on a first definitive choice.

I can see web sockets solves so much problems for developpers, and i'm still looking if it could help achieve correctly what I want to. The problem of IE < 10 for the instance is not so important.

Now also, can you try to advise me the best way for serving file using python-Django (apache, unicorn, ..)?

Thanks again.

2012/5/15 Jani Tiainen <red...@gmail.com>
Hi,

Now it starts to make "sense".

I just wonder why are you trying to build something so extremely complicated?

What is the rationale behind to have additional middleware layer between web ui and the server backend?

Wouldn't it be sufficient to have architecture like:

Browser <-> django middleware <-> remote backend

Communication between django middle ware and remote backend should be built on top of some messaging system, like celery + rabbitmq which gives you quite standard asyncronous communication between django middleware and remote backend. Of course you might need to write some adapters on remote side but that's part of the job.

Only real problem is that if you need to push changes to browser side. There doesn't exists any really good ways to do that. HTML5 was supposed to bring websockets to overcome the problem. One big problem is that only from IE series only IE 10 supports it. All others, FF, Chrome, Safari has had it for a good while.

There exists also alternative workarounds like Comet, BOSH, push and few others.

So let
       <mailto:django-users@googlegroups.com>.

       To unsubscribe from this group, send email to
       <mailto:django-users%2Bunsu...@googlegroups.com>.

       For more options, visit this group at
       http://groups.google.com/group/django-users?hl=en.




   --
   Jani Tiainen

   - Well planned is half done, and a half done has been sufficient
   before...

   --
   You received this message because you are subscribed to the Google
   Groups "Django users" group.
   To post to this group, send email to django...@googlegroups.com

   To unsubscribe from this group, send email to
   <mailto:django-users%2Bunsu...@googlegroups.com>.

   For more options, visit this group at
   http://groups.google.com/group/django-users?hl=en.




--
ngon...@epitech.net <mailto:ngon...@epitech.net>
symp...@gmail.com <mailto:symp...@gmail.com>
------------------------------------------------------------
/*Aux hommes il faut un chef, et au*//* chef il faut des hommes!*/


--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to

For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/django-users?hl=en.




--
ngon...@epitech.net

Jani Tiainen

unread,
May 16, 2012, 10:00:52 AM5/16/12
to django...@googlegroups.com
Hi,

Like I said, it all depends what you have and what is the goal.

You keep constantly talking about magical "server" that talks with the
database. Is this server already existing piece of infrastructure that
some programs already use and you like to hook up with that?

Or is this server something that you just invented in lack of better
knowledge?

You talk about state changes (in example you give a task). Must those
changes be reflected in "real time" between arbitrary clients? Or is it
sufficient that client sees changes at some later point?
> 2012/5/15 Jani Tiainen <red...@gmail.com <mailto:red...@gmail.com>>
> <mailto:red...@gmail.com> <mailto:red...@gmail.com
> <mailto:red...@gmail.com>>>
>
>
> Hi,
>
> There is several ways to achieve what you maybe want to do.
> One of
> the simplest way is separate frontend (your userinterface) and
> server backend. You can build your Django application as a
> service
> (xml-rpc, json-rpc, restful). That would give you advantage to
> choose whatever frontend you like. Of course it would add
> some overhead.
>
> On Sun, May 13, 2012 at 1:14 PM, Eugene NGONTANG
> <symp...@gmail.com <mailto:symp...@gmail.com>
> django...@googlegroups.com <mailto:django...@googlegroups.com>
> <mailto:django-users@__googlegroups.com
> <mailto:django...@googlegroups.com>>.
>
> To unsubscribe from this group, send email to
> django-users+unsubscribe@__googlegroups.com
> <mailto:django-users%2Bunsu...@googlegroups.com>
> <mailto:django-users%__2Buns...@googlegroups.com
> <mailto:django-users%252Buns...@googlegroups.com>__>.
>
> For more options, visit this group at
> http://groups.google.com/__group/django-users?hl=en
> <http://groups.google.com/group/django-users?hl=en>.
>
>
>
>
> --
> Jani Tiainen
>
> - Well planned is half done, and a half done has been sufficient
> before...
>
> --
> You received this message because you are subscribed to the
> Google
> Groups "Django users" group.
> To post to this group, send email to
> django...@googlegroups.com <mailto:django...@googlegroups.com>
> <mailto:django-users@__googlegroups.com
> <mailto:django...@googlegroups.com>>.
>
> To unsubscribe from this group, send email to
> django-users+unsubscribe@__googlegroups.com
> <mailto:django-users%2Bunsu...@googlegroups.com>
> <mailto:django-users%__2Buns...@googlegroups.com
> <mailto:django-users%252Buns...@googlegroups.com>__>.
>
> For more options, visit this group at
> http://groups.google.com/__group/django-users?hl=en
> <http://groups.google.com/group/django-users?hl=en>.
>
>
>
>
> --
> ngon...@epitech.net <mailto:ngon...@epitech.net>
> <mailto:ngon...@epitech.net <mailto:ngon...@epitech.net>>
> symp...@gmail.com <mailto:symp...@gmail.com>
> <mailto:symp...@gmail.com <mailto:symp...@gmail.com>>
> ------------------------------__------------------------------
> /*Aux hommes il faut un chef, et au*//* chef il faut des hommes!*/
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to
> django...@googlegroups.com
> <mailto:django...@googlegroups.com>.
> To unsubscribe from this group, send email to
> django-users+unsubscribe@__googlegroups.com
> <mailto:django-users%2Bunsu...@googlegroups.com>.
> For more options, visit this group at
> http://groups.google.com/__group/django-users?hl=en
> <http://groups.google.com/group/django-users?hl=en>.
>
>
>
> --
> Jani Tiainen
>
> - Well planned is half done and a half done has been sufficient
> before...
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@googlegroups.com>.
> To unsubscribe from this group, send email to
> django-users+unsubscribe@__googlegroups.com
> <mailto:django-users%2Bunsu...@googlegroups.com>.
> For more options, visit this group at
> http://groups.google.com/__group/django-users?hl=en
> <http://groups.google.com/group/django-users?hl=en>.
>
>
>
>
> --
> ngon...@epitech.net <mailto:ngon...@epitech.net>
> symp...@gmail.com <mailto:symp...@gmail.com>
> ------------------------------------------------------------
> /*Aux hommes il faut un chef, et au*//* chef il faut des hommes!*/
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users...@googlegroups.com.

Eugène Ngontang

unread,
May 16, 2012, 11:47:27 AM5/16/12
to django...@googlegroups.com

No i'm not inventing a server.
The application has a centrilzed server (module server installed on a dedicated host
).
The dispatches tasks to remote clients (the client module is installed on each client host) and receives informations from clients about taks state.

How would you like me to describe or call my app  components?
What is not clear for you in my architecture description?
How would you call my server module?
And i'm not saying the database is installed on the same machine as the server, even if it could be.
But only the server can access database directly.

If you like so, What i call server could stand for a central task supervisor.

Thanks for attention Jani.



               To unsubscribe from this group, send email to
       django-users+unsubscribe@__googlegroups.com
       <mailto:django-users%2Bunsu...@googlegroups.com>


               For more options, visit this group at
       http://groups.google.com/__group/django-users?hl=en
       <http://groups.google.com/group/django-users?hl=en>.




           --
           Jani Tiainen

           - Well planned is half done, and a half done has been sufficient
           before...

           --
           You received this message because you are subscribed to the
       Google
           Groups "Django users" group.
           To post to this group, send email to


           To unsubscribe from this group, send email to
       django-users+unsubscribe@__googlegroups.com
       <mailto:django-users%2Bunsu...@googlegroups.com>


           For more options, visit this group at
       http://groups.google.com/__group/django-users?hl=en
       <http://groups.google.com/group/django-users?hl=en>.




       --
       ngon...@epitech.net <mailto:ngon...@epitech.net>
       <mailto:ngon...@epitech.net <mailto:ngon...@epitech.net>>
       symp...@gmail.com <mailto:symp...@gmail.com>
       <mailto:symp...@gmail.com <mailto:symp...@gmail.com>>
       ------------------------------__------------------------------
       /*Aux hommes il faut un chef, et au*//* chef il faut des hommes!*/


       --
       You received this message because you are subscribed to the Google
       Groups "Django users" group.
       To post to this group, send email to
       django...@googlegroups.com
       <mailto:django-users@googlegroups.com>.

       To unsubscribe from this group, send email to
       django-users+unsubscribe@__googlegroups.com
       <mailto:django-users%2Bunsu...@googlegroups.com>.
       For more options, visit this group at
       http://groups.google.com/__group/django-users?hl=en
       <http://groups.google.com/group/django-users?hl=en>.



   --
   Jani Tiainen

   - Well planned is half done and a half done has been sufficient
   before...


   --
   You received this message because you are subscribed to the Google
   Groups "Django users" group.
   To post to this group, send email to django...@googlegroups.com

   To unsubscribe from this group, send email to
   django-users+unsubscribe@__googlegroups.com
   <mailto:django-users%2Bunsu...@googlegroups.com>.
   For more options, visit this group at
   http://groups.google.com/__group/django-users?hl=en
   <http://groups.google.com/group/django-users?hl=en>.




--
ngon...@epitech.net <mailto:ngon...@epitech.net>
symp...@gmail.com <mailto:symp...@gmail.com>
------------------------------------------------------------
/*Aux hommes il faut un chef, et au*//* chef il faut des hommes!*/

--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to

For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.

Marcin Tustin

unread,
May 16, 2012, 11:49:27 AM5/16/12
to django...@googlegroups.com
A lot of people seem confused by your architecture. It might help if you provided a complete (but high-level) description of the architecture of the system in a single email.

To unsubscribe from this group, send email to django-users...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/django-users?hl=en.



--
Marcin Tustin
Tel: 07773 787 105

Eugène Ngontang

unread,
May 16, 2012, 12:20:08 PM5/16/12
to django...@googlegroups.com

Ok!
But it's not so complited to understand.
I will even send a diagram.

Frank Stüss

unread,
May 16, 2012, 12:49:40 PM5/16/12
to django...@googlegroups.com
or maybe you might have a look at http://pyjs.org/
which could help you having an event aware client app in your browser.
Served by and with django.
Armaturen und Fittings Stüss e.K.
Frank Stüss + Inhaber
Tel. +49+6187-5019 + FAX. +49+6187-91725
Kilianstädter Straße 25 + D-61137 Schöneck
email frank....@stuess.de <http://www.stuess.de>
Sitz Schöneck, HRA5340, Amtsgericht Hanau
USt.-ID: DE252310440

............................................
Fördermitglied der Wirtschaftsjunioren
Hanau-Gelnhausen-Schlüchtern
Umfassende Infos: http://www.wj-hanau.de
Senator #68128


Alec Taylor

unread,
May 16, 2012, 2:02:41 PM5/16/12
to django...@googlegroups.com
On Wed, May 16, 2012 at 10:49 PM, Frank Stüss <frank....@stuess.de> wrote:
> or maybe you might have a look at http://pyjs.org/
> which could help you having an event aware client app in your browser.
> Served by and with django.

I'm impressed

(just read the exec summary from homepage)

Alec Taylor

unread,
May 16, 2012, 2:06:44 PM5/16/12
to django...@googlegroups.com
Oh right, it's just Pyjamas.

Still, annoyed I didn't think to recommend it first!

Eugène Ngontang

unread,
May 18, 2012, 3:36:41 AM5/18/12
to django...@googlegroups.com
Hi Guys!

I've been busy a bit, I'm back to thread with the high level architecture. Attached here is a diagram, just to understand what i meant.

Don't pay attention for object I use to describe modules or architecture components.

Now you will be able to understand what I mean by the server module, the admin module, and the client module of my architecture.

As you could see on the diagram, the admin module is installd on the server(where the server module is installed) and is destined to provide views to the GUI.
The clients receive and send data to the server.
When the admin make some actions, some clients are notifed, and when client send informations admin (GUi is notified).

Now two things come in my mind when I was thinking :

- First I could stay in the way I want the server to use HTTP for the admin side, and another protocol to communicate with client. In that way the Admin Module (Django) will alter and read data from data base. and the server module will alter and read data from database. Then each information retrievement will lead in reading database since informations could have been changed. You can that's really heavy.

- Second do all things in http. Mean that my server is just a web application undertanding HTTP (I will the use django for that). The server will serve request depending on the type of request, and each client will communicate with the server using HTTP.  Then server will define pages/urls for admin (to be sent to the GUI), and pages/urls  for clients.
By this way, the only relation between my modules will be the protocol (HTTP for the instance) and they could be implemented in what ever language we like. The sever will run asynchronously for admin and clients.
  The admin will then be just an interface to wich convert data to the right display format for the GUI. And the GUI could be any type, and for the web interface type I will use DJANGO for my Admin module.
   I will then also have to develop a http client for my client module.

Actuallu I'm going to take the second choice, since it lets all the charge for read and write database to the server, which could run and publish informations asynchronously(websocket could help here).

I precise that I'm not a web architect or designer, but i understand software architecture. I'm really a system and network engineer, with good developpement skill but not to much in web.

Look now my architecture diagram and tell me if what I'm describing in the second item fit. And give idea if you have, about libraiies and or framwork that could help going fast and easy.
I thing I will use django and green unicorn.

Thanks for your attention.


2012/5/16 Alec Taylor <alec.t...@gmail.com>
ModelArchitecture.png

Alec Taylor

unread,
May 19, 2012, 1:33:31 AM5/19/12
to django...@googlegroups.com
Duuuude

That architecture diagram shows exactly your problem.

You are thinking about this problem incorrectly.

- Server: nginx [or whatever] with Django
- Client: web-browser
- Admin: <extend> Client: web-browser

#done

Kurtis Mullins

unread,
May 19, 2012, 2:16:10 AM5/19/12
to django...@googlegroups.com
If you're dead set on using a non-browser GUI for the administration application, just use the HTTP Protocol for your communications between the Django Server and whatever Desktop Application you build. However, if you can just use a web browser for that (even if it's a Qt browser or something that looks like a desktop application, as others have mentioned) then your life will be a lot easier.

Kurtis Mullins

unread,
May 19, 2012, 2:41:24 AM5/19/12
to django...@googlegroups.com
My questions are:
- Can I override the djando admin methods so that i can not only
customized my views and html page, but also manipulate objects in
database, so that i can do another action when catching an  event in
the GUi.

Anything that can be done with Django's Admin interface can be done programmatically. If you choose to use a custom administration application (for example, your Desktop Application) then you'll need to provide some sort of an API over some sort of a Protocol (I vote HTTP). The easiest to implement, in my opinion, is just using HTTP Methods (POST, GET, DELETE, etc...) with proper HTTP Responses (200 OK, 404 Missing, etc...) and some sort of a standard data-format (JSON, XML) as the Response Content when sending data back and forth.

For example, taking the django admin tutorial, I would like to do and
action like sending a message the user choose "add a poll". How can I
do those things? Cause I noticed that method that alter data in data
base are part of django admin module and cannot be overriden

I'm not sure if I understand you correctly, here. You can use signals to fire off an event when a user saves an object. If you want to display a message to a user (e.g. "Your new poll has been created") then use the Django Messaging Framework. If the default admininstration application doesn't do what you need and it's not flexible enough to do what you want -- then don't fight it, write your own Views and Model Methods to perform this behavior.

- To achieve what I want, i would like to run my server engine and my
django admin in two separated threads. How do i run my admin module in
a thread? Cause till now i'm using the command line "python manage.py
runserver"

If you want to run the two as completely separate applications, simply take two copies of your code-base and disable 'Admin' in one. Don't use Django's runserver as a production server -- I'm sure others have already pointed out (as well as the documentation) that it's not designed for that purpose. Instead, use Nginx + uWSGI, Nginx + gunicorn, or even Apache for a lower-traffic site.

 - I also tried to overide tables name, and foreign keys names. Could
you guys provide me a true life example?

Override foreign key name(s): Not really sure what you are asking here.

- And now in the production step, I would like you guys to tell me
what to choose for serving files. I would like to with your experience
what's better between running a unicorn server or apache with mod_wsgi

I use Nginx + uWSGI. There's plenty of sites out there that give you more information on the subject. I chose this option because it's scalable, I've got the configuration figured out, and it's pretty efficient and lightweight.

I don't know if i'm clear, but i hope. In brief I'd like to use the
django framework features to design my Gui like i want, customize
interactions between the gui and the backend, and choose a good web
server for the production.

From your diagram you posted later-on, I think Django will work just fine for your purpose. Just take it one step at a time and bulid it iteratively. Break the whole architecture down into smaller pieces and tackle them one at a time. You will learn a lot and will have a lot of fun doing it. Django is a great framework to use and it's always been a pleasure for me except the first month where there was so many features it was hard to pick a place and go. Following the tutorials, as it appears you have done, is a great way to start and you can learn more as you start to dive in deeper and write more exciting code.

Good luck to you!

Jani Tiainen

unread,
May 19, 2012, 6:08:48 AM5/19/12
to django...@googlegroups.com
Hi,

By looking your diagram it's still the same as you described in your earlier mails. So it doesn't help at all. :)

1) Is your server something that exists and is used in everyday life or is it something that you're going to build?

2) Are your clients something that already exists and is used in everyday life?

3) Are you now trying to figure out how to plug in Django in "Adming module/PC with GUI block"?

Eugène Ngontang

unread,
May 19, 2012, 9:38:09 AM5/19/12
to django...@googlegroups.com

When you're asking if my client/server already exist. You're talking about physical machines or applications/modules?

- the machines where client module will run already exist and are used dayly. The client module will just be installed there and do what it has to do.
- every body knows the browser/gui can be found and run anywhere.
- Now the server machine where the web server should be running and the admin module will be deployed is a dedicated machine that should be set up specially for the project.
- the database could be on a separated machine or anywhere, it doesn't matter.

I don't know why you still don't understand Jani. The physical architecture is simple and i described it.

And i was saying all will now be done in http. I just have to make my admin(browser) notified asynchronously, as well as my clients (i know i should avoid distinguish them from the gui/browser but it's for make things clear)

See you.

Eugène Ngontang

unread,
May 19, 2012, 6:01:38 PM5/19/12
to django...@googlegroups.com

Hi Jani.
I don't know why you say

" 3) Are you now trying to figure out how to plug in Django in "Adming module/PC with GUI block"?"

My admin module and the gui do not share anything. They are not on the same pc.
Gui is for displaying and admin for the page content management like any web aplication works.

I please us unot to build a myster arround this thread. The problem was simple:
I wanted my server to asynchronously manage web pages for views, and remote dustributed clients (like in the diagram) using tcp/udp sockets.
Now all communications will be done in http and any client will use this protocol (web browser or my app client module).
The server (a http server) will then just use an admin module based on django.

That's the way were going to do. Now, if you have advises concerning this impletation give them to please.
Thanks.

Le 19 mai 2012 11:38, "Eugène Ngontang" <symp...@gmail.com> a écrit :

Eugène Ngontang

unread,
May 19, 2012, 8:05:49 PM5/19/12
to django...@googlegroups.com

Hi Jani.
I don't know why you say

" 3) Are you now trying to figure out how to plug in Django in "Adming module/PC with GUI block"?"

My admin module and the gui do not share anything. They are not on the same pc.
Gui is for displaying and admin for the page content management as any

Le 19 mai 2012 11:38, "Eugène Ngontang" <symp...@gmail.com> a écrit :

Marc Aymerich

unread,
May 20, 2012, 12:35:46 AM5/20/12
to django...@googlegroups.com
On Sat, May 19, 2012 at 8:01 PM, Eugène Ngontang <symp...@gmail.com> wrote:
> Hi Jani.
> I don't know why you say
>
> " 3) Are you now trying to figure out how to plug in Django in "Adming
> module/PC with GUI block"?"
>
> My admin module and the gui do not share anything. They are not on the same
> pc.
> Gui is for displaying and admin for the page content management like any web
> aplication works.
>
> I please us unot to build a myster arround this thread. The problem was
> simple:


HI Eugène,
the problem was simple, but all we have misunderstood you because
usually the term GUI is used to refer "desktop application" rather
than a web page, which seems to be the case.

br
--
Marc

Eugène Ngontang

unread,
May 20, 2012, 12:50:03 AM5/20/12
to django...@googlegroups.com
Yes you're right Marc!

It's just that I wanted to mention the fact my application is not only a web site accessible via a web browser only, but a client-server application with web-based GUI.

But now things are clear, we're all now ok with the problematic and with your help and great responses, i noticed it's better to do all my system communication based on HTTP.

I thank you for all your attention, all new ideas are still well come, and i'll let you follow up the evelution of the development.

Thanks guys.



2012/5/20 Marc Aymerich <glic...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Eugène Ngontang

unread,
Jul 15, 2012, 7:07:09 PM7/15/12
to django...@googlegroups.com
Hi all!

Hope you still remember this post which helps dive into django. I have gone really ahead with my developments, and now i'm willing to make some optimization and have some few issues. I don't know if I should open a new thread for each one. You will tell me, but I prefered to do it here because the initial thread was this one.

- First I can't use the HttpResponseRedirect() method in my application, it does not work like it should. In fact in my models module, I have a JobHistory class and a member function in that class which returns a link for the listdisplay of that model in the admin module.
But when the id i'm looking for in the database does not exist, i would like to redirect the user to a custum error page. And to that I used HttpResponseRedirect() wich is unable to return the right address to the browser. I tried such things, read the documentation several times but nothing. I thought it was the reverse function which does not locate the page but no, because even with google address the browser receive a response address with some headers concatanated, and the browser cannot access the page, cause it has an invalid address:
the code line in the models module:
        def get_executing_user_url(self):
                user_list = SystemUser.objects.filter(systemuser_name = self.job_executing_user, host = self.job.host)
                if not user_list:
                        return HttpResponse('http://www.google.com/')
                        #return HttpResponseRedirect('10.136.37.19:8080%s/' % reverse('fancycron.views.job_exec_user_error', args=(self.jobhistory_id,)))                          
                else:
                        return '../systemuser/%s/' % (user_list[0].systemuser_id)

You can see I've even tried to hardput the server address, but it did not work, and I even tested with google and it didn't work too. Tell me if I missed something in the use of HttpResponseRedirect. The error is not a django error, but the returned address is just not accessible each any time i try.

- The second issue is that I have implement my middleware (django) and remote backend communication using django signals. It works, but as you can expected, it's synchronous, and I would like now to do it asynchronously. Is Celery the best option? If yes, could you please indicate me the simplest and efficient way to set that up? Anyway, ho can I send messages to my remote backend, without block in my browser rendering?

Some good and working tutorials are welcome.

Thank you a lot guys.
Eugène NG

2012/5/20 Eugène Ngontang <symp...@gmail.com>



--
ngon...@epitech.net
------------------------------------------------------------
 chef il faut des hommes!
L'habit ne fait pas le moine, mais lorsqu'on te voit on te juge!

Eugène Ngontang

unread,
Jul 16, 2012, 11:14:11 AM7/16/12
to django...@googlegroups.com
Hi!

To complete my HttpResponseRedirect issue, here is a screenshot i have when clinking on the link.

The browser does not know the page content type, and I don't see the to set the content type with HttpResponseRedirect method, cause it takes only one argument, which is the address to redirect to.

Thank for advance for your answer.

2012/7/15 Eugène Ngontang <symp...@gmail.com>
Hi all!

Hope you still remember this post which helps dive into django. I have gone really ahead with my developments, and now i'm willing to make some optimization and have some few issues. I don't know if I should open a new thread for each one. You will tell me, but I prefered to do it here because the initial thread was this one.

- First I can't use the HttpResponseRedirect() method in my application, it does not work like it should. In fact in my models module, I have a JobHistory class and a member function in that class which returns a link for the listdisplay of that model in the admin module.
But when the id i'm looking for in the database does not exist, i would like to redirect the user to a custum error page. And to that I used HttpResponseRedirect() wich is unable to return the right address to the browser. I tried such things, read the documentation several times but nothing. I thought it was the reverse function which does not locate the page but no, because even with google address the browser receive a response address with some headers concatanated, and the browser cannot access the page, cause it has an invalid address:
the code line in the models module:
        def get_executing_user_url(self):
                user_list = SystemUser.objects.filter(systemuser_name = self.job_executing_user, host = self.job.host)
                if not user_list:
                         return HttpResponseRedirect('http://www.google.com/')
HttpResponseRedirect.png

Eugène Ngontang

unread,
Jul 16, 2012, 11:30:16 AM7/16/12
to django...@googlegroups.com
Ok!

I think several times and solved the problem.

In fact I think the admin was waiting an address to build the http response it self, not really a http response.

I remove the HttpResponse or HttpResponseRedirect method  from the return statement, and it worked as I expected.

The wrong code line :
                       #return HttpResponseRedirect('10.136.37.19:8080%s/' % reverse 'app.views.job_exec_user_error', args=(self.jobhistory_id,)))   

The correct code line :
                       #return (reverse('app.views.job_exec_user_error', args=(self.jobhistory_id,)))

Now I'm dealing whith asyncronous communications.



2012/7/16 Eugène Ngontang <symp...@gmail.com>
Reply all
Reply to author
Forward
0 new messages