Posts

Showing posts from June, 2016

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     Partial Content 207     Multi-Status 208     Already Reported 209-225     Unassigned      226     IM Used 227-299     Unassigned      300     Multiple Choices 301     Moved Permanently 302     Found 303     See Other 304     Not Modified 305     Use Proxy   306     (Unused)   307     Temporary Redirect   30

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):         self.assertEqual('foo', 'FOO')     def test_isupper(self):         self.assertTrue('FOO'.isupper())     

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': 'details',         },     },     'loggers': {         'employee.views': {             'handlers': ['file'],             'level': 'DEBUG',             'propagate': True,         },     }, } views.py -------------- import logging #Logging object logger = logging.getLogger(

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