Fabin
Dict={ 'products':Product.objects.all() 'Users':User.objects.all() } I have a dictionary like this. I want to console the Users key values in console.How can I console it in django?
Fabin
If i try to print print(Dict['Users']) It shows <QuerySet [<Users: myname>] All the fields and it's value not showing
Fabin
print(Users['nameuser'])
How can I access Users directly without adding the Dict?
Fabin
It's shows Users is not defined,because Users is inside the Dict dictionary
S
Dict={ 'products':Product.objects.all() 'Users':User.objects.all() } I have a dictionary like this. I want to console the Users key values in console.How can I console it in django?
Do this products = Product.objects.all() users = User.objects.all() Dict={ 'products':products 'Users':users } To access each entry, products[0].YOUR_FIELD_NAME products[1].YOUR_FIELD_NAME users[0].YOUR_FIELD_NAME users[1].YOUR_FIELD_NAME To print in Django console
bv
does the framework create Django Form object for each request of entity in admin panel?
bv
I have a json field in a model and want an option to edit it in the admin panel. I know it's possible to edit it as a string but I want it to be user friendly so I want each "key" to be editable as a different field So I created a custom Form for my AdminModel but the problem is it's not being initialized on each request Did anyone face/solve similar problems with creating dynamic fields in admin panel?
Ali
guys does django and react works good together?
Maksim
When to better use unique=True in model Django? In time registration use for name and password or just for name?
cj
When to better use unique=True in model Django? In time registration use for name and password or just for name?
there's no sense to set unique=True for password field ¯\_(ツ)_/¯ totally unnecessary... neither for name field; don't you want to have 2 George in your app?
Maksim
Ok, but passwords in project cannot to repeat, really?
Maksim
So me make to check passwords with the authentucation?
Andrej
Ok, but passwords in project cannot to repeat, really?
The most used password in the internet is: 123456 Many users use the same password on the same platform. You don't want to expose that someone else has that password. Never unique the password field! Just the username and/or email
Maksim
Passwords in project can repeat?
cj
Passwords in project can repeat?
do you think passwords are stored as plain text?
last
No, When pigs fly. never. if done, your database can be hacked from hacker
Maksim
Why I'm cannot to use name with unique=True for login?
aRi
Why I'm cannot to use name with unique=True for login?
If you want to name or something else be unique in django forms You should override the clean method ( Username is unique automatically but you should override the clean method for that )
Maksim
User with this Name already exists. How to resolve this problem?
ASKAR
User with this Name already exists. How to resolve this problem?
It seems you made name field unique. https://t.me/django/219465 So you need to remove unique=True from that field
Maksim
For USERNAME_FIELD you need to add unique, but with them I cannot to write name(USERNAME_FIELD) for login on site)😔
ASKAR
For USERNAME_FIELD you need to add unique, but with them I cannot to write name(USERNAME_FIELD) for login on site)😔
USERNAME_FIELD is not a field name. You need to specify username field with this variable in your user manager
Krishnajith US
Hello.. somebody can suggest me tutorial for me.how can I connect postgresql with django...and how to create custom Admin panel
Hell
hello once again to all sirs, I wrote a piece of code that displays changes to tables on forms after the user edits them. but there is a problem, changed_data takes the whole form, and starts checking every line, but I can only send part of the models. each model in the form is exactly blank:true in order to be able to edit blocks using one form. the problem is that changed_data for those fields that were not included in the post - returns them as none or null - and after this action I have contract.save() to save the model. and that's when I give the user the option to edit smallintegerfield(choice) everything works fine. but in models with charfield(text) all information is erased, turns it into null. how can i fix this Code: http://linkode.org/#i5OE2NwkBWU2VBitFKWoT2
The Inspired
Hello.. somebody can suggest me tutorial for me.how can I connect postgresql with django...and how to create custom Admin panel
https://www.digitalocean.com/community/tutorials/how-to-use-postgresql-with-your-django-application-on-ubuntu-20-04
The Inspired
for custom admin panel, search for 'modelAdmin' in django docs
The Inspired
I'm experiencing a ValueError at return an HttpResponse object. It returned None instead.
any view in django is supposed to either return a response (either JSON or a template), OR raise an exception... the error you mentioned happens when its doing none of those... check your code to see if everything is alright.
MR_X
I have knowledge about python and Django but I want to be pro. I want to learn advance python and Django pls help
MR_X
Practice, do a lot of projects thats the only way
I want to see how to write code in proper way, how to write code smart , proper way to maintain code
Holla
http://linkode.org/#v71ROiSODPlM6MSiCAYNn2
Holla
are the paremeters not enought
Holla
i only entered three it should have taken as it worked for the instructor too
Dave
i only entered three it should have taken as it worked for the instructor too
Can you also share the code of your urls.py? As my assumption, your name for url is home. And you are passing 2022 and March as a url kwargs. But we still need to see the urls.py to conclude if what is your url patter for home url.
Johan
Hello Guys, how can I pass qs from a listview (CBV) to another view (FBV), I pass qs to context in listview but I don´t know how to get this qs in the other one, please your help. class EmployeeListView(ListView): queryset = Employee.is_active.all() template_name = 'employees/list.html' def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context ['to_export'] = self.get_queryset() return context def to_export(request) data_to_export = # here need queryset from EmployeeListView Thank you in advance
MR_X
I have knowledge about python and Django but I want to be pro. I want to learn advance python and Django pls help
DaVidoff
Hi all! Please, advise! I need to create a django model that will contain the title of the article and the "is_blocked" field. I need the articles to be available to all users with is_blocked filed being binded to each specific user. I need to be able to change the “is_blocked” field for any of the articles separately for each user using POST request.
Ramin
Hello everyone! If I want to use web socket should I have to know JavaScript??
AK
Yes
Maksim
Custom user with this Name already exists
Ganesh
Hello everyone I develop group project
Ganesh
But I have face essue while adding multiple members in group
Ganesh
offtopic
Django use inbuilt group functionality
EAgold
how to import external module in django?
Koen de
how to import external module in django?
Exactly like you do with standard Python; Search your module on pypi.org , then; pip install <module> In your code; import <module> or; from <module> import <xyz>
Koen de
No it is not; Enable your virualenv from your mainproject. Browse to the “module” folder, then pip install -e . (With the dot)
Koen de
Or if it is in the same folder structure as your main-app, but then it is not an external module anymore, add it in your INSTALLED_APPS
Koen de
i putted it on the same level as the project directory and it's impossible to import
Do you have something like; /home/me/code/mainproject/ and /home/me/code/module/ ? And does the “module” have a setup.py?
EAgold
Or if it is in the same folder structure as your main-app, but then it is not an external module anymore, add it in your INSTALLED_APPS
no.. this is not django app and it's not a pip package this is kind of helpers that i want to use in views
Doragonsureiyā
i can send file structure but media isn't allowed here
Rule 5️⃣: Never post walls of text or screen photos. Use paste bins like https://linkode.org, https://nekobin.com (or your favorite one)
EAgold
The module.py file, is in the same folder as views.py then?
no djangoproject/ djangoproject/djangoproject/ djangoproject/anotherApp/ djangoproject/anotherApp/views.py mypackage/ mypackage/file1.py mypackage/file2.py mypackage/__init__.py i want to import mypackage from views.py
Koen de
Okay! mypackage needs a setup.py then you can import it with pip install -e .
Koen de
Else Python/Django can not see it as a module.
Koen de
https://docs.python.org/3/distutils/setupscript.html
EAgold
Not easy, and not likable
but if i have two separated projects one of them is django project and another is for telegram bot how to get access to bot project from django project?
EAgold
or for example i should edit uploaded photos with openCV before savind i have some files with code for image edition where i should put them?
Koen de
Your questions and my answers remain the same…
Koen de
Please read; https://docs.readthedocs.io/en/stable/guides/private-python-packages.html https://towardsdatascience.com/create-your-custom-python-package-that-you-can-pip-install-from-your-git-repository-f90465867893?gi=bb1a8ae08816 https://stackoverflow.com/questions/41535915/python-pip-install-from-local-dir
Mohamad
Hi I have a ModelForm that I've added an extra CharField to it . This CharField is not a field of my model. I just want to use its value. When im calling form.save(commit=False), i get an attribute error that tells me my model has no attribute to my CharField. Is there any solution?