best practices for GenericForeignKeys in reusable apps

35 views
Skip to first unread message

bobhaugen

unread,
Nov 20, 2008, 12:06:57 PM11/20/08
to django-hotclub
This is for http://code.google.com/p/django-attachments/
which I will soon incubate at http://code.google.com/p/pinax-cohousing/

Also previously announced in this group in this thread:
http://groups.google.com/group/django-hotclub/browse_thread/thread/467e910045df5848

I'm looking for good reusable apps to emulate, that link to domain
objects using GenericForeignKeys.

Also trying to enumerate the components, classes, methods, template
tags, templates, etc. involved in a good solution.

Where good = simple, clean, and encapsulated in reusable app, so
reusers need to do minimal work.
And of course those criteria may conflict with each other...

In #django-hotclub IRC, Kellen`suggested contrib.comments.
I'm also looking at django-threadedcomments, especially as
incorporated into pinax.

So that's apps-to-emulate. Anything better or interestingly different
in approach?

Elements of a good solution:
* GenericForeignKey, of course.
* Custom Manager?
* some urlpatterns and views
* template tags
* template components for inclusion, a la /pinax/projects/
complete_project/templates/threadedcomments/comments.html

Anything else?

(In case it ain't clear, I am also trying to learn GenericForeignKeys
during this project...)

Nicola Larosa

unread,
Nov 20, 2008, 12:31:42 PM11/20/08
to django-...@googlegroups.com
bobhaugen wrote:
> So that's apps-to-emulate. Anything better or interestingly different
> in approach?

django-tagging, I'd say.

--
Nicola Larosa - http://www.tekNico.net/

A common science fiction trope involves aliens intercepting our
television shows and being so impressed that they use it as a basis
for their entire civilization. That's pretty egotistical. Even human
beings don't base their entire lives on one long-defunct television
show. Well, except for Firefly fans. - Lore Sjöberg, June 2008

bobhaugen

unread,
Nov 20, 2008, 1:34:48 PM11/20/08
to django-hotclub
On Nov 20, 11:31 am, Nicola Larosa <nicola.lar...@gmail.com> wrote:
> bobhaugen wrote:
> > So that's apps-to-emulate. Anything better or interestingly different
> > in approach?
>
> django-tagging, I'd say.

That was one of the apps I started out to look at, but all the Pinax
apps that use tags seem to add TagField to their domain models. And I
don't think attachments should require domain model changes.

Any other reason I should continue to look at django-tagging for ideas?

Eric Drechsel

unread,
Nov 21, 2008, 5:34:31 AM11/21/08
to django-hotclub
django-tagging works without modifying the model: just call
tagging.register(YourModel)

The TagField adds some helper methods, adds a field to ModelForm
forms, etc I believe. Look at http://django-tagging.googlecode.com/svn/trunk/docs/overview.txt

bobhaugen

unread,
Nov 21, 2008, 6:24:33 AM11/21/08
to django-hotclub
On Nov 21, 4:34 am, Eric Drechsel <ericd...@gmail.com> wrote:
> django-tagging works without modifying the model: just call
> tagging.register(YourModel)

Thanks, I did not know that. I'll check it out again.

Doc says that feature is new, so maybe was not available when the
Pinax gang started to use it.
Reply all
Reply to author
Forward
0 new messages