Hello. I want to insert data into django db from a function in the views.py file.
I'm using linux, python 3.4, django 1.8.2, PyMySQL
from django.db import models class Publisher(models.Model): name = models.CharField(max_length=30) city = models.CharField(max_length=60)
from django.http import HttpResponse import pymysql from books.models import Publisher def send(request): p = Publisher(name='Apress', city='Berkeley') p.save()
from niloofar.views import send url(r'^index/', send),
I want when the page index is loaded, the send function works and insert data to database but it does not give any error and also nothing happened when i refreshed the index page.
I don't know how but the problem fixed after rebooting system.
We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.