Nilou
Hi guys, i have a Modalform for registration in index.html page but i don't know how should i set urls.py and views.py for it how should i put template name in views.py,a modalform as a part of index.html? and how should i route it in urls? path(' ', index, name='index'), path(' ', register, name='register'),
Dami_codr
Hi guys, i have a Modalform for registration in index.html page but i don't know how should i set urls.py and views.py for it how should i put template name in views.py,a modalform as a part of index.html? and how should i route it in urls? path(' ', index, name='index'), path(' ', register, name='register'),
You can create a register form and add it to views like def index(request): Form = registerForm() . Then pass the form like a dictionary in the render () to the index.html like {{form}} Your URL will be like.. views.index, name="index"
Nilou
thx a lot, if i couldn't do it i would give you MSG 🙈🙏
Dami_codr
thx a lot, if i couldn't do it i would give you MSG 🙈🙏
No problem.. I'll respond if I see your message
Bekzod
Hello everyone, I need your help. Now I have a sqlite database. With the information in it, I can't link this database to my django project without using ORM.
Ivan
Why?
Doragonsureiyā
Why?
What are you talking about?
Ivan
I’m asking why Bezkort can’t link his database, what’s wrong with it
Bekzod
Why?
I have a fully prepared database. I need to create a project using this information.
Maxim
I’m asking why Bezkort can’t link his database, what’s wrong with it
his question is clear with certain assumptions the file is locked by Django, so he can't open it with other tools
AFK
Can anyone explain me in a better way about META class inside models. Also about why we use and when and when not to. I have used it many projects but still confused
Anmol
I want to learn django from the scratch, purchasing course from codewithmosh.com would be great choice or not?
Anmol
can you suggest one?
Sachin
And Google for a 'portfolio django app' ... It will take you to a blog which really explains how to start with django with examples
Sachin
can you suggest one?
Yes... A moment pls
Sachin
https://www.udemy.com/share/101Wis3@n08nK_IVEZnPiv3KerUr9BI-zyL2UOh1cgXvfIs9oA41UXJNXHfASOW2MhAx8t11/
AFK
I want to learn django from the scratch, purchasing course from codewithmosh.com would be great choice or not?
Try justdjango! Youtube channel plus a he has a good roadmap and website Mosh skips many Codewith harry is good but not organized
Anmol
Try justdjango! Youtube channel plus a he has a good roadmap and website Mosh skips many Codewith harry is good but not organized
studying from youtube is not a good choice as it's not focused on teaching, instead they're just coding without giving the better understanding.
Anmol
Okay.
マクスイム • グセブ
I want to learn django from the scratch, purchasing course from codewithmosh.com would be great choice or not?
I thought there's actually a better way to learn Django except reading the documentation and doing pet-project but after a year I've finally realized that documentation is better than any course or YouTube tutorial series.
Ivan
I suspect that just reading Django documentation could be too hard for newcomers. Despite the fact that Django documentation is much better that many other technologies docs
Jerome
there are tons of docs made by enthusiasts all over the place... thx to Python & Django communities
Doragonsureiyā
Anyone on this?
Maybe anyone is here, yes, but they are not obliged to read everyone's message here neither to reply to everyone's message, if someone wants to reply to your message, they will do that, just don't try to draw attention to your message writing "anyone?" every 5 minutes, that will lead you to be warned for SPAM/Flood, just be patient or use Google/DuckDuckGo to research about your question instead of wasting time here waiting for people to do your work. Have a nice day 😊
Aziz
Hello, I am uploading a portfolio site. What happens if a customer sends me little information in an email and a comment and it is automatically sent to my email? Please help
bikrant
Hi guys is there any way to access dictionary object in django templates. Not using a for loop Ex- In views.py map[object.id] = value In templates {{Map.object.id}} this doesn't work
bikrant
Any ideas how to get the map values?
マクスイム • グセブ
Any ideas how to get the map values?
Write your custom teplate tag, it's a common practice
マクスイム • グセブ
Create a folder templatetags in the root, add __init__.py there ​from​ ​django​ ​import​ ​template ​register​ ​=​ ​template​.​Library​() ​@​register​.​filter​(​name​=​'lookup'​) ​def​ ​lookup​(​value​, ​arg​): ​    ​return​ ​value​[​arg​]
マクスイム • グセブ
Then you can include this filter and use it with {{ map|lookup:id }}
Anonymous
Please help me when should i use def__str(self) . Do i need to use it on only strings or even other fields have to declare them
Anonymous
Ts confusing me why is it declared on only one parameter among others
Stephen
The idea of multi tenants or saas application in Django is never clear to me. I Wish I can find a book I can buy or a course on this subject... Anyone?
マクスイム • グセブ
Please help me when should i use def__str(self) . Do i need to use it on only strings or even other fields have to declare them
__str__ magic method of a model is needed to print out the model instance. You can see a result in the Django admin panel, for example. Or when you print(queryset). You don't need to use it for fields, because they have verbose_name argument.
Fan / Ac
can i join number of tables using a single query using django ORM 5 tables A B C D E A related to B B related to C C related to D D related to E i need to get connection btw table A and E
Wasim Ansari
I have started learning Django REST Framework, from documentation. Please suggest some Projects for begining
Anonymous
Did you buy the course in site or YouTube videos Is it worth to buy a course from him?
Anonymous
Some of you here bought the course can answer here.
マクスイム • グセブ
Fan / Ac
I guess Model.objects.all().prefetch_related(<list of related fields joined by double underscore>) will do the trick
select_related will also work right ?? i should check this, doc confuses me does select_related() arguments specify based on which argument they will be joined or which all tables/models will be joined
Sudhagar
Did you buy the course in site or YouTube videos Is it worth to buy a course from him?
the course is absolutely worth it moshhamedani the tutor of that course explains only essential topics so its easier to understand. i download pirated content from the internet bro.
マクスイム • グセブ
select_related will also work right ?? i should check this, doc confuses me does select_related() arguments specify based on which argument they will be joined or which all tables/models will be joined
prefetch_related Returns a QuerySet that will automatically retrieve, in a single batch, related objects for each of the specified lookups. select_related Returns a QuerySet that will “follow” foreign-key relationships, selecting additional related-object data when it executes its query. This is a performance booster which results in a single more complex query but means later use of foreign-key relationships won’t require database queries.
マクスイム • グセブ
Oh, now I think that select_related actually is the best option, as well as your tables are connected by FK-relationships
Fan / Ac
Oh, now I think that select_related actually is the best option, as well as your tables are connected by FK-relationships
what if the table have two foreign keys, will it select the foreign key which is present in both tables
マクスイム • グセブ
Yes, you can select several relationships with double-underscore syntax as well
マクスイム • グセブ
And select_related itself supports several fields to select, so it perfectly matches your request
Ranken
My Django authenticate method returns None....... After user registration in template
Ranken
Can anyone help
Ranken
Please??? 🥺
Doragonsureiyā
Please??? 🥺
Please provide a full explanation including all the details that you consider relevant. Your statement is too broad and there is no clear way to answer you, you have to explain: - what you're doing - what you're expecting - what you're using - where you're running the script - what Python version you're using - what packages and their versions you're using - and the most important thing: show the code YOU wrote (read rule 5️⃣ for that) and more details, that way your chances to get help will increase
#me {display: none;}
guys, hello, could you help me, how can i get element by index from ArrayAgg by lookup in django ORM?
Maxim
Dude, mine returns nothing.. Be hopeful.
None is the same as nothing
Doragonsureiyā
Dude, mine returns nothing.. Be hopeful.
All functions return something. If they don't explicitly return something, they return a None object. Examples of functions that return None: print, list.append, dict.update
Ranken
What I'm doing: I'm trying to login a user and redirect the user to his dashboard ...... But when I do a python print it returns "None" I'm expecting a redirect after login or registration to the dashboard area..... I'm using Django I'm running the app on cpanel Using python 3.8.6
Ali
None is the same as nothing
I meant for the templates. Whenever I hop into the endpoints, templates are empty and nothing is there. :(
Ranken
It worked on my local machine before I did an ftp to cpanel
Ali
Yes exactly
So, set the redirect endpoint in your settings.py. What do you print? Where do you print?
Ranken
So, set the redirect endpoint in your settings.py. What do you print? Where do you print?
By default all outputs from the python app go a file called "stderr. log" file...... I printed to this file and to my template as a message when user tries to register..... The funny thing is the user is registered but does not authenticate
Ali
In most cases, users use fake information in order to authenticate and do the stuff. This step will prevent from that.
Ali
Well, that's common. Better approach is to redirect the registered user (after the registration process) to the login/signin page and let him log in.
Otherwise, you can easily log the user in right after the registration and then, redirect him to the proper view.
Ranken
But the major problem is that when I try to login it keeps redirecting back to the login template
Ali
This is mandatory?
It is. That shows where should Django redirect the user after signin/signup.
Ranken
cj
Which part of it?
the part where you're having issues with... obviously