1👍
add some log to your addwriter view. Just like this
logger = logging.getLogger(__name__)
def addwriter(request,name):
logger.debug("the coming request is: {}, and the name is: {}".format(request, name))
nimos = Writer(name=name);
nimos.save();
return render_to_response("addJournalist.html",{"name":nimos.name})
I think you just like @Rohan said, you send 3 request to this view. Your python code work correctly.
here is my naive test code
from django.test import TestCase
from .models import Writer
class WriterTestCase(TestCase):
def test_writer_name_function(self):
for i in range(3):
self.client.get("/new/George/")
writer_set = Writer.objects.all()
self.assertEqual(writer_set.count(), 3)
PS: before add the logger code, make sure you have set up logging in django
1👍
m sorry i know now the answer i simply included static files for css and imgs by a wrong way embedded in html so the browser made the request three times im very sorry for bothering you
Source:stackexchange.com