Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当通过views.py调用addietm函数时,找不到带有django-config文件的ebay python SDK,否则有效_Python_Django_Ebay Api_Ebay Sdk - Fatal编程技术网

当通过views.py调用addietm函数时,找不到带有django-config文件的ebay python SDK,否则有效

当通过views.py调用addietm函数时,找不到带有django-config文件的ebay python SDK,否则有效,python,django,ebay-api,ebay-sdk,Python,Django,Ebay Api,Ebay Sdk,我正在构建一个django项目,在我的views.py中,我试图从同一目录下的另一个.py文件调用一个函数,该文件对ebay进行api调用。当我在.py文件中运行该函数时,它工作正常,但当我从我的views.py调用它时,会出现以下错误: 'config file ebay.yaml not found. Set config_file=None for use without YAML config.' 我不明白为什么只有当我从views.py调用它时才会发生这种情况?ebay.yaml文件

我正在构建一个django项目,在我的views.py中,我试图从同一目录下的另一个.py文件调用一个函数,该文件对ebay进行api调用。当我在.py文件中运行该函数时,它工作正常,但当我从我的views.py调用它时,会出现以下错误:

'config file ebay.yaml not found. Set config_file=None for use without YAML config.'
我不明白为什么只有当我从views.py调用它时才会发生这种情况?ebay.yaml文件与这两个文件位于同一目录中

视图.py

from django.http import HttpResponse
from django.shortcuts import render
import sys
from djangonautic.forms import HomeForm
import _sqlite3
import os.path
from djangonautic import additem #this is the file that has the function

def homepage(request):

    if request.method == "POST":

        form = HomeForm(request.POST)
        if form.is_valid():
            print("Form was valid")
            text = form.cleaned_data['post']
            config_for_ebay = 'ebay.yaml' #config file to make api call
            resp_object = additem.make_api_call(text, config_file=config_for_ebay)
            args = {'form': form, 'text': text}
            context = {'title': resp_object}
            return render(request, "script_run.html", context=context)
    else:
        print("ewe")
        form = HomeForm()
        return render(request, "homepage.html", {'form': form, 'text': 'bla'})
from ebaysdk.trading import Connection

from djangonautic import api_formatting_for_raw_html
from djangonautic import get_categories
#var_pics = {'Color': [x[1] for x in variations]}

def make_api_call(url, config_file):
    '''Makes the api call to add product, also calls other functions to import the product in the url'''
    (title_fr, listing_has_variations, main_product_images, price_value, variation_node, variationSpecificsSet, variationSpecificName, variationSpecificPictureSet) = api_formatting_for_raw_html.format_api_call(url)
    cateid = get_categories.get_suggested_categories(url, config_file = config_file)[1]
...
...
附加项py

from django.http import HttpResponse
from django.shortcuts import render
import sys
from djangonautic.forms import HomeForm
import _sqlite3
import os.path
from djangonautic import additem #this is the file that has the function

def homepage(request):

    if request.method == "POST":

        form = HomeForm(request.POST)
        if form.is_valid():
            print("Form was valid")
            text = form.cleaned_data['post']
            config_for_ebay = 'ebay.yaml' #config file to make api call
            resp_object = additem.make_api_call(text, config_file=config_for_ebay)
            args = {'form': form, 'text': text}
            context = {'title': resp_object}
            return render(request, "script_run.html", context=context)
    else:
        print("ewe")
        form = HomeForm()
        return render(request, "homepage.html", {'form': form, 'text': 'bla'})
from ebaysdk.trading import Connection

from djangonautic import api_formatting_for_raw_html
from djangonautic import get_categories
#var_pics = {'Color': [x[1] for x in variations]}

def make_api_call(url, config_file):
    '''Makes the api call to add product, also calls other functions to import the product in the url'''
    (title_fr, listing_has_variations, main_product_images, price_value, variation_node, variationSpecificsSet, variationSpecificName, variationSpecificPictureSet) = api_formatting_for_raw_html.format_api_call(url)
    cateid = get_categories.get_suggested_categories(url, config_file = config_file)[1]
...
...