django built-in web server
hi, Can I use the django's built in web server in an intranet enviroment where the maximum users could be not more than 50 users? I am just asking this for the purpose for easy deployment :). I am very newbie, and trying to avoid apache THanks james --~--~-~--~~~---~--~~ 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 styling
On Aug 9, 2007, at 10:21 PM, james_027 wrote: > > hi, > > is there any advantage or disadvantage or best practices in forming > urls? like which set are much better? > > domain/employee/1 > domain/edit_employee/1 > domain/inactive_employee/1 > > or > > domain/employee/1 > domain/employee/1/edit/ > domain/employee/1/inactive/ > Better is always subjective. From a technical perspective, here is what the URL patterns look like: a) simple form r'domain/(?:(\w+)_)?(\w+)/(\d+)' one where you get all of the items nicely named: r'domain/(?:(?P\w+)_)?(?P\w+)/(?P\d+)' b) r'domain/(\w+)/(\d+)(?:/(\w+))?' r'domain/(?P\w+)/(?P\d+)(?:/(?P\w+))?' I see the first URL set as being function oriented and the second set being more object oriented. Just depends on how you prefer to see the world I suppose. Personally, I would probably do the second one. May I suggest the first choice get turned around slightly: domain/employee_edit/1 Like I said, I see the first grouping as more functional style and it is good practice to name the object first in function names. You end up with a regex like this: r'domain/(?P\w+)(?:_(?P\w+))?/(?P\d+)' which reads better in my opinion. BTW, the (?:) syntax lets you group things without adding more items to the groupdict result. Purely optional, I just like to be really explicit about my regexes. --~--~-~--~~~---~--~~ 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: Is this not allowed select_related()
THanks Doug > > class Employee(models.Model): > # your employee model fields here, no FKs to Contact or > Assignment models > ... > > class EmployeeAssignment(models.Model): > active = models.BooleanField() # I added this > employee = models.ForeignKey(Employee) > ... > > class EmployeeContract(models.Model): > active = models.BooleanField() # I added this > employee = models.ForeignKey(Employee) > ... > > then you could do > > bob = Employee.objects.get(pk=1) > current_contacts = bob.employeecontract_set.filter(active=True) > current_assignments = bob.employeassignment_set.filter(active=True) > > I added the active flag to differentiate history vs current cheers, james --~--~-~--~~~---~--~~ 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: scheduling job
Try creating a cron job. On Fri, 2007-08-10 at 06:42 +, james_027 wrote: > hi, > > This might not be a django stuff, but how could I write something that > will execute itself depending on the frequency that I'll set. For > example, since django session table needs to be clean up at a certain > time, I want to write a script that will execute itself monthly to > clean up the session table. > > Thanks > james > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
scheduling job
hi, This might not be a django stuff, but how could I write something that will execute itself depending on the frequency that I'll set. For example, since django session table needs to be clean up at a certain time, I want to write a script that will execute itself monthly to clean up the session table. Thanks james --~--~-~--~~~---~--~~ 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 styling
I think the second is better because you're being consistent in your hierarchy order. IE you're going from least specific to most specific: domain -> object -> instance ->action Instead, in the first one you're going: domain -> action -> object -> instance Then again, it's purely preference. On Aug 10, 1:21 am, james_027 <[EMAIL PROTECTED]> wrote: > hi, > > is there any advantage or disadvantage or best practices in forming > urls? like which set are much better? > > domain/employee/1 > domain/edit_employee/1 > domain/inactive_employee/1 > > or > > domain/employee/1 > domain/employee/1/edit/ > domain/employee/1/inactive/ > > thanks > james --~--~-~--~~~---~--~~ 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 on Linux, MS SQL on Windoz
Hi, There is currently no fully working backend for mssql, but someone is working on it already (and I am sure he will need some testers). If I am not mistaken there is also http://pymssql.sourceforge.net/ I hope this helps, Florian On Aug 9, 7:10 pm, [EMAIL PROTECTED] wrote: > Is it possible to run a django web server on a nix box and communicate > with a MS-SQL (2000) database on a Windoz 2003 server. I am looking > for a good python framework, and django seems like it might be the > one, but if it can't do this, that could be a show stopper. From what > I have seen, there is only the adodapi that you can use to connect to > sql server (and it may not be great), and I believe that has to run on > a doz box. > > I am trying to migrate away from windows, thus the desired > implementation above. Plan won't work if I have to run django on a > windows box. > > Help anyone ... > > Thanks, > > Peter --~--~-~--~~~---~--~~ 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: Is this not allowed select_related()
maybe something like this... class Employee(models.Model): # your employee model fields here, no FKs to Contact or Assignment models ... class EmployeeAssignment(models.Model): active = models.BooleanField() # I added this employee = models.ForeignKey(Employee) ... class EmployeeContract(models.Model): active = models.BooleanField() # I added this employee = models.ForeignKey(Employee) ... then you could do bob = Employee.objects.get(pk=1) current_contacts = bob.employeecontract_set.filter(active=True) current_assignments = bob.employeassignment_set.filter(active=True) I added the active flag to differentiate history vs current --~--~-~--~~~---~--~~ 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 styling
hi, is there any advantage or disadvantage or best practices in forming urls? like which set are much better? domain/employee/1 domain/edit_employee/1 domain/inactive_employee/1 or domain/employee/1 domain/employee/1/edit/ domain/employee/1/inactive/ thanks james --~--~-~--~~~---~--~~ 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: Two Things
Thanks Mike. -LJ On Aug 10, 12:23 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > New to the group, so I thought I'd post my favorite > > Django video:http://video.google.com/videoplay?docid=-70449010942275062 > Django > book:http://www.amazon.com/Pro-Django-Development-Done-Right/dp/1590597257... > > Cheers, > > Mike --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Two Things
New to the group, so I thought I'd post my favorite Django video: http://video.google.com/videoplay?docid=-70449010942275062 Django book: http://www.amazon.com/Pro-Django-Development-Done-Right/dp/1590597257/ref=pd_bbs_sr_1/104-7275500-7139960?ie=UTF8&s=books&qid=1186719760&sr=8-1 Cheers, Mike --~--~-~--~~~---~--~~ 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: ReStructuredText, markdown and other
Hi all I tried out all three for an application that I was writing. This would be used by non-computer persons for a wiki thing. * I liked Markdown syntax as it was very readable. It did not have support for a simple table syntax - for that you use normal HTML. Likewise you can insert HTML div tags and css in there. * REST has very good table support but can't take things like and I didn't like the syntax. * Textiles syntax isn't as 'text like' as Markdown but it's got tables and you can add any style info after an element like table{border: 1px solid red} Hence Textile won out over Markdown for me as I absolutely had to have tables. - [EMAIL PROTECTED] wrote: > I'm watching on some light markup languages that can be used in Python > - what they can and what they can't do. I'm planning to use one in a > "sandbox" on my sites and more or less in other apps with some extra > plugins. > > Markdown: > + simple, easy to understand > + there is showdown - markdown in JS so online preview :) (http:// > www.attacklab.net/showdown-gui.html) > - limited syntax (no tables) > - hard to extend > > ReST: > + powerfull syntax > + rather easy to extend > - not so obvious syntax in some places > - errors on bad syntax > > Textile: > + powerfull syntax > + looks quite good > ? never used it, > ? are there some extras ? > > Currently I'm on Markdown + my template filter on top of it buy maybe > it's better to use python-born ReST? What are your experiences with > them? > > > > > -- Michael Lake Computational Research Support Unit Science Faculty, UTS Ph: 9514 2238 --~--~-~--~~~---~--~~ 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: Newforms validations & request.user
Hi, On 8/9/07, Collin Grady <[EMAIL PROTECTED]> wrote: > > Add an __init__ function to your form that you can pass request to. > > def __init__(self, request=None, *args, **kwargs): > self.request = request > super(MyForm, self).__init__(*args, **kwargs) > > Something like that should work to add request to the form, and you > can then use it in the clean_fieldname functions :) Is this the recommended way to do this sort of thing? I had created a view that returns a json/ajax/whatever response and called it via javascript to get the old password. Thanks :) Kai --~--~-~--~~~---~--~~ 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: pagination for search result ...
hi, On Aug 10, 11:25 am, "Kai Kuehne" <[EMAIL PROTECTED]> wrote: > On 8/10/07, james_027 <[EMAIL PROTECTED]> wrote: > > > > > > > hi, > > > > def list_filter(request): > > > """Update session filter""" > > > # request['filter'] is a hidden field. frankly, I don't know if > > > this is really needed. > > > # I added it in case I add another form to the template > > > if request.method == 'POST' and request['filter'] == '1': > > > request.session['filter_title'] = request.POST['title'] > > > request.session['filter_genre'] = request.POST['genre'] > > > request.session['filter_rating'] = request.POST['rating'] > > > return HttpResponseRedirect('/') > > > thanks kai :). is this request['filter'] a django builtin or u just > > created it? > > No, I added it. It's a hidden field just to check that's the filter > that is fired up and not another form on the page. > > To tell the truth, this should be request.POST['filter'] and I > don't really know why request['filter'] worked. Thanks for > pointing that out. :-) > > Kai THanks for all of this! cheers, james --~--~-~--~~~---~--~~ 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: Is this not allowed select_related()
hi collin, On Aug 10, 11:26 am, Collin Grady <[EMAIL PROTECTED]> wrote: > What do you mean by "get the history" ? the employee could have new contract & assignment as months goes by. the employee_contract & employee_assignment tells of their recent contract & assignment. while the employee attribute on the EmployeeContract & EmployeeAssignment will make the getting of employee contracts & assignment history possible. Thanks james --~--~-~--~~~---~--~~ 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 Filter on a list of objects?
AlrightI'm sorry guys this is taking so long to get figured out. I'm trying my best. It a lot shorter than when I started and I'm no longer using any for statements. Here is my view: def searchresult(request): if request.method == 'POST': NOT_PICKED = "---" y = Choice.objects.all() if ('price' in request.POST and request.POST['price'] <> NOT_PICKED): y = y.filter(price__price_cat=request['price']) if ('size' in request.POST and request.POST['size'] <> NOT_PICKED): y = y.filter(size__size_cat=request['size']) choice_ids = [c.id for c in y] styles = Style.objects.filter(sandp__choice__in=choice_ids).distinct() if ('color' in request.POST) and (request.POST['color'] <> NOT_PICKED): styles = styles.filter(color_cat=request['color']) return render_to_response('searchresult.html', {'s': styles}) I'm having a couple of problems with this code. First is the following code: y = y.filter(price__price_cat=request['price']) I currently have two prices in the 200-299 range (249 and 299). If the user does a search for price between 200-299 then the only thing this filter returns is the first one. I never returns more than one. For example when i do a assert False, y after the statement above I get: AssertionError at /rugs/searchresult/ [, )>] I do have a record in my choice table that has 249 as the price. /// Second. The following code doesn't seem to work correctly choice_ids = [c.id for c in y] styles = Style.objects.filter(sandp__choice__in=choice_ids).distinct() This returns [] even though in myexample choice_ids = [7] Here is my Style Class: class Style(models.Model): name = models.CharField(maxlength=200, core=True) color = models.CharField(maxlength=100) color_cat = models.ForeignKey(ColorCategory) image = models.ImageField(upload_to='site_media/') mimage = models.ImageField(upload_to='site_media/thumbnails', editable=False) simage = models.ImageField(upload_to='site_media/thumbnails', editable=False) theslug = models.SlugField(prepopulate_from=('name',)) manufacturer = models.ForeignKey(Manufacturer) collection = models.ForeignKey(Collection, edit_inline=models.TABULAR, num_in_admin=6) sandp = models.ManyToManyField(Choice) // Thanks again for the help On Aug 9, 5:52 pm, RajeshD <[EMAIL PROTECTED]> wrote: > Hi Greg, > > > myset.add(styles) > > You don't need the myset part anymore. > > > It's bringing back the right records (not filtered though), however > > they are not visible. Probably because of a list within a list. > > Right. I assume that you were using the set idiom to eliminate > duplicate records of Style. Since the new query does all of that for > you, you can just directly use 'styles' where you previously needed > 'myset'. In other words, this: > > return render_to_response('searchresult.html', {'s': myset}) > > would change to: > > return render_to_response('searchresult.html', {'s': styles}) --~--~-~--~~~---~--~~ 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: Is this not allowed select_related()
What do you mean by "get the history" ? --~--~-~--~~~---~--~~ 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: pagination for search result ...
On 8/10/07, james_027 <[EMAIL PROTECTED]> wrote: > > hi, > > > def list_filter(request): > > """Update session filter""" > > # request['filter'] is a hidden field. frankly, I don't know if > > this is really needed. > > # I added it in case I add another form to the template > > if request.method == 'POST' and request['filter'] == '1': > > request.session['filter_title'] = request.POST['title'] > > request.session['filter_genre'] = request.POST['genre'] > > request.session['filter_rating'] = request.POST['rating'] > > return HttpResponseRedirect('/') > > > > thanks kai :). is this request['filter'] a django builtin or u just > created it? No, I added it. It's a hidden field just to check that's the filter that is fired up and not another form on the page. To tell the truth, this should be request.POST['filter'] and I don't really know why request['filter'] worked. Thanks for pointing that out. :-) Kai --~--~-~--~~~---~--~~ 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: Multi field validation with clean method
Reverse the field order in the form, otherwise not that I'm aware of. --~--~-~--~~~---~--~~ 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: pagination for search result ...
hi, > def list_filter(request): > """Update session filter""" > # request['filter'] is a hidden field. frankly, I don't know if > this is really needed. > # I added it in case I add another form to the template > if request.method == 'POST' and request['filter'] == '1': > request.session['filter_title'] = request.POST['title'] > request.session['filter_genre'] = request.POST['genre'] > request.session['filter_rating'] = request.POST['rating'] > return HttpResponseRedirect('/') > thanks kai :). is this request['filter'] a django builtin or u just created it? james --~--~-~--~~~---~--~~ 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: Is this not allowed select_related()
hi, On Aug 9, 11:37 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > He means that you can remove: > > employee = models.ForeignKey(Employee) > > from your 'EmployeeAssignment' and 'EmployeeContract' models because > the relationship is already defined in your 'Employee' model. You can > use reverse relations to get the relation instead. > when i remove the employee = models.ForeignKey(Employee), how can I get the history of employee contract & assignment? THanks james --~--~-~--~~~---~--~~ 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: pagination for search result ...
Hi, On 8/10/07, james_027 <[EMAIL PROTECTED]> wrote: > Hi Kai, > Could you share you code how your save your filter in session? Yes: def list_filter(request): """Update session filter""" # request['filter'] is a hidden field. frankly, I don't know if this is really needed. # I added it in case I add another form to the template if request.method == 'POST' and request['filter'] == '1': request.session['filter_title'] = request.POST['title'] request.session['filter_genre'] = request.POST['genre'] request.session['filter_rating'] = request.POST['rating'] return HttpResponseRedirect('/') > THanks > james Greetings :) Kai --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
fastcgi process trouble
We have been experiencing fastcgi processes dying. The error in the lighttpd log is unexpected end-of-file (perhaps the fastcgi process died): pid: 0 socket: unix:/usr1/local/oper/class.sock 2007-08-09 12:10:33: (mod_fastcgi.c.3215) response not received, request sent: 641 on socket: unix:/usr1/local/oper/class.sock for / mysite.fcgi , closing connection Another message is 2007-08-09 12:10:32: (mod_fastcgi.c.3215) response not received, request sent: 641 on socket: unix:/usr1/local/oper/class.sock for / mysite.fcgi , closing connection 2007-08-09 12:10:32: (mod_fastcgi.c.2964) write failed: Broken pipe 32 This all seems to happen as the load increases. The fix the problem we have to kill and restart the manange.py --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
context processors execution
hi, Are the context processors executed only when you pass a request context from view to template? The documentation mentions that a requestcontext could accept an optional argument which is a context processor, is it the same as putting the context processor in the context processor settings but only gets executed when as requested by the requestcontext? Thanks james --~--~-~--~~~---~--~~ 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: Activating the admin site
config your apache site-enable/* files On 8/10/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Hi, > > While I was following the tutorial 2 available at > http://www.djangoproject.com/documentation/0.95/tutorial02/ , I ran > into another problem. > > I did all the three steps in the tutorial: > * Add "django.contrib.admin" to your INSTALLED_APPS setting. > * Run python manage.py syncdb. Since you have added a new > application to INSTALLED_APPS, the database tables need to be updated. > * Edit your mysite/urls.py file and uncomment the line below > "Uncomment this for admin:". This file is a URLconf; we'll dig into > URLconfs in the next tutorial. For now, all you need to know is that > it maps URL roots to applications. > > But, when point my web browser to "http://edtech.soe.ku.edu/admin";, I > got 404 error: > Not Found > > The requested URL /admin/ was not found on this server. > Apache/2.2.3 (Ubuntu) mod_python/3.2.10 Python/2.5.1 PHP/5.2.1 Server > at edtech.soe.ku.edu Port 80 > > Can anyone help me solve this problem? > > Thanks in advance. > > Young-Jin Lee > > > > > -- [EMAIL PROTECTED] 13585201588 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
ReStructuredText, markdown and other
I'm watching on some light markup languages that can be used in Python - what they can and what they can't do. I'm planning to use one in a "sandbox" on my sites and more or less in other apps with some extra plugins. Markdown: + simple, easy to understand + there is showdown - markdown in JS so online preview :) (http:// www.attacklab.net/showdown-gui.html) - limited syntax (no tables) - hard to extend ReST: + powerfull syntax + rather easy to extend - not so obvious syntax in some places - errors on bad syntax Textile: + powerfull syntax + looks quite good ? never used it, ? are there some extras ? Currently I'm on Markdown + my template filter on top of it buy maybe it's better to use python-born ReST? What are your experiences with them? --~--~-~--~~~---~--~~ 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: pagination for search result ...
Hi Kai, > > Do you mean that the filter works on the first page but > is lost when you go to another page? If yes: > I save my filter in a session and filter on each page using > that filter values (the values that were given to the input fields > of the filter form). I don't know whether this is the right way (tm) > but it works for me. :-) > Could you share you code how your save your filter in session? THanks james --~--~-~--~~~---~--~~ 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: Multi field validation with clean method
So, if I use clean_annotationvalue to do both how would I be able to put an error message on the annotation type when a value is entered but no annotation type is entered. Wouldn't that error message appear under the annotationvalue field Jeff -- Original message -- From: Collin Grady <[EMAIL PROTECTED]> > > The clean_foo functions are run in order. > > So in your situation, clean_annotationtype will only have access to > the annotationtype value, but clean_annotationvalue will be able to > see both, since clean_annotationtype has already been run. > > > > --~--~-~--~~~---~--~~ 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: Multi field validation with clean method
The clean_foo functions are run in order. So in your situation, clean_annotationtype will only have access to the annotationtype value, but clean_annotationvalue will be able to see both, since clean_annotationtype has already been run. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Activating the admin site
Hi, While I was following the tutorial 2 available at http://www.djangoproject.com/documentation/0.95/tutorial02/ , I ran into another problem. I did all the three steps in the tutorial: * Add "django.contrib.admin" to your INSTALLED_APPS setting. * Run python manage.py syncdb. Since you have added a new application to INSTALLED_APPS, the database tables need to be updated. * Edit your mysite/urls.py file and uncomment the line below "Uncomment this for admin:". This file is a URLconf; we'll dig into URLconfs in the next tutorial. For now, all you need to know is that it maps URL roots to applications. But, when point my web browser to "http://edtech.soe.ku.edu/admin";, I got 404 error: Not Found The requested URL /admin/ was not found on this server. Apache/2.2.3 (Ubuntu) mod_python/3.2.10 Python/2.5.1 PHP/5.2.1 Server at edtech.soe.ku.edu Port 80 Can anyone help me solve this problem? Thanks in advance. Young-Jin Lee --~--~-~--~~~---~--~~ 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 with modpython in Ubuntu
I cannot explain it, I was able to solve this problem by deleting cache of my browser. Young-Jin On Aug 9, 12:53 pm, John <[EMAIL PROTECTED]> wrote: > It would appear to > Be a problem with your cookie.py > File.In order for me to help you further I will need > To see The source of said file > > John Menerick > > Sent from my iPhone > > On Aug 9, 2007, at 9:03 AM, "[EMAIL PROTECTED]" <[EMAIL PROTECTED] > > > wrote: > > > Dear all, > > > I have a problem using mod_python with Django (v 0.95) under apache2 > > in Ubunu. > > I followed all the steps described in the online documentation, but it > > did not work. > > The followins is how I set up the httpd.conf and error message I got. > > > httpd.conf: > > DirectoryIndex index.php index.html index.htm > > AcceptPathInfo on > > > > >SetHandler python-program > >PythonHandler django.core.handlers.modpython > >SetEnv DJANGO_SETTINGS_MODULE mysite.settings > >PythonDebug On > >PythonPath "['/home/yjlee/Worx/Django/Projects'] + sys.path" > > > > > I created a project with "django-admin.py startproject mysite" at "/ > > home/yjlee/Worx/Django/Projects" directory. > > > When I pointed my web browser to "http://edtech.soe.ku.edu/mysite/"; > > I got the following error messages: > > Mod_python error: "PythonHandler django.core.handlers.modpython" > > > Traceback (most recent call last): > > > File "/usr/lib/python2.5/site-packages/mod_python/apache.py", line > > 299, in HandlerDispatch > >result = object(req) > > > File "/var/lib/python-support/python2.5/django/core/handlers/ > > modpython.py", line 163, in handler > >return ModPythonHandler()(req) > > > File "/var/lib/python-support/python2.5/django/core/handlers/ > > modpython.py", line 136, in __call__ > >response = self.get_response(req.uri, request) > > > File "/var/lib/python-support/python2.5/django/core/handlers/ > > base.py", line 59, in get_response > >response = middleware_method(request) > > > File "/var/lib/python-support/python2.5/django/contrib/sessions/ > > middleware.py", line 69, in process_request > >request.session = > > SessionWrapper(request.COOKIES.get(settings.SESSION_COOKIE_NAME, > > None)) > > > File "/var/lib/python-support/python2.5/django/core/handlers/ > > modpython.py", line 59, in _get_cookies > >self._cookies = > > http.parse_cookie(self._req.headers_in.get('cookie', '')) > > > File "/var/lib/python-support/python2.5/django/http/__init__.py", > > line 150, in parse_cookie > >c.load(cookie) > > > File "Cookie.py", line 619, in load > >self.__ParseString(rawdata) > > > File "Cookie.py", line 650, in __ParseString > >self.__set(K, rval, cval) > > > File "Cookie.py", line 572, in __set > >M.set(key, real_value, coded_value) > > > File "Cookie.py", line 451, in set > >raise CookieError("Illegal key value: %s" % key) > > > CookieError: Illegal key value: hide:inst11 > > > Can anyone help me solve this problem? > > > Thanks in advance. > > > Young-Jin Lee --~--~-~--~~~---~--~~ 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 Filter on a list of objects?
Hi Greg, > myset.add(styles) You don't need the myset part anymore. > It's bringing back the right records (not filtered though), however > they are not visible. Probably because of a list within a list. Right. I assume that you were using the set idiom to eliminate duplicate records of Style. Since the new query does all of that for you, you can just directly use 'styles' where you previously needed 'myset'. In other words, this: return render_to_response('searchresult.html', {'s': myset}) would change to: return render_to_response('searchresult.html', {'s': styles}) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Car Tuning - Styling
Cool cars, tuning & styling, modified cars, many upgrades... http://tuning-styling.blogspot.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 -~--~~~~--~~--~--~---
Solution: using Many-to-Many horizontal interface outside of admin
A number of people, myself included, have asked this list how the admin interface's slick javascript many-to-many widget can be used in templates outside admin. None of the answers given solved the issue for me, but they did point me in the right direction. After a day of reading the source, I was able to get the widget to work with my templates. Here's how I got it working: 1. Get the right javascripts imported. Two script files, "core.js" and "SelectFilter2.js", are needed. Additionally, you must include the jsi18n view generated by admin interface; by default its url is "/admin/jsi18n". 2. Decorate your form field with the "vSelectMultipleField" class attribute. For example, if you had created a form called "form" from your model, and the M2M field was called "foo", you would put this in your view: form.fields['foo'].widget.attrs['class'] = 'vSelectMultipleField' 3. Include javascript in your template to initialize the widget. For our "foo" example, you would insert this line somewhere after {{ form.foo }}: addEvent(window, "load", function(e) { SelectFilter.init("id_tags", "tags", 0, "/media/"); }); In the admin interface, inserting this code is handled by a template tag called "filter_interface_script_maybe". That tag has admin-specific logic, but one could easily write a similar tag for one's own templates. I hope that is helpful. On 6/13/07, Jason McVetta <[EMAIL PROTECTED]> wrote: > > Forgive this question if the answer is overly obvious; but I have not yet > figured it out. I want to use the horizontal M2M widget from the admin > interface in my own template. The model looks like something this: > > class Foo(models.Model): > bars = models.ManyToManyField(Bar, filter_interface=models.HORIZONTAL) > > My views.py looks something like this: > > def myView(request, object_id): >foo = Foo.objects.filter(id=object_id)[0] >FooForm = form_for_instance(foo) >form = FooForm() >rc = template.RequestContext(request) >return render_to_response('path/to/mytemplate.html', {'form': form}, > rc) > > And my template includes a line like: > > Bars: {{ form.bars }} > > While the model alone is sufficient to produce a horizontal filter in the > admin interface, in my template all it displays is a basic HTML select > multiple list. > > I suspect the answer lies in decorating the widget rendered by {{ > form.bars }} with a class or id so the Javascript knows to beautify it, > but I am not sure how to do so. > --~--~-~--~~~---~--~~ 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 Filter on a list of objects?
RajeshD, I implemented what you said. Here is my attempt: choice_ids = [c.id for c in y] styles = Style.objects.filter(sandp__choice__in=choice_ids) if ('color' in request.POST) and (request.POST['color'] <> NOT_PICKED): styles = styles.filter(color_cat=request['color']) myset.add(styles) assert False, myset When it encounters the 'assert False, myset'. I see a set within a list within a list: AssertionError at /rugs/searchresult/ set([[, , , , ]]) // It's bringing back the right records (not filtered though), however they are not visible. Probably because of a list within a list. Thanks On Aug 9, 4:29 pm, RajeshD <[EMAIL PROTECTED]> wrote: > Try changing this fragment: > > for q in y: >styles = Choice.objects.get(id=q.id).style_set.all() > > to something like this: > > choice_ids = [c.id for c in y] > styles = Style.objects.filter(choice__id__in=choice_ids).distinct() > > If that works, you shouldn't need a set or a map to weed out > duplicates. > > Incidentally, set() doesn't do the trick for you because you get two > different instances of the Style model class. Granted that they both > represent the same row of data in your DB but they are still two > different Python object instances unless you add comparison methods in > your Style class that make it seem to Python that they are the same > object. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Multi field validation with clean method
I have run across an issue trying to implement the clean method. I have 2 fields an annotation type and annotation value. I am trying to validate that if one value is entered the other value cannot be blank or empty. Initially, I tried to implement the clean method at the field level. The problem I encounter is that the annotation value does not show up in the cleaned_data in the clean_annotationtype function. This occurs even if I enter data in the annotation value field. The annotation value does appear in the cleaned_data in the clean_annotationvalue function. I can correctly validate both fields when I implement the clean method at the form level. But, I was trying to have the error message appear in either the annotation type or annotation value field depending upon the error message. Would appreciate any direction with this issue. Thanks, Jeff --~--~-~--~~~---~--~~ 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 Filter on a list of objects?
Try changing this fragment: for q in y: styles = Choice.objects.get(id=q.id).style_set.all() to something like this: choice_ids = [c.id for c in y] styles = Style.objects.filter(choice__id__in=choice_ids).distinct() If that works, you shouldn't need a set or a map to weed out duplicates. Incidentally, set() doesn't do the trick for you because you get two different instances of the Style model class. Granted that they both represent the same row of data in your DB but they are still two different Python object instances unless you add comparison methods in your Style class that make it seem to Python that they are the same object. --~--~-~--~~~---~--~~ 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 Filter on a list of objects?
Ok...I'm looking more into sets. Whenever I do a search for products under 3' width. This is what I get when I do a 'assert False, myset': AssertionError at /rugs/searchresult/ set([, , , , , , , ]) I don't understand how the 2 entries of '' and '' are getting put into the list. // I ran some examples through in my python prompt: >>> s = set([1,2,3,4,5,6]) >>> s.add(7) >>> s set([1, 2, 3, 4, 5, 6, 7]) >>> s.add(7) >>> s set([1, 2, 3, 4, 5, 6, 7]) >>> s2 = set([1,2,3,4,5]) >>> s2.add(9) >>> s2 set([1, 2, 3, 4, 5, 9]) >>> s2.add(5) >>> s2 set([1, 2, 3, 4, 5, 9]) I created the same thing using the s2 variable and the s2.add(5) statement wasn't added to the list. It makes me wonder if the two '' and ' objects are different, because based on my example only one of each should be in the list. Thanks On Aug 9, 12:17 pm, Greg <[EMAIL PROTECTED]> wrote: > Tim and Nis, > Okay thanks for the help. My view is definitily better now than > before. Here is my new view > > def searchresult(request): > if request.method == 'POST': > myset = set() > NOT_PICKED = "---" > y = Choice.objects.all() > if ('price' in request.POST and request.POST['price'] <> > NOT_PICKED): > y = y.filter(price__price_cat=request['price']) > if ('size' in request.POST and request.POST['size'] <> > NOT_PICKED): > y = y.filter(size__size_cat=request['size']) > for q in y: > styles = Choice.objects.get(id=q.id).style_set.all() > if ('color' in request.POST) and > (request.POST['color'] <> > NOT_PICKED): > styles = > styles.filter(color_cat=request['color']) > for style in styles: > myset.add(style) > if myset == set([]): > return render_to_response('searchresult_none.html', {'s': "No > product available"}) > else: > return render_to_response('searchresult.html', {'s': myset}) > > > > Does that look any better? I have two issues with this. > > 1) Is there anyway to get it so that I don't have to use the following > for loop: > > for style in styles: > myset.add(style) > > 2) Is still adds duplicate products. If a product contains two > choices that have a price of 149 and 199. Then when a user searches > by price only (100-199) then the product is displayed twice in the > result set. > > > > Thank you SO much for your help!!! This is my first time developing > in Python and I'm learning quite a bit. > > On Aug 9, 8:37 am, Tim Chase <[EMAIL PROTECTED]> wrote: > > > > NO_COLOR = "---" > > > styles = Choice.objects.get(id=h.id).style_set.all() > > > if ('color' in request.POST) and (request.POST['color'] <> NO_COLOR): > > > styles = styles.filter(color_cat=request['color']) > > > for u in styles: > > > dict[u] = u > > > > > > > > I did notice that whenever I do a search for just the color 'brown'. > > > Then the result set will bring back the same style however many > > > different sizes that are in the style. So if an area rug sells two > > > choices (2'x3' 39.00, 4'x6' 149.00). Then that style will show up > > > twice in the result set. Is there anyway better to filter out the > > > styles that have already been added to the dictionary. My previous > > > code worked..but not sure it's the best way to do it. Here it is: > > > > num = 0 > > > for a in dict: > > >if a == j: # 'j' being the name of the style and 'a' is the name of > > > the style that is already in the dictionary > > >num = 1 > > >if num == 0: > > >dict[j] = j > > > I second the suggestion by Nis to make meaningful variable names, > > as well as the suggestion to use sets rather than abusing a > > dictionary (and tromping on the namespace with "dict"...just got > > bitten by this yesterday, a "zip"-code variable shadowed the > > built-in zip() command causing some confusing errors) > > > It looks like you could just do something like > > >results = Choice.objects.get(id=h.id).style_set.all() > ># filter results > >results = set(results) > > > I'm not sure on the performance of set creation, so you might > > compare the results with > > > results = set(list(results)) > > > or > > > results = set(tuple(results)) > > > -tim --~--~-~--~~~---~--~~ 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: Access the request object in a filter?
{% if item|in_cart:request %} --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: about templates tags
Yes, a tag file is a tag library, it does not represent a single tag :) --~--~-~--~~~---~--~~ 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: Newforms validations & request.user
Add an __init__ function to your form that you can pass request to. def __init__(self, request=None, *args, **kwargs): self.request = request super(MyForm, self).__init__(*args, **kwargs) Something like that should work to add request to the form, and you can then use it in the clean_fieldname functions :) --~--~-~--~~~---~--~~ 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: OperationalError 1054 Unknown column
Why did you add _id to your model definition for levelID ? The column does not have that. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Sitemaps - how to add custom links?
Hello I've started to use the django.contrib.sitemaps module, and it works superb for my apps. But, I want to add custom links to it, and not base it entirely on my django-applications.. for example I want to add a entry for my contact form. Is it possible to do this without any major battle with the framework? Thanks! Jan Maximilian --~--~-~--~~~---~--~~ 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 display an error
You cannot do that from save() - you need to add a validator for the admin forms to use, using the validator_list attribute for a field. --~--~-~--~~~---~--~~ 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 display an error
On 8/9/07, Lic. José M. Rodriguez Bacallao <[EMAIL PROTECTED]> wrote: > if I have a model with save method overrided to check if some values in my > model are ok, how can I display the field(s) with errors in red in admin > like django admin does when an error occur with that field(s)? > This is documented. See http://www.djangoproject.com/documentation/forms/ if you are using oldforms. Or look here http://www.djangoproject.com/documentation/newforms/ if you are using newforms. Regards, -- Ramiro Morales --~--~-~--~~~---~--~~ 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 display an error
I think U don't understand the question. What I want is in admin interface, displey the row representing a field with and error in red like ther other normal fields in django, right now I'm checking if the field has errors in the save() method of my model. On 8/9/07, Grupo Django <[EMAIL PROTECTED]> wrote: > > > You can use the shell. > Run python manage.py shell within your project path. > Import your model: > from app.models import foo > f = foo( bar=2 ) > f.save() > > now you can check all the variables you want. f.id returns the id of > the new created object. > > > On Aug 9, 1:29 pm, "Lic. José M. Rodriguez Bacallao" > <[EMAIL PROTECTED]> wrote: > > if I have a model with save method overrided to check if some values in > my > > model are ok, how can I display the field(s) with errors in red in admin > > like django admin does when an error occur with that field(s)? > > > > -- > > Lic. José M. Rodriguez Bacallao > > Cupet > > - > > Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo > > mismo. > > > > Recuerda: El arca de Noe fue construida por aficionados, el titanic por > > profesionales > > - > > > > > -- Lic. José M. Rodriguez Bacallao Cupet - Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo. Recuerda: El arca de Noe fue construida por aficionados, el titanic por profesionales - --~--~-~--~~~---~--~~ 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: [Q] Django with modpython in Ubuntu
It would appear to Be a problem with your cookie.py File.In order for me to help you further I will need To see The source of said file John Menerick Sent from my iPhone On Aug 9, 2007, at 9:03 AM, "[EMAIL PROTECTED]" <[EMAIL PROTECTED] > wrote: > > Dear all, > > I have a problem using mod_python with Django (v 0.95) under apache2 > in Ubunu. > I followed all the steps described in the online documentation, but it > did not work. > The followins is how I set up the httpd.conf and error message I got. > > httpd.conf: > DirectoryIndex index.php index.html index.htm > AcceptPathInfo on > > >SetHandler python-program >PythonHandler django.core.handlers.modpython >SetEnv DJANGO_SETTINGS_MODULE mysite.settings >PythonDebug On >PythonPath "['/home/yjlee/Worx/Django/Projects'] + sys.path" > > > I created a project with "django-admin.py startproject mysite" at "/ > home/yjlee/Worx/Django/Projects" directory. > > When I pointed my web browser to "http://edtech.soe.ku.edu/mysite/"; > I got the following error messages: > Mod_python error: "PythonHandler django.core.handlers.modpython" > > Traceback (most recent call last): > > File "/usr/lib/python2.5/site-packages/mod_python/apache.py", line > 299, in HandlerDispatch >result = object(req) > > File "/var/lib/python-support/python2.5/django/core/handlers/ > modpython.py", line 163, in handler >return ModPythonHandler()(req) > > File "/var/lib/python-support/python2.5/django/core/handlers/ > modpython.py", line 136, in __call__ >response = self.get_response(req.uri, request) > > File "/var/lib/python-support/python2.5/django/core/handlers/ > base.py", line 59, in get_response >response = middleware_method(request) > > File "/var/lib/python-support/python2.5/django/contrib/sessions/ > middleware.py", line 69, in process_request >request.session = > SessionWrapper(request.COOKIES.get(settings.SESSION_COOKIE_NAME, > None)) > > File "/var/lib/python-support/python2.5/django/core/handlers/ > modpython.py", line 59, in _get_cookies >self._cookies = > http.parse_cookie(self._req.headers_in.get('cookie', '')) > > File "/var/lib/python-support/python2.5/django/http/__init__.py", > line 150, in parse_cookie >c.load(cookie) > > File "Cookie.py", line 619, in load >self.__ParseString(rawdata) > > File "Cookie.py", line 650, in __ParseString >self.__set(K, rval, cval) > > File "Cookie.py", line 572, in __set >M.set(key, real_value, coded_value) > > File "Cookie.py", line 451, in set >raise CookieError("Illegal key value: %s" % key) > > CookieError: Illegal key value: hide:inst11 > > Can anyone help me solve this problem? > > Thanks in advance. > > Young-Jin Lee > > > > --~--~-~--~~~---~--~~ 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 display an error
You can use the shell. Run python manage.py shell within your project path. Import your model: from app.models import foo f = foo( bar=2 ) f.save() now you can check all the variables you want. f.id returns the id of the new created object. On Aug 9, 1:29 pm, "Lic. José M. Rodriguez Bacallao" <[EMAIL PROTECTED]> wrote: > if I have a model with save method overrided to check if some values in my > model are ok, how can I display the field(s) with errors in red in admin > like django admin does when an error occur with that field(s)? > > -- > Lic. José M. Rodriguez Bacallao > Cupet > - > Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo > mismo. > > Recuerda: El arca de Noe fue construida por aficionados, el titanic por > profesionales > - --~--~-~--~~~---~--~~ 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 Filter on a list of objects?
Tim and Nis, Okay thanks for the help. My view is definitily better now than before. Here is my new view def searchresult(request): if request.method == 'POST': myset = set() NOT_PICKED = "---" y = Choice.objects.all() if ('price' in request.POST and request.POST['price'] <> NOT_PICKED): y = y.filter(price__price_cat=request['price']) if ('size' in request.POST and request.POST['size'] <> NOT_PICKED): y = y.filter(size__size_cat=request['size']) for q in y: styles = Choice.objects.get(id=q.id).style_set.all() if ('color' in request.POST) and (request.POST['color'] <> NOT_PICKED): styles = styles.filter(color_cat=request['color']) for style in styles: myset.add(style) if myset == set([]): return render_to_response('searchresult_none.html', {'s': "No product available"}) else: return render_to_response('searchresult.html', {'s': myset}) Does that look any better? I have two issues with this. 1) Is there anyway to get it so that I don't have to use the following for loop: for style in styles: myset.add(style) 2) Is still adds duplicate products. If a product contains two choices that have a price of 149 and 199. Then when a user searches by price only (100-199) then the product is displayed twice in the result set. Thank you SO much for your help!!! This is my first time developing in Python and I'm learning quite a bit. On Aug 9, 8:37 am, Tim Chase <[EMAIL PROTECTED]> wrote: > > NO_COLOR = "---" > > styles = Choice.objects.get(id=h.id).style_set.all() > > if ('color' in request.POST) and (request.POST['color'] <> NO_COLOR): > > styles = styles.filter(color_cat=request['color']) > > for u in styles: > > dict[u] = u > > > > > > I did notice that whenever I do a search for just the color 'brown'. > > Then the result set will bring back the same style however many > > different sizes that are in the style. So if an area rug sells two > > choices (2'x3' 39.00, 4'x6' 149.00). Then that style will show up > > twice in the result set. Is there anyway better to filter out the > > styles that have already been added to the dictionary. My previous > > code worked..but not sure it's the best way to do it. Here it is: > > > num = 0 > > for a in dict: > >if a == j: # 'j' being the name of the style and 'a' is the name of > > the style that is already in the dictionary > >num = 1 > >if num == 0: > >dict[j] = j > > I second the suggestion by Nis to make meaningful variable names, > as well as the suggestion to use sets rather than abusing a > dictionary (and tromping on the namespace with "dict"...just got > bitten by this yesterday, a "zip"-code variable shadowed the > built-in zip() command causing some confusing errors) > > It looks like you could just do something like > >results = Choice.objects.get(id=h.id).style_set.all() ># filter results >results = set(results) > > I'm not sure on the performance of set creation, so you might > compare the results with > > results = set(list(results)) > > or > > results = set(tuple(results)) > > -tim --~--~-~--~~~---~--~~ 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 on Linux, MS SQL on Windoz
Is it possible to run a django web server on a nix box and communicate with a MS-SQL (2000) database on a Windoz 2003 server. I am looking for a good python framework, and django seems like it might be the one, but if it can't do this, that could be a show stopper. From what I have seen, there is only the adodapi that you can use to connect to sql server (and it may not be great), and I believe that has to run on a doz box. I am trying to migrate away from windows, thus the desired implementation above. Plan won't work if I have to run django on a windows box. Help anyone ... Thanks, Peter --~--~-~--~~~---~--~~ 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: session expire_date
SESSION_COOKIE_NAME = 'sessionid' # Cookie name. This can be whatever you want. SESSION_COOKIE_AGE = 60 * 60 * 24 * 7 * 2 # Age of cookie, in seconds (default: 2 weeks). SESSION_COOKIE_DOMAIN = None # A string like ".lawrence.com", or None for standard domain cookie. SESSION_COOKIE_SECURE = False # Whether the session cookie should be secure (https:// only). SESSION_SAVE_EVERY_REQUEST = False# Whether to save the session data on every request. SESSION_EXPIRE_AT_BROWSER_CLOSE = False # Whether sessions expire when a user closes his browser. You can view all other settings in django_root_dir/conf/global_settings.py Jens Diemer пишет: > I would like to know the expire date of the current session. I made this: > > > -- > from django.contrib.sessions.models import Session > > session_cookie_name = settings.SESSION_COOKIE_NAME > current_session_id = self.request.COOKIES[session_cookie_name] > > s = Session.objects.get(pk=current_session_id) > > expiry_date = s.expire_date > -- > > > There must be a simpler way for this, isn't it? > > > > > -- Artiom Diomin, Development Dep, "Comunicatii Libere" S.R.L. http://www.asterisksupport.ru http://www.asterisk-support.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 -~--~~~~--~~--~--~---
[Q] Django with modpython in Ubuntu
Dear all, I have a problem using mod_python with Django (v 0.95) under apache2 in Ubunu. I followed all the steps described in the online documentation, but it did not work. The followins is how I set up the httpd.conf and error message I got. httpd.conf: DirectoryIndex index.php index.html index.htm AcceptPathInfo on SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE mysite.settings PythonDebug On PythonPath "['/home/yjlee/Worx/Django/Projects'] + sys.path" I created a project with "django-admin.py startproject mysite" at "/ home/yjlee/Worx/Django/Projects" directory. When I pointed my web browser to "http://edtech.soe.ku.edu/mysite/"; I got the following error messages: Mod_python error: "PythonHandler django.core.handlers.modpython" Traceback (most recent call last): File "/usr/lib/python2.5/site-packages/mod_python/apache.py", line 299, in HandlerDispatch result = object(req) File "/var/lib/python-support/python2.5/django/core/handlers/ modpython.py", line 163, in handler return ModPythonHandler()(req) File "/var/lib/python-support/python2.5/django/core/handlers/ modpython.py", line 136, in __call__ response = self.get_response(req.uri, request) File "/var/lib/python-support/python2.5/django/core/handlers/ base.py", line 59, in get_response response = middleware_method(request) File "/var/lib/python-support/python2.5/django/contrib/sessions/ middleware.py", line 69, in process_request request.session = SessionWrapper(request.COOKIES.get(settings.SESSION_COOKIE_NAME, None)) File "/var/lib/python-support/python2.5/django/core/handlers/ modpython.py", line 59, in _get_cookies self._cookies = http.parse_cookie(self._req.headers_in.get('cookie', '')) File "/var/lib/python-support/python2.5/django/http/__init__.py", line 150, in parse_cookie c.load(cookie) File "Cookie.py", line 619, in load self.__ParseString(rawdata) File "Cookie.py", line 650, in __ParseString self.__set(K, rval, cval) File "Cookie.py", line 572, in __set M.set(key, real_value, coded_value) File "Cookie.py", line 451, in set raise CookieError("Illegal key value: %s" % key) CookieError: Illegal key value: hide:inst11 Can anyone help me solve this problem? Thanks in advance. Young-Jin Lee --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
about templates tags
can I include more than one template tag definition in a single template tag file? Right now I was trying to do that and I can't. -- Lic. José M. Rodriguez Bacallao Cupet - Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo. Recuerda: El arca de Noe fue construida por aficionados, el titanic por profesionales - --~--~-~--~~~---~--~~ 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: Commenting on Comments
On 8/8/07, Ramdas S <[EMAIL PROTECTED]> wrote: > > How do I use the comments framework, so that users can comment on > comments made by others? The free comments example does not > > Is it possible without hacking the comments app? Ramdas, Sorry you've received no response. You'll find that relatively few people are using the comments app in production, since it's undocumented and known to be pending a re-write. That said, there should be no problem commenting on a comment-- it's just another content type, after all. The trick will be making a template tag to render the tree of comments. For some example code making extensive use of the comments system, check out this: http://code.google.com/p/django-comment-utils/ --~--~-~--~~~---~--~~ 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 forms in newforms-admin
On 8/9/07, eXt <[EMAIL PROTECTED]> wrote: > > Sorry that I'm not exacly on the topic but I'd like to know what is > current state of newforms-admin. Is it safe to use it in application > or is it still too early? I would say it's too early unless you are comfortable fixing bugs and maintaining patches since they aren't really being applied to the branch in a timely manner. (I blame myself for that, just too much going on at the moment.) Here's a list of known bugs. Some of them are fairly big problems for most applications. For instance, deletion does not work. http://code.djangoproject.com/query?status=new&status=assigned&status=reopened&version=newforms-admin&order=priority Joseph --~--~-~--~~~---~--~~ 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: Is this not allowed select_related()
He means that you can remove: employee = models.ForeignKey(Employee) from your 'EmployeeAssignment' and 'EmployeeContract' models because the relationship is already defined in your 'Employee' model. You can use reverse relations to get the relation instead. On Aug 8, 10:58 pm, james_027 <[EMAIL PROTECTED]> wrote: > Hi collin > > On Aug 9, 1:06 pm, Collin Grady <[EMAIL PROTECTED]> wrote: > > > Because you have an infinite loop there. > > > Why are you linking both directions? There's a reverse relation > > available to get from EmployeeAssignment and EmployeeContract back to > > the Employee model, you don't need to explicitly define it. > > The EmployeeAssignment and EmployeeContract keeps track the history of > each employee contract and assignment they receive, while the > employee_contract and the employee_assignment attributes tells their > current status ... > > Regards, > james --~--~-~--~~~---~--~~ 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: pagination for search result ...
Hi James, On 8/9/07, james_027 <[EMAIL PROTECTED]> wrote: > > hi, > > I am trying to put a page list for a search result. So far here's what > I've try by using the django.views.generic.list_detail.object_list and > the pagination tag (http://code.djangoproject.com/wiki/PaginatorTag) > and later found out that it won't meet my needs. > > def search_employee(request): > if not request.GET: > return render_to_response('search_employee.htm') > else: > params = request.GET['name'].split() > employees = Employee.objects.all() > for p in params: > employees = employees.filter(Q(firstname = p) | Q(lastname > = p)) > return object_list(request, employees, paginate_by=3, > template_name='search_employee_result.htm', > template_object_name='employee') > > This won't work because when you try to select other page the > query_set from previous is lost ... I am thinking off passing the > request.GET to the object_list's extra_context argument, then edit the > pagination tag that will provide link constrcuted from the > extra_context? > > Or is there a better solution or existing solution? Do you mean that the filter works on the first page but is lost when you go to another page? If yes: I save my filter in a session and filter on each page using that filter values (the values that were given to the input fields of the filter form). I don't know whether this is the right way (tm) but it works for me. :-) > Thanks > james Greetings Kai --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Optimize WINDOWS XP
Learn how to optimize your Windows XP with powerful tips and tricks http://windowsxpsp2pro.blogspot.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: Looking for good forum software for integration with Django project ...
On Aug 9, 11:16 am, "Justin Lilly" <[EMAIL PROTECTED]> wrote: > there's counterpoint, but I don't think its ready yet. > > http://code.google.com/p/counterpoint > > On 8/9/07, ZebZiggle <[EMAIL PROTECTED]> wrote: There's also the Sphene board/wiki/community stuff: http://sct.sphene.net/wiki/show/Start/ The author, Herbert Poul, is very open to suggestions for improvement. --~--~-~--~~~---~--~~ 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: Looking for good forum software for integration with Django project ...
there's counterpoint, but I don't think its ready yet. http://code.google.com/p/counterpoint On 8/9/07, ZebZiggle <[EMAIL PROTECTED]> wrote: > > > I need a good comment/forum library, ideally with Karma/Blocking/ > Voting/etc to integrate with my django project. > > I've looked at PHPBB and vbulletin which are good, but I can't stand > PHP. > > Any suggestions? > > Anyone interested in making a Django side project for this? > > -Z > > > > > -- Justin Lilly University of South Carolina --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Tuned cars!!!!!
Only for biggest fans http://tuning-styling.blogspot.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 -~--~~~~--~~--~--~---
session expire_date
I would like to know the expire date of the current session. I made this: -- from django.contrib.sessions.models import Session session_cookie_name = settings.SESSION_COOKIE_NAME current_session_id = self.request.COOKIES[session_cookie_name] s = Session.objects.get(pk=current_session_id) expiry_date = s.expire_date -- There must be a simpler way for this, isn't it? -- Mfg. Jens Diemer A django powered CMS: http://www.pylucid.org --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Looking for good forum software for integration with Django project ...
I need a good comment/forum library, ideally with Karma/Blocking/ Voting/etc to integrate with my django project. I've looked at PHPBB and vbulletin which are good, but I can't stand PHP. Any suggestions? Anyone interested in making a Django side project for this? -Z --~--~-~--~~~---~--~~ 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: SQLite + float vs MySQL + Decimal
On 8/9/07, Vincent Foley <[EMAIL PROTECTED]> wrote: > > Hello, > > I found a curious problem in my application when I put it into > production this week: when a models.FloatField is "extracted" from the > database, its type changes depending on the database. With SQLite in > development, I got back floats, while on MySQL in production I have > decimals. As mentionned in other posts, decimals are not serializable > in JSON. For the record - current trunk has no problem serializing Decimal fields or Float fields. > We are using Django 0.96 (and have no intention to use the Subversion > branch.) Is it possible to fix the problem without applying a patch? > I don't have root access to the production environment, so I can't > apply patches. Not really, no. What you are seeing is a known issue caused by the way that we handled FloatFields. If you can't patch the version of Django, there isn't really anything you can do in a clean way to fix the problem. This problem was fixed in [5302] (which is post 0.96). See the following for more details: http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#RenamedFloatFieldtoDecimalField 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 -~--~~~~--~~--~--~---
SQLite + float vs MySQL + Decimal
Hello, I found a curious problem in my application when I put it into production this week: when a models.FloatField is "extracted" from the database, its type changes depending on the database. With SQLite in development, I got back floats, while on MySQL in production I have decimals. As mentionned in other posts, decimals are not serializable in JSON. We are using Django 0.96 (and have no intention to use the Subversion branch.) Is it possible to fix the problem without applying a patch? I don't have root access to the production environment, so I can't apply patches. Vincent. >>> # Development environment w/ SQLite >>> from gestio.inventory.models import * >>> import django >>> type(Item.objects.all()[0].loss) >>> django.VERSION (0, 96, None) >>> >>> # Production environment w/ PostgreSQL >>> from gestio.inventory.models import * >>> import django >>> type(Item.objects.all()[0].loss) >>> django.VERSION (0, 96, None) >>> --~--~-~--~~~---~--~~ 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 Filter on a list of objects?
> NO_COLOR = "---" > styles = Choice.objects.get(id=h.id).style_set.all() > if ('color' in request.POST) and (request.POST['color'] <> NO_COLOR): > styles = styles.filter(color_cat=request['color']) > for u in styles: > dict[u] = u > > > > I did notice that whenever I do a search for just the color 'brown'. > Then the result set will bring back the same style however many > different sizes that are in the style. So if an area rug sells two > choices (2'x3' 39.00, 4'x6' 149.00). Then that style will show up > twice in the result set. Is there anyway better to filter out the > styles that have already been added to the dictionary. My previous > code worked..but not sure it's the best way to do it. Here it is: > > num = 0 > for a in dict: > if a == j: # 'j' being the name of the style and 'a' is the name of > the style that is already in the dictionary > num = 1 > if num == 0: > dict[j] = j I second the suggestion by Nis to make meaningful variable names, as well as the suggestion to use sets rather than abusing a dictionary (and tromping on the namespace with "dict"...just got bitten by this yesterday, a "zip"-code variable shadowed the built-in zip() command causing some confusing errors) It looks like you could just do something like results = Choice.objects.get(id=h.id).style_set.all() # filter results results = set(results) I'm not sure on the performance of set creation, so you might compare the results with results = set(list(results)) or results = set(tuple(results)) -tim --~--~-~--~~~---~--~~ 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: Testing/Fixtures/Production/TestRunner
On 8/9/07, Chris Green <[EMAIL PROTECTED]> wrote: > > 1) initial_data has bitten me not realizing it was synced in > production each time. I think that initial_data should only get > inserted if you have an empty new database. Perhaps things synced > each time should be called "constant_data". The fixtures > documentation in testing does say it gets synched each time but also > says its purpose is to populate the initial empty new database. There is an argument to be made that initial_data for a model should only be loaded once - when the model is added to the database. I can't say I've been bitten by this problem myself, but I'm happy to entertain discussion/patches that address the issue. > 2) Setting up users/groups/users manually in the runner gets blown > away by the TestCase architecture. Works as documented. However, I'm > not sure where I should put things that should happen post-each syncdb > for testing only. Should there be a testrunner function that gets > called post each sync or should I create a single TestCase derived > from django.test.TestCase that does the "pre-setup"? I'm not sure I follow. TestCase goes out of its way to avoid interfering with setUp/tearDown methods, and in a TestCase, there is a complete flush after each test, so any setup would need to be rerun on a per-test basis, not a per-sync basis. Can you provide an example of the problem? > 3) DateTime serialization won't work if the date is before 1901 - I > have a bug/real life data set where I get some bogus dates out of > another system. This is really a python problem. Again, if you can provide an example, it would help. However, if the problem is with Python itself, there's not a great deal we can do. 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 -~--~~~~--~~--~--~---
OperationalError 1054 Unknown column
Hi all, I'm working with a MySQL legacy DB which was changed. This was our previous Level table: +-+---+--+-+-+---+ | Field | Type | Null | Key | Default | Extra | +-+---+--+-+-+---+ | level_name | varchar(20) | NO | PRI | | | | instrument_name | varchar(20) | NO | PRI | | | | available | enum('Y','N') | NO | | Y | | | tablename | varchar(20) | YES | | NULL| | +-+---+--+-+-+---+ This was the previous model class for the Level table: class Level(models.Model): level_name = models.CharField(primary_key=True, maxlength=60) instrument_name = models.CharField(blank=False, maxlength=60) available = models.TextField(blank=False) tablename = models.CharField(blank=True, maxlength=60) Because in the database the primary key was made of two fields, the level_name and the instrument_name this wasn't working properly. So we changed the table to: +-+---+--+-+- ++ | Field | Type | Null | Key | Default | Extra | +-+---+--+-+- ++ | level_name | varchar(20) | NO | MUL | || | instrument_name | varchar(20) | NO | | || | available | enum('Y','N') | NO | | Y || | tablename | varchar(20) | YES | | NULL || | levelID | bigint(20)| NO | PRI | NULL| auto_increment | +-+---+--+-+- ++ and the Level model class to (with the help of the inspectdb command): class Level(models.Model): level_name = models.CharField(unique=True, maxlength=60) instrument_name = models.CharField(unique=True, maxlength=60) available = models.TextField() tablename = models.CharField(blank=True, maxlength=60) levelID_id = models.AutoField(primary_key=True) But now, when I try to do for example this: def view_levels(request, orderby): levels=Level.objects.all() levellist=[] for l in levels: levellist.append({'levelname':l.level_name, 'instrname':l.instrument_name, 'available':l.available, 'tablename':l.tablename}) ordering='Instrument Name' return render_to_response('view_levels.html', {'levellist':levellist, 'ordering':ordering}) It gives me this error: Exception Type: OperationalError Exception Value:(1054, "Unknown column 'Level.levelID_id' in 'field list'") Exception Location: /nobackup/reis/Python/lib/python2.5/site-packages/ MySQLdb/connections.py in defaulterrorhandler, line 35 What is happening here? Thanks for your time! Ana --~--~-~--~~~---~--~~ 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: Single-object serializers?
On 8/9/07, Shawn Allen <[EMAIL PROTECTED]> wrote: > > Hey everyone, > > I'm about to tackle an API that supports multiple response formats > using serializers. I realize that the API (as simple as it is) is > subject to change, but it seems like a totally sensible pattern for > what I'd like to do. One problem I've come across already is that the > base Serializer class's serialize() method assumes whatever is passed > to it is an iterable. This is a poor assumption in the case of my > API, which, in many cases, will be returning a serialized > representation of a single object. Can anyone recommend a strategy > for overriding this behavior? Adding serialization of single objects would be a reasonable addition to the Django serialization framework. There could be some devil in the details (especially on deserialization), but at a conceptual level, I don't see why we couldn't modify serialize() to check: if data is iterable: serialize list else serialize object Patches welcome. 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 -~--~~~~--~~--~--~---
how to display an error
if I have a model with save method overrided to check if some values in my model are ok, how can I display the field(s) with errors in red in admin like django admin does when an error occur with that field(s)? -- Lic. José M. Rodriguez Bacallao Cupet - Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo. Recuerda: El arca de Noe fue construida por aficionados, el titanic por profesionales - --~--~-~--~~~---~--~~ 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: (1040, 'Too many connections')
On Aug 9, 12:01 am, Michel Thadeu Sabchuk <[EMAIL PROTECTED]> wrote: > Hi guys! > > I´m having a problem with a django site, sometimes my server stuck and > goes down. Just before it happens I receive about 200 traceback > messages telling me the same error: (1040, 'Too many connections'), I > get these messages in an interval of 1 minutes. I changed mysql > configuration and set the simultaneous connection limit to 1000 but > the problem persist. I´m not a mysql expert so I talked to my tecnical > support, they tell me mysql isn´t stucking the server, maybe it is the > traceback messages by email. > > I disabled email traceback messages and this weekend my server goes ok > but I´m not fighting the problem this way. I have about 20 000 daily > visits (250 000 - 290 000 hits each day). This site is hosted on a > dedicated server, a Xeon 3.20GHz with 4GB of RAM space. I´m using > django-0.96pre and I use locmem as the cache backend. I´m using mysql > 5.0.18 as database. > > I have locmem configured with default parameters, when I start my > server it costs me about 800MB of RAM space, but now, after 10 days of > uptime, the consumed RAM is between 3.0GB and 3.4GB. I don´t send > emails from my server, except by the traceback and registration ones, > the registration is few number of emails. > > I don´t know where should I look at to solve my problem. Some people > tell me to use a static index page server by apache, generated by a > cron job, do you think it´s really necessary? Does anyone is facing > such problem? The WebFaction guidelines someone else pointed to is a good start as far as ideas to pursue, but some of these are Apache/mod_python centric. What web server arrangement are you using? Are you trying to use inbuilt Django web server, mod_python, fastcgi, or something else? Also perhaps post some of the traceback so it is more obvious to people exactly what is raising the error about too many connections and what call sequence triggered it. Graham --~--~-~--~~~---~--~~ 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: (1040, 'Too many connections')
I'm pretty sure that will help you - http://blog.webfaction.com/tips-to-keep-your-django-mod-python-memory-usage-down --~--~-~--~~~---~--~~ 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: testing
Для тестов существуют модули doctest и unittest, попробуй почитать документацию :) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
admin search
I would like to use the admin search of the flatpage in my website template so how can i do that any help will be appreciated Thank you in advance --~--~-~--~~~---~--~~ 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 Filter on a list of objects?
Greg skrev: > Nis, > Thanks for the help. We'll I got my view to work for website visitors > searching by any combintation of Size, Price, and Color. My code is > not the most efficient and I wonder how the performance is going to be > once I add more products and take it off of developmental version and > into a production environment. > > If anybody has any suggestions on how to make the code more optimized > would be appreciated. Here is my view: > What Tim said, and this: It would make your code much more readable if you used meaningful variable names. Python makes the need for explicit looping a lot less frequent than most other programming languages. Whenever you are looping through a list/dictionary and comparing each value to some other value, chance is that you should really be using "if a in b". In general, dont use my_dictionary = {} my_dictionary[x] = x Use myset = set() myset.add(x) And finally: Don't Repeat Yourself. Whenever you have two blocks of code that looks almost the same, try to refactor your code. Example: > NO_COLOR = "---" > styles = > Choice.objects.get(id=h.id).style_set.all() > if request['color'] <> NO_COLOR: > styles = > styles.filter(color_cat=request['color']) > for j in styles: > num = 0 > for a in dict: > if a == j: > num = 1 > if num == 0: > dict[j] = j > else: > for p in styles: > num = 0 > for a in dict: > if a == p: > num = 1 > if num == 0: > dict[p] = > p#assert False, styles > First step: Rename variables so they match in the two branches: NO_COLOR = "---" styles = Choice.objects.get(id=h.id).style_set.all() if request['color'] <> NO_COLOR: styles = styles.filter(color_cat=request['color']) for style in styles: num = 0 for key in dict: if key == style: num = 1 if num == 0: dict[style] = style else: for style in styles: num = 0 for key in dict: if key == style: num = 1 if num == 0: dict[style] = style Second step: Move the common block out of the conditional NO_COLOR = "---" styles = Choice.objects.get(id=h.id).style_set.all() if request['color'] <> NO_COLOR: styles = styles.filter(color_cat=request['color']) for style in styles: num = 0 for key in dict: if key == style: num = 1 if num == 0: dict[style] = style Third step: Replace the logic "If the key is not in the dictionary, put it there" with "put the key in the dictionary". Since the value associated with the key is
Access the request object in a filter?
Hey All, I'm trying to create a 'shopping' website, and one of the design elements that is necessary is that the "Purchase this item" link changes to a "Remove this item from your cart" link when the item has been added to the user's Shopping Cart. When an object is added to the shopping cart, a ShoppingCartItem object is created (this is necessary to allow for things like quantities, item discounts, shipping calculation etc...), and I need to tell whether a ShoppingCartItem the exists for a particular Item (fk'd to the user's ShoppingCart). Everything works great apart from this bit. I know that I can make a template tag that has access to the request object (added by the Context Processors), but am a bit stuck as to how to do this in a filter. Ideally I would like to do something like: {% if item|in_cart %}foo{% else %}bar{% endif %} So, all I really need to know is how I would get access to the request object in a filter. I haven't tried it, but don't think {% if item|in_cart:request.session.cart %} Would work. Any help in getting access to the request (or session) data in a filter, or a better way if anyone can think of it, would be much appreciated. Kind Regards, Oliver --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
pagination for search result ...
hi, I am trying to put a page list for a search result. So far here's what I've try by using the django.views.generic.list_detail.object_list and the pagination tag (http://code.djangoproject.com/wiki/PaginatorTag) and later found out that it won't meet my needs. def search_employee(request): if not request.GET: return render_to_response('search_employee.htm') else: params = request.GET['name'].split() employees = Employee.objects.all() for p in params: employees = employees.filter(Q(firstname = p) | Q(lastname = p)) return object_list(request, employees, paginate_by=3, template_name='search_employee_result.htm', template_object_name='employee') This won't work because when you try to select other page the query_set from previous is lost ... I am thinking off passing the request.GET to the object_list's extra_context argument, then edit the pagination tag that will provide link constrcuted from the extra_context? Or is there a better solution or existing solution? Thanks james --~--~-~--~~~---~--~~ 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: mysite.polls application error
> question = models.CharField(max_length=200) change the above to 'question = models.CharField(maxlength=200)' There should not be a '_' between 'max' and 'length'. You should be set now On 8/8/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > hi, after hitting > python manage.py sql polls > an error appears and i don't know how to debug in python for find the > error. > > could someone help me with this, THANKS > > This is what appears on screen: > > mysite.polls: __init__() got an unexpected keyword argument > 'max_length' > 1 error found. > > Traceback (most recent call last): > File "manage.py", line 11, in > execute_manager(settings) > File "/var/lib/python-support/python2.5/django/core/management.py", > line 1672, in execute_manager > execute_from_command_line(action_mapping, argv) > File "/var/lib/python-support/python2.5/django/core/management.py", > line 1620, in execute_from_command_line > mod_list = [models.get_app(app_label) for app_label in args[1:]] > File "/var/lib/python-support/python2.5/django/db/models/ > loading.py", line 40, in get_app > mod = load_app(app_name) > File "/var/lib/python-support/python2.5/django/db/models/ > loading.py", line 51, in load_app > mod = __import__(app_name, {}, {}, ['models']) > File "/home/eduardo/djangoProject/mysite/../mysite/polls/models.py", > line 5, in > class Poll(models.Model): > File "/home/eduardo/djangoProject/mysite/../mysite/polls/models.py", > line 6, in Poll > question = models.CharField(max_length=200) > TypeError: __init__() got an unexpected keyword argument 'max_length' > > > > > --~--~-~--~~~---~--~~ 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 forms in newforms-admin
I noticed that item deletion is currently broken. Except for that everything seems to work for me, even inline editing. On 9 August 2007 (Thu), eXt wrote: > Hi > > Sorry that I'm not exacly on the topic but I'd like to know what is > current state of newforms-admin. Is it safe to use it in application > or is it still too early? I have to do some customizations in admin's > widgets and I really don't want to do it with old style forms. > > To answer your question - i did such things with classic admin but I > had to override admin views and templates... which is probably not the > answer you were expecting. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
getting pagination tag to work
hi, I am trying to do this http://code.djangoproject.com/wiki/PaginatorTag I have two apps in my projects which are main and manning. I put the pagination tag code in the main/templatetags/extra_tags.py file. And I am trying to use the tag from a template in manning/templates/ results.htm. But I am getting this error "TemplateDoesNotExist at / manning/search_employee/ paginator.htm". I place the paginator.htm in main/templates folder. how do I correct this? thanks james --~--~-~--~~~---~--~~ 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: List with pagination, sorting and simple search interface
Hi Pigletto; Is there a way that i can see the code you have implemented it will be great to help me Thank you in advance; On Jul 24, 11:27 pm, Przemek Gawronski <[EMAIL PROTECTED]> wrote: > > Thanks. Finally I've used PaginatorPag from your link (with some > > changes) and > > Sortable Headers (from djangosnippets) with some changes too, newforms > > to createsearchform and generic list. > > Changes I had to do were necessary because each of those components - > > sort, filter and pagination should > > know about others parameters, eg. while sorting you shouldn't lost > > filter parameters etc. > > Maybe you could put it at djangosnippets for others? I would be more > then happy to take a look at it :) > > Przemek > -- > AIKIDO TANREN DOJO - Poland - Warsaw - Mokotow - Ursynow - Natolin > inf o:ht tp://www.tanren.pl/phone: +4850151 email: [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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 forms in newforms-admin
Hi Sorry that I'm not exacly on the topic but I'd like to know what is current state of newforms-admin. Is it safe to use it in application or is it still too early? I have to do some customizations in admin's widgets and I really don't want to do it with old style forms. To answer your question - i did such things with classic admin but I had to override admin views and templates... which is probably not the answer you were expecting. Regards -- Jakub Wisniowski On 9 Sie, 08:38, Densetsu no Ero-sennin <[EMAIL PROTECTED]> wrote: > Hi > > I'm currently investigating newforms-admin and it looks amazingly > customizable. :) But still I couldn't find the way to use custom forms for > some models or something like that. What I need is to add some custom fields > to some admin form and then to save some additional data to the database > after the object (the instance of the model being edited) is saved. In other > words, it is like edit_inline, but different. Has anybody done something like > that? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Newforms validations & request.user
Hello, I need to write form for re-setting user's password: class SettingsForm(forms.Form): old_password = forms.CharField(max_length=200, required=False, widget=forms.PasswordInput(attrs=passw_dict, render_value=False), label=u'Actual password') password1 = forms.CharField(max_length=200, required=False, widget=forms.PasswordInput(attrs=passw_dict, render_value=False), label=u'New password') password2 = forms.CharField(max_length=200, required=False, widget=forms.PasswordInput(attrs=passw_dict, render_value=False), label=u'New password (again)') I would like check old user password at form validation level. But is it possible? (I have no request object, so I don't know which user is actually logged in). I could check it in view level too, but I would like to generate form error message (ie. invoke ValidationError exceprion outside of the form class). Is it possible please? Regards Michal --~--~-~--~~~---~--~~ 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: Overwriting the login function
OK, I got it. You can't use the login_decorator to do what I'm trying to do. I"ve addded one simple line to the form, used the original auth/views.py and my original method of authentication and it all works fine. Misread the docs again. return HttpResponseRedirect('/accounts/login/?next=%s' % request.path) et voila On 08/08/07, Matt Davies <[EMAIL PROTECTED]> wrote: > > Ok, I'm now using the login_required decorator, much better > > one problem though, here's a snippet of a form > > http://pastie.caboo.se/85932 > > How do I check the IP prior to askign for a login check, and if the IP is > good, not ask for login? > > I'm stumped > > > > On 08/08/07, Matt Davies <[EMAIL PROTECTED]> wrote: > > > > Getting there. > > > > It's not setting the logged in as yes as it's not logging me in :-) > > > > This conditional in the login function in views > > > > if request.POST: > > > > is not getting a positive and it's falling through to the else which is > > setting errors to blank > > > > else: > > print 'balls' > > errors = {} > > request.session.set_test_cookie() > > return render_to_response(template_name, { > > 'form': oldforms.FormWrapper (manipulator, request.POST, > > errors), > > 'matts_back_to': redirect_to, > > > > 'site_name': Site.objects.get_current().name, > > }, context_instance=RequestContext(request)) > > > > which then throws me back to the page without logging me in at all, I > > can put any old rubbish into that form. > > I think I somehow need to make this part of the secured views do what I > > need, really not sure though. > > > > return HttpResponseRedirect("/accounts/login") > > > > > > > > > > On 08/08/07, Matt Davies <[EMAIL PROTECTED]> wrote: > > > > > > I've copied the /contrib/auth/views.py into my project and edited it > > > like so > > > > > > redirect_to = request.META["HTTP_REFERER"] > > > > > > return render_to_response(template_name, { > > > 'form': oldforms.FormWrapper (manipulator, request.POST, errors), > > > 'matts_back_to': redirect_to, > > > 'site_name': Site.objects.get_current().name, > > > > > > I've added in my login forms this as the action > > > > > > > > > > > > Now, when a user comes to a page that shows a view that has this in > > > the top > > > if request.user.is_authenticated(): > > > do all your stuff > > > else: > > > return HttpResponseRedirect("/accounts/login") > > > > > > If they're not logged in they get sent to directly to the login page, > > > they login and get sent back to the page they were trying to access > > > initially. > > > > > > This works fine, but for some reason the user is not being shown as > > > having logged in when they are returned to the initial page. If they try > > > to > > > access another secured page at that point, it asks them to login again, > > > and > > > also the login/logout button is showing as logged out. > > > > > > Anyone got any ideas why? > > > > > > If this is a really bad way to achieve what I want then please let me > > > know, it is a bit of a workaround I suppose. > > > > > > > > > > > > > > > > > > > > > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---