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')


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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.