Django bugfix release: 1.11.4

2017-08-01 Thread Tim Graham
Details are available on the Django project weblog:

https://www.djangoproject.com/weblog/2017/aug/01/bugfix-release/

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5313ac11-112b-4e1d-8b6a-968649d33659%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django tutorial part 4: 'utf8' codec can't decode byte 0xa0 in position 22431

2017-08-01 Thread 'SNATCHGIRL1' via Django users
Hi everyone, 

I am a Django newbie and started the Tutorial. I followed all steps so far 
but I am stuck at the part 4. 
So far I've written 3 templates. 

*1.* file:///C:/Python27/Django/mysite/polls/templates/polls/detail.html

{{ question.question_text }}

 

{% if error_message %}{{ error_message }}{% endif %}

 



{% csrf_token %}

{% for choice in question.choice_set.all %}



{{ choice.choice_text
 }}

{% endfor %}



<

/form>


*2. *file:///C:/Python27/Django/mysite/polls/templates/polls/index.html


{% if latest_question_list %}



{% for question in latest_question_list %}

{{ 
question.question_text }}

{% endfor %}



{% else %}

No polls are available.

{% endif %}


* 3. *file:///C:/Python27/Django/mysite/polls/templates/polls/results.html


{{ question.question_text }}

 



{% for choice in question.choice_set.all %}

{{ choice.choice_text }} -- {{ choice.votes }} vote{{ 
choice.votes|pluralize }}

{% endfor %}



 

Vote again?



just like explained in the tutorial. 


When I wan to run it on the server I get the error: 



UnicodeDecodeError at /polls/1/

'utf8' codec can't decode byte 0xa0 in position 22431: invalid start byte

Request Method: GET
Request URL: http://127.0.0.1:8000/polls/1/
Django Version: 1.11.3
Exception Type: UnicodeDecodeError
Exception Value: 

'utf8' codec can't decode byte 0xa0 in position 22431: invalid start byte

Exception Location: C:\Python27\lib\codecs.py in decode, line 314
Python Executable: C:\Python27\python.exe
Python Version: 2.7.13
Python Path: 

['C:\\Python27\\Django\\mysite',
 'C:\\Windows\\system32\\python27.zip',
 'C:\\Python27\\DLLs',
 'C:\\Python27\\lib',
 'C:\\Python27\\lib\\plat-win',
 'C:\\Python27\\lib\\lib-tk',
 'C:\\Python27',
 'C:\\Python27\\lib\\site-packages']

Server time: Tue, 1 Aug 2017 16:03:11 +1000
Unicode error hint

The string that could not be encoded/decoded was: *yes'>��� https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4360a617-289d-4e4c-8f60-b7dda65e1fda%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django tutorial part 4: 'utf8' codec can't decode byte 0xa0 in position 22431

2017-08-01 Thread Jani Tiainen

Hi.

You need to make sure that file is really encoded as utf8 and contains 
valid unicode characters.


Some editors, specially in windows tend to do lot of black magic to 
display characters correctly.




On 01.08.2017 09:18, 'SNATCHGIRL1' via Django users wrote:

Hi everyone,

I am a Django newbie and started the Tutorial. I followed all steps so 
far but I am stuck at the part 4.

So far I've written 3 templates.
*
*
*1.* file:///C:/Python27/Django/mysite/polls/templates/polls/detail.html

{{ question.question_text }}

{% if error_message %}{{ error_message }}{% 
endif %}




{% csrf_token %}

{% for choice in question.choice_set.all %}

value="{{ choice.id }}" />


{{ 
choice.choice_text }}


{% endfor %}



<

/form>


*2. *file:///C:/Python27/Django/mysite/polls/templates/polls/index.html


{% if latest_question_list %}



{% for question in latest_question_list %}

{{ 
question.question_text }}


{% endfor %}



{% else %}

No polls are available.

{% endif %}


* 3. *file:///C:/Python27/Django/mysite/polls/templates/polls/results.html


{{ question.question_text }}



{% for choice in question.choice_set.all %}

{{ choice.choice_text }} -- {{ choice.votes }} vote{{ 
choice.votes|pluralize }}


{% endfor %}



Vote again?



just like explained in the tutorial.


When I wan to run it on the server I get the error:



  UnicodeDecodeError at /polls/1/

