Django model with only foreign keys

I have an existing database, which cannot be changed. It contains three tables: A: a_id [primary key] B: b_id [primary key] A_B: a_id [foreign key] b_id [foreign key] I want to create django models for these tables. Since django require...
more »

2017-03-18 22:03 (0) Answers

Python functions with multiple parameter brackets

I've been having trouble understanding what h(a)(b) means. I'd never seen one of those before yesterday, and I couldn't declare a function this way: def f (a)(b): return a(b) When I tried to do def f (a, b):, it didn't work either. What do the...
more »

2017-03-18 14:03 (3) Answers

find all sublist of list in python

I need to find maximum length of sublist with first element greater than last. if a original list has first element greater than last then i just return the length of list. if not i have to find the sublist of list with maximum length and first elem...
more »

2017-03-18 14:03 (4) Answers

xml bulk file editor increment by numbers

I am trying to prefix the TEXT_VALUE field's values by a number in incremental way in all my xml files only the tags called "TRANSL" with ID="Example". Currently I am doing it manually, but since I have several thousands of them, I think I should do...
more »

2017-03-18 14:03 (2) Answers

'UpdateView' object has no attribute 'object'

So I've been trying to add a cancel button to my UpdateView that I've been using. Here's my code for it: class CountryEditView(generic.edit.UpdateView): model = Country fields = ['name'] template_name_suffix = '_edit' d...
more »

2017-03-18 04:03 (1) Answers

Visible Deprecation Warning Python

I am trying to make a model in python for an economics dissertation and in calculating a function: elif wage_online == max(wages): # after going to online you get the highest wage after cost of education learning_benefit = i...
more »

2017-03-17 21:03 (1) Answers

NoReverseMatch at Django

and I do not know why and what will be the problem, could they help me? Thanks beforehand, greetings! Reverse for 'entregado' with arguments '()' and keyword arguments '{'cod_experto': 'ASE-0048', 'id_pedido': 1770}' not found. 1 pattern(s) tri...
more »

2017-03-17 14:03 (1) Answers

Python: sort specific elements in a list

I have a list of elements I want to sort, but I don't want to sort all of them, only those with a particular state. For example, let's say I have a list of peole: lst = [Mary, John, Anna, Peter, Laura, Lisa, Steve] Some of them have a job, let's s...
more »

2017-03-17 10:03 (1) Answers

What is the technical term for 'x' in 'for x...'

If I had the code... list = ['Clemont', 'Albert', 'Shiro'] for x in range(len(list)): print(x) ...what would technical term for x be here? I'm assuming it's "iterate object" but maybe that's a misconception; if it's not a misconception, what i...
more »

2017-03-16 22:03 (4) Answers

Python re.sub replace html attributes

I'm trying to resize images from html code. This is one example: My goal is to substitute " height="108" " and " width="150" with height and width 400. I've tried the following lines, though they don't seem to work: re.sub(r'width="[0-9]{2,4}"','...
more »

2017-03-16 16:03 (2) Answers

How to parse a .txt file into .xml?

This is my txt file: In File Name: C:\Users\naqushab\desktop\files\File 1.m1 Out File Name: C:\Users\naqushab\desktop\files\Output\File 1.m2 In File Size: Low: 22636 High: 0 Total Process time: 1.859000 Out File Size: Low: 77619 Hi...
more »

2017-03-16 14:03 (2) Answers