Dynamic fixtures?

4 views
Skip to first unread message

gnijholt

unread,
Mar 15, 2007, 4:48:10 AM3/15/07
to Django users
Just watched a co-worker demonstrate fixtures in Django, which worked
fast and flawlessly.
>From what I understand, it takes JSON or XML files, but is it also
possible to do Rails-style dynamic fixtures?
Would be nice to generate a fixture with a few lines of Python instead
of having to extract from an existing database etc.

Thanks in advance.
Gijs

Russell Keith-Magee

unread,
Mar 15, 2007, 6:05:30 AM3/15/07
to django...@googlegroups.com
On 3/15/07, gnijholt <gijs.n...@gmail.com> wrote:
>
> Just watched a co-worker demonstrate fixtures in Django, which worked
> fast and flawlessly.

Thats nice to hear. They're a recent addition, so its good to know
that they are stable and fast under serious use.

> >From what I understand, it takes JSON or XML files, but is it also
> possible to do Rails-style dynamic fixtures?

Django's fixtures framework uses the built-in serialization tools, so
any supported serializer can be used as a fixture format.
Out-of-the-box, this means JSON, XML, YAML (if you have PyYAML
installed), and a Python-based syntax. However, you can also define
your own serializer for some other format, and use that format if you
want.

> Would be nice to generate a fixture with a few lines of Python instead
> of having to extract from an existing database etc.

At present, ERb-style dynamic fixtures are not possible. However, it
is an interesting idea.

I've submitted it as ticket #3735; I'll try to get a discussion
started in the developers forum.

Yours,
Russ Magee %-)

Reply all
Reply to author
Forward
0 new messages