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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:32:24+00:00 2026-05-24T11:32:24+00:00

My goal is to create a log app, apart from my main app, that

  • 0

My goal is to create a “log” app, apart from my main app, that will be used for several custom handler classes, filters, etc, and other error and stat reporting. But when running the dev server for my Django project, I receive the error:

  File "/Library/Python/2.7/site-packages/Django-1.3-py2.7.egg/django/conf/__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "/Library/Python/2.7/site-packages/Django-1.3-py2.7.egg/django/conf/__init__.py", line 139, in __init__
    logging_config_func(self.LOGGING)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/config.py", line 776, in dictConfig
    dictConfigClass(config).configure()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/config.py", line 575, in configure
    '%r: %s' % (name, e))
ValueError: Unable to configure handler 'db_handler': Unable to configure handler 'db_handler': 'module' object has no attribute 'models'

My LOGGING directive in settings looks like:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'default': {
            'format': '[%(asctime)s] %(levelname)s::(%(process)d %(thread)d)::%(module)s - %(message)s'
        },
    },
    'handlers': {
        'db_handler': {
            'level': 'DEBUG',
            'class': 'Project.log.handlers.db_handler'
        },
        'file_handler': {
            'level': 'DEBUG',
            'formatter':'default',
            'class': 'logging.TimedRotatingFileHandler',
            'filename':'Custom_log',
            'when':'midnight',
            'interval':1
        },
    },
    'loggers': {
        'django.request': {
            'handlers': ['db_handler'],
            'level': 'DEBUG',
            'propagate': True,
        },
    }
}

The layout of my “log” app is pretty simple, and currently:

log/
    __init__.py
    handlers.py
    models.py

models.py contains a single model, LogHandler:

from django.db import models

class LogRecord(models.Model):
    .... 
    ....

and handlers.py contains a single handler:

import logging

from models import LogRecord

class db_handler(logging.Handler):   
    def emit(self, record):
        ....
        ....

The error, as far as I can tell, is referring to the from models import LogRecord line. I have tried using project.log.models, and log.models, but both yield the same results. I have also tried moving the handler into models.py and not importing anything, but I get a similar error saying that “module” has no attribute “models”.

My log app is in my installed apps, and contains an __init__.py.

  • 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-05-24T11:32:25+00:00Added an answer on May 24, 2026 at 11:32 am

    It looks like you are getting a circular import. You cannot define a handler class in a module which itself imports settings.py

    It is documented at https://docs.djangoproject.com/en/dev/topics/logging/#topic-logging-parts-handlers (Search for ‘circular imports’)

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

Sidebar

Related Questions

My goal is to create an entry form (addnew.php) that will allow me to
Goal I want to create a web app with a horizontal GUI bar that
My goal is to create a list from menu.bin. This is the func: pitem
I am working on an app that implements a custom ListView that contains images.
Goal: Build an Android app that discovers the names and addresses of BT devices
So I've used code examples from all over the net and got my app
Using JavaScript how do I create a subclass that inherits values from the parent
Is there any way to create a log file with NLOG will just contain
The goal of the following code is to create a 2d array such that
I'm trying to create a PHP based application that allows students from my school

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.