Форум сайта python.su
STATIC_ROOT = '' STATIC_URL = '/static/' TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')] STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
[08/May/2015 14:46:03] "GET /accounts/profile/ HTTP/1.1" 200 4118 [08/May/2015 14:46:03] "GET /static//css/bootstrap.css HTTP/1.1" 304 0 [08/May/2015 14:46:03] "GET /static/css/sticky-footer-navbar.css HTTP/1.1" 304 0 [08/May/2015 14:46:03] "GET /static/css/style.css HTTP/1.1" 404 1643 [08/May/2015 14:46:03] "GET /static/css/tables.css HTTP/1.1" 304 0 [08/May/2015 14:46:03] "GET /static/js/jquery-2.1.3.min.js HTTP/1.1" 304 0 [08/May/2015 14:46:03] "GET /static/js/ajax.js HTTP/1.1" 304 0 [08/May/2015 14:46:03] "GET /static/js/tables.js HTTP/1.1" 304 0 [08/May/2015 14:46:03] "GET /accounts/profile/vacancy/all/ HTTP/1.1" 200 3164 [08/May/2015 14:46:03] "GET /css/bootstrap.css HTTP/1.1" 404 2928 [08/May/2015 14:46:03] "GET /accounts/profile/vacancy/all/css/sticky-footer-navbar.css HTTP/1.1" 404 3437 [08/May/2015 14:46:03] "GET /accounts/profile/vacancy/all/css/style.css HTTP/1.1" 404 3392
InternalError: current transaction is aborted, commands ignored until end of transaction block
@task(ignore_result=True) @transaction.atomic def update_task(obj_id): try: item = Object.objects.get(pk=obj_id) obj.update() except Object.DoesNotExist: ... som other function try: sid = transaction.savepoint() obj2.save() transaction.savepoint_commit(sid) except IntegrityError: transaction.savepoint_rollback(sid)
def f(x): f= (5*x**2-x+2) return f a=input() b=input() dx=input() n=(b-a)*1.0/dx+1 x=a s=0 for i in xrange (int(n+1)): f(x) s+=f(x)*dx x+=dx print(s)
from django.conf import settings from lib.sphinxsearch import SphinxClient, SPH_MATCH_EXTENDED, SPH_SORT_RELEVANCE, SPH_SORT_ATTR_ASC, SPH_SORT_ATTR_DESC, SPH_SORT_EXPR, SPH_SORT_EXTENDED, SPH_SORT_TIME_SEGMENTS, SPH_RANK_BM25, SPH_RANK_PROXIMITY_BM25, SPH_RANK_WORDCOUNT, SPH_RANK_SPH04 def sphinx_instance(): sphinx = SphinxClient() sphinx.SetServer(settings.SPHINX_SERVER, settings.SPHINX_PORT) sphinx.SetMatchMode(SPH_MATCH_EXTENDED) sphinx.SetSortMode(SPH_SORT_RELEVANCE) sphinx.SetRankingMode(SPH_RANK_SPH04) sphinx.SetLimits(0, 100000, 100000) return sphinx sphinx = sphinx_instance() result = sphinx.Query('usb', 'product')
$ mysql -P 9306 -h 0 mysql> select * from product where match('usb'); +--------+--------+---------+---------+-------------+------------+------------+------------+-------+------------+--------+------------+------------+ | id | weight | item_id | country | category_id | company_id | updated | price_min | image | verified | tariff | is_testing | model_name | +--------+--------+---------+---------+-------------+------------+------------+------------+-------+------------+--------+------------+------------+ | 246534 | 2803 | 246534 | 0 | 3430 | 17727 | 1429783486 | 100.000000 | 0 | 2905310389 | 1000 | 0 | 4 | +--------+--------+---------+---------+-------------+------------+------------+------------+-------+------------+--------+------------+------------+ 1 row in set (0.00 sec)
import calendar def create_calendar_page(year, month): calendars = calendar.month(month, year) return calendars
import datetime def create_calendar_page(month=0,year=0): first_week={ 0:'01 02 03 04 05 06 07', 1:' 01 02 03 04 05 06', 2:' 01 02 03 04 05', 3:' 01 02 03 04', 4:' 01 02 03', 5:' 01 02', 6:' 01'} list_of_high=[1,3,5,7,8,10,12] list_of_low=[4,6,9,11] x=None y=None finish='' week='' first='' list_days='' temp='' z=None before_first_date='' finish_n='' list_of_second=[] list_of_second_new=[] xom=None Flag=True if month==0 and year==0: xom=datetime.datetime.today() x=xom.strftime("%Y, %m") Flag=False elif year==0: xom=datetime.datetime.today() year=xom.strftime("%Y") x=year+', '+str(month) Flag=False if Flag==False: year=x[0:(x.find(','))] month=x[(x.find(',')+2):len(x)] month=str(month) month=month.replace('0','') y=datetime.date(int(year), int(month),1).weekday() week='MO TU WE TH FR SA SU' for i in first_week: if i==y: first=first_week[i] if int(month) in list_of_high: days_in_month=32 elif int(month) in list_of_low: days_in_month=31 elif int(month)==2: if int(year)%4!=0: days_in_month=29 else: days_in_month=30 z=(8-y) for k in range(days_in_month): list_of_second.append(k) list_of_second_new=list_of_second[z:] for j in range(len(list_of_second_new)): if len(str(list_of_second_new[j]))==1: temp='0'+str(list_of_second_new[j]) else: temp=str(list_of_second_new[j]) if (j+1)%7==0: finish_n=finish_n+temp+'\n' else: if list_of_second_new[j]==list_of_second_new[len(list_of_second_new)-1]: finish_n=finish_n+temp else: finish_n=finish_n+temp+' ' finish='--------------------\n%s\n--------------------\ \n%s\n%s' %(week,first,finish_n) return finish
line = '1BCDEFG1BCDEFG1' values = {'HHH': 10, 'HHHH': 25, 'HHHHH': 150, 'GGG': 10, 'GGGG': 25, 'GGGGG': 150, 'FFF': 150, 'FFFF': 500, 'FFFFF': 2000, 'EEE': 100, 'EEEE': 200, 'EEEEE': 2000, 'DDD': 300, 'DDDD': 1000, 'DDDDD': 2000, 'CCC': 300, 'CCCC': 1000, 'CCCCC': 5000, 'BBB': 300, 'BBBB': 1500, 'BBBBB': 500, '111': 50, '1111': 500, '11111': 5000 }
line[0] == line[1] and line[1] == line[2] and line[2] == line[3] and line[3] == line[4]