Hamakor / pycon-israel

updates to Symposion for PyCon Israel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make a way to load fixtures into the site

shaib opened this issue · comments

Basically a view that does loaddata -- which will allow us to prepare data files and load them in without including them in the site sources.

It would be nice if this view can also handle media files.

At some point we want a solution which allows downloading "full data" (including both data and dynamic media) as a backup; if the "upload" solution can just take whatever the "backup" produces, it could be really nice.

the current solution: include in git (under static/src), then use heroku Procfile to make links in ilpycon/site_media.

Can't one simply do:

heroku run python manage.py loaddata the_fixture

Yes, I don't think there's anything left to do here. If anyone disagrees, please reopen.

FTR the method suggested by Meir does not work. Or rather, it only works if you have the fixture on the dyno.

The whole point is that we do not want it in the git repo (e.g. might contain sensitive user data), and it is surpisingly difficult to get data files into the dyno in other ways (most reliable way I found was using netcat with two terminals).

However, there is another way which does work: use local manage.py with heroku's postgresql db:

  • type heroku config to get the connection parameters of the heroku postgresql
  • export DATABASE_URL=...
  • ./manage.py loaddata fixture_name
    very hacky and insecure (must remember to unset the env var when done), but handy...

Really? The PG instance is accessible from outside? That's worrying...

The way to make sure you don't "forget to unset the env var" is not to export it at all:

DATABASE_URL=... ./manage.py loaddata fixture_name