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 8891283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:42:06+00:00 2026-06-14T22:42:06+00:00

When I run my project’s default tests, one test is failing: FAIL: test_current_site_in_context_after_login (django.contrib.auth.tests.views.LoginTest)

  • 0

When I run my project’s default tests, one test is failing:

FAIL: test_current_site_in_context_after_login (django.contrib.auth.tests.views.LoginTest)

Traceback (most recent call last):
File “/Users/me/Dropbox/dotfiles/.virtualenvs/mysite/lib/python2.7/site-packages/django/contrib/auth/tests/views.py”, line 294, in test_current_site_in_context_after_login
self.assertEqual(response.context[‘site_name’], site.name)
AssertionError: ‘MySite’ != u’example.com’

My settings.py file contains:

SITE_NAME = 'MySite'

I load the SITE_NAME in my context at the end of the settings file with:

TEMPLATE_CONTEXT_PROCESSORS = GLOBAL_SETTINGS.TEMPLATE_CONTEXT_PROCESSORS + (
    'utils.context_processors.mysite',
)

utils/context_processors.py contains:

from mysite import settings
def mysite(request):
    return {
        'site_name': settings.SITE_NAME,
        'request': request
    }

I’ve looked at the source code but I don’t understand why the test is comparing my site’s name to ‘example.com’. I’ve also looked at the django.contrib.sites.models.Site class and am wondering if I need to clear the Site object cache. However, I don’t have a CACHES setting. Could there be some conflict in a .pyc file such that I need to delete all the pyc files in my virtualenv?

BTW, I’m running Django 1.4.2 and 2.7.1.

Thanks very much.

  • 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-14T22:42:08+00:00Added an answer on June 14, 2026 at 10:42 pm

    The problem is that you hardcode the SITE_NAME in your settings. You should use Site.objects.get_current() in your middleware/view instead: https://docs.djangoproject.com/en/1.4/ref/contrib/sites/#hooking-into-the-current-site-from-views

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

Sidebar

Related Questions

We run a project in which we want to solve with test driven development.
I am using AndEngine to create a Test run project. I am doing well
I try to run my project in windows. Project use android ndk. I install
I'm trying to run a project which a friend of mine send me, but
Using VB 6 Once I run the project, How to display a previously selected
Im trying to connect my project via sFTP. and everytime I run the project
I am getting an error when i try to run my project ddms]ADB rejected
I have an ASP.NET project with outputType library, I need to run the project
I'm attempting to add a mirgration before I run my project. I get the
In iphone I add twitter framework. When I am run that project it give

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.