db = pymysql.connect(host='localhost',
user='myuser',
passwd='welcome',
db='mydb',
charset='utf8')
app = Flask(__name__)
app.config['JSON_AS_ASCII'] = False
class Message(models.Model):
text = models.TextField()
manager = models.ForeignKey(Manager, models.SET_NULL, null=True, related_name="messages")
somemanager=Manager.objects.first()
messages=somemanager.messages
x = float('40.80')
a = int(x)
b = int(100 * (x - a))
print(a, b) # => 40 79
from decimal import Decimal
x = Decimal('40.80')
a = int(x)
b = int(100 * (x - a))
print(a, b) # => 40 80
a, b = map(int, '40.80'.split('.'))
print(a, b) # => 40 80
apt-get install nginx php-fpm
def post(self, request):
create_form = BookForm(request.POST)
if create_form.is_valid():
create_form.save()
response = {"data": "goes here"}
return HttpResponse(json.dumps(response), content_type='application/json')
$.ajax({
method: 'post',
url: your-url,
data: serialized-data
}).done(function(response){
console.log(response.data)
});
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
</div>