Answer the question
In order to leave comments, you need to log in
How to get records from db where category = category?
class Razdely (models.Model):
title = models.CharField(verbose_name=_('Заголовок'), max_length=256, null=True, blank=True)
alias = models.CharField(verbose_name=_('Алиас'), max_length=256, null=True, blank=True)
def __unicode__(self):
return self.title
class Meta:
verbose_name = _('Categories')
verbose_name_plural = _('Разделы')
class Classifieds (models.Model):
title = models.CharField(verbose_name=_('Заголовок'), max_length=256)
description = models.TextField(verbose_name=('Содержание'))
image = models.FileField(verbose_name=_('Изображение'), upload_to='Classifieds', null=True, blank=True)
phone = models.CharField(verbose_name=_('Телефон'), max_length=256, null=True, blank=True)
category = models.ForeignKey(Razdely, verbose_name=_('Категория'), null=True, blank=True)
created_at = models.DateTimeField(verbose_name=('Date create'), auto_now_add=True)
user_id = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name=_('User'), related_name='users')
def __unicode__(self):
return self.title
class Meta:
verbose_name = _('Classifieds')
verbose_name_plural = _('Объявления')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question