'utf8' codec can't decode byte 0xa0 in position 22431: invalid start byte
Request Method: GET
Request URL:http://127.0.0.1:8000/polls/1/
Django Version: 1.11.3
Exception Type: UnicodeDecodeError
Exception Value:
'utf8' codec can't decode byte 0xa0 in position 22431: invalid start byte
Exception Location: C:\Python27\lib\codecs.py in decode, line 314
Python Executable:  C:\Python27\python.exe
Python Version: 2.7.13
Python Path:
['C:\\Python27\\Django\\mysite',
  'C:\\Windows\\system32\\python27.zip',
  'C:\\Python27\\DLLs',
  'C:\\Python27\\lib',
  'C:\\Python27\\lib\\plat-win',
  'C:\\Python27\\lib\\lib-tk',
  'C:\\Python27',
  'C:\\Python27\\lib\\site-packages']
Server time:Tue, 1 Aug 2017 16:03:11 +1000


Unicode error hint

The string that could not be encoded/decoded was: *yes'>��� Unfortunately I don't know how to fix this. I've read many threats but 
none of them really helped me to solve this issue.


Has anyone experienced a similar problem and can 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 post to this group, send email to django-users@googlegroups.com 
.

Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4360a617-289d-4e4c-8f60-b7dda65e1fda%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
Jani Tiainen

--
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2c1ee309-7d52-476d-9cf3-81576a0e6374%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


csrf_token during registration is giving me problems

2017-08-01 Thread pieceofkayk2718
Hey,

I recently started playing with my user registration and login and logout 
stuff for an app.  It worked fine before I moved it but now that it's moved 
I keep getting the following error:


Forbidden (403) 
>
> CSRF verification failed. Request aborted.
> Help 
>
> Reason given for failure:
>
> CSRF token missing or incorrect.
> 
>
> In general, this can occur when there is a genuine Cross Site Request 
> Forgery, or when Django's CSRF mechanism 
>  has not been used 
> correctly. For POST forms, you need to ensure:
>
>- Your browser is accepting cookies.
>- The view function passes a request to the template's render 
>
> 
>  
>method.
>- In the template, there is a {% csrf_token %} template tag inside 
>each POST form that targets an internal URL.
>- If you are not using CsrfViewMiddleware, then you must use 
>csrf_protect on any views that use the csrf_token template tag, as 
>well as those that accept the POST data.
>- The form has a valid CSRF token. After logging in in another browser 
>tab or hitting the back button after a login, you may need to reload the 
>page with the form, because the token is rotated after a login.
>
> You're seeing the help section of this page because you have DEBUG = True 
> in your Django settings file. Change that to False, and only the initial 
> error message will be displayed. 
>
> You can customize this page using the CSRF_FAILURE_VIEW setting.
>


The following are my codes.  If I'm missing any useful info just let me 
know and I'll add it in.

views.py 
def register(request):
# Boolean value.  Upon successful registration, registered will be 
changed to True
registered = False

user_form = UserForm(data=request.POST or None)
profile_form = UserProfileForm(data=request.POST or None)

if user_form.is_valid() and profile_form.is_valid():
user = user_form.save()
user.set_password(user.password)
user.save()
profile = profile_form.save(commit=False)
profile.user = user
profile.save()
registered = True

return render(request, 'friends/register.html', {'user_form':user_form, 
'profile_form':profile_form, 'registered':registered})


register.html
{% extends 'hallo/base-k.html' %}
{% load staticfiles %}

{% block title_block %}
Register
{% endblock %}

{% block body_block %}



{% if registered %}


Thank you for registering!




Return to the homepage.



{% else %}


Register here!




https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cecf9272-4567-411b-8fce-c25b542e1598%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: csrf_token during registration is giving me problems

2017-08-01 Thread Dylan Reinhold
You have a quoting miss-match in your enctype, that might be messing with
the csrf_token

   I keep getting the following error:
