heya,

Just to clarify.

My understanding is that the FK should be on Articles, since that's
the many side of the many-to-one, and also the "child" in a sense.

However, I still wanted some way of creating categories on the "Add
Article" page - is there a way of doing inlines here, and having the
"Add Firm" embedded on that page (without having to open a new
window), or should I reverse the way my FK is?

Cheers,
Victor

On Apr 15, 3:58 pm, Victor Hooi <victorh...@gmail.com> wrote:
> 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 django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to