I want to have a models.py like this,

class PageRevision(models.Model):
    """Stores a specific revision of the page"""
    text = models.TextField()
    revision_for = models.ForeignKey(Page, related_name =
'revision_for')

class Page(models.Model):
    """Stores the latest page, the page which needs to be displayed to
the user."""
    title = models.SlugField(unique = True, max_length = 100)
    current_revision = models.ForeignKey(PageRevision, related_name =
'main')
    current_disc_rev =  models.ForeignKey(PageRevision, related_name =
'discussion', blank = True, null = True)

This line gives me an error,
revision_for = models.ForeignKey(Page, related_name = 'revision_for')
as NameError: name 'Page' is not defined, obviously because page is
defined later in the file. I can not put PageRevision later as Page
class refers to that. How can I acieve this?
(I need this type of model as PageREvision is a detail table for Page,
so it needs to have a Foreign key to Page. But page also needs to keep
track of its latest revision, and so needs a foreign key to
PageREvision! I guess I can achieve what I want to do by having two
boolen fields in PageRevision to track its latest status, but this
seems a cleaner model.)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to