Re: tuple comparison to make one tuple
On Jun 8, 2011, at 9:41 AM, Tom Evans wrote: > On Wed, Jun 8, 2011 at 5:34 PM, MikeKJ <mike.jo...@paston.co.uk> wrote: >> >> I have 3 tuples of email addresses, I want to compare the 3 against each >> other to make a single tuple of email addresses with no duplicates, any >> ideas? > >>>> t1 = ( 'a...@b.com', 'b...@b.com', 'c...@b.com' ) >>>> t2 = ( 'a...@b.com', 'a...@c.com', ) >>>> t3 = ( 'a...@c.com', ) >>>> set(t1) | set(t2) | set(t3) > set(['a...@c.com', 'c...@b.com', 'a...@b.com', 'b...@b.com']) > Depending on the size of the tuples, you can avoid creating extra sets (5 in the example above) with: from itertools import chain set(chain(t1, t2, t3)) Just adding a vote here for other recipes in itertools, http://docs.python.org/library/itertools.html#recipes You could use unique_everseen, still creates a set, but might be useful if you intention is only to iterate through the remaining list. # overkill for example... tuple(unique_everseen(chain(t1, t2, t3))) ('a...@b.com', 'b...@b.com', 'c...@b.com', 'a...@c.com') Jason Culverhouse http://www.mischievous.org > Cheers > > Tom > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: save out a test database?
On May 29, 2011, at 7:13 PM, Margie Roginskiwrote: > Anyone know if there is a way to save out a test database that is > created through the django TestCase module? > I think this gets you close: https://docs.djangoproject.com/en/1.2/ref/django-admin/#testserver-fixture-fixture django-admin.py testserver Runs a Django development server (as in runserver) using data from the given fixture(s). > IE, say I have a test that runs part way through. I'd like to save > it out and then modify my settings.py to refer to the saved out test > database and take a look at it via my web client (ie, runserver) - is > that possible? > > Thanks for any pointers, > > Margie > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Getting "most"
On May 27, 2011, at 9:58 AM, bax...@gretschpages.com wrote: > I have a "watch" model that lets users keep an eye on various things > through a generic relation: > > class Watch(models.Model): >subscriber = models.ForeignKey(User, verbose_name="Subscriber") >content_type = models.ForeignKey(ContentType) >content_object = generic.GenericForeignKey() >object_id = models.IntegerField('object ID') >created = models.DateTimeField(auto_now_add=True) > > > What I'm trying to do is get the most-watched objects. > I saw James Bennett's snippet from 2007 (http://djangosnippets.org/ > snippets/108/) which looks like it would work (subbing my Watch model > for comments), but I'm wondering if there's a better way to do it with > newer versions of django, possibly through annotate or aggregate? > If you were to do something like this: from django.models import count most = Watch.objects.values('content_type', 'object_id').annotate(Count('object_id')).order_by('-object_id__count') [ {'object_id__count': 15, 'object_id': 1, 'content_type': 10}, {'object_id__count': 2, 'object_id': 1, 'content_type': 5}, ... ] # this isn't efficient, but you get the idea # you need to resolve the content types and object id's into models from django.contrib.contenttypes.models import ContentType for object in most: foo = ContentType.objects.get(id= object['content_type']).get_object_for_this_type(object['object_id']) You can also see https://github.com/coleifer/django-generic-aggregation This will get you close but I think it only if you want to annotate the count on a single content type at once. Jason Culverhouse http://www.mischievous.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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How do you apply a decorator to all views in a views.py file?
On May 10, 2011, at 12:50 PM, Shawn Milochik wrote: > I have a decorator I'd like to apply to every view in a given views.py file. > Is there an elegant way to do that in Django? > > I searched Google and the docs but didn't find anything. > > So, I wrote some code which works and demonstrates what I'm trying to do, but > it's really ugly. > http://dpaste.com/hold/540845/ > > Is there a good way to do this? > > If you're using __all__ in views.py (which is a great idea anyway), it can be > MUCH simplified: > http://dpaste.com/540853/ <-- MUCH MUCH better! > I have no way of knowing what the exception_wrapper function in http://dpaste.com/540853/ does, but have you looked into just implementing your exception_wrapper with process_exception in custom middleware? http://docs.djangoproject.com/en/dev/topics/http/middleware/#process-exception """ process_exception(self, request, exception) request is an HttpRequest object. exception is an Exception object raised by the view function. Django calls process_exception() when a view raises an exception. process_exception() should return either None or anHttpResponse object. If it returns an HttpResponse object, the response will be returned to the browser. Otherwise, default exception handling kicks in. Again, middleware are run in reverse order during the response phase, which includes process_exception. If an exception middleware returns a response, the middleware classes above that middleware will not be called at all. """ Jason > The latter dpaste just might be the hot ticket. But I'm still sending this > out just in case there's a "best practice" for this. > > Thanks, > Shawn > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django-voting : How to get objects with number of votes.
On May 6, 2011, at 8:35 AM, Shawn Milochik wrote: > Sorry, I was going off of your pasted code. > > Sounds like this could be a case for annotate. > http://docs.djangoproject.com/en/1.3/ref/models/querysets/#annotate > > I recommend reading this whole page, along with the two prerequisite pages > called for at the top. It'll help a lot. > I don't think these work with generic relations, correct me if i am wrong, http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#generic-relations-and-aggregation "Django's database aggregation API doesn't work with a GenericRelation. For example, you might be tempted to try something like" You can use https://github.com/coleifer/django-generic-aggregation from django.contrib.comments.models import Comment from django.db.models import Sum from generic_aggregation import generic_annotate from voting.models import Vote #want might to filter on is_public and is_removed top = generic_annotate(Comment.objects.all(), Vote.object, Sum('vote')) Jason > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Email app is breaking long lines, any fix?
On May 5, 2011, at 5:50 PM, John Crawford wrote: > I'm using the filebased email backend for testing (although the console > version had the same problem). When I send email, either via function or > template, lines that are too long, are broken, with an '=' sign at the end. > For instance: > > this is a test of a really long line that has more words that could possibl= > y fit in a single column of text. > > When sending email, is there some maximum-linelength variable, or something, > that's truncating/breaking lines? Any way to prevent this from happening? The answer is no, it it the underlying python email.MIMEText object that is performing the encoding The only encoding that isn;t going to wrap is charset="us-ascii" http://www.rfc-editor.org/rfc/rfc5322.txt 2.1.1. Line Length Limits There are two limits that this specification places on the number of characters in a line. Each line of characters MUST be no more than 998 characters, and SHOULD be no more than 78 characters, excluding the CRLF. The 998 character limit is due to limitations in many implementations that send, receive, or store IMF messages which simply cannot handle more than 998 characters on a line. Receiving implementations would do well to handle an arbitrarily large number of characters in a line for robustness sake. However, there are so many implementations that (in compliance with the transport requirements of [RFC5321]) do not accept messages containing more than 1000 characters including the CR and LF per line, it is important for implementations not to create such messages. The more conservative 78 character recommendation is to accommodate the many implementations of user interfaces that display these messages which may truncate, or disastrously wrap, the display of more than 78 characters per line, in spite of the fact that such implementations are non-conformant to the intent of this specification (and that of [RFC5321] if they actually cause information to be lost). Again, even though this limitation is put on messages, it is incumbent upon implementations that display messages to handle an arbitrarily large number of characters in a line (certainly at least up to the 998 character limit) for the sake of robustness. Jason > > Code I'm using to test: > > EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend' > from django.core.mail import send_mail > > def send_letter(request): >the_text = 'this is a test of a really long line that has more words that > could possibly fit in a single column of text.' >send_mail('some_subject', the_text, 'm...@test.com', ['m...@test.com']) > > Thanks. > John C> > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Overwriting the handler404
On May 1, 2011, at 8:01 AM, doniyor wrote: > Hi there, > i am trying to overwrite handler404 of django so that i can call my > own view function when it doesnot find the appropriate view and if it > tries to give Http404. the whole problem is as follows: > > i defined my view function called 'remap_test' in my proxy app. and i > changed the default handler404 to handler404 = > 'proxy.views.remap_test'. > The problem is that it gives all the time 404 error even if the > handler404 is defined right and even if it is in right place(in > urls.py) and the settings.py has the DEBUG = FALSE and my new view > function is theoretically ready to be called. but it isnot called, > sometimes it is. it is sooo weird. > > i will post here the code blocks i added: > > in my urls.py is this: > You problem statement is a little confusing, so I'm not sure I am on the right track here Just a quick thought, Does your urls.py contain from django.conf.urls.defaults import * If you are missing the "import *" the handler404 function that your are assigning to > handler404 = 'proxy.views.remap_test' > . will just be a local variable and not django.conf.urls.defaults.handler404 Jason > > > and my view function is this: > > def remap_test(request): > return HttpResponse("test message as 404") > > and my model is this: > > class Remap(models.Model): >new_url = models.CharField(max_length=50) >src_url = models.CharField(max_length=150) >def __unicode__(self): >return self.src_url > > ... i dont know why it calls 404 all the time, sometimes i get the > problem if i add items to my database tables in admin, and sometimes > not. can someone please help me with this or does anyone have an idea > what the problem could be ? > > thank you guys so much in advance, > > doni > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: URLs in error messages from form validation
On Apr 25, 2011, at 5:39 AM, Kane Dou wrote: > * Daniel Gerzo[2011-04-25 13:07:46 +0200]: > >> On 25.4.2011 12:40, Kane Dou wrote: >>> * Daniel Gerzo [2011-04-24 17:52:13 +0200]: >>> Hello all, say I have a following form: class MyForm(forms.Form): id = forms.IntegerField(max_length=9) language = forms.CharField(max_length=10) file = forms.FileField() And a following pseudo clean method: def clean(self): for file in self.files.values(): if file_exists(file): raise forms.ValidationError('We already have this filehere') return self.cleaned_data So I want to display a URL in the error message. The text is displayed fine, but the URL is being escaped by Django and thus is not clickable. Is there some way to disable it for this specific case? You only need to mark the string as safe as in: http://docs.djangoproject.com/en/1.3/ref/utils/#module-django.utils.safestring from django.utils.safestring import mark_safe raise forms.ValidationError(mark_safe('We already have this filehere')) Jason -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django template strange behavior
You can use the template language to test against what you think are constants, the parser is actually testing 2 "literals". The parser tests for 2 literals with names 'None' and 'False'. When parser tries to resolve these in the context a VariableDoesNotExist exception is thrown and both objects resolves to the python value None and None == None. >>> from django.template import Context, Template >>> t = Template("{% if None == False %} not what you think {% endif %}") >>> c = Context({"foo": foo() }) u' not what you think ' >>> c = Context({'None':None}) >>> t.render(c) u' not what you think ' >>> c = Context({'None':None, 'False':False}) >>> t.render(c) u'' Jason On Apr 14, 2011, at 7:59 PM, carrier24sg wrote: > > > Hi guys, > > {% if None == False %} >abc > {% endif %} > > Strangely my template displayed abc. Any explanation? > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Navigation menu
There is a snippet http://djangosnippets.org/snippets/1729/ "Template tag to handle navigation item selection" which is quite useful for creating navigation/menu structure Jason On Apr 12, 2011, at 11:43 AM, javatina wrote: > You can put your current menu option in context and then, while > rendering pages, check for it and use a different style for the active > menu option. > > On Apr 12, 5:33 am, Daniel Gerzowrote: >> Hello all, >> >> I was wondering how do you generate the navigation menu in your web >> sites, with a possibility to mark up the "active" page? >> >> My searching revealed some solutions, most of them based on implementing >> a custom template tag and then parsing the request.path. I was wondering >> whether someone came up with something more nicer? >> >> Thanks! >> >> -- >> Kind regards >>Daniel Gerzo > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: south for django
On Mar 31, 2011, at 1:18 PM, jay K. wrote: > > I think i found the source of all problems > > I am not a python expert, so I was wondering if anybody can tell me what this > code means > > // beginning of code > > from django.db import models > > > class TranslationForeignKey(models.ForeignKey): > """ > """ > pass > > // end of code > > This piece of code has been generating an error when executing the python > manage.py schemamigration myApp --initial command in South > > If the above code has doesn't do anything, I will comment it out See: http://south.aeracode.org/docs/tutorial/part4.html#simple-inheritance Add to the bottom of the file that defines TranslationForeignKey: replace my_app.fields with a that matches the definition try: from south.modelsinspector import add_introspection_rules add_introspection_rules([], ['^my_app\.fields\.TranslationForeignKey']) except ImportError: pass Jason > > > On Thu, Mar 31, 2011 at 5:04 PM, jay K.wrote: > > Hello, > > I've been using south to migrate a database > > I followed all the commands to make the migrations in south (--initial and > --auto), all > of this, after making my desired changes in modes.py > > but when I refresh my page I still get a "Error 505" messages > > I've checked spelling mistakes etc but found nothing > > Any other suggestions would be great > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: staticfile app question
On Mar 30, 2011, at 5:10 PM, Mike Ramirez wrote: > On Wednesday, March 30, 2011 05:01:08 pm Jason Culverhouse wrote: >> On Mar 30, 2011, at 4:50 PM, Mike Ramirez wrote: >>> On Wednesday, March 30, 2011 04:20:32 pm Shawn Milochik wrote: >>>> I have the exact same problem. I hope there is a solution, because >>>> good site design often results in image references in the CSS. >> >> I think you guys are over analyzing the problem >> >> You can use relative urls in css >> >> Just look at >> http://www.djangoproject.com/m/css/base.css >> > > Never really been a fan of relative urls or paths. It feels clumsy and full > of > pitfalls. The angst it causes me isn't worth it, since absolute solves all > that. > Some don't immediately grok that the that the url references in the style sheet are relative to the css file. If your reference are relative, then everything stays modular and you'll make a python developer happy when he doesn't have to muck css. To quote the spec http://www.w3.org/TR/CSS21/syndata.html#uri 4.3.4 URLs and URIs """ In order to create modular style sheets that are not dependent on the absolute location of a resource, authors may use relative URIs. Relative URIs (as defined in [RFC3986]) are resolved to full URIs using a base URI. RFC 3986, section 5, defines the normative algorithm for this process. For CSS style sheets, the base URI is that of the style sheet, not that of the source document. For example, suppose the following rule: body { background: url("yellow") } is located in a style sheet designated by the URI: http://www.example.org/style/basic.css The background of the source document's BODY will be tiled with whatever image is described by the resource designated by the URI http://www.example.org/style/yellow """ > Mike > -- > Avoid Quiet and Placid persons unless you are in Need of Sleep. > -- National Lampoon, "Deteriorata" > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: staticfile app question
On Mar 30, 2011, at 4:50 PM, Mike Ramirez wrote: > On Wednesday, March 30, 2011 04:20:32 pm Shawn Milochik wrote: >> I have the exact same problem. I hope there is a solution, because >> good site design often results in image references in the CSS. > > I think you guys are over analyzing the problem You can use relative urls in css Just look at http://www.djangoproject.com/m/css/base.css Assuming this layout under STATIC_URL {{STATIC_URL}} css/screen.css images/header.gif Just use a relative path in screen.css #container-head { background: transparent url('../images/header.gif') 50% 0 no-repeat; } Jason > The best one I've come up with and it's far from 'best' is to run a command > that edits css templates and spits them out to the directory they should be > served on at update time. AFAIK DJango can not process the .css files in the > media/static directory on the fly. > > But you might be able to trick it, just thought about this as I was writing > above. Have a url in urls.py of a regex that ends in '.css' and direct it > to > a view that serves your css. > > something like this: > > url(r'^media/css/(?P[\w-]+)\.css$', 'views.css', name='serve-css'), > > with my views.css just for processing css templates. > > I don't know how hard it would be to implement or how well it would work, I > haven't done it. It's a thought of this. > > Mike > > > -- > I appoint you ambassador to Fantasy Island!!! > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to filter the list_display in the django admin with the request.session[user_id]
On Mar 30, 2011, at 2:31 PM, Pablo Vidal wrote: > I need to know how to filter in the django admin model License, the > licenses of the user logged-in to the admin. > > class License(models.Model): >user = models.ForeignKey('wiki.User') >name = models.CharField(max_length = 100) > >def __unicode__(self): >return self.name > > Example: > > So if Bob has created in the License Model 3 licenses, but John has > created only two, then the model has 5 licenses total, but if Bob logs > in to the admin he should only see his licenses (3 Licenses). http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.queryset class MyModelAdmin(admin.ModelAdmin): def queryset(self, request): qs = super(MyModelAdmin, self).queryset(request) if request.user.is_superuser: return qs return qs.filter(author=request.user) > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > Jason -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: check for existence in bulk
On Mar 30, 2011, at 9:47 AM, Calvin Spealman wrote: > I think your best bet is > > MyModel.objects.filter(some_field__in=ok_values).count() == len(ok_values) > > On Wed, Mar 30, 2011 at 12:44 PM, dmitry bwrote: >> Hi, >> >> is there a way to check in bulk for record existence and get back a >> map of results similar to what's returned by in_bulk(). In my case, I >> need to look up records by a unique field which is not the primary key >> and I don't want object instances back, just true or false. You could use values_list and flat as in: User.objects.filter(username__in =['jason', 'was', 'here']).values_list('username', flat=True) returns a list: [u'jason', u'was'] After that you can figure out the best way to perform the lookup. Jason >> >> >> Thanks >> Dmitry -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Exclude results with ManyToManyField
On Mar 23, 2011, at 12:19 PM, Julien Castets wrote: > Hello, > > from django.contrib.auth.models import User > > class Team(models.Model): > users = models.ManyToManyField(User) > > > I would like to retrieve every User in my database who does not belong > to a team. Left outer join is your friend User.objects.filter(team__users__isnull = True) > I'm facing to this problem for several hours, and I found a *very* > crappy solution : > > def _get_all_users_in_teams(): > for team in Team.objects.all(): > for user in team.users.all(): > yield user.pk > > CHOICES = User.objects.all().exclude(pk__in=[id for id in > _get_all_users_in_teams()]) > > Is there something better? > I'm on django 1.2.4 > > Regards, > -- > J. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Error installing permissions superuser when a userprofile has been defined
On Mar 23, 2011, at 4:25 AM, Malcolm Box wrote: > Further investigation: looks like it's a South/syncdb interaction. The > UserProfile will be created by the south migration, but of course that > hasn't run when the auth post_install runs to prompt for a superuser. > > Sadly syncdb --migrate doesn't do the right thing either. > > For now, I'm just creating a superuser manually using ./manage.py > shell, but would welcome any ideas on how to solve this better. > Don't create the super user during syncdb, you user profile table will not exist. You must have a create signal on admin that creates a user profile, this looks like it is failing The procedure you wan to use to initialize the database is: manage.py syncdb --noinput manage.py migrate mange.py createsuperuser Jason > Malcolm > > On Mar 23, 10:11 am, Malcolm Boxwrote: >> Hi, >> >> I'm running into an error when doing a syncb on a clean DB during the >> installation of the auth system. >> >> I get the normal prompt "You just installed Django's auth system, >> which means you don't have any superusers defined. Would you like to >> create one now? (yes/no):" and answer yes. >> >> But when the user is created, I get a django.db.utils.DatabaseError: >> (1146, "Table 'x.x_userprofile' doesn't exist"), because the >> userprofile table from my app hasn't been created yet. >> >> This must be a common problem, but I can't find a recommendation on >> how to deal with it. What's the right thing to do? >> >> Thanks, >> >> Malcolm > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: sorting in /admin
> On Tue, Mar 22, 2011 at 5:29 PM, Jason Culverhouse <ja...@mischievous.org> > wrote: > On Mar 22, 2011, at 12:10 PM, Bobby Roberts wrote: > > > how else would you pull in information from another model into the > > current model list view in admin? > > > > > There are some options: > Search for > http://www.google.com/search?q=ModelAdmin+__ > > You'll find http://code.djangoproject.com/ticket/10743 > "Support lookup separators in ModelAdmin.list_display" > > If this "bug" were fixed, your problem would be solved > > There is no need for any Django change to get this to work today. All that > needs to be done is for the existing callables specified in list_display to > specify the appropriate admin_order_field value, e.g.: > > > def Client_Lastname(self, obj): > return obj.CustomerId.lastName > Client_Lastname.admin_order_field = 'CustomerId__lastName' > > Doc on admin_order_field is > here:http://docs.djangoproject.com/en/1.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display, > search for admin_order_field. > I missed that, I see that the latest docs http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_filter Specifically state: "Fields in list_filter can also span relations using the __ lookup:" I don't see that verbiage for other fields, perhaps a Doc enhancement is in order? > Karen > -- > http://tracey.org/kmt/ > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: sorting in /admin
On Mar 22, 2011, at 12:10 PM, Bobby Roberts wrote: > how else would you pull in information from another model into the > current model list view in admin? > > There are some options: Search for http://www.google.com/search?q=ModelAdmin+__ You'll find http://code.djangoproject.com/ticket/10743 "Support lookup separators in ModelAdmin.list_display" If this "bug" were fixed, your problem would be solved Would search work as an alternative?? http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.search_fields search_fields = ['foreign_key__related_fieldname'] i.e. search_fields = ['user__email'] You can filter on them on the right ( this isn't going to work for names) http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_filter ModelAdmin.list_filter supports __ Jason > > On Mar 22, 2:41 pm, Siarawrote: >> Why are you doing this way ? >> The better idea is to make it that way: >> >> class YourModelAdmin(admin.ModelAdmin): >>model = YourModel >>list_display = [ 'firstName', 'lastName' ] >> >> admin.site.register(YourModel, YourModelAdmin) >> >> and i'm sure then you will be able to sort olums >> >> On 22 Mar, 19:28, Bobby Roberts wrote: >> >>> I am listing the following fields from the model in /admin as follows: >> >>> [...snip...] >> >>> def Client_Lastname(self, obj): >>> return obj.CustomerId.lastName >> >>> def Client_Firstname(self, obj): >>> return obj.CustomerId.firstName >> >>> list_display = ('Client_Firstname', 'Client_Lastname', ) >> >>> [...snip...] >> >>> The Firstname and Lastname fields from the Client model drop right >>> into the list fine but I cannot sort on these fields when i click the >>> column header. What do I need to do to make them sortable? > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Postgresql transaction error
On Mar 22, 2011, at 10:03 AM, cootetom wrote: > I'm using the psycopg2 python library and have tried postgresql 8 and > now 9. > > The error, in brief, is: > > " > Template error > In template c:\python26\lib\site-packages\django\contrib\admin > \templates\admin\base.html, error at line 58 > Caught DatabaseError while rendering: current transaction is aborted, > commands ignored until end of transaction block Look in the postgres log file, by default it should log the first error and the subsequent errors If not, you can add: log_statement = 'all' to your postgresql.conf and see every statement... Jason -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Multiple INNER JOIN without raw SQL
On Mar 18, 2011, at 6:38 AM, Ricardo F. Teixeira wrote: > Hi everyone! > > Without using raw SQL queries how can I make multiple joins using this > model? > Do a search for "django select_related reverse one to many" for some alternatives > I'm trying to get something like this: > > SELECT Package.package, Release.release, Release.version, > ContribComment.* > FROM ContribComment > INNER JOIN Contrib > ON Contrib.id = ContribComment.fk_contrib_id > INNER JOIN ContribRelease > ON ContribRelease.fk_contrib = Contrib.id > INNER JOIN Release > ON Release.id = ContribRelease.id > INNER JOIN Package > ON Package.id = Release.fk_package > > Is that possible to anchive something like this without using raw SQL > queries? > I'm asking that because I can't find any example with multiple inner > joins that is similar to my model. > What you want work is: Package.objects.select_related() But since the ORM will only follow 'forward' ForeignKey references, the result will be the same as: Package.objects.all() You can get close with ContribRelease.objects.select_related() which will inner join everything except ContribComment since there is no "forward" ForeignKey reference see http://docs.djangoproject.com/en/dev/ref/models/querysets/#select-related > class ContribComment(models.Model): > fk_contrib_id = models.ForeignKey(Contrib) > subject = models.TextField() > text = models.TextField() > ratings = models.IntegerField() > > class Contrib(models.Model): > username = models.TextField() > city = models.TextField() > > class ContribRelease(models.Model): > fk_contrib = models.ForeignKey(Contrib) > fk_release = models.ForeignKey(Release) > > class Release(models.Model): > fk_package = models.ForeignKey(Package) > release = models.TextField() > version = models.TextField() > distribution = models.TextField() > arch = models.TextField() > summary = models.TextField() > description = models.TextField() > > class Package(models.Model): > name = models.TextField(unique=True) > homepage = models.TextField() > snapshot = models.TextField() > > Thanks, > > Ricardo F. Teixeira > Jason -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django projects, apps, and git repos
Ben, You should a have a look at https://github.com/bueda/django-boilerplate "django-boilerplate is an attempt to set up a standard convention for Django app layouts, to assist in writing utilities to deploy such applications. A bit of convention can go a long way." It's very similar to what you are describing pip, virtualenv, fabric, git-submodules Jason On Mar 16, 2011, at 11:08 AM, br wrote: > Thanks for the feedback. I've looked at git submodules and think that > will be a useful tool in django projects that share apps, once I'm > comfortable with the submodule functionality & understand how it fits > in with my prjoects. And once I get my apps so they actually are in > fact "pluggable" (not there yet) I'll be looking at making them > installable with pip via pypi. > > In the mean time, I've thought through our site and how i want to > structure the projects & repos and thought I would share what I've > come up with. > > Basically what I've come up with for our specific scenario, is a > realization that our site consists of three or four distinct > "projects" or Applications (not talking about django apps) with fairly > distinct and modular sets of functionalities. Within each of these > projects will be various django apps, which i would like to make as > pluggable as possible. Our client users will need to have access to > each of the Applications (corresponding to the projects) from a > central dashboard, with a corresponding wrapper templates. So in > addition to each separate Application project, I a have a "glue" > project that includes the general site functionality (e.g., user > accounts & permissions, wrapper templates, etc.) For now, I'm setting > up each project as its own repository, since releases might be > different for each one, and I want the projects themselves, in > addition to their apps, to be fairly pluggable, and even stand on > their own as deployable sites. The "glue" project for the dashboard & > common functionality will have a settings.py for the whole site, which > is cognizant of all the included projects, although individual > projects will have their own settings.py that can be used to deploy > them individually. We'll see how this set up goes. > > btw, I'm using virtualenv & pip for managing site-packages & external > packages, and using Fabric for deploying to development, staging, > production virtual hosts. I've currently set it up so each project has > its own corresponding virtualenv environment and fabric script but > haven't quite figured the long term vision for all of this out yet > since i'm still familiarizing myself with the different tools. If > someone sees any pitfalls to be aware of, let me know. > > Any feedback is, of course, welcomed. > > Thanks, > > Ben > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to use extra to count based on the value of a field?
On Mar 16, 2011, at 8:49 AM, Margie Roginski wrote: > Hmmm ... so I just got back to trying this and I actually don't think > the annotate call as suggested does what I am looking for. Say I want > to annotate queues with the number of closed tasks. This call: > > Queue.objects.filter(task__status=Task.STATUS_CLOSED).annotate(num_tasks=Count('task')) > > finds all queues that have tasks that are closed, but then it > annotates the queue with the total number of tasks that point to the > queue, not just the number of closed tasks that point to the queue. > It seems like I really need something like this (which doesn't exist): > > Queue.objects.annotate(num_tasks=Count('task__status=Task.CLOSED_STATUS')) > Would something like this work? Queue.objects.extra( select = { 'num_tasks' = 'SELECT COUNT(*) FROM app_task WHERE app_task.queue_id = app_queue.id' and app_task.status=%s'), select_params=(Task.CLOSED_STATUS,) > > At a higher level, I am trying to find a way to sort my queues based > on the number of tasks that point to the queue of a particular status. > IE, the user would be able to sort their queues based on number of > open tasks or number of closed tasks. Perhaps there is some other > approach that I am missing ... > > Margie > > > > > On Mar 15, 2:43 am, Tom Evanswrote: >> On Mon, Mar 14, 2011 at 8:57 PM,MargieRoginski >> >> wrote: >>> class Queue(models.Model): >>> # fields here, not relevant for this discussion >> >>> class Task(models.Mode): >>> queue = models.ForeignKey("Queue") >>> status = models.IntegerField(choices=STATUS_CHOICES) >> >>> I am trying to create a Queue queryset that willannotateeach Queue >>> with the number of tasks whose queue field is pointing to that Queue >>> and status field has a certain value. >> >>> I don't thinkannotatewill work for me due to me needing to count up >>> only tasks whose status field has a certain value. I think I might >>> need extra? But I'm having touble making that work. >> >> No, this is precisely whatannotateis for. >> >> Queue.objects.filter(task__status=Task.SOME_CHOICE).annotate(num_tasks=Count('task')) >> >> Cheers >> >> Tom > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: request.user.save() doesnt work
On Mar 11, 2011, at 10:46 AM, Daniel Roseman wrote: > On Thursday, March 10, 2011 11:59:15 PM UTC-8, Ndungi Kyalo wrote: > Hi guys. Am using django non-rel on appengine. I am using django's > auth backend for my authentication, since I did not want to have to > force my users to use gmail logins, and appengine models > {google.appengine.ext.db} for the other models. I have a form where I > allow users to edit their email. So : > > if settings_form.is_valid() : > user = request.user > user.email = request.POST['email'] > user.save() > > print request.POST['email'] returns the correct data entered in the > form. But user.save() just doesnt save! > Am I doing it correctly ? Is there something else I shopuld be doing ? > -- > Regards, > Guy-at-the-end-of-the-tether :-) > > Are you sure that the condition is true - that the form is valid? Put some > logging in to be sure. Are you sure that user is a django.contrib.auth.models.User and not at django.contrib.auth.models.AnonymousUser. http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.user if request.user.is_authenticated(): # Do something for logged-in users. else: # Do something for anonymous users. > -- > DR. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Error on aggragate function-Count
On Mar 11, 2011, at 5:02 AM, pols wrote: > hai > I have two models as shown belove > > from django.db import models > from django.db.models import Sum > # Create your models here. > class polls(models.Model): > question = models.CharField(max_length=200) > pubish_date = models.DateTimeField('Date published') > > def __unicode__(self): >return self.question > def getCount(self): > count = > choice.objects.filter(polls=self.id).annotate(test=Sum('vote')) > return count.test > getCount.allow_tags = 'true' > getCount.short_description = 'Total Answers' > > > class choice(models.Model): > polls = models.ForeignKey(polls) > choice = models.CharField(max_length=200) > vote = models.IntegerField() > > > > Here i need to get sum of votes for each question.So I need to edit > the code in the function getCount(). I try with the above code but > getting 'none'.then what may be the problem??.This is for the listing > in django admin polls listing > # if you have a poll (this could also be the 'self' in your method) poll = polls.objects.get(1) choice.objects.filter(polls = poll).aggregate(Sum('vote')) SELECT SUM("polls_choice"."vote") AS "vote__sum" FROM "polls_choice" WHERE "polls_choice"."polls_id" = 1 or poll.choice_set.aggregate(Sum('vote')) SELECT SUM("polls_choice"."vote") AS "vote__sum" FROM "polls_choice" WHERE "polls_choice"."polls_id" = 1 you would use annotate to add columns to a queryset polls.objects.annotate((Sum('choice__vote')) SELECT "polls_polls"."id", "polls_polls"."question", "polls_polls"."pubish_date", SUM("polls_choice"."vote") AS "choice__vote__sum" FROM "polls_polls" LEFT OUTER JOIN "polls_choice" ON ("polls_polls"."id" = "polls_choice"."polls_id") GROUP BY "polls_polls"."id", "polls_polls"."question", "polls_polls"."pubish_date", "polls_polls"."id", "polls_polls"."question", "polls_polls"."pubish_date" Jason > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django remove unicode from query result ?
On Mar 10, 2011, at 5:26 PM, sushanth Reddy wrote: > I using jplot in my app .if list is in unicode(u) ,it not displaying the > charts,thats the reason i want to remove it ... > Pass a json string then have the Java(?) side convert it back into "objects" In [1]: import json In [2]: json.dumps([[1744,u'x'], [13,u'm'], [126,u'n']]) Out[2]: '[[1744, "x"], [13, "m"], [126, "n"]]' > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: What apps or snippets to use for Facebook and Twitter registration, login and posting?
On Mar 2, 2011, at 8:28 AM, Rodrigo Cea wrote: > I am developing a site that I want to link with Facebook and Twitter. > > So as to not reinvent the wheel, I'm looking for apps or snippets that can > help with this, specifically: > > 1) allow users to register and login with their Facebook and/or Twitter > accounts. > > 2) Have these accounts be linked to the local one (crossposting to their FB > and Twitter account, pulling in their posts on FB and TW, etc.) > Pointing you here, since davidmarble does a nice rollup of the of options in a github readme From: https://github.com/davidmarble/Django-Socialauth Important note This is a fork to rollup other forks of this app and try to get it running with the most recent facebook/twitter/linkedin APIs. It is completely untested. Just thought I'd share the work while it's in-progress. It's supposed to allow logging in via Facebook, Yahoo, Gmail, Twitter and Openid. It's sad that Rails has such a complete solution with omniauth -- Django has nothing to compare! I'm hoping we all rally around one of these projects to create our own omniauth. I'm not sure this is the best code base to start from. I'm also exploring the following: • https://github.com/pennersr/django-allauth • https://github.com/flashingpumpkin/django-socialregistration (note the forks) • https://github.com/kmike/django-registration-facebook-backend • https://github.com/zbowling/python-oauth2 (good fork of simplegeo's) • https://github.com/tschellenbach/Django-facebook. Jason -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django 1.2.5 postgres autocommit and contenttype sites tests failures
Hi, It seems that the contenttype framework and the sites contribs conflict with using the autocommit:True database option. I'm not really sure what happens but here is a simple test case that shows that the order of the tests causes a failure. It looks like from the SQL that the save point is being rolled back in a new transaction, not the transaction that the savepoint was created. If I create a new django tests site with {{{ django-admin-2.6.py startproject sitecontenttypebug }}} Modify settings.py to use postgres autocommit {{{ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', ... 'OPTIONS': { "autocommit": True, } } } }}} The minimum required to have the django tests fail is: {{{ python manage.py test contenttypes sites.SitesFrameworkTests.test_get_current_site }}} Switching the order causes no failure {{{ python manage.py test sites.SitesFrameworkTests.test_get_current_site contenttypes }}} Stack trace from the failure {{{ == ERROR: test_get_current_site (django.contrib.sites.tests.SitesFrameworkTests) -- Traceback (most recent call last): File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/django/test/testcases.py", line 257, in __call__ self._pre_setup() File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/django/test/testcases.py", line 224, in _pre_setup self._fixture_setup() File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/django/test/testcases.py", line 515, in _fixture_setup return super(TestCase, self)._fixture_setup() File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/django/test/testcases.py", line 236, in _fixture_setup call_command('flush', verbosity=0, interactive=False, database=db) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/django/core/management/__init__.py", line 166, in call_command return klass.execute(*args, **defaults) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute output = self.handle(*args, **options) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/django/core/management/base.py", line 351, in handle return self.handle_noargs(**options) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/django/core/management/commands/flush.py", line 75, in handle_noargs emit_post_sync_signal(all_models, verbosity, interactive, db) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/django/core/management/sql.py", line 182, in emit_post_sync_signal interactive=interactive, db=db) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/django/dispatch/dispatcher.py", line 172, in send response = receiver(signal=self, sender=sender, **named) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/django/contrib/auth/management/ __init__.py", line 28, in create_permissions defaults={'name': name, 'content_type': ctype}) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/django/db/models/manager.py", line 135, in get_or_create return self.get_query_set().get_or_create(**kwargs) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/django/db/models/query.py", line 387, in get_or_create transaction.savepoint_rollback(sid, using=self.db) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/django/db/transaction.py", line 242, in savepoint_rollback connection._savepoint_rollback(sid) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/django/db/backends/__init__.py", line 61, in _savepoint_rollback self.cursor().execute(self.ops.savepoint_rollback_sql(sid)) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/django/db/backends/postgresql_psycopg2/ base.py", line 44, in execute return self.cursor.execute(query, args) DatabaseError: no such savepoint -- Ran 2 tests in 0.478s FAILED (errors=1) Destroying test database 'default'... }}} Offending SQL {{{ LOG: statement: BEGIN; SET TRANSACTION ISOLATION LEVEL READ COMMITTED LOG: statement: SELECT "auth_permission"."id", "auth_permission"."name", "auth_permission"."content_type_id", "auth_permission"."codename" FROM