Re: limiting the drop down option of a one-to-one relationship in the admin app. is that possible ?

2017-01-29 Thread Melvyn Sopacua
On Saturday 28 January 2017 21:48:03 Mike08 wrote:
> Ok that makes sense.
> 
> Now I have something like this
> 
> class modelStudentAdmin(admin.ModelAdmin):
> form = modelStudentAdminForm
> 
> #Only display students that belong to this user
> def get_queryset(self, request):
> qs = super(modelStudentAdmin, self).get_queryset(request)
> 
> if request.user.is_superuser:
> return qs
> else:
> # Get the school instance
> schoolInstance =
> modelSchool.objects.get(user=request.user) qs =
> modelStudent.objects.filter(school=schoolInstance) return qs
> 
> def get_form(self, request, obj=None, **kwargs):

This self isn't the form. It's the model admin and should return a ModelForm. 
The 
docs I linked has a complete example you can build on.
-- 
Melvyn Sopacua

-- 
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/1530490.zkR37A3afP%40devstation.
For more options, visit https://groups.google.com/d/optout.


form_invalid

2017-01-29 Thread Roberto Russi
I need get data from a form when submit is clicked even if data are 
invalid, inconplete or empty.
I try to override form_invalid in CreateView but it is never called and 
form_valid, obviously, only if data are valid.
Why form_invalid is never called? 

I have this test project with django 1.10.5 and python 3.5

models.py

class Demo(models.Model):
demo_descr = models.CharField("Description",
max_length=50, 
)
demo_code = models.CharField("Code",
max_length=5,
)

def __str__(self):
return self.demo_descr

class Meta:
verbose_name = "Test"
verbose_name_plural = "Tests"
ordering = ["demo_descr"]

views.py

class DemoForm(forms.ModelForm):
class Meta:
model = models.Demo
fields = ('demo_descr','demo_code')
   

class DemoCreateView(CreateView):
form_class = DemoForm
success_url = 'demo'
template_name = 'test_form.html'
model = models.Demo

def form_valid(self, form):
print('valid')
return CreateView.form_valid(self, form)

def form_invalid(self, form):
print('invalid')
return CreateView.form_invalid(self, form)

urls.py

url(r'^demo$', views.DemoCreateView.as_view(),  name='demo'),


test_form.html


{% csrf_token %}
{{ form.as_p }}



-- 
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/c4ab5b85-13cc-4569-aa0d-5ef4dd6911a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Wiring django-channels to html without javascript?

2017-01-29 Thread Nikoleta Misheva
I used the console to test my app but now I want to wire my django-channels 
app to the html but I don't know any JS so is it possible to wire 
django-channels to html without using javascript? If it is possible how? 
Here  you 
can check my consumers.py and html template. I know less than 5% JS so any 
help would be appreciated :)

-- 
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/2ce32eb5-e117-48f1-9fa8-eb4d050ea142%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Wiring django-channels to html without javascript?

2017-01-29 Thread Avraham Serour
Yes, the client application connecting to the websocket server can be an
user using an interactive console, a python application or any other
software in any language.

But if your objective is to have a webpage then no, unfortunately web
browsers can only run javascript, if you really dislike javascript you may
even use some other language that can transpile to js such as coffescript
or typescript, but at the end the browser will still run javascript.

I still dream of the day that we will be able to run python on the browser

On Sun, Jan 29, 2017 at 5:51 PM, Nikoleta Misheva 
wrote:

> I used the console to test my app but now I want to wire my
> django-channels app to the html but I don't know any JS so is it possible
> to wire django-channels to html without using javascript? If it is possible
> how? Here
>  you
> can check my consumers.py and html template. I know less than 5% JS so any
> help would be appreciated :)
>
> --
> 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/2ce32eb5-e117-48f1-9fa8-eb4d050ea142%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/CAFWa6tKpGLe5Q0iPq%3D1_9n23%3Dmgh-Y7tTx_EJ--pwhfTzYWybg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: form_invalid

2017-01-29 Thread Norberto Bensa
https://ccbv.co.uk is your friend with class based views.

I'd override post(self, request, *args, **kwargs), in request.POST, you'll
have your form's data (before it's validated).

HTH,
Norberto

2017-01-29 9:10 GMT-03:00 Roberto Russi :

