ʚɞÇherry Łoveʚɞ
get_object_or_404 return only object if it exists, or raise 404 Not Found exception if object does not exists.
Yep
Someone got a simple example of how to input a string in a field and store it in the database and call a python script, that use the string? Django tut with the polls ab didnt show that all :-/
Yep
Naaa the Input string. Store it in a db and access the string to work with the value in a python script
Yep
I thought this might be "easy"??
Yep
Sqlite3-DB
Yep
Or grab the string when it gets entered with a Python script
Le Createur
Don't understand. Accessing a string in db is accessing the db nah
Le Createur
From the python script you can query directly the database
Yep
From the python script you can query directly the database
But i need a Tutorial, how to Input a string via a view/template(sry new to django), store that string in a DB and than access the string with a pyton script. I hope its now understandable :-)
Yep
Or a good book...got 2 and both dont cover my needs...
Le Createur
The third accessing the string from a python script
Le Createur
Require to directly query the database with the std sqlite3 module
Le Createur
Or by setting django in the script and query the database using the orm
Yep
The 2 first requirements are covered by the django tutorial check it
Have....they dont cover that. Just how to add values via shell, no Input field and so...
Bernard Kwey
i'm having this issue of password reset
Bernard Kwey
i was trying to direct users to their gmail account so that they could reset their password there but i'm receiving errors
cj
Bernard wanted to post this long code: https://del.dog/qivuheqexu
Leo
There is a option in settings in Google "allow less secure app "turn it on.. this may be because of it
Leo
If worked let me know
Maverick
With above python 3.X versions
Bernard Kwey
Can I have a look at you Email settings in settings.py?
EMAIL_HOST = 'smtp.gmail.com' EMAIL_PORT = 587 EMAIL_USE_TLS = True EMAIL_HOST_USER = os.environ.get('EMAIL_USER') EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_PASS')
Leo
Which email backend you are using?
Leo
Add this line DEFAULT_FROM_EMAIL=EMAIL_HOST_USER
Bernard Kwey
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
Bernard Kwey
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER NameError: name 'EMAIL_HOST_USER' is not defined
Bernard Kwey
no
Bernard Kwey
that above is the message i received from my server
Leo
Test it by giving your email and password directly in setting
Bernard Kwey
okay
Bernard Kwey
it isn't working still giving the same errors
Bernard Kwey
yes
Leo
yes
Ugh!!
Himanshu
Add a debugger on view level and share what you get in defined variables section.
Bernard Kwey
how ? how should i define it
Manish
Check for your env values
Manish
Show your .env file.
Himanshu
.env file? Didn't they use that in Laravel or some PHP based system?
Himanshu
Okay, I will just observe.
Himanshu
Okay. Will google how to use .env in Django!
Manish
He associates EMAIL_HOST_USER in settings with the value of EMAIL_USER in .env file. So it must be verified that the value is properly extracting from environment variable(.env)
Manish
That's why I asked him to give directly. That didn't work either
That should work or it will be better if he try sending some mail from django shell
Manish
So that he can know where is the problem
Leo
That should work or it will be better if he try sending some mail from django shell
I think this happens because of Google's security policy.
Himanshu
That's why I asked him to give directly. That didn't work either
That's weird. Sometimes server doesn't restart itself on change. Maybe a human mistake?
Himanshu
Try sendgrid.com or something else?
Leo
That's weird. Sometimes server doesn't restart itself on change. Maybe a human mistake?
Dev server will load python files after the change is made but may not load html.
Leo
@goshbak visit this link https://myaccount.google.com/lesssecureapps confirm the toggle button is on
Сергей
hi, I send a field in request, but field doesn`t exist in model, how can I receive it in serializer?
Сергей
what I need to share, in my case I send field but it doesn`t exist in model, it`s nothing to share
Сергей
I have not code, I don`t know how it`s doing
Titus Joyson
hi, I send a field in request, but field doesn`t exist in model, how can I receive it in serializer?
I hope this will help class FooSerializer(ModelSerializer): foo = serializers.SerializerMethodField() def get_foo(self, obj): return "Foo id: %i" % obj.pk https://stackoverflow.com/a/39489034/5012233
Сергей
I send field in request but it there is not in obj
Titus Joyson
I send field in request but it there is not in obj
can you share a sample code based on your requirement, like how you expect
Сергей
class SerializerV3(serializers.ModelSerializer): photo_data = PhotoSerializer(many=True, required=True,source='photos_auto') class Meta: model = ReportPodbor depth = 1 def validate_photo_data(self, obj): print(obj) return obj
Сергей
pthotos_auto foreign key, рhoto_data I send in request and try receive in the serialiser, but have no idee how can I do
Titus Joyson
does Photo is a model and have relation with ReportPodbor ?
Сергей
it`s true
Titus Joyson
You can try nested serializers like this photo_data = serializers.ListField(child=PhotoSerializer())
highnes
https://www.uphub.io/bin/ZSYiPN