variable inside a template

2022-06-16 Thread luca72.b...@gmail.com
Hello i have a list like:
mylist =  ['1,png','2.png',3.jpj']
in the template i do as follow:
{% for o in mylist %}

{% if "png" in o %}
{{ o }}

{% else %}
{{o}}

{% endif %}
{% endfor %}
in the template i see the file name but it never render, if i loock the 
source code i see that in the http://127.0.0.1:8000/static_files/polls/%7Bo%7D>" class="">
So i never get the correct file name.
How is the correct way to get the name of the variable o inside the img tag
Thanks

-- 
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/b7e47034-7029-476a-bb08-a5e780c4b95bn%40googlegroups.com.


Re: static file serve nothing is load in deployment

2022-06-15 Thread luca72.b...@gmail.com
no i'm not in production
i'm running with runserver 

Il giorno mercoledì 15 giugno 2022 alle 12:45:54 UTC+2 Antonis Christofides 
ha scritto:

> Is this in production? Are you using apache or something? if yes, please 
> take a look at 
> https://djangodeployment.readthedocs.io/en/latest/_images/how-static-files-work-apache.png.
>  
> Otherwise, please explain in more detail what your deployment environment 
> looks like.
>
>
> On 15/06/2022 13.08, luca72.b...@gmail.com wrote:
>
> Hello i have this configuration in settings.py 
>
> STATIC_URL = '/static_files/'
> STATIC_ROOT =  'D:/prova_nuovo_sito/static_files'
>
> INSTALLED_APPS = [
> 'polls.apps.PollsConfig',
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> ]
>
> The folder where I store the file is  'D:/prova_nuovo_sito/static_files'
> in this folder I have a subfolder polls with all the needed file
>
> The template I write as follow:
> {% load static %}
>  media="screen">
>
> What is wrong
> Thanks
>
> -- 
> 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/8398ea8b-63da-40c1-90e6-fedd08594085n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/8398ea8b-63da-40c1-90e6-fedd08594085n%40googlegroups.com?utm_medium=email_source=footer>
> .
>
>

-- 
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/34b6ab11-2892-4d16-a848-ee8b09a09344n%40googlegroups.com.


static file serve nothing is load in deployment

2022-06-15 Thread luca72.b...@gmail.com
Hello i have this configuration in settings.py

STATIC_URL = '/static_files/'
STATIC_ROOT =  'D:/prova_nuovo_sito/static_files'

INSTALLED_APPS = [
'polls.apps.PollsConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]

The folder where I store the file is  'D:/prova_nuovo_sito/static_files'
in this folder I have a subfolder polls with all the needed file

The template I write as follow:
{% load static %}


What is wrong
Thanks

-- 
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/8398ea8b-63da-40c1-90e6-fedd08594085n%40googlegroups.com.


Problem when i turn debug False

2021-09-02 Thread luca72.b...@gmail.com
Hello my web site is hosted on a2hosting
 when i turn to False the image are not loaded.

My settings.py have this line:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static_files')

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, "static_media")

the file are located in:
home///myapp/static_files/polls

In the template I do as follow
 {% load static %}

https://groups.google.com/d/msgid/django-users/836ae997-cc6d-4d47-be45-fed85df79ab9n%40googlegroups.com.


Re: problem to show image

2021-02-11 Thread luca72.b...@gmail.com
Solved 
i have add


Il giorno giovedì 11 febbraio 2021 alle 15:27:51 UTC+1 
luca72.b...@gmail.com ha scritto:

> Hello
> In the setup file i have:
>
> STATIC_URL = '/static/'
> MEDIA_URL = '/media/'
>
> #STATICFILES_DIRS = [
> #os.path.join(BASE_DIR, "static"),
> #'/polls/static/polls',
> #]
>
> STATIC_ROOT = "F:/aflbmanager/mysite/polls/static"
> MEDIA_ROOT = "F:/aflbmanager/mysite/polls/media"
>
> In the template for load file that are in static file i use:
> {% load static %}
> than  for load the file :
> 
> and it works
>
> How i can load image stored in media/img
> 

-- 
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/669fe9d3-9bd8-412d-8e2b-0efa3435c5a7n%40googlegroups.com.


problem to show image

2021-02-11 Thread luca72.b...@gmail.com
Hello
In the setup file i have:

STATIC_URL = '/static/'
MEDIA_URL = '/media/'

#STATICFILES_DIRS = [
#os.path.join(BASE_DIR, "static"),
#'/polls/static/polls',
#]

STATIC_ROOT = "F:/aflbmanager/mysite/polls/static"
MEDIA_ROOT = "F:/aflbmanager/mysite/polls/media"

In the template for load file that are in static file i use:
{% load static %}
than  for load the file :

and it works

How i can load image stored in media/img
https://groups.google.com/d/msgid/django-users/3b856ad3-5c87-4297-910b-2fe85752f22en%40googlegroups.com.


Re: forloop.counter

2020-10-15 Thread luca72.b...@gmail.com
thanks i forgot it

Il giorno giovedì 15 ottobre 2020 alle 16:39:45 UTC+2 
larry.mart...@gmail.com ha scritto:

> On Thu, Oct 15, 2020 at 7:32 AM luca72.b...@gmail.com
>  wrote:
> >
> > i have this :
> > {% if forloop.counter < {{ variable }} %}
> > i have this error:
> >
> > Could not parse the remainder: '{{' from '{{'
> >
> > how i can solve it?
>
> You don't need {{ }} inside of a {% %}
>

-- 
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/92123136-638f-47c7-a49f-4ce97f34a4b9n%40googlegroups.com.


forloop.counter

2020-10-15 Thread luca72.b...@gmail.com
i have this :
 {% if forloop.counter < {{ variable }} %}
i have this error:

Could not parse the remainder: '{{' from '{{' 

how i can solve it?
Thanks 

-- 
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/58585ced-68c2-4b46-862f-36f919d13555n%40googlegroups.com.


django template forloop

2020-10-14 Thread luca72.b...@gmail.com
Hello 
I have this:
{% for x in lista_form %}
{% if forloop.counter < 100 %}
{% for fieldi in formone %}
{{ fieldi.label }} {{ fieldi }}
{% endfor %}
Immagine 
 {% endif %}  
{% if forloop.counter|divisibleby:"2" %}

{% endif %}

The second forloop is not executed, where i have to apply it?

Thanks

-- 
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/7a3e9bec-7e96-4922-ac0d-765ab49eb0d7n%40googlegroups.com.


Double for cycle in template

2020-10-14 Thread luca72.b...@gmail.com
Hello
i have this:

{% for fieldi in formone %}
{{ fieldi.label }} {{ fieldi }}

{% if forloop.counter|divisibleby:"2" %}

{% endif %}
{% endfor %}


i need to add:
{% for fieldi in formone and for or x in lista_form %}
 { % if forloop.counter < 100 %}
Immagine 
{% endif  %} 
   
{{ fieldi.label }} {{ fieldi }}

{% if forloop.counter|divisibleby:"2" %}

{% endif %}
{% endfor %}
{% endfor %}
 

{% for x in lista_form %}
{% if forloop.counter < 100 %}
Immagine 
{% endif  %} 
{% endfor %}

-- 
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/b68ff59f-a229-4a08-8b36-ba811c96e4c6n%40googlegroups.com.


request.FILES.getlist()

2020-10-07 Thread luca72.b...@gmail.com
i have a form that is like:
class tesoffcliForm(forms.Form)
image = forms.FileField(label='Image', required = False)
art_gen = forms.CharField(label='test ', required = False ,widget = 
forms.Textarea())  

the view is:

def testrendering(request):
form = tesoffcliForm()
number = range(100)
return render(request, 'polls/test.html', {'form':form, 
'range':number,  })

the template is:

{% for a in range %} 
{% for field in form %}
{{ field.label }} {{ field }}

{% if forloop.counter|divisibleby:"2" %}

{% endif %}
{% endfor %}

the view for get the data is very easy:

def get_data(request):

art = request.POST.getlist('art_gen')
image = request.FILES.getlist('image')

the list generated are:
art = a list of 100 lines, where if i have no imput in the list i find  '  '
image = a list with only the file that i have decide to upload.

how can i have also an empty folder in the image list??? for example
image = [file obg, ' ' , file obj 2, etc]
if i can't do this i have no corrispondance between art and image when i 
save in the database

Thanks for your help

-- 
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/1f83f275-ab62-4b94-b314-81eda7ac2580n%40googlegroups.com.


MultiValueDictKeyError at

2020-09-23 Thread luca72.b...@gmail.com
Hello i have this problem :
MultiValueDictKeyError at 
The view is:
matricola = request.POST['matricola']

The form is:

matricola = forms.CharField(label='Matricola',  required = False, 
max_length=100, widget = forms.TextInput(attrs={'readonly':'readonly'}))

the template is 

{{ form }}

Why i get this error? 

-- 
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/fe51409d-d219-472c-9ac6-fcaf017e268en%40googlegroups.com.