Commit c81f1da1 authored by Luke Plant's avatar Luke Plant
Browse files

[1.1.X] Fixed #6961 - loaddata fails if models is a package instead of a module

  
Thanks to pmd for report, zhaoz, mmalone and justinlilly for patch

Backport of 11914 from trunk.


git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@11918 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent 281114d2
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -76,7 +76,17 @@ class Command(BaseCommand):
        if has_bz2:
            compression_types['bz2'] = bz2.BZ2File

        app_fixtures = [os.path.join(os.path.dirname(app.__file__), 'fixtures') for app in get_apps()]
        app_module_paths = []
        for app in get_apps():
            if hasattr(app, '__path__'):
                # It's a 'models/' subpackage
                for path in app.__path__:
                    app_module_paths.append(path)
            else:
                # It's a models.py module
                app_module_paths.append(app.__file__)

        app_fixtures = [os.path.join(os.path.dirname(path), 'fixtures') for path in app_module_paths]
        for fixture_label in fixture_labels:
            parts = fixture_label.split('.')

+2 −0
Original line number Diff line number Diff line

+18 −0
Original line number Diff line number Diff line
[
    {
        "pk": "2", 
        "model": "fixtures_model_package.article", 
        "fields": {
            "headline": "Poker has no place on ESPN", 
            "pub_date": "2006-06-16 12:00:00"
        }
    }, 
    {
        "pk": "3", 
        "model": "fixtures_model_package.article", 
        "fields": {
            "headline": "Time to reform copyright", 
            "pub_date": "2006-06-16 13:00:00"
        }
    }
]
+18 −0
Original line number Diff line number Diff line
[
    {
        "pk": "3", 
        "model": "fixtures_model_package.article", 
        "fields": {
            "headline": "Copyright is fine the way it is", 
            "pub_date": "2006-06-16 14:00:00"
        }
    }, 
    {
        "pk": "4", 
        "model": "fixtures_model_package.article", 
        "fields": {
            "headline": "Django conquers world!", 
            "pub_date": "2006-06-16 15:00:00"
        }
    }
]
+11 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<django-objects version="1.0">
    <object pk="2" model="fixtures_model_package.article">
        <field type="CharField" name="headline">Poker on TV is great!</field>
        <field type="DateTimeField" name="pub_date">2006-06-16 11:00:00</field>
    </object>
    <object pk="5" model="fixtures_model_package.article">
        <field type="CharField" name="headline">XML identified as leading cause of cancer</field>
        <field type="DateTimeField" name="pub_date">2006-06-16 16:00:00</field>
    </object>
</django-objects>
Loading