views:

55

answers:

1

Hello everybody

I am building a news app for my website. I want to use a sort of tag system. Each news article can have different and multiple tags. All tags are saved in a tag model, and i want to connect the tags to the newsarticle. Now is this possible with: tags = models.ForeignKey( TagsModel ) for one tag, but how i can do this with multiple of them?

Thank you!

+2  A: 

Use django tagging.

In your model you do: tags = TagField() and presto, you have tags that behave like you expect. The app also comes with several niceties to perform common tasks. e.g. parse input into tags or output the tags in templates.

In general, though, you can have ManyToMany fields like so:

some_things = models.ManyToManyField(OtherModel)

here are the docs for that. You can have multiple ManyToManyFields in a single model, you just need to specify related names.

rz
thanks for your answer, but i want to make it 100% my one. so this is no option...
Tom
your awnser in your edit is good!!! thank you!
Tom