I have started to read the django book and i could make it work with firebird without issues
Bellow are the instructions for Chapter 2 : Getting started
Install django using pip
pip install django
check django version from python console
>>> import django
>>> django.VERSION
(1, 5, x, 'final', 0)
pip install django-firebird
create a new project
django-admin.py startproject wordpress_clone
cd wordpress_clone
python manage.py runserver
load in browser http://localhost:8000
Step 02 completed , we now should do the step 03
http://djangobook.com/en/2.0/chapter03/
Chapter 3 is quite easy to read mainly hello world application here is the screenshot
after finising it (no modifications needed or related to firebird)
Chapter 04 is only related to templates so no modifications needed related to firebird.Chapter 3 is quite easy to read mainly hello world application here is the screenshot
after finising it (no modifications needed or related to firebird)
So we reached chapter 05 the db and the The MTV Development Pattern (Beavis and Butthead pattern maybe )
http://djangobook.com/en/2.0/chapter05/
In a way i like the Dumb pattern ViewController
Only the View and the Controller and The Model is in database anyway (triggers/rules/procedures and business logic)
I have created an empty database in /var/lib/firebird/2.5/data/firedjango.fdb
with flamerobin
Ok so the the shell worked with my firebird db config in settings.py
$python manage.py shell
>>> from django.db import connection
>>> cursor = connection.cursor()
So the next thing was to create the models and generate the db
$ python manage.py validate
$ python manage.py sqlall books
and here is the output
After that sync worked
$ python manage.py syncdb
import md5
Creating table books_publisher
Creating table books_book
Creating table books_author
Installing index for books.Book model
$ python manage.py shell
(InteractiveConsole)
>>> from books.models import Publisher
>>> p1 = Publisher(name='Apress', address='2855 Telegraph Avenue',
... city='Berkeley', state_province='CA', country='U.S.A.',
... website='http://www.apress.com/')
>>> p1.save()
>>> p2 = Publisher(name="O'Reilly", address='10 Fawcett St.',
... city='Cambridge', state_province='MA', country='U.S.A.',
... website='http://www.oreilly.com/')
>>> p2.save()
>>> publisher_list = Publisher.objects.all()
>>> publisher_list
[
after i have added the _unicode method
$ python manage.py shell
>>> from books.models import Publisher
>>> publisher_list = Publisher.objects.all()
>>> publisher_list
[<Publisher: Apress>, <Publisher: O'Reilly>]
8 comments:
I have tried to use your changes with Firebird 1.5. I don't know which veresions of Firebird should work.
Apart form hard-coding in the base module I do not see how to specify that you do not wan to use the mx date routines.
When you use syncdb it put the table names and fieldnames in quotes which errors with my version of firebird.
If I can do anytong to help you please let me know.
Hello , i have tested with latest firebird 2.1 stable (2.1.3) , i think is better to install that version to begin with
Thanks for repling os quickly.
I have now installed that version, but still get this error with syncdb
kinterbasdb.DatabaseError: Execute query error. FB error No. -104
isc_dsql_prepare:
Dynamic SQL Error
SQL error code = -104
Token unknown - line 1, column 14
"AUTH_PERMISSION"
Query:
CREATE TABLE "AUTH_PERMISSION" (
"ID" integer NOT NULL PRIMARY KEY,
"NAME" varchar(50) NOT NULL,
"CONTENT_TYPE_ID" integer NOT NULL,
"CODENAME" varchar(100) NOT NULL,
UNIQUE ("CONTENT_TYPE_ID", "CODENAME")
)
;
I think it is because of the quotes?
did you created the database with dialect 3
Maybe you need to create the database from scratch with flamerobin and to be done with new firebird 2.1.x server
also i guess you have installed the latest kinterbasdb 3.3.0
http://www.firebirdsql.org/index.php?op=devel&sub=python
I am using kinterbasdb3.2 which comes with the firebird on ubuntu.
How do you set the dialect in django settings?
i didn't set any dialect i was just thinking that might be the issue
I guess you need to remove the old kinterbasdb
and install 3.3.0
http://mapopa.blogspot.com/2009/02/firebird-python-howto-on-ubuntu-wget.html
I can't make it work, I get django.core.exceptions.ImproperlyConfigured: 'firebird' isn't an available database backend. error, I use
-Linux Mint.
-django 1.7
-python 2.7
-firebird 2.5.
-django-firebird 1.6.4
I don't know if I have to do an other configuration in my computer, like put a path to firebird or something, Firebird works perfect alone and with python, but I have that error when I try to use it with Django.
DATABASES = {
'default': {
'ENGINE': 'firebird',
'NAME': '/var/lib/firebird/2.5/data/first_database.fdb',
'USER': 'SYSDBA', # Your db user
'PASSWORD': '*********', # db user password
'HOST': '127.0.0.1', # Your host machine
'PORT': '3050', # If is empty, use default 3050
}
}
you need to use django 1.6.x
django 1.7 support is in alpha state in the driver , you can test with git version
but i recommend to use 1.6.x with django 1.6.x
https://github.com/maxirobaina/django-firebird/commits/develop
Post a Comment