Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a script which pretend to create a form in my site and receive the response, let's call it script.py.
This script needs to call a function in views.py:

Python
opc = newproject.views.Menu_Options(request, ask, Options)


This function needs to use request.POST, so needs to receive "request" as parameter.
The problem is:
Script.py doesn't know what is "request". I imported this:

Python
import newproject.views
import django
from django.http import request



I ran the project but simply ignored the parameter "request" and gave me an error in this line:

Python
opc = newproject.views.Menu_Options(ask, Options)


Exception Type: TypeError at /
Exception Value: Menu_Opctions() missing 1 required positional argument:     'Options'



Did I import a "wrong request"?
Is there any other way in views.py to import in a function the object "request" without passing it as parameter?
Thanks in advance! :)

What I have tried:

I tried to import this:

Python
import newproject.views
import django
from django.http import request


to Script.py but don't seems to work
Posted
Updated 13-Aug-16 2:23am

1 solution

I fixed it! I realised that I forgot to pass the "request" parameter when I call my script main funcion. That's why my external script "didn't know" what "request" was.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900