views:

40

answers:

1

I have a 3 - 4000 nodes in a drupal 6 installation on mysql and want to access these data through my django application. I have used manage.py inspectdb to get a skeleton of a model structure. I guess that there are good/historical reasons for drupal's database schemes, but find that there are some hard to understand structure and that there are some challenges in applying django models on the database. Some experiences this far are:

  • node and node revision are intertwined and I solved this by using a OneToOneField (don't need the versions). This meens that the node's body gets accessible through node.vid.body, but it works.
  • Foreign keys need to define the proper db_column to sort out the primary keys.
  • Terms need to use an intermediary table with ManyToManyField.through.
  • Drupal stores both the original and the thumbnailed/resized versions of any image as files in the files table.

Does anyone have experiences in accessing drupal data in django?

  • Are there better solution to for example the node <-> node revision relationship?
  • Drupal stores time/dates as unix-style timestamps in integerfields. Any recommendations? How about time zones?
+1  A: 

How will you make node and revisions to a OneToOne relation, when a node can have several revisions. It might be convenient/possible now, but can give you problems later.

You should make a Manager or method to access the the latest revision of the body instead.

The problem when dealing with timestamps, is always, that the timezone information is gone. If you want that info you will need to get it from the Drupal server. If you use the same timezone though, it shouldn't be a problem unless you need the times to be very specific.

googletorp
I agree that my OneToOne isn't the prettiest. For my specific use case, I don't use the revisions feature and the nid and the vid always are parallell.
Hans