Advertisement

Use django python for a small browser game?

Started by December 10, 2016 02:51 PM
4 comments, last by Kylotan 7 years, 11 months ago
hello forum,
I want to know your feedback about an idea that I have. I know python html css and javascript. My idea is to make a browsergame with django and postgres/mongoDB as database. Has django enough power for a project like that? I wanted to start small with a normal user login and that the user can do some stuff after login, like run some actions .
thank you

It's a bit hard to say if it will do the job without knowing what kind of game you are thinking about and what sort of operations your backend will need to do. However, the tech stack is rarely the bottleneck in a small game that doesn't have thousands of concurrent users, and, anyway, python has been successfully used in game backends before, so you should be fine.

Advertisement

An alternative could be to use a plain http server, likel Flask or Bottle, and perhaps program a REST API to communicate with the browser.

I cannot really compare that solution with Django, as I have no knowledge about the latter at all.

From what I have heard, my alternative starts at a lower level with complete freedom in how and what you communicate between the server and the browser, at the cost of having nothing prepared for you. It's more "start with HTTP requests, and go from there".

hello forum,
I want to know your feedback about an idea that I have. I know python html css and javascript. My idea is to make a browsergame with django and postgres/mongoDB as database. Has django enough power for a project like that? I wanted to start small with a normal user login and that the user can do some stuff after login, like run some actions .
thank you

Personally I like Flask better, specially for a small project. Flask is much simpler and actually designed for smaller projects.

If you like this idea, you can use for the login this module: https://flask-login.readthedocs.io/en/latest/

As for the database, if you want to go really simple, you can use sqlite. It is very, very simple and you can use from scratch (comes with python by default). Regardless of the database you pick, you can use SQLAlchemy as ORM: http://flask-sqlalchemy.pocoo.org/2.1/ with the advantage that you can change the database you use with no changes to your code.

Currently working on a scene editor for ORX (http://orx-project.org), using kivy (http://kivy.org).

thanks guys, I will try to make something with the flask framework. I start with a very very small project to test it out.

Flask's a nightmare once you try and actually structure any reasonably-sized program. That's what happens when you base a framework around globals thread-local variables. My next Python web project will probably use Django.

But any web server framework will have 100x more 'power' than you need if you're just talking about simple turn-based actions. And if you're talking about quicker actions, that will be handled client-side anyway so the web server matters little.

Postgres/mongoDB are obviously 2 separate databases and they have quite different modes of operation. If you know this already, fine. If you're not sure, I recommend postgres if you're hoping to deploy this to other people (because it's robust), and mongo if you're just tinkering, at least to begin with (because it's very easy to get started with).

This topic is closed to new replies.

Advertisement