Re: Popups in django forms?

2021-03-03 Thread zvo...@seznam.cz
No response for this topic for some time, so I will try partially answer 
myself.

Admin Django starting from version 2.0 has autocomplete_fields.
These are relalational fields (ForeignKey, ManyToManyField), targeted into 
other ModelAdmin, which find content for their widget via ajax at the url 
autocomplete/.
It works together with the .search_fields attribute of the targeted 
ModelAdmin.
.search_fields says, in which fields should be searched the string, which 
user will enter into the popup widget.
.search_fields can be replaced using .get_search_results().

Django implementation is weak. Problem is that the implementation doesn't 
think at all about the situation when 2 different ForeignKey-s target into 
same model.
Example: If you have in model 2 fields "Owner" and "Responsible", both 
targeted into User model, Django cannot in .get_search_results() find, 
which of them you just enter and how the accesible options should be 
filtered.
It is possible to make a trick with modyfiing of the Referer adress 
(request.headers['Referer']). We could add something like ?key=..., so 
.get_search_results() has then information, which one ForeignKey asks for 
results.
I made some experiments with this earlier and in 
github.com/pyutil/django-admin-autocomplete-all it is implemented (and a 
little commented with an usage example) in 
`autocomplete_all/js/autocomplete_params.js`.
Just inspiration, because I don't think that this package is perfect and 
its documentation well.

Django 2+ autocomplete_fields however cannot be used outside of Admin.
So we have 2 ways how to go:
1) Use django-autocomplete-light everywhere and ignore the possibility of 
Dj2 autocomplete_fields,
or 2) inside the Admin to prefer the native possibility: 
autocomplete_fields.

Dne pátek 26. února 2021 v 10:14:54 UTC+1 uživatel zvo...@seznam.cz napsal:

> I want start a new project with good support for popups (select+options) 
> in forms.
>
> My requirements are (and I think for real life project they are 
> neccessary):
> 1. ajax retrieved options based on users selection (outside of admin and 
> inside admin),
> 2. dynamic filtering of (especially related) options (again outside/inside 
> admin, include admin inlines); example: country & city: only cities from 
> selected country should be accessible.
>
> I have implemented this
>
> https://simpleisbetterthancomplex.com/tutorial/2018/01/29/how-to-implement-dependent-or-chained-dropdown-list-with-django.html
> include (2) functionality in inlines and it works.
>
> However it requires to much individual work in each case and doesn't 
> combine with ajax.
>
> Is there a better way how to achieve (1)+(2) everywhere in application?
> Are there some packages? What about django-autocomplete-light?
>
> Best regards,
> Mirek
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3a1517e7-9d59-4453-bd0f-81d639fb415an%40googlegroups.com.


Problem with admin site

2021-03-03 Thread kolo1
Hey
I've made some project with couples apps and now I'd like to manage by 
admin site but when I try to open localhost:8000/admin I get error
"""
TypeError at /admin/'tuple' object is not a mappingRequest Method:
GETRequest URL: http://localhost:8000/admin/
Django Version: 3.1.6Exception Type:
TypeErrorException Value: 'tuple' object is not a mappingException 
Location:/usr/lib/python3.9/site-packages/django/urls/resolvers.py, line 
486, in _populate
Python Executable:/usr/bin/python3Python 
Version: 3.9.1
"""
I can't find the problem? 
My urls.py
"""
from django.contrib import admin
from django.urls import include,path


urlpatterns = [
path('admin/', admin.site.urls),
path('', include('main.urls')),
path('raporty/', include('raporty.urls')), 
path('settings/', include('settings.urls'))

]
"""

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c64b8f71-35a7-4fb9-b902-93082aab64f7n%40googlegroups.com.


Re: Problem with admin site

2021-03-03 Thread Mr. X Offencer
Show your model.py

On Wed, 3 Mar 2021, 19:41 kolo1,  wrote:

