Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'str' object has no attribute '_meta' #23

Open
ElijahAhianyo opened this issue Sep 3, 2020 · 0 comments
Open

AttributeError: 'str' object has no attribute '_meta' #23

ElijahAhianyo opened this issue Sep 3, 2020 · 0 comments

Comments

@ElijahAhianyo
Copy link

so im using django 3.1 and i defined a model with a foreign key relation like this:

class Account(TimeStampedModel):
    corporate = models.ForeignKey('CompanyDetail',on_delete=models.CASCADE,related_name= 'corporate_accounts')
    balance = models.DecimalField(max_digits=20, decimal_places=2)

this throwns an this error when I try to run the project or run migrations:

Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/django/utils/autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/django/utils/autoreload.py", line 76, in raise_last_exception
    raise _exception[1]
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
    autoreload.check_errors(django.setup)()
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/django/utils/autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/django/apps/registry.py", line 122, in populate
    app_config.ready()
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/jet_django/apps.py", line 12, in ready
    conf = JetDjangoConfiguration()
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/jet_django/configuration.py", line 28, in __init__
    self.models = dict(map(lambda x: (self.model_key(x), self.serialize_model(x)), models))
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/jet_django/configuration.py", line 28, in <lambda>
    self.models = dict(map(lambda x: (self.model_key(x), self.serialize_model(x)), models))
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/jet_django/configuration.py", line 185, in serialize_model
    'fields': list(map(lambda field: self.serialize_field(field), fields))
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/jet_django/configuration.py", line 185, in <lambda>
    'fields': list(map(lambda field: self.serialize_field(field), fields))
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/jet_django/configuration.py", line 214, in serialize_field
    result['params'] = {'related_model': self.serialize_related_model(field.related_model)}
  File "/home/zeus-of-python/.virtualenv/lib/python3.6/site-packages/jet_django/configuration.py", line 250, in serialize_related_model
    'model': Model._meta.db_table,
AttributeError: 'str' object has no attribute '_meta'

everything works fine when I manually import CompanyDetail. It also works fine when I take out jet_django from my installed apps in settings.py and urls.py file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant