16

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...

theheadofabroom
  • 20,639
  • 5
  • 33
  • 65

2 Answers2

21

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.

jathanism
  • 33,067
  • 9
  • 68
  • 86
  • If you "p"? Did you get cutoff there? :) – jathanism May 04 '11 at 15:40
  • Lol - yes - I was using a smartphone - I had no idea it had actually posted. I was going to say that I'll have a play about with it before I accept your answer in case there's anything more the needs explaining. Cheers! – theheadofabroom May 04 '11 at 15:44
  • Thanks, I decided to go with the standalone Django scripts. It's scalable and easier to learn. – spedy Jul 29 '16 at 12:12
0

You'll still have to run the Django app as a web server, but you can restrict it to serve to only localhost or something. And sure, you can use QtWebKit as the client.

arussell84
  • 2,443
  • 17
  • 18
  • Are you sure I'd need a full app to do this? It seems rather heavyweight, I was hoping to be able to strip down to just the database functions and the template engine... – theheadofabroom May 02 '11 at 14:39
  • @BiggAl Well, you've got to render your templates somehow. I think it'd be simpler to do it this way. Seems like a lot of trouble to go through just because you don't like the idea of a web server. – arussell84 May 02 '11 at 14:46
  • at the moment it looks like the method @jathanism provided should do great. I want to deploy the client on mobile devices, so I want to make it as light-weight a possible, however if you've tried this before feel free to let me know if you encountered pitfalls. – theheadofabroom May 02 '11 at 15:21