Created
January 10, 2010 22:06
-
-
Save alexcabrera/273815 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# My app will start with creating a generic relationship with any object that notifies it of an update | |
from django.db import models | |
from django.contrib.contenttypes.models import ContentType | |
from django.contrib.contenttypes import generic | |
class ActivityStreamItem(models.Model): | |
actor = models.ForeignKey("... want to populate from another model's inner class ...") | |
content_type = models.ForeignKey(ContentType) | |
object_id = models.PositiveIntegerField() | |
content_object = generic.GenericForeignKey('content_type', 'object_id') | |
# I'd like to make it as easy as possible to integrate with existing apps and models. | |
# So, ideally it would just require the developer to add an inner class to their models the same way | |
# django-imagekit handles spec files | |
from django.db import models | |
from django.contrib.auth.models import User | |
class BlogEntry(models.Model): | |
title = models.CharField(max_length=80) | |
body = models.TextField() | |
author = models.ForeignKey(User, related_name = 'blog_author') | |
class NotifyStream(self): | |
title = self.title | |
actor = self.author | |
# So, in my app's model, how do I a.) know that an event has occurred in the hypothetical blog app, | |
# and b.) access the inner class from my app's model? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment