Recent entries:

Tags:

Django Documentation and Hindsight (of the 20/20 sort)

Monday, March 10th

If you're one of the three people that has ever taken a look at vcBlog, you probably realize that there's about six posts missing. Like I alluded to in the first 0.2 post, they went missing in the course of MySQL surgery necessary as a result of adding another model to my application--specifically, one with a many-to-many field. An entry has multiple tags, a tag can be applied to multiple entries, so... Anyway, those entries that have gone missing could all have been sitting in a pretty JSON file, had I used manage.py's dumpdata function. In fact they could have been sitting in a pretty file in any one of four formats.

The surgery itself could also have been a lot easier on me, had I used the sql- commands, which print out what Django would do if it had to create my database tables from my models.py file. I would then (ideally) have compared that to the status quo and made the changes myself. Sadly, manage.py's magical syncdb function only creates new tables--it does not modify existing ones. The django documentation justifies this:

Changes to model classes and database schemas often involve some form of ambiguity and, in those cases, Django would have to guess at the correct changes to make. There is a risk that critical data would be lost in the process.

If you haven't gotten the point of this all yet, it's this: RTFM. Or, in Django's case, RTFDocumentation. It's wiser than hacking around because it's written by people who have learned better than to hack around. And wouldn't we all like to learn better?

EDIT: Lamenting my lack of readership, I decided to check out Google's webmaster tools to see how crawling etc. was going. I realized that after 0.2, the meta tag used to verify me as vcBlog.shareyourgifts.net's owner had disappeared in a one of the dumps to dev. After resurrecting it, I poked around and found that a bunch of the missing entries were actually still cached! Glory, hallelujah! They'll be back up when I get a chance to copy them in--a painful process, as vcBlog does not love markup in entries.. yet. Praises to the Palo Alto superheroes.

Tags: Django, MySQL, Google

Comments:

Add a new comment:

Theme: Prof (default) | Corn | Simple Admin: Log in