>
>
> Forbidden (403)
>>
>> CSRF verification failed. Request aborted.
>> Help
>>
>> Reason given for failure:
>>
>> CSRF token missing or incorrect.
>>
>>
>> In general, this can occur when there is a genuine Cross Site Request
>> Forgery, or when Django's CSRF mechanism
>>  has not been used
>> correctly. For POST forms, you need to ensure:
>>
>>- Your browser is accepting cookies.
>>- The view function passes a request to the template's render
>>
>> 
>>method.
>>- In the template, there is a {% csrf_token %} template tag inside
>>each POST form that targets an internal URL.
>>- If you are not using CsrfViewMiddleware, then you must use
>>csrf_protect on any views that use the csrf_token template tag, as
>>well as those that accept the POST data.
>>- The form has a valid CSRF token. After logging in in another
>>browser tab or hitting the back button after a login, you may need to
>>reload the page with the form, because the token is rotated after a login.
>>
>> You're seeing the help section of this page because you have DEBUG = True
>> in your Django settings file. Change that to False, and only the initial
>> error message will be displayed.
>>
>> You can customize this page using the CSRF_FAILURE_VIEW setting.
>>
>
>
> The following are my codes.  If I'm missing any useful info just let me
> know and I'll add it in.
>
> views.py
> def register(request):
> # Boolean value.  Upon successful registration, registered will be
> changed to True
> registered = False
>
> user_form = UserForm(data=request.POST or None)
> profile_form = UserProfileForm(data=request.POST or None)
>
> if user_form.is_valid() and profile_form.is_valid():
> user = user_form.save()
> user.set_password(user.password)
> user.save()
> profile = profile_form.save(commit=False)
> profile.user = user
> profile.save()
> registered = True
>
> return render(request, 'friends/register.html', {'user_form':user_form
> , 'profile_form':profile_form, 'registered':registered})
>
>
> register.html
> {% extends 'hallo/base-k.html' %}
> {% load staticfiles %}
>
> {% block title_block %}
> Register
> {% endblock %}
>
> {% block body_block %}
> 
> 
>
> {% if registered %}
> 
> 
> Thank you for registering!
> 
> 
> 
> 
> Return to the homepage.
> 
> 
>
> {% else %}
> 
> 
> Register here!
> 
> 
> 
> 
>  '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',
> ]
>
>
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/cecf9272-4567-411b-8fce-c25b542e1598%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHtg44BZo_rV407Gt7-75f-T101hF8kg2tQyxjPa3hps9isOcg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: csrf_token during registration is giving me problems

2017-08-01 Thread pieceofkayk2718
fml.  Thank you.

On Tuesday, August 1, 2017 at 12:55:10 PM UTC-6, Dylan Reinhold wrote:
>
> You have a quoting miss-match in your enctype, that might be messing with 
> the csrf_token
>
>enctype='multipart/form-data">
>
> On Tue, Aug 1, 2017 at 9:57 AM, > 
> wrote:
>
>> Hey,
>>
>> I recently started playing with my user registration and login and logout 
>> stuff for an app.  It worked fine before I moved it but now that it's moved 
>> I keep getting the following error:
>>
>>
>> Forbidden (403) 
>>>
>>> CSRF verification failed. Request aborted.
>>> Help 
>>>
>>> Reason given for failure:
>>>
>>> CSRF token missing or incorrect.
>>> 
>>>
>>> In general, this can occur when there is a genuine Cross Site Request 
>>> Forgery, or when Django's CSRF mechanism 
>>>  has not been used 
>>> correctly. For POST forms, you need to ensure:
>>>
>>>- Your browser is accepting cookies.
>>>- The view function passes a request to the template's render 
>>>
>>> 
>>>  
>>>method.
>>>- In the template, there is a {% csrf_token %} template tag inside 
>>>each POST form that targets an internal URL.
>>>- If you are not using CsrfViewMiddleware, then you must use 
>>>csrf_protect on any views that use the csrf_token template tag, as 
>>>well as those that accept the POST data.
>>>- The form has a valid CSRF token. After logging in in another 
>>>browser tab or hitting the back button after a login, you may need to 
>>>reload the page with the form, because the token is rotated after a 
>>> login.
>>>
>>> You're seeing the help section of this page because you have DEBUG = 
>>> True in your Django settings file. Change that to False, and only the 
>>> initial error message will be displayed. 
>>>
>>> You can customize this page using the CSRF_FAILURE_VIEW setting.
>>>
>>
>>
>> The following are my codes.  If I'm missing any useful info just let me 
>> know and I'll add it in.
>>
>> views.py 
>> def register(request):
>> # Boolean value.  Upon successful registration, registered will be 
>> changed to True
>> registered = False
>>
>> user_form = UserForm(data=request.POST or None)
>> profile_form = UserProfileForm(data=request.POST or None)
>>
>> if user_form.is_valid() and profile_form.is_valid():
>> user = user_form.save()
>> user.set_password(user.password)
>> user.save()
>> profile = profile_form.save(commit=False)
>> profile.user = user
>> profile.save()
>> registered = True
>>
>> return render(request, 'friends/register.html', {'user_form':
>> user_form, 'profile_form':profile_form, 'registered':registered})
>>
>>
>> register.html
>> {% extends 'hallo/base-k.html' %}
>> {% load staticfiles %}
>>
>> {% block title_block %}
>> Register
>> {% endblock %}
>>
>> {% block body_block %}
>> 
>> 
>>
>> {% if registered %}
>> 
>> 
>> Thank you for registering!
>> 
>> 
>> 
>> 
>> Return to the homepage.
>> 
>> 
>>
>> {% else %}
>> 
>> 
>> Register here!
>> 
>> 
>> 
>> 
>> > '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',
>> ]
>>
>>
>>
>> -- 
>> 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 post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/cecf9272-4567-411b-8fce-c25b542e1598%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a324c1bc-4af3-478d-a290-b6cf0c4f5361%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: csrf_token during registration is giving me problems