> I need get data from a form when submit is clicked even if data are
> invalid, inconplete or empty.
> I try to override form_invalid in CreateView but it is never called and
> form_valid, obviously, only if data are valid.
> Why form_invalid is never called?
>
> I have this test project with django 1.10.5 and python 3.5
>
> models.py
>
> class Demo(models.Model):
> demo_descr = models.CharField("Description",
> max_length=50,
> )
> demo_code = models.CharField("Code",
> max_length=5,
> )
>
> def __str__(self):
> return self.demo_descr
>
> class Meta:
> verbose_name = "Test"
> verbose_name_plural = "Tests"
> ordering = ["demo_descr"]
>
> views.py
>
> class DemoForm(forms.ModelForm):
> class Meta:
> model = models.Demo
> fields = ('demo_descr','demo_code')
>
>
> class DemoCreateView(CreateView):
> form_class = DemoForm
> success_url = 'demo'
> template_name = 'test_form.html'
> model = models.Demo
>
> def form_valid(self, form):
> print('valid')
> return CreateView.form_valid(self, form)
>
> def form_invalid(self, form):
> print('invalid')
> return CreateView.form_invalid(self, form)
>
> urls.py
>
> url(r'^demo$', views.DemoCreateView.as_view(),  name='demo'),
>
>
> test_form.html
>
> 
> {% csrf_token %}
> {{ form.as_p }}
> 
> 
>
> --
> 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/c4ab5b85-13cc-4569-aa0d-5ef4dd6911a4%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/CADut3oCq-9aZ%2B_VeV9%3D1B97ZYDopCtcBYg4CN38h3aKp_b%3DCpA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Debug Toolbar installation

2017-01-29 Thread Richard Jackson
Hi Vijay - that's going to be the problem; I've installed it locally but 
haven't installed it on my (Webfaction-provided) server.

Thanks,

Rich

On Saturday, January 28, 2017 at 4:58:56 PM UTC, Vijay Khemlani wrote:
>
> Did you install debug_toolber on your server? 
>
> pip install django-debug-toolbar 
>
> On 1/28/17, Richard Jackson > wrote: 
> > Hi everyone, 
> > 
> > I've recently installed the Django Debug Toolbar for local use; I've 
> just 
> > pushed the code online and am greeted with the below error: 
> > 
> > [81.95.157.172] out: Traceback (most recent call last): 
> > [81.95.157.172] out:   File "", line 1, in  
> > [81.95.157.172] out:   File 
> > 
> "/home/rjackson87/.virtualenvs/richardjackson/lib/python2.7/site-packages/django/__init__.py",
>  
>
> > 
> > line 18, in setup 
> > [81.95.157.172] out: apps.populate(settings.INSTALLED_APPS) 
> > [81.95.157.172] out:   File 
> > 
> "/home/rjackson87/.virtualenvs/richardjackson/lib/python2.7/site-packages/django/apps/registry.py",
>  
>
> > 
> > line 85, in populate 
> > [81.95.157.172] out: app_config = AppConfig.create(entry) 
> > [81.95.157.172] out:   File 
> > 
> "/home/rjackson87/.virtualenvs/richardjackson/lib/python2.7/site-packages/django/apps/config.py",
>  
>
> > 
> > line 86, in create 
> > [81.95.157.172] out: module = import_module(entry) 
> > [81.95.157.172] out:   File 
> > "/usr/local/lib/python2.7/importlib/__init__.py", line 37, in 
> import_module 
> > [81.95.157.172] out: __import__(name) 
> > [81.95.157.172] out: ImportError: No module named debug_toolbar 
> > [81.95.157.172] out: 
> > 
> > Fatal error: run() received nonzero return code 1 while executing! 
> > 
> > Requested: python -c "import 
> > os;os.environ['DJANGO_SETTINGS_MODULE']='richardjackson.settings';import 
> > django;django.setup();from django.conf import 
> > settings;print(settings.STATIC_ROOT)" 
> > Executed: /bin/bash -l -c "cd /home/rjackson87/webapps/richardjackson 
> >>/dev/null && source 
> > /home/rjackson87/.virtualenvs/richardjackson/bin/activate && python -c 
> > \"import 
> > os;os.environ['DJANGO_SETTINGS_MODULE']='richardjackson.settings';import 
> > django;django.setup();from django.conf import 
> > settings;print(settings.STATIC_ROOT)\"" 
> > 
> > What should I do to resolve this? 
> > 
> > Cheers, 
> > 
> > Rich 
> > 
> > -- 
> > 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/d3657e15-1375-481c-ba6d-f3a97ed0dca5%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/53484dc1-d4cb-4964-9b49-e27c021301ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: form_invalid

2017-01-29 Thread Roberto Russi
I have tried it but post method is called only if form is valid and not if 
there are mandatory field not filled. 


