Re: Django URL routing

2020-05-07 Thread Ronald Kamulegeya
Hi Roseman,

Your comment pointed me to the right direction.

I have finally cracked the mystery!

Thanks so much!

On Thursday, May 7, 2020 at 5:17:22 PM UTC+3, Ronald Kamulegeya wrote:
>
> Here is my attempt at creating unique path:
> Still i get page not found error. The index page is not opening too.
> urlpatterns = [
> path("tenants/", views.TenantsListView.as_view(), name="index"),
> path("tenants/details",views.TenantDetailView.as_view(),name="detail"
> ),
> path("tenants/add",views.createTenant, name='createTenant'), 
> path("tenants/edit//",views.TenantUpdateView.as_view(), name=
> 'edit'),
> path("tenants/delete//",views.delete, name='delete'),   
>  
> ]
> urlpatterns = [
> path('', include('rentals.urls',namespace='rentals')),
> path('admin/', admin.site.urls),
>
> On Thursday, May 7, 2020 at 3:53:44 PM UTC+3, Ronald Kamulegeya wrote:
>>
>> Hello Roseman,
>> Please suggest how i can code the different Urls.
>>
>>
>> On Thursday, May 7, 2020 at 3:24:28 PM UTC+3, Daniel Roseman wrote:
>>>
>>> You have multiple URLs that are the same path. That can't work. One URL 
>>> maps to one view.
>>> -- 
>>> DR.
>>>
>>> On Thursday, 7 May 2020 11:40:09 UTC+1, Ronald Kamulegeya wrote:

 I am learning Django and progressing well but i am stuck on how to 
 configure the different urls to view functions. 
 I have gone through tutorials and URL routing seems pretty 
 straight forward but i cant make it work in my apps.

 I am almost hitting a brick wall. I dont see anything wrong i have done.

 What happens is that the index view and admin interface opens.

 But connecting from the index view to other pages raises the 404 error.

 [image: project-s.png]
 I created a project TenancyMGt and added  app rentals as shown above.
 I have created several views in the module views.py Two are relevant 
 here:

 def createTenant(request):
 form = TenantsForm
 context = {'form': form}
 html_form = render_to_string('rentals/partial_tenant_create.html',
 context,
 request=request,
 )
 return JsonResponse({'html_form': html_form})class 
 TenantsListView(ListView):
 model = Tenants
 context_object_name = 'tenant_list'
 template_name = 'rentals/tenants_list.html'
 paginate_by = 5
 def get_queryset(self):
 return Tenants.objects.all()

 Now i created a file urls.py under the app rentals:

 from . import viewsfrom django.urls import path
 app_name='rentals'
 urlpatterns = [
 path("", views.TenantsListView.as_view(), name="index"),
 path("",views.TenantDetailView.as_view,name="detail"),
 path("",views.createTenant, name='createTenant'), 
 path("/",views.TenantUpdateView.as_view, name='edit'),
 path("/",views.delete, name='delete'),
 ]

 under TenancyMgr/urls, i add the following:

 from django.contrib import adminfrom django.urls import path,includefrom 
 rentals import views

 urlpatterns = [
 path('admin/', admin.site.urls),
 path('', include('rentals.urls')),
 ]

 When i run the server, the index view opens successfully! From the index, 
 i want to open the createTenant view as below.

 >>> data-url="{% url 'rentals:createTenant' %}>
   
   New Tenant
 

 When the button is clicked, i get the urls below:

 http://127.0.0.1:8000/rentals/createTenant/

 Then i get the response is 404,page not found error.

 But this opens admin page:

 http://127.0.0.1:8000/admin/

 So far i have failed to crack the secret of how the Urls work. I have gone 
 through several tutorials and i see the same set up as mine.

 I am requesting for guidance on how to crack the puzzle i.e make the other 
 urls work.

 Ronald



-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/162a7ab5-0c45-4c94-a00e-122823056234%40googlegroups.com.


Re: Django URL routing

2020-05-07 Thread Ronald Kamulegeya
Here is my attempt at creating unique path:
Still i get page not found error. The index page is not opening too.
urlpatterns = [
path("tenants/", views.TenantsListView.as_view(), name="index"),
path("tenants/details",views.TenantDetailView.as_view(),name="detail"),
path("tenants/add",views.createTenant, name='createTenant'), 
path("tenants/edit//",views.TenantUpdateView.as_view(), name=
'edit'),
path("tenants/delete//",views.delete, name='delete'),   
 
]
urlpatterns = [
path('', include('rentals.urls',namespace='rentals')),
path('admin/', admin.site.urls),
   
On Thursday, May 7, 2020 at 3:53:44 PM UTC+3, Ronald Kamulegeya wrote:
>
> Hello Roseman,
> Please suggest how i can code the different Urls.
>
>
> On Thursday, May 7, 2020 at 3:24:28 PM UTC+3, Daniel Roseman wrote:
>>
>> You have multiple URLs that are the same path. That can't work. One URL 
>> maps to one view.
>> -- 
>> DR.
>>
>> On Thursday, 7 May 2020 11:40:09 UTC+1, Ronald Kamulegeya wrote:
>>>
>>> I am learning Django and progressing well but i am stuck on how to 
>>> configure the different urls to view functions. 
>>> I have gone through tutorials and URL routing seems pretty 
>>> straight forward but i cant make it work in my apps.
>>>
>>> I am almost hitting a brick wall. I dont see anything wrong i have done.
>>>
>>> What happens is that the index view and admin interface opens.
>>>
>>> But connecting from the index view to other pages raises the 404 error.
>>>
>>> [image: project-s.png]
>>> I created a project TenancyMGt and added  app rentals as shown above.
>>> I have created several views in the module views.py Two are relevant 
>>> here:
>>>
>>> def createTenant(request):
>>> form = TenantsForm
>>> context = {'form': form}
>>> html_form = render_to_string('rentals/partial_tenant_create.html',
>>> context,
>>> request=request,
>>> )
>>> return JsonResponse({'html_form': html_form})class 
>>> TenantsListView(ListView):
>>> model = Tenants
>>> context_object_name = 'tenant_list'
>>> template_name = 'rentals/tenants_list.html'
>>> paginate_by = 5
>>> def get_queryset(self):
>>> return Tenants.objects.all()
>>>
>>> Now i created a file urls.py under the app rentals:
>>>
>>> from . import viewsfrom django.urls import path
>>> app_name='rentals'
>>> urlpatterns = [
>>> path("", views.TenantsListView.as_view(), name="index"),
>>> path("",views.TenantDetailView.as_view,name="detail"),
>>> path("",views.createTenant, name='createTenant'), 
>>> path("/",views.TenantUpdateView.as_view, name='edit'),
>>> path("/",views.delete, name='delete'),
>>> ]
>>>
>>> under TenancyMgr/urls, i add the following:
>>>
>>> from django.contrib import adminfrom django.urls import path,includefrom 
>>> rentals import views
>>>
>>> urlpatterns = [
>>> path('admin/', admin.site.urls),
>>> path('', include('rentals.urls')),
>>> ]
>>>
>>> When i run the server, the index view opens successfully! From the index, i 
>>> want to open the createTenant view as below.
>>>
>>> 
>>>   New Tenant
>>> 
>>>
>>> When the button is clicked, i get the urls below:
>>>
>>> http://127.0.0.1:8000/rentals/createTenant/
>>>
>>> Then i get the response is 404,page not found error.
>>>
>>> But this opens admin page:
>>>
>>> http://127.0.0.1:8000/admin/
>>>
>>> So far i have failed to crack the secret of how the Urls work. I have gone 
>>> through several tutorials and i see the same set up as mine.
>>>
>>> I am requesting for guidance on how to crack the puzzle i.e make the other 
>>> urls work.
>>>
>>> Ronald
>>>
>>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/546fa5a3-f824-438b-b8b2-e986a16b0552%40googlegroups.com.


Re: Django URL routing

2020-05-07 Thread Ronald Kamulegeya
Hello Roseman,
Please suggest how i can code the different Urls.


On Thursday, May 7, 2020 at 3:24:28 PM UTC+3, Daniel Roseman wrote:
>
> You have multiple URLs that are the same path. That can't work. One URL 
> maps to one view.
> -- 
> DR.
>
> On Thursday, 7 May 2020 11:40:09 UTC+1, Ronald Kamulegeya wrote:
>>
>> I am learning Django and progressing well but i am stuck on how to 
>> configure the different urls to view functions. 
>> I have gone through tutorials and URL routing seems pretty 
>> straight forward but i cant make it work in my apps.
>>
>> I am almost hitting a brick wall. I dont see anything wrong i have done.
>>
>> What happens is that the index view and admin interface opens.
>>
>> But connecting from the index view to other pages raises the 404 error.
>>
>> [image: project-s.png]
>> I created a project TenancyMGt and added  app rentals as shown above.
>> I have created several views in the module views.py Two are relevant here:
>>
>> def createTenant(request):
>> form = TenantsForm
>> context = {'form': form}
>> html_form = render_to_string('rentals/partial_tenant_create.html',
>> context,
>> request=request,
>> )
>> return JsonResponse({'html_form': html_form})class 
>> TenantsListView(ListView):
>> model = Tenants
>> context_object_name = 'tenant_list'
>> template_name = 'rentals/tenants_list.html'
>> paginate_by = 5
>> def get_queryset(self):
>> return Tenants.objects.all()
>>
>> Now i created a file urls.py under the app rentals:
>>
>> from . import viewsfrom django.urls import path
>> app_name='rentals'
>> urlpatterns = [
>> path("", views.TenantsListView.as_view(), name="index"),
>> path("",views.TenantDetailView.as_view,name="detail"),
>> path("",views.createTenant, name='createTenant'), 
>> path("/",views.TenantUpdateView.as_view, name='edit'),
>> path("/",views.delete, name='delete'),
>> ]
>>
>> under TenancyMgr/urls, i add the following:
>>
>> from django.contrib import adminfrom django.urls import path,includefrom 
>> rentals import views
>>
>> urlpatterns = [
>> path('admin/', admin.site.urls),
>> path('', include('rentals.urls')),
>> ]
>>
>> When i run the server, the index view opens successfully! From the index, i 
>> want to open the createTenant view as below.
>>
>> 
>>   New Tenant
>> 
>>
>> When the button is clicked, i get the urls below:
>>
>> http://127.0.0.1:8000/rentals/createTenant/
>>
>> Then i get the response is 404,page not found error.
>>
>> But this opens admin page:
>>
>> http://127.0.0.1:8000/admin/
>>
>> So far i have failed to crack the secret of how the Urls work. I have gone 
>> through several tutorials and i see the same set up as mine.
>>
>> I am requesting for guidance on how to crack the puzzle i.e make the other 
>> urls work.
>>
>> Ronald
>>
>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fd94d9a1-1c90-4544-b795-e4a8f89fb116%40googlegroups.com.


Re: Django URL routing

2020-05-07 Thread LGBS fine soul coders
Yaaahhh

On Thu, 7 May 2020, 15:24 Daniel Roseman,  wrote:

> You have multiple URLs that are the same path. That can't work. One URL
> maps to one view.
> --
> DR.
>
> On Thursday, 7 May 2020 11:40:09 UTC+1, Ronald Kamulegeya wrote:
>>
>> I am learning Django and progressing well but i am stuck on how to
>> configure the different urls to view functions.
>> I have gone through tutorials and URL routing seems pretty
>> straight forward but i cant make it work in my apps.
>>
>> I am almost hitting a brick wall. I dont see anything wrong i have done.
>>
>> What happens is that the index view and admin interface opens.
>>
>> But connecting from the index view to other pages raises the 404 error.
>>
>> [image: project-s.png]
>> I created a project TenancyMGt and added  app rentals as shown above.
>> I have created several views in the module views.py Two are relevant here:
>>
>> def createTenant(request):
>> form = TenantsForm
>> context = {'form': form}
>> html_form = render_to_string('rentals/partial_tenant_create.html',
>> context,
>> request=request,
>> )
>> return JsonResponse({'html_form': html_form})class 
>> TenantsListView(ListView):
>> model = Tenants
>> context_object_name = 'tenant_list'
>> template_name = 'rentals/tenants_list.html'
>> paginate_by = 5
>> def get_queryset(self):
>> return Tenants.objects.all()
>>
>> Now i created a file urls.py under the app rentals:
>>
>> from . import viewsfrom django.urls import path
>> app_name='rentals'
>> urlpatterns = [
>> path("", views.TenantsListView.as_view(), name="index"),
>> path("",views.TenantDetailView.as_view,name="detail"),
>> path("",views.createTenant, name='createTenant'),
>> path("/",views.TenantUpdateView.as_view, name='edit'),
>> path("/",views.delete, name='delete'),
>> ]
>>
>> under TenancyMgr/urls, i add the following:
>>
>> from django.contrib import adminfrom django.urls import path,includefrom 
>> rentals import views
>>
>> urlpatterns = [
>> path('admin/', admin.site.urls),
>> path('', include('rentals.urls')),
>> ]
>>
>> When i run the server, the index view opens successfully! From the index, i 
>> want to open the createTenant view as below.
>>
>> 
>>   New Tenant
>> 
>>
>> When the button is clicked, i get the urls below:
>>
>> http://127.0.0.1:8000/rentals/createTenant/
>>
>> Then i get the response is 404,page not found error.
>>
>> But this opens admin page:
>>
>> http://127.0.0.1:8000/admin/
>>
>> So far i have failed to crack the secret of how the Urls work. I have gone 
>> through several tutorials and i see the same set up as mine.
>>
>> I am requesting for guidance on how to crack the puzzle i.e make the other 
>> urls work.
>>
>> Ronald
>>
>> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4cc1d70b-119e-4f07-9867-f4c9786fbabc%40googlegroups.com
> 
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKNQJk5xgmPLPA7-Drhtgc4andjuZ8yqh3sbAMaQ25zDATG-DA%40mail.gmail.com.


Re: Django URL routing

2020-05-07 Thread Daniel Roseman
You have multiple URLs that are the same path. That can't work. One URL 
maps to one view.
-- 
DR.

On Thursday, 7 May 2020 11:40:09 UTC+1, Ronald Kamulegeya wrote:
>
> I am learning Django and progressing well but i am stuck on how to 
> configure the different urls to view functions. 
> I have gone through tutorials and URL routing seems pretty 
> straight forward but i cant make it work in my apps.
>
> I am almost hitting a brick wall. I dont see anything wrong i have done.
>
> What happens is that the index view and admin interface opens.
>
> But connecting from the index view to other pages raises the 404 error.
>
> [image: project-s.png]
> I created a project TenancyMGt and added  app rentals as shown above.
> I have created several views in the module views.py Two are relevant here:
>
> def createTenant(request):
> form = TenantsForm
> context = {'form': form}
> html_form = render_to_string('rentals/partial_tenant_create.html',
> context,
> request=request,
> )
> return JsonResponse({'html_form': html_form})class 
> TenantsListView(ListView):
> model = Tenants
> context_object_name = 'tenant_list'
> template_name = 'rentals/tenants_list.html'
> paginate_by = 5
> def get_queryset(self):
> return Tenants.objects.all()
>
> Now i created a file urls.py under the app rentals:
>
> from . import viewsfrom django.urls import path
> app_name='rentals'
> urlpatterns = [
> path("", views.TenantsListView.as_view(), name="index"),
> path("",views.TenantDetailView.as_view,name="detail"),
> path("",views.createTenant, name='createTenant'), 
> path("/",views.TenantUpdateView.as_view, name='edit'),
> path("/",views.delete, name='delete'),
> ]
>
> under TenancyMgr/urls, i add the following:
>
> from django.contrib import adminfrom django.urls import path,includefrom 
> rentals import views
>
> urlpatterns = [
> path('admin/', admin.site.urls),
> path('', include('rentals.urls')),
> ]
>
> When i run the server, the index view opens successfully! From the index, i 
> want to open the createTenant view as below.
>
> 
>   New Tenant
> 
>
> When the button is clicked, i get the urls below:
>
> http://127.0.0.1:8000/rentals/createTenant/
>
> Then i get the response is 404,page not found error.
>
> But this opens admin page:
>
> http://127.0.0.1:8000/admin/
>
> So far i have failed to crack the secret of how the Urls work. I have gone 
> through several tutorials and i see the same set up as mine.
>
> I am requesting for guidance on how to crack the puzzle i.e make the other 
> urls work.
>
> Ronald
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4cc1d70b-119e-4f07-9867-f4c9786fbabc%40googlegroups.com.


Re: Django URL routing

2020-05-07 Thread ROBSON SOUZA
You are missing parenteses right after as_view in urls.py 

Enviado do meu iPhone

Em 7 de mai de 2020, à(s) 03:22, Ronald Kamulegeya 
 escreveu:

> I am learning Django and progressing well but i am stuck on how to configure 
> the different urls to view functions. 
> I have gone through tutorials and URL routing seems pretty straight forward 
> but i cant make it work in my apps.
> 
> I am almost hitting a brick wall. I dont see anything wrong i have done.
> 
> What happens is that the index view and admin interface opens.
> 
> But connecting from the index view to other pages raises the 404 error.
> 
> 
> 
> I created a project TenancyMGt and added  app rentals as shown above.
> I have created several views in the module views.py Two are relevant here:
> def createTenant(request):
> form = TenantsForm
> context = {'form': form}
> html_form = render_to_string('rentals/partial_tenant_create.html',
> context,
> request=request,
> )
> return JsonResponse({'html_form': html_form})
> class TenantsListView(ListView):
> model = Tenants
> context_object_name = 'tenant_list'
> template_name = 'rentals/tenants_list.html'
> paginate_by = 5
> def get_queryset(self):
> return Tenants.objects.all()
> Now i created a file urls.py under the app rentals:
> from . import views
> from django.urls import path
> app_name='rentals'
> urlpatterns = [
> path("", views.TenantsListView.as_view(), name="index"),
> path("",views.TenantDetailView.as_view,name="detail"),
> path("",views.createTenant, name='createTenant'), 
> path("/",views.TenantUpdateView.as_view, name='edit'),
> path("/",views.delete, name='delete'),
> 
> ]
> under TenancyMgr/urls, i add the following:
> from django.contrib import admin
> from django.urls import path,include
> from rentals import views
> 
> urlpatterns = [
> path('admin/', admin.site.urls),
> path('', include('rentals.urls')),
> 
> ]
> When i run the server, the index view opens successfully! From the index, i 
> want to open the createTenant view as below.
> 
>   New Tenant
> 
> When the button is clicked, i get the urls below:
> http://127.0.0.1:8000/rentals/createTenant/
> Then i get the response is 404,page not found error.
> But this opens admin page:
> http://127.0.0.1:8000/admin/
> So far i have failed to crack the secret of how the Urls work. I have gone 
> through several tutorials and i see the same set up as mine.
> 
> I am requesting for guidance on how to crack the puzzle i.e make the other 
> urls work.
> 
> Ronald
> 
> -- 
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/29c8fdd0-5c82-4ccf-98f9-33e05b8e5ab1%40googlegroups.com.
> 

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1AD1D392-7270-48A8-97D2-E8C1E5C31214%40gmail.com.