Scrapy project can't find django.core.management

前端 未结 1 541
攒了一身酷
攒了一身酷 2020-12-20 00:32

I\'m trying to follow the method here to \'Scrapy\' data from the web and simultaneously save that data directly to my Django database using Scrapy\'s item pipeline.

相关标签:
1条回答
  • 2020-12-20 01:29

    Try setting this in your Spider's settings.py:

    import os
    import sys
    
    sys.path.append('/home/gchorn/webapps/django_app')
    
    os.environ['DJANGO_SETTINGS_MODULE'] = 'django_project.settings'
    

    Then you can import your model classes like:

    from django_project.app1.models import some_model
    
    0 讨论(0)
提交回复
热议问题