0

Was an error with the API. However, didn't throw back any errors.

6
  • I don't understand your code, can you make sure the indentation is correct? Your def get_context_data() method does nothing (because of pass) and the 3 lines at the bottom of your code snippet are not part of any function so this would crash. Commented Feb 20, 2020 at 15:09
  • Sorry. The person who made the edit added a pass, which i didn't notice. Updated. Commented Feb 20, 2020 at 15:26
  • 1
    you're setting kwargs['test'] to be a function, not the result of that function. Anyway, what is client in the first place? What are these "events" you're talking about? Commented Feb 20, 2020 at 15:29
  • Hi @dirkgroten apologies for the lack of context. I've updated my code to make it a little cleaner. I'll provide some more info. I'm using the following: github.com/ettoreleandrotognoli/python-ami as I'm accessing call information from a PBX. I've obtained a list of callers using an Action. Within each Action, there are multiple events. I can retrieve and print the events inside the console / shell. However, I need to pass them to display these items to the template in Django. Commented Feb 20, 2020 at 15:42
  • 'add_event_listener' will retrieve the events and pass them to the function 'event_notification'. I then want to pass that data to the template. Commented Feb 20, 2020 at 15:42

1 Answer 1

1

As Django Docs suggest, it is better to extend / add custom data to context, rather than re-implementing it:

def get_context_data(self, **kwargs):
    context = super().get_context_data(**kwargs)
    context['test'] = event_notification(source, event)
    return context

Also, as event_notification is callable, you need to resolve it and pass result of the function to template (or template can call callables, but without arguments; or you can use custom template tags).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.