Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Django minus the web server

I'm writing a syndication client, with the aim being to have a client for devices, and a web site that has the same functionality. I shall develop the website using Django - this is already decided; the client shall be written in python with both a CLI and a PyQt4 GUI. I have been writing the clinet first, and it's fairly database-heavy, as everything is cached to enable it to be read while offline.

It struck me today that it would make sense to use Django models for my application, to reduce the repetition of effort between the client and the website. My question is how easy it is to seperate this, and how much of Django I will need in my client to use Django's models. AFAIK I should not need to run the server, but what else is needed? I had an idea of generating the same html for my client as the website, but showing it withing Qt widgets rather than serving pages for a browser.

Has anyone tried this sort of thing before? I'm starting on this already, but it would be good to get a warning of potential dead-ends or things that will create a maintainance nightmare...

like image 479
theheadofabroom Avatar asked May 02 '11 14:05

theheadofabroom


People also ask

Does Django need a web server?

Django, being a web framework, needs a web server in order to operate. And since most web servers don't natively speak Python, we need an interface to make that communication happen. Django currently supports two interfaces: WSGI and ASGI.

Which web server is used by Django?

Django's primary deployment platform is WSGI, the Python standard for web servers and applications. Django's startproject management command sets up a minimal default WSGI configuration for you, which you can tweak as needed for your project, and direct any WSGI-compliant application server to use.

Can I use Django to create a website?

Django is a powerful structure written with and using all the functionality of the Python programming language to create commercial and home websites of varying complexity. Django is an open source project that supports the implementation of the most popular packages and Python tools.

Is Django only for websites?

Django is a free, open source framework for Python web development and is a very flexible web development tool that can be used to create just about any type of website or app that is needed.


1 Answers

Read up on standalone Django scripts and you'll be on your path to victory. Basically all you're really doing is referencing the Django settings.py (which Django expects) and then using models without web views or urls.

If all you're really interested in is using Django's ORM to manage your models and database interaction, you might want to consider using SQLAlchemy instead.

like image 162
jathanism Avatar answered Sep 20 '22 15:09

jathanism