Sign in to follow this  
hakura88

Use django python for a small browser game?

Recommended Posts

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

Share this post


Link to post
Share on other sites

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.

Edited by Avalander

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this