> Hey
> I've made some project with couples apps and now I'd like to manage by
> admin site but when I try to open localhost:8000/admin I get error
> """
> TypeError at /admin/'tuple' object is not a mappingRequest Method:
> GETRequest URL: http://localhost:8000/admin/
> Django Version: 3.1.6Exception Type:
> TypeErrorException Value: 'tuple' object is not a mappingException
> Location:/usr/lib/python3.9/site-packages/django/urls/resolvers.py, line
> 486, in _populate
> Python Executable:/usr/bin/python3Python
> Version: 3.9.1
> """
> I can't find the problem?
> My urls.py
> """
> from django.contrib import admin
> from django.urls import include,path
>
>
> urlpatterns = [
> path('admin/', admin.site.urls),
> path('', include('main.urls')),
> path('raporty/', include('raporty.urls')),
> path('settings/', include('settings.urls'))
>
> ]
> """
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c64b8f71-35a7-4fb9-b902-93082aab64f7n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABz7kDTw1xVqNBfyed-Zn-dRZ6aruUoDeLHWkRfd-NS0WgBVOA%40mail.gmail.com.


Re: Problem with admin site

2021-03-03 Thread kolo1
Re: Problem with admin siteThanx for your replay. I found my mistake. I 
have incorrectly implemented the qrcode software in urls.py in two 
applications in my project. 
I have:
path('pdf_page', lost.home, include('qr_code.urls', namespace="qr_code"), 
name='pdf_page')
change to:
path('pdf_page', include('qr_code.urls', namespace="qr_code"))
For some reason everything was working with my err path only admin site not 
(why?). After change path seems everything works fine.

środa, 3 marca 2021 o 17:11:43 UTC+1 mr.xof...@gmail.com napisał(a):

> Show your model.py
>
> On Wed, 3 Mar 2021, 19:41 kolo1,  wrote:
>
>> Hey
>> I've made some project with couples apps and now I'd like to manage by 
>> admin site but when I try to open localhost:8000/admin I get error
>> """
>> TypeError at /admin/'tuple' object is not a mappingRequest Method:
>> GETRequest URL: http://localhost:8000/admin/
>> Django Version: 3.1.6Exception Type:
>> TypeErrorException Value: 'tuple' object is not a mappingException 
>> Location:/usr/lib/python3.9/site-packages/django/urls/resolvers.py, line 
>> 486, in _populate
>> Python Executable:/usr/bin/python3Python 
>> Version: 3.9.1
>> """
>> I can't find the problem? 
>> My urls.py
>> """
>> from django.contrib import admin
>> from django.urls import include,path
>>
>>
>> urlpatterns = [
>> path('admin/', admin.site.urls),
>> path('', include('main.urls')),
>> path('raporty/', include('raporty.urls')), 
>> path('settings/', include('settings.urls'))
>>
>> ]
>> """
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/c64b8f71-35a7-4fb9-b902-93082aab64f7n%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e3bb96d7-8306-4522-9da3-0d4ca2b5bb41n%40googlegroups.com.


Create a custom User model and Authenticate with it

2021-03-03 Thread Devansh Soni
Hi, 

I'm currently working on a Django project in which I have to create a User 
model with fields such as username, email, college, branch, semester, 
password, etc. And use this model to authenticate a user with an email and 
password.

How can I achieve this? Or what are the ways to achieve this?

Thank you

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fc2401f3-c80d-4b03-8b02-e62c90645ee8n%40googlegroups.com.


Re: Create a custom User model and Authenticate with it

2021-03-03 Thread Kasper Laudrup

On 03/03/2021 16.27, Devansh Soni wrote:

Hi,

I'm currently working on a Django project in which I have to create a 
User model with fields such as username, email, college, branch, 
semester, password, etc. And use this model to authenticate a user with 
an email and password.


How can I achieve this? Or what are the ways to achieve this?



https://docs.djangoproject.com/en/3.1/topics/auth/customizing/
https://testdriven.io/blog/django-custom-user-model/
https://simpleisbetterthancomplex.com/tutorial/2016/07/22/how-to-extend-django-user-model.html
https://learndjango.com/tutorials/django-custom-user-model


There's tons of documentation and examples for doing that.

Kind regards,

Kasper Laudrup

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6206bd8c-dec4-1362-75a4-34d370e1d5ea%40stacktrace.dk.


Re: Create a custom User model and Authenticate with it

2021-03-03 Thread Chelsea Fan
try this code, do not forget import authenticate (from django.contrib.auth
import authenticate, login)
modify this code

