Anonymous
Hi there. Is there an analogue of this variable in Django? https://www.php.net/manual/en/reserved.variables.files.php
Anonymous
Yes
Can I get a name, please?🙏
Anonymous
request.FILES
ok. thanks! ❤️
cj
ok. thanks! ❤️
read more about it here: https://docs.djangoproject.com/en/4.0/topics/http/file-uploads/
cj
don't forget about this important thing: > "Note that request.FILES will only contain data if the request method was POST, at least one file field was actually posted, and the <form> that posted the request has the attribute enctype="multipart/form-data". Otherwise, request.FILES will be empty." most of developers forget that and don't know why it's not working ¯\_(ツ)_/¯
cj
Now the problem is that if I send a POST request without selecting an avatar, then the recording does not occur at all due to an error in the "validation" of the image. Apparently you need to do an check: if !empty request.FILES['avatar_select']
you should always validate everything ¯\_(ツ)_/¯ —that's why form.is_valid() exists— and other things to check/sanitize the inputs before actually committing things to DB
Anonymous
here the whole form is checked
cj
https://linkode.org/#WDKnj5CtkO5rNM7Be4nvB6
set your models' attributes properly where you want to allow blank/empty values ¯\_(ツ)_/¯
cj
https://linkode.org/#WDKnj5CtkO5rNM7Be4nvB6
also why are you doing things in that soooooo manual way? you'd better learn a little more about ModelForms and you'll reduce your code at ~80%
Eng Mohammed
use access mixins
How can I use it Can you give example or something like that
Prashant
Hi can anyone say me how to redirect the data to previous page without navigating to that page in django
Isha
django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'accounts.CustomUser' that has not been installed
Isha
i have this problem
Isha
AUTH_USER_MODEL = 'accounts.CustomUser' i use this on settings.py file
Isha
also add in install ap
Morteza
are you sure? share your settings file
Isha
INSTALLED_APPS = [ ..... "accounts", ]
waran
I have one issue in my django static files import Static /12.jpg------was display in pc Static/images/12.jpg---- didn't display in the image I have try many way what the error have any one tell guys
jaxx
Hi I'm creating an e-commerce website, can anyone help me with how to filter products by categories?
Mr
How can I create a python Django bot app with machine learning functionalities
Batman
AUTH_USER_MODEL = 'accounts.CustomUser' i use this on settings.py file
Your custom user probably exists in models file so it would refer to that too accounts.models.CustomUser
Sergey
Hi guys. I want to know if anyone of you ever used Celery, why process can be selfkilled?
Isha
String model references must be of the form 'app_label.ModelName'.
Alex
String model references must be of the form 'app_label.ModelName'.
settings AUTH_USER_MODEL=<app_name>.<model_name> + migration
jaxx
foreign key with categories
Yeah i did but i Don't know how to write views for that
Alex
Yeah i did but i Don't know how to write views for that
depends on how you want to show the category if you wish to list all the products of a specific category use a filter. (category='Your category').
cj
String model references must be of the form 'app_label.ModelName'.
looks like you created the Django project with an older version 3.2-, and now you're trying to run it with a newer version 3.2+
Alex
Can you please show me a sample just to refer... please?
Most Django e-commerce websites have those features, just google
Isha
Share codebase
https://dpaste.org/j5qfO
Alex
Codebase means the entire project, use GitHub
demon
https://dpaste.org/j5qfO
Is DJANGO_SETTINGS_MODULE set correctly ?
demon
In admin.py shouldn't it be admin.site.register(CustomUser, USERAdmin)
demon
Instead of admin.site.register(USER,USERAdmin)
demon
https://dpaste.org/YxiiN
Also what's USER ?
demon
Shouldn't it be model=CustomUser ?
Isha
demon
https://dpaste.org/P6pr2
This is not how you do it
demon
You should have only one user model other information should go to a profile model that you link to user model using a one to one relationship
demon
1) In admin.py line 25 try to set model model=CustomUser 2) in admin.py line 27 change USER to CustomUser 3) follow this doc to create a profile model https://docs.djangoproject.com/en/4.0/topics/auth/customizing/#extending-the-existing-user-model
Rutherford
I'm trying to host my django website on digitalocean droplet. However I'm confused as to how to set the environment variables for maximum security. Should i place my environment variables into a .env file in the project directory(wont be on github) or place the environment varibales into my .bashrc file Thanks
Artur
Hi. Can someone help integrate gmail API to django project. Maybe is it another way to simply send email from one gmail to another?
Emmanuel
Please I need to integrate fingerprints biometrics in my Django app, any help?
Shubham
Hi I'm creating an e-commerce website, can anyone help me with how to filter products by categories?
Suggestion - integrate razorpay or paypal. Or you can take it to another step like if a person purchage a eBook than ebook will be downloades after his payment
Rohan
But there are resources if you google.
Emmanuel
But there are resources if you google.
I have checked, but no result
Rohan
Emmanuel
Like you said, it's hardware dependent
Emmanuel
I found a nice solution from auth0, but it only works with the system's fingerprint reader, not external readers
Javier
I'm using waitress, right now
Javier
but my deployment is very small
Rohan
I found a nice solution from auth0, but it only works with the system's fingerprint reader, not external readers
That’s why you don’t implement features that are so much tied up to platform or hardware
Rohan
But a client demanded for it
Then do your research and tell them about the hurdles.
Rohan
Also, use offtopic to discuss about it unless you have a package you wanna use and django issues regarding it.
Emmanuel
Will do that