Hi everybody,

i have some problem i just dont understand. I have a business model
(derived from django namespace):
class Business(models.Model):
    business = models.ForeignKey("self", related_name="other_business")
    name = models.CharField(max_length=50, unique=True)
...
    objects = BusinessModelManager()

and:

class BusinessModelManager(models.Manager):
    def user_can_access(self, user):
        if user.is_superuser:
            return super(BusinessModelManager, self).get_query_set()
        else:
            return super(BusinessModelManager,
self).get_query_set().filter( Q(business__groups=user.groups.all()) |
Q(business__users=user) )

Now when i go ahead into django shell and do:
from eiwomisa.business.models import Business
Business.objects.all()

it returns the expected output, the Business objects.

But, i have a templatetag:

class Business(Node):
    def __init__(self, context, user):
        self.context = context
        self.user = template.Variable(user)

    def render(self, context):
        user = self.user.resolve(context)
        business = Business.objects.all()
        #context[self.context] = business
        #context[self.context] = 'nd'
        return ''

def get_business(parser, token):
    bits = token.contents.split()

    return Business(bits[2], bits[3])
register.tag('get_business', get_business)

Which should do the same, but it throws the following error:
-----------------------------
TemplateSyntaxError at /admin/time_tracking/timetracking/

Caught an exception while rendering: type object 'Business' has no
attribute 'objects'

Original Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/django/template/debug.py",
line 71, in render_node
    result = node.render(context)
  File "/usr/lib/python2.6/site-packages/django/template/defaulttags.py",
line 155, in render
    nodelist.append(node.render(context))
  File 
"/home/sveri/programmierprojekte/eiwomisa/eiwomisa/../eiwomisa/project/time_tracking/templatetags/tags.py",
line 49, in render
    business = Business.objects.all()
AttributeError: type object 'Business' has no attribute 'objects'

Request Method:         GET
Request URL:    http://localhost:8000/admin/time_tracking/timetracking/?e=1
Exception Type:         TemplateSyntaxError
Exception Value:        

Caught an exception while rendering: type object 'Business' has no
attribute 'objects'

Original Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/django/template/debug.py",
line 71, in render_node
    result = node.render(context)
  File "/usr/lib/python2.6/site-packages/django/template/defaulttags.py",
line 155, in render
    nodelist.append(node.render(context))
  File 
"/home/sveri/programmierprojekte/eiwomisa/eiwomisa/../eiwomisa/project/time_tracking/templatetags/tags.py",
line 49, in render
    business = Business.objects.all()
AttributeError: type object 'Business' has no attribute 'objects'
-------------------------

Hm, thats something thats completely out of my mind, i mean, its the
same call, but it cannot get executed? Why is that?


Greetings and thanks in Advance
Sven

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