Mirco
https://pastebin.com/9wUQbk5n
Never used trigram similarity yet but by reading the docs, I haven't found that lookup
Anonymous
Anonymous
doc example: >>> Author.objects.filter(name__unaccent__lower__trigram_similar='Hélène') [<Author: Helen Mirren>, <Author: Hélène Joy>]
Jimmies San
https://pastebin.com/9wUQbk5n
https://docs.djangoproject.com/en/2.1/ref/contrib/postgres/lookups/#trigram-similarity
Mirco
@marcoscoder I suggest you this read as well “Full-Text Search in Django with PostgreSQL” https://medium.com/@pauloxnet/full-text-search-in-django-with-postgresql-4e3584dee4ae Don't forget to thank @paulox 💪
Paolo
Thanks for sharing 👍
Anonymous
now, i have another error
Anonymous
django.db.utils.ProgrammingError: operator does not exist: character varying % unknown LINE 1: ...toes_questoes" WHERE "questoes_questoes"."titulo" % 'Enin' O... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. query: >>> Questoes.objects.filter(titulo__trigram_similar='Enin')
Anonymous
Extension created on PG ?
I think it's already installed, I've created classes in the application template. as in the doc https://docs.djangoproject.com/en/2.1/_modules/django/contrib/postgres/operations/#TrigramExtension
Anonymous
I tried to migrate but did not detect any changes
Anonymous
in the doc there is a link to the psql doc but there is no info on how to create
Mirco
nope
Try to do that I've shared you the read on Medium Follow that
Anonymous
ok
Anonymous
its work
Anonymous
now, look: <QuerySet [<Questoes: 133 (Enem 2012 - Segundo Dia)>]> >>> Questoes.objects.filter(titulo__trigram_similar='enen') <QuerySet []>
Mirco
Is it working as you expected ?
Anonymous
by what I understood, when I type something like "ene" or "enen", it was to return the list containing "Enem" in the title
Anonymous
i think its because this "Now we have a different problem - the longer name of “Helena Bonham Carter” doesn’t show up as it is much longer"
Anonymous
oh, that's really what happens
Anonymous
>>> Questoes.objects.filter(titulo__trigram_similar='133 enen segumdo dya') <QuerySet [<Questoes: 133 (Enem 2012 - Segundo Dia)>]>
Mirco
💪💪💪
Anonymous
also, thank you all for the help
Mirco
Yw 😀 thank to your issue, I've learned something new too 💪
Yamil
Hello good evening. I am trying to connect with to a server that has https, with that sentence: r = requests.post('https://example.com/Example/0.1/archivos/cargar', verify=False, headers={'Authorization': 'Basic XXXXXXXXXX='}, files=files) That error appears :
Yamil
('Connection aborted.', OSError("(104, 'ECONNRESET')",))
Yamil
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1638)
Yamil
TypeError: 'NoneType' object is not subscriptable
Yamil
Has someone already solved it?
Yamil
I am new with django. Thanks.
Tok
Is a type error... Review your code
Tok
I think that your request is empty
Yamil
I am using this : file = request.FILES['file'] handle_uploaded_file(request.FILES['file'], file) ruta = '%s/%s' % (settings.TMP, file) file = open(ruta, 'rb') print(file.name)
Yamil
when I print the name of the file <_io.BufferedReader name='/home/yjorozco/workspace/FirmaEventos/sources/tmp/formato-permiso.pdf'>
Yamil
I tested the url with a javascript program and it works.
Anonymous
what is the "related_name" in the models? I read a little in the doc but I did not understand which usage I had found it was to use his name instead of using the model name in a relation.
Rajjix
from django.contrib.auth.view import LoginView as loginview class LoginView(loginview): form_class = UserLoginForm template_name = 'user/login.html' success_url = '' authentication_form = UserLoginForm
Rajjix
LoginView Works fine when imported and used directly into my urls but when i wanna add some stuff to it i get this error
Rajjix
__init__() got an unexpected keyword argument 'request'
Rajjix
File "/home/rajjix/Django/lib64/python3.7/site-packages/django/views/generic/edit.py", line 33, in get_form return form_class(**self.get_form_kwargs()) TypeError: __init__() got an unexpected keyword argument 'request'
Rajjix
path('login/', LoginView.as_view(), name='login'),
Rajjix
again when i import it directly from django.contrib.auth.views it works fine in urls but now when i import it from my views i get that error
Rajjix
https://pastebin.com/XyWAMevc
inchidi
https://pastebin.com/XyWAMevc
oh what you want is your user can login with username or email?
Rajjix
Ye
Rajjix
It worked until i decided to bring in the LoginView to my views maybe add some functions
inchidi
better create custom authentication backend instead handle it in your form
Rajjix
better create custom authentication backend instead handle it in your form
I just took a shortcut from that but guess i’ll be doing it if you suggest so
inchidi
here is the sample
Rajjix
inchidi
by using this technique django will handle your authentication for you. the logic behind it is something like this: >> authenticate() called >> django iterate through all authentication backend >> if fail to authenticate, use next auth backend >> if success, return the user object
inchidi
so even if you have so many user type, maybe user can login just by token without providing username at all, or/and maybe user can also login with phone number also. all you need to do is register your auth logic there
Rajjix
I’ll be adding the custom authentication back end thanks for the feedback
Rajjix
But since your here if that doesn’t solve my request problem from the editview as shown above is it ok to just edit the source code and add a try except statement without that request in the __init
Rajjix
File "/home/rajjix/Django/lib64/python3.7/site-packages/django/views/generic/edit.py", line 33, in get_form return form_class(**self.get_form_kwargs()) TypeError: __init__() got an unexpected keyword argument 'request'
inchidi
But since your here if that doesn’t solve my request problem from the editview as shown above is it ok to just edit the source code and add a try except statement without that request in the __init
in that case, override from django.contrib.auth.forms import AuthenticationForm instead form.Form and dont forget to authenticate() there
Rajjix
I have time i’ll keep trying something gotta work ))
Rajjix
Thanks for the efforts master inchidi 🙇
inchidi
Thanks for the efforts master inchidi 🙇
you're welcome. am not master btw i just prefer to really know tools i use
None
Hello, I have a django project on wsgi server. I want to include django channels and to do it I should use asgi server. Will it work if I just change wsgi on asgi?
Piyush
Hi, I create the 3 services, one is oauth2 provider.. And two are clients. I am trying to implement openid connect so that I can get sso feature. How can I implement it??
Rajjix
in that case, override from django.contrib.auth.forms import AuthenticationForm instead form.Form and dont forget to authenticate() there
All setup, backend and my custom login form (inherited from authentication form), literally took me 30 mins xd now i can edit whatever whenever i want, thank you 🙏
Anonymous
Hello everyone
Anonymous
What is the best way to build django app on azure
Rajjix
https://medium.com/@__pamaron__/deploy-a-django-application-connected-to-azure-sql-using-docker-and-azure-app-service-a2c107773c11?source=userActivityShare-f344d1364a9b-1539322618
Anonymous
Yeah i read thiz
Anonymous
This*