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

  • Home
  • SEARCH
  • 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 8798439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:05:50+00:00 2026-06-14T00:05:50+00:00

I have custom middleware, when I add it to my MIDDLEWARE_CLASSES tuple in my

  • 0

I have custom middleware, when I add it to my MIDDLEWARE_CLASSES tuple in my settings.py all of the css and images on the site disappear leaving the site with just text.

middleware.py

from django.shortcuts import redirect
from django.core import urlresolvers

class AcceptTOSMiddleware(object):
    def process_request(self, request):
        login_url = urlresolvers.reverse('login')
        tos_url = urlresolvers.reverse('tos')
        if request.path not in [login_url, tos_url]:
            profile = request.user.get_profile()
            if not profile.tos:
                return redirect(tos_url)
        return None

settings.py

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
    'pagination.middleware.PaginationMiddleware',
    'utils.middleware.AcceptTOSMiddleware'
)

Does anyone know why this would happen?

  • 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-14T00:05:51+00:00Added an answer on June 14, 2026 at 12:05 am
    1. This should only happen in development, otherwise the HTTPD would serve the static files and there would be nothing on django’s side to block it,

    2. Read runserver’s console output, it should show that requests for static files are responded with a 3xx redirect (probably 301),

    3. For development, your middleware should also check if request.path doesn’t start with settings.STATIC_URL nor settings.MEDIA_URL, and return None in that case.

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

Sidebar

Related Questions

i have custom cell with 2 buttons(the function of these buttons is just to
I have custom event that has several different subscribers who will all use the
I have placed my css in stylesheets folder and image in images folder. Both
I have custom js/jquery code which is running fine on all browsers including IE9
I have some things I need to use custom SQL for. Just to start,
I have custom field with volume slider (just color line), I want to update
I get this error sometimes in custom Middleware in process_response method. I have the
I have a django app that uses a custom middleware module to create a
I have custom UITableViewCell . It contains UITextLabel . When I press this cell
I have custom validation rule: public function customRule($check) { } Inside this rule I

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.