1
Contributor
2
Replies
9
Views
1 Year
Discussion Span
Last Post by Niloofar24
0

models.py:

from django.db import models

class Publisher(models.Model):
    name = models.CharField(max_length=30)
    city = models.CharField(max_length=60)

views.py:

from django.http import HttpResponse
import pymysql
from books.models import Publisher

def send(request):
    p = Publisher(name='Apress', city='Berkeley')
    p.save()

urls.py

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.