heya,
We're creating a small app to manage data-entry of publicat articles
in Django.
Each article has a category, a subject, a list of firms (as in the
companies mentioned), etc.
I'm trying to add firm as an inline to article, however, I think I've
got the ordered in the model all wrong, as it's telling me:
<class 'mediatracking.articles.models.Category'> has no ForeignKey to
<class 'mediatracking.articles.models.Article'>
Basically, each article can have one category, but there's obviously
many articles to each category.
An excerpt from models.py:
class Category(models.Model):
name = models.CharField(max_length=25)
def __unicode__(self):
return self.name
class Meta:
verbose_name_plural = "categories"
....
class Article(models.Model):
title = models.CharField(max_length=50)
publication_date = models.DateField()
abstract = models.TextField() # Can we restrict this to 450
characters?
category = models.ForeignKey(Category)
subject = models.ForeignKey(Subject)
source = models.ForeignKey(Publication)
page_number = models.CharField(max_length=20)
url = models.URLField()
firm = models.ManyToManyField(Firm)
#firm = models.ForeignKey(Firm)
spokesperson = models.ManyToManyField(Spokeperson)
#spokesperson = models.ForeignKey(Spokeperson)
And admin.py:
class CategoryInline(admin.TabularInline):
model = Category
...
class ArticleAdmin(admin.ModelAdmin):
inlines = [
CategoryInline,
]
...
admin.site.register(Article, ArticleAdmin)
Also, I noticed that dajngo-command-extensions, using the graph_models
command, it seems to ignore m2m relationships. It's really weird.
http://github.com/django-extensions/django-extensions/issues#issue/6
Has anybody else noticed something similar? Were there any major
changes to Django's m2m base recently?
Cheers,
Victor
--
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.