Il giorno domenica 29 gennaio 2017 18:30:50 UTC+1, Norberto Bensa ha 
scritto:
>
> https://ccbv.co.uk is your friend with class based views.
>
> I'd override post(self, request, *args, **kwargs), in request.POST, you'll 
> have your form's data (before it's validated). 
>
> HTH,
> Norberto
>
> 2017-01-29 9:10 GMT-03:00 Roberto Russi 
> >:
>
>> I need get data from a form when submit is clicked even if data are 
>> invalid, inconplete or empty.
>> I try to override form_invalid in CreateView but it is never called and 
>> form_valid, obviously, only if data are valid.
>> Why form_invalid is never called? 
>>
>> I have this test project with django 1.10.5 and python 3.5
>>
>> models.py
>>
>> class Demo(models.Model):
>> demo_descr = models.CharField("Description",
>> max_length=50, 
>> )
>> demo_code = models.CharField("Code",
>> max_length=5,
>> )
>>
>> def __str__(self):
>> return self.demo_descr
>> 
>> class Meta:
>> verbose_name = "Test"
>> verbose_name_plural = "Tests"
>> ordering = ["demo_descr"]
>>
>> views.py
>>
>> class DemoForm(forms.ModelForm):
>> class Meta:
>> model = models.Demo
>> fields = ('demo_descr','demo_code')
>>
>>
>> class DemoCreateView(CreateView):
>> form_class = DemoForm
>> success_url = 'demo'
>> template_name = 'test_form.html'
>> model = models.Demo
>>
>> def form_valid(self, form):
>> print('valid')
>> return CreateView.form_valid(self, form)
>>
>> def form_invalid(self, form):
>> print('invalid')
>> return CreateView.form_invalid(self, form)
>>
>> urls.py
>>
>> url(r'^demo$', views.DemoCreateView.as_view(),  name='demo'),
>>
>>
>> test_form.html
>>
>> 
>> {% csrf_token %}
>> {{ form.as_p }}
>> 
>> 
>>
>> -- 
>> 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/c4ab5b85-13cc-4569-aa0d-5ef4dd6911a4%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/1262e431-5210-4707-bea6-0e8d8813c33b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: form_invalid

2017-01-29 Thread Norberto Bensa
Are you telling me the following doesn't work for you?

class DemoCreateView(CreateView):
...
def post(self, request, *args, **kwargs):
   print(request.POST)
   return super().post(request, *args, **kwargs)
...


Now, at the console:




...

BTW, I had to add "blank=True, null=True" to your models, otherwise
the fields are marked as required and the browser does validate that.

HTH,
Norberto


2017-01-29 15:54 GMT-03:00 Roberto Russi :
>
> I have tried it but post method is called only if form is valid and not if 
> there are mandatory field not filled.
>
>
> Il giorno domenica 29 gennaio 2017 18:30:50 UTC+1, Norberto Bensa ha scritto:
>>
>> https://ccbv.co.uk is your friend with class based views.
>>
>> I'd override post(self, request, *args, **kwargs), in request.POST, you'll 
>> have your form's data (before it's validated).
>>
>> HTH,
>> Norberto
>>
>> 2017-01-29 9:10 GMT-03:00 Roberto Russi :
>>>
>>> I need get data from a form when submit is clicked even if data are 
>>> invalid, inconplete or empty.
>>> I try to override form_invalid in CreateView but it is never called and 
>>> form_valid, obviously, only if data are valid.
>>> Why form_invalid is never called?
>>>
>>> I have this test project with django 1.10.5 and python 3.5
>>>
>>> models.py
>>>
>>> class Demo(models.Model):
>>> demo_descr = models.CharField("Description",
>>> max_length=50,
>>> )
>>> demo_code = models.CharField("Code",
>>> max_length=5,
>>> )
>>>
>>> def __str__(self):
>>> return self.demo_descr
>>>
>>> class Meta:
>>> verbose_name = "Test"
>>> verbose_name_plural = "Tests"
>>> ordering = ["demo_descr"]
>>>
>>> views.py
>>>
>>> class DemoForm(forms.ModelForm):
>>> class Meta:
>>> model = models.Demo
>>> fields = ('demo_descr','demo_code')
>>>
>>>
>>> class DemoCreateView(CreateView):
>>> form_class = DemoForm
>>> success_url = 'demo'
>>> template_name = 'test_form.html'
>>> model = models.Demo
>>>
>>> def form_valid(self, form):
>>> print('valid')
>>> return CreateView.form_valid(self, form)
>>>
>>> def form_invalid(self, form):
>>> print('invalid')
>>> return CreateView.form_invalid(self, form)
>>>
>>> urls.py
>>>
>>> url(r'^demo$', views.DemoCreateView.as_view(),  name='demo'),
>>>
>>>
>>> test_form.html
>>>
>>> 
>>> {% csrf_token %}
>>> {{ form.as_p }}
>>> 
>>> 
>>>
>>> --
>>> 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/c4ab5b85-13cc-4569-aa0d-5ef4dd6911a4%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/1262e431-5210-4707-bea6-0e8d8813c33b%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/CADut3oAUzueTVWnYZUqjgaYp3CU%3DAnJZsNSawfZfx_U0-9BgwQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


set_cookie raise exception when the value contains Unicode charset

2017-01-29 Thread Xx Johnsua
Hello everyone,

Following is my code:

def post(self, request, *args, **kwargs):
self.object = self.get_object()
form = forms.CommentForm(request.POST or None)
if form.is_valid():
response = self.form_valid(form)
return self._set_cookies(response, form)
...

@transaction.atomic
def form_valid(self, form):
self.object = form.save(commit=False)
self.object.ip = get_remote_addr(self.request)
self.object.save()
return HttpResponseRedirect(self.get_success_url())


