function import errors model import in other file

26 views
Skip to first unread message

Gerard Petersen

unread,
Sep 22, 2008, 2:01:57 PM9/22/08
to django...@googlegroups.com
Hi All,

I'm trying to import a function. When adding this statement I get a Model import error in a completely different place, not even related. I've added the files from my app directory and their import statements below.

Are there any unauthorized imports being done?
Do I need to specify more exact since it's a deviating filename?
Do I need to add the deviating filenames (myforms.py, myfunctions.py) to settings.py or _init__.py?

I'm completely lost. Thanx a lot!

Regards,

Gerard.


## __init__.py
empty!

## urls.py
from django.conf.urls.defaults import *
from django.contrib import admin
from django.conf import settings

## views.py
from django.shortcuts import render_to_response, get_object_or_404
from django.conf.urls.defaults import *
from django.http import Http404, HttpResponseRedirect, HttpResponse
from django.core.urlresolvers import reverse
from models import *
from myforms import *
from myfunctions import *
from datetime import datetime

## models.py
from django.db import models
from django.contrib import admin
from statemachine import Machine
import datetime

## myforms.py
from models import *
from django.forms import *

## statemachine.py
from django.db import models
from django.utils.functional import curry
from myfunctions import current_date << Adding this one

## myfunctions.py
from django.db import models
from models import MetaData << Breaks this one
from datetime import datetime, timedelta
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_DOWN

With this >> ImportError: cannot import name MetaData

Full trace: http://paste.pocoo.org/show/85970/


Thanx again!


--
urls = { 'fun': 'www.zonderbroodje.nl', 'tech': 'www.gp-net.nl' }

Norman Harman

unread,
Sep 22, 2008, 2:22:46 PM9/22/08
to django...@googlegroups.com
It looks like you have made a circular import:

statemachine imports myfunctions which imports models which imports
statemachine == doh!

Don't do that.


--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___________________________________________________________________________
Get off the sidelines and huddle up with the Statesman all season long
for complete high school, college and pro coverage in print and online!

Gerard Petersen

unread,
Sep 22, 2008, 4:06:04 PM9/22/08
to django...@googlegroups.com
Norman,

Seems so simple when you point it out .. :-)I know what happens, but it still seems fuzzy. This means I can not place anything anywhere even though I needed the stuff where I imported it. I think I'll draw some schematics to get a clearer view on what goes where.

Thanx a lot!!

Regards,

Gerard.

--

Reply all
Reply to author
Forward
0 new messages