Re: Why the default Django transaction way doesn't work?
Thanks for your reply. I am using MySQL 5.0.24, with InnoDB engine. Actually I am not familiar with MySQL settings, but as far as I understand, as when I use the decorator @transaction.commit_on_success, the transaction works well, does that means my database backend has no problem in support transaction? or I am wrong on this point? On 1月13日, 上午3时06分, Alex Koshelev <[EMAIL PROTECTED]> wrote: > Transaction behaviour depends on database backend. What backend do you > use and have you setup transaction support for it? > > On 12 янв, 20:45, pength <[EMAIL PROTECTED]> wrote: > > > > > At first, I tried to search in this group, but only got an un-answered > > question similar to > > mine:http://groups.google.com/group/django-users/browse_thread/thread/7677... > > > in my settings.py, i am using TransactionMiddleware. and my testing > > views.py as following: > > > def index(request): > > c=Myobject.objects.get(pk=45) ###Myobject with a field 'isUpdate' > > which default value is False. > > c.isUpdate = True > > c.save() > > raise NameError > > > after a request to this index view, I found in database that object's > > 'isUpdate' was set to True... > > > then I added an decorator: > > @transaction.commit_on_success > > def index(request): > > c=Myobject.objects.get(pk=45) > > . > > > Then the object won't be changed. > > > I am confused about this, because according to the Django document > > about transaction, I think the default way is just commit_on_success? > > or what mistake I have made? > > > 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ManyToManyField -- help with view?
SOLVED my problem - Problem was in TEMPLATE {% for x in department.persons.all %} {% endfor %} [EMAIL PROTECTED] wrote: > I need some help with ManytoManyField > > > Here is simplified version of my models > > > class Person(models.Model): > name = models.CharField(maxlength=20) > > class Company(models.Model): > > class Department(models.Model): > persons = models.ManyToManyField(Person) > company = models.ForeignKey(Company) > > > So, the same person can be linked to multiple Departments. > A department is link to a company. > > I want to display list of people link to Department AND department > > Example: > > Company Dept Person > -- -- > CompanyA HRBob > CompanyA ITJohn > CompanyB ITBob > > > My view looks like this (THIS IS WHERE I NEED HELP) > > > def company_detail(request, myid): > """ Main page to people per Company and Dept """ > my_company = Company.objects.get(id=myid) > my_department = Department.objects.filter(company__id=myid) > my_persons = Module.objects.filter(site__department__id=myid) > return render_to_response('company_detail.html', > {'company': my_company, 'department_list': my_department, > 'person_list': my_persons,}) > > > In my Template I am unable to link person to Company -- think my VIEW > is not correct > Any comments will be appreciated. > > Sorry for long post... > > LIAM --~--~-~--~~~---~--~~ 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: remove ^M: project moved from window to linux
I need to do that often at work when Windows files are moved over to AIX. I just use vi. The key sequence is: :%s/^M// To create the ^M character, press Ctrl+V, then M. I'm not sure what that character is (never bothered to look), but I think may be that extra control character that Windows uses to represent CRLF (carriage return/line feed). Unix based system only use one control character. I'm not sure if that affects Python at all. Testing out a simple script with those characters shows that it doesn't matter... Keith On Jan 12, 9:46 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > On 12-Jan-08, at 10:12 PM, crybaby wrote: > > > What is the fastest way to remove ^M from every files in main project > > folder and apps folders. Doing it by hand seems time consuming. Is > > there a simple script take care of this? if I just leave the ^M in > > python code, would it cause problems? > > dos2unix > > -- > > regards > kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/web/ > Foss Conference for the common man:http://registration.fossconf.in/web/ --~--~-~--~~~---~--~~ 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: remove ^M: project moved from window to linux
On 12-Jan-08, at 10:12 PM, crybaby wrote: > What is the fastest way to remove ^M from every files in main project > folder and apps folders. Doing it by hand seems time consuming. Is > there a simple script take care of this? if I just leave the ^M in > python code, would it cause problems? dos2unix -- regards kg http://lawgon.livejournal.com http://nrcfosshelpline.in/web/ Foss Conference for the common man: http://registration.fossconf.in/web/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق
صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات قطر كورة اهلى زمالك ابوتريكة جنس سكس عربى صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق http://66rb.net http://www.forex.zw2j.com تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات قطر كورة اهلى زمالك ابوتريكة جنس سكس عربى صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق http://66rb.net http://www.forex.zw2j.com تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات قطر كورة اهلى زمالك ابوتريكة جنس سكس عربى صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق http://66rb.net http://www.forex.zw2j.com تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات قطر كورة اهلى زمالك ابوتريكة جنس سكس عربى صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق http://66rb.net http://www.forex.zw2j.com http://66rb.net تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات قطر كورة اهلى زمالك ابوتريكة جنس سكس عربى صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق
صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات قطر كورة اهلى زمالك ابوتريكة جنس سكس عربى صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق http://66rb.net http://www.forex.zw2j.com تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات قطر كورة اهلى زمالك ابوتريكة جنس سكس عربى صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق http://66rb.net http://www.forex.zw2j.com تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات قطر كورة اهلى زمالك ابوتريكة جنس سكس عربى صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق http://66rb.net http://www.forex.zw2j.com تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات قطر كورة اهلى زمالك ابوتريكة جنس سكس عربى صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق http://66rb.net http://www.forex.zw2j.com http://66rb.net تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات قطر كورة اهلى زمالك ابوتريكة جنس سكس عربى صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات
تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات قطر كورة اهلى زمالك ابوتريكة جنس سكس عربى صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق http://66rb.net http://www.forex.zw2j.com تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات قطر كورة اهلى زمالك ابوتريكة جنس سكس عربى صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق http://66rb.net http://www.forex.zw2j.com تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات قطر كورة اهلى زمالك ابوتريكة جنس سكس عربى صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق http://66rb.net http://www.forex.zw2j.com تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات قطر كورة اهلى زمالك ابوتريكة جنس سكس عربى صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق http://66rb.net http://www.forex.zw2j.com http://66rb.net تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات قطر كورة اهلى زمالك ابوتريكة جنس سكس عربى صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات قطر كورة اهلى زمالك ابوتريكة جنس سكس عربى صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات قطر كورة اهلى زمالك ابوتريكة جنس سكس عربى صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات قطر كورة اهلى زمالك ابوتريكة جنس سكس عربى صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات قطر كورة اهلى زمالك ابوتريكة جنس سكس عربى صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات قطر كورة اهلى زمالك ابوتريكة جنس سكس عربى صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات قطر كورة اهلى زمالك ابوتريكة جنس سكس عربى صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات قطر كورة اهلى زمالك ابوتريكة جنس سكس عربى صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات قطر كورة اهلى زمالك ابوتريكة جنس سكس عربى صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات قطر كورة اهلى زمالك ابوتريكة جنس سكس عربى صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات قطر كورة اهلى زمالك ابوتريكة جنس سكس عربى صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث نغمات فن تعارف شات زواج فضائح فنانين ممثلات نانسى هيفاء روبى مصر الامارات الكويت السعودية لبنان توظيف احلام طبخ اسرة روايات قطر كورة اهلى زمالك ابوتريكة جنس سكس عربى صور افلام جنسية مقاطع جوال اغتصاب قصص جنسية نيك سحاق تحميل برامج العاب كومبيوتر اسلاميات دينى كتب افلام اغانى فيديو كليب بلوتوث
Re: Multilingual text in db
On Jan 12, 2008 11:04 PM, Grupo Django <[EMAIL PROTECTED]> wrote: > > IMHO Internationalization is useless if there is no support for > multilingual translations in the database. I've seen different > approaches like Django Multilingual ( > http://code.google.com/p/django-multilingual/ > ) and transdb ( http://code.google.com/p/transdb/ ), but I have no > idea which I should use if I should use one of those. Is there any > plan to include this feature before django 1.0? I think this is the > biggest lack in the django framework, and it's a very important > problem especially for non English speakers. I18n of the database isn't on the v1.0 plan. The fact that there are multiple approaches should give you a hint as to why this is the case - there isn't a consensus on how the problem can be solved in a generic fashion (or even if it can be solved in a generic fashion at all). The needs for a content i18n system will depend very much on your own local site requirements. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ 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: user.get_profile() attribute error
get_profile() uses default profile model manager. So if you profile model is Profile - exception is Profile.DoesNotExist that is subclass of ObjectDoesNotExist On 13 янв, 02:45, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I had the settings.py configured with the wrong Model name. > useraccount instead of userprofile. > > Whoops. Thanks! > > Though the documentation might be wrong, in that DoesNotExist doesn't > seem to be a real exception. ObejctDoesNotExist, as defined in django/ > core/exceptions.py, is the correct exception when a profile doesn't > exist if user.get_profile() is called. > > Ivan > > On Jan 12, 3:24 pm, Alex Koshelev <[EMAIL PROTECTED]> wrote: > > > Do you create a profile model and set right value in settings.py > > file?http://www.djangoproject.com/documentation/authentication/#storing-ad... > > > And User.get_pofile() does not require logged in user. Note that > > profile instance per user you must create manually. > > > On 13 янв, 01:32, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > > wrote: > > > > I'm trying to catch any exceptions from user.get_profile() during > > > account creation in order to create the profile > > > > I create the user, authenticate them, log them in, and then try to > > > get_profile. To start out, the user name is the email and I'm setting > > > the password to a random string > > > > newUser = User.objects.create_user(email, email, randomString ) > > > user = auth.authenticate(username=email, password=randomString) > > > auth.login(request, user) > > > userProfile = user.get_profile() > > > > This causes an error: > > > AttributeError("'NoneType' object has no attribute > > > '_default_manager'",), > > > > I expected an ObjectDoesNotExist exception. It looks like the user > > > object doesn't exist, but I explicitly test for "user is None" > > > > What is this about? > > > > Thanks, > > > Ivan --~--~-~--~~~---~--~~ 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: user.get_profile() attribute error
I had the settings.py configured with the wrong Model name. useraccount instead of userprofile. Whoops. Thanks! Though the documentation might be wrong, in that DoesNotExist doesn't seem to be a real exception. ObejctDoesNotExist, as defined in django/ core/exceptions.py, is the correct exception when a profile doesn't exist if user.get_profile() is called. Ivan On Jan 12, 3:24 pm, Alex Koshelev <[EMAIL PROTECTED]> wrote: > Do you create a profile model and set right value in settings.py > file?http://www.djangoproject.com/documentation/authentication/#storing-ad... > > And User.get_pofile() does not require logged in user. Note that > profile instance per user you must create manually. > > On 13 янв, 01:32, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: > > > I'm trying to catch any exceptions from user.get_profile() during > > account creation in order to create the profile > > > I create the user, authenticate them, log them in, and then try to > > get_profile. To start out, the user name is the email and I'm setting > > the password to a random string > > > newUser = User.objects.create_user(email, email, randomString ) > > user = auth.authenticate(username=email, password=randomString) > > auth.login(request, user) > > userProfile = user.get_profile() > > > This causes an error: > > AttributeError("'NoneType' object has no attribute > > '_default_manager'",), > > > I expected an ObjectDoesNotExist exception. It looks like the user > > object doesn't exist, but I explicitly test for "user is None" > > > What is this about? > > > Thanks, > > Ivan --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Earn 5000 $ Per Month with Gooooooooooooogle
http://www.GetRealCash.com Earn 5000 $ Per Month Earn With Google Easy ways to Earn While Sitting At home http://www.GetRealCash.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: user.get_profile() attribute error
Do you create a profile model and set right value in settings.py file? http://www.djangoproject.com/documentation/authentication/#storing-additional-information-about-users And User.get_pofile() does not require logged in user. Note that profile instance per user you must create manually. On 13 янв, 01:32, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I'm trying to catch any exceptions from user.get_profile() during > account creation in order to create the profile > > I create the user, authenticate them, log them in, and then try to > get_profile. To start out, the user name is the email and I'm setting > the password to a random string > > newUser = User.objects.create_user(email, email, randomString ) > user = auth.authenticate(username=email, password=randomString) > auth.login(request, user) > userProfile = user.get_profile() > > This causes an error: > AttributeError("'NoneType' object has no attribute > '_default_manager'",), > > I expected an ObjectDoesNotExist exception. It looks like the user > object doesn't exist, but I explicitly test for "user is None" > > What is this about? > > Thanks, > Ivan --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
user.get_profile() attribute error
I'm trying to catch any exceptions from user.get_profile() during account creation in order to create the profile I create the user, authenticate them, log them in, and then try to get_profile. To start out, the user name is the email and I'm setting the password to a random string newUser = User.objects.create_user(email, email, randomString ) user = auth.authenticate(username=email, password=randomString) auth.login(request, user) userProfile = user.get_profile() This causes an error: AttributeError("'NoneType' object has no attribute '_default_manager'",), I expected an ObjectDoesNotExist exception. It looks like the user object doesn't exist, but I explicitly test for "user is None" What is this about? Thanks, Ivan --~--~-~--~~~---~--~~ 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: Django won't create foreign keys
Well inserting rows with invalid poll_id's works, until i enter the ALTER TABLE by hand, so the foreign key constraints are definitely not there. Anyways, here's what it outputs: BEGIN; CREATE TABLE `polls_poll` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `question` varchar(200) NOT NULL, `pub_date` datetime NOT NULL ) ; CREATE TABLE `polls_choice` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `poll_id` integer NOT NULL, `choice` varchar(200) NOT NULL, `votes` integer NOT NULL ) ; -- The following references should be added but depend on non-existent tables: -- ALTER TABLE `polls_choice` ADD CONSTRAINT poll_id_refs_id_5d896c23 FOREIGN KE Y (`poll_id`) REFERENCES `polls_poll` (`id`); CREATE INDEX `polls_choice_poll_id` ON `polls_choice` (`poll_id`); COMMIT; On Jan 12, 2:11 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Do manage.py sqlall polls instead, it will show all the sql, not just > the tables, > > On Jan 12, 3:41 pm, apramanik <[EMAIL PROTECTED]> wrote: > > > Hi all, > > > I'm trying out the Django development version and have been going > > through the tutorial, but the models aren't creating foreign keys. > > > When I run 'python manage.py sql polls' I get: > > > BEGIN; > > CREATE TABLE `polls_poll` ( > > `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, > > `question` varchar(200) NOT NULL, > > `pub_date` datetime NOT NULL > > ) > > ; > > CREATE TABLE `polls_choice` ( > > `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, > > `poll_id` integer NOT NULL, > > `choice` varchar(200) NOT NULL, > > `votes` integer NOT NULL > > ) > > ; > > -- The following references should be added but depend on non-existent > > tables: > > -- ALTER TABLE `polls_choice` ADD CONSTRAINT poll_id_refs_id_5d896c23 > > FOREIGN KE > > Y (`poll_id`) REFERENCES `polls_poll` (`id`); > > COMMIT; > > > Notice the weird message at the bottom, 'polls_choice' does exist! > > > models.py: > > > class Poll(models.Model): > > > question = models.CharField(max_length=200) > > pub_date = models.DateTimeField('date published') > > > def __unicode__( self ) : > > return self.question > > > def wasPublishedToday( self ) : > > return self.pub_date.date() == datetime.date.today() > > > class Choice(models.Model): > > > poll = models.ForeignKey(Poll) > > choice = models.CharField(max_length=200) > > votes = models.IntegerField() > > > def __unicode__( self ) : > > return self.choice > > > settings.py: > > > DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', 'postgresql', > > 'mysql', 'sqlite3' or 'oracle'. > > DATABASE_NAME = 'mysite' # Or path to database file if using > > sqlite3. > > DATABASE_USER = 'root' # Not used with sqlite3. > > DATABASE_HOST = '' # Set to empty string for localhost. > > Not used with sqlite3. > > DATABASE_PORT = '' # Set to empty string for default. Not > > used with sqlite3. > > DATABASE_OPTIONS = { > > "init_command" : "SET storage_engine = INNODB", > > > } --~--~-~--~~~---~--~~ 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: Django won't create foreign keys
Do manage.py sqlall polls instead, it will show all the sql, not just the tables, On Jan 12, 3:41 pm, apramanik <[EMAIL PROTECTED]> wrote: > Hi all, > > I'm trying out the Django development version and have been going > through the tutorial, but the models aren't creating foreign keys. > > When I run 'python manage.py sql polls' I get: > > BEGIN; > CREATE TABLE `polls_poll` ( > `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, > `question` varchar(200) NOT NULL, > `pub_date` datetime NOT NULL > ) > ; > CREATE TABLE `polls_choice` ( > `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, > `poll_id` integer NOT NULL, > `choice` varchar(200) NOT NULL, > `votes` integer NOT NULL > ) > ; > -- The following references should be added but depend on non-existent > tables: > -- ALTER TABLE `polls_choice` ADD CONSTRAINT poll_id_refs_id_5d896c23 > FOREIGN KE > Y (`poll_id`) REFERENCES `polls_poll` (`id`); > COMMIT; > > Notice the weird message at the bottom, 'polls_choice' does exist! > > models.py: > > class Poll(models.Model): > > question = models.CharField(max_length=200) > pub_date = models.DateTimeField('date published') > > def __unicode__( self ) : > return self.question > > def wasPublishedToday( self ) : > return self.pub_date.date() == datetime.date.today() > > class Choice(models.Model): > > poll = models.ForeignKey(Poll) > choice = models.CharField(max_length=200) > votes = models.IntegerField() > > def __unicode__( self ) : > return self.choice > > settings.py: > > DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', 'postgresql', > 'mysql', 'sqlite3' or 'oracle'. > DATABASE_NAME = 'mysite' # Or path to database file if using > sqlite3. > DATABASE_USER = 'root' # Not used with sqlite3. > DATABASE_HOST = '' # Set to empty string for localhost. > Not used with sqlite3. > DATABASE_PORT = '' # Set to empty string for default. Not > used with sqlite3. > DATABASE_OPTIONS = { > "init_command" : "SET storage_engine = INNODB", > > } --~--~-~--~~~---~--~~ 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 won't create foreign keys
Hi all, I'm trying out the Django development version and have been going through the tutorial, but the models aren't creating foreign keys. When I run 'python manage.py sql polls' I get: BEGIN; CREATE TABLE `polls_poll` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `question` varchar(200) NOT NULL, `pub_date` datetime NOT NULL ) ; CREATE TABLE `polls_choice` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `poll_id` integer NOT NULL, `choice` varchar(200) NOT NULL, `votes` integer NOT NULL ) ; -- The following references should be added but depend on non-existent tables: -- ALTER TABLE `polls_choice` ADD CONSTRAINT poll_id_refs_id_5d896c23 FOREIGN KE Y (`poll_id`) REFERENCES `polls_poll` (`id`); COMMIT; Notice the weird message at the bottom, 'polls_choice' does exist! models.py: class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') def __unicode__( self ) : return self.question def wasPublishedToday( self ) : return self.pub_date.date() == datetime.date.today() class Choice(models.Model): poll = models.ForeignKey(Poll) choice = models.CharField(max_length=200) votes = models.IntegerField() def __unicode__( self ) : return self.choice settings.py: DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. DATABASE_NAME = 'mysite' # Or path to database file if using sqlite3. DATABASE_USER = 'root' # Not used with sqlite3. DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. DATABASE_OPTIONS = { "init_command" : "SET storage_engine = INNODB", } --~--~-~--~~~---~--~~ 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: Integrating TinyMCE in django.contrib.flatpages
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Christoph Egger wrote: > Hi > > I'm trying to use TinyMCE within flatpages. I followed the instructions > given on code.djangoproject.com > > http://code.djangoproject.com/wiki/AddWYSIWYGEditor > > but TinyMCE won't show up (Tested with Opera + Konqueror + > Iceweasel(Firefox)). Currently I'm serving TinyMCE from my apache and my > Django Project from the test-server but serving both from apache doesn't > change anything. > > I could not make the site available as for now the production webserver > isn't set up for django. > > Christoph Seems I just can't form correct URLs so I solved this problem by correcting my URLs. But I still can't get additional dialogues like Images and HTML-View working. Christoph -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHiRUSy7PXBwNyJ10RCnV1AJ4psalD9QkOSeTvoJWpah+h5cm+nACePkOx kMfvezYPr3oCG+l0Z7xMjuE= =cPm+ -END PGP SIGNATURE- --~--~-~--~~~---~--~~ 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: Model validation basics
On Jan 12, 6:36 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > Did you miss the "This is an experimental feature!" note at the top of: > > http://www.djangoproject.com/documentation/models/validation/ > > ? > > Last I recall seeing it mentioned here, model validation is still a work in > progress. Meaning I don't believe everything is supposed to work just yet. > > Karen I did miss it! Many thanks! It's a pain because when you're writing doctests you trigger a postgres error and then receive "current transaction is aborted" messages for whatever else you try and do to the database within the test. Thanks again Ian --~--~-~--~~~---~--~~ 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: Why the default Django transaction way doesn't work?
Transaction behaviour depends on database backend. What backend do you use and have you setup transaction support for it? On 12 янв, 20:45, pength <[EMAIL PROTECTED]> wrote: > At first, I tried to search in this group, but only got an un-answered > question similar to > mine:http://groups.google.com/group/django-users/browse_thread/thread/7677... > > in my settings.py, i am using TransactionMiddleware. and my testing > views.py as following: > > def index(request): > c=Myobject.objects.get(pk=45) ###Myobject with a field 'isUpdate' > which default value is False. > c.isUpdate = True > c.save() > raise NameError > > after a request to this index view, I found in database that object's > 'isUpdate' was set to True... > > then I added an decorator: > @transaction.commit_on_success > def index(request): > c=Myobject.objects.get(pk=45) > . > > Then the object won't be changed. > > I am confused about this, because according to the Django document > about transaction, I think the default way is just commit_on_success? > or what mistake I have made? > > 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: URL Method
This is a fairly recent addition to the development trunk, it allows for named URL patterns. It is explained in detail at http://www.djangoproject.com/documentation/url_dispatch/#naming-url-patterns In terms of whether you should start writing your url expressions like that, it's up to you. If you would like to use named URL patterns, then you should. Otherwise, maybe it's not worth the effort. Hope that helped, Eric Florenzano On Jan 12, 12:44 pm, Chris <[EMAIL PROTECTED]> wrote: > HI I was tinkering around with this django app called basic blog > (http://code.google.com/p/django-basic-blog/) and I noticed that the > author uses a method called URL() to define his URL patterns, views, > and template objects. Should I start writing my url expressions like > this? Is it a new standard? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
URL Method
HI I was tinkering around with this django app called basic blog (http://code.google.com/p/django-basic-blog/) and I noticed that the author uses a method called URL() to define his URL patterns, views, and template objects. Should I start writing my url expressions like this? Is it a new standard? --~--~-~--~~~---~--~~ 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: Model validation basics
On Jan 12, 2008 1:17 PM, Ian J Cottee <[EMAIL PROTECTED]> wrote: > > I've actually written a couple of basic apps in Django but today I > thought I'd play around with doc tests and realised I didn't know as > much as I thought I did. This is all done with latest trunk. > > Let's take a model definition that has just the following: > > class PartType(models.Model): >code = models.CharField(max_length=15) >description = models.CharField(max_length=50) > > We can play around with this in the shell and do this: > > >>> pt = PartType() > >>> pt.validate() > {'code': [u'This field is required.'], 'description': [u'This field is > required.']} > > Which is what we expect. These two fields are required. > > >>> pt.code='ACODE' > >>> pt.description='A description' > >>> pt.validate() > {} > >>> pt.save() > > All good, it validates and saves. Now let's give it something a little > longer than it can't cope with. > > >>> pt.code='THISISLONGERTHANFIFTEENCHARS' > >>> pt.validate() > {} > > Odd - it validates but we know our code field can only be 15 characters. > > >>> pt.save() > Traceback (most recent call last): > File "", line 1, in > File > "/usr/local/lib/python2.5/site-packages/django/db/models/base.py", line > 238, in save >db_values + self._meta.pk.get_db_prep_lookup('exact', pk_val)) > File > "/usr/local/lib/python2.5/site-packages/django/db/backends/util.py", > line 18, in execute >return self.cursor.execute(sql, params) > ProgrammingError: value too long for type character varying(15) > > BANG! > > I'd be expecting for Django to tell me before postgres does, that the > field does not validate. Am I misunderstanding something? > Did you miss the "This is an experimental feature!" note at the top of: http://www.djangoproject.com/documentation/models/validation/ ? Last I recall seeing it mentioned here, model validation is still a work in progress. Meaning I don't believe everything is supposed to work just yet. 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: WSGI session
I talked to the host and they said it was 'scripting-related' and they couldn't help. In desperation, I installed lighttpd, and with their debug mode, and the ability to reconfigure at will, I had it running in 3 hrs! Conclusion: if the host doesn't know how to set up apache for django/ fastcgi, and you can't tell them, don't even try. Remaining big issues are: --- lighttpd is currently on port 81. how do I cause it to be used in place of apache without putting it on a non-standard port. --- I start lighttpd from the shell. If it goes down, how do I make it restart automatically --karl On Jan 12, 6:17 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Jan 12, 2008 2:47 AM, kbochert <[EMAIL PROTECTED]> wrote: > > > > > mod_fastcgi installation > > > The error is: > > 'WSGIRequest' object has no attribute 'session' > > > any ideas? > > Do you have 'django.contrib.sessions.middleware.SessionMiddleware' listed in > MIDDLEWARE_CLASSES in settings.py? > > If I add lines to the file, the error stays at the same location. > > > and if I erase the .pyc file, it does not get regenerated. > > > How do I cause it to use the newly edited file?? > > > I've tried touching the .fcgi file with no luck > > I'm not sure what file you are referring to here. At any rate, this doesn't > sound like and fcgi-specific problem. > > 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Model validation basics
I've actually written a couple of basic apps in Django but today I thought I'd play around with doc tests and realised I didn't know as much as I thought I did. This is all done with latest trunk. Let's take a model definition that has just the following: class PartType(models.Model): code = models.CharField(max_length=15) description = models.CharField(max_length=50) We can play around with this in the shell and do this: >>> pt = PartType() >>> pt.validate() {'code': [u'This field is required.'], 'description': [u'This field is required.']} Which is what we expect. These two fields are required. >>> pt.code='ACODE' >>> pt.description='A description' >>> pt.validate() {} >>> pt.save() All good, it validates and saves. Now let's give it something a little longer than it can't cope with. >>> pt.code='THISISLONGERTHANFIFTEENCHARS' >>> pt.validate() {} Odd - it validates but we know our code field can only be 15 characters. >>> pt.save() Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.5/site-packages/django/db/models/base.py", line 238, in save db_values + self._meta.pk.get_db_prep_lookup('exact', pk_val)) File "/usr/local/lib/python2.5/site-packages/django/db/backends/util.py", line 18, in execute return self.cursor.execute(sql, params) ProgrammingError: value too long for type character varying(15) BANG! I'd be expecting for Django to tell me before postgres does, that the field does not validate. Am I misunderstanding something? Ian --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Why the default Django transaction way doesn't work?
At first, I tried to search in this group, but only got an un-answered question similar to mine: http://groups.google.com/group/django-users/browse_thread/thread/767716b62a244b33/85b8203990407a6c?lnk=gst=transaction+default#85b8203990407a6c in my settings.py, i am using TransactionMiddleware. and my testing views.py as following: def index(request): c=Myobject.objects.get(pk=45) ###Myobject with a field 'isUpdate' which default value is False. c.isUpdate = True c.save() raise NameError after a request to this index view, I found in database that object's 'isUpdate' was set to True... then I added an decorator: @transaction.commit_on_success def index(request): c=Myobject.objects.get(pk=45) . Then the object won't be changed. I am confused about this, because according to the Django document about transaction, I think the default way is just commit_on_success? or what mistake I have made? 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: using newforms
Figured it out. Just like Kenneth said above, I need a super line where he said. I was also appending the values incorrectly. It should have been GROUP_CHOICES += ((g.id, g.name),) Thanks for the help everyone. On Jan 12, 11:14 am, ocgstyles <[EMAIL PROTECTED]> wrote: > Great. That works. Only problem now, though, is that GROUP_CHOICES > is still [] after the object is instantiated. From a shell I can do > this: > > f = ReferralForm(User.objects.get(username='keith')) > f.fields['field1'].choices = f.GROUP_CHOICES > > And that will populate the field with the right data. How do I do > this in the class itself? > > Keith > > On Jan 12, 6:25 am, shabda <[EMAIL PROTECTED]> wrote: > > > Instead of this > >def __init__(self, user): > > profile = user.get_profile() > > > for g in profile.groups.all(): > > self.GROUP_CHOICES += (g.id, g.name) > > > super(MyForm, self) > > > Should it not be, > >def __init__(self, user, *args, **kwargs): > > profile = user.get_profile() > > > for g in profile.groups.all(): > > self.GROUP_CHOICES += (g.id, g.name) > > > super(MyForm, self).__init__(*args, **kwargs) > > > On Jan 12, 2:18 pm, ocgstyles <[EMAIL PROTECTED]> wrote: > > > > Hi, > > > > I using the newforms library to create a form. I need to know who the > > > current user is so I know which values to display in a dropdown > > > control. So I have this so far: > > > > from django import newforms as forms > > > > class MyForm(forms.Form): > > > GROUP_CHOICES = [] > > > >field1 = forms.ChoiceField(choices=GROUP_CHOICES) > > >field2 = forms.CharField(widget=forms.Textarea()) > > > >def __init__(self, user): > > > profile = user.get_profile() > > > > for g in profile.groups.all(): > > > self.GROUP_CHOICES += (g.id, g.name) > > > > super(MyForm, self) > > > > But when I try to render this in the template > > > ( {{ form.as_table }} ), I get no output. Am I creating this form > > > class incorrectly? > > > > Keith --~--~-~--~~~---~--~~ 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: remove ^M: project moved from window to linux
On 12 Jan 17:47, Lars Stavholm wrote: > > crybaby wrote: > > What is the fastest way to remove ^M from every files in main project > > folder and apps folders. Doing it by hand seems time consuming. Is > > there a simple script take care of this? if I just leave the ^M in > > python code, would it cause problems? > > If you're on a Linux box (you might want to mention > details like that:) you could try to apply the dos2unix > command on each file. > > find . -type f | xargs dos2unix except if you, like me, don't have dos2unix on your linux box... at which point you just do something like: find . -type f | xargs sed -i -s -e 's#\r$##;' HTH, HAND, -- Brett Parker --~--~-~--~~~---~--~~ 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: How to see if current item is in a list
Doh! Yup I forgot that...cheers! :) On Jan 12, 4:17 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Jan 12, 2008 10:59 AM, Darthmahon <[EMAIL PROTECTED]> wrote: > > > > > > > Hey, > > > I want to check if the current item I am printing in one list is also > > available in another list. Basically I have a list of books and I want > > to check if the user already has a particular book in their profile so > > that instead of it saying "Add Book", it says "Remove Book". > > > At the moment I am trying something like this: > > > > > # File: custom_filters.py > > > > @register.filter > > def IN(value,arg): return value in arg > > > > > > > # File: /books/views.py > > > > {% for book in books %} > > {% if book.id|IN:user_profile.books.all %} > > Remove Book > > {% else %} > > Add Book > > {% endif %} > > {% endfor %} > > > > This is really your template file, right, not views.py? > > > user_profile has a many-to-many field relationship so that it gets a > > list of all the books the user has. > > > Basically, I get an error that tells me: > > > Invalid Filter: 'IN' > > > Is there a better way of checking if the current item in the for loop > > is present in another list? > > In my experience "Invalid" whatever from template processing usually means I > forgot to load my custom template tags/filters. So did you include a {% > load custom_filters %} in your template file? > > 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: remove ^M: project moved from window to linux
crybaby wrote: > What is the fastest way to remove ^M from every files in main project > folder and apps folders. Doing it by hand seems time consuming. Is > there a simple script take care of this? if I just leave the ^M in > python code, would it cause problems? If you're on a Linux box (you might want to mention details like that:) you could try to apply the dos2unix command on each file. find . -type f | xargs dos2unix /L --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
remove ^M: project moved from window to linux
What is the fastest way to remove ^M from every files in main project folder and apps folders. Doing it by hand seems time consuming. Is there a simple script take care of this? if I just leave the ^M in python code, would it cause problems? --~--~-~--~~~---~--~~ 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: How to see if current item is in a list
On Jan 12, 2008 10:59 AM, Darthmahon <[EMAIL PROTECTED]> wrote: > > Hey, > > I want to check if the current item I am printing in one list is also > available in another list. Basically I have a list of books and I want > to check if the user already has a particular book in their profile so > that instead of it saying "Add Book", it says "Remove Book". > > At the moment I am trying something like this: > > > # File: custom_filters.py > > @register.filter > def IN(value,arg): return value in arg > > > > # File: /books/views.py > > {% for book in books %} > {% if book.id|IN:user_profile.books.all %} > Remove Book > {% else %} > Add Book > {% endif %} > {% endfor %} > > This is really your template file, right, not views.py? > user_profile has a many-to-many field relationship so that it gets a > list of all the books the user has. > > Basically, I get an error that tells me: > > Invalid Filter: 'IN' > > Is there a better way of checking if the current item in the for loop > is present in another list? In my experience "Invalid" whatever from template processing usually means I forgot to load my custom template tags/filters. So did you include a {% load custom_filters %} in your template file? 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: using newforms
Great. That works. Only problem now, though, is that GROUP_CHOICES is still [] after the object is instantiated. From a shell I can do this: f = ReferralForm(User.objects.get(username='keith')) f.fields['field1'].choices = f.GROUP_CHOICES And that will populate the field with the right data. How do I do this in the class itself? Keith On Jan 12, 6:25 am, shabda <[EMAIL PROTECTED]> wrote: > Instead of this >def __init__(self, user): > profile = user.get_profile() > > for g in profile.groups.all(): > self.GROUP_CHOICES += (g.id, g.name) > > super(MyForm, self) > > Should it not be, >def __init__(self, user, *args, **kwargs): > profile = user.get_profile() > > for g in profile.groups.all(): > self.GROUP_CHOICES += (g.id, g.name) > > super(MyForm, self).__init__(*args, **kwargs) > > On Jan 12, 2:18 pm, ocgstyles <[EMAIL PROTECTED]> wrote: > > > Hi, > > > I using the newforms library to create a form. I need to know who the > > current user is so I know which values to display in a dropdown > > control. So I have this so far: > > > from django import newforms as forms > > > class MyForm(forms.Form): > > GROUP_CHOICES = [] > > >field1 = forms.ChoiceField(choices=GROUP_CHOICES) > >field2 = forms.CharField(widget=forms.Textarea()) > > >def __init__(self, user): > > profile = user.get_profile() > > > for g in profile.groups.all(): > > self.GROUP_CHOICES += (g.id, g.name) > > > super(MyForm, self) > > > But when I try to render this in the template > > ( {{ form.as_table }} ), I get no output. Am I creating this form > > class incorrectly? > > > Keith --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
How to see if current item is in a list
Hey, I want to check if the current item I am printing in one list is also available in another list. Basically I have a list of books and I want to check if the user already has a particular book in their profile so that instead of it saying "Add Book", it says "Remove Book". At the moment I am trying something like this: # File: custom_filters.py @register.filter def IN(value,arg): return value in arg # File: /books/views.py {% for book in books %} {% if book.id|IN:user_profile.books.all %} Remove Book {% else %} Add Book {% endif %} {% endfor %} user_profile has a many-to-many field relationship so that it gets a list of all the books the user has. Basically, I get an error that tells me: Invalid Filter: 'IN' Is there a better way of checking if the current item in the for loop is present in another list? Cheers, Chris --~--~-~--~~~---~--~~ 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: displaying errors after form validation
On Jan 12, 2008 6:26 AM, cesco <[EMAIL PROTECTED]> wrote: > > Hi, > > I'm a bit puzzled by the following behaviour of newforms. > > I have a field in the form called 'seller'. > > In the form validation I have a clean_seller method which if a certain > condition is verified will do the following: > > self.errors.update(seller = ErrorList([u"message1: the indicated > seller doesn't exist in our database"])) > raise forms.ValidationError(u"message2: seller doesn't exist") > > In the template I have the following: > > {{ monitor_f.seller.errors|join:", " }} > > I would expect the first message (that is: "message1: the indicated > seller doesn't exist in our database") to be displayed in case of > error and I thought that the forms.ValidationError was just an > exception raised to stop the validation. Instead the second message > (the one contained in forms.ValidationError is displayed). > > Probably there is something I'm missing. Would anyone help me > understand? > From http://www.djangoproject.com/documentation/newforms/#custom-form-and-field-validation : "If you detect multiple errors during a cleaning method and wish to signal all of them to the form submitter, it is possible to pass a list of errors to the ValidationError constructor." So, you can accumulate your list of errors and pass them all to ValidationError at once. 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Custom ForeignKey field validation
On Jan 12, 2008 5:28 AM, David Grant <[EMAIL PROTECTED]> wrote: > I have a simple category model. They will eventually be chapters in a book > and I only want entries to go into child categories, not the roots. Here's > the models: > > class Category(models.Model): > name = models.CharField (max_length=120, blank=True) > parent = models.ForeignKey('self', null=True, blank=True, > related_name='child_set') > > class Content(models.Model): > category = models.ForeignKey(Category) > > So say the categories were like this: > > Languages >-python >-ruby >-C++ > Frameworks > -django > -rails > -j2ee > > I don't want any content to go into the languages or frameworks > categories, only the child ones. Where would the logic to restrict the > choice of category in Content within the admin interface? > Have you looked at the limit_choices_to argument for a ForeignKey ( http://www.djangoproject.com/documentation/model-api/#many-to-one-relationships )? > My best idea so far is to create a sub-class of ForeignKey called > ContentCategoryField and override the validate method. In the validate > method I could look up the id that was entered and see that has a parent id > or not. > > I was also thinking of restricting my categories to be just 2 levels, like > above. I could create a a ParentForCategoryField that overrides ForeignKey > and it could check to make sure that any new category being created does not > have a parent that also has a parent. > > Not sure if I'm on the right track here for a DRY method that will work > with the admin interface and also with newforms (should I decide to make > some of my own admin-like views). Not sure if limit_choices_to will be DRY, since it's admin-specific, but it seems designed to do what you are looking for in the admin interface, at least. 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: WSGI session
On Jan 12, 2008 2:47 AM, kbochert <[EMAIL PROTECTED]> wrote: > > mod_fastcgi installation > > The error is: > 'WSGIRequest' object has no attribute 'session' > > any ideas? > Do you have 'django.contrib.sessions.middleware.SessionMiddleware' listed in MIDDLEWARE_CLASSES in settings.py? If I add lines to the file, the error stays at the same location. > and if I erase the .pyc file, it does not get regenerated. > > How do I cause it to use the newly edited file?? > > I've tried touching the .fcgi file with no luck > I'm not sure what file you are referring to here. At any rate, this doesn't sound like and fcgi-specific problem. 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: using newforms
On 12-Jan-08, at 2:48 PM, ocgstyles wrote: > def __init__(self, user): you need a super line here > profile = user.get_profile() -- regards kg http://lawgon.livejournal.com http://nrcfosshelpline.in/web/ Foss Conference for the common man: http://registration.fossconf.in/web/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Media path when sharing virtual host for two projects
Hi! I've many Django projects that doesn't have any relation. In production I use different domains, so I have different virtual hosts for them, and everything is ok. In development I want to have just one domain, and access all my projects from it. Something like: http://dev.mycompany.com/project1 (that in production will be www.project1.com) http://dev.mycompany.com/project2 ... Structure that I use is something like: /var/www /var/www/project1 /var/www/project1/settings.py /var/www/project1/media /var/www/project1/media/css /var/www/project1/media/img ... /var/www/project2 /var/www/project1/media ... In production I set DocumentRoot to /var/www/project1/media, so I just point to /img/myimage.png for static files. Using Django's documentation setup is great for Django's served pages: ServerName www.example.com # ... SetEnv DJANGO_SETTINGS_MODULE mysite.settings PythonInterpreter mysite SetEnv DJANGO_SETTINGS_MODULE mysite.other_settings PythonInterpreter mysite_other But how can I set where to find media file? If I just add: SetHandler None a request to http://dev.mycompany.com/project1/img/myimage.png will be searched in: /var/www/img/myimage.png (DocumentRoot + link) and should be searched in /var/www/project1/media/img/myimage.png (DocumentRoot + project path from requested url + link) Thanks a lot! Marc --~--~-~--~~~---~--~~ 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: Inserting a date into DateField
Hmm ok, so there is no easy way to do this without using newforms? On Jan 12, 12:56 pm, shabda <[EMAIL PROTECTED]> wrote: > _dob = request.POST['dob'] gets the string representation of dob, and > so python complains as it can't find the strftime method. > You need to change your code to, > _dob = form_name.cleaned_data['date_attribute_name'] > form.cleaned_data, gets you the canonical representation for the data > type depending on the field type declared in the Form class. > (All this assuming you are using newforms) > > On Jan 12, 5:49 pm, Darthmahon <[EMAIL PROTECTED]> wrote: > > > Hi, > > > I'm trying to insert a simple date (2002-01-12) from a form I have > > created into a DateField but I keep getting this error: > > > 'str' object has no attribute 'strftime' > > > This is how the DateField is setup in my models.py file: > > > birthday = models.DateField(blank=True) > > > This is how I am trying to write to this field: > > > _dob = request.POST['dob'] > > user_profile = > > UserProfile(user_id=user.id,gender=_gender,birthday=_dob,living=_location) > > user_profile.save() > > > In my form I am writing the date like this: > > > 2002-01-12 > > > Any ideas? Seems like a basic thing, but can't find a solution > > anywhere. > > > Cheers, > > Chris --~--~-~--~~~---~--~~ 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: Inserting a date into DateField
_dob = request.POST['dob'] gets the string representation of dob, and so python complains as it can't find the strftime method. You need to change your code to, _dob = form_name.cleaned_data['date_attribute_name'] form.cleaned_data, gets you the canonical representation for the data type depending on the field type declared in the Form class. (All this assuming you are using newforms) On Jan 12, 5:49 pm, Darthmahon <[EMAIL PROTECTED]> wrote: > Hi, > > I'm trying to insert a simple date (2002-01-12) from a form I have > created into a DateField but I keep getting this error: > > 'str' object has no attribute 'strftime' > > This is how the DateField is setup in my models.py file: > > birthday = models.DateField(blank=True) > > This is how I am trying to write to this field: > > _dob = request.POST['dob'] > user_profile = > UserProfile(user_id=user.id,gender=_gender,birthday=_dob,living=_location) > user_profile.save() > > In my form I am writing the date like this: > > 2002-01-12 > > Any ideas? Seems like a basic thing, but can't find a solution > anywhere. > > Cheers, > Chris --~--~-~--~~~---~--~~ 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: Inserting a date into DateField
On Jan 12, 1:49 pm, Darthmahon <[EMAIL PROTECTED]> wrote: > Hi, > > I'm trying to insert a simple date (2002-01-12) from a form I have > created into a DateField but I keep getting this error: > > 'str' object has no attribute 'strftime' > > This is how the DateField is setup in my models.py file: > > birthday = models.DateField(blank=True) > > This is how I am trying to write to this field: > > _dob = request.POST['dob'] > user_profile = > UserProfile(user_id=user.id,gender=_gender,birthday=_dob,living=_location) > user_profile.save() > Try this: user_profile = UserProfile(request.POST) if user_profile.is_valid(): user_profile.save() else: ... Best regards, l. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Inserting a date into DateField
Hi, I'm trying to insert a simple date (2002-01-12) from a form I have created into a DateField but I keep getting this error: 'str' object has no attribute 'strftime' This is how the DateField is setup in my models.py file: birthday = models.DateField(blank=True) This is how I am trying to write to this field: _dob = request.POST['dob'] user_profile = UserProfile(user_id=user.id,gender=_gender,birthday=_dob,living=_location) user_profile.save() In my form I am writing the date like this: 2002-01-12 Any ideas? Seems like a basic thing, but can't find a solution anywhere. Cheers, Chris --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Integrating TinyMCE in django.contrib.flatpages
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Hi I'm trying to use TinyMCE within flatpages. I followed the instructions given on code.djangoproject.com http://code.djangoproject.com/wiki/AddWYSIWYGEditor but TinyMCE won't show up (Tested with Opera + Konqueror + Iceweasel(Firefox)). Currently I'm serving TinyMCE from my apache and my Django Project from the test-server but serving both from apache doesn't change anything. I could not make the site available as for now the production webserver isn't set up for django. Christoph -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHiKmhy7PXBwNyJ10RChoAAJ4p5FJ9jXU9wuz9f7gEbSVFfY4xHgCggJf9 vks6aYXNK3/g/0Hys3ml/Pg= =Xd79 -END PGP SIGNATURE- --~--~-~--~~~---~--~~ 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: Manually Inserting Non Field Errors in a newform
Override __init__ for the Form, passing it the request object and store it. Access it in .clean method. On Jan 12, 10:45 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I also just realized that the reason clean() wouldn't work when I > tried to pass it the request as an argument is simply because this > required me to call clean() by itself and thus the errors raised > within it aren't properly inherited (and thus reflected when the form > is reloaded) when clean() is called outside of is_valid() > > On Jan 11, 9:24 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: > > > Thanks Karen, > > > I did initially want to raise it in the clean method but what I'm > > trying to do this is validate that cookies are enabled thus requiring > > access to the request object. I first tried to pass it to clean which > > really doesn't seem like a clean way to do it - no pun intended - > > anyway, since usually I would just want clean() to be called when I > > called form.is_valid() and I cannot pass any arguments that way, but > > in any case that didn't really work out (def clean(self,request) would > > complain about the number of arguments being too many - 3 instead of 2 > > - when I attempted to pass in the request object) Granted, I didn't > > try this for as long as the other method. > > > If you have suggestions for how to pass arguments to clean() in a > > better way that would be another workaround for this issue. Basically > > I wanted to raise cookie errors from within the form handling so I > > didnt have to redirect to another page or implement some custom thing > > in the template. (I am however open to doing this if it is the better > > solution, I'm just not sure what best practice here would be). > > > On Jan 11, 8:21 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > > > > On Jan 11, 2008 10:49 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > > I want to manually insert an error into a form from the view using > > > > f.errors (where f is the form in question). For a specific field this > > > > is easy (f.errors['fieldname'] = u'my error here') but I can't seem to > > > > figure out how to make non field errors work. Is there a special > > > > dictionary entry for non field errors, or some other way to do this. I > > > > had a look at the django code but didn't get much further here. Any > > > > suggestions are appreciated. > > > > Take a look at the doc for the Form subclass's clean() method here: > > > >http://www.djangoproject.com/documentation/newforms/#custom-form-and-... > > > > It would be cleaner to raise the error in a clean() method, but I think > > > the > > > doc includes the information you need to manipulate it yourself if you > > > really want to. (Note you can also customize the error messages for > > > fields, > > > which could get around having to manipulate f.errors['fieldname'] > > > directly, > > > see:http://www.djangoproject.com/documentation/newforms/#error-messages.) > > > > 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Working with object paginator
Ove of my view function is, def recently_featured (request): featured = FeaturedPage.objects.all().order_by('-ordering') paged_featured = ObjectPaginator(featured, djikikisettings.details_per_page) try: page_num = request.GET['page'] page_num = int(page_num) except: page_num = 0 next_page = page_num + 1 prev_page = page_num - 1 featured = paged_featured.get_page(page_num) has_next = paged_featured.has_next_page(page_num) has_previous = paged_featured.has_previous_page(page_num) payload = {'featured':featured, 'has_next':has_next, 'has_previous':has_previous, 'next_page':next_page, 'prev_page':prev_page} return render(request, 'djikiki/featured.html', payload) I need to do something similar whenever I need to paginate a queryset, and the logic to paginate is longer than the view function. If instead we an api like, paged_featured = ObjectPaginator(featured, djikikisettings.details_per_page) featured = paged_featured.get_page(page_num) And then has_next/has_prev/next_page_num/prev_page_num were methods with the object returned by get_page(here featured), we can have a much simpler way to access the required things in the template. Or am I missing some thing obvious? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
displaying errors after form validation
Hi, I'm a bit puzzled by the following behaviour of newforms. I have a field in the form called 'seller'. In the form validation I have a clean_seller method which if a certain condition is verified will do the following: self.errors.update(seller = ErrorList([u"message1: the indicated seller doesn't exist in our database"])) raise forms.ValidationError(u"message2: seller doesn't exist") In the template I have the following: {{ monitor_f.seller.errors|join:", " }} I would expect the first message (that is: "message1: the indicated seller doesn't exist in our database") to be displayed in case of error and I thought that the forms.ValidationError was just an exception raised to stop the validation. Instead the second message (the one contained in forms.ValidationError is displayed). Probably there is something I'm missing. Would anyone help me understand? Many thanks Francesco --~--~-~--~~~---~--~~ 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: using newforms
Instead of this def __init__(self, user): profile = user.get_profile() for g in profile.groups.all(): self.GROUP_CHOICES += (g.id, g.name) super(MyForm, self) Should it not be, def __init__(self, user, *args, **kwargs): profile = user.get_profile() for g in profile.groups.all(): self.GROUP_CHOICES += (g.id, g.name) super(MyForm, self).__init__(*args, **kwargs) On Jan 12, 2:18 pm, ocgstyles <[EMAIL PROTECTED]> wrote: > Hi, > > I using the newforms library to create a form. I need to know who the > current user is so I know which values to display in a dropdown > control. So I have this so far: > > from django import newforms as forms > > class MyForm(forms.Form): > GROUP_CHOICES = [] > >field1 = forms.ChoiceField(choices=GROUP_CHOICES) >field2 = forms.CharField(widget=forms.Textarea()) > >def __init__(self, user): > profile = user.get_profile() > > for g in profile.groups.all(): > self.GROUP_CHOICES += (g.id, g.name) > > super(MyForm, self) > > But when I try to render this in the template > ( {{ form.as_table }} ), I get no output. Am I creating this form > class incorrectly? > > Keith --~--~-~--~~~---~--~~ 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: Middleware for checking client info and many other queries
thanks UDI, this is waht I needed to some extent. On Jan 9, 2008 3:16 PM, Udi <[EMAIL PROTECTED]> wrote: > > Re: #2 > > I wouldn't worry about it. > http://aspn.activestate.com/ASPN/Mail/Message/python-list/998253 > > Re: #4 > > http://www.djangosnippets.org/snippets/358/ > http://code.djangoproject.com/wiki/PageStatsMiddleware > > > > > On Jan 8, 12:35 am, "Ravi Kumar" <[EMAIL PROTECTED]> wrote: > > Hi, > > This is my First post to the group. I started devotion to Python > recently, > > and now I have to implement Django (which came out to be something I was > > needing as framework). Familiar with Django basics and some core > features, I > > am still looking for some knwoledge base for certain issues. > > > > 1. I need a middleware intercepting request, and finding if client > request > > has cookies in it. If not, then I want to redirect that request to a > page > > which serves a page with some user states (such as random unique uid > > assigned so his navigation and page accesses can be recorded). The page > > would use Javascript to redirect to the requested page (one the user > > requested along with information such as Flash installed, versions, > > Browsers(though browsers can also be fetched from the request header), > > Client Platform, Java installed or not etc. > > When the requested page finds the cookie info, it would better render > the > > page with flash components/ads whatever, else serve the static picture. > > In case the client has no javascript enabled, the page header to auto > > redirect would come into effect. Something like such. > > So what I need, one middleware for intercepting the request and check > the > > cookie. > > > > 2. I want to know how much impact does exception handling has on > > performance. if i have 3-4 try-except handlings, will it take a > considerably > > more time. (just infomation, though otimization is not a initial > > consideration). > > > > 3. I was reading some pros-cons about Django. I came to know Django has > a > > memory problem in deployment environment, leaked memory. I also read > many > > articles regarding how to prevent such leakage and hogging. I found some > > good points in configuring APache. BUt i could not find one official doc > > where deployment on Apache+mod_python is described in detail with > various > > conditions and environments. It took me almost 5hrs to study and > configure > > media/static content serving with Apache default rather than going > through > > Django. BUt still I am looking for something much better. > > Is there any pointer which I failed to look into for such thing? > > Is Django memory problem still present or is patched? > > > > 4. HOw can i enable get a benchmarking context such as "Page rendered on > > 0.0034 seconds " in Django. Is there somethign available. > > > > Hmm, since i asked so may question in Just a single mail, I am sorry. > But i > > was excited and could not sleep well in night. I have a presentation > > tomorrow to team handling our company sites and high profile personnel > for > > better Website. Excited, I challenged the big guys... I can't find what > to > > present, i have something in mind, so just finding the answers to these > > problems which would help me formulate the final presentation structure. > > > > -- > > -=Ravi=- > > > -- -=Ravi=- --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Custom ForeignKey field validation
I have a simple category model. They will eventually be chapters in a book and I only want entries to go into child categories, not the roots. Here's the models: class Category(models.Model): name = models.CharField(max_length=120, blank=True) parent = models.ForeignKey('self', null=True, blank=True, related_name='child_set') class Content(models.Model): category = models.ForeignKey(Category) So say the categories were like this: Languages -python -ruby -C++ Frameworks -django -rails -j2ee I don't want any content to go into the languages or frameworks categories, only the child ones. Where would the logic to restrict the choice of category in Content within the admin interface? My best idea so far is to create a sub-class of ForeignKey called ContentCategoryField and override the validate method. In the validate method I could look up the id that was entered and see that has a parent id or not. I was also thinking of restricting my categories to be just 2 levels, like above. I could create a a ParentForCategoryField that overrides ForeignKey and it could check to make sure that any new category being created does not have a parent that also has a parent. Not sure if I'm on the right track here for a DRY method that will work with the admin interface and also with newforms (should I decide to make some of my own admin-like views). -- David Grant http://www.davidgrant.ca --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
lincoln
http://www.lincoln.cba.pl --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
using newforms
Hi, I using the newforms library to create a form. I need to know who the current user is so I know which values to display in a dropdown control. So I have this so far: from django import newforms as forms class MyForm(forms.Form): GROUP_CHOICES = [] field1 = forms.ChoiceField(choices=GROUP_CHOICES) field2 = forms.CharField(widget=forms.Textarea()) def __init__(self, user): profile = user.get_profile() for g in profile.groups.all(): self.GROUP_CHOICES += (g.id, g.name) super(MyForm, self) But when I try to render this in the template ( {{ form.as_table }} ), I get no output. Am I creating this form class incorrectly? Keith --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---