Very good my people, I am entering the world of programming in django and I would like to know if it is possible to be able to create urls equal to those that exist in wordpress.
example
therefore the first thing I have to do is validate if that /hello-world comes from the url or not or if it doesn't direct me to the main page
I explain
# Create your views here.
def home_inicio(request):
if request.GET:
#si viene /hola-mundo , me envié a articulo.html y muestro la data en esa pagina del articulo hola mundo
data = ...consulta a la base...
return render(request, "home/articulo.hml", {'data': data})
else:
#si no viene /hola-mundo redirecciono a pagina principal
return render(request, "home/home.html" , {})
I come up with code like that, that's why my query, is it feasible or not?
You define the redirection in the
urls.py
. In fact, what you are interested in is defining anything other than an article before defining the routes for the articles, and these show them from a fieldslug
. For example, if you have pages in addition to articles:I hope it helps