def _set_cookies(self, response, form):
year = 365 * 24 * 60 * 60
response.set_cookie('nickname', form.cleaned_data['nickname'], max_age=year)
response.set_cookie('url', form.cleaned_data['url'], max_age=year)
response.set_cookie('email', form.cleaned_data['email'], max_age=year)
return response


But if the form.cleaned_data['nickname'] contains Chinese, an exception is 
raised:


Traceback (most recent call last):
  File 
"/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/wsgiref/handlers.py",
 line 138, in run
self.finish_response()
  File 
"/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/wsgiref/handlers.py",
 line 180, in finish_response
self.write(data)
  File 
"/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/wsgiref/handlers.py",
 line 274, in write
self.send_headers()
  File 
"/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/wsgiref/handlers.py",
 line 333, in send_headers
self._write(bytes(self.headers))
  File 
"/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/wsgiref/headers.py",
 line 142, in __bytes__
return str(self).encode('iso-8859-1')
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 
227-228: ordinal not in range(256)

So how to save the unicode data into cookie? I have to urlencode it manually?


-- 
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/4a5ca63a-e947-4c5a-80eb-bab026b6445a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: form_invalid

2017-01-29 Thread Roberto Russi
But fields are required! I need to have a control over form also if 'save' 
button is clicked and required fields are not filled.

