calling index.html

11 visualizações
Pular para a primeira mensagem não lida

Tato Müller

não lida,
28 de set. de 2019, 18:26:4528/09/2019
para Django users
Hi everyone.

How can i call an html page when i request the root of my app, like http://127.0.0.1:8000/app.
I want index.html loads when i call this url.

Could you help me?

Lim Kai Wey

não lida,
29 de set. de 2019, 00:44:0429/09/2019
para django...@googlegroups.com
Greetings Müller,

In order for your template to load for that specific page, you have to state it under that page’s view in views.py

Eg:
class IndexView():
       template_name = “index.html”

// Or if it’s a function view

def index(request):
    
    return render(request, 'app/index.html', context)

Hope it helps!

Sincerely,
Kai Wey

Lim Kai Wey

não lida,
29 de set. de 2019, 00:50:5529/09/2019
para django...@googlegroups.com
Note: Nonetheless, you should read more about the documentation or the tutorials available since everything you need to start you first Django project is already there.

אורי

não lida,
29 de set. de 2019, 04:45:1629/09/2019
para django...@googlegroups.com
You can use generic.TemplateView to load an HTML template.

See for example:
 
Although, there are many options to use in your templates and usually it's better not to load a static HTML page.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d7441b68-9cf2-47ec-950e-b44b6bd9717c%40googlegroups.com.

RAJ musixx

não lida,
29 de set. de 2019, 08:23:1129/09/2019
para django...@googlegroups.com
1.GO to views.py and the index function 
2.def index(request):
       return render(request, 'index.html')
3.goto ur urls.py and write following

path(' ', name of your view.index, name = 'home' )

THis how u can render any page to browser as ur home page .
you need to import render in ur views file ...... check google how to import render.

Deepak

não lida,
29 de set. de 2019, 08:23:1629/09/2019
para django...@googlegroups.com
Basically bro,when you you serve project it takes the index file,You can change route from / to /app then you will be directed there.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d7441b68-9cf2-47ec-950e-b44b6bd9717c%40googlegroups.com.


--
Thanks
Deepak Paliwal
Mob 8619437133
Responder a todos
Responder ao autor
Encaminhar
0 nova mensagem