Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

117
Vistas
django create an api

Issue

hi there, my application are almost frontend, what I meant by that, similar to json formatter, codePen, jsFiddle and some online graphers. to be more focused, I have specific views, let's say, a markdown editor, that you can type from left, and outlook appearance render to right.

here, it's a bit intricate. For some user cases: in a form, that the user can input raw text into a textarea, and it's markdown supported, therefore, I need to write a button, see in editor, which takes all user's current input text, and open a new tab with the markdown editor. The difficulty of this, is that those raw text do not need to be saved, the user only need to see the rendered effect, but django only works with model.

I thought of many ways:

  • rest framework api view
  • Ajax POST view
  • abstract model

but I failed to make it work.


Code

template

<!-- some code above -->
{% comment %} form.content returns a string {% endcomment %}
{{ form.content }}
<button>see in editor</button>
<!-- some code below -->

javascript

const content = document.querySelector('#id_content');
const button = document.querySelector('button');
button.onclick = () => {
    $.ajax({
        type: "POST", 
        url: "{% url 'some-view-name' %}",
        data: {
            content: content.value,
        }, 
        success: function(url){
            // return the link of markdown editor
            window.open(url);
        }, 
        error: function(res){
            console.log(res);
        },
    })
}

this javascript is just an attempt, which I have no idea how to write the view.


if I got you confused, I am sorry, please look at: Web: how to redirect to a CodePen or JsFiddle with information filled?, this kind is exactly what I am trying to do, an api backend.

I have been working on the issue for a week, frustrated, I will be very grateful for any of the help you may offer:

  • suggestion of another way
  • any resource to look at
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda