Re: iteration of query set appears to fail when running function directly from interpretor
Merric Mercer schreef: > Help! I have a function that is provided below. When I try the > individual lines of the function through the interpretor (Ipython) > everything works as expected. For example:- > > >> qset=PointTransaction.objects.filter etc this works fine!! > > However, when I try to run the function as a whole: Example:- > > >> admin_sync_agg(user_id=1,points_type=1) >> > > This runs but it seems that is is not iterating through the query set, > so only the first record of qset is getting added to the balance. > > Can anybody advise.. it's completely baffling me. Thanks > > MerMer > > > def admin_sync_agg (user_id,points_type): > > qset=PointTransaction.objects.filter(user=user_id).filter(points_type=points_type) > credit=0 > debit=0 > for i in qs: > credit = credit + i.credit > debit = credit + i.debit > balance= credit-debit > > pa=UserPointTypeAggregate.objects.get(user=user_id,points_type=points_type) > pa.total_points=balance > pa.save() You are iterating over qs instead of qset. def admin_sync_agg (user_id,points_type): qset=PointTransaction.objects.filter(user=user_id).filter(points_type=points_type) credit=0 debit=0 for i in qset: credit = credit + i.credit debit = credit + i.debit balance= credit-debit pa=UserPointTypeAggregate.objects.get(user=user_id,points_type=points_type) pa.total_points=balance pa.save( (indentation of qset & pa line screwed up using Thunderbird) Regards, Benedict --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Free Ebooks on Cooking, Hacking, IT, Sex etc.. Website Submission, Forum, .
Free Ebooks on Cooking, Hacking, IT, Sex etc.. Website Submission, Forum, Visit http://www.aonearticles.com. No membership required. --~--~-~--~~~---~--~~ 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: iteration of query set appears to fail when running function directly from interpretor
Benedict, Unfortunately, that is just a typo in my post and not the answer. The actual code has 'for i in qset'. The code runs without displaying any errors. But when I check the "UserPointTypeAggregate" database the field has only been updated from the first record of the PointTransaction query set. MerMer Benedict Verheyen wrote: > Merric Mercer schreef: > >> Help! I have a function that is provided below. When I try the >> individual lines of the function through the interpretor (Ipython) >> everything works as expected. For example:- >> >> >> qset=PointTransaction.objects.filter etc this works fine!! >> >> However, when I try to run the function as a whole: Example:- >> >> >> admin_sync_agg(user_id=1,points_type=1) >> >> >> This runs but it seems that is is not iterating through the query set, >> so only the first record of qset is getting added to the balance. >> >> Can anybody advise.. it's completely baffling me. Thanks >> >> MerMer >> >> >> def admin_sync_agg (user_id,points_type): >> >> qset=PointTransaction.objects.filter(user=user_id).filter(points_type=points_type) >> credit=0 >> debit=0 >> for i in qs: >> credit = credit + i.credit >> debit = credit + i.debit >> balance= credit-debit >> >> pa=UserPointTypeAggregate.objects.get(user=user_id,points_type=points_type) >> pa.total_points=balance >> pa.save() >> > > You are iterating over qs instead of qset. > > def admin_sync_agg (user_id,points_type): > qset=PointTransaction.objects.filter(user=user_id).filter(points_type=points_type) > credit=0 > debit=0 > for i in qset: > credit = credit + i.credit > debit = credit + i.debit > balance= credit-debit > pa=UserPointTypeAggregate.objects.get(user=user_id,points_type=points_type) > pa.total_points=balance > pa.save( > > (indentation of qset & pa line screwed up using Thunderbird) > > Regards, > Benedict > > > > > > > --~--~-~--~~~---~--~~ 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 postpone HttpResponse but still get new requests
Hi, im sorry, my question sucked. sure, i use an ajax request. and i know that i could just poll. but i rather would wait on serverside for new items and then respond. it is possible: if i dont specify a timeout for the request i can respond hours later. BUT: i cant get new requests, cause the webserver is stuck in the view- function that handles the postponed request. there wil be now performance issues cause there are a max of 5 clients accessing the server at a time. any idea to implement this without polling? (at least not each 200ms) best an easy way without using another framework. thx for your help --~--~-~--~~~---~--~~ 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: Application parameters
Malcolm Tredinnick <[EMAIL PROTECTED]> writes: > You can pass whatever extra arguments you like to views as the optional > third argument in the urlpatterns tuples Ahh thanks. That was the missing piece in the puzzle. Regards, Frank --~--~-~--~~~---~--~~ 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: iteration of query set appears to fail when running function directly from interpretor
Merric Mercer schreef: > Benedict, > > Unfortunately, that is just a typo in my post and not the answer. The > actual code has 'for i in qset'. > > The code runs without displaying any errors. But when I check the > "UserPointTypeAggregate" database the field has > only been updated from the first record of the PointTransaction query set. > > MerMer > The way your function is designed, it will only update 1 record: you iterate PointTransaction to calculate balance. Then you use a get on UserPointTypeAggregate which will give you 1 or no objects. Then you assign the balance value and save it. If you are running on the development server, you can use print statements to check you code. If you're on production, you can use the logging package to achieve printing debugging messages in a file. Regards, Benedict > > > Benedict Verheyen wrote: >> Merric Mercer schreef: >> >>> Help! I have a function that is provided below. When I try the >>> individual lines of the function through the interpretor (Ipython) >>> everything works as expected. For example:- >>> >>> >> qset=PointTransaction.objects.filter etc this works fine!! >>> >>> However, when I try to run the function as a whole: Example:- >>> >>> >> admin_sync_agg(user_id=1,points_type=1) >> >>> >>> This runs but it seems that is is not iterating through the query set, >>> so only the first record of qset is getting added to the balance. >>> >>> Can anybody advise.. it's completely baffling me. Thanks >>> >>> MerMer >>> >>> >>> def admin_sync_agg (user_id,points_type): >>> >>> qset=PointTransaction.objects.filter(user=user_id).filter(points_type=points_type) >>> credit=0 >>> debit=0 >>> for i in qs: >>> credit = credit + i.credit >>> debit = credit + i.debit >>> balance= credit-debit >>> >>> pa=UserPointTypeAggregate.objects.get(user=user_id,points_type=points_type) >>> pa.total_points=balance >>> pa.save() >>> >> You are iterating over qs instead of qset. >> >> def admin_sync_agg (user_id,points_type): >> qset=PointTransaction.objects.filter(user=user_id).filter(points_type=points_type) >> credit=0 >> debit=0 >> for i in qset: >> credit = credit + i.credit >> debit = credit + i.debit >> balance= credit-debit >> pa=UserPointTypeAggregate.objects.get(user=user_id,points_type=points_type) >> pa.total_points=balance >> pa.save( >> >> (indentation of qset & pa line screwed up using Thunderbird) >> >> Regards, >> Benedict >> >> >> >> > > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
ObjectPaginator misbehaving with custom query_sets
I've the following problem: I am making a fulltext-index based search, resulting in a query_set constructed in a somewhat more complex way: revisions = Revision.objects.select_related().filter(published=True, contentEntry__master__archived=False).extra(select={"relevance":"MATCH (title, cont\ ent) AGAINST (%s)"}, where=("MATCH (title, content) AGAINST (%s)", subquery), params=("certificate", "certificate")).order_by("- relevance") This is packed as a custom Manager function, since the subquery is out of context, if I'm not using select_related. The subquery there is a dependent subquery that takes care to only look in the latest article revision. It all works as a charm, using the resulting set is not a problem. Except when I pass it to a paginator, in which case I get SQL query error: (1054, "Unknown column 'kb_article_contententry.id' in 'where clause'"). As I see it, this is the subquery, failing to execute, since the count probably does not add the necessary joins for it to be valid. The problem comes when the ObjectPaginator tries to select the "hits" property. The current code executes this: if self._hits is None: # Try .count() or fall back to len(). try: self._hits = int(self.query_set.count()) except (AttributeError, TypeError, ValueError): # AttributeError if query_set has no object count. # TypeError if query_set.count() required arguments. # ValueError if int() fails. self._hits = len(self.query_set) return self._hits Which in my situation does not handle the exception and it's being propagated upwards. Is there any good solution to the problem, such that .count() will be able to include the necessary joins for my query to work ? --~--~-~--~~~---~--~~ 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: newb question: Kind of confused MEDIA_URL, MEDIA_ROOT, SITE_MEDIA and so on.
* Jeremy Dunck wrote, On 14.02.2007 19:33: > On 2/14/07, Joseph Heck <[EMAIL PROTECTED]> wrote: >> It's worth noting that to use the MEDIA_URL settings in your template, >> you'll need to either pass it down through the views into the Template >> context, or write a quick little middleware that always pushes it into the >> context (which is what I did). >> > > This is what context processors are for: > http://www.djangoproject.com/documentation/templates_python/#subclassing-context-requestcontext Or you can use simple template tag like this: from django import template from django.conf import settings # register library register = template.Library() def MEDIA_URL(): """ return MEDIA_URL """ return settings.MEDIA_URL.rstrip('/') register.simple_tag(MEDIA_URL) I don't like to stuff things into the context which are not related to the current view. This way template namespace is a little cleaner. -- Nebojša Đorđević - nesh, ICQ#43799892 Studio Quattro - Niš - Serbia http://studioquattro.biz/ | http://trac.studioquattro.biz/djangoutils/ Registered Linux User 282159 [http://counter.li.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 -~--~~~~--~~--~--~---
Re: iteration of query set appears to fail when running function directly from interpretor
Apologies, for wasting time the problem was with the line. Couldn't see the wood for the trees! debit = credit + i.debit should read debit = debit + i.debit MerMer Benedict Verheyen wrote: > Merric Mercer schreef: > >> Benedict, >> >> Unfortunately, that is just a typo in my post and not the answer. The >> actual code has 'for i in qset'. >> >> The code runs without displaying any errors. But when I check the >> "UserPointTypeAggregate" database the field has >> only been updated from the first record of the PointTransaction query set. >> >> MerMer >> >> > > The way your function is designed, it will only update 1 record: > you iterate PointTransaction to calculate balance. > Then you use a get on UserPointTypeAggregate which will give you > 1 or no objects. > Then you assign the balance value and save it. > > > If you are running on the development server, you can use print > statements to check you code. > If you're on production, you can use the logging package to achieve > printing debugging messages in a file. > > Regards, > Benedict > > >> Benedict Verheyen wrote: >> >>> Merric Mercer schreef: >>> >>> Help! I have a function that is provided below. When I try the individual lines of the function through the interpretor (Ipython) everything works as expected. For example:- >> qset=PointTransaction.objects.filter etc this works fine!! However, when I try to run the function as a whole: Example:- >> admin_sync_agg(user_id=1,points_type=1) >> This runs but it seems that is is not iterating through the query set, so only the first record of qset is getting added to the balance. Can anybody advise.. it's completely baffling me. Thanks MerMer def admin_sync_agg (user_id,points_type): qset=PointTransaction.objects.filter(user=user_id).filter(points_type=points_type) credit=0 debit=0 for i in qs: credit = credit + i.credit debit = credit + i.debit balance= credit-debit pa=UserPointTypeAggregate.objects.get(user=user_id,points_type=points_type) pa.total_points=balance pa.save() >>> You are iterating over qs instead of qset. >>> >>> def admin_sync_agg (user_id,points_type): >>> qset=PointTransaction.objects.filter(user=user_id).filter(points_type=points_type) >>> credit=0 >>> debit=0 >>> for i in qset: >>> credit = credit + i.credit >>> debit = credit + i.debit >>> balance= credit-debit >>> pa=UserPointTypeAggregate.objects.get(user=user_id,points_type=points_type) >>> pa.total_points=balance >>> pa.save( >>> >>> (indentation of qset & pa line screwed up using Thunderbird) >>> >>> Regards, >>> Benedict >>> >>> >>> >>> >>> >> > > > > > > > --~--~-~--~~~---~--~~ 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: Image upload - self.image not defined in save method
* Dirk Eschler wrote, On 13.02.2007 11:12: > Hello, > > i use ImageWithThumbnailField to upload screenhots. In the save method i want > to set some additional model fields, like filesize and width/height of the > uploaded image. The problem is, that self.image isn't defined at this point, > the same entry has to be saved twice in the admin. pre_save signal at which image rename/processing is done is fired up from django.db.Model.save() so you must call it first if you want to have your image renamed. OTOH, self.image (before calling save) is populated with original file name (IIRC when I used to manually create thumbnails in the save() method). More precisely it is populated at the point of dispatching pre_save signal which is the first line in the base model save() (look at the source of ImageWithThumbnailField). > > Checking for self.image (like i read in another thread) doesn't work for me. > Is there any way to get around this problem? > > # - > class Screenshot(models.Model): > image= ImageWithThumbnailField(upload_to='upload/screenshots/') image= ImageWithThumbnailField(upload_to='upload/screenshots/', width_field='width', height_field='height') > filesize = models.PositiveIntegerField(null=True, blank=True, > editable=False) .get_image_size() > width= models.PositiveSmallIntegerField(null=True, blank=True, > editable=False) .get_image_width() > height = models.PositiveSmallIntegerField(null=True, blank=True, > editable=False) .get_image_height() > > def get_image_path(self): > return '%s/%s' % (settings.MEDIA_ROOT, self.image) .get_image_filename(). > > def save(self): > super(Screenshot, self).save() > if self.image: > self.filesize = getsize(self.get_image_path()) > img = Image.open(self.get_image_path()) > self.width = img.size[0] > self.height = img.size[1] > Or if you want to store filesize/whatever in the database: def save(self): super(Screenshot, self).save() self.filesize = getsize(self.get_image_filename()) super(Screenshot, self).save() # save again to store filesize It saves twice to the database, but IMHO this is not a big problem. I presumed that `image` field is required so that never be a case of empty `image` field submission. Also you can subclass ImageWithThumbnailField and override _save() like this (untested): class ScreenshotImageField(ImageWithThumbnailField): def _save(self, instance=None): super(ScreenshotImageField, self)._save(instance) # do the renaming stuff setattr(instance, 'filesize', getsize(getattr(instance, 'get_%s_filename' % self.attname)()) This way you can avoid need for overriding .save() method. I hope that helps. -- Nebojša Đorđević - nesh, ICQ#43799892 Studio Quattro - Niš - Serbia http://studioquattro.biz/ | http://trac.studioquattro.biz/djangoutils/ Registered Linux User 282159 [http://counter.li.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 -~--~~~~--~~--~--~---
Re: Listing users
That's a very good question, Dougal, and I'm too much of a noob to be able to answer it. I THINK those lookups are lazy, but I'd love to hear from someone who knows more about it. On Feb 14, 8:47 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > The problem I have with this is that, if I'm correctly understand what > goes on, when I do a select_related all the related objects are > retrieved. In this case, if a user has made, say, 4000 posts plus > other types of contributions, it seems like it's pulling in a lot of > unnecessary data. > > Am I misunderstanding or is this correct? > > Thanks for the ideas, > -Dougal > > On Feb 14, 11:46 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: > > > I just use a generic list view and send it > > user_dict = { > > 'queryset': GpUser.objects.all(),} > > > GpUser is my model that extends auth.user > > > On Feb 14, 2:47 am, "Aidas Bendoraitis" <[EMAIL PROTECTED]> > > wrote: > > > > Your profile perhaps is related by a foreign key to the user, which > > > means that theoretically one user can have several profiles. > > > Therefore, in my opinion, you should get the profiles and use > > > select_related() for related users. > > > > profiles = > > > UserProfile.objects.select_related().order_by('user__id')[offset:limit] > > > > Regards, > > > Aidas Bendoraitis [aka Archatas] > > > > On 2/14/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > > > > I have a site with users and an additional user_profile to store extra > > > > information like a signature, avatar, etc. > > > > > I cannot figure out how to use a single query to get a list of users > > > > and at the same time join in their user_profile information. > > > > > Currently I have this: > > > > > users = User.objects.all().order_by('id')[offset:limit] > > > > > But I can't figure out how to get their profiles joined to that query. > > > > Any ideas? > > > > > thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using django for CMS stuff
I'm going to respectfully disagree with Kenneth. Django CAN be just the thing, even if you're not a programmer. The things you can accomplish just with generic views are mind-boggling. I'm not much of a programmer (as is evident by many of my posts here) but I chose Django over an off-the-shelf CMS because none of the off- the-shelf systems would do what I wanted, how I wanted. Not even close. For my purposes, I always found like I was shoving a square peg in a round hole. I also found the admin sections to be almost- universally clunky, and the output code to be horrible. Anyway, I managed to muddle through. Some things, like a blog or news aggregator, are trivially easy to build in Django. Other things, like e-commerce, are going to be more difficult. Many things have already been built and are available for your use. Figure out what YOU need. If an off-the-shelf system meets them, that may be the way to go. If you feel like you're fighting with the tool, you probably need better tools. Django is like a big Snap-On truck just for you. On Feb 14, 3:43 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > On 15-Feb-07, at 1:49 AM, [EMAIL PROTECTED] wrote: > > > Django is very good for CMS like apps. I develop Diamanda Wiki and > > MyghtyBoard forum (www.rkblog.rk.edu.pl) and each app has it's own > > folder for code/templates and can be rather easily used in other > > projects :) > > if you want a readymade cms with all those goodies ready to go - then > django will not suit. In django, to a greater or lesser extent, you > have to either roll your own or modify code written by others (if > they allow). So and end user of a CMS (ie a non-programmer who is > setting up his own CMS) would be happier with something like plone > (or mambo, jumbo etc). Django is meant for programmers who would like > to have a finely tuned, customised site to offer to the enduser. > > -- > > regards > kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/web/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django bug?
I don't know if I'm just confused or if it's a bug in Django, but here's a little bit of code I put in a shell: >>> sunday = datetime.date(2006, 12, 3) >>> saturday = sunday + datetime.timedelta(days=6) >>> next_sunday = sunday + datetime.timedelta(days=7) >>> for day in (sunday, saturday, next_sunday): print day.strftime("%A, >>> %d-%b-%Y") ... Sunday, 03-Dec-2006 Saturday, 09-Dec-2006 Sunday, 10-Dec-2006 >>> e.get_messages().filter(date_saisie__gte=sunday, >>> date_saisie__lte=saturday).count() 63L >>> e.get_messages().filter(date_saisie__gte=sunday, >>> date_saisie__lt=next_sunday).count() 68L >>> Why the difference in the number of messages found? Isn't "<= saturday" equivalent to "< next_sunday"? --~--~-~--~~~---~--~~ 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 bug?
Ah, don't bother replying. The field date_saisie is actually a DateTime, so that explains it. Sorry. On Feb 15, 11:22 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I don't know if I'm just confused or if it's a bug in Django, but > here's a little bit of code I put in a shell: > > >>> sunday = datetime.date(2006, 12, 3) > >>> saturday = sunday + datetime.timedelta(days=6) > >>> next_sunday = sunday + datetime.timedelta(days=7) > >>> for day in (sunday, saturday, next_sunday): print day.strftime("%A, > >>> %d-%b-%Y") > > ... > Sunday, 03-Dec-2006 > Saturday, 09-Dec-2006 > Sunday, 10-Dec-2006 > > >>> e.get_messages().filter(date_saisie__gte=sunday, > >>> date_saisie__lte=saturday).count() > 63L > >>> e.get_messages().filter(date_saisie__gte=sunday, > >>> date_saisie__lt=next_sunday).count() > 68L > > Why the difference in the number of messages found? Isn't "<= > saturday" equivalent to "< next_sunday"? --~--~-~--~~~---~--~~ 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 bug?
[EMAIL PROTECTED] wrote: > I don't know if I'm just confused or if it's a bug in Django, but > here's a little bit of code I put in a shell: > sunday = datetime.date(2006, 12, 3) saturday = sunday + datetime.timedelta(days=6) next_sunday = sunday + datetime.timedelta(days=7) for day in (sunday, saturday, next_sunday): print day.strftime("%A, %d-%b-%Y") > ... > Sunday, 03-Dec-2006 > Saturday, 09-Dec-2006 > Sunday, 10-Dec-2006 e.get_messages().filter(date_saisie__gte=sunday, date_saisie__lte=saturday).count() > 63L e.get_messages().filter(date_saisie__gte=sunday, date_saisie__lt=next_sunday).count() > 68L > > Why the difference in the number of messages found? Isn't "<= > saturday" equivalent to "< next_sunday"? I'd suspect your database data type is tripping you up. I would verify that your database handles date comparisons the way you think it does. The first django filter above would equate roughly to: WHERE date_saisie >= '2006-12-03' AND date_saisie <= '2006-12-09'. I use postgresql which I think would interpret this as "from '2006-12-03 00:00:00' to '2006-12-09 00:00:00'". And the second one: "from '2006-12-03 00:00:00' to '2006-12-10 00:00:00". The second form includes all TIMES after 'saturday' started until the end of that day. The first form doesn't include TIMES after the very beginning of 'saturday'. Eric. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Aggregate stats for recordsets...best practices?
For reporting purposes, we're hoping to summarize a variety of fields across volumes of data. I know recordsets currently have a count() method that returns the number of rows. However, I'm trying to find a good way of obtaining max/min/sum/avg results for all the items in the recordset. I can hand-roll the SQL as necessary, but would prefer to be able to reuse the queries I've already built up in standard Django-ese if possible. My figured-it-would-fail first attempt was to use the extra() call to add the aggregate functions to the SELECT clause. As expected, it failed because I was mixing aggregate and non-aggregate fields. The underlying data can return thousands of records so it would be a bad idea to try and do the aggregation on the Django side of things (the final results are ObjectPaginator'ed, so the actual full-data never actually makes it back to Django). I don't know enough about the query-sets' internal representation to go monkeying with the internal SQL, but with a little guidance, this sounds like a viable route to explore. Such could even be generated somewhat automatically by inspecting the Model subclass for FloatField/IntegerField and their kin (Small/Positive prefixed items). Does anybody have any experience with this and can give war-stories about good or bad ways to do this? Thanks, -tkc --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Hi
Hi go to http://www.maduraiman.co.nr for downloading free softwares,games,videos, ring tones, making money online,Power point slide shows, etc., http://www.maduraiman.co.nr http://www.maduraiman.co.nr http://www.maduraiman.co.nr http://www.maduraiman.co.nr http://www.maduraiman.co.nr http://www.maduraiman.co.nr http://www.maduraiman.co.nr http://www.maduraiman.co.nr http://www.maduraiman.co.nr http://www.maduraiman.co.nr http://www.maduraiman.co.nr http://www.maduraiman.co.nr http://www.maduraiman.co.nr http://www.maduraiman.co.nr http://www.maduraiman.co.nr http://www.maduraiman.co.nr http://www.maduraiman.co.nr --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Comparison between Dreamhost and ASmallOrange
I thought this might be useful for those considering Django hosting alternatives. I've been working on a Dreamhost server for quite a while for a friend's site and just started working on a site for a non-profit group who agreed to try a new host (ASmallOrange). While working on the ASO server, it seemed much faster and more responsive, so I thought I would copy the project from Dreamhost to ASO to see how they compared. I've been happy with Dreamhost, but ASO is insanely fast compared to Dreamhost. Same installation on both, except that the ASO example uses flup and Dreamhost uses fcgi.py (since I could never get flup to work there). Compare for yourselves: http://www.ebbflowarts.com/ (Dreamhost) http://ebb.kanzatrails.org/ (ASmallOrange) (Also, in case someone notices, yes the Gallery thumbnails are actually the full sized images...my friend hasn't created thumbs yet, so it will become even faster then. And also if anyone is curious, the store is turned off because she's still adding items. It should be on by tomorrow.) Hope this is helpful. I'll leave the copied project up for a couple days so people can see, but I'm going to try to talk my friend into just switching over to ASO. Branton --~--~-~--~~~---~--~~ 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: Comparison between Dreamhost and ASmallOrange
By the way, I would also appreciate any comments on the site. It's a work in progress, mainly in the middle of the night, so I know there's much left to do. On Feb 15, 12:01 pm, "sansmojo" <[EMAIL PROTECTED]> wrote: > I thought this might be useful for those considering Django hosting > alternatives. > > I've been working on a Dreamhost server for quite a while for a > friend's site and just started working on a site for a non-profit > group who agreed to try a new host (ASmallOrange). While working on > the ASO server, it seemed much faster and more responsive, so I > thought I would copy the project from Dreamhost to ASO to see how they > compared. I've been happy with Dreamhost, but ASO is insanely fast > compared to Dreamhost. Same installation on both, except that the ASO > example uses flup and Dreamhost uses fcgi.py (since I could never get > flup to work there). > > Compare for > yourselves:http://www.ebbflowarts.com/(Dreamhost)http://ebb.kanzatrails.org/(ASmallOrange) > > (Also, in case someone notices, yes the Gallery thumbnails are > actually the full sized images...my friend hasn't created thumbs yet, > so it will become even faster then. And also if anyone is curious, > the store is turned off because she's still adding items. It should > be on by tomorrow.) > > Hope this is helpful. I'll leave the copied project up for a couple > days so people can see, but I'm going to try to talk my friend into > just switching over to ASO. > > Branton --~--~-~--~~~---~--~~ 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: Threaded versus forked how can I tell?
Hi, Thanks, but that is not what I'm looking for. I need to find out at runtime from within my code. Something like. if i_am_threaded: do_something_thread_safe else: do_something_thread_unsafe I suppose this is more a python question than a Django one. So sorry for the off topic. Best Regards On 2/4/07, Frédéric Roland <[EMAIL PROTECTED]> wrote: > > Hi, > > I found the answer here http://httpd.apache.org/docs/2.0/mpm.html > > in short just type > > ./httpd -l > > (Lower case "L") > > And you will see the list of all modules compiled in your apache server. > If you see prefork.c it should be ok. > > CC > > Jakub Labath a �crit : > > Hi, > > > > Is there a way to detect in my code if I'm running in prefork or threaded > > mode? > > > > Jakub > > > > > > > > > > > > > > > > > > > -- Jakub Labath --~--~-~--~~~---~--~~ 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: Threaded versus forked how can I tell?
On Feb 15, 2007, at 10:30 AM, Jakub Labath wrote: > Hi, > > Thanks, but that is not what I'm looking for. > > I need to find out at runtime from within my code. Something like. Since, you can't change modes during runtime, I would set an environment variable when you start the server and test for that in your code. Don --~--~-~--~~~---~--~~ 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: Threaded versus forked how can I tell?
On 2/1/07, Jakub Labath <[EMAIL PROTECTED]> wrote: > > Is there a way to detect in my code if I'm running in prefork or threaded > mode? Your best bet is probably through mod_python. I'd probably start by looking here first: http://www.modpython.org/live/current/doc-html/module-apache.html 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: Aggregate stats for recordsets...best practices?
Hey Tim, Tim Chase wrote: > For reporting purposes, we're hoping to summarize a variety of > fields across volumes of data. I know recordsets currently have > a count() method that returns the number of rows. However, I'm > trying to find a good way of obtaining max/min/sum/avg results > for all the items in the recordset. I can hand-roll the SQL as > necessary, but would prefer to be able to reuse the queries I've > already built up in standard Django-ese if possible. I've had success 'hand-rolling' complex SQl into a VIEW (let's assume your DB has views). To Django your views look and behave like any other table (for reading data and possibly for writing data (depending on your view)). Create a Django model that uses the view like they normally use a table. You can then create Django model objects that return the results of your view, including Django's yummie filter stuff. I've found there is a threshold at which hand-rolling complex SQL is easier on my brain than trying to bend Django's ORM to my will. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Model instance identity
I think in this case the Python docs were mis-interpreted. The key point to consider when writing a __hash__ function is that two objects that compare equal must hash equally, and the hash value cannot change. Just because an object is mutable doesn't mean that these rules will be violated. In particular, Django model instances will usually simply use their id attribute as the hash, and so will be perfectly acceptable as dictionary keys. --Ned. On Feb 14, 10:19 am, Ivan Sagalaev <[EMAIL PROTECTED]> wrote: > David Abrahams wrote: > > I just wrote some code that used Model instances as keys in a dict, > > and was surprised to find two instances in the dict that represented > > the same object in the database. Shouldn't that be impossible? If > > you can't guarantee that a given object in the database is always > > represented by the same Python instance, shouldn't django.db.Model > > have __hash__ and __eq__ methods that makes equivalent instances hash > > the same? > > This is a known issue:http://code.djangoproject.com/ticket/2936 > > The ticket was closed as "invalid" with a good reason (model instances > are mutable and shouldn't be used as keys in dicts). --~--~-~--~~~---~--~~ 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: Comparison between Dreamhost and ASmallOrange
Thanks for posting, Branton. Just curious, ASO service plan are you using? On Feb 15, 11:01 am, "sansmojo" <[EMAIL PROTECTED]> wrote: > I thought this might be useful for those considering Django hosting > alternatives. > > I've been working on a Dreamhost server for quite a while for a > friend's site and just started working on a site for a non-profit > group who agreed to try a new host (ASmallOrange). While working on > the ASO server, it seemed much faster and more responsive, so I > thought I would copy the project from Dreamhost to ASO to see how they > compared. I've been happy with Dreamhost, but ASO is insanely fast > compared to Dreamhost. Same installation on both, except that the ASO > example uses flup and Dreamhost uses fcgi.py (since I could never get > flup to work there). > > Compare for > yourselves:http://www.ebbflowarts.com/(Dreamhost)http://ebb.kanzatrails.org/(ASmallOrange) > > (Also, in case someone notices, yes the Gallery thumbnails are > actually the full sized images...my friend hasn't created thumbs yet, > so it will become even faster then. And also if anyone is curious, > the store is turned off because she's still adding items. It should > be on by tomorrow.) > > Hope this is helpful. I'll leave the copied project up for a couple > days so people can see, but I'm going to try to talk my friend into > just switching over to ASO. > > Branton --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
catalog of django apps?
Has anyone give much thought to building a "Cheeseshop" for reusable Django apps? I have a bunch of ideas but want to check what's been done already. I'm thinking it could be a two-tiered catalog: one tier accepting all submissions, the other tier being more constrained to apps that follow certain conventions to improve interoperability with one another. One potential name that came to mind is "Hot Club of France" :-) 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: catalog of django apps?
On 2/15/07, James Tauber <[EMAIL PROTECTED]> wrote: > Has anyone give much thought to building a "Cheeseshop" for reusable > Django apps? A couple people have tried to start sourceforge-esque sites for hosting Django apps, but so far none of them have taken off. Personally, I've just been using Google Code to set up SVN repos for a couple things I'm working on, but if there were such a site I'd list apps there as I finish them. If someone wants to do it for real, I'd be more than happy to pitch in and contribute code for a system to track apps, categories, versions, etc... -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Users permissions
Hello, I'm thinking about create a website using django. One of the apps would be a news section, where everybody can publish the news (perhaps after approval) and where the users can edit and delete their own news, but not the other users news. Is it possible to implement this within the django admin or should I create a specific application for this? I accept suggestions about how to do it. Thank you! --~--~-~--~~~---~--~~ 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: Aggregate stats for recordsets...best practices?
> Does anybody have any experience with this and can give war-stories about > good or bad ways to do this? I just finished updating an aggregate-rich view and I think it is better to use SQL than messing with filters for most complex things. My basic rule of thumb is to use python functions to aggregate for less than 20 expected rows & SQL beyond that. You can sometimes figure the filter code it to work with the other fields, where, select etc but it is not worth it - you end up with something that is unreadable. The point is not to avoid writing all SQL, it is just to make it simpler in most cases and to fit your performance requirements. Do try to keep it organized/consistent though, if you can. The absolute best thing you can do is write a good test suite. Since the aggregate functions are trickier it will pick up on nuances you might miss with schema changes & should make your testing a little quicker. Also it gives you a performance benchmark, which I've used to change designs on some views. HTH, -rob --~--~-~--~~~---~--~~ 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: Users permissions
it's impossible at the moment, but it should be possible with the newforms-admin branch via a hook On 2/15/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Hello, I'm thinking about create a website using django. One of the > apps would be a news section, where everybody can publish the news > (perhaps after approval) and where the users can edit and delete their > own news, but not the other users news. > Is it possible to implement this within the django admin or should I > create a specific application for this? > I accept suggestions about how to do it. > > Thank you! > > > > > -- Honza Kr�l E-Mail: [EMAIL PROTECTED] ICQ#: 107471613 Phone: +420 606 678585 --~--~-~--~~~---~--~~ 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: Users permissions
On 2/16/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Is it possible to implement this within the django admin or should I > create a specific application for this? The right solution here is to write your own application. The admin view is intended to be just that - an adminstration view. It isn't a CMS, or any other breed of end-user application. It is a low level view of your data structures, that trusted users can use to enter or tweak data. It is not intended to be the publicly visible face of any application. That's not to say you can't leverage off the admin view. The Admin view gets most of its magic from generic views; learn how to use these, and you should be able to prototype your custom application (with its own workflows, etc) relatively quickly. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django and Eclipse Autocomplete NOT WORKING
Igor Guerrero wrote: > You must add the app dir and django dir to the PYTHON_PATH env variable in > the preferrence menu and rescan the PATH. It worked well with 0.95 version (just need to add django dir to the PYTHON PATH of Eclipse) but with svn version it looks it does not work any longer for me. Any idea about this ? Nicolas --~--~-~--~~~---~--~~ 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: catalog of django apps?
On 15/02/2007, at 8:48 PM, James Bennett wrote: > > On 2/15/07, James Tauber <[EMAIL PROTECTED]> wrote: >> Has anyone give much thought to building a "Cheeseshop" for reusable >> Django apps? > > A couple people have tried to start sourceforge-esque sites for > hosting Django apps, but so far none of them have taken off. I wasn't thinking of hosting the development - I agree Google Code Project Hosting is perfect for that. > Personally, I've just been using Google Code to set up SVN repos for a > couple things I'm working on, but if there were such a site I'd list > apps there as I finish them. Great - you're one of the people I was hoping would contribute apps! > If someone wants to do it for real, I'd be more than happy to pitch in > and contribute code for a system to track apps, categories, versions, > etc... That would be great. In fact, it would be nice if many of the component apps of the site were themselves available on the site for building other software component catalog sites. What do you think of the idea of having (optional) conventions for improving the ability of apps to work together? 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: How to do dynamic lookup of variables.
Hi Benedict Verheyen wrote: > When i need such functionality, i assign values to vars of the list items. > For instance, in your case i would do something like this > def experiments(request): > experiment_list = Experiment.objects.all() > ecount = len(experiment_list) + 1 > > for e in experiment_list: > e.proc_count = e.experiment_procedure_set.all().count() > return render_to_response('lab/experiments.html', >{'experiment_list': experiment_list, >'ecount': ecount, >}) > > As you've seen, i reuse the experiment_list to loop over and assign > values too. > This is from the top of my head so i hope it works :) Yes it does work, thanks heaps. I presume though that the render_to_return is outside of the previous for loop as below. for e in experiment_list: e.proc_count = e.experiment_procedure_set.all().count() return render_to_response('lab/experiments.html', {'experiment_list': experiment_list, 'ecount': ecount, }) Anyhow with the above I now get the correct list of procs for each experiment. So what's happening I understand is that I'm creating a new attribute or method of the object e called .proc_count by simply assigning e.proc_count a value? > Mike Lake schreef: >>Im trying to place into a list of experiments the number of procedures for >>each experiment. >>From within the views.py I can save the number of procedures in an experiment >>into either a list of tuples (e.id, count) or a dictionary {'e.id': count}. >>But when I come to access them in the templates I can't do something like {{ >>e."e.id".1 }} >> >>The template: >> >>This works: {{ pcount.1.1 }} is the number of procedures in experiment 1. >>This works: {{ pcount.2.1 }} is the number of procedures in experiment 2. >> >>{% for e in experiment_list %} >>{{ e.id }} >>{{ e.name }} >>{{ e."e.id".1 }} <- what to use here though ??? >>{% endfor %} >> >>In views.py: >> >>def experiments(request): >>experiment_list = Experiment.objects.all() >>ecount = len(experiment_list) + 1 >> >># TODO create a dictionary of the number of procedures in each experiment. >>pcount = [] >>my_tuple = () >>for e in Experiment.objects.all(): >>my_count = e.experiment_procedure_set.all().count() >>pcount.append( (e.id, my_count) ) >> >>return render_to_response('lab/experiments.html', >>{'experiment_list': experiment_list, >> 'ecount': ecount, # ecount is the number of experiments. >> 'pcount': pcount, # pcount is the number of procedures in an >> experiment. >>}) >> >>There are references to 'dynamic lookup' of variables in the docs for >>template authors. >>But this seems very complex to use custom tags and filters. I know the docs >>can be a little behind the development version so is there an easy way to do >>this? Mike -- 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: catalog of django apps?
Is there a reason *not* to use the Cheeseshop, and utilize the metadata framework it provides? For example, Zope Corp publishes Zope-specific pieces there and marks them as "Framework:Zope" (or something like that... don't recall exactly). This makes the packages available to setuptools enabled tools. Nathan On 2/15/07, James Tauber <[EMAIL PROTECTED]> wrote: > > On 15/02/2007, at 8:48 PM, James Bennett wrote: > > > > > On 2/15/07, James Tauber <[EMAIL PROTECTED]> wrote: > >> Has anyone give much thought to building a "Cheeseshop" for reusable > >> Django apps? > > > > A couple people have tried to start sourceforge-esque sites for > > hosting Django apps, but so far none of them have taken off. > > I wasn't thinking of hosting the development - I agree Google Code > Project Hosting is perfect for that. > > > Personally, I've just been using Google Code to set up SVN repos for a > > couple things I'm working on, but if there were such a site I'd list > > apps there as I finish them. > > Great - you're one of the people I was hoping would contribute apps! > > > If someone wants to do it for real, I'd be more than happy to pitch in > > and contribute code for a system to track apps, categories, versions, > > etc... > > That would be great. In fact, it would be nice if many of the > component apps of the site were themselves available on the site for > building other software component catalog sites. > > What do you think of the idea of having (optional) conventions for > improving the ability of apps to work together? > > 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: Problems with session middleware
Hello, please...nobody have a clue? I've run into same issue again and it's somehow making django usuable for me :-( (and yes, still with the freshest trunk) Thank You, Almad On Jan 28, 4:30 pm, "Almad" wrote: > Hello, > > I'd like to ask about session/auth middleware I'm trying to use. --~--~-~--~~~---~--~~ 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: Users permissions
On 2/15/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Hello, I'm thinking about create a website using django. One of the > apps would be a news section, where everybody can publish the news > (perhaps after approval) and where the users can edit and delete their > own news, but not the other users news. > Is it possible to implement this within the django admin or should I > create a specific application for this? > I accept suggestions about how to do it. If you use the row-level permissions branch, you *can* do this from the Admin. However, that branch isn't really being maintained right now. I'm using it on one website, and it's working nicely for me. However, I would recommend that normal end users not be allowed to use it, just "trusted" admins. Jay P. --~--~-~--~~~---~--~~ 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: Problems with session middleware
On 2/16/07, Almad <[EMAIL PROTECTED]> wrote: > > Hello, > > please...nobody have a clue? > > I've run into same issue again and it's somehow making django usuable > for me :-( > > (and yes, still with the freshest trunk) > > Thank You, > > Almad my guess would be that you are somewhere returning a string instead of a HttpResponse object... so some middleware's process_response which is trying to get the response_code gets confused... but its only a guess btw. priste se rovnou ptej na nyxu, tam se divam casteji ;) > > On Jan 28, 4:30 pm, "Almad" wrote: > > Hello, > > > > I'd like to ask about session/auth middleware I'm trying to use. > > > > > -- Honza Kr�l E-Mail: [EMAIL PROTECTED] ICQ#: 107471613 Phone: +420 606 678585 --~--~-~--~~~---~--~~ 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: catalog of django apps?
On 2/15/07, James Tauber <[EMAIL PROTECTED]> wrote: > That would be great. In fact, it would be nice if many of the > component apps of the site were themselves available on the site for > building other software component catalog sites. Absolutely. I'm a fan of open-source sites (hopefully going to be launching one soon!). > What do you think of the idea of having (optional) conventions for > improving the ability of apps to work together? I've come across a few useful things I've been meaning to write up, but I've already got a huge backlog of blog entries I need to finish :) I think that a lot of it comes down to four things: 1. Good conventions for code structure, so things end up in predictable locations. 2. Use of the "app directories" template loader so you can distribute sample templates with the app. 3. Careful import statements which don't rely on the name of an overarching project (which isn't hard, but a little different setup from when people do a project where all the apps live in directories under the project dir). 4. Documentation. Can't stress this one enough: having both standalone documentation and docstrings and comments throughout the code can make or break an app's reusability. Anybody else got thoughts on useful ways to help the reusability of a Django app? There are some other minor things like how to safely handle custom SQL, but the four I've listed are, in my experience, the big ones. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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: catalog of django apps?
On 2/16/07, James Bennett <[EMAIL PROTECTED]> wrote: > > On 2/15/07, James Tauber <[EMAIL PROTECTED]> wrote: > > That would be great. In fact, it would be nice if many of the > > component apps of the site were themselves available on the site for > > building other software component catalog sites. > > Absolutely. I'm a fan of open-source sites (hopefully going to be > launching one soon!). > > > What do you think of the idea of having (optional) conventions for > > improving the ability of apps to work together? > > I've come across a few useful things I've been meaning to write up, > but I've already got a huge backlog of blog entries I need to finish > :) > > I think that a lot of it comes down to four things: > > 1. Good conventions for code structure, so things end up in > predictable locations. > 2. Use of the "app directories" template loader so you can distribute > sample templates with the app. > 3. Careful import statements which don't rely on the name of an > overarching project (which isn't hard, but a little different setup > from when people do a project where all the apps live in directories > under the project dir). > 4. Documentation. Can't stress this one enough: having both standalone > documentation and docstrings and comments throughout the code can make > or break an app's reusability. > > Anybody else got thoughts on useful ways to help the reusability of a > Django app? There are some other minor things like how to safely > handle custom SQL, but the four I've listed are, in my experience, the > big ones. > Good points. And I also think about the deployment or installation of the apps, and also want to easy deal with static files, such as css, images, js, of cause these may still mainly associated with deployment things. And consider the Ajax and reuse, so I think how to improve the reuse of common apps, for example: 1. How to include templates or extend templates 2. How to reuse the view functions 3. How to deal ajax functionalities 4. How to seperate common functionalities and special functionalities Maybe I write not so clearly, but I don't know much about how to express my thoughts, I'm sorry. -- I like python! UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad My Blog: http://www.donews.net/limodou --~--~-~--~~~---~--~~ 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: Extending django.contrib.auth.views.login ?
Easily solved the problem once I realized the difference between HttpRequest and HttpResponse objects (doh!). In the event another nub is looking to make stuff happen post- successful login/logout here's the (now obvious) pseudo-code solution: def user_login(request): response = django.contrib.auth.views.login(request) if request.user.is_authenticated(): do database stuff... return response --~--~-~--~~~---~--~~ 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 do dynamic lookup of variables.
On Feb 14, 4:41 pm, Mike Lake <[EMAIL PROTECTED]> wrote: > There are references to 'dynamic lookup' of variables in the docs for > template authors. > But this seems very complex to use custom tags and filters. A custom lookup filter is quite easy to do, because the template module already has a lookup function. All you need to do is expose it as a filter: from django import template register = template.Library() def lookup(value, key): return template.resolve_variable(key,value) register.filter(lookup) > {{ e."e.id".1 }} <- what to use here though ??? You case is a little different than what I've use this for because you want to do a lookup on the result of the lookup, one of which would be handled normally by the template, the other you need a filter for. I'm not sure if you can use the dot syntax on the result of a filter, but can chain filters, so you could write: {{ e|lookup:e.id|lookup1 }} But this statement looks a little weird to me given what's in your view code. I think you probably meant {{ p_count."e.id".1 }}. Since p_count is a list, I'm not even sure that would work. I'd use a dict, like you mentioned earlier so that you view is something like: for e in Experiment.objects.all(): my_count = e.experiment_procedure_set.all().count() pcount[e.id] = my_count And you template lookup was like: {{ p_count|lookup:e.id }} I think the filter syntax is really unfortunate, since precedence can be hard to determine when using both filters and dot syntax lookups, and filters can only take one parameter. Parenthesized expressions would be a lot better. They're common for a reason. Hope this helped, Justin --~--~-~--~~~---~--~~ 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: catalog of django apps?
Hello, I'm currently working on a "DjangoForge" type of site right now. I've been working on it for the past few weeks with any spare time that I've had. It's definitely not ready for public consumption yet, but it's coming along very nicely and I think that more than a few people will find it useful. I'll definitely post a link to a beta version of the website when it's at that point, along with the source code. It could be really cool if the code for the "DjangoForge" site itself could be public, and available through its own interface. (How meta!) Looking forward to seeing your reactions in some days, Eric Florenzano On Feb 15, 8:11 pm, limodou <[EMAIL PROTECTED]> wrote: > On 2/16/07, James Bennett <[EMAIL PROTECTED]> wrote: > > > > > On 2/15/07, James Tauber <[EMAIL PROTECTED]> wrote: > > > That would be great. In fact, it would be nice if many of the > > > component apps of the site were themselves available on the site for > > > building other software component catalog sites. > > > Absolutely. I'm a fan of open-source sites (hopefully going to be > > launching one soon!). > > > > What do you think of the idea of having (optional) conventions for > > > improving the ability of apps to work together? > > > I've come across a few useful things I've been meaning to write up, > > but I've already got a huge backlog of blog entries I need to finish > > :) > > > I think that a lot of it comes down to four things: > > > 1. Good conventions for code structure, so things end up in > > predictable locations. > > 2. Use of the "app directories" template loader so you can distribute > > sample templates with the app. > > 3. Careful import statements which don't rely on the name of an > > overarching project (which isn't hard, but a little different setup > > from when people do a project where all the apps live in directories > > under the project dir). > > 4. Documentation. Can't stress this one enough: having both standalone > > documentation and docstrings and comments throughout the code can make > > or break an app's reusability. > > > Anybody else got thoughts on useful ways to help the reusability of a > > Django app? There are some other minor things like how to safely > > handle custom SQL, but the four I've listed are, in my experience, the > > big ones. > > Good points. > > And I also think about the deployment or installation of the apps, and > also want to easy deal with static files, such as css, images, js, of > cause these may still mainly associated with deployment things. > > And consider the Ajax and reuse, so I think how to improve the reuse > of common apps, for example: > > 1. How to include templates or extend templates > 2. How to reuse the view functions > 3. How to deal ajax functionalities > 4. How to seperate common functionalities and special functionalities > > Maybe I write not so clearly, but I don't know much about how to > express my thoughts, I'm sorry. > > -- > I like python! > UliPad <>:http://wiki.woodpecker.org.cn/moin/UliPad > My Blog:http://www.donews.net/limodou --~--~-~--~~~---~--~~ 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: catalog of django apps?
On 2/16/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Hello, > > I'm currently working on a "DjangoForge" type of site right now. I've > been working on it for the past few weeks with any spare time that > I've had. It's definitely not ready for public consumption yet, but > it's coming along very nicely and I think that more than a few people > will find it useful. > > I'll definitely post a link to a beta version of the website when it's > at that point, along with the source code. It could be really cool if > the code for the "DjangoForge" site itself could be public, and > available through its own interface. (How meta!) > > Looking forward to seeing your reactions in some days, > Eric Florenzano > Great! I'll waiting for that. -- I like python! UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad My Blog: http://www.donews.net/limodou --~--~-~--~~~---~--~~ 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: Comparison between Dreamhost and ASmallOrange
What I've noticed with Django on Dreamhost is that if your site is hit before the fcgi timeout (2 minutes) its quite responsive. If the fcgi process exits, it has to restart, reconnect to the db, etc. and there is a very couple of seconds delay before things get going again. But I just checked out your site and it does seem quites slow on DH, compared to my site - http://surveys.zdecisions.com. Have you opened a support issue? I recall reading that DreamHost was offering free hosting for all non- profits http://wiki.dreamhost.com/index.php/Non-profit_Discount. Not sure if there's something similar at ASO or not. Good luck, -chasfs On Feb 15, 1:01 pm, "sansmojo" <[EMAIL PROTECTED]> wrote: > I thought this might be useful for those considering Django hosting > alternatives. > > I've been working on a Dreamhost server for quite a while for a > friend's site and just started working on a site for a non-profit > group who agreed to try a new host (ASmallOrange). While working on > the ASO server, it seemed much faster and more responsive, so I > thought I would copy the project from Dreamhost to ASO to see how they > compared. I've been happy with Dreamhost, but ASO is insanely fast > compared to Dreamhost. Same installation on both, except that the ASO > example uses flup and Dreamhost uses fcgi.py (since I could never get > flup to work there). > > Compare for > yourselves:http://www.ebbflowarts.com/(Dreamhost)http://ebb.kanzatrails.org/(ASmallOrange) > > (Also, in case someone notices, yes the Gallery thumbnails are > actually the full sized images...my friend hasn't created thumbs yet, > so it will become even faster then. And also if anyone is curious, > the store is turned off because she's still adding items. It should > be on by tomorrow.) > > Hope this is helpful. I'll leave the copied project up for a couple > days so people can see, but I'm going to try to talk my friend into > just switching over to ASO. > > Branton --~--~-~--~~~---~--~~ 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 do dynamic lookup of variables.
Michael Lake schreef: > Yes it does work, thanks heaps. I presume though that the render_to_return is > outside > of the previous for loop as below. Yes it's outside the loop as you already found out. > for e in experiment_list: > e.proc_count = e.experiment_procedure_set.all().count() > > return render_to_response('lab/experiments.html', > {'experiment_list': experiment_list, > 'ecount': ecount, > }) > > Anyhow with the above I now get the correct list of procs for each > experiment. So > what's happening I understand is that I'm creating a new attribute or method > of the > object e called .proc_count by simply assigning e.proc_count a value? Yes indeed, that's what happens. It's an easy way to "transport" extra data to your templates. Glad it worked. Regards, Benedict --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---