Why i cant use two o more id in my project?

well i tried to explain my project
i have a view post and is ok when use post, get but if i try whit a new view send this error
this is my error.

Blockquote
in _reverse_with_prefix
raise NoReverseMatch(msg)
django.urls.exceptions.NoReverseMatch: Reverse for ‘landedit’ with no arguments not found. 2 pattern(s) tried: [‘landing/landedit/(?P<land_id>[^/]+)$’, ‘landedit/(?P<land_id>[0-9]+)$’]
Blockquote

  • landing/views
def landedit(request,land_id):
    ess = Es.objects.get(pk=land_id)
    estudios = EsForm(instance = ess)
    if request.method == "POST":
        estudios = EsForm(request.POST, instance = ess)
        if estudios.is_valid():
            ess = form.save(commit=False)
            ess.save()
    return render(request, "landing/landedit.html", {'estudios':estudios, 'ess':ess})

landing/urls

from django.urls import path, include
from django.conf import settings

from django.conf import settings
from landing import views
from landing import views as landing_views
from landing.views import  pruebaform, AddGeneral, AddyGeneral, landing_page, landedit, landsurf


#app_name = 'landing' 

urlpatterns = [
    path('landing_page/', landing_views.landing_page, name="landing_page"),
    path('landsurf/', landing_views.landsurf, name="landsurf"),
    path('pruebaform', landing_views.pruebaform, name="pruebaform"),
    path('AddyGeneral', landing_views.AddGeneral, name='AddyGeneral'),
    path('AddGeneral', AddGeneral.as_view(), name='AddGeneral'),
]
urlpatterns += [
    path('landedit/<land_id>', landing_views.landedit, name="landedit"),
]

landing/models

class Ess(models.Model):
    nombrempresa = models.CharField(max_length=100, default="Nombre de la Empresa")
    celular = models.CharField(max_length=10, default="Celular")
    Telefono = models.CharField(max_length=10, default="Telefono")
    correo = models.EmailField(max_length=254, default="Correo")
    edad = models.CharField(max_length=10, default="Dia de nacimiento")
    callenumero = models.CharField(max_length=100, default="Calle")
    numerointerior = models.CharField(max_length=5, default="Numero Interior")
    numeroexterior = models.CharField(max_length=5, default="Numero Exterior")
    entrecalles = models.CharField(max_length=50, default="Entre Calles")
    estado = models.CharField(max_length=25, default="Estado")
    ciudad = models.CharField(max_length=25, default="Ciudad")
    codigopostal = models.CharField(max_length=5, default="Codigo Postal")
    image = models.ImageField(upload_to='blog', verbose_name='blog/images', default='static/blog/images/no-img.jpg')
    fecha_registro = models.DateTimeField(auto_now_add=True, null=True)
    update = models.DateTimeField(auto_now_add=True, null=True)
    empresas = models.ManyToManyField(Empresa)

landing/forms


class GeneralForm(forms.ModelForm):

    class Meta:
        model = generales
        fields = '__all__'
        labels = {
            'nombreempresa':'Nombre de la Empresa',
            'celular':'Celular',
            'Telefono':'Telefono',
            'correo':'Correo',
            'edad':'Edad',
            'callenumero':'Calle Numero',
            'numerointerior':'NI',
            'numeroexterior':'NE',
            'entrecalles':'Entre Calles',
            'estado':'Estado',
            'ciudad':'Ciudad',
            'codigopostal':'CP',
        }
        empresas = CustomModelMultipleChoiceField(queryset=Empresa.objects.all(), widget=forms.CheckboxSelectMultiple)

landing/html


<!DOCTYPE html>
<html lang="es">
{% load i18n %} 
<head>
    <title>PsIQuedu</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link  rel="stylesheet" url='/static/blog/img/Logo_psIQedu.jpg'>
    <link rel="shortcut icon" href="/static/blog/img/Imagenpsi.ico">
    <scrip type="text/javascript" src="js/jquery.js"></script>
    <link rel="stylesheet" type="text/css" href="/static/blog/css/centro.css">
