Hi, I think what you're trying to accomplish is more or less what django-tagging [http://code.google.com/p/django-tagging/] does, so I suggest looking at its source code.
HTH, Nuno On Sun, May 9, 2010 at 11:24 PM, Nick Taylor <nicktaylor1...@googlemail.com> wrote: > Hi all, > > I want to create my own "field" type for a model, this essentially > will be a relationship to another model via a generic link model > (using GenericForeignKey etc). > > As en example I basically want to do the following in models.py: > > class Pizza(models.Model): > toppings = IngredientsField() > > Which can then be reused in another app sandwiches/models.py as: > > class Sandwich(models.Model) > filling = IngredientsField() > > Where I use a IngredientsField() field type which then controls the > links as a separate set of models Ingredients and IngredientItems. > > Now I have created in fields.py: > > class IngredientsField(CharField): > def __init__(self, *args, **kwargs): > ...... > > However I get an "Unknown column 'pizza_pizza.toppings' in 'field > list'" error - BUT I don't want to add it as a column in toppings as I > want it to be linked via the link table/model IngredientItems. > Eventually what I want to achieve is while using the admin system for > certain models that you manage there will be a text box where you can > enter ingredients into a TextField in the admin comma delimited > "Cheese, Ham" and then the model take care of the rest. > > Hopefully I'm pretty close, any ideas anyone? > > Thanks in advance, > > Nick > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.