rationalizing everything
I skimmed through the documentation, looking for a way to iterate over the specific fields in a Django model. Seems pretty elementary, right? Google wasn't any help, so I looked into django.db.base.py.
And voila! Just like that, I found what I was looking for:
>>> Post._meta.fields [<django.db.models.fields.AutoField object at 0x86a20cc>, <django.db.models.fields.CharField object at 0x869da8c>, <django.db.models.fields.TextField object at 0x869db0c>, <django.db.models.fields.DateTimeField object at 0x869db2c>, <django.db.models.fields.related.ForeignKey object at 0x869db4c>, <django.db.models.fields.SlugField object at 0x869db6c>] >>> for f in Post._meta.fields: ... print f.attname ... id title body written_at author_id slugObviously, very straightforward.
Well, mostly. To access many-to-many fields, you have to use:
>>> Post._meta.many_to_many [<django.db.models.fields.related.ManyToManyField object at 0x869dc0c>]There's also a virtual_fields list, which I assume has something to do with generic relations and the like:
>>> Post._meta.virtual_fields []
Certainly better than the god-awful hack I found from a couple years ago. *shiver*
*Droooooooooooooooooooooooooooooooooooool*
Gonna play with this tonight if I don't collapse into a sick pile of useless coder. Running a fever and horrific sinus pressure is no way to go through life, Scout.
I'd briefly seen the Django critters thread in passing, whilst perusing the Django Users group.
But after sitting down and reading it, I came across a pretty great story, I suggest you read it. Better yet: one of the images, rendered by Andrew McCloud, is spectacular and particularly Django-esque. So, with permission from the artist, I present to you, the new truedat.org 404. It's purty.
Thanks, Andrew!
Wow. I wondered when this would happen. Expect Pyccuracy tests for truedat.org.
Is it savvier than Cucumber? Probably not. Yet.
Voila!. Sitemaps have been added.
At 12:05 AM on July 2nd, 2009, BaKiNeC commented...
At 4:21 PM on June 29th, 2009, VordEndofop commented...
At 10 AM on May 30th, 2009, Игорь commented...
At 11:09 AM on May 21st, 2009, Ubay Oramas commented...