Code Monkey home page Code Monkey logo

qdjango's Introduction

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

qdjango's People

Contributors

edwardbetts avatar israelins85 avatar jlaine avatar mbroadst avatar pavleb avatar rohieb avatar swex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qdjango's Issues

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?

setForeignKey doc does not match behavior of the code

The documentation for QDjangoModel::setForeignKey() says it takes ownership of the QObject* value argument, but what the code does is assign value as a property of the model instance, and this is not taking ownership: a QObject does not delete its properties when it is deleted.

I think the code is doing the right thing, but the doc should be fixed.

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)

toString

With

QList<Variant> numbers = {4, 8, 15, 16, 23, 42};
auto s = QDjangoWhere("number", QDjangoWhere::IsIn, numbers).toString();

s is QDjangoWhere(key="number", operation="IsIn", value="", negate=false)
without the numbers (value is empty).

Note: My real problem is to make something similar to QDjangoWhere::sql or a serialize of a QDjangoWhere and I tried to use the toString() for that.

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

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

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.

Unnecessary template usage

I recently started to use QDjango, it's great and works very well !
However, there is one thing which seems not ideal in our context of use : It is nearly impossible to use without template, because of QDjangoQuerySet.
What we aim at is to encapsulate all QDjango access in a single class, which can save, load, delete, all kind of objects in our application. It would be a lot easier if we could just pass/return qobject pointers to these functions without template (for example to connect signals and slots).
I started to modify the QDjangoQuerySet to be template-less, and I have a first version which seems to work. I did not go change the unit tests yet, but I can.
Do you consider it would be worth ? Is there any chance this feature would be merged if i made a pull request ?

Add columns if QDjangoModel changes

Hi,

Right now if you modify a field on your model, you need to delete the table to make it work. The select statements use column names that doesn't exist and fails.

I would like to discuss if you are interested on adding a new feature to regenerate the tables (adding columns) if the model changes.

Basically, in createTable(), if the table exists then check the columns of the table and the fields of the model, if any of the fields is not in the table, alter the table accordingly.

Does it have sense? Otherwise, is there any other method instead of removing the table?

Thanks.

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"

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.