Menu_Opciones() missing 2 required positional arguments: 'Pregunta' and 'Opciones'
<p>I have a problem which evolve a script: "script.py" and a view in "views.py" in a django project.
The goal is to show in a page a question: "Pregunta" and a list of options: "Opciones" 
In a part of the script I need to call a view's function "Menu_Opciones" in this way:</p>

<pre><code>ESI_App.views.Menu_Opciones(request, Pregunta, Opciones)
</code></pre>

<p>In views.py I have the function defined in this way:</p>

<pre><code>def Menu_Opciones(request, Pregunta, Opciones):
    for i in range(len(Opciones)):
    ModelOpciones.objects.create(opciones=Opciones[i])
    form = OpcionesForm(request.POST or None, field1_qs = ModelOpciones.objects.all())
    context = {
    'pregunta': Pregunta,
    'form': form,
    }
    if form.is_valid():
        opcion = form.cleaned_data['Campo_Opciones']
    return render(request, "Menu_op.html", context)
</code></pre>

<p>Here's the traceback:</p>

<pre><code>Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/Menu_Opciones/

Django Version: 1.9.7
Python Version: 3.4.3
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'ESI_App']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback:

File "C:\Users\Miguel\Desktop\VenvProyecto\lib\site-packages\django\core\handlers\base.py" in get_response
  149.                     response = self.process_exception_by_middleware(e, request)

File "C:\Users\Miguel\Desktop\VenvProyecto\lib\site-packages\django\core\handlers\base.py" in get_response
  147.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)

Exception Type: TypeError at /Menu_Opciones/
Exception Value: Menu_Opciones() missing 2 required positional arguments: 'Pregunta' and 'Opciones'
</code></pre>

<p><strong>More information:</strong> I have this error since I changed computer but I created a new proyect and app, copied the code, modified all paths, project files and folder names, app name, settings... carefully.</p>

<p>As you can see, I call the function with that 3 arguments and I can't imagine why get that error. Please, give me a hand.
Thanks in advance.</p>

<p>I fixed it! First I tried to pass the parameters as keyword but got the same error, so I tried simply to define in views "Pregunta" and "Opciones" as global variables:</p>

<pre><code>Preg = ''
Opcs = []
</code></pre>

<p>I imported them in "script.py" and asigned their proper value:</p>

<pre><code>ESI_App.views.Preg = Pregunta
ESI_App.views.Opcs = Opciones
</code></pre>

<p>Then, I call the view and use those global variables :)
I know it's not elegant abusing of global variables, but it avoided the error and solved the problem.
If you find another elegant solucion or way to solve that error, I would appreciate it and would mark his solution as accepted. </p>

python django parameters arguments views