Are you in your application's urls.py or your project's urls.py? You need to be in your APPLICATION'S urls.py for this to work. Your application's folder has admin.py, apps.py, forms.py, etc.
def show(request):
context = {}
render(request, 'index.html', context=context)I still recommend you do something like this in your urls.py:
from django.urls import path
from . import views
path('', views.index, name='index'),<p><a href="{% url 'index' %}">Home Page</a></p>The views.index means "use this view called index" like so:
def index(request):
context ={}
render(request, 'index.html', context=context)I'd recommend you go to Mozilla's Django tutorial to learn a bit. They have some good explanations with phenomenal tutorials.
Does that make sense?
On Sunday, May 26, 2019 at 6:41:03 AM UTC-4, Saeed Pooladzadeh wrote:
Can you please explain. But I have seen in one of my app it works with just second one!!
در یکشنبه 26 مهٔ 2019، ساعت 3:49:59 (UTC+4:30)، Yoo نوشته:First one. Usually I'd have it be views.index. Otherwise, the first one is perfectly fine. Need explanation?
On Saturday, May 25, 2019 at 7:14:18 PM UTC-4, Saeed Pooladzadeh wrote:HelloWich of them is the right method for url mapping:path('', views.show, name='index'),orpath('index', views.show),Regards,Saeed
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f702f59f-752b-49b8-8193-0bfe25b91d72%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment