Can you please provide a simple example? 2009/4/21 Andy Mikhailenko <[email protected]>
> > http://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkey > > class Section(Model): > ... > parent = models.ForeignKey('self') > > plus some code to build the string representing the path. > > On Apr 21, 1:30 pm, Oleg Oltar <[email protected]> wrote: > > Hi! > > I am writing an application - a kind of article manager. I defined my > model > > this way: > > > > class Section(models.Model): > > #id = models.IntegerField(unique=True) > > > > section = models.CharField(max_length=200, unique=True) > > name = models.CharField(max_length=200, blank = True) > > > > def __unicode__(self): > > return u"%s" %(self.section) > > > > 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() > > #body = models.TextField(max_length = 10000) > > pub_date = models.DateTimeField('date_published') > > # Image fields > > main_image = models.ImageField(upload_to="upload", blank=True) > > image_description = models.CharField(max_length = 100, > > help_text= u"Строка описания > > картинки: 8-10 слов") > > > > section = models.ForeignKey(Section) > > # SEO > > seo_description = models.TextField(max_length = 300) > > seo_keywords = models.CharField(max_length = 100) > > #comment = models.ForeignKey(Comment) > > > > def get_absolute_url(self): > > return "/article/%s/" % self.url > > > > def __unicode__(self): > > return u"Article: %s" %(self.title) > > > > It allows me to assign articles to different sections. > > > > But now I need to define subsections. How can I do it? > > > > Thanks, > > Oleg > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

