On Thu, Feb 20, 2020 at 11:38 PM Phil Kauffman <kauffman.p...@gmail.com>
wrote:

> Hello,
>
> Newbie in need of a little shove. It seems I need to review the purpose of
> the urls.py file. At present I am getting an HTTP Error 405 with the
> following:
>
HTTP 405 error code states the the HTTP method is not allowed on the
endpoint (https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405)

>
> urls.py:
> path('', views.show_site, name = 'home'),
> path('site-view', views.List.as_view(), name='site-view')
>
> views.py
> class List(ListView):
>     def get_queryset(self, *args, **kwargs):
>         return Profile.objects.filter(sitename_id=self.kwargs['pk'])
>
You need to define the post() method yourself,

>
> def show_site(request):
>     form = SelectSite()
>     if request.method == 'POST':
>         form = SelectSite(request.POST)
>         if form.is_valid():
>             pass
>     else:
>         form = SelectSite()
>     return render(request, 'app/home.html', {'form': form})
>
> home.html
> {% extends 'app\base.html' %}
>
> {% block title %}Site Home{% endblock %}
> {% block content %}
> <h1>This Form is Terrible</h1>
> <form action={% url 'site-view' %} method="post">{% csrf_token %}
>     <p> {{form}} </p>
> <input type="submit" value="Submit"/>
> </form>
> {% endblock %}
>
> Any guidance would be greatly appreciated.
>
> Thank You
>
> --
> 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/10be0e68-da3f-42cd-a095-96d6d2a5617f%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/10be0e68-da3f-42cd-a095-96d6d2a5617f%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAD%3DM5eRtsXUhGdjNvmMCjtBeG6OyQmJcwG3tjDyzfQ_GmX_pvQ%40mail.gmail.com.

Reply via email to