[Python Edinburgh] using django to create db for app?

Philip Hunt cabalamat at gmail.com
Thu Jan 26 03:57:52 CET 2012


On 25 January 2012 19:44, Alex Bird <alex at alexbird.co.uk> wrote:
> Oh, right, neither in fact!
>
> I was simply wanting to use django as the admin interface for creating a
> static (though I guess it needn't be) database which lives in the app.

That's eminently doable: you use Django's ORM to define the database
and then the admin interface to populate it.

This then produces an sqlite file which (I presume but haven't
checked) is portable between sqlite installations.

> The
> file could be part of the app bundle and/or a download.  Of course not all
> apps need to keep much data, or can because it needs to be updated, but for
> some this is a key part.  There's no reason, in principle, why this database
> couldn't also back a webservice or website, but sqlite3 probably wouldn't be
> your first choice for that.

If your database is small you may want to just use a flat ascii file,
or python data statements like this:

data = [
   ["Fred Blogs", "123 Acacia Avenue", "EH12 1RS"],
   ...etc... ]

which can then very easily be transformed into whatever data format you like.


More information about the Edinburgh mailing list