CyberSeed2017 / unf

0 stars 1 forks source link

Fixtures #3

Open MichaelDimmitt opened 7 years ago

MichaelDimmitt commented 7 years ago

https://code.djangoproject.com/wiki/Fixtures

cd smirk pwd; #this is the project
cd unf pwd; #this is the app
vi settings.py
MichaelDimmitt commented 7 years ago

-

MichaelDimmitt commented 7 years ago

path: unf/unf/settings.py

STATIC_URL = '/static/'
import json
FIXTURE_DIRS = (
           '/Users/michaeldimmitt/new_h/todays_works_sat/unf/unf/fixtures/',
           '/Users/michaeldimmitt/new_h/todays_works_sat/unf/smirk/fixtures/',
    )
MichaelDimmitt commented 7 years ago

succeeded in getting the database to dump the information:

python manage.py dumpdata --format=json smirk > /Users/michaeldimmitt/new_h/todays_works_sat/unf/unf/fixtures/initial_data.json

MichaelDimmitt commented 7 years ago

???

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}
MichaelDimmitt commented 7 years ago

http://racingtadpole.com/blog/django-fixtures-to-copy-database/

./manage.py dumpdata --indent 2 > all.json;
./manage.py loaddata all.json;
ahmsayat commented 7 years ago

@MichaelDimmitt

???

replace that with the below only in the docker since docker has mariadb:

DATABASES = {
    'default': {
    'ENGINE':'django.db.backends.mysql',
    'NAME':'myproject',
    'USER':'student',
    'PASSWORD':'ask_mike',
    'HOST':'localhost',
    'PORT':'',
    }
}
MichaelDimmitt commented 7 years ago

~python manage.py dumpdata -e contenttypes >dumpdata/debug-e.json~

MichaelDimmitt commented 7 years ago

https://stackoverflow.com/questions/853796/problems-with-contenttypes-when-loading-a-fixture-in-django

manage.py dumpdata --natural --indent=4

or
./manage.py dumpdata --exclude contenttypes > fixture.json
MichaelDimmitt commented 7 years ago

python manage.py dumpdata --format=xml smirk > fixtures/xml_info.xml