Il giorno domenica 29 gennaio 2017 20:26:10 UTC+1, Norberto Bensa ha 
scritto:
>
> Are you telling me the following doesn't work for you? 
>
> class DemoCreateView(CreateView): 
> ... 
> def post(self, request, *args, **kwargs): 
>print(request.POST) 
>return super().post(request, *args, **kwargs) 
> ... 
>
>
> Now, at the console: 
>
>
>  ['A3hHKM6Bs6NjJA996ALAsYPcYR7M3NWkzP4wcd6WUX1CEazC1dAK3aD1n8zl1aUU'], 
> 'demo_desc 
> r': [''], 'demo_code': ['']}> 
>
> ... 
>
> BTW, I had to add "blank=True, null=True" to your models, otherwise 
> the fields are marked as required and the browser does validate that. 
>
> HTH, 
> Norberto 
>
>
> 2017-01-29 15:54 GMT-03:00 Roberto Russi  >: 
> > 
> > I have tried it but post method is called only if form is valid and not 
> if there are mandatory field not filled. 
> > 
> > 
> > Il giorno domenica 29 gennaio 2017 18:30:50 UTC+1, Norberto Bensa ha 
> scritto: 
> >> 
> >> https://ccbv.co.uk is your friend with class based views. 
> >> 
> >> I'd override post(self, request, *args, **kwargs), in request.POST, 
> you'll have your form's data (before it's validated). 
> >> 
> >> HTH, 
> >> Norberto 
> >> 
> >> 2017-01-29 9:10 GMT-03:00 Roberto Russi : 
> >>> 
> >>> I need get data from a form when submit is clicked even if data are 
> invalid, inconplete or empty. 
> >>> I try to override form_invalid in CreateView but it is never called 
> and form_valid, obviously, only if data are valid. 
> >>> Why form_invalid is never called? 
> >>> 
> >>> I have this test project with django 1.10.5 and python 3.5 
> >>> 
> >>> models.py 
> >>> 
> >>> class Demo(models.Model): 
> >>> demo_descr = models.CharField("Description", 
> >>> max_length=50, 
> >>> ) 
> >>> demo_code = models.CharField("Code", 
> >>> max_length=5, 
> >>> ) 
> >>> 
> >>> def __str__(self): 
> >>> return self.demo_descr 
> >>> 
> >>> class Meta: 
> >>> verbose_name = "Test" 
> >>> verbose_name_plural = "Tests" 
> >>> ordering = ["demo_descr"] 
> >>> 
> >>> views.py 
> >>> 
> >>> class DemoForm(forms.ModelForm): 
> >>> class Meta: 
> >>> model = models.Demo 
> >>> fields = ('demo_descr','demo_code') 
> >>> 
> >>> 
> >>> class DemoCreateView(CreateView): 
> >>> form_class = DemoForm 
> >>> success_url = 'demo' 
> >>> template_name = 'test_form.html' 
> >>> model = models.Demo 
> >>> 
> >>> def form_valid(self, form): 
> >>> print('valid') 
> >>> return CreateView.form_valid(self, form) 
> >>> 
> >>> def form_invalid(self, form): 
> >>> print('invalid') 
> >>> return CreateView.form_invalid(self, form) 
> >>> 
> >>> urls.py 
> >>> 
> >>> url(r'^demo$', views.DemoCreateView.as_view(),  name='demo'), 
> >>> 
> >>> 
> >>> test_form.html 
> >>> 
> >>>  
> >>> {% csrf_token %} 
> >>> {{ form.as_p }} 
> >>>  
> >>>  
> >>> 
> >>> -- 
> >>> 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/c4ab5b85-13cc-4569-aa0d-5ef4dd6911a4%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...@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/1262e431-5210-4707-bea6-0e8d8813c33b%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/59d268d9-269e-4875-a405-bc9c7985e506%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: form_invalid

2017-01-29 Thread Melvyn Sopacua
On Sunday 29 January 2017 04:10:20 Roberto Russi wrote:
> I need get data from a form when submit is clicked even if data are
> invalid, inconplete or empty.
> I try to override form_invalid in CreateView but it is never called
> and form_valid, obviously, only if data are valid.
> Why form_invalid is never called?

Because the form is blocked by client-side validation: it never gets to the 
server. If you 
watch the development console closely, you will see that when you press save, 
there 
is no incoming request.

Add the following clean method to DemoForm, fill in "bla" for demo_code in the 
form 
and you will see form_invalid being called.

*def clean(*self*):if *self.data[*'demo_code'*] *!= 'valid':raise 
*ValidationError*('{}: Invalid demo code'*.format*(
*self.data[*'demo_code'*]
*))


*
-- 
Melvyn Sopacua

-- 
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/27521978.ZcxQx4Jsyq%40devstation.
For more options, visit https://groups.google.com/d/optout.


Re: Django Debug Toolbar installation

2017-01-29 Thread Melvyn Sopacua
On Sunday 29 January 2017 09:48:31 Richard Jackson wrote:
> Hi Vijay - that's going to be the problem; I've installed it locally
> but haven't installed it on my (Webfaction-provided) server.

So don't add it to installed apps. One common pattern is to only enable debug 
tools when settings.DEBUG is True.

So in settings.py make sure INSTALLED_APPS is a list (not a tuple), remove 
debug_toolbar and add this code:

if DEBUG:
INSTALLED_APPS.append('debug_toolbar')

Done.

Now, all you have to do is not enable DEBUG on the server. Of course, that's 
the 
same problem since you're pushing settings.py to the server. And for that, see 
how 
Mezzanine solved it using a local_settings.py that is not pushed to the server.
-- 
Melvyn Sopacua

-- 
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/5185069.uTKruVASae%40devstation.
For more options, visit https://groups.google.com/d/optout.


Re: set_cookie raise exception when the value contains Unicode charset

2017-01-29 Thread Melvyn Sopacua
On Sunday 29 January 2017 13:03:34 Xx Johnsua wrote:


>   File
> 
"/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versi
o
> ns/3.5/lib/python3.5/wsgiref/headers.py", line 142, in __bytes__
> return str(self).encode('iso-8859-1')

https://docs.djangoproject.com/en/1.10/ref/settings/#default-charset

I believe your default charset is set to 'iso-8859-1'.
-- 
Melvyn Sopacua

-- 
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/4253246.14c2IRoxpm%40devstation.
For more options, visit https://groups.google.com/d/optout.


Re: Issue with Tutorial pt 5 "Fixing the bug"

2017-01-29 Thread Melvyn Sopacua
On Tuesday 24 January 2017 11:14:58 Tim Graham wrote:
> Correct, you shouldn't declare class QuestionAdmin(...) twice. What
> problem do you see if you combine those classes? It's unlikely
> related to your Python version.
> 
> On Tuesday, January 24, 2017 at 10:45:50 AM UTC-5, John Wall wrote:
> > I'm guessing you mean that I have to class calls for QuestionAdmin?

Note that Tim calls it "declare" and you call it "calls". Not being pedantic, 
but it's the 
key to understanding your mistake: You can only declare something once in the 
same 
scope. You can call it as many times as you want.

The scope is also important:

class Awesome(models.Model):
name = models.CharField(max_length=200)

def awesome_factory(unique=False):
class Awesome(models.Model):
name = models.CharField(max_length=200, unique=unique)
class Meta:
abstract = True
return Awesome

class TheBomb(awesome_factory(unique=True)):
pass

class Magnificent(awesome_factory()):
pass

As you see, I declared two Awesome classes, but the second is in the scope of 
the 
awesome_factory function - so this works.

The result is that in the outer scope Awesome and Magnificent are identical 
models 
with a different name and that TheBomb has a name field that enforces 
uniqueness.

Hope this sheds some light on things :)
-- 
Melvyn Sopacua

-- 
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/2242474.KXECURW2MG%40devstation.
For more options, visit https://groups.google.com/d/optout.


Re: form_invalid

2017-01-29 Thread Norberto Bensa
Then you need to make your model fields not required and override your
form.clean() methods, then you'll have complete control over the
validation process.

I see Melvyn already aswered.