</head>
<body>
   <div class="contenido-section x-style">
    <div class="content-home-descrip" >
        <div class="content-home-descrip-contenido" style="color:#cae4db;">
           <h2 style="background-color: #333; color:white;">{{ estudio.nombre }}</h2>
            <div class="content-home-descrip-body">
                <h4 style="background-color: black; color:white; font-size: 10px;">{{ estudio.nombreempresa }}</h4>
                <h4 style="background-color: black; color:white; font-size: 10px;">{{ estudio.update }}</h4>
            </div>
         </div>
    </div>
    </div>
</body>
</html>

Blockquote
somebody can help me ?

Blockquote

This error message is referring to a page attempting to be rendered either with a call to reverse or with the url tag. We would need to see the view (or template) where this is being done. I don’t see a reference to that named url in anything you’ve posted here.

Also, when posting issues here, it’s generally useful to post the complete traceback. Sometimes the real problem isn’t in the last / final message. Sometimes the root issue is found earlier in the trace.

Blockquote
Thank by reply
Blockquote
This is the Html that render to landedit.html

{% extends 'blog/inicio.html' %}
{% load static %}
{% block title %} Centro {% endblock %}
{% block header %} PLATAFORMA EDUCATIVA ESPECIALIZADA | centro {%endblock %} 
{% block content %}

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

<link rel="stylesheet" type="text/css" href="/static/blog/css/centro.css">
 <!--
<div class="content-centro">
    <form>
        <fieldset>  
            <legend>Soluciones</legend>
                <select id="status" name="status" onChange="mostrar(this.value);">
                    <optgroup label="Elige una opcion">
                        <option value=""></option>
                        <option value="cuadro1">Centro Evaluador</option>
                        <option value="cuadro2">Dialogo2</option>
                        <option value="cuadro3">Dialogo3</option>
                        <option value="cuadro4">Dialogo4</option>
                    </optgroup>
                </select>
        </fieldset>
    </form>
</div> --> 
{% if user.is_authenticated %}
<!--<div id="content-lateral" style="display:block" id="myDIV">-->
<div id="content-lateral" style="display:block">
    <marquee><p>Usuario:<i style="color:black;"> {{ user.username }} </i>.....Registra tus datos</p></marquee>
</div>
<div id="lateral-fix" style="display-block">
    <div class="lateral-box"><a href="#cuadro1" onclick="mytema1()">cuadro 1</a></div>
    <div class="lateral-box"><a href="#cuadro2" onclick="mytema2()">Datos CE</a></div>
    <div class="lateral-box"><a href="#cuadro3" onClick="mytema3()">Logo</a></div>
    <div class="lateral-box"><a href="#cuadro4" onclick="mytema4()">Datos X</a></div>
    <div class="lateral-box"><a href="#cuadro5" onclick="mytema5()">Salir</a></div>
    <div class="lateral-box"><a href="#cuadro7" onclick="mytema7()">Id Es</a></div>
    <div class="lateral-box"><a href="{% url 'landing_page' %}" >My L.Page</a></div>
    <div class="lateral-box"><a href="{% url 'landsurf' %}" >My L.surf</a></div>
   
    <div class="lateral-box"><a href="{% url 'landedit' %}">L. Edit</a></div>

    <div class="lateral-box" ><a onClick="mytema()">color</a></div>
 
    <div id="cuadro2"  class="cuadro-x" style="display:none;">
        <div class="content-alumno">
        <!-- <h3 style="color: lightblue;"> Bienvenido </h3>-->
            <div class="content-alumno-formato">
                <form method="POST" class="post-form" autocomplete="off">
                    {% csrf_token %}
                    {{ formato.as_p }} 
                    <input type="submit" value="Submit">
                </form>
            </div>
        </div>
    </div>
    <div id="cuadro3"  class="cuadro-x" style="padding: 1px;display:none;">
        <div class="content-alumno"><div class="content-form"><h5>DESCARGA TU IMAGEN</h5>
            {% include 'albums/upload_image.html' %}
        </div>
    </div>  </div>
    <div id="cuadro4"  class="cuadro-x" style="padding: 5x; display:none;">
    <div class="content-alumno" style="padding: 5x;">
        <h5>Registra tus proximos eventos</h5>
        <a href="{% url 'pruebaform' %}"  style="color:silver;">Evento</a>
        <!--   include 'landing/pruebaform.html'  -->
        <hr>
        <h5>Registrar Los Datos Generales de la empresa</h5>
        <a href="#"  style="color:silver;">Generales</a>
        <hr>
        <h5>Registra tu salida</h5>
        <a href="{% url 'logout' %}" style="color:silver;">Salir</a>
    </div></div>
    <div id="cuadro5"  class="cuadro-x" style="padding: 5x; display:none;">
        <div class="content-alumno">
          {% include 'landing/AddGeneral.html' %} 
        </div>
    </div>
    <div id="cuadro6" class="efecto" class="cuadro" style="display:none">
        <div class="content-land-descrip">
            <div class="content-land-descrip-contenido">
                <h1>Direcciona a Landing page </h1>
                <hr>
            </div>
            <div class="nav-menu-land"><a href="{% url 'landing_page' %}"></a>Landing page</div>
        </div> 
    </div> 
    <div id="cuadro7" class="cuadro-x" style="display:none;">
        <div class="content-alumno">
            {% for estudio in estudios %}
                <div class="content-home-descrip-body">
                    <h5>{{ estudio.nombre }} </h5>
                    <a href="/landedit/{{ estudio.land_edit }}" style="font-size:10px;color:silver;">Leer mas</a>               
                    {% if estudio.link %}
                        <p><a href="{{ estudio.link }}">Leer mas</a></p>
                    {% endif %}
                </div>
            {% endfor %}
        </div>
    </div>
        
