[Answer]-Django View issue-ForeignKey

1👍

what specifically is not working? what errors are you receiving?

I see one that you’re attempting to pass cineslug to your view function and as a parameter.

When you used named groups they are passed as positional arguments to the view.

def FuncionesByCine(request, id):

shoudl be

def FuncionesByCine(request, cineslug, id):

but i do believe this will break your original url,

you could change your function definition to def FuncionesByCine(request, cineslug, id):

and pass in default value for cineslug

url(r'^funciones/(?P<id>.*)/$', views.FuncionesByCine, {'cineslug': None})

def FuncionesByCine(request, cineslug, id):
  if cineslug is None:
     # this is from funciones/{id} 

You can retrieve Funcion‘s by slug like:

funciones = Funcion.objects.filter(idcine__slug={{ your slug value here }})

Leave a comment