Snippet List
Just like it says -- set it up and run. Use it for server migrations, for project handoffs, in cron jobs, you name it.
I have never had problems exporting models to individual fixtures in this way, and only one bout of trouble re-importing them (and that was, like, an impossible-triangle of OneToOneField dependencies anyway, and they were going from a sqlite file to a postgres schema that totally had inappropriate nullable columns in it). I find that the json files named for what they contain is helpful when and if manage.py does freak out during an import, as the output from `loaddata` command is so opaque it's autistic, basically.
A trivial refactoring effort could make it into a management command -- it already makes use of the builtin `dumpdata` command class internally. However I did not feel like overthinking it enough to set it up in a repository (doubtlessly padded with unrelated 'utilities' and explanatory .rst files) and then writing a blog post to sell it to you. That is why you are reading this code here, instead of on GitHub.
Don't get me wrong, GitHub is awesome, and like a consummate host... but not the way I love me some quick and dirty snippet code, these days. Whatever, you say lazy, I say productively relaxed, potato/potahto.
Erm. In any case please do enjoy this model fixture-exporter. Yes.
- django
- python
- json
- export
- data
- script
- command
- archive
- django1.1
- backup
- datestamp
- tar
- tarball
I tried to think of a way to use generic views to show all my blog posts on one page organized chronologically with each post title under one month name and all the month names under one year name.
Like so:
`
2009
October
My last example blog entry
Entry even before the last one
First of October
September
Only one entry in Sept.
2008
December
It is cold in December
First posting of my blog
`
I could not think of a way to do this using generic views, before I wrote a view and some template logic that does.
The template logic is here:
[http://www.djangosnippets.org/snippets/1765/](http://www.djangosnippets.org/snippets/1765/)
Any suggestions for design patterns are greatly appreciated.
I tried to think of a way to use generic views to show all my blog posts on one page organized chronologically with each post title under one month name and all the month names under one year name.
Like so:
`
2009
October
My last example blog entry
Entry even before the last one
First of October
September
Only one entry in Sept.
2008
December
It is cold in December
First posting of my blog
`
I could not think of a way to do this using generic views, before I wrote a view and some template logic that does.
The view code is here:
[http://www.djangosnippets.org/snippets/1766/](http://www.djangosnippets.org/snippets/1766/)
Any suggestions for design patterns are greatly appreciated.
### Simple wiki with MediaWiki and Markdown Support
Once you install the mwlib you can use mwit to convert Mediawiki markup to HTML. I am include the model that uses it to hopefully provide a good example. I maintain a version and only one copy of each wiki entry in the main table and archive replaced markup into another table, you will need to create the archive model or remove that section of code. The line ending changes in mwit are so that it will work with IE.
- markup
- markdown
- mediawiki
- wiki
- archive
5 snippets posted so far.