0

I'm working with an ModelAdmin from my model. I have a field that I need to check if it's right.

It's a string and I'm sending it to the server, and this returns me a graph in which I can check the string if it's ok.

The big question is about how to use ajax with the admin view, and the view returns the object to me. It's a little different from the classic way with ajax+views, because i have the admin mode class inside admin.py. I redefined the change_form template and added the js and ajax calls. But it returns me nothing at the moment.

Thanks for your advice!

1 Answer 1

1

Place your change_form.html in the below hierachy:

/myproject/templates/admin/myapp/mymodel/change_form.html

And inherit the base change_form.html from admin. Eg:

{% extends "admin/change_form.html" %}
{% block after_field_sets %}{{ block.super }}
Print my model here {{ original }}
Print foreignkey related records of my model:
{% for item in original.items_set.all %} {{ item }} {% endfor %}
{% endblock %}
Sign up to request clarification or add additional context in comments.

4 Comments

Yeah, i had that. But the question it's about where i put the action view with the ajax request. I an independant view or inside the admin class?
you can handle this in independent view for your ajax calls, that view will be responsible for the required data by ajax
@DavidPinedaOsorio always ready to help, please upvote and accept as the correct answer.
Yep, i voted, but i have less than 15 points or something like that :)

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.