I would really want to add some sort of filtering to that http://img.skitch.com/20091017-mfs2mbhbuudk2rgquium1bu61d.png
On Sat, Oct 17, 2009 at 10:00 PM, Oleg Oltar <[email protected]> wrote: > I tried to do it. It works really nice. > > I wonder how can I query all articles related to the current one in a > view... Need some examples. > > > Also currently I see all articles in a listbox...And as far as I have more > then 200 in the database it's quite hard to select something. Maybe its > possible to arrange some filters to the list? > > > On Sat, Oct 17, 2009 at 7:40 PM, bruno desthuilliers < > [email protected]> wrote: > >> >> >> >> On 17 oct, 17:45, Oleg Oltar <[email protected]> wrote: >> > Hi >> > >> > I am trying to create a model for Article site. I want to link each >> article >> > with 3-5 related articles, so what I am thinking of is creating code >> this >> > way: >> > >> > class Article (models.Model): >> > # Tiny url >> > url = models.CharField(max_length = 30, unique=True) >> > is_published = models.BooleanField() >> > author = models.CharField(max_length = 150) >> > title = models.CharField(max_length = 200) >> > short_description = models.TextField(max_length = 600) >> > body = tinymce_models.HTMLField() >> > related1 = models.ForeignKey(Article) >> > related2 = models.ForeignKey(Article) >> > related3 = models.ForeignKey(Article) >> > >> > But not sure if it's possible to make a foreign key relation to the same >> > model. >> >> It is of course possible, and it's documented here: >> >> >> http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey >> >> But: >> >> >Also if for example, I will decide to bind 6, 7 articles together, >> > how that will work, do I have to write related4, 5, 6....in the model? I >> > want to have more common solution, so if I binding more articles, I >> don't >> > need to redefine code again and again >> >> A very sensible concern !-) >> >> And the solution is obviously to use a many to many relationship - as >> documented here: >> >> http://docs.djangoproject.com/en/dev/ref/models/fields/#manytomanyfield >> >> You'll probably want to make this relationship symetrical (as >> explained in the FineManual). >> >> HTH >> >> >> > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---

