So something like this?
def site(request, site_id):
    site = get_object_or_404(Site.name, pk=site_id)
    
def sitesubmit(request):
    #    site=get_object_or_404(Site, pk=site_id)
    form = SelectSite()
    if request.method == 'POST':
        form = SelectSite(request.POST)
        if form.is_valid():
            instance = form.save(commit=False)
            instance.name = site.site_id
            instance.save()
    else:
        form = SelectSite()
    return render(request, 'app/home.html', {'form': form})

I'm just learning this stuff. If you can think of any posts or examples 
please let me know.

On Thursday, February 20, 2020 at 1:16:07 PM UTC-5, OnlineJudge95 wrote:

>
>
> On Thu, Feb 20, 2020 at 11:38 PM Phil Kauffman <kauffm...@gmail.com 
> <javascript:>> 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...@googlegroups.com <javascript:>.
>> 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/ba1394b9-1fde-442e-9d4d-e67e32b2f694%40googlegroups.com.

Reply via email to