Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7972781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:57:04+00:00 2026-06-04T07:57:04+00:00

For a given slot the user selects (which should have time, club, day, and

  • 0

For a given slot the user selects (which should have time, club, day, and court associated with it), how do I save the value stored in “username” to the “reservation” field in class Opening?

def vote(request, club_id):
    if 'username' in request.POST and request.POST['username'] and 'slot' in request.POST and request.POST['slot']:
        username = request.POST['username']
        slot = request.POST['slot']
        #save the value stored in "username" to the "reservation" field in class Opening with the other associated data (club, time, day, court)
        return HttpResponseRedirect('reserve/templates/booked.html',{'username':username, 'slot':slot})
    else:
        return render_to_response('reserve/templates/vote.html', {'error': True})

Avail_times.html:

<form action="/clubs/{{ club.id }}/vote/" method="post">
{% csrf_token %}
{{ today }}<br>
{% for slot in open_slots %}
    <input type="checkbox" name="slot" id="slot{{ forloop.counter }}" value="{{ slot.id }}" />
    <label for="slot{{ forloop.counter }}">{{ slot.slot }} on Court {{slot.court}}</label><br />
{% endfor %}

<br>
{{ tomorrow }}<br>
{% for slot in tom_open_slots %}
    <input type="checkbox" name="slot" id="slot{{ forloop.counter }}" value="{{ slot.id }}" />
    <label for="slot{{ forloop.counter }}">{{ slot.slot }} on Court {{slot.court}}</label><br />
{% endfor %}    
<input type="text" name="username" />
<input type="submit" value="Reserve" />

Model:

from django.db import models
import datetime

class Club(models.Model):
    establishment = models.CharField(max_length=200)
    address = models.CharField(max_length=200)
    def __unicode__(self):
        return self.establishment

class Court(models.Model):
    club = models.ForeignKey(Club)
    day = models.ForeignKey(Day)
    court = models.IntegerField(max_length=200)
    def __unicode__(self):
        return unicode(self.court)

class Opening(models.Model):
    club = models.ForeignKey(Club)
    day = models.DateField('date')
    court = models.ForeignKey(Court)
    slot = models.TimeField('slot')
    reservation = models.CharField(max_length=200)
    def __unicode__(self):
        return unicode(self.slot)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:57:05+00:00Added an answer on June 4, 2026 at 7:57 am

    If you want to update the Opening model, then you need to know which one.

    Write the opening_id into the form. I’m not sure how your slots and openings are related so you’ll have to figure this bit out.

    I’d usually use get_object_or_404 to get the relevant Opening

    username = request.POST['username']
    opening = get_object_or_404(Opening, id=request.POST['opening_id'])
    opening.reservation = username
    opening.save()
    

    You’d also want to check that the user is allowed to update that opening.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have multiple binary trees stored as an array. In each slot is either
So recently I was given a problem, which I have been mulling over and
I have a table like this id item user slot I want the SLOT
Given that the web application doesn't have su privileges, I'd like to execute a
Given a certain date, I want to set the value of a cell with
Given the following code: $(.force-selection).blur(function() { var value = $('matched-item').val(); //check if the input's
I have to create a table with cells on which by clicking I have
Here's the problem. Given a large/intricate datatemplate A, which has 3 sections - General,
I have an Object X which owns (owns pointers to and initializes) Objects Y1..10
I have the following model: from django.db import models import datetime class Club(models.Model): establishment

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.