session management problem
Hi all, In my application i have a login screen. The view is simple as below: loginform=None formvalid=True if request.method == "POST": username = request.POST['username'] password = request.POST['password'] loginform=LoginForm(request.POST) formvalid=loginform.is_valid() if formvalid: user = authenticate(username=username, password=password) if user is not None: if user.is_active: login(request, user) return render_to_response("menu.html", {"somekey":somevalue}) ... menu.html has some menus. One of them had the address of "localhost/add" which is defined in urls.py also. The view for add, is also add. But at my add function it seems i lost my session. if not request.user.is_authenticated(): return HttpResponse("nok") else: return HttpResponse("ok") So i am gettig alwasy nok on the screen. How can i keep accesing session values from not posted sites? -- Oguz Yarimtepe --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
javascript problem
Hi, At my application i have ben working quiete fine but when i tested my app, i saw that there is a problem about the function i am onlloading at the body part. So i have something as below: This function is adding an onchange event to a form element (a select indeed). When i select something from the drop box another select box is being updated. The code is working on Firefox but when i tested with IE, i realized it is not working. I tried also by writing pure xmlHTTP requests and functions by thinking the protoculous is not suitable with IE, but it it didn't work either. So loadEventHandlers is never activating the update function defined in it. The code is as below: function updateDepartment(facultyname) { if (facultyname!= '') { new Ajax.Updater( document.getElementById("{{ form.department.auto_id }}"), 'someurl/' + facultyname, {method:'get'}); } } function loadEventHandlers() { document.getElementById("{{ form.faculty.auto_id }}").onchange = function () { updateDepartment(this.options[this.selectedIndex].value); //test(this.options[this.selectedIndex].value); // alert("ok"); }; } So is there a restriction using onload functions at templates at Django? Or should it normaly work but am i doing something wrong? -- Oguz Yarimtepe --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
strange javascript problem at IE
Hi all, I am having problems on executing the javascripts. At my django app, i added this simple script to my base.html. alert("ok"); I added these lines just after the body part by expecting to see an "ok" alert message at the load of the first page of the application. The code is working of Firefox but when i tested with IE, i dont see any messages. I didn't find a solution yet. Anybody encounter with the same issue before? -- Oguz Yarimtepe --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
strange javascript problem at IE
Hi all, I am having problems on executing the javascripts. At my django app, i added this simple script to my base.html. alert("ok"); I added these lines just after the body part by expecting to see an "ok" alert message at the load of the first page of the application. The code is working of Firefox but when i tested with IE, i dont see any messages. I didn't find a solution yet. Anybody encounter with the same issue before? -- Oguz Yarimtepe --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
matplotlib usage problem
Hi, I was trying to use the matplotlib at my Django view. The version i was trying is 0.98. What i did is to import the library and then plot a graph. The problem is when i tried the "from pylab import *", i got "RuntimeError: could not create GdkCursor object". This is most probably because of the apache user is not able to access the X server. Indeed at my distro it doesn't have shell account. I don't want to define X access to apache user. So what do you suggest? -- Oguz Yarimtepe --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
filling model choices field according to language code
Hi, In my django application i have a Ticket class at my model as below class Ticket(models.Model): ... faculty = models.SmallIntegerField( _('Faculty'), #edit begins choices=((0,""),), #edit begins default=0, blank=False, null=True, help_text=_('Faculty name of the ticket related with'), ) The thing is, i want to fill the choices part dynamically. According to the language, i want to fill the string part so at the template the right human readable string will be seen. Because i couldn't visualize how i can do it, i tried to fix it at the view part as if lang == "en": form.fields['faculty'].choices = [(0, '')] + [[f.fakulte_id, f.faculty_name] for f in Faculty.objects.all()] fak=Faculty.objects.get(fakulte_id=fak) form.fields['department'].choices = [(0, '')] + [[d.bolum_id, d.dep_name] for d in fak.department_set.all()] if lang == "tr": form.fields['faculty'].choices = [(0, '')] + [[f.fakulte_id, f.fakulte_tr] for f in Faculty.objects.all()] fak=Faculty.objects.get(fakulte_id=fak) form.fields['department'].choices = [(0, '')] + [[d.bolum_id, d.bolum_tr] for d in fak.department_set.all()] form.fields['problemcategory'].choices = [(0, '')] + [[p.id, p.category] for p in ProblemCategory.objects.all()] As you can see i have problemcategory and department fields also. At the ticket edit issue, i have modelform as class EditTicketForm(forms.ModelForm): class Meta: model = Ticket And at the view form = EditTicketForm(request.POST, instance=ticket) lang=request.LANGUAGE_CODE fak=int(request.POST["faculty"]) The rest continues as above lang part. When i tried if form.is_valid(): i got errors saying that the values from the department, faculty and problemcategory fields are not valid. When i add a clean method for modelform as def clean_faculty(self): data = self.cleaned_data['faculty'] return 0 the error related with faculty is gone. So it seems modelform is creating the choices with (0, "") which is defined at the model. How can i fix it like at the view part so that i will fill the choices according to the language code? -- Oguz Yarimtepe -- 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.
ajax toolkit suggest request
Hi, I need some ajax help at my Django application. I haven't used ajax before so it will be good if someone suggest me some toolkits so that i won't spend time reading all ajax things. One thing that i want to do is filling a text box by clicking a button. It will be good if another Django form site is opened and after choosing the required value (most probably by clicking a check box) and submiting , i want to see the selected value at the text area. Maybe this is not a related topic with ajax, but i dont know how i will do it in Django. It may be a javascript job, i dont know. Second, i want to update some form parts or part of the site when a form elements value is changed. Any help will be helpful. Thanx. -- Oğuz Yarımtepe www.yarimtepe.com --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ajax toolkit suggest request
> If you have not already, go to new.djangobook.com and read chapter 7 > on form processing. Make sure you understand it. Visit the excellent > newforms reference in the Django doc. Look at the onchange attribute > for checkboxes to see how to make a form autosubmit on a change to a > field, and I think you will see how to do what you describe in a > straightforward fashion. > I solved my problem by using prototype.js. It was good updating some parts of the site when an action occured on the site. Thanx for your interest. -- Oğuz Yarımtepe www.yarimtepe.com --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django web app reaching rest api and CORS problem
I have a django app and at the template part i have javascript function calling the rest api: http://komandor.app.gittigidiyor.net:8000/static/js/select-autofiller.js>"> At the js file i am filling a select box according to the returned json response $('#field1').change(function(){ var var1=$("#filed2").val(); var var2=$("#field1 option:selected").text(); url="http://www.foo.com:8080/"; + var1 + "/" + var2 + "/"; $.get(url, function( data ) { alert( "Load was performed." + data); }); }); The Django web app is running on www.foo.com:8000 At the rest api side, falcon is running and i installed falcon-cors import falcon from wsgiref import simple_server from falcon_cors import CORS check_python() cors = CORS(allow_origins_list=settings.ALLOWED_ORIGINS) api = falcon.API( media_type='application/json', middleware=[ # json.RequireJSON(), # json.JSONTranslator(), https.RequireHTTPS(), headers.BaseHeaders(), handle_404.WrongURL(), cors.middleware ], ) *** route definitions httpd = simple_server.make_server('0.0.0.0', 8080, api) httpd.serve_forever() ALLOWED_ORIGINS is a list: ['www.foo.com:8000', 'www.foo.com:8080'] Still when i select the box and triggered the js at the Django web app, i am getting XMLHttpRequest cannot load http://www.foo.com:8080/var1/var2. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://www.foo.com:8000' is therefore not allowed access. The response had HTTP status code 400. I couldn't find ow to fix it. Any idea? -- 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/8f920ccf-9948-4e57-8976-a79a7385be0a%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.