Re: Django Exception "Detected path traversal attempt in" for save a model with filefield

2022-02-03 Thread Jacob Greene
This is obviously some type of security feature to prevent someone from
climbing up a directory. You have ".." in your string for the file path
somewhere.

What is the value of "dir_name" when the exception is raised? It should be
in the traceback somewhere. Should help narrow down where it's coming from.
Most likely a mistake you made in your settings file concating strings
related to where Django should upload files.

On Thu, Feb 3, 2022, 2:12 PM Joalbert Palacios  wrote:

> Hi group,
>
> I have been updating my django version so as to cover the last security
> patch with django version 3.2  (current version 3.2.12).
>
> Unfortunately, after this update the following exception occurs during
> execution of testing:
>
> Detected path traversal attempt in '/home/joalbert/Documents/Remesas
> App/RemesasServer/media/payments/images/temp_qHaTViL.png'
> Bad Request: /webapp/payment
>
> I have read
> https://stackoverflow.com/questions/69745412/django-and-suspiciousfileoperationdetected-path-traversal-attempt
> and followed but not works in my case, maybe I misunderstood something, I
> would appreciate any help regarding how to fix those exception.
>
> I read django code and find the errors is in the following section:
>
> def get_available_name(self, name, max_length=None):
>
> """
>
> Return a filename that's free on the target storage system and
>
> available for new content to be written to.
>
> """
>
> name = str(name).replace('\\', '/')
>
> dir_name, file_name = os.path.split(name)
>
> if '..' in pathlib.PurePath(dir_name).parts:
>
> raise SuspiciousFileOperation("Detected path traversal attempt in '%s'" %
> dir_name)
>
> Here it is my code in the sections that code goes by to send response to
> client.
>
> *Model.py:*
> class Payment(models.Model):
> STATUS = ((0, _("Draft")), (1, _("Aproved")), (2 , _("Rejected")), (3,
> _("Released")))
> order_number_id = models.OneToOneField(Exchange_Order,
> on_delete=models.CASCADE, related_name="order_payment")
> user_id =models.ForeignKey(User, verbose_name=_('user'), on_delete=
> models.CASCADE, related_name="payment_user_id")
> capture = models.FileField(verbose_name=_('image'),
> upload_to="payments/images", max_length=1024)
> payment_date = models.DateTimeField(verbose_name=_('date'),
> default=datetime.now().replace(tzinfo=timezone.utc))
> status = models.PositiveSmallIntegerField(verbose_name=_('status'),
> default=0, choices=STATUS)
> reason = models.ForeignKey(Reasons,verbose_name=_('reason'),
> on_delete=models.CASCADE, related_name="payment_reason",
> null=True, blank=True)
>
> def __str__(self) -> str:
> return f"{self.order_number_id} {self.user_id.username}
> {self.payment_date}"
> class Meta: #new
> verbose_name = _("Payment from Client to 'Activo Digital'")
> verbose_name_plural = _("Payments from Client to 'Activo Digital'")
>
> *forms.py*
> class Payment_All_Form(forms.ModelForm):
> class Meta:
> model = Payment
> fields = "__all__"
> views.py (only post method is included for clarity)
> class PaymentSessionView(LoginRequiredMixin, CreateView):
> queryset = Payment.objects.all()
> form_class = Payment_Form
> http_method_names = ['get', 'post']
> template_name="clienteServidor/webapp/payment.html"
>
> @method_decorator(User_Detail_Permission_Web)
> def post(self, request, *args, **kwargs):
> models = Exchange_Order.objects.filter(status=0, user_id=request.user)
> # En caso de que no haya ordenes abiertas
> if not models.exists():
> context =self._add_context_data()
> context["existant"] ="No hay orden abierta"
> context["form"] = Payment_Form()
> return render(request,self.template_name, context)
> # Procesar pago para ordenes abiertas
> forms = []
> data_list = []
> order_ids = []
> for model in models:
> my_data = self._complete_data(request, model.id)
> data_list.append(my_data)
> order_ids.append(f"Orden: {model.id}")
> forms.append(Payment_All_Form(my_data,request.FILES))
> # Chequear que todas las formas sean validas
> are_valids = []
> for form in forms:
> are_valids.append(form.is_valid())
> # If any invalid
> if False in are_valids:
> for index, items in enumerate(are_valids):
> if not items:
> form = forms[index]
> context = self._add_context_data()
> context["form"] = form
> return render(request,self.template_name, context)
> for index, model in enumerate(models):
> if index == 0:
> forms[index].save()
> else:
> data_list[index]["order_number_id"]=model
> data_list[index]["user_id"]=request.user
> datum = {k:v for k,v in data_list[index].items() if
> k!="csrfmiddlewaretoken"}
> payment = Payment(**datum)
> payment.save()
> model.status=1
> model.grouped_orders = order_ids
> model.save()
> my_message ="Orden Nro "+ str(model.id) + (" fue procesada exitosamente,
> les estaremos notificando"
> " por correo cuando el pago sea validado y procesado en el destino.")
> messages.add_message(request, messages.INFO, my_message)
> return HttpResponseRedirect(reverse_lazy("transaction_web"))
>
> Settings.py:
> MEDIA_ROOT = 

Login page download as pdf instead of the other url page.

2022-02-03 Thread Aadil Rashid
Hello Django Family, I hope you all are well and in good Health.

I am trying to generating pdf from webpages, using popen subprocess , but
when i call its

view it generates only login page as pdf,


Here is my view


from projName.settings import BASE_DIR

from subprocess import Popen, PIPE, STDOUT

from wsgiref.util import FileWrapper



class DownloadAsPDF(View):

def post(self, request, *args, **kwargs):

base = str(BASE_DIR)

file_name = str( base + '/testreport.pdf')

post_url = request.POST.get("page_url")

url = str('http://' + request.get_host() + post_url)

chrome_args = ['/path/google-chrome', '--headless',
'--virtual-time-buget=2',

'--print-to-pdf=/path/testreport.pdf', url]

external_process = Popen(chrome_args, stdout=PIPE, stderr=STDOUT)

external_process.wait()

