. Rising Code Challenges Skip to main content

Posts

Showing posts from June, 2017

How to save a Form into database in Django

Django is the most popular framework for python. Here we'll discuss about save a form into database in Django. Step 1:  First create a model 'models.py' for DB table. we are creating a model named 'Request'. from django.db import models # Create your models here. class Request(models.Model): request_url = models.CharField(max_length=255) created_at = models.DateTimeField('date published') run command python manage.py migrate . This will create a table into your DB, with two columns.`request_url` and `created_at`. Step 2:  Now create a 'forms.py' to define your form. This will render a form in template with HTML code.  Here creating a form 'RequestForm'. from django import forms class RequestForm(forms.Form): request_url = forms.CharField(label="Enter your URL", max_length=500) we have a single field form 'request_url' Now import your model and form into your views. ...

For and Foreach loop in Javascript

Don't use for-in unless you use it with safeguards or are at least aware of why it might bite you. Your best bets are usually a for-of loop (ES2015+ only), Array#forEach ( spec | MDN ) (or its relatives some and such) (ES5+ only), a simple old-fashioned for loop, or for-in with safeguards. But there's lots more to explore, read on... JavaScript has powerful semantics for looping through arrays and array-like objects. I've split the answer into two parts: Options for genuine arrays, and options for things that are just array- like , such as the arguments object, other iterable objects (ES2015+), DOM collections, and so on. For Actual Arrays You have three options in ECMAScript 5 ("ES5"), the version most broadly supported at the moment, and will soon have two more in ECMAScript 2015 ("ES2015", "ES6"), the latest version of JavaScript that vendors are working on supporting: Use forEach and related (ES5+) Us...

How to add a new customer on stripe in php

The Stripe API is organized around REST. Our API has predictable, resource-oriented URLs, and uses HTTP response codes to indicate API errors. We use built-in HTTP features, like HTTP authentication and HTTP verbs, which are understood by off-the-shelf HTTP clients. We support cross-origin resource sharing, allowing you to interact securely with our API from a client-side web application (though you should never expose your secret API key in any public website's client-side code). JSON is returned by all API responses, including errors, although our API libraries convert responses to appropriate language-specific objects. Before create any payment request we have to create a customer on stripe. Stripe payment works with customer id. So it is necessary to create customer. There are several way to create a customer in diff languages. Here it is. To add a customer a token is must thing. We discuss about generate token in last article. Now we are assuming that you have alre...

How to implement Stripe.js v3 in php

 Stripe.js makes it easy to collect certain kinds of sensitive information without having it touch your server. If you need help after reading this, search our documentation or check out answers to common questions. You can even chat live with other developers in stripe on freenode. Stripe.js is our foundational JavaScript library for securely sending sensitive information to Stripe directly from the customer’s browser     However you’re using Stripe.js, you always begin by including the library and setting your API key. To get started, include this script on your pages—it should always be loaded directly from https://js.stripe.com:   < script src = "https://js.stripe.com/v3/" > </ script > Stripe.js Implementation  First we need to create a form to user's enter card details. <pre> < form action =" /payment/pay " method =" POST " id =" payment-form "> < input type =" hidden " name =...