On 8/14/07, Todd O'Bryan <[EMAIL PROTECTED]> wrote: > > The only permanent solution I can think of would be to introduce some > > sort of query language into the fixtures, which is a road I'd rather > > not travel down. Any other suggestions are welcome. > > That's something I hadn't thought of, but do you run into trouble > because Django creates the content-types itself and then you try to load > yours afterward? I was getting weird errors and discovered that the way > to solve the problem was to *not* dumpdata auth or any other of Django's > own apps.
If you overwrite Django's content types with a new set that don't match, then yes - you will experience problems. To my understanding, content-type creation order _should_ be predictable - applications are installed in the same order, models should be synchronized in the same order, and the post_syncdb calls should be triggered in the same order. However, there will be more than one dictionary involved in the process, so it is very much possible that this isn't the case. If you can provide a test case (which will be difficult if the problem is dictionary order), it would be most helpful. > Here's something I considered. What if fixtures were a Python module > instead of just a folder and you could include a function as part of a > fixture. For example, in addition to test.json, I could include a > function called test in fixtures/__init__.py that added stuff to the > database using the ORM. Most things would still be done through > serialization, because it's so handy, but generic relations and > permissions and such could be set with a few lines of Python code. Does > that seem like too big a hammer for such a small nail? Originally I thought about this, too, but then Malcolm hit me with the obvious point - you can already do this. It's the setUp method on a TestCase. Put whatever code you want as a 'fixture' as a test method, wherever it is convenient, and call your fixture method in the setUp for your TestCase. Yours, Russ Magee %-) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---