Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8448615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:28:33+00:00 2026-06-10T10:28:33+00:00

Pretty simple code but a weird situation… have a template with this snippet: {%

  • 0

Pretty simple code but a weird situation…

have a template with this snippet:

{% is_contest story as iscontest %}

where is_contest is this custom template tag:

@register.assignment_tag
def is_contest(obj):
    contesttype = ContentType.objects.get_for_model(Contest)
    return obj.source_content_type == contesttype

But Contest is in the django_content_type table.

Weirdest part: This is only an intermittent error, and only seems to be caused by the template tag (I do this check in views too but no errors there).

Any ideas?

EDIT: Full Traceback

Traceback (most recent call last):

  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 111, in get_response
    response = callback(request, *callback_args, **callback_kwargs)

  File "/home/ubuntu/src/cbframe/commentableobjects/views/commentableobject_list.py", line 142, in commentablobject_list
    return render_to_response('commentableobjects-list.html', info, context_instance=RequestContext(request))

  File "/usr/local/lib/python2.7/dist-packages/django/shortcuts/__init__.py", line 20, in render_to_response
    return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)

  File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py", line 176, in render_to_string
    return t.render(context_instance)

  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 140, in render
    return self._render(context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 134, in _render
    return self.nodelist.render(context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 823, in render
    bit = self.render_node(node, context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 74, in render_node
    return node.render(context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py", line 123, in render
    return compiled_parent._render(context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 134, in _render
    return self.nodelist.render(context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 823, in render
    bit = self.render_node(node, context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 74, in render_node
    return node.render(context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py", line 62, in render
    result = block.nodelist.render(context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 823, in render
    bit = self.render_node(node, context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 74, in render_node
    return node.render(context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py", line 281, in render
    return nodelist.render(context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 823, in render
    bit = self.render_node(node, context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 74, in render_node
    return node.render(context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py", line 155, in render
    return self.render_template(self.template, context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py", line 137, in render_template
    output = template.render(context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 140, in render
    return self._render(context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 134, in _render
    return self.nodelist.render(context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 823, in render
    bit = self.render_node(node, context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 74, in render_node
    return node.render(context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py", line 185, in render
    nodelist.append(node.render(context))

  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 1139, in render
    context[self.target_var] = func(*resolved_args, **resolved_kwargs)

  File "/home/ubuntu/src/cbframe/commentableobjects/templatetags/url_target_blank.py", line 27, in is_contest
    return obj.source_content_type == contesttype

  File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/related.py", line 350, in __get__
    rel_obj = qs.get(**params)

  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 366, in get
    % self.model._meta.object_name)

DoesNotExist: ContentType matching query does not exist.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:28:35+00:00Added an answer on June 10, 2026 at 10:28 am

    One problem might be that you are comparing 2 instances with eachother, while these should be the same in Django since Django caches them, that is not a guarantee.

    Not sure how/where the source_content_type comes from, but I would recommend this instead:

    return isinstance(obj, contesttype)
    

    As for the original problem, do you have a stacktrace? This error seems a bit strange.

    Are you sure that Contest isn’t being overwritten somewhere in the scope?
    Contest could be overwritten by other code in the module, the most likely suspect in that case would be a global Contest but that doesn’t appear to be the case here.

    [edit]

    Thanks to the stacktrace the problem is a bit clearer.

    This part specifically shows that it’s going wrong in the obj.source_content_type part:

    return obj.source_content_type == contesttype
    

    I think that some object doesn’t have an existing source_content_type anymore.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have pretty simple jquery code : $(document).ready(function(){ $('img.marqFl').on({ mouseenter: function() { $(this).animate({height: 300},
I have a problem with WCF. My testing code is pretty simple. I call
Pretty simple code, which I may say worked as intended in Xcode 4.1 but
I have written a pretty simple code to get the first result for any
This should be pretty simple but for some reason I can't get this value
I have pretty simple piece of code var propertyBuilder = typeBuilder.DefineProperty(upperName, PropertyAttributes.None, propertyType, new[]
In my code I have a pretty simple [editedObject setValue:[NSData dataWithContentsOfURL:url] forKey:editedFieldKey]; however my
I have a pretty simple problem, but right now can't seem to see the
I have an ASP.NET MVC application which is pretty simple so far, but I
Pretty simple task, but the source code doesn't do required job... Please advise. There

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.