AttributeError:'设置'对象没有属性' OSCAR_REQUIRED_ADDRESS_FIELDS'

时间:2017-08-15 09:34:13

标签: python postgresql django-oscar

当我执行python manage.py migrate我是django oscar的初学者时,我在django oscar中遇到了这个问题。欢迎提供帮助和建议。 下面是我的错误信息。

@localhost production1]$ python manage.py makemigrations
Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/lib64/python2.7/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "/usr/lib64/python2.7/site-packages/django/core/management/__init__.py", line 337, in execute
    django.setup()
  File "/usr/lib64/python2.7/site-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/lib64/python2.7/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models()
  File "/usr/lib64/python2.7/site-packages/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/usr/lib/python2.7/site-packages/oscar/apps/address/models.py", line 1, in <module>
    from oscar.apps.address.abstract_models import (
  File "/usr/lib/python2.7/site-packages/oscar/apps/address/abstract_models.py", line 19, in <module>
    class AbstractAddress(models.Model):
  File "/usr/lib/python2.7/site-packages/oscar/apps/address/abstract_models.py", line 35, in AbstractAddress
    POSTCODE_REQUIRED = 'postcode' in settings.OSCAR_REQUIRED_ADDRESS_FIELDS
  File "/usr/lib64/python2.7/site-packages/django/conf/__init__.py", line 57, in __getattr__
    val = getattr(self._wrapped, name)
AttributeError: 'Settings' object has no attribute 'OSCAR_REQUIRED_ADDRESS_FIELDS'

1 个答案:

答案 0 :(得分:2)

按文档

设置文件的最后一个添加是导入所有Oscar的默认设置:

import csv

test = []

for document in new:
    event_obj = {}

    # Get name
    event_obj['name'] = document['name']

    # Get images
    event_obj['picture'] = document['picture']

    test.append(event_obj)

# Create CSV file
with open('Eventbrite_events.csv', 'w', newline='') as csvfile:
     fields = ['name', 'picture']
     writer = csv.DictWriter(csvfile, fieldnames=fields)
     writer.writeheader()
     for x in test:
         writer.writerow(x)
print(csvfile)

更多详情install-by-hand,希望对您有所帮助