TypeError: record_club_minutes() fehlt 2 erforderlichen positions-Argumente: 'Kauf' und 'Fonds'

Ich mache eine app, in der die Studierenden geben Ihre club Daten und erstellen Minuten für Ihre jeweiligen Vereine. Jetzt bin ich laufen in einige Probleme, die versuchen, übergeben Sie diese zwei Variablen aus einem Formular in ein anderes (Kauf und Finanzierung); Sie hält auf dem geben der TypeError oben. Diese Variablen geben die Anzahl der Einträge für ein FormField in form. Es ist sehr wahrscheinlich, dass der Fehler in generate_minutes(user_id), weil wenn ich mit einer fest zugewiesenen integer in record_club_minutes(user_id, club_id, kaufen, Fonds), so dass Kauf=0 und Fonds=0, es funktionierte. Jede Hilfe wird sehr geschätzt!

routes.py

@login_required
def generate_minutes(user_id):
    user = User.query.get_or_404(user_id)
    # TODO: use the same form
    form = record_club_name_form(user)
    if form.validate_on_submit():
        # send user to the record_club_minutes
            club = form.club_list.data
            purchitems = form.purchaseitems.data
            funditems = form.funditems.data
            return redirect(url_for('clubs.record_club_minutes', user_id=user_id, club_id=club.id, purchase=purchitems, fund=funditems))
    return render_template('record_club_name.html', title='Record', form=form, user=user)

#THERE MAY BE BUGS HERE 
@clubs.route("/record_minutes/<int:user_id>/<int:club_id>/record", methods=['GET', 'POST'])
@login_required
def record_club_minutes(user_id, club_id, purchase, fund):
    user = User.query.get_or_404(user_id)
    club = Club.query.get_or_404(club_id)
    members = club.members
    form = create_club_minutes_form(club, purchase, fund)
    # form.purchaseform.entries = purchase
    # form.fundform.entries = fund
    if form.validate_on_submit():
            minute = Minutes(club_id=club_id, date=form.date.data, time=form.time.data, location=form.location.data, minute=form.notes.data)
            db.session.add(minute)
            for index, field in enumerate(form.attendance):
                if field:
                    attendance = Attendance(student_name=members[index].firstname + members[index].lastname)
                    minute.attendance.append(attendance)    
            db.session.commit()
            flash('Minutes successfully recorded', 'success')
            return redirect(url_for('clubs.view_club_name', user_id=user.id))
    return render_template('record_minutes.html', title='Record', form=form, user=user, club=club, members=members)

Hier ist forms.py für die record_club_minutes(user_id, club_id, Kauf, fund) vor.

def create_club_minutes_form(club, purchase, fund):
    num_members = len(club.members)
    class ClubMinutesForm(FlaskForm):
        date = DateField('Meeting Date (mm/dd/year)',
            validators=[DataRequired(), DateRange(max = date.today())],
            format = '%%m/%%d/%%Y')
        time = TimeField('Meeting Called to Order at')
        location = StringField('Meeting Place',
            validators=[DataRequired()],
            render_kw={"placeholder":"Room # or Area"})
        attendance = FieldList(BooleanField('Here'),
            min_entries=num_members,
            max_entries=num_members)
        purchaseform = FieldList(FormField(PurchaseOrderForms), 
            min_entries=purchase, 
            max_entries=purchase)
        purchasevote = FormField(MotionForms)
        fundform = FieldList(FormField(FundraiserForms), 
            min_entries=fund, 
            max_entries=fund)
        fundvote = FormField(MotionForms)
        notes = TextAreaField('Overview of Meeting', 
            validators=[DataRequired(), Length(min=10, max=500)])
        submit = SubmitField('Submit')

    return ClubMinutesForm()

Traceback

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask/app.py", line 2463, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask/app.py", line 2449, in wsgi_app
    response = self.handle_exception(e)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask/app.py", line 1866, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask_login/utils.py", line 261, in decorated_view
    return func(*args, **kwargs)
TypeError: record_club_minutes() missing 2 required positional arguments: 'purchase' and 'fund'
0
2019-09-18 06:26:58
Quelle
0 Antworten

Sehen Sie sich andere Fragen zu Tags an