Django without database

2,999 views
Skip to first unread message

Anja

unread,
May 12, 2006, 6:44:40 AM5/12/06
to Django users
Hi,
we are thinking about creating a small application with Django and
deliver it to our customers.
We would like to use Django without a database.
Reason:
1) Installation without database is easier
2) Our small application won't use a database, but our own search
engine that has a python api.

I tried to get the built-in web server running without database, but
did not succeed.
I modified settings.py, DATABASE_ENGINE = ''
But this did not work.
Any ideas?
Thanks Anja

Vladimir Pouzanov

unread,
May 12, 2006, 6:47:15 AM5/12/06
to django...@googlegroups.com
You can use sqlite, fast and easy db interface.


--
Sincerely,
Vladimir "Farcaller" Pouzanov
http://www.hackndev.com

Alexandre CONRAD

unread,
May 12, 2006, 6:54:25 AM5/12/06
to django...@googlegroups.com
Can django run without a DB ?

--
Alexandre CONRAD

Peter Ma

unread,
May 12, 2006, 6:56:57 AM5/12/06
to django...@googlegroups.com
can Django's database-roadmap add XML or CSV ./etc


--
www.mawei.name
Petit
IM&mail:mawe...@gmail.com
13585201588

Peter Ma

unread,
May 12, 2006, 6:58:46 AM5/12/06
to django...@googlegroups.com
I think django has automatic CRUD method to any DB object,
So, without DB maybe so diffcult on It's archieve .

dr.v...@laposte.net

unread,
May 12, 2006, 7:24:49 AM5/12/06
to django-users
Django makes use of a database backend for authentication,
sessions and so on. I would also advise you to look at sqlite
(http://www.sqlite.org/whentouse.html).

No specific installation except the sqlite shared libraries,
and the python bindings (http://initd.org/tracker/pysqlite).

Do you have any reason for not using sqlite?

Accédez au courrier électronique de La Poste : www.laposte.net ;
3615 LAPOSTENET (0,34 €/mn) ; tél : 08 92 68 13 50 (0,34€/mn)

Malcolm Tredinnick

unread,
May 12, 2006, 7:36:31 AM5/12/06
to django...@googlegroups.com
Hi Anja,

In the latest source code, have a look in the examples directory. There
is a little "hello" application in there that uses the views and
templates without using a database at all. That has a very minimal
settings file as well (so short, I can paste it in full):

# Django settings for the example project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG
ROOT_URLCONF = 'examples.urls'

You can run that in place to see what happens by setting your PYTHONPATH
to the directory above examples/ and then running "python manage.py
runserver" and it should work (it did for me when I tried it just now).
So if you can get that example running, customising for your own
purposes should be relatively simple.

Regards,
Malcolm


Anja

unread,
May 12, 2006, 7:59:25 AM5/12/06
to Django users
Reason for not using sqlite or not using any database:
1) My application does not need a database, it stores the data in the
indexes of a search engine.
2) We would like to deliver that application to some customers. The
easier the installation the better. The more steps an installation has
the more error can occur.
Regards Anja

Adrian Holovaty

unread,
May 12, 2006, 10:51:03 AM5/12/06
to django...@googlegroups.com
On 5/12/06, Alexandre CONRAD <aconr...@magic.fr> wrote:
> Can django run without a DB ?

Yes, you can use Django without a DB, in the latest development
version (trunk). A database connection is required in 0.90 and 0.91,
but removing that dependency is one of the many, many improvements we
made in the magic-removal branch, which is now the new development
version.

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com

Karl Fast

unread,
May 12, 2006, 11:28:06 AM5/12/06
to Django users
Can anyone point me to examples of django apps that either do not use
a database, or use it for only part of the app? Looking for source.

I'm specifically interested in examples with models that use other
persistence backends (like a config file), and the associated
views and templates.

Jeremy Dunck

unread,
May 12, 2006, 11:41:42 AM5/12/06
to django...@googlegroups.com

If you want to do that, you may want to write a model backend which
complies with DBAPI, I think. The models stuff is pretty compelling
and you'll reinvent a big wheel if you have a somewhat complex non-RDB
data store without the models to back it.

Adrian Holovaty

unread,
May 13, 2006, 1:54:35 AM5/13/06
to django...@googlegroups.com
On 5/12/06, Karl Fast <karl...@gmail.com> wrote:

As Malcolm pointed out earlier in this thread, the latest Django trunk
comes with an "examples" directory that contains a few example views
that don't use the database.

It's almost absurd to have to explain this -- if you want to use
Django without a database, uh, just don't use any models! :) It's the
same basic premise as: If you want to make a Web page that doesn't
display blinking bright-red text, don't use blinking bright-red text.
If you don't want to receive a letter from yourself in the mail, don't
send yourself a letter in the mail. :)

Facundo Casco

unread,
May 13, 2006, 1:29:17 PM5/13/06
to django...@googlegroups.com
On 5/12/06, Karl Fast <karl...@gmail.com> wrote:
>> Can anyone point me to examples of django apps that either do not use
>> a database, or use it for only part of the app? Looking for source.
>>
>> I'm specifically interested in examples with models that use other
>> persistence backends (like a config file), and the associated
>> views and templates.
>>
Hi, I'm new to Django and Python. What I'm trying to do right now is a
Django powered webapp to display information stored on a DBF database. I
use the template system and everything but the database backend. So far
I only have very basic functionality but I don't see any problem, just
don't use the models (or put only what you need in them) and the rest
works just fine.

Facundo

facundo.vcf

Bill de hÓra

unread,
May 14, 2006, 6:05:11 PM5/14/06
to django...@googlegroups.com

My first cut with django used RDF files for data (this is ancien code,
django has changed since then):

[[[
from django.core import template_loader
from django.core.extensions import DjangoContext
from django.utils.httpwrappers import HttpResponse
from django.core import formfields
from rdflib.StringInputSource import StringInputSource
import time
from mobius.apps.contacts.models import contacts
from mobius import About

def index(request):
contacts_list = contacts.get_contacts()
contacts_list.sort(sortCodes)
date = time.ctime()
t = template_loader.get_template('contacts/index')
about = About()
c = DjangoContext(request, {
'contacts_list': contacts_list,
'date': date,
'pmr': about,
})
return HttpResponse(t.render(c))
]]]


get_contacts looked like this (rdflib with sparta):

[[[
def get_contacts():
store, schema_store = TripleStore(), TripleStore()
ds = DataStore()
ds.loadData(CONTACTS_HOME, store)
f = open(PMR_SCHEMA_LOC)
rdfxml= "".join(f.readlines())
f.close()
schema_store.parse(StringInputSource(rdfxml))
Thing = ThingFactory(store, schema_store)
gen = ds.findContactGenerators(store)
summaries = ds.loadContacts(gen, Thing, store)
return summaries
]]]

For models and admin usage your storage will need to meet the DBAPI
contract. I think it can be done, but with considerable effort. I think
I'd wonder why bother tho' - the main reason I cna think of is for the
CMS case where users can create

cheers
Bill

Bill de hÓra

unread,
May 14, 2006, 6:08:22 PM5/14/06
to django...@googlegroups.com
Bill de hÓra wrote:

> For models and admin usage your storage will need to meet the DBAPI
> contract. I think it can be done, but with considerable effort. I think
> I'd wonder why bother tho' - the main reason I cna think of is for the
> CMS case where users can create

...arbitrary content types (ie autogenerated models). That would be
either table-on-demand or some uber-content-model (a la RDF/CMF/Archetypes)

cheers
Bill

Reply all
Reply to author
Forward
0 new messages