Posts

Status Codes

Note     1xx: Informational - Request received, continuing process     2xx: Success - The action was successfully received, understood, and accepted     3xx: Redirection - Further action must be taken in order to complete the request     4xx: Client Error - The request contains bad syntax or cannot be fulfilled     5xx: Server Error - The server failed to fulfill an apparently valid request         Available Formats Value     Description    100     Continue 101     Switching Protocols 102     Processing 103-199     Unassigned     200     OK 201     Created 202     Accepted 203     Non-Authoritative Information 204     No Content 205     Reset Content 206     Parti...

How to write simple unit test in django

Success Run test file ============== tests.py ===== from django.test import TestCase # Create your tests here. class TestStringMethods(TestCase):     def test_upper(self):         self.assertEqual('foo'.upper(), 'FOO')     def test_isupper(self):         self.assertTrue('FOO'.isupper())         self.assertFalse('Foo'.isupper()) Success Run test file ============== $./manage.py test Creating test database for alias 'default'... .. ---------------------------------------------------------------------- Ran 2 tests in 0.664s OK Destroying test database for alias 'default'... --------------------------- Failed Run test file ============ tests.py ===== from django.test import TestCase # Create your tests here. class TestStringMethods(TestCase):     def test_upper(self):      ...

How to write logging in django

settings.py ------------------ # https://docs.python.org/2/library/logging.html#logrecord-attributes   LOGGING = {     'version': 1,     'disable_existing_loggers': False,     'formatters':{         'details':{             'format':'%(asctime)s %(process)d %(filename)s %(funcName)s %(lineno)d %(levelname)s %(message)s'         },     },     'handlers': {         'file': {             'level': 'DEBUG',             'class': 'logging.FileHandler',             'filename': 'location for/ log file/debug.log',             'formatter': '...

How to copy files from remote to home machine using scp

$ scp <domain name>:/home/file.txt /home/sanu/Videos/

NameError: name 'logging' is not defined

logger = logging.getLogger(__name__) NameError: name 'logging' is not defined this error is occurs due to you are not import loggin >>>import logging

AttributeError: Got AttributeError when attempting to get a value for field `abc` on serializer `PfleSerializer`. The serializer field might be named incorrectly and not match any attribute or key on the `QuerySet` instance. Original exception text was: 'QuerySet' object has no attribute 'abc'.

AttributeError: Got AttributeError when attempting to get a value for field `abc` on serializer ` PfleSerializer `. The serializer field might be named incorrectly and not match any attribute or key on the `QuerySet` instance. Original exception text was: 'QuerySet' object has no attribute 'abc'. >>> p=Pfle.objects.all() >>> seri=PfleSerializer(p,many=True) >>> seri.data

How to rename folder using command prompt

mv oldfolder/ newfolder/