This TypeError message always baffles me and is hard to debug.  I'm
using SVN 6962 which means I should probably upgrade, but I tried that
a month or so ago around query-set-refactor merge and things were
unhappy so decided to wait.

TypeError: Cannot resolve keyword 'presentation' into field. Choices
are: groups, user_permissions, tutorial, forum_post_set, subscription,
logentry, application, ...

Here's two stack traces that cause the problem:

http://dpaste.com/57816/
http://dpaste.com/57701/

Here's the patch that causes both of them, very odd:

Index: /workshops/models.py
===================================================================
--- /workshops/models.py (revision 967)
+++ /workshops/models.py (revision 1015)
@@ -1217,11 +1217,20 @@
         return dir_choices

+    def get_member_pks():
+        """
+        Return unique list of user id's that are staff or have been
accepted.
+        """
+        dict={}
+        for u in User.objects.filter(is_staff=True):
+            dict[u.pk]=True
+        for u in
User.objects.filter(application__status=Application.ACCEPTED_STATUS):
+            dict[u.pk]=True
+        return dict.keys()
+
     workshop = models.ForeignKey(Workshop)
     members = models.ManyToManyField(
                 User,
-                limit_choices_to={
-                    'application__status' :
Application.ACCEPTED_STATUS,
-                },
-                help_text="This list is limited to people accepted in
a workshop. ",
+                limit_choices_to= {'pk__in': get_member_pks()},
+                help_text="This list is limited to people accepted in
a workshop or staff. ",
                 filter_interface=models.HORIZONTAL,
     )

Here's the model the patch applies to:

class Project(models.Model):

    def get_dir_choices():
        """
        returns a tuple of tuples of directories for use with choices
in a
        selectfield.
        """
        import os
        import re
        dir_choices = []
        # only go 4 dirs deep from project_static_root
        match1 = re.compile('^[^/]+/[^/]+/[^/]+/[^/]+$')
        match2 = re.compile('^[^/]+/[^/]+/[^/]+$')
        for root, dirs, files in
os.walk(settings.PROJECT_STATIC_ROOT):
            for d in dirs:
                d = os.path.join(root, d)
                d = d.replace(settings.PROJECT_STATIC_ROOT, "", 1)
                # relative path is stored in DB
                if re.search(match1, d) or re.search(match2, d):
                    # check for index.html
                    if os.path.isfile(settings.PROJECT_STATIC_ROOT+d
+os.path.sep+'index.html'):
                        dir_choices.append((d, d))
        return dir_choices

    def get_member_pks():
        """
        Return unique list of user id's that are staff or have been
accepted.
        """
        dict={}
        for u in User.objects.filter(is_staff=True):
            dict[u.pk]=True
        for u in
User.objects.filter(application__status=Application.ACCEPTED_STATUS):
            dict[u.pk]=True
        return dict.keys()

    workshop = models.ForeignKey(Workshop)
    members = models.ManyToManyField(
                User,
                limit_choices_to= {'pk__in': get_member_pks()},
                help_text="This list is limited to people accepted in
a workshop or staff. ",
                filter_interface=models.HORIZONTAL,
    )
    pub_date = models.DateField('Published Date')
    title = models.CharField(blank=False, max_length=255)
    directory = models.TextField(
        'Directory',
        help_text="The directory where the project files live, not
including the base.  This maps directly to the filesystem.  Currentl
the base is "
            + settings.PROJECT_STATIC_ROOT + '.',
        blank=True,
        choices=get_dir_choices(),
        #prepopulate_from=('title','pub_date'),
    )
    url = models.URLField(
        help_text="Useful if the project is hosted on another
server.",
        verify_exists=False,
        blank=True
    )
    pullquote = models.CharField(max_length=150, blank=True)
    desc = models.TextField(blank=False)
    public = models.BooleanField(default=False)
    enable_comments = models.BooleanField(default=True)
    image = models.ImageField(
        help_text='A small screenshot or thumbnail that represents
this project. Typically less than 250px wide.',
        upload_to='upload/projects/',
        blank=True)


    class Admin:
        list_display = ( '__unicode__',
'workshop','pub_date','public',)
        list_filter = ['workshop']
        js = (
             '/admin/media/js/getElementsBySelector.js',
             '/admin/media/filebrowser/js/AddFileBrowser.js',
             '/media/js/tiny_mce/tiny_mce.js',
             '/media/js/TinyMCEAdmin.js',
             '/media/js/admin.js',
        )

    def __unicode__(self):
        return self.title


    def get_show_url(self):
        if self.url:
            return self.url
        else:
            return '/training/projects/%s/show/' % self.id

    def get_absolute_url(self):
            return '/training/projects/%s/' % self.id

    def get_static_dir(self):
        """
        Fullpath to the project filesystem location.
        """
        return settings.PROJECT_STATIC_ROOT + self.directory

--~--~---------~--~----~------------~-------~--~----~
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