2017-08-01 Thread pieceofkayk2718
fml.  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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a7c3f5df-ff30-4d5a-a876-f4614ded0feb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Turn off migrations completely in Django 1.7

2017-08-01 Thread Robert F.
I know this is an old topic but I completely agree with Frank.  Nothing 
gives me more headaches and makes me want to move off Django more than 
migrations.  They seldom run smoothly and cause me no end of headaches.  I 
hate them!

On Friday, November 20, 2015 at 2:26:59 PM UTC-8, Frank Malina wrote:
>
> RE: Carl Meyer
> >> To my knowledge, out of the many hundreds of 
> >> thousands of Django users, you are the first and only one to request a 
> >> way to turn off migrations entirely.
>
> No he isn't, Django migrations are ridiculous waste of time, never work 
> and make me angry.
> I work with Django from v0.96 and it never got in the way as much as it 
> does now.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0eb69425-7fa5-48ce-b8d1-b2eac4726622%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Python OSError No such file or directory but file exists

2017-08-01 Thread Ronaldo Bahia
Hi everyone, can you help me?
Thanks in advance

Thread: 
https://stackoverflow.com/questions/45449102/django-python-oserror-no-such-file-or-directory-but-file-exists

Code:



down votefavorite 


I'm converting doc and docx files to pdf in the server using unoconv with 
LibreOffice. And I need to upload to S3 the converted file.

I can convert with success the files and I can see them in the server.

But when I try to upload the pdf, I get the error. What am I missing?

Thanks in advance

This works just fine:

import subprocessfrom boto.s3.connection import S3Connection, Bucket, Key
def doc_to_pdf(user):
'''
Convert doc or docx to PDF.

parameter user: is a request.user

Usage:
doc_to_pdf(self.request.user):
'''

user_cv = CandidateCV.objects.get(user=user)
user_cv_file = str(user_cv.resume).split('/')[-1] # tem que ser PDF
user_cv_filetype = user_cv_file.split('.')[-1]

if not user_cv_filetype in settings.PDF_FILE_TYPE:
# Se não for PDF
file_in = user_cv.resume.url
file_name = file_in.split('/')[-1]
# download
urllib.request.urlretrieve(file_in, file_name)
file_out = user_cv_file.split('.')[0] + '.pdf'

# converte para PDF
env = os.environ.copy()
env['HOME'] = '/tmp'
subprocess.Popen(["unoconv","-f", "pdf", "%s" % (file_in)], env = env)

# Define a path para salvar o documento na S3
resume_path = 'resumes/%s/' % str(date.today())

# key é o nome do arquivo na S3
key = '%s%s' % (resume_path, file_out)

# deleta o arquivo localmente
subprocess.call("rm -f %s" % user_cv_file, shell=True)

# Salva o novo formato no banco
user_cv.resume = key
user_cv.save()

This is the code in which I get the error in line: 
k_out.set_contents_from_filename(s3file)

def s3upload(s3file):

# Conecta na AWS S3
conn = S3Connection(settings.AWS_ACCESS_KEY_ID, 
settings.AWS_SECRET_ACCESS_KEY)
bucket_out = Bucket(conn, settings.AWS_STORAGE_BUCKET_NAME)
k_out = Key(bucket=bucket_out, name=s3file)

# Define a path para salvar o documento na S3
resume_path = 'resumes/%s/' % str(date.today())

# key é o nome do arquivo na S3
key = '%s%s' % (resume_path, s3file)
k_out.key = key

# Salva na AWS S3
k_out.set_contents_from_filename(s3file)
k_out.make_public()

# deleta o arquivo localmente
subprocess.call("rm -f %s" % s3file, shell=True)


