1π
I think as your template name is conflicting with each other. You can make one templates folder for you whole project like this
Project
|>Templates
|>store
|>home
In templates, you can put your templates like this
Project
|>Templates
store
|>index.html
home
|>index.html
|store
|home
Now you can give path of your template like this
def index(request):
return render(
request,
'home/index.html'
)
If you want to keep templates in directory under you app, then this issue might help you.
4π
You need to anchor and terminate the pattern for the root view:
url(r'^$', 'home.views.index', name='view_home'),
0π
You have a trailing slash β/β in
url(r'^store/$', 'store.views.store_list', name='view_store_list')
so it will be valid for the url localhost:8000/store/
but not for the url localhost:8000/store
. So you need to remove trailing slash.
Plus @Daniel is right you need the put the home URL like he mentioned in his answer. Trailing slash is the reason you could not get it to work after changing the home URL.
0π
The first problem, as mentioned by Daniel is the url pattern, if you just set the empty string it will always match. Therefore you should use url(r'^$', 'home.views.index', name='view_home')
. With r'^$'
you are saying that the pattern match only with the empty string. Alternatively you can move this url at the end of the list and it will be used as the default view if anything else matches.
The second problem I see is that in your store_list
view you are returning:
return render(
request,
'index.html',
{
'stores': stores,
}
)
Are you using the same template, index.html
, for both index and store or is it just a copy and paste error? If so, are you sure that the stores
variable contains data? If you donβt have any result the outcome will be the same as the index view.
- [Django]-Is it possible to run ubuntu terminal commands using DJango
- [Django]-Django admin custom commands β passing a list of strings into args
- [Django]-PayPal Python Pay request ClientDetails
- [Django]-Show management commands in admin site