2017-01-29 18:04 GMT-03:00 Roberto Russi :
> But fields are required! I need to have a control over form also if 'save'
> button is clicked and required fields are not filled.
>
> Il giorno domenica 29 gennaio 2017 20:26:10 UTC+1, Norberto Bensa ha
> scritto:
>>
>> Are you telling me the following doesn't work for you?
>>
>> class DemoCreateView(CreateView):
>> ...
>> def post(self, request, *args, **kwargs):
>>print(request.POST)
>>return super().post(request, *args, **kwargs)
>> ...
>>
>>
>> Now, at the console:
>>
>>
>> > ['A3hHKM6Bs6NjJA996ALAsYPcYR7M3NWkzP4wcd6WUX1CEazC1dAK3aD1n8zl1aUU'],
>> 'demo_desc
>> r': [''], 'demo_code': ['']}>
>>
>> ...
>>
>> BTW, I had to add "blank=True, null=True" to your models, otherwise
>> the fields are marked as required and the browser does validate that.
>>
>> HTH,
>> Norberto
>>
>>
>> 2017-01-29 15:54 GMT-03:00 Roberto Russi :
>> >
>> > I have tried it but post method is called only if form is valid and not
>> > if there are mandatory field not filled.
>> >
>> >
>> > Il giorno domenica 29 gennaio 2017 18:30:50 UTC+1, Norberto Bensa ha
>> > scritto:
>> >>
>> >> https://ccbv.co.uk is your friend with class based views.
>> >>
>> >> I'd override post(self, request, *args, **kwargs), in request.POST,
>> >> you'll have your form's data (before it's validated).
>> >>
>> >> HTH,
>> >> Norberto
>> >>
>> >> 2017-01-29 9:10 GMT-03:00 Roberto Russi :
>> >>>
>> >>> I need get data from a form when submit is clicked even if data are
>> >>> invalid, inconplete or empty.
>> >>> I try to override form_invalid in CreateView but it is never called
>> >>> and form_valid, obviously, only if data are valid.
>> >>> Why form_invalid is never called?
>> >>>
>> >>> I have this test project with django 1.10.5 and python 3.5
>> >>>
>> >>> models.py
>> >>>
>> >>> class Demo(models.Model):
>> >>> demo_descr = models.CharField("Description",
>> >>> max_length=50,
>> >>> )
>> >>> demo_code = models.CharField("Code",
>> >>> max_length=5,
>> >>> )
>> >>>
>> >>> def __str__(self):
>> >>> return self.demo_descr
>> >>>
>> >>> class Meta:
>> >>> verbose_name = "Test"
>> >>> verbose_name_plural = "Tests"
>> >>> ordering = ["demo_descr"]
>> >>>
>> >>> views.py
>> >>>
>> >>> class DemoForm(forms.ModelForm):
>> >>> class Meta:
>> >>> model = models.Demo
>> >>> fields = ('demo_descr','demo_code')
>> >>>
>> >>>
>> >>> class DemoCreateView(CreateView):
>> >>> form_class = DemoForm
>> >>> success_url = 'demo'
>> >>> template_name = 'test_form.html'
>> >>> model = models.Demo
>> >>>
>> >>> def form_valid(self, form):
>> >>> print('valid')
>> >>> return CreateView.form_valid(self, form)
>> >>>
>> >>> def form_invalid(self, form):
>> >>> print('invalid')
>> >>> return CreateView.form_invalid(self, form)
>> >>>
>> >>> urls.py
>> >>>
>> >>> url(r'^demo$', views.DemoCreateView.as_view(),  name='demo'),
>> >>>
>> >>>
>> >>> test_form.html
>> >>>
>> >>> 
>> >>> {% csrf_token %}
>> >>> {{ form.as_p }}
>> >>> 
>> >>> 
>> >>>
>> >>> --
>> >>> 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/c4ab5b85-13cc-4569-aa0d-5ef4dd6911a4%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...@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/1262e431-5210-4707-bea6-0e8d8813c33b%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-user

Re: form_invalid

2017-01-29 Thread Norberto Bensa
BTW, IIRC, you can also make your model fields required (for db
consistency) but then you need to use django.forms.Form instead of
django.forms.ModelForm.



2017-01-30 0:08 GMT-03:00 Norberto Bensa :
> Then you need to make your model fields not required and override your
> form.clean() methods, then you'll have complete control over the
> validation process.
>
> I see Melvyn already aswered.
>
>
>
> 2017-01-29 18:04 GMT-03:00 Roberto Russi :
>> But fields are required! I need to have a control over form also if 'save'
>> button is clicked and required fields are not filled.
>>
>> Il giorno domenica 29 gennaio 2017 20:26:10 UTC+1, Norberto Bensa ha
>> scritto:
>>>
>>> Are you telling me the following doesn't work for you?
>>>
>>> class DemoCreateView(CreateView):
>>> ...
>>> def post(self, request, *args, **kwargs):
>>>print(request.POST)
>>>return super().post(request, *args, **kwargs)
>>> ...
>>>
>>>
>>> Now, at the console:
>>>
>>>
>>> >> ['A3hHKM6Bs6NjJA996ALAsYPcYR7M3NWkzP4wcd6WUX1CEazC1dAK3aD1n8zl1aUU'],
>>> 'demo_desc
>>> r': [''], 'demo_code': ['']}>
>>>
>>> ...
>>>
>>> BTW, I had to add "blank=True, null=True" to your models, otherwise
>>> the fields are marked as required and the browser does validate that.
>>>
>>> HTH,
>>> Norberto
>>>
>>>
>>> 2017-01-29 15:54 GMT-03:00 Roberto Russi :
>>> >
>>> > I have tried it but post method is called only if form is valid and not
>>> > if there are mandatory field not filled.
>>> >
>>> >
>>> > Il giorno domenica 29 gennaio 2017 18:30:50 UTC+1, Norberto Bensa ha
>>> > scritto:
>>> >>
>>> >> https://ccbv.co.uk is your friend with class based views.
>>> >>
>>> >> I'd override post(self, request, *args, **kwargs), in request.POST,
>>> >> you'll have your form's data (before it's validated).
>>> >>
>>> >> HTH,
>>> >> Norberto
>>> >>
>>> >> 2017-01-29 9:10 GMT-03:00 Roberto Russi :
>>> >>>
>>> >>> I need get data from a form when submit is clicked even if data are
>>> >>> invalid, inconplete or empty.
>>> >>> I try to override form_invalid in CreateView but it is never called
>>> >>> and form_valid, obviously, only if data are valid.
>>> >>> Why form_invalid is never called?
>>> >>>
>>> >>> I have this test project with django 1.10.5 and python 3.5
>>> >>>
>>> >>> models.py
>>> >>>
>>> >>> class Demo(models.Model):
>>> >>> demo_descr = models.CharField("Description",
>>> >>> max_length=50,
>>> >>> )
>>> >>> demo_code = models.CharField("Code",
>>> >>> max_length=5,
>>> >>> )
>>> >>>
>>> >>> def __str__(self):
>>> >>> return self.demo_descr
>>> >>>
>>> >>> class Meta:
>>> >>> verbose_name = "Test"
>>> >>> verbose_name_plural = "Tests"
>>> >>> ordering = ["demo_descr"]
>>> >>>
>>> >>> views.py
>>> >>>
>>> >>> class DemoForm(forms.ModelForm):
>>> >>> class Meta:
>>> >>> model = models.Demo
>>> >>> fields = ('demo_descr','demo_code')
>>> >>>
>>> >>>
>>> >>> class DemoCreateView(CreateView):
>>> >>> form_class = DemoForm
>>> >>> success_url = 'demo'
>>> >>> template_name = 'test_form.html'
>>> >>> model = models.Demo
>>> >>>
>>> >>> def form_valid(self, form):
>>> >>> print('valid')
>>> >>> return CreateView.form_valid(self, form)
>>> >>>
>>> >>> def form_invalid(self, form):
>>> >>> print('invalid')
>>> >>> return CreateView.form_invalid(self, form)
>>> >>>
>>> >>> urls.py
>>> >>>
>>> >>> url(r'^demo$', views.DemoCreateView.as_view(),  name='demo'),
>>> >>>
>>> >>>
>>> >>> test_form.html
>>> >>>
>>> >>> 
>>> >>> {% csrf_token %}
>>> >>> {{ form.as_p }}
>>> >>> 
>>> >>> 
>>> >>>
>>> >>> --
>>> >>> 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/c4ab5b85-13cc-4569-aa0d-5ef4dd6911a4%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...@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/1262e431-5210-4707-bea6-0e8d8813c33b%40googlegroups.com.
>>> >
>>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You recei

Installing Django

2017-01-29 Thread Danny Jr Chu
Guys, please help. I am new with Python and Django, I mean I don't have any 
clue what's going on (don't even know how to encode), but I wish I could 
build a website out of my imaginary. I know this will goes miles and 
miles... I am trying to install Django but couple of errors occur : 

PS C:\Users\Luv> easy_install django
Searching for django
Reading https://pypi.python.org/simple/django/
Downloading 
https://pypi.python.org/packages/c3/c2/6096bf5d0caa4e3d5b985ac72e3a0c795e37fa7407d6c85460b2a105b467/Django-1
.10.5.tar.gz#md5=3fce02f1e6461fec21f1f15ea7489924
Best match: Django 1.10.5
Processing Django-1.10.5.tar.gz
Writing 
C:\Users\Luv\AppData\Local\Temp\easy_install-5dcbu64l\Django-1.10.5\setup.cfg
Running Django-1.10.5\setup.py -q bdist_egg --dist-dir 
C:\Users\Luv\AppData\Local\Temp\easy_install-5dcbu64l\Django-1.10
.5\egg-dist-tmp-k4dzxio3
no previously-included directories found matching 'django\contrib\admin\bin'
warning: no previously-included files matching '__pycache__' found anywhere 
in distribution
creating c:\program files (x86)\lib\site-packages\django-1.10.5-py3.6.egg
Extracting django-1.10.5-py3.6.egg to c:\program files 
(x86)\lib\site-packages
Adding django 1.10.5 to easy-install.pth file
Installing django-admin.py script to c:\program files (x86)\Scripts
error: [Errno 13] Permission denied: 'c:\\program files 
(x86)\\Scripts\\django-admin.py'

-- 
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/86091d59-6578-4e85-9be0-d24beb1f5b84%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: set_cookie raise exception when the value contains Unicode charset

2017-01-29 Thread Xx Johnsua
But I never change the DEFAULT_CHARSET , this is my diffsettings:

$ ./manage.py diffsettings
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'}]
AUTH_USER_MODEL = 'ucenter.User'
BASE_DIR = '/Users/shiyu/pro/python/talkbook'  ###
DATABASES = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'PORT': 
'', 'NAME': '/Users/shiyu/pro/python/talkbook/db.sqlite3', 'TEST': 
{'COLLATION': None, 'NAME': None, 'CHARSET': None, 'MIRROR': None}, 
'PASSWORD': '', 'AUTOCOMMIT': True, 'TIME_ZONE': None, 'CONN_MAX_AGE': 0, 
'USER': '', 'ATOMIC_REQUESTS': False, 'OPTIONS': {}, 'HOST': ''}}
DEBUG = True
DEFAULT_FROM_EMAIL = None
EMAIL_HOST = None
EMAIL_HOST_PASSWORD = None
EMAIL_HOST_USER = None
EMAIL_PORT = None
EMAIL_USE_SSL = None
EMAIL_USE_TLS = None
INSTALLED_APPS = ['django.contrib.admin', 'django.contrib.auth', 
'django.contrib.contenttypes', 'django.contrib.sessions', 
'django.contrib.messages', 'django.contrib.staticfiles', 'django_select2', 
'django_markup', 'bootstrap3', 'pure_pagination', 'django_gravatar', 
'mptt', 'captcha', 'app.ucenter', 'app.front', 'app.manager']
IP_HEADER = None  ###
LANGUAGE_CODE = 'zh-hans'
LOGGING = {'version': 1, 'formatters': {'standard': {'format': 
'[%(asctime)s] - [%(levelname)s] - [%(name)s:%(lineno)d]  - %(message)s', 
'datefmt': '%Y-%m-%d %H:%M:%S'}}, 'handlers': {'console': {'class': 
'logging.StreamHandler', 'level': 'DEBUG'}, 'file': {'filename': 
'/Users/shiyu/pro/python/talkbook/error.log', 'class': 
'logging.FileHandler', 'level': 'WARNING'}}, 'disable_existing_loggers': 
False, 'loggers': {'': {'handlers': ['console'], 'level': 'WARNING'}, 
'talkbook': {'propagate': True, 'handlers': ['console'], 'level': 'DEBUG'}, 
'django': {'handlers': ['file'], 'level': 'WARNING'}}}
LOGIN_REDIRECT_URL = 'manager:index'
LOGIN_URL = 'manager:login'
MARKUP_SETTINGS = {'markdown': {'safe_mode': 'escape', 'extension_configs': 
{'toc': {'anchorlink': True}}, 'extensions': ('extra', 'nl2br', 
'codehilite', 'toc', 'linkify')}}  ###
MEDIA_ROOT = '/Users/shiyu/pro/python/talkbook/media'
MEDIA_URL = '/media/'
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']
OPTION_INI_PATH = '/Users/shiyu/pro/python/talkbook/conf/option.ini'  ###
PAGINATION_SETTINGS = {'SHOW_FIRST_PAGE_WHEN_INVALID': True, 
'PAGE_RANGE_DISPLAYED': 5, 'MARGIN_PAGES_DISPLAYED': 2}  ###
ROOT_URLCONF = 'conf.urls'  ###
SECRET_KEY = '.'
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
SETTINGS_MODULE = 'conf.settings'  ###
STATIC_URL = '/static/'
TEMPLATES = [{'BACKEND': 'django.template.backends.django.DjangoTemplates', 
'DIRS': ['/Users/shiyu/pro/python/talkbook/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', 
'talkbook.context.global_site_context']}}]
TIME_ZONE = 'Asia/Shanghai'
USE_L10N = True
USE_TZ = True
WSGI_APPLICATION = 'talkbook.wsgi.application'


在 2017年1月30日星期一 UTC+8上午9:48:47,Melvyn Sopacua写道:
>
> On Sunday 29 January 2017 13:03:34 Xx Johnsua wrote:
>
>  
>
>  
>
> > File
>
> > "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versio
>
> > ns/3.5/lib/python3.5/wsgiref/headers.py", line 142, in __bytes__
>
> > return str(self).encode('iso-8859-1')
>
>  
>
> https://docs.djangoproject.com/en/1.10/ref/settings/#default-charset
>
>  
>
> I believe your default charset is set to 'iso-8859-1'.
>
> -- 
>
> Melvyn Sopacua
>

-- 
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/f45e726e-b6bd-4bad-a556-9283eeeb79a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.