-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7cecdcdb-7fcf-4f4a-858a-30801fa9cf9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Create ModelForms to create ModelForms

2017-08-01 Thread Shazia Nusrat
I need to create a frontend app where I can use forms to create forms such
as Google Surveys or Survey Monkey kind of application. Can someone point
me to any reusable app or something similar or someone can guide me that
would be a great help.

Regards,

Shazia

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAD83tOzVsD004ZO%3Ddu%3DGZnpPnAScKxqm9mdks%2BjLCmhV4x1BKQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django tutorial part 4: 'utf8' codec can't decode byte 0xa0 in position 22431

2017-08-01 Thread 'SNATCHGIRL1' via Django users
Hi Jani, 

thank you for the response. It was really helpful. Instead of using word I 
edited the html files with Notepad. Now it's working :)

Am Dienstag, 1. August 2017 23:01:49 UTC+10 schrieb Jani Tiainen:
>
> Hi.
>
> You need to make sure that file is really encoded as utf8 and contains 
> valid unicode characters.
>
> Some editors, specially in windows tend to do lot of black magic to 
> display characters correctly.
>
>
> On 01.08.2017 09:18, 'SNATCHGIRL1' via Django users wrote:
>
> Hi everyone,  
>
> I am a Django newbie and started the Tutorial. I followed all steps so far 
> but I am stuck at the part 4. 
> So far I've written 3 templates. 
>
> *1.* file:///C:/Python27/Django/mysite/polls/templates/polls/detail.html
>
> {{ question.question_text }}
>
>  
>
> {% if error_message %}{{ error_message }}{% endif
>  %}
>
>  
>
> 
>
> {% csrf_token %}
>
> {% for choice in question.choice_set.all %}
>
>  value="{{ choice.id }}" />
>
> {{ choice.choice_text
>  }}
>
> {% endfor %}
>
> 
>
> <
>
> /form>
>
>
> *2. *file:///C:/Python27/Django/mysite/polls/templates/polls/index.html
>
>
> {% if latest_question_list %}
>
> 
>
> {% for question in latest_question_list %}
>
> {{ 
> question.question_text }}
>
> {% endfor %}
>
> 
>
> {% else %}
>
> No polls are available.
>
> {% endif %}
>
>
> * 3. *file:///C:/Python27/Django/mysite/polls/templates/polls/results.html
>
>
> {{ question.question_text }}
>
>  
>
> 
>
> {% for choice in question.choice_set.all %}
>
> {{ choice.choice_text }} -- {{ choice.votes }} vote{{ 
> choice.votes|pluralize }}
>
> {% endfor %}
>
> 
>
>  
>
> Vote again?
>
>
>
> just like explained in the tutorial. 
>
>
> When I wan to run it on the server I get the error: 
>
>
>
> UnicodeDecodeError at /polls/1/ 
>
> 'utf8' codec can't decode byte 0xa0 in position 22431: invalid start byte
>
> Request Method: GET 
> Request URL: http://127.0.0.1:8000/polls/1/ 
> Django Version: 1.11.3 
> Exception Type: UnicodeDecodeError 
> Exception Value: 
>
> 'utf8' codec can't decode byte 0xa0 in position 22431: invalid start byte
>
> Exception Location: C:\Python27\lib\codecs.py in decode, line 314 
> Python Executable: C:\Python27\python.exe 
> Python Version: 2.7.13 
> Python Path: 
>
> ['C:\\Python27\\Django\\mysite',
>  'C:\\Windows\\system32\\python27.zip',
>  'C:\\Python27\\DLLs',
>  'C:\\Python27\\lib',
>  'C:\\Python27\\lib\\plat-win',
>  'C:\\Python27\\lib\\lib-tk',
>  'C:\\Python27',
>  'C:\\Python27\\lib\\site-packages']
>
> Server time: Tue, 1 Aug 2017 16:03:11 +1000 
> Unicode error hint 
>
> The string that could not be encoded/decoded was: *yes'>��� 
>
> I see the same when I encode my html files with utf-8 in word. 
>
>
> Unfortunately I don't know how to fix this. I've read many threats but 
> none of them really helped me to solve this issue.
>
> Has anyone experienced a similar problem and can 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 post to this group, send email to django...@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/4360a617-289d-4e4c-8f60-b7dda65e1fda%40googlegroups.com
>  
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> -- 
> Jani Tiainen
>
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1daf722c-4eb0-4c5d-b2d9-a13512ff6ca9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django tutorial part 4: 'utf8' codec can't decode byte 0xa0 in position 22431

