QDjango, a Qt-based C++ web framework

Overview

QDjango - a Qt-based C++ web framework
Copyright (c) 2010-2015 Jeremy Lainé

Build Status

About

QDjango is a web framework written in C++ and built on top of the Qt library. Where possible it tries to follow django's API, hence its name.

It is released under the terms of the GNU Lesser General Public License, version 2.1 or later.

To learn more about QDjango, please read the online documentation.

Requirements

QDjango builds and is auto-tested both with Qt 4 and Qt 5.

Qt 4 on Debian:

sudo apt-get install libqt4-dev

Qt 5 on Debian:

sudo apt-get install qtbase5-dev

Qt 4 on Mac OS X:

sudo port install qt4-mac

Building QDjango

mkdir build
cd build
qmake ..
make

You can pass the following arguments to qmake:

PREFIX=<prefix>                 to change the install prefix
                                default:
                                    unix:  /usr/local on unix
                                    other: $$[QT_INSTALL_PREFIX]
QDJANGO_LIBRARY_TYPE=staticlib  to build a static version of QDjango

Mailing list

If you wish to discuss QDjango, you are welcome to join the QDjango group.

Notes

MSSQL

Fast forward cursors are used by default. This greatly improves performance, and has the added benefit of implicitly converting to a static cursor when it needs to. Unfortunately, this also means that these cursors can block a connection to the server. In order to deal properly with this situation, there are a few requirements:

  • Connection pooling must be enabled in your ODBC manager
  • You must enable Multiple Active Result Sets in the QODBC driver using "MARS_Connection=Yes" in the connection string
  • You must enable connection pooling in the QODBC driver using the "SQL_ATTR_CONNECTION_POOLING" attribute
Comments
  • Please migrate QtScript usage to QJSEngine (support will be removed in Qt 5.6)

    Please migrate QtScript usage to QJSEngine (support will be removed in Qt 5.6)

    QtScript is currently deprecated, and in Qt 5.6 it will be removed.

    I currently use QDjango for one of the components in Ubuntu Touch (the infographics on the lock screen). See (https://bugs.launchpad.net/ubuntu/+source/libusermetrics/+bug/1457488).

    Apparently the replacement for QtScript is QJSEngine (http://doc.qt.io/qt-5/qtjavascript.html).

    Thanks!

    opened by pete-woods 14
  • Add validators

    Add validators

    Adds validators for field validation in QDjango. None of this is enabled by default (a la django), but you now have the option of running cleanFields on your model to check for data validation.

    currently includes:

    • QDjangoRegExpValidator
    • QDjangoUrlValidator
    • QDjangoIPv4Validator

    the tests are basically the same as django

    opened by mbroadst 7
  • added SQL aggregate functions to use with QDjangoQuerySet

    added SQL aggregate functions to use with QDjangoQuerySet

    hi there. I think its very useful to make it possible to use aggregate SQL functions on QDjangoQuerySet. I've added AggregateType enum to QDjangoWhere, probably its not the base place for it, but it requires much less changes.

    opened by swex 3
  • Create a quickstart guide

    Create a quickstart guide

    At first glance it's difficult to see how QDjango can help my project; I think users would greatly appreciate some sort of quickstart guide with a simple example on how the library is supposed to be used.

    I think a good example is the readme of https://github.com/sandeepmistry/bleno

    opened by RazZziel 3
  • build on win32

    build on win32

    util.cpp needs QDjangoDatabase::databaseType but it's not exported so I added QDJANGO_EXPORT to QDjangoDatabase class but then the unresolved symbol changes:

    QDjangoScript.obj:-1: error: LNK2001: unresolved external symbol "public: static struct QMetaObject const QDjangoDatabase::staticMetaObject" (?staticMetaObject@QDjangoDatabase@@2UQMetaObject@@B)
    

    while qdjangoscript build instead normally, the linux build is fine, but the export keyword is mandatory on win32

    opened by sherpya 3
  • Upgraded selectRelated to work like in the current Django version.

    Upgraded selectRelated to work like in the current Django version.

    One can list the foreign keys to be loaded thus limiting the DB traverse. In the current version the selectRelated loaded all the foreign keys recursively, which is quite demanding for large DB structures.

    opened by pavleb 2
  • Handling QString() for NOT NULL fields

    Handling QString() for NOT NULL fields

    Is there any specific reason for returning QLatin1String("") here? https://github.com/jlaine/qdjango/blob/master/src/db/QDjangoMetaModel.cpp#L203

    It converts null strings to empty strings and bypasses NOT NULL rules. For my case returning QVariant() instead fixed the behavior.

    opened by jerch 2
  • Add a non template member: QDjangoMetaModel QDjango::metaModel(const QOb...

    Add a non template member: QDjangoMetaModel QDjango::metaModel(const QOb...

    Adds a non template member QDjangoMetaModel QDjango::metaModel(const QObject *model)

    It avoids the use of template to retrieve an already registered model, and as a consequence allows one to develop a non template function that saves any QObject in database:

    bool storageManager::saveItem(QObject *o)
    {
        QDjangoMetaModel meta = QDjango::metaModel(o);
        if(!meta.isValid())
        {
            qWarning() << "Metamodel is not available in storageManager::saveItem for" << o->metaObject()->className();
            return false;
        }
        for(const auto &i : meta.foreignFields().keys())
        {
            meta.setForeignKey(o, i, o->property(i).value<QObject*>());
        }
        return meta.save(o);
    }
    

    This is especially useful when using QDjango without QDjangoModel

    opened by ericLemanissier 2
  • create/dropTables() FK dependencies

    create/dropTables() FK dependencies

    When creating/droping tables with QDjango::createTables() QDjango::dropTables() check for FK dependencies. Now the tables are processed alphabeticaly.

    Example: If I have table A which has foreign key to table B: SQL query "CREATE TABLE A (id integer B_id integer NOT NULL, CONSTRAINT FK_B_id FOREIGN KEY (B_id) REFERENCES B (id) ON DELETE RESTRICT)" Then it ends with error like SQL error QSqlError("1005", "QMYSQL: Unable to execute query", "Can't create table 'DB.A' (errno: 150)")

    There is workaround - to run createTables many times (or until there is no error 150).

    It would be nice if the createTables() checked for foreign keys first, from these FK dependencies created list of tables in right order and then created those tables.

    opened by topolsky 2
  • Included setBody method to use on WebView and NetworkAccessManager.

    Included setBody method to use on WebView and NetworkAccessManager.

    Hi, I'm working on a desktop application using a WebKit WebView. I'm using QDjangoUrlResolver to deal with routes from WebView requests. I wrote a custom NetworkAccessManager where I translate default QNetworkRequest (and the request body that comes on an QIODevice pointer) to QDjangoHttpRequest, then I invoke QDjangoUrlResolver::respond to do stuff. At the end, I translate QDjangoHttpResponse to QHttpResponse. Thanks, ofrankmartin

    opened by ofrankmartin 2
  • Add support to SQLCipher

    Add support to SQLCipher

    As SQLCipher behave just like an SQLite database and it is possible to create a Qt plugin to use it, I think the only change needed to get support to it is to add it on the list of possible drivers on QDjango::setDatabase(QSqlDatabase). Something like: (...) && database.driverName() != QLatin1String("QSQLCIPHER")) I tested it and the only "issue" is the warning, everything else works like a charm. Here is the SQLCipher Qt Plugin project:

    https://github.com/sijk/qt5-sqlcipher

    opened by ofrankmartin 2
  •  has a many-to-one relationship with itself

    has a many-to-one relationship with itself

    django manual: To create a recursive relationship – an object that has a many-to-one relationship with itself – use models.ForeignKey('self', on_delete=models.CASCADE). How can I implement the function in the qdjango?

    opened by leoiwa 0
  • Added RANDOM as dummy field for random order in queries

    Added RANDOM as dummy field for random order in queries

    I recently needed to use a random ordering of query results. To avoid the call to databaseColumn with a non-existing field I added a special case for using RANDOM as a field name and adding the RANDOM() call to the query.

    opened by adapar 5
  • Bad compiled delete query with inner join for PostrgeSql

    Bad compiled delete query with inner join for PostrgeSql

    When I add a join to the delete operation (like a "table1___column") for postgreSql, an wrong result query is generated. Like this

    DELETE FROM "Table0"
     INNER JOIN "Table1" ON "Table0"."fk" = "Table1"."pk"
     WHERE "Table1"."column" = "something"
    

    Correct query fo this operation like this

    DELETE FROM "Table0"
          USING "Table1"
     WHERE "Table0"."fk" = "Table1"."pk" AND "Table1"."column" = "something"
    
    opened by Sanych33 1
  • Models in namespaces

    Models in namespaces

    Can there be a notation in the QDjangoModel documentation that explains how to use foreign keys when the models are in namespaces?

    It took me quite a while to figure out why

    Q_PROPERTY(Model *model READ model WRITE setModel)
    

    fails (at QDjango::createTables()), and should instead be

    Q_PROPERTY(modelns::Model *model READ model WRITE setModel)
    
    opened by davidmahoney 0
  • Bind Database Connection to certain classes

    Bind Database Connection to certain classes

    Hello Jeremy, we are using QDjango in our project for some time now and it worked well. But now we added another database which stores a different type of data. The problem now is that, as far as I can see, there is only a globally registered database connection. We now have to change this connection in each method that does something with the database. Is there a possibility to bind a connection to certain classes? For example registering a property for the connection in the class that inherits the QDjangoModel class.

    Best Regards, Daniel

    opened by paradoxon82 2
Owner
Jeremy Lainé
Jeremy Lainé
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.

Cutelyst - The Qt Web Framework A Web Framework built on top of Qt, using the simple and elegant approach of Catalyst (Perl) framework. Qt's meta obje

Cutelyst 809 Dec 19, 2022
TreeFrog Framework : High-speed C++ MVC Framework for Web Application

Small but Powerful and Efficient TreeFrog Framework is a high-speed and full-stack web application framework based on C++ and Qt, which supports HTTP

TreeFrog Framework 1.1k Dec 22, 2022
Tntnet is a web application server for web applications written in C++.

Tntnet is a web application server for web applications written in C++.

Tommi Mäkitalo 73 Sep 26, 2022
Drogon: A C++14/17 based HTTP web application framework running on Linux/macOS/Unix/Windows

English | 简体中文 | 繁體中文 Overview Drogon is a C++14/17-based HTTP application framework. Drogon can be used to easily build various types of web applicat

An Tao 8.5k Dec 31, 2022
Crow is very fast and easy to use C++ micro web framework (inspired by Python Flask)

Crow is C++ microframework for web. (inspired by Python Flask) #include "crow.h" int main() { crow::SimpleApp app; CROW_ROUTE(app, "/")([]()

Jaeseung Ha 7k Jan 8, 2023
Your high performance web application C framework

facil.io is a C micro-framework for web applications. facil.io includes: A fast HTTP/1.1 and Websocket static file + application server. Support for c

Bo 1.7k Dec 29, 2022
This is a proof-of-concept of a modern C web-framework that compiles to WASM and is used for building user interfaces.

DanCing Web ?? ?? (DCW) Getting Started Dancing Web is now distributed with the Tarantella Package Manager — a tool I've made to simplify setup of pro

Danilo Chiarlone 3 Sep 11, 2021
CppCMS - High Performance C++ Web Framework

CppCMS - High Performance C++ Web Framework What is CppCMS? CppCMS is a Free High Performance Web Development Framework (not a CMS) aimed at Rapid Web

Artyom Beilis 375 Dec 25, 2022
A high performance, middleware oriented C++14 http web framework please use matt-42/lithium instead

A high performance, middleware oriented C++14 http web framework please use matt-42/lithium instead

Matthieu Garrigues 1.7k Dec 17, 2022
Embedded C/C++ web server

CivetWeb The official home of CivetWeb is https://github.com/civetweb/civetweb Continuous integration for Linux and macOS (Travis CI): Continuous inte

null 2.3k Jan 8, 2023
C library to create simple HTTP servers and Web Applications.

Onion http server library Travis status Coverity status Onion is a C library to create simple HTTP servers and Web Applications. master the developmen

David Moreno Montero 1.9k Dec 31, 2022
A C++11 RESTful web server library

Served Overview Served is a C++ library for building high performance RESTful web servers. Served builds upon Boost.ASIO to provide a simple API for d

Meltwater 696 Dec 28, 2022
cserv is an event-driven and non-blocking web server

cserv is an event-driven and non-blocking web server. It ideally has one worker process per cpu or processor core, and each one is capable of handling thousands of incoming network connections per worker. There is no need to create new threads or processes for each connection.

null 43 Nov 6, 2022
Corvusoft's Restbed framework brings asynchronous RESTful functionality to C++14 applications.

Restbed Restbed is a comprehensive and consistent programming model for building applications that require seamless and secure communication over HTTP

Corvusoft 1.8k Jan 7, 2023
C++ application development framework, to help developers create and deploy applications quickly and simply

ULib - C++ library Travis CI: Coverity Scan: ULib is a highly optimized class framework for writing C++ applications. I wrote this framework as my too

stefano casazza 950 Dec 24, 2022
The application framework for developer module of EdgeGallery platform

crane-framework crane-framework将可复用的计算和软件功能抽象成插件,APP开发者面向使用插件进行MEC APP开发。这样屏蔽了和MEC平台交互的细节,实现MCE APP和MEC平台的松耦合。而且插件框架基础能力可裁剪,按需提供最小的APP系统。 特性介绍 为了方便开发者

EdgeGallery 21 Aug 30, 2021
A http/websocket server framework on linux.

The framework is a Web-Server on unix based system. Without using any third-party libraries, the framework writes from unix system calls and standard C library functions.

xingyuuchen 17 Oct 15, 2022
Pistache is a modern and elegant HTTP and REST framework for C++

Pistache is a modern and elegant HTTP and REST framework for C++. It is entirely written in pure-C++17* and provides a clear and pleasant API.

null 2.8k Jan 4, 2023