</div>
{% else %}
    <div class="content-land-descrip">
    <div class="centrar-auth" style="background-color:#F4EB16; color:blue">
        <a href="{% url 'login' %}">Login</a>
    </div>
    <div class="centrar-auth" style="background-color:blue; color:yellow">
        <a href="{% url 'register' %}"><strong>Registro</strong></a>
    </div>
    </div>
{% endif %}
    <div class="content-land-decrip">
        <div class="content-land-descrip-contenido" style="background-color: #417690">
            <h5>prueba content  land descrip </h5>
        </div> 
    </div>
{% endblock %}

and come from App Blog

This is the URL you’ve defined named landedit. Notice that you’ve specified that there must be a parameter. (Identified as land_id in the URL.)

This is how you’re trying to render the URL named landedit

Notice that you’re not supplying a parameter there for the reverse resolution of that URL.

See the docs on Reverse resolution of URLs.

ok thanks
then ireplace by it

<div class="lateral-box"><a href="/landing/landedit/{{'estudios.id}}">L. Edit</a></div>

blog/centro.html

    <div id="cuadro7" class="cuadro-x" style="display:none;">
        <div class="content-alumno">
            {% for estudio in estudios %}
                <div class="content-home-descrip-body">
                    <h5>{{ estudio.nombre }} </h5>
                    <a href="/landing/landedit/{{ estudio.id }}" style="font-size:10px;color:silver;">Leer mas</a>  
                    {% if estudio.link %}
                        <p><a href="{{ estudio.link }}">Leer mas</a></p>
                    {% endif %}
                </div>
            {% endfor %}
        </div>
    </div>

and make
landing/views

def landedit(request,id):
    estudios = Es.objects.get(id=id)
    #estudios = EsForm(instance = ess)
    #if request.method == "POST":
    #    estudios = EsForm(request.POST, instance = ess)
    #    if estudios.is_valid():
    #        ess = estudios.save(commit=False)
    #        ess.save()
    return render(request, "landing/landedit.html", {'estudios':estudios})

and
landing/urls

urlpatterns += [
    path('landedit/', landing_views.landedit, name="landedit"),
]

whit it urls i have the failure

Page not found (404)
Request Method:	GET
Request URL:	http://127.0.0.1:8000/centro/landing/landedit/1

thanks by your help

Yes, because now your url doesn’t accept a parameter, but that request is supplying one.

Thanks
I try and try so many time and then the ligth!
ok
in blog/centro.html

 <a href="{{'/landing/landedit/' }}{{ estudio.id }}">Leer mas</a>

and is ok
¡¡¡¡ thanks so muchs !!!

To complete this code solution

Blockquote landing/urls

urlpatterns += [
    path('landedit/<id>', landing_views.landedit, name="landedit"),
]

That works, but that’s not the solution I was trying to lead you toward.

The url template tag takes a parameter. The Django-style solution is:
<a href="{% url 'landedit' estudio.id %}">...</a>

(You generally want to use your named urls by name, not by hard-coded path.)

1 Like

Thanks

Yes . it’s ok

Thanks so much