I
I
Ivan Koryakin2021-01-09 14:02:45
Django
Ivan Koryakin, 2021-01-09 14:02:45

Django, want to add 2000 columns to database?

I want to add 2000 columns with different dates to the database, there are no errors, just the dates are not filled in when makemigratons and migrate

class parts_direct_stpc(models.Model):
    title = models.CharField('Название', max_length=50)
    now = datetime.now().date()
    data = []
    for i in range(2000):
        data.append(None)
    for i in range(2000):
        data[i] = models.CharField(str(now + timedelta(i)), max_length=20)
    def __str__(self):
        return self.title

Answer the question

In order to leave comments, you need to log in

5 answer(s)
S
Sergey Gornostaev, 2021-01-09
@valera228822

It's too early for you to take on Django, you obviously don't know Python.

D
Dr. Bacon, 2021-01-09
@bacon

On the face of a design error or misunderstanding of relationships, you do not need 2000 columns.

A
Adilet Usonov, 2021-01-09
@Adilet-novichok

for i in range(2000):
data.append(None)
ಠ_ಠ want to add nothing 2000 times?
Correct data.append(i)
for i in range(2000):
data[i] = models.CharField...
ಠ_ಠ
Check
https://www.codewars.com/ here for your knowledge

F
Froggyweb, 2017-04-05
@Froggyweb

Better native for

V
Vlad Feninets, 2017-04-05
@fnnzzz

var nodesArr = [].slice.call(document.querySelectorAll('div[class*="innerItem"]'));
nodesArr.map(function(item) {
   console.log(item)
   //....
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question