コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
4541 ビュー

when I try to include code into a question in his forum I lose all carriage returns so the code block apprears to be all in one line.

 

How to paste code into forum without losing return characters?

アバター
破棄
著作者

I am sorry, it seems I was not clear enough. the block quote used to work well but not anymore. please see my reply below.

I have the same behaviour, latest Firefox and Windows 10 here. It is really annoying and impacts posts quality.

最善の回答

Hesham, when creating your post, notice the bar above beginning with "B". Hover over each of the choices in the bar to see the explanation of each. The fifth one from the left is "Block Quote". Position your cursor anywhere in this reply box where you want your code to go and press the "Block Quote" button. As a result you'll see an indented vertical bar on the left, with the cursor positioned just to the right of that bar and in the middle of its vertical height. Then paste your code. That should do it.

def translate_state_code_to_database_id(state_code):
    state_dict = {'AL': '1',
                  'AK': '2',
                  'AZ': '3',
                  'AR': '4',
                  'CA': '5',
                  'CO': '6',
                  'CT': '7',
                  'DE': '8',
                  'DC': '9',
                  'FL': '10',
                  'GA': '11',
                  'HI': '12',
                  'ID': '13',
                  'IL': '14',
                  'IN': '15',
                  'IA': '16',
                  'KS': '17',
                  'KY': '18',
                  'LA': '19',
                  'ME': '20',
                  'MT': '21',
                  'NE': '22',
                  'NV': '23',
                  'NH': '24',
                  'NJ': '25',
                  'NM': '26',
                  'NY': '27',
                  'NC': '28',
                  'ND': '29',
                  'OH': '30',
                  'OK': '31',
                  'OR': '32',
                  'MD': '33',
                  'MA': '34',
                  'MI': '35',
                  'MN': '36',
                  'MS': '37',
                  'MO': '38',
                  'PA': '39',
                  'RI': '40',
                  'SC': '41',
                  'SD': '42',
                  'TN': '43',
                  'TX': '44',
                  'UT': '45',
                  'VT': '46',
                  'VA': '47',
                  'WA': '48',
                  'WV': '49',
                  'WI': '50',
                  'WY': '51'}

    return 'base.state_us_{}'.format(state_dict.get(state_code))

アバター
破棄
著作者

Thank you Larry. I already do that and this is the result. It used to work well but not anymore. Please see next reply

It is the same here.

著作者 最善の回答

Thanks. I already do that and this is the result:

 

@api.constrains('name') # this means the following method defines constraint(s). in our case: duplication. argument passed is the field which you want make it unique def check_duplicate_rec(self): students = self.search([('name', '=', self.name)]) if len(students) > 1: # if only 1 record is found means we are ok. we just found the record we are creating. raise Warning("The student record is already exists!") # if raise XXX is called the method will exit from here and will not continue return True print "students :::::::::::", students

アバター
破棄

What browser are you using and what OS?

著作者

Chrome on Ubuntu

関連投稿 返信 ビュー 活動
3
7月 25
1784
0
9月 23
4230
8
3月 15
10209
0
2月 25
1064
2
12月 24
2329