Martin
I've this template that broke on migration from Django 1.x to 2.x, did nesting blocks somehow change?
The line marked with green executes just fine but the same condition inside another block is ignored (marked with red)
https://i.imgur.com/OCoOVJs.png
relevant bit from template.html - https://haste.rys.pw/raw/vucinixake
Ori
Martin
Martin
it's as if it wasn't there.
Note that I simplified the code on the first screenshot(but not in the .html I posted), hence this is way longer
Martin
left side is Django 1.x, right side 2.x
Ori
Hm, maybe try printing {{ users }} into the template to see what's there
Martin
Martin
or you mean in the condition already
Ori
I mean, try to check what's in the "users" near the failing for loop to see its value.
Ori
It doesn't look there's an error in the template
Ori
What is users by the way? How do you obtain users list in your view?
Martin
It's a list of users from an LDAP database
Martin
So it looks like it borks on repeatedly using the same condition
Martin
Seriously, that second message was 6 lines, not 60.
Martin
@chomuchomu https://haste.rys.pw/raw/nulagayifo
this is enough to break it
Ori
That means that it's probably an iterator. It exhausts itself after the first run.
Ori
So, how do you get this value? Maybe there is another way to do that.
Ori
If there's not, you can convert an iterator to a list:
users = list(users)
this should do the trick.
Martin
Ori
Weird, a list shouldn't behave like that
Ori
Are you sure it's not converted into an iterator on the way to the template?
Martin
I didn't really touch Django before and the first thing I'm doing is this migration, so sorry for the basic questions
Martin
To be fair I *did* touch this function.
for line in data.split("\n"):
>>
for line in data.decode().split("\n"):
Ori
Martin
"iter" string isn't anywhere in the entire project, so that's a no
Anders (izzno / gooood) 🇳🇴
Moving / copying a Postgres DB:
Our stage DB now has alot more data than our dev DB.
I was thinking of just dumping the stage DB and importing it in a DEV environment.
How will (or not) this effect the user login / password? Is it hashed meaning its somehow connected to the SECRET_KEY or will it be uneffected and pretty much busyness as usuall? (Both environments are postgres of course)
Anders (izzno / gooood) 🇳🇴
I do understand it will overwrite the current users, and could just add a new admin user. But I just want a heads up if this is a problem.
Ori
Ori
Afaik filter function returns in iterator
Ori
The best thing to do is to convert users to list right where it's being put into the template's context like that:
list(users)
Anders (izzno / gooood) 🇳🇴
wait what..
Ori
Anders (izzno / gooood) 🇳🇴
Martin
Afaik filter function returns in iterator
Huh, on the old 1.x version it returns [{'phone': '', 'email': 'testuser@company.cz', 'name': 'Test User'}]
Ori
Afaik SECRET_KEY is used to encrypt cookies
Anders (izzno / gooood) 🇳🇴
Ori
Martin
Yeah
Ori
That's what changed
Anders (izzno / gooood) 🇳🇴
yep
Ori
filter returns a list in python 2
Anders (izzno / gooood) 🇳🇴
@C0rn3j Remember I told you you might wanna re-write the whole thing? Hows that looking right now ? ;)
Martin
Ansab
Anybody offer me a job in python django? I have 1year of experience❤️
Ansab
Iam from india
Anders (izzno / gooood) 🇳🇴
Anonymous
django based capture the flag event application[ A multiple teams can participate in event to find answers for questions],has many many features like Real time Scoreboard with channels and sockets, caching with redis. worth to play around it fork it start it.
https://github.com/balaraju1278/capture_the_flag
Martin
Anonymous
I have register the nptel course programming in Java and also register for exam but whenever I open my app it show two option first go to course and second register for course ..
Why it is showing this when I have already regist for exam and pay the pay ..
And also my week 0 assignment 0 score is not showing in progress dashboard
cj
Anonymous
Is there any other database connectivity in python other than model.py?
cj
cj
but... why? what do you want to do?
Anonymous
Nothing just asking for confirmation
cj
Anonymous
No
Other way instead od django
Anonymous
Okay fine
Rock
How to fetch user data from database and show as a form
inchidi
niwla23
I want to have a button in my app, and when you press it it should call a simple function.
(For a smarthome where i want to control a lamp over a webapp)
niwla23
how to do that?
niwla23
niwla23
but i am new to django
niwla23
so i need a tutorial or an easy example
cj
niwla23
Where shall i look??
niwla23
and in which part is it?
niwla23
cj
?
don't you understand what you wrote yourself? 🤔 that's new
niwla23
In which Part of the tutorial can i find a request from the user interface to the python backend?
cj