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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:49:08+00:00 2026-06-05T03:49:08+00:00

I followed this link to use Django’s ORM on my stand alone application in

  • 0

I followed this link to use Django’s ORM on my stand alone application in python. manage.py sql ‘application_name’ and manage.py syncdb is working well and tables were created when I performed syncdb. The problem I am encountering is when I am running the actual script (for this case, it’s dparser.py) that will handle DB transactions, I am encountering a “TypeError: relative imports require the ‘package’ argument”. Below is the stacktrace:

Traceback (most recent call last):
  File "dparser.py", line 23, in <module>
    from dmodel.models import *
  File "/home/<user>/d/dapp/dmodel/models.py", line 1, in <module>
    from django.db import models
  File "/usr/local/lib/python2.7/site-packages/django/db/__init__.py", line 11, in <module>
    if DEFAULT_DB_ALIAS not in settings.DATABASES:
  File "/usr/local/lib/python2.7/site-packages/django/utils/functional.py", line 184, in inner
    self._setup()
  File "/usr/local/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/local/lib/python2.7/site-packages/django/conf/__init__.py", line 93, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/local/lib/python2.7/site-packages/django/utils/importlib.py", line 28, in import_module
    raise TypeError("relative imports require the 'package' argument")
TypeError: relative imports require the 'package' argument

Below are the contents of my settings.py, models.py and dparser.py:

settings.py:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',   
        'NAME': 'd',
        'USER': 'root',
        'PASSWORD': '<password>',
        'HOST': 'localhost',
        'PORT': '3306',
    }
}
INSTALLED_APPS = ("dapp.dmodel",)

models.py:

from django.db import models
from django.db.models import Max


class Topics(models.Model):
     topic_id = models.AutoField(primary_key=True)
     topic = models.CharField(max_length=1000)

class Links(models.Model):
     link_id = models.AutoField(primary_key=True)
     topic = models.ForeignKey(Topics)
     link = models.CharField(max_length=1000)

def getLastId(tag):
     ...
     return lastid

dparser.py (partial):

from django.conf import settings
os.environ['DJANGO_SETTINGS_MODULE'] = ".settings.py"
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',   
        'NAME': 'd',
        'USER': 'root',
        'PASSWORD': '<password>',
        'HOST': 'localhost',
        'PORT': '3306',
    }
}
INSTALLED_APPS = ("dapp.dmodel",)

from dmodel.models import * # --> This is were the exception occurs

Hope somebody can help me out here. Thanks in advance!

  • 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-05T03:49:10+00:00Added an answer on June 5, 2026 at 3:49 am

    Looking at the code of django.utils.importlib.py where the execption is raised you see that your settings file name is causing the problem:

    if name.startswith('.'):
        if not package:
            raise TypeError("relative imports require the 'package' argument")
    

    Don’t use .settings.py as the name for your settings file, use something that does not start with a ‘.’ and it will solve this particular error.

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

Sidebar

Related Questions

I followed this link to make use of recent files list but statement below
I followed this link Android get external IP . I am connecting to this
I have followed this guide: http://www.danielbaulig.de/socket-ioexpress/ to link express.js to socket.io and it works
I want to link an XML Schema with an XML file. I followed this
When a button/link is clicked, I want this URL to be called followed by
Regarding the answer provided at this link: Proposed solution I tried to use this
I followed this a link to try to configure Twitter's boostrap.less under Node 0.6.12
Followed this question about delayed_job and monit Its working on my development machine. But
I followed this Push Notification tutorial . When I finish the tutorial, I found
I followed this tutorial to setup auto-completion functions for figlet / toilet . #

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.