In [ ]:
def create_task(request):
    if request.method == 'POST':
        creator = request.user
        job_title = 'data engineer'
        skill_name = request.POST.get('skill_name')
        starting = request.POST.get('starting')
        description = request.POST.get('description')
        target_date = request.POST.get('target_date')

        if tasksx.objects.filter(skill_name='skill_name', creator=request.user).exists() is True:
            messages.success(request, ('Skill Is A Duplicate  '))
            return redirect('index')

        else:
            i = tasksx.objects.create(target_date2=target_date, creator=creator, job_title=job_title, skill_name=skill_name,  starting=starting, current=starting, description=description)

            try:
                if  starting != '100':
                    Client = PyUdemy(clientID = 'clientId', clientSecret = 'clientsecret')

                    response = Client.get_courseslist(search = skill_name, ordering='highest-rated')
                    data = json.loads(response)
                    df1 = json_normalize(data['results'])
                    chosen_course = df1.iloc[0]
                    chosen_coursex = pd.DataFrame(chosen_course).T

                    creator = request.user
                    chosen_title = chosen_coursex.iloc[0]['title']
                    chosen_price = chosen_coursex.iloc[0]['price']
                    chosen_img = chosen_coursex.iloc[0]['image_240x135']
                    chosen_url = chosen_coursex.iloc[0]['url']
                    chosen_url = 'https://udemy.com' + chosen_url

                    j = courses.objects.create(creator=creator, course_title=chosen_title, chosen_price=chosen_price, chosen_img=chosen_img, chosen_url=chosen_url, skill=skill_name)
            except:
                print('error')
            messages.success(request, ('Skill created  '))
            return redirect('index')