2017-08-01 Thread Jani Tiainen
Hi,

I really suggest you to use real editor or even IDE.

For editor I've been using VS Code.

For IDE PyCharm is pretty nice.

2.8.2017 3.53 "'SNATCHGIRL1' via Django users" <
django-users@googlegroups.com> kirjoitti:

> Hi Jani,
>
> thank you for the response. It was really helpful. Instead of using word I
> edited the html files with Notepad. Now it's working :)
>
> Am Dienstag, 1. August 2017 23:01:49 UTC+10 schrieb Jani Tiainen:
>>
>> Hi.
>>
>> You need to make sure that file is really encoded as utf8 and contains
>> valid unicode characters.
>>
>> Some editors, specially in windows tend to do lot of black magic to
>> display characters correctly.
>>
>>
>> On 01.08.2017 09:18, 'SNATCHGIRL1' via Django users wrote:
>>
>> Hi everyone,
>>
>> I am a Django newbie and started the Tutorial. I followed all steps so
>> far but I am stuck at the part 4.
>> So far I've written 3 templates.
>>
>> *1.* file:///C:/Python27/Django/mysite/polls/templates/polls/detail.html
>>
>> {{ question.question_text }}
>>
>>
>>
>> {% if error_message %}{{ error_message }}{% endif
>>  %}
>>
>>
>>
>> 
>>
>> {% csrf_token %}
>>
>> {% for choice in question.choice_set.all %}
>>
>> > value="{{ choice.id }}" />
>>
>> {{ choice.choice_text }}> label>
>>
>> {% endfor %}
>>
>> 
>>
>> <
>>
>> /form>
>>
>>
>> *2. *file:///C:/Python27/Django/mysite/polls/templates/polls/index.html
>>
>>
>> {% if latest_question_list %}
>>
>> 
>>
>> {% for question in latest_question_list %}
>>
>> {{
>> question.question_text }}
>>
>> {% endfor %}
>>
>> 
>>
>> {% else %}
>>
>> No polls are available.
>>
>> {% endif %}
>>
>>
>> * 3. *file:///C:/Python27/Django/mysite/polls/templates/polls/
>> results.html
>>
>>
>> {{ question.question_text }}
>>
>>
>>
>> 
>>
>> {% for choice in question.choice_set.all %}
>>
>> {{ choice.choice_text }} -- {{ choice.votes }} vote{{
>> choice.votes|pluralize }}
>>
>> {% endfor %}
>>
>> 
>>
>>
>>
>> Vote again?
>>
>>
>>
>> just like explained in the tutorial.
>>
>>
>> When I wan to run it on the server I get the error:
>>
>>
>>
>> UnicodeDecodeError at /polls/1/
>>
>> 'utf8' codec can't decode byte 0xa0 in position 22431: invalid start byte
>>
>> Request Method: GET
>> Request URL: http://127.0.0.1:8000/polls/1/
>> Django Version: 1.11.3
>> Exception Type: UnicodeDecodeError
>> Exception Value:
>>
>> 'utf8' codec can't decode byte 0xa0 in position 22431: invalid start byte
>>
>> Exception Location: C:\Python27\lib\codecs.py in decode, line 314
>> Python Executable: C:\Python27\python.exe
>> Python Version: 2.7.13
>> Python Path:
>>
>> ['C:\\Python27\\Django\\mysite',
>>  'C:\\Windows\\system32\\python27.zip',
>>  'C:\\Python27\\DLLs',
>>  'C:\\Python27\\lib',
>>  'C:\\Python27\\lib\\plat-win',
>>  'C:\\Python27\\lib\\lib-tk',
>>  'C:\\Python27',
>>  'C:\\Python27\\lib\\site-packages']
>>
>> Server time: Tue, 1 Aug 2017 16:03:11 +1000
>> Unicode error hint
>>
>> The string that could not be encoded/decoded was: *yes'>��� >
>>
>> I see the same when I encode my html files with utf-8 in word.
>>
>>
>> Unfortunately I don't know how to fix this. I've read many threats but
>> none of them really helped me to solve this issue.
>>
>> Has anyone experienced a similar problem and can 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 post to this group, send email to django...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/4360a617-289d-4e4c-8f60-b7dda65e1fda%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> --
>> Jani Tiainen
>>
>> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/1daf722c-4eb0-4c5d-b2d9-a13512ff6ca9%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post