コード例 #1
0
def create_subscribers(num):
    subscribers = []
    for i in range(num):
        subscriber = Subscriber()
        subscriber.name = fake.name()
        subscriber.phone = fake.phone_number()
        subscriber.email = fake.email()
        subscriber.address = fake.address()
        subscribers.append(subscriber)
    Subscriber.objects.insert(subscribers)
コード例 #2
0
def create_subscriber():
    form = SubscriberForm()
    if request.method == 'GET':
        return render_template('subscriber.html', form=form)
    elif request.method == 'POST':
        if form.submit.data:
            if form.validate_on_submit():
                subscriber = Subscriber()
                subscriber.name = form.name.data
                subscriber.email = form.email.data
                subscriber.phone = form.phone.data
                subscriber.address = form.address.data
                subscriber.save()
                flash("Subscriber created successfully", 'success')
        return redirect('/list')