cannot import name DjangoServiceBase - django

I have a problem. spyne example dosn't work.
>>> django.get_version()
'1.6.5'
from spyne.util.django import DjangoComplexModel, DjangoServiceBase
ImportError: cannot import name DjangoServiceBase

Related

ModuleNotFoundError: No module named 'core'

Django Version: 3.1.5
folder structure
So, I'm studying Django. When I try to generate random data for my project I get this error:
Traceback (most recent call last):
File "C:\PythonProjects\DJANGO\myblogsite\blog\management\commands\create_data.py", line 2, in <module>
from core.models import Category, Post, Comment
ModuleNotFoundError: No module named 'core'
Process finished with exit code 1
create_data.py
from django.core.management.base import BaseCommand
from core.models import Category, Post, Comment
from random import randint
import datetime
Has anybody a clue how to deal with this problem?
from django.core.management.base import BaseCommand
from blog.models import Category, Post, Comment
from random import randint
import datetime

How to solve KeyError?

I was trying to create some steps in the Abaqus by using the following python code. Unfortunately having this error. Anybody, please help me...
KeyError:model_name
Python Code:
from abaqus import *
from abaqusConstants import *
import __main__
import section
import regionToolset
import displayGroupMdbToolset as dgm
import part
import material
import assembly
import step
import interaction
import load
import mesh
import optimization
import job
import sketch
import visualization
import xyPlot
import displayGroupOdbToolset as dgo
import connectorBehavior
def create_step(model_name, new_step, previous_step):
mdb.models['model_name'].StaticStep(name='new_step', previous='previous_step', initialInc=0.025,
maxInc=0.025)
session.viewports['Viewport: 1'].assemblyDisplay.setValues(step='new_step')
model_name = 'Model-' + str(0)
new_step = 'C4'
previous_step = 'C3'
create_step(model_name, new_step, previous_step)
Replace mdb.models['model_name'].Stat... with mdb.models[model_name].Stat...
def create_step(model_name, new_step, previous_step):
mdb.models['model_name'].StaticStep(name='new_step', previous='previous_step', initialInc=0.025,
maxInc=0.025)
session.viewports['Viewport: 1'].assemblyDisplay.setValues(step='new_step')
2nd line should be,
mdb.models[model_name].StaticStep(name='new_step', previous='previous_step', initialInc=0.025,
maxInc=0.025)

ImportError: cannot import name 'classproperty'

What is the solution of this error........
from django.utils.decorators import classproperty
ImportError: cannot import name 'classproperty'
Why this error shows. How can I solve this problem ?
If you have this issue after 21 Oct 2019 that is because in this PullRequest classproperty were moved from django.utils.decorators to django.utils.functional.
You need to change your import statement or add some code to check what version of django are you using and from where to import the classproperty
try:
# Django 3.1 and above
from django.utils.functional import classproperty
except ImportError:
from django.utils.decorators import classproperty
Check your django version. This module is not there before django 1.9

How to update admin.py in django-registration-redux?

RequestSite is no longer in django.contrib.sites.models but is in django.contrib.sites.requests. I found that when I installed django-registration-redux, those old import statements are still there. So it raises the following errors:
from django.contrib.sites.models import RequestSite
ImportError: cannot import name 'RequestSite'
So how can I fix it? How do I replace RequestSite in python3.4/site-packages/registration/admin.py file? I am using django-registration-redux 1.2, Django 1.9 and Python 3.4.
RequestSite is under django.contrib.sites.requests
so replace: from django.contrib.sites.models import RequestSite
with: from django.contrib.sites.requests import RequestSite
Reference: (https://docs.djangoproject.com/en/1.9/ref/contrib/sites/#requestsite-objects)

Django orm and path import

Here is my file tree :
--script
..........script.py
-- emails
.........__init__.py
.........models.py
settings.py
_init_.py
manage.py
and my code in script.py
import email, getpass, imaplib, os
import datetime
import unicodedata
import time
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "../settings")
import sys
cmd_folder = os.path.realpath("../")
sys.path.append(cmd_folder)
from emails.models import Email
but i have this error :
TypeError: relative imports require the 'package' argument
How to resolve it please ?
Regards
Try something like:
os.path.realpath(os.path.dirname(os.path.realpath(__file__)) + '/..')
The solution thanks to #django
../ is incorrect for module path so :
import sys
cmd_folder = os.path.realpath(os.path.dirname(os.path.realpath(__file__)) + '/../..')
sys.path.append(cmd_folder)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Sumomo.settings")
from Sumomo.emails.models import Email
(sumomo is the name of my project)