Login

MetaOptions

Author:
haagenti
Posted:
July 13, 2007
Language:
Python
Version:
.96
Score:
1 (after 1 ratings)

A class called MetaOptions that enables decoration of Django models with meta classes in similar style to Admin and Meta.

Included is an example usage to enable CSV export of any set of models.

The package installs into django.contrib.options and is available for download at the Python Cheeseshop

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
### Example:
###
### from django.db import models
### from django.contrib.options import MetaOptions
###
### class ExampleNamedObject(models.Model):
###     class CSV(MetaOptions):
###             separator = ';'
###             format = (
###                     ('name', 'Name'),
###                     ('describe', 'Description'),
###             )
###     name = models.CharField(maxlength=32)
###     def describe(self):
###             return str(self)
###
### from django.contrib.options.csv import csv
### for row in csv(ExampleNamedObject):
###     print row

More like this

  1. Template tag - list punctuation for a list of items by shapiromatron 6 months ago
  2. JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 6 months, 1 week ago
  3. Serializer factory with Django Rest Framework by julio 1 year, 1 month ago
  4. Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 1 month ago
  5. Help text hyperlinks by sa2812 1 year, 2 months ago

Comments

derivin (on July 13, 2007):

Please never install anything into the django tree like that. It means most of us can never use it.

Is there any reason why this is not just a third party app like everyone else writes?

#

Please login first before commenting.