Example #1
0
def add_pup():
    form = AddForm()
    if form.validate_on_submit():
        name = form.name.data
        pup = Puppy(name)
        db.session.add(pup)
        db.session.commit()
        return redirect(url_for('puppies.list_pup'))
    return render_template('addpup.html', form=form)
def add():
    form = AddForm()
    if form.validate_on_submit():
        name = form.name.data
        new_pup = Puppy(name)
        db.session.add(new_pup)
        db.session.commit()
        return redirect(url_for('puppies.list'))
    return render_template("add.html", form=form)
Example #3
0
def add():
    form=AddForm()

    if form.validate_on_submit():
        name=form.name.data
        pup_name=Puppy(name)
        db.session.add_all([pup_name])
        db.session.commit()
        return (redirect(url_for('puppies.list')))
    return(render_template('add.html',form=form))
Example #4
0
def add_pup():
	form=AddForm()

	if form.validate_on_submit():
		name=form.name.data
		new_pup=Puppy(name)
		db.session.add(new_pup)
		db.session.commit()
		flash('Puppy Added Successfully!')
		return redirect(url_for('puppies.list_pup'))
	return render_template('add.html',form=form)
Example #5
0
def add():
    form = AddForm()
    if form.validate_on_submit():

        name = form.name.data
        # flash(f"{name.capitalize()} has been added to the database!",
        #       category="success")
        new_pup = Puppy(name)
        db.session.add(new_pup)
        db.session.commit()

        return redirect(url_for('puppies.list'))
    return render_template('add.html', form=form)
Example #6
0
def add():
    form = AddForm()

    if form.validate_on_submit():
        name = form.name.data

        # Add new student to database
        new_pup = Puppy(name)
        db.session.add(new_pup)
        db.session.commit()

        return redirect(url_for('students.list'))

    return render_template('add.html', form=form)
Example #7
0
def add():
    form = AddForm()
    if form.validate_on_submit():
        name = form.name.data
        owner = form.owner.data
        if owner == '':
            new_pup = Puppy(name, None)
        else:
            new_pup = Puppy(name, owner)
        db.session.add(new_pup)
        db.session.commit()
        flash(f"We added {new_pup.name} to our database!")
        #return redirect(url_for('puppies.list'))
    return render_template("add.html", form=form)
def add():

    #create form
    form = AddForm()

    #Add puppy to database
    if form.validate_on_submit():
        name = form.name.data

        new_pup = Puppy(name)
        db.session.add(new_pup)
        db.session.commit()

        return redirect(url_for('puppies.list'))
    return render_template('add.html', form=form)
def add():

    form = AddForm()

    if form.validate_on_submit():
        name = form.name.data
        #add now owner to database
        new_pup = Puppy(name)
        db.session.add(new_pup)
        db.session.commit()

        #blueprintname = puppies and #view (function) -> list()
        return redirect(url_for('puppies.list'))

    return render_template('add.html', form=form)
def add():
    form = AddForm()

    if form.validate_on_submit():
        name = form.name.data

        # Add new Puppy to database
        new_pup = Puppy(name)
        db.session.add(new_pup)
        db.session.commit()

        return redirect(
            url_for('puppies.list')
        )  #note like now we specify it's the 'list' view function from puppies by the 'puppies.list'

    return render_template('add.html', form=form)
Example #11
0
def add():
    form = AddForm()

    if form.validate_on_submit():
        name = form.name.data
        color = form.color.data
        breed = form.breed.data

        # Add new Puppy to database
        new_pup = Puppy(name, color, breed)
        db.session.add(new_pup)
        db.session.commit()

        return redirect(url_for('puppies.list'))

    return render_template('add.html', form=form)