On Wed, Mar 3, 2021 at 8:01 PM Kasper Laudrup  wrote:

> On 03/03/2021 16.27, Devansh Soni wrote:
> > Hi,
> >
> > I'm currently working on a Django project in which I have to create a
> > User model with fields such as username, email, college, branch,
> > semester, password, etc. And use this model to authenticate a user with
> > an email and password.
> >
> > How can I achieve this? Or what are the ways to achieve this?
> >
>
> https://docs.djangoproject.com/en/3.1/topics/auth/customizing/
> https://testdriven.io/blog/django-custom-user-model/
>
> https://simpleisbetterthancomplex.com/tutorial/2016/07/22/how-to-extend-django-user-model.html
> https://learndjango.com/tutorials/django-custom-user-model
>
>
> There's tons of documentation and examples for doing that.
>
> Kind regards,
>
> Kasper Laudrup
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/6206bd8c-dec4-1362-75a4-34d370e1d5ea%40stacktrace.dk
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJwZndfACQ0WWnBxOaWa1AfdMtKFD4vmRX3KHfoa1e6%2BYjWe8g%40mail.gmail.com.


ANN: django-yamlconf v1.4.0 is available

2021-03-03 Thread Michael Rohan
Hi Folks,

Have released v1.4.0 for django-yamlconf, a module supporting Django
settings via YAML files (searching up the directory hierarchy, e.g., in a
K8s environment, adding a "final" set of settings via "/APPLICATION.yaml",
see the documentation a https://django-yamlconf.readthedocs.io/en/latest/
for more detailed info.

The updates for the this release are:

- Added support for JSON encoded environment values if decorated with
":jsonenv".  If JSON decoding fails (invalid JSON string), the value is
used as is.  This allows the definition of more complex values via the
environment, list, dictionaries, etc.  This can be used in K8s
environments, e.g., Concourse (for me).

- Added a `CODE-OF-CONDUCT` file for contributors.

Take care,
Michael


-- 
Michael Rohan
mro...@acm.org

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAOCsNFhSOuHUGur-ruPmvFrZEJ7mndGfd0B9x5cgCKV3Cn%3D4pQ%40mail.gmail.com.


Re: Create a custom User model and Authenticate with it

2021-03-03 Thread Gabriel Araya Garcia
Davansh:
The tables are made already in Admin Django, you only have to build
template (html), and the view. For example, in views.py:

def login_ini(request):
variable1 = 'Pantalla de Acceso al Sistema'
error_log = 'ok'
username = request.POST.get('username')
password = request.POST.get('password') # valor del template
user = auth.authenticate(username=username, password=password)
if request.method == "POST":
if user is not None and user.is_active:
#Correct password, and the user is marked "active"
auth.login(request, user)
request.session['username_x'] = username # variable gobal
request.session['id_x'] = user.id   # variable gobal
return HttpResponseRedirect("principal")
error_log = "error"

context = {'user':user,"variable1":variable1,"error_log":error_log,}

return render(request,'login_ini.html',context)


def log_out(request):
logout(request)
return redirect('login_ini')

Where login_ini.html, is the authentication template.

Only you must to build authentication template


Gabriel Araya Garcia
GMI - Desarrollo de Sistemas Informáticos




El mié, 3 mar 2021 a las 13:54, Devansh Soni ()
escribió:

> Hi,
>
> I'm currently working on a Django project in which I have to create a User
> model with fields such as username, email, college, branch, semester,
> password, etc. And use this model to authenticate a user with an email and
> password.
>
> How can I achieve this? Or what are the ways to achieve this?
>
> Thank you
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/fc2401f3-c80d-4b03-8b02-e62c90645ee8n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKVvSDCiWju%3D9B29mJaDkr5e94yXbBdtZx0B2G01nptiqQjKrA%40mail.gmail.com.


Seasoned Django Developer

2021-03-03 Thread Noel Simela
Good day,

I am looking for a good django developer to assist with some elements of a
project.
If you are familiar with Class Based Views , Signal and Haystack please
respond.

No chancers please.

-- 
*Noel Nqabeni Simela*
Web: https://nqabeni.wordpress.com

*"The Best thing in Life, is Life!"*

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGBhr7aAHfANOCd689cJUgD6LvYWshV%2B5sOQoX-yK%2Bb7Rye%2Big%40mail.gmail.com.


Re: Django does't send email on the remote server

2021-03-03 Thread AMRIT SHAHI
is that your site backend is fully backend

On Tue, Feb 23, 2021 at 3:51 PM Sergei Sokov  wrote:

> I am trying to send an email when a user fills out a form on my site.
> Everything works on my local server, letters are sent and I am got them.
> On a remote timeweb.com server with the same settings, letters are not
> sent.
> Tried DEBUG = False and True
> I tried different mail services: gmail, mail, yandex, timeweb mail.
> In gmail included "Unreliable applications that have access to the
> account".
> And here I included https://accounts.google.com/DisplayUnlockCaptcha
> Nothing helps.
>
> Who knows, please tell me where to dig.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/9c081e17-30ad-4bf9-9728-6b3010b3736an%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADydCv8ETHsZH8G30aF63s5oAh8cgyJJLt3m%2BnJ_T2gp_nS_9A%40mail.gmail.com.


Re: Django does't send email on the remote server

2021-03-03 Thread Malcolm MacKinnon
This might help:
https://dev.to/abderrahmanemustapha/how-to-send-email-with-django-and-gmail-in-production-the-right-way-24ab

On Wed, Mar 3, 2021 at 8:57 PM AMRIT SHAHI  wrote:
>
> is that your site backend is fully backend
>
> On Tue, Feb 23, 2021 at 3:51 PM Sergei Sokov  wrote:
>>
>> I am trying to send an email when a user fills out a form on my site.
>> Everything works on my local server, letters are sent and I am got them.
>> On a remote timeweb.com server with the same settings, letters are not sent.
>> Tried DEBUG = False and True
>> I tried different mail services: gmail, mail, yandex, timeweb mail.
>> In gmail included "Unreliable applications that have access to the account".
>> And here I included https://accounts.google.com/DisplayUnlockCaptcha
>> Nothing helps.
>>
>> Who knows, please tell me where to dig.
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/9c081e17-30ad-4bf9-9728-6b3010b3736an%40googlegroups.com.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CADydCv8ETHsZH8G30aF63s5oAh8cgyJJLt3m%2BnJ_T2gp_nS_9A%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK8W3XpTTGBMYxFETBft4TMAt7H-6_s19tavys_5No1arkPmSg%40mail.gmail.com.


Re: Seasoned Django Developer

2021-03-03 Thread Suraj Thapa FC
Yess

On Thu, 4 Mar, 2021, 10:01 am Noel Simela,  wrote:

> Good day,
>
> I am looking for a good django developer to assist with some elements of a
> project.
> If you are familiar with Class Based Views , Signal and Haystack please
> respond.
>
> No chancers please.
>
> --
> *Noel Nqabeni Simela*
> Web: https://nqabeni.wordpress.com
>
> *"The Best thing in Life, is Life!"*
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAGBhr7aAHfANOCd689cJUgD6LvYWshV%2B5sOQoX-yK%2Bb7Rye%2Big%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPjsHcG4NikBi%3Dixopjh1CQeFAjPY6QbgW2UXs0NHA7ugR7rDw%40mail.gmail.com.


Re: Seasoned Django Developer

2021-03-03 Thread Hubert Kanyamahanga
Hello, I am used to drf views and I have implemented a working search
engine with def and haystack and Elastic search

Do not hesitate to reach me out on my whastapp number +221777922780

On Thu, Mar 4, 2021, 4:31 AM Noel Simela  wrote:

> Good day,
>
> I am looking for a good django developer to assist with some elements of a
> project.
> If you are familiar with Class Based Views , Signal and Haystack please
> respond.
>
> No chancers please.
>
> --
> *Noel Nqabeni Simela*
> Web: https://nqabeni.wordpress.com
>
> *"The Best thing in Life, is Life!"*
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAGBhr7aAHfANOCd689cJUgD6LvYWshV%2B5sOQoX-yK%2Bb7Rye%2Big%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAE4dFh0i4ip9D5zFxNzqH5%3D9Z4vqgjXtwGvYEYxf-vrEzz6stw%40mail.gmail.com.