Apache unicode problem!why it is OK in "manage.py runserver 8000" ? but it is not OK when "apach + mod_python" !
hi all: I write a tag "model_as_table_with", used like this in template : {{model_instance | *model_as_table_with*:"real_name,gender,birthdate,}} problem was raise in my "*model_as_table_with*" function. this following code is ok when I runserver with "manage.py runserver 8000" *col = "%s:%s" % (field.name and field.verbose_name, getattr(model_instance, **field**.name)) * but, when I run my project with " apache + mod_python ". it raise this Exception : "Exception=,e='ascii' codec can't decode byte 0xe7 in position 4: ordinal not in range(128)" I have to modify the code like this : *col = "%s:%s" % (field.name and field.verbose_name, getattr(**model_instance**, **field**.name).encode('utf-8') **)* all of my code files are set to utf-8, why it is still need to *encode('utf-8') ?* why it is OK in "manage.py runserver 8000" ? but it is not OK when "apach + mod_python" thanks . -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
how to keep the FileField being unmodified ?
I display a ModelForm. if user edit the field, ModelForm.save() will save the edited field,and the non-edited field keep its origin value. but, FileField/ImageField do not act as that. if users have not modified the FieldField, it will be empty. how to implement that? thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
who using Dajax? it modify the encoding of my data,how to make my data keeping utf-8? thanks.
What steps will reproduce the problem? 1.there is a field in the join_request_form。 2.submit the form data like this: Dajax.friends_app_invite({ 'data':$('#join_request_form').formSerialize () }); 3.in the django end. data = QueryDict(request.POST['data']) join_request_form = MultiJoinRequestForm(data) ...process with the form.. render = render_to_string( "friends_app/email_invite_form.html", {'join_request_form':join_request_form}) dajax.assign("#join_request_form",'innerHTML',render) return dajax 4. the error raised!the value of ==> . -->so, Dajax modify the encoding of my "message" field. how to resolve this error? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
when click ,the corresponding view function was called twice,why?
with the follow code/config,one request lead to view function was execute twice。 -- url config: url(r'^ader/basic/(?P[0-9]+)/ $',ader_basic,name='ad_ader_basic'), -- view function: def ader_basic(request,ad_id=None,template = "advertise/ ad_wizard_basic.html"): print 'ader_basic' -- template: --- Validating models... 0 errors found --- submit a request,lead to view_function was called twice! why? -- Django version 1.1, using settings 'bxdc_project.settings' Development server is running at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK. ader_basic #print first time when [17/Oct/2009 23:48:11] "GET /advertise/ader/basic/2/ HTTP/1.1" 200 121201 [17/Oct/2009 23:48:11] "GET /site_media/blueprint/src/reset.css HTTP/ 1.1" 304 0 [17/Oct/2009 23:48:11] "GET /site_media/jquery.js HTTP/1.1" 304 0 ader_basic # print twice [17/Oct/2009 23:48:11] "GET /advertise/ader/basic/2/ HTTP/1.1" 200 68221 [17/Oct/2009 23:48:11] "GET /site_media/img/logo.png HTTP/1.1" 304 0 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
when click ,the corresponding view function was called twice,why?
with the follow code/config,one request lead to view function was execute twice。 -- url config: url(r'^ader/basic/(?P[0-9]+)/ $',ader_basic,name='ad_ader_basic'), -- view function: def ader_basic(request,ad_id=None,template = "advertise/ ad_wizard_basic.html"): print 'ader_basic' -- template: --- Validating models... 0 errors found --- submit a request,lead to view_function was called twice! why? -- Django version 1.1, using settings 'bxdc_project.settings' Development server is running at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK. ader_basic #print first time when [17/Oct/2009 23:48:11] "GET /advertise/ader/basic/2/ HTTP/1.1" 200 121201 [17/Oct/2009 23:48:11] "GET /site_media/blueprint/src/reset.css HTTP/ 1.1" 304 0 [17/Oct/2009 23:48:11] "GET /site_media/jquery.js HTTP/1.1" 304 0 ader_basic # print twice [17/Oct/2009 23:48:11] "GET /advertise/ader/basic/2/ HTTP/1.1" 200 68221 [17/Oct/2009 23:48:11] "GET /site_media/img/logo.png HTTP/1.1" 304 0 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: new permission
def get_permission_object(perm_label): from django.contrib.contenttypes.models import ContentType from django.contrib.auth.models import Permission app_label,perm_code_name = perm_label.split('.') content_type = ContentType.objects.get(app_label=app_label) perm = Permission.objects.get (content_type=content_type,codename=perm_code_name) return perm def add_perm_to_user(user,perm_label): user.user_permissions.add(get_permission_object(perm_label)) user.save() return user >>> u=User.objects.get(username="test_ader1") >>> u=add_perm_to_user(u,'your_app_label.your_perm_label') your_app_label.your_perm_label ==> in your case, is "appname.total" On Oct 14, 2:58 am, Михаил Лукинwrote: > Try ./manage reset auth > > > > On Tue, Oct 13, 2009 at 1:08 PM, elminio wrote: > > > hi, > > > It didnt help :/ > > > On Oct 9, 10:33 am, "Bogdan I. Bursuc" > > wrote: > > > Try to delete the auth_permissions table the sync db > > > see if it helps > > > > On Fri, 2009-10-09 at 01:29 -0700,elminiowrote: > > > > Up Up > > > > > On Oct 8, 12:10 pm,elminio wrote: > > > > > Hi, > > > > > I've extended my model with new permission. > > > > > > class Meta: > > > > > permissions = ( > > > > > ("total", "total"), > > > > > ) > > > > > > After that I mafe manage.py syncdb. But after that when I wanted to > > > > > add user new privilage just created there wasn't it in admin panel > > > > > where you can choose permissions add and remove from user. > > > > > > thanks for help > > -- > regards, > Mihail --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: how to design mobile version of my site based on django?
thank you. you means the greatest difference between PC and phone is the size of their screen. ok. and what I need to do is to ensure that the DIV+CSS is resizable. but .whether it is easy for DIV+CSS designed for PC to adapt the mobile screen? thank you . On Oct 10, 3:54 pm, Jani Tiainen <rede...@gmail.com> wrote: > hao he kirjoitti: > > > I'm developing my site with django, > > > mainly, my site works as normal, visited by PC. > > > but ,the site will also be visited by mobile device(e.g.iphone) > > > who tell me the solution? > > > or recommend me some relevant articles? > > This has almost nothing to do with Django. > > It's just what to display for smaller display devices and simples way is > to use simplified versions of huge pages. If your site is "normal", > there is not much of need to do anything. Standard HTML, CSS and even JS > works in most mobile devices without problems. > > Of course you might want to limit amount of data sent over network since > mobile speeds aren't that high. So you might want to use some detection > about "this is mobile device" (maybe there is some magic header that > reveals it) and forward user to a bit more lightweight page(s) instead > of using heavy, large screen pages meant for large display computers. > > Easiest way is to test your site with mobile and see does it work or not. > > -- > Jani Tiainen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: can I do doctest in view function? if I can, how to use fixture data in doctest?
w(request, template = "userprofile/profile/overview.html"): """ >>> from django.test.client import Client >>> c = Client() >>> c.login(username='aaa', password='aaa') True >>> response = c.get('/user/') >>> response.status_code 200 >>> if isinstance(response.context, list): ... response.context[0]['email'] ... else: ... response.context['email'] u'speed...@gmaila.com' """ . . ... On Oct 10, 11:31 am, hao he <speed...@gmail.com> wrote: > @login_required > def overview(request, template = "userprofile/profile/overview.html"): > """ > this is the doctest of a view function! > > >>> from django.test.client import Client > >>> c = Client() > >>> c.login(username='fred', password='secret') > >>> response = c.get('/userprofile/overview/') > >>> response.context.email > > f...@gmail.com > > """ > > profile, created = Profile.objects.get_or_create > (user=request.user) > validated = False > try: > email = EmailValidation.objects.get(user=request.user).email > except EmailValidation.DoesNotExist: > email = request.user.email > > if email: > validated = True > > data = { 'email': email, 'validated': validated, 'fields' : > Profile._meta.fields } > > return render_to_response(template, data, > context_instance=RequestContext(request)) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
can I do doctest in view function? if I can, how to use fixture data in doctest?
@login_required def overview(request, template = "userprofile/profile/overview.html"): """ this is the doctest of a view function! >>> from django.test.client import Client >>> c = Client() >>> c.login(username='fred', password='secret') >>> response = c.get('/userprofile/overview/') >>> response.context.email f...@gmail.com """ profile, created = Profile.objects.get_or_create (user=request.user) validated = False try: email = EmailValidation.objects.get(user=request.user).email except EmailValidation.DoesNotExist: email = request.user.email if email: validated = True data = { 'email': email, 'validated': validated, 'fields' : Profile._meta.fields } return render_to_response(template, data, context_instance=RequestContext(request)) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
how to design mobile version of my site based on django?
I'm developing my site with django, mainly, my site works as normal, visited by PC. but ,the site will also be visited by mobile device(e.g.iphone) who tell me the solution? or recommend me some relevant articles? thanks . --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: how to set field value of a form object before render it?
thanks for your reply。 yes,i want to display the form again with some field being modified. how to set the new value to a field of fhe old form to render ? for example : in site signup case. when there are some errors, we hope to display the signup again ,but the password field would been cleared up。 how to clear it ? thanks 。 2009/8/29 Karen Tracey <kmtra...@gmail.com> > On Fri, Aug 28, 2009 at 10:35 PM, hao he <speed...@gmail.com> wrote: > >> hi. >> >> this following code show what I want to do,but 'red' line is incorrect, >> >> if request.method == "POST": >> form = MyForm(request.POST) >> c = form.data["a"] + form.data["b"] >> form.data["c"] = c >> return render_to_response(template_name , {"form": form}) >> >> how to modify it? thanks. > > > Perhaps if you put a few more words around what it is you are trying to do > someone might be able to offer useful help. This code looks quite odd to > me. You generally don't want to take values from form.data (which will not > have been normalized) but rather validate the form and then take values from > form.cleaned_data (which will be both validated and normalized). Doing > nothing with what you've got other than displaying the form (again?) also > seems a bit odd. > > Karen > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
how to set field value of a form object before render it?
hi. this following code show what I want to do,but 'red' line is incorrect, if request.method == "POST": form = MyForm(request.POST) c = form.data["a"] + form.data["b"] form.data["c"] = c return render_to_response(template_name , {"form": form}) how to modify it? thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---