Reputation: 45094
I'm trying to split up my Django models into separate files but I apparently haven't done it right. When I try to run my Django script that I've been using without problems since I started my project, I get this:
$ ./import.py
Traceback (most recent call last):
File "./import.py", line 6, in <module>
from mcif.models import GenericImport, CSVRow
File "/home/jason/projects/mcifdjango/mcif/models/__init__.py", line 1, in <module>
from mcif.models.account_address import AccountAddress
File "/home/jason/projects/mcifdjango/mcif/models/account_address.py", line 1, in <module>
class AccountAddress(models.Model):
NameError: name 'models' is not defined
My app is called mcif
and it's talking about mcif/models/account_address.py
which is this:
class AccountAddress(models.Model):
id = models.BigIntegerField(primary_key=True)
account = models.ForeignKey(Account)
address = models.ForeignKey(Address)
created_at = models.DateTimeField()
updated_at = models.DateTimeField()
class Meta:
db_table = u'account_address'
app_name = 'mcif'
It's saying it doesn't know about the models
part of AccountAddress(models.Model)
, which makes sense. I'm assuming I need to import something, but if that's the case, I don't know what to import. If that's not the case, I'm at a total loss. What should I do?
Upvotes: 1
Views: 652
Reputation: 10353
Is there any from django.db import models
in account_address.py?
Upvotes: 3