return_file = FileWrapper(open('{}'.format(file_name), 'r'))

download_file_name = 'report'

response = FileResponse(return_file,
content_type='application/force-download')

response['Content-Disposition'] = f'attachment; filename=
{download_file_name}.pdf'

return response


I was thinking of creating the popen subprocess in the same browser session
so that it will directly go to the said url page, instead of login page,

I couldn't find any good resources to implement this functionality, as it
is headless chrome here may be it's not possible to open in the same
browser session.


If this can't be the perfect solution, then please if anyone have some
other solution I will be very thankful,

Thanks you very much

-- 
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/CAAYXZx8dCU5ydr6B383kMgdMSxsg7i9vuJUyo7HjJ1g-EJMmZw%40mail.gmail.com.


Oracle database sequences generated by Django

2022-02-03 Thread Harold Achipiz
Hello everyone.

I have a web application built in Django == 1.11.6, when the migrations 
were generated in oracle the sequences are created and they can be modified 
and even deleted. 

When I update to django 3 and I generate the migrations again, it creates 
the sequences with a name similar to this (ISEQ $$ _ 76200) but it does not 
allow me to edit them and or delete them, it shows me the following message 
(ORA-32794: cannot delete a sequence generated by the system). The downside 
is that I have a stored procedure that drops a stream and recreates it to 
load with data from other tables each time it is run. 
(BEGIN / * DELETE RPT DATA --- --- 
* / / * INITIALIZE THE SEQUENCE 
- - * / DELETE FROM 
SISREPORTS_RPT02; EXECUTE IMMEDIATE 'DROP SEQUENCE SISREPORTS_RPT02_SQ'; 
EXECUTE IMMEDIATE 'CREATE SEQUENCE SISREPORTS_RPT02_SQ INCREMENT BY 1 START 
WITH 1 MAXVALUE  MINVALUE 1 CACHE 20 '; 
/*FINISH --- 
 * /) 

 My question is that if the new versions of django can do some 
configuration before generating them migrations and can have the option to 
modify the oracle sequences.

-- 
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/23eca760-c5f3-49f2-b3c2-1bd20c672e5an%40googlegroups.com.


Django Exception "Detected path traversal attempt in" for save a model with filefield

2022-02-03 Thread Joalbert Palacios
Hi group,

I have been updating my django version so as to cover the last security 
patch with django version 3.2  (current version 3.2.12). 

Unfortunately, after this update the following exception occurs during 
execution of testing:

Detected path traversal attempt in '/home/joalbert/Documents/Remesas 
App/RemesasServer/media/payments/images/temp_qHaTViL.png'
Bad Request: /webapp/payment

I have 
read 
https://stackoverflow.com/questions/69745412/django-and-suspiciousfileoperationdetected-path-traversal-attempt
 
and followed but not works in my case, maybe I misunderstood something, I 
would appreciate any help regarding how to fix those exception. 

I read django code and find the errors is in the following section:

def get_available_name(self, name, max_length=None):

"""

Return a filename that's free on the target storage system and

available for new content to be written to.

"""

name = str(name).replace('\\', '/')

dir_name, file_name = os.path.split(name)

if '..' in pathlib.PurePath(dir_name).parts:

raise SuspiciousFileOperation("Detected path traversal attempt in '%s'" % 
dir_name)

Here it is my code in the sections that code goes by to send response to 
client.

*Model.py:*
class Payment(models.Model):
STATUS = ((0, _("Draft")), (1, _("Aproved")), (2 , _("Rejected")), (3, 
_("Released")))
order_number_id = models.OneToOneField(Exchange_Order, 
on_delete=models.CASCADE, related_name="order_payment")
user_id =models.ForeignKey(User, verbose_name=_('user'), on_delete= 
models.CASCADE, related_name="payment_user_id")
capture = models.FileField(verbose_name=_('image'), 
upload_to="payments/images", max_length=1024)
payment_date = models.DateTimeField(verbose_name=_('date'), 
default=datetime.now().replace(tzinfo=timezone.utc))
status = models.PositiveSmallIntegerField(verbose_name=_('status'), 
default=0, choices=STATUS) 
reason = models.ForeignKey(Reasons,verbose_name=_('reason'), 
on_delete=models.CASCADE, related_name="payment_reason", 
null=True, blank=True)

def __str__(self) -> str:
return f"{self.order_number_id} {self.user_id.username} {self.payment_date}"
class Meta: #new
verbose_name = _("Payment from Client to 'Activo Digital'")
verbose_name_plural = _("Payments from Client to 'Activo Digital'")

*forms.py*
class Payment_All_Form(forms.ModelForm):
class Meta: 
model = Payment
fields = "__all__"
views.py (only post method is included for clarity)
class PaymentSessionView(LoginRequiredMixin, CreateView):
queryset = Payment.objects.all()
form_class = Payment_Form
http_method_names = ['get', 'post']
template_name="clienteServidor/webapp/payment.html" 

@method_decorator(User_Detail_Permission_Web)
def post(self, request, *args, **kwargs):
models = Exchange_Order.objects.filter(status=0, user_id=request.user)
# En caso de que no haya ordenes abiertas
if not models.exists():
context =self._add_context_data()
context["existant"] ="No hay orden abierta"
context["form"] = Payment_Form()
return render(request,self.template_name, context)
# Procesar pago para ordenes abiertas
forms = []
data_list = []
order_ids = []
for model in models:
my_data = self._complete_data(request, model.id)
data_list.append(my_data)
order_ids.append(f"Orden: {model.id}")
forms.append(Payment_All_Form(my_data,request.FILES))
# Chequear que todas las formas sean validas
are_valids = []
for form in forms: 
are_valids.append(form.is_valid())
# If any invalid
if False in are_valids:
for index, items in enumerate(are_valids):
if not items:
form = forms[index] 
context = self._add_context_data() 
context["form"] = form 
return render(request,self.template_name, context)
for index, model in enumerate(models):
if index == 0:
forms[index].save()
else:
data_list[index]["order_number_id"]=model
data_list[index]["user_id"]=request.user
datum = {k:v for k,v in data_list[index].items() if 
k!="csrfmiddlewaretoken"}
payment = Payment(**datum)
payment.save() 
model.status=1
model.grouped_orders = order_ids
model.save()
my_message ="Orden Nro "+ str(model.id) + (" fue procesada exitosamente, 
les estaremos notificando"
" por correo cuando el pago sea validado y procesado en el destino.")
messages.add_message(request, messages.INFO, my_message)
return HttpResponseRedirect(reverse_lazy("transaction_web"))

Settings.py:
MEDIA_ROOT = "./media/"#os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'

I hope sincerely that you could have any answer how to fix it. I really 
appreciate your help regarding this issue.

Sincerely,
Joalbert 

-- 
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/35a15616-92fc-41d4-97b3-8fb3061ec881n%40googlegroups.com.


Re: Static files not found

2022-02-03 Thread Muhammad Muhammad inuwa
At the bottom of your code, you need to include the STATICFILES_DIRS =
[BASE_DIR/""].
This tells django where your static files are

On Thu, Feb 3, 2022, 18:49 Opeyemi Ogunsanya 
wrote:

> Move the static folder to the Django app folder
>
> On Thu, Feb 3, 2022, 6:01 PM Serge Alard  wrote:
>
>> Thank you for the suggestion but it does not work.
>> I add 2 things to make easier your helps :
>>
>>- the settings and wsgi files are in /www/Web_bridge/ Web_bridge/
>>- the static files are in /www/Web_bridge/static/bridge/
>>
>> Below an example of connexion.html that calls a static file :
>>
>> {% extends "bridge/sous_base.html" %}
>>
>> {% block content %}
>> {% if error_message %}{{ error_message }}{% endif %}
>> Connexion
>> 
>> {% csrf_token %}
>> 
>> Pseudonyme : 
>> > required />
>> 
>> Mot de passe : 
>> 
>> > onclick="Afficher(['pass'])" >
>> 
>> Mot
>> de passe oublié
>> 
>> 
>> 
>> 
>> 
>> {% endblock %}
>>
>> {% block script %}
>> {% load static %}
>> {{ block.super }}
>> 
>> {% endblock %}
>>
>> Thank you in advance for your suggestions.
>>
>> Le jeudi 3 février 2022 à 16:33:10 UTC+1, dashlaksh...@gmail.com a
>> écrit :
>>
>>> Please add this line below static_url
>>>
>>> STATICFILES_DIRS = [
>>> 'static'
>>> ]
>>>
>>> On Thu, Feb 3, 2022, 20:53 Serge Alard  wrote:
>>>
 Hello

 I developped a project in Django python that works fine. Thus, I
 deployed my project. Everything works but the static files are not found by
 the application.
 I give you below the settings and wsgi files.

 *WSGI*
 import os

 from django.core.wsgi import get_wsgi_application

 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Web_bridge.settings')

 application = get_wsgi_application()

 *SETTINGS*
 import os
 from pathlib import Path

 os.environ['ENV'] = 'PRODUCTION'

 BASE_DIR = Path(__file__).resolve(strict=True).parent.parent

 DEBUG = False
 SECRET_KEY =
 'django-insecure-eqlug^3e20v1c5%mo9*mhhea^vv$!$%x&6!@6$+e%7'
 ALLOWED_HOSTS = ['*']

 STATIC_ROOT = os.path.join(BASE_DIR, "static")

 INSTALLED_APPS = [
 'bridge.apps.BridgeConfig',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 ]

 MIDDLEWARE = [
 'django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 ]

 ROOT_URLCONF = 'Web_bridge.urls'

 TEMPLATES = [
 {
 'BACKEND': 'django.template.backends.django.DjangoTemplates',
 'DIRS': [BASE_DIR / 'templates'],
 'APP_DIRS': True,
 'OPTIONS': {
 'context_processors': [
 'django.template.context_processors.debug',
 'django.template.context_processors.request',
 'django.contrib.auth.context_processors.auth',
 'django.contrib.messages.context_processors.messages',
 ],
 },
 },
 ]

 WSGI_APPLICATION = 'Web_bridge.wsgi.application'

 DATABASES = {
 'default': {
 'ENGINE': 'django.db.backends.postgresql', # on utilise l'adaptateur
 postgresql
 'NAME': 'sudoku_bridge', # le nom de notre base de donnees creee
 precedemment
 'USER': 'sudoku', # attention : remplacez par votre nom d'utilisateur
 'PASSWORD': '*',
 'HOST': 'postgresql-sudoku.alwaysdata.net',
 'PORT': '5432',
 'CONN_MAX_AGE': 500,
 }
 }

 AUTH_PASSWORD_VALIDATORS = [
 {
 'NAME':
 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
 },
 {
 'NAME':
 'django.contrib.auth.password_validation.MinimumLengthValidator',
 },
 {
 'NAME':
 'django.contrib.auth.password_validation.CommonPasswordValidator',
 },
 {
 'NAME':
 'django.contrib.auth.password_validation.NumericPasswordValidator',
 },
 ]

 LANGUAGE_CODE = 'fr-FR'

 TIME_ZONE = 'Europe/Paris'

 USE_I18N = True

 USE_L10N = True

 USE_TZ = False

 STATIC_URL = 'static/'

 Thank you in advance to help me.

 --
 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/1c8bda14-d16f-405f-9c66-29e63275419bn%40googlegroups.com
 

Re: Static files not found

2022-02-03 Thread Lakshyaraj Dash X-D 25
Ok! Actually I had not looked properly to your file. The line that I had
given was already in STATIC_ROOT. If you have debug=False, then you can run
something like this :
python manage.py runserver --insecure

It will serve your static files while the debug mode is set to false.

On Thu, Feb 3, 2022, 22:29 Serge Alard  wrote:

> Thank you for the suggestion but it does not work.
> I add 2 things to make easier your helps :
>
>- the settings and wsgi files are in /www/Web_bridge/ Web_bridge/
>- the static files are in /www/Web_bridge/static/bridge/
>
> Below an example of connexion.html that calls a static file :
>
> {% extends "bridge/sous_base.html" %}
>
> {% block content %}
> {% if error_message %}{{ error_message }}{% endif %}
> Connexion
> 
> {% csrf_token %}
> 
> Pseudonyme : 
>  />
> 
> Mot de passe : 
> 
>  onclick="Afficher(['pass'])" >
> 
> Mot de
> passe oublié
> 
> 
> 
> 
> 
> {% endblock %}
>
> {% block script %}
> {% load static %}
> {{ block.super }}
> 
> {% endblock %}
>
> Thank you in advance for your suggestions.
>
> Le jeudi 3 février 2022 à 16:33:10 UTC+1, dashlaksh...@gmail.com a écrit :
>
>> Please add this line below static_url
>>
>> STATICFILES_DIRS = [
>> 'static'
>> ]
>>
>> On Thu, Feb 3, 2022, 20:53 Serge Alard  wrote:
>>
>>> Hello
>>>
>>> I developped a project in Django python that works fine. Thus, I
>>> deployed my project. Everything works but the static files are not found by
>>> the application.
>>> I give you below the settings and wsgi files.
>>>
>>> *WSGI*
>>> import os
>>>
>>> from django.core.wsgi import get_wsgi_application
>>>
>>> os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Web_bridge.settings')
>>>
>>> application = get_wsgi_application()
>>>
>>> *SETTINGS*
>>> import os
>>> from pathlib import Path
>>>
>>> os.environ['ENV'] = 'PRODUCTION'
>>>
>>> BASE_DIR = Path(__file__).resolve(strict=True).parent.parent
>>>
>>> DEBUG = False
>>> SECRET_KEY =
>>> 'django-insecure-eqlug^3e20v1c5%mo9*mhhea^vv$!$%x&6!@6$+e%7'
>>> ALLOWED_HOSTS = ['*']
>>>
>>> STATIC_ROOT = os.path.join(BASE_DIR, "static")
>>>
>>> INSTALLED_APPS = [
>>> 'bridge.apps.BridgeConfig',
>>> 'django.contrib.admin',
>>> 'django.contrib.auth',
>>> 'django.contrib.contenttypes',
>>> 'django.contrib.sessions',
>>> 'django.contrib.messages',
>>> 'django.contrib.staticfiles',
>>> 'django.contrib.sites',
>>> ]
>>>
>>> MIDDLEWARE = [
>>> 'django.middleware.security.SecurityMiddleware',
>>> 'django.contrib.sessions.middleware.SessionMiddleware',
>>> 'django.middleware.common.CommonMiddleware',
>>> 'django.middleware.csrf.CsrfViewMiddleware',
>>> 'django.contrib.auth.middleware.AuthenticationMiddleware',
>>> 'django.contrib.messages.middleware.MessageMiddleware',
>>> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
>>> ]
>>>
>>> ROOT_URLCONF = 'Web_bridge.urls'
>>>
>>> TEMPLATES = [
>>> {
>>> 'BACKEND': 'django.template.backends.django.DjangoTemplates',
>>> 'DIRS': [BASE_DIR / 'templates'],
>>> 'APP_DIRS': True,
>>> 'OPTIONS': {
>>> 'context_processors': [
>>> 'django.template.context_processors.debug',
>>> 'django.template.context_processors.request',
>>> 'django.contrib.auth.context_processors.auth',
>>> 'django.contrib.messages.context_processors.messages',
>>> ],
>>> },
>>> },
>>> ]
>>>
>>> WSGI_APPLICATION = 'Web_bridge.wsgi.application'
>>>
>>> DATABASES = {
>>> 'default': {
>>> 'ENGINE': 'django.db.backends.postgresql', # on utilise l'adaptateur
>>> postgresql
>>> 'NAME': 'sudoku_bridge', # le nom de notre base de donnees creee
>>> precedemment
>>> 'USER': 'sudoku', # attention : remplacez par votre nom d'utilisateur
>>> 'PASSWORD': '*',
>>> 'HOST': 'postgresql-sudoku.alwaysdata.net',
>>> 'PORT': '5432',
>>> 'CONN_MAX_AGE': 500,
>>> }
>>> }
>>>
>>> AUTH_PASSWORD_VALIDATORS = [
>>> {
>>> 'NAME':
>>> 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
>>> },
>>> {
>>> 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
>>> },
>>> {
>>> 'NAME':
>>> 'django.contrib.auth.password_validation.CommonPasswordValidator',
>>> },
>>> {
>>> 'NAME':
>>> 'django.contrib.auth.password_validation.NumericPasswordValidator',
>>> },
>>> ]
>>>
>>> LANGUAGE_CODE = 'fr-FR'
>>>
>>> TIME_ZONE = 'Europe/Paris'
>>>
>>> USE_I18N = True
>>>
>>> USE_L10N = True
>>>
>>> USE_TZ = False
>>>
>>> STATIC_URL = 'static/'
>>>
>>> Thank you in advance to help me.
>>>
>>> --
>>> 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/1c8bda14-d16f-405f-9c66-29e63275419bn%40googlegroups.com
>>> 
>>> .
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> 

Re: Static files not found

2022-02-03 Thread Opeyemi Ogunsanya
Move the static folder to the Django app folder

On Thu, Feb 3, 2022, 6:01 PM Serge Alard  wrote:

> Thank you for the suggestion but it does not work.
> I add 2 things to make easier your helps :
>
>- the settings and wsgi files are in /www/Web_bridge/ Web_bridge/
>- the static files are in /www/Web_bridge/static/bridge/
>
> Below an example of connexion.html that calls a static file :
>
> {% extends "bridge/sous_base.html" %}
>
> {% block content %}
> {% if error_message %}{{ error_message }}{% endif %}
> Connexion
> 
> {% csrf_token %}
> 
> Pseudonyme : 
>  />
> 
> Mot de passe : 
> 
>  onclick="Afficher(['pass'])" >
> 
> Mot de
> passe oublié
> 
> 
> 
> 
> 
> {% endblock %}
>
> {% block script %}
> {% load static %}
> {{ block.super }}
> 
> {% endblock %}
>
> Thank you in advance for your suggestions.
>
> Le jeudi 3 février 2022 à 16:33:10 UTC+1, dashlaksh...@gmail.com a écrit :
>
>> Please add this line below static_url
>>
>> STATICFILES_DIRS = [
>> 'static'
>> ]
>>
>> On Thu, Feb 3, 2022, 20:53 Serge Alard  wrote:
>>
>>> Hello
>>>
>>> I developped a project in Django python that works fine. Thus, I
>>> deployed my project. Everything works but the static files are not found by
>>> the application.
>>> I give you below the settings and wsgi files.
>>>
>>> *WSGI*
>>> import os
>>>
>>> from django.core.wsgi import get_wsgi_application
>>>
>>> os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Web_bridge.settings')
>>>
>>> application = get_wsgi_application()
>>>
>>> *SETTINGS*
>>> import os
>>> from pathlib import Path
>>>
>>> os.environ['ENV'] = 'PRODUCTION'
>>>
>>> BASE_DIR = Path(__file__).resolve(strict=True).parent.parent
>>>
>>> DEBUG = False
>>> SECRET_KEY =
>>> 'django-insecure-eqlug^3e20v1c5%mo9*mhhea^vv$!$%x&6!@6$+e%7'
>>> ALLOWED_HOSTS = ['*']
>>>
>>> STATIC_ROOT = os.path.join(BASE_DIR, "static")
>>>
>>> INSTALLED_APPS = [
>>> 'bridge.apps.BridgeConfig',
>>> 'django.contrib.admin',
>>> 'django.contrib.auth',
>>> 'django.contrib.contenttypes',
>>> 'django.contrib.sessions',
>>> 'django.contrib.messages',
>>> 'django.contrib.staticfiles',
>>> 'django.contrib.sites',
>>> ]
>>>
>>> MIDDLEWARE = [
>>> 'django.middleware.security.SecurityMiddleware',
>>> 'django.contrib.sessions.middleware.SessionMiddleware',
>>> 'django.middleware.common.CommonMiddleware',
>>> 'django.middleware.csrf.CsrfViewMiddleware',
>>> 'django.contrib.auth.middleware.AuthenticationMiddleware',
>>> 'django.contrib.messages.middleware.MessageMiddleware',
>>> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
>>> ]
>>>
>>> ROOT_URLCONF = 'Web_bridge.urls'
>>>
>>> TEMPLATES = [
>>> {
>>> 'BACKEND': 'django.template.backends.django.DjangoTemplates',
>>> 'DIRS': [BASE_DIR / 'templates'],
>>> 'APP_DIRS': True,
>>> 'OPTIONS': {
>>> 'context_processors': [
>>> 'django.template.context_processors.debug',
>>> 'django.template.context_processors.request',
>>> 'django.contrib.auth.context_processors.auth',
>>> 'django.contrib.messages.context_processors.messages',
>>> ],
>>> },
>>> },
>>> ]
>>>
>>> WSGI_APPLICATION = 'Web_bridge.wsgi.application'
>>>
>>> DATABASES = {
>>> 'default': {
>>> 'ENGINE': 'django.db.backends.postgresql', # on utilise l'adaptateur
>>> postgresql
>>> 'NAME': 'sudoku_bridge', # le nom de notre base de donnees creee
>>> precedemment
>>> 'USER': 'sudoku', # attention : remplacez par votre nom d'utilisateur
>>> 'PASSWORD': '*',
>>> 'HOST': 'postgresql-sudoku.alwaysdata.net',
>>> 'PORT': '5432',
>>> 'CONN_MAX_AGE': 500,
>>> }
>>> }
>>>
>>> AUTH_PASSWORD_VALIDATORS = [
>>> {
>>> 'NAME':
>>> 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
>>> },
>>> {
>>> 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
>>> },
>>> {
>>> 'NAME':
>>> 'django.contrib.auth.password_validation.CommonPasswordValidator',
>>> },
>>> {
>>> 'NAME':
>>> 'django.contrib.auth.password_validation.NumericPasswordValidator',
>>> },
>>> ]
>>>
>>> LANGUAGE_CODE = 'fr-FR'
>>>
>>> TIME_ZONE = 'Europe/Paris'
>>>
>>> USE_I18N = True
>>>
>>> USE_L10N = True
>>>
>>> USE_TZ = False
>>>
>>> STATIC_URL = 'static/'
>>>
>>> Thank you in advance to help me.
>>>
>>> --
>>> 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/1c8bda14-d16f-405f-9c66-29e63275419bn%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
> 

Re: Static files not found

2022-02-03 Thread Serge Alard
Thank you for the suggestion but it does not work.
I add 2 things to make easier your helps :

   - the settings and wsgi files are in /www/Web_bridge/ Web_bridge/
   - the static files are in /www/Web_bridge/static/bridge/

Below an example of connexion.html that calls a static file :

{% extends "bridge/sous_base.html" %}

{% block content %}
{% if error_message %}{{ error_message }}{% endif %}
Connexion

{% csrf_token %}

Pseudonyme : 


Mot de passe : 



Mot de 
passe oublié





{% endblock %}

{% block script %}
{% load static %}
{{ block.super }}

{% endblock %}

Thank you in advance for your suggestions.

Le jeudi 3 février 2022 à 16:33:10 UTC+1, dashlaksh...@gmail.com a écrit :

> Please add this line below static_url
>
> STATICFILES_DIRS = [
> 'static'
> ]
>
> On Thu, Feb 3, 2022, 20:53 Serge Alard  wrote:
>
>> Hello
>>
>> I developped a project in Django python that works fine. Thus, I deployed 
>> my project. Everything works but the static files are not found by the 
>> application.
>> I give you below the settings and wsgi files.
>>
>> *WSGI*
>> import os
>>
>> from django.core.wsgi import get_wsgi_application
>>
>> os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Web_bridge.settings')
>>
>> application = get_wsgi_application()
>>
>> *SETTINGS*
>> import os
>> from pathlib import Path
>>
>> os.environ['ENV'] = 'PRODUCTION'
>>
>> BASE_DIR = Path(__file__).resolve(strict=True).parent.parent
>>
>> DEBUG = False
>> SECRET_KEY = 
>> 'django-insecure-eqlug^3e20v1c5%mo9*mhhea^vv$!$%x&6!@6$+e%7'
>> ALLOWED_HOSTS = ['*']
>>
>> STATIC_ROOT = os.path.join(BASE_DIR, "static")
>>
>> INSTALLED_APPS = [
>> 'bridge.apps.BridgeConfig',
>> 'django.contrib.admin',
>> 'django.contrib.auth',
>> 'django.contrib.contenttypes',
>> 'django.contrib.sessions',
>> 'django.contrib.messages',
>> 'django.contrib.staticfiles',
>> 'django.contrib.sites',
>> ]
>>
>> MIDDLEWARE = [
>> 'django.middleware.security.SecurityMiddleware',
>> 'django.contrib.sessions.middleware.SessionMiddleware',
>> 'django.middleware.common.CommonMiddleware',
>> 'django.middleware.csrf.CsrfViewMiddleware',
>> 'django.contrib.auth.middleware.AuthenticationMiddleware',
>> 'django.contrib.messages.middleware.MessageMiddleware',
>> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
>> ]
>>
>> ROOT_URLCONF = 'Web_bridge.urls'
>>
>> TEMPLATES = [
>> {
>> 'BACKEND': 'django.template.backends.django.DjangoTemplates',
>> 'DIRS': [BASE_DIR / 'templates'],
>> 'APP_DIRS': True,
>> 'OPTIONS': {
>> 'context_processors': [
>> 'django.template.context_processors.debug',
>> 'django.template.context_processors.request',
>> 'django.contrib.auth.context_processors.auth',
>> 'django.contrib.messages.context_processors.messages',
>> ],
>> },
>> },
>> ]
>>
>> WSGI_APPLICATION = 'Web_bridge.wsgi.application'
>>
>> DATABASES = {
>> 'default': {
>> 'ENGINE': 'django.db.backends.postgresql', # on utilise l'adaptateur 
>> postgresql
>> 'NAME': 'sudoku_bridge', # le nom de notre base de donnees creee 
>> precedemment
>> 'USER': 'sudoku', # attention : remplacez par votre nom d'utilisateur
>> 'PASSWORD': '*',
>> 'HOST': 'postgresql-sudoku.alwaysdata.net',
>> 'PORT': '5432',
>> 'CONN_MAX_AGE': 500,
>> }
>> }
>>
>> AUTH_PASSWORD_VALIDATORS = [
>> {
>> 'NAME': 
>> 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
>> },
>> {
>> 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
>> },
>> {
>> 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
>> },
>> {
>> 'NAME': 
>> 'django.contrib.auth.password_validation.NumericPasswordValidator',
>> },
>> ]
>>
>> LANGUAGE_CODE = 'fr-FR'
>>
>> TIME_ZONE = 'Europe/Paris'
>>
>> USE_I18N = True
>>
>> USE_L10N = True
>>
>> USE_TZ = False
>>
>> STATIC_URL = 'static/'
>>
>> Thank you in advance to help me.
>>
>> -- 
>> 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/1c8bda14-d16f-405f-9c66-29e63275419bn%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/280871bd-69c4-42a4-b781-578e20c0d7f4n%40googlegroups.com.


Re: Resource leaks from FieldFile's implicit open?

2022-02-03 Thread Carsten Fuchs
Hello,

many thanks for your reply!

Am 02.02.22 um 09:17 schrieb Antonis Christofides:
> It is actually FieldFile.open() that is a wrapper around Storage.open(). 
> Therefore I think I'd rephrase as follows:
> 
> FieldFile is a subclass of File. While File is a wrapper around Python's 
> built-in file object, FieldFile uses the underlying Storage.

Yes, thanks, that makes a lot more sense than what's in the docs!

> Inside the "with" block you will probably access `some_file_field.file`. 
> Apparently accessing that attribute is what opens the file (but accessing the 
> `size` attribute also seems to be opening it, which is probably suboptimal.)

Yes, and e.g. the `width` attribute if it is an image...

I had a look at the code, but there are still a *lot* of open questions. At 
this time, I consider to not use FileField at all but to use plain CharFields 
instead to just store the file names and then to use the storage directly. This 
removes an entire layer of abstraction without which things seem to be a lot 
clearer.

Best regards,
Carsten



> On 01/02/2022 21.22, Carsten Fuchs wrote:
>> Dear group,
>>
>> despite a lot of reading and searching I still don't understand how 
>> FieldFiles work.
>>
>> The documentation at 
>> https://docs.djangoproject.com/en/4.0/ref/models/fields/#django.db.models.fields.files.FieldFile
>>  says:
>>
>>> The API of FieldFile mirrors that of File, with one key difference: The 
>>> object wrapped by the class is not necessarily a wrapper around Python’s 
>>> built-in file object. Instead, it is a wrapper around *** the result of the 
>>> Storage.open() method ***, which may be a File object, or it may be a 
>>> custom storage’s implementation of the File API.
>> (I added markers to indicate the portion that I have trouble with.)
>>
>> As far as I understand this, whenever a `FieldFile` is instantiated, 
>> `Storage.open()` is called. Thus, if the underlying storage is the 
>> `FileSystemStorage`, a Python file object is opened.
>>
>> However, how is this file handle closed again?
>>
>> It looks as if it stays open until garbage collected, that is, possibly for 
>> a very long time.
>>
>> Another consequence besides the potential resource leak seems to be that the 
>> implicit open will raise an exception if the file that the `FieldFile` 
>> refers to doesn't exist. As I don't exactly understand when this opening 
>> occurs, a lot of code must be wrapped in try-except blocks to handle this?
>>
>> Best regards,
>> Carsten
>>

-- 
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/2db4c126-10b2-a79f-fb00-bd9b836db209%40cafu.de.


Re: Static files not found

2022-02-03 Thread Lakshyaraj Dash X-D 25
Please add this line below static_url

STATICFILES_DIRS = [
'static'
]

On Thu, Feb 3, 2022, 20:53 Serge Alard  wrote:

> Hello
>
> I developped a project in Django python that works fine. Thus, I deployed
> my project. Everything works but the static files are not found by the
> application.
> I give you below the settings and wsgi files.
>
> *WSGI*
> import os
>
> from django.core.wsgi import get_wsgi_application
>
> os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Web_bridge.settings')
>
> application = get_wsgi_application()
>
> *SETTINGS*
> import os
> from pathlib import Path
>
> os.environ['ENV'] = 'PRODUCTION'
>
> BASE_DIR = Path(__file__).resolve(strict=True).parent.parent
>
> DEBUG = False
> SECRET_KEY =
> 'django-insecure-eqlug^3e20v1c5%mo9*mhhea^vv$!$%x&6!@6$+e%7'
> ALLOWED_HOSTS = ['*']
>
> STATIC_ROOT = os.path.join(BASE_DIR, "static")
>
> INSTALLED_APPS = [
> 'bridge.apps.BridgeConfig',
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'django.contrib.sites',
> ]
>
> MIDDLEWARE = [
> 'django.middleware.security.SecurityMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
> ]
>
> ROOT_URLCONF = 'Web_bridge.urls'
>
> TEMPLATES = [
> {
> 'BACKEND': 'django.template.backends.django.DjangoTemplates',
> 'DIRS': [BASE_DIR / 'templates'],
> 'APP_DIRS': True,
> 'OPTIONS': {
> 'context_processors': [
> 'django.template.context_processors.debug',
> 'django.template.context_processors.request',
> 'django.contrib.auth.context_processors.auth',
> 'django.contrib.messages.context_processors.messages',
> ],
> },
> },
> ]
>
> WSGI_APPLICATION = 'Web_bridge.wsgi.application'
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.postgresql', # on utilise l'adaptateur
> postgresql
> 'NAME': 'sudoku_bridge', # le nom de notre base de donnees creee
> precedemment
> 'USER': 'sudoku', # attention : remplacez par votre nom d'utilisateur
> 'PASSWORD': '*',
> 'HOST': 'postgresql-sudoku.alwaysdata.net',
> 'PORT': '5432',
> 'CONN_MAX_AGE': 500,
> }
> }
>
> AUTH_PASSWORD_VALIDATORS = [
> {
> 'NAME':
> 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
> },
> {
> 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
> },
> {
> 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
> },
> {
> 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
> },
> ]
>
> LANGUAGE_CODE = 'fr-FR'
>
> TIME_ZONE = 'Europe/Paris'
>
> USE_I18N = True
>
> USE_L10N = True
>
> USE_TZ = False
>
> STATIC_URL = 'static/'
>
> Thank you in advance to help me.
>
> --
> 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/1c8bda14-d16f-405f-9c66-29e63275419bn%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/CAF7qQgD5cHEDVcoCtL6JNJQyg%3Dhqr15bskOg6RWCKKn4-YCreQ%40mail.gmail.com.


Static files not found

2022-02-03 Thread Serge Alard
Hello

I developped a project in Django python that works fine. Thus, I deployed 
my project. Everything works but the static files are not found by the 
application.
I give you below the settings and wsgi files.

*WSGI*
import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Web_bridge.settings')

application = get_wsgi_application()

*SETTINGS*
import os
from pathlib import Path

os.environ['ENV'] = 'PRODUCTION'

BASE_DIR = Path(__file__).resolve(strict=True).parent.parent

DEBUG = False
SECRET_KEY = 
'django-insecure-eqlug^3e20v1c5%mo9*mhhea^vv$!$%x&6!@6$+e%7'
ALLOWED_HOSTS = ['*']

STATIC_ROOT = os.path.join(BASE_DIR, "static")

INSTALLED_APPS = [
'bridge.apps.BridgeConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'Web_bridge.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / 'templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'Web_bridge.wsgi.application'

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql', # on utilise l'adaptateur 
postgresql
'NAME': 'sudoku_bridge', # le nom de notre base de donnees creee 
precedemment
'USER': 'sudoku', # attention : remplacez par votre nom d'utilisateur
'PASSWORD': '*',
'HOST': 'postgresql-sudoku.alwaysdata.net',
'PORT': '5432',
'CONN_MAX_AGE': 500,
}
}

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 
'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]

LANGUAGE_CODE = 'fr-FR'

TIME_ZONE = 'Europe/Paris'

USE_I18N = True

USE_L10N = True

USE_TZ = False

STATIC_URL = 'static/'

Thank you in advance to help me.

-- 
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/1c8bda14-d16f-405f-9c66-29e63275419bn%40googlegroups.com.


Re: Django docs failing with search docs - certificate has expired

2022-02-03 Thread Will
I'm having the same issue starting about 10 minutes ago. For 
docs.djangoproject.com and code.djangoproject.com. Root domain works fine.
On Wednesday, February 2, 2022 at 11:24:45 PM UTC-5 Mike Dewhirst wrote:

>
> Error 503 certificate has expired
>
> certificate has expired
>
>
> Guru Mediation:
>
> Details: cache-syd10147-SYD 1643862123 79021947
>
> 
>
> Varnish cache server
>
>
> -- 
> Signed email is an absolute defence against phishing. This email has
> been signed with my private key. If you import my public key you can
> automatically decrypt my signature and be sure it came from me. Just
> ask and I'll send it to you. Your email software can handle signing.
>
>

-- 
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/98de31ae-e897-4c8f-8591-381b287c7711n%40googlegroups.com.


Re: Potential bug: mysql-connector-python Django 3.2.11 and third-party packages that populate the Admin Site

2022-02-03 Thread Richard Mayebo
mysql-connector-python 8.0.27 has another bug (see
https://stackoverflow.com/questions/69900463/django-migration-error-typeerror-sequence-item-1-expected-a-bytes-like-object
)
so I did not try it.

mysql-connector-python 8.0.26 did not have this problem with Django 3.1. So
the bug must have been introduced in the transition to Django 3.2.

>From what I am picking up (for example from Lakshyaraj Dash above),
mysql-connector-python seems to be buggy generally and mysqlclient should
be used as the first choice.

On Thu, Feb 3, 2022 at 4:14 PM Jason  wrote:

> can you observe the same behavior in previous versions of connector?  You
> listed two patch versions, makes me curious where in the 8.x version line
> this works.  Likely this is an issue with mysql-connector-python, but with
> it being an Oracle product, it doesn't have much internal visibility.  So
> could be helpful to downgrade versions till you get a working one.
>
> On Wednesday, February 2, 2022 at 9:01:51 PM UTC-5 dashlaksh...@gmail.com
> wrote:
>
>> Use only the mysqlclient package to populate your admin site with MySQL
>> database.
>>
>> You can watch this tutorial also : https://youtu.be/SNyCV8vOr-g
>>
>> On Thu, Feb 3, 2022, 06:19 Richard Mayebo  wrote:
>>
>>> Platform: Observed on Ubuntu 20.04
>>>
>>>
>>>1. Install MySQL (Observed on 5.7 and 8.0)
>>>2. Create a Virtual environment using venv, and activate it.
>>>3. Install Django 3.2.11
>>>4. Install mysql-connector-python (Observed on 8.0.26 and 8.0.28)
>>>5. Install django-easy-audit and/or django-axes (both these third
>>>party packages populate the Django Admin Site, where the apparent bug
>>>manifests).
>>>6. Create a superuser (python manage.py createsuperuser)
>>>7. Start Django (python manage.py runserver)
>>>8. Launch the Django Admin Site and log in with the superuser.
>>>9. The pane on the left hand side will have links to objects created
>>>by django-easy-audit and/or django-axes, depending on what was installed.
>>>10. Click on the "Request event" link under "Easy Audit Application"
>>>or "Access logs" under "Axes"
>>>11. RESULT:
>>>
>>> Template error: In template
>>> /home//.venv/lib/python3.8/site-packages/django/contrib/admin/templates/admin/base.html,
>>> error at line 44
>>>
>>>'NoneType' object has no attribute 'day' [*OR  'NoneType' object has
>>> no attribute 'month'*]
>>>
>>> This behaviour is observed on MySQL 5.7.37 and 8.0.26 using
>>> my-sql-connector 8.0.26 and 8.0.28.
>>>
>>> Replacing MySQL with SQLite or PostgreSQL 12 solves the issue.
>>>
>>> Replacing the connector with mysqlclient-2.1.0 solves the issue.
>>>
>>> This implies there is a bug in the interaction between third-party
>>> packages like django-easy-audit and django-axes, Django 3.2.11 and
>>> my-sql-connector 8.0.26 and 8.0.28.
>>>
>>> Has similar behaviour been observed by anyone else? In any case, how can
>>> this be brought to the attention of the development team?
>>>
>>> My apologies if this is the wrong forum for this post. I am new at this.
>>> Regards,
>>> Richard.
>>>
>>> --
>>> 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/0a483673-3393-42f9-87a1-c4463c583d7dn%40googlegroups.com
>>> 
>>> .
>>>
>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/s1s42RcxNMQ/unsubscribe.
> To unsubscribe from this group and all its topics, 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/d3eda24e-ab25-406c-9992-3af6f98701c1n%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/CAHYamgAJvB8M9b3c_Mqd8t7ZbbWMnYjjCHhF-Cvme9V%3D18E3fA%40mail.gmail.com.


Re: Potential bug: mysql-connector-python Django 3.2.11 and third-party packages that populate the Admin Site

2022-02-03 Thread Jason
can you observe the same behavior in previous versions of connector?  You 
listed two patch versions, makes me curious where in the 8.x version line 
this works.  Likely this is an issue with mysql-connector-python, but with 
it being an Oracle product, it doesn't have much internal visibility.  So 
could be helpful to downgrade versions till you get a working one.

On Wednesday, February 2, 2022 at 9:01:51 PM UTC-5 dashlaksh...@gmail.com 
wrote:

> Use only the mysqlclient package to populate your admin site with MySQL 
> database.
>
> You can watch this tutorial also : https://youtu.be/SNyCV8vOr-g
>
> On Thu, Feb 3, 2022, 06:19 Richard Mayebo  wrote:
>
>> Platform: Observed on Ubuntu 20.04
>>
>>
>>1. Install MySQL (Observed on 5.7 and 8.0)
>>2. Create a Virtual environment using venv, and activate it.
>>3. Install Django 3.2.11
>>4. Install mysql-connector-python (Observed on 8.0.26 and 8.0.28)
>>5. Install django-easy-audit and/or django-axes (both these third 
>>party packages populate the Django Admin Site, where the apparent bug 
>>manifests).
>>6. Create a superuser (python manage.py createsuperuser)
>>7. Start Django (python manage.py runserver)
>>8. Launch the Django Admin Site and log in with the superuser.
>>9. The pane on the left hand side will have links to objects created 
>>by django-easy-audit and/or django-axes, depending on what was installed.
>>10. Click on the "Request event" link under "Easy Audit Application" 
>>or "Access logs" under "Axes"
>>11. RESULT: 
>>
>> Template error: In template 
>> /home//.venv/lib/python3.8/site-packages/django/contrib/admin/templates/admin/base.html,
>>  
>> error at line 44
>>
>>'NoneType' object has no attribute 'day' [*OR  'NoneType' object has 
>> no attribute 'month'*] 
>>
>> This behaviour is observed on MySQL 5.7.37 and 8.0.26 using 
>> my-sql-connector 8.0.26 and 8.0.28.
>>
>> Replacing MySQL with SQLite or PostgreSQL 12 solves the issue. 
>>
>> Replacing the connector with mysqlclient-2.1.0 solves the issue. 
>>
>> This implies there is a bug in the interaction between third-party 
>> packages like django-easy-audit and django-axes, Django 3.2.11 and 
>> my-sql-connector 8.0.26 and 8.0.28.
>>
>> Has similar behaviour been observed by anyone else? In any case, how can 
>> this be brought to the attention of the development team?
>>
>> My apologies if this is the wrong forum for this post. I am new at this.
>> Regards,
>> Richard.
>>
>> -- 
>> 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/0a483673-3393-42f9-87a1-c4463c583d7dn%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/d3eda24e-ab25-406c-9992-3af6f98701c1n%40googlegroups.com.