Mirco
Ok, I'm just bad at Python 😄. I'll figure it out.
that's why u have to study Python before Django 😊
Anonymous
But in my courses I never came across **self.
Anonymous
In def get_form():
Anonymous
return form_class(**self.get_form_kwargs())
Anonymous
I know I am rubbish at Django (and Python!), but I'm just trying to brute force my way through this project. So if I ever get stuck again, I can just look back at my solutions.
Anonymous
But after this project, I want to go back to Python and learn more.
Alex
return form_class(**self.get_form_kwargs())
You are unpacking not self argument, but rather the returning value of its (self's) method get_form_kwargs
Anonymous
Thanks for your help guys
Anonymous
Might not be the most optimal way to do it, but it works and I'm happy about it. I used the dispatch method to solve it.
Alex
You could use the simple get()
guess the same logic is needed for both get and post.
Mirco
guess the same logic is needed for both get and post.
Yup maybe 😁 without the code they are hypothesises 😂
Tukhtamurod
hi
Tukhtamurod
who has paid account on pythonanywhere.com, i have a question. can i register for example something.uz domain name? or should it end with .com
Anonymous
You could use the simple get()
Probably, but I am an actual idiot. I have avoided class-based views this entire time because I don't understand them.
Anonymous
Don't even know how to use get()
Anonymous
So this is how I solved my problem: del.dog/ekihumethi.txt This could have also been solved by using the get() method?
Anonymous
Okay never mind 🤣🤣. Now my form doesn't work! EDIT: Fixed 😎
Shohjaxon
NameError: name 'model' is not defined
Lucid
How would i call the output parameter which I have to show
Mirco
I avoid them too. I find function based view more easy to understand
Just because you did not study enough OOP Anyway yeah at first they are easy but with CBVs you can avoid lot of redundant code
Shohjaxon
Pretty clear error
>>> from mainapp.models import LatestProducts >>> LatestProducts.objects.get_products_for_main_page('notebook') Traceback (most recent call last): File "<console>", line 1, in <module> File "C:\Users\User\PycharmProjects\shop\shop\mainapp\models.py", line 16, in get_products_for_main_page model_products = ct_model.model_class()._base_manager.all().order_by('-id')[:5] NameError: name 'model' is not defined >>>
Naveen
Just because you did not study enough OOP Anyway yeah at first they are easy but with CBVs you can avoid lot of redundant code
Totally agree with you that lot of redunant code can be avoided and its just i didn't practice them
Naveen
How would i call the output parameter which I have to show
Here's working example def inbox_conversation(request): all_conversations = Room.objects.filter(room_members__in=[request.user]) return render(request, 'inbox_conversation.html', {'all_conversations': all_conversations})
Mirco
So this is how I solved my problem: del.dog/ekihumethi.txt This could have also been solved by using the get() method?
Mmm honestly I think you can achieve the same by creating two forms and one can inherit from the first one by overriding the fields and then handle the form class with get_form_class as already suggested Without the need of dispatch
Mirco
But it's nice you have found a way to make it work 🙂
Naina
Being a software engineer is it possible to become a developer ?
Doragonsureiyā
Being a software engineer is it possible to become a developer ?
Looks like you need an offtopic group, please continue this conversation at @pythonofftopic as it's not related to Python
Lucid
How can I call the pandas dataframe in function based view ? Whenever I call the function it is giving me empty table
Lucid
Ok
Lucid
Can you share the screenshot
https://del.dog/eckythegam.txt
Lucid
Please take a look what am I doing wrong
Shubham
I an getting error in a virtual environment couldn't import django, anyone can help??
AMIR HUSAIN
what is <model_name>_ptr attribute?
Lucid
I an getting error in a virtual environment couldn't import django, anyone can help??
Some of the requirements of the project are not installed in the virtual env
Lucid
Install them again in running terminal including django
Shubham
Okay bro thanks
Anonymous
Good night, folks to make international transactions from one PayPal to another is a credit card necessary?
Anonymous
https://stackoverflow.com/questions/65821960/unable-to-get-progress-count-in-django-admin Can someone help me with this?
yeus
Hello, i want to make a system where a person posts something and the admin verifies that post and after clicking on verified button from admin side. The person should get 50 points automatically. How do i do this? Really need help . Thanks in advance
abcde
Watching for file changes with StatReloader I am getting this error when running python manage.py runserver and it doesn't load up
abcde
any solution?
abcde
I am using gitbash to run it
Alex
any solution?
Have you tried to google it?
abcde
yep
abcde
I didn't understand stack overflow ans
Alex
I didn't understand stack overflow ans
try better https://stackoverflow.com/a/55831861/2516502
Milton
Any Django Back End developers looking for Job? Experience: 2+ years Skills: Django, Node.js, SQL, Mongo, AWS experts Location: Remote/ Bangalore Send resume to majtechnologiesteam@gmail.com
Doragonsureiyā
Any Django Back End developers looking for Job? Experience: 2+ years Skills: Django, Node.js, SQL, Mongo, AWS experts Location: Remote/ Bangalore Send resume to majtechnologiesteam@gmail.com
Rule 🔟: Job offers are only allowed in the offtopic chat - @PythonOfftopic. To avoid being marked as spam, make your offer include skillset/techstack, salary/reward, contact information and a brief description of what work you want done.
Alex
Hello, i want to make a system where a person posts something and the admin verifies that post and after clicking on verified button from admin side. The person should get 50 points automatically. How do i do this? Really need help . Thanks in advance
This is merely an example. The ending solution is up to you and you're responsible for it. You have to create (if already not) a model named Post. Beside other it has to have some way to determen if it's approved or not. Let say it's a BooleanField called "approved". Since a post has to be approved right after it's created we can set it to default=False. Then an admin can verify it in the admin interface. The moment with the points is tricky. Should we substract them if for some reasons a post was first approved and then disapproved back? Is it possible to reward more than 50 points at once? A simple approach would be: create a model, say, Accout 1to1 related to the User model and add it a field points. Since the buisnes logic is performed on a post's save we can place it in the ModelAdmin.save_model where we can Account.objects.filter(user=post.user) and update the points field. To prevent redundant points refilling we can add casing logic so if the post is already approved, we're not adding points to it and if it already disapproved we're not substracting them.
__init__
What is the best way to automate Django deployment?
Alex
What is the best way to automate Django deployment?
gitlab-ci is also cool, if you're using gitlab
....
hi guys, is it mandatory to learn JavaScript with Django+Python?
Alex
hi guys, is it mandatory to learn JavaScript with Django+Python?
Would not say that. But better to be familiar with it.
R
Im trying to split input string at \r\n and period followed by space but not after Mr/dr etc using regex but getting look behind requires fixed width pattern error Any suggestions on how to achieve this?
Daniil
Hello everyone! I've field in my model like PropColor = models.ForeignKey( PropsColor, verbose_name='Color', on_delete = models.PROTECT, default=1)
appu
plzz help me i tried to call an django url from ajax but i dont want to get an response to ajax i just wanna to redirect into another url .