'module' object has no attribute 'PeriodicTask' when accessing /admin - django

I have djcelery installed and it seems it's installed properly:
In [1]: from djcelery import models
In [2]: models.PeriodicTask
Out[2]: djcelery.models.PeriodicTask
However, when I access the admin site, I get this error which seems to imply that there's an issue with djcelery. I suspect it has to do with my setup. The details of the error are below. Anyone seen this or have any thoughts?
AttributeError at /admin/
'module' object has no attribute 'PeriodicTask'
Request Method: GET
Django Version: 1.4
Exception Type: AttributeError
Exception Value:
'module' object has no attribute 'PeriodicTask'
Exception Location: /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py in import_module, line 37
Python Version: 2.7.1

It turned out that I was getting this error because of an old tasks.pyc that was in one of my applications (where tasks.py had been removed). Djcelery automatically tries to load tasks.py file in all the installed apps, and this one apparently referenced PeriodicTask incorrectly.

Related

AttributeError at /BRMapp/view-books/

I am developing Book Record Management system as my first project on django but after performing all my functionalities I got a problem in my views.py file in a function name view-book in a line(books=models.Book.objects.all()).Although i have made a class name 'Book' in models.py and i also have imported models in my views.py file with a line(form django.db import models).Although it is not working.Kindly help
Error showing like this:::
module 'django.db.models' has no attribute 'Book'
Request Method: GET
Request URL: http://localhost:8000/BRMapp/view-books/
Django Version: 3.2.5
Exception Type: AttributeError
Exception Value:
module 'django.db.models' has no attribute 'Book'
Exception Location: G:\Django projects\firstproject\BRMapp\views.py, line 41, in viewBooks
Python Executable: C:\Users\amann\AppData\Local\Programs\Python\Python39\python.exe
Python Version: 3.9.2
Python Path:
['G:\\Django projects\\firstproject',
'C:\\Users\\amann\\AppData\\Local\\Programs\\Python\\Python39\\python39.zip',
'C:\\Users\\amann\\AppData\\Local\\Programs\\Python\\Python39\\DLLs',
'C:\\Users\\amann\\AppData\\Local\\Programs\\Python\\Python39\\lib',
'C:\\Users\\amann\\AppData\\Local\\Programs\\Python\\Python39',
'C:\\Users\\amann\\AppData\\Roaming\\Python\\Python39\\site-packages',
'C:\\Users\\amann\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages']
Server time: Thu, 12 Aug 2021 10:19:08 +0000
Based on the exception models points to the models submodule of the django.db module, but there is no Book defined in that module.
Likely the Book originates from elsewhere, from an appname.models module.
You thus import this with:
from appname.models import Book
# …
def viewBooks(request):
# …
# ↓ no models.
books = Book.objects.all()
# …

django-pgcrypto: AttributeError: module 'django.db.models' has no attribute 'SubfieldBase'

I am trying to add django-pgcrypto to my django project but I am getting an error message:
class EncryptedTextField (six.with_metaclass(models.SubfieldBase, BaseEncryptedField)):
AttributeError: module 'django.db.models' has no attribute 'SubfieldBase'
Do you have any advice on how this could be fixed? I am using django 1.10 and python 3.5

Python Version 2.7.6. psutil version 2.1.3 - AttributeError: 'module' object has no attribute 'users'

I am running UBUNTU 14.04. Python version is 2.7.6 and psutil version is 2.1.3
I import psutil and then call one of the following only to get errors.
import psutil
psutil.users()
psutil.pids()
psutil.cpu_times()
AttributeError: 'module' object has no attribute 'users'
AttributeError: 'module' object has no attribute 'pids'
AttributeError: 'module' object has no attribute 'boot_time'
I do not have this issue with psutil.cpu_percent() and psutil.cpu_times()
Try to print psutil.__version__. It's likely you're using an old version (< 2.X).

Dojango with django 1.5

I'm a django noob. I just added dojango 0.5.5 in project apps. I use Django 1.5 and when i try to vie the test page dojango offers at mysite/dojango/test/ i got this error:
__init__() got an unexpected keyword argument 'namedtuple_as_object'
the error is in the dojango base template file where there is:
'isDebug':{{ DOJANGO.DEBUG|json }},
Has someone encountered this issue? How do you resolve it?
I found a similar issue. Try to find
from django.utils import simplejson as json
and replace it with
try:
import json
except ImportError:
from django.utils import simplejson as json

Django nonrel error "No Module name models"

Guys,
I Started playing with django-nonrel, and am trying to run my old django app on it.
My app was done on django 1.2.1 & python 2.6.
When i fire up the local server, there are a couple of warnings but the server starts well.
But when i try to run the main page from the browser, django throws the following error
ImportError at /bytex
No module named bytexpro.bytex.models
Request Method: GET
Request URL: http://127.0.0.1:8000/bytex
Django Version: 1.3 beta 1
Exception Type: ImportError
Exception Value:
No module named bytexpro.bytex.models
Exception Location: E:\home\web\bytex\bytexpro\bytex\admin.py in <module>, line 1
Python Executable: C:\python26\python.exe
...
My admin.py looks like this
from bytexpro.bytex.models import ItemGroup
from bytexpro.bytex.models import Item
from bytexpro.bytex.models import Supplier
....
Anything i i have forgotten to include?
Gath
try
from bytex.models import ....