Re: or-ing to QuerySets turns INNER into LEFT OUTER joins?

2013-07-26 Thread Martin J. Laubach
> This is still about 50 times better than the form with Q objects and > LEFT OUTER joins. This is rather unusual. A join in the database should be quite a bit faster than doing things manually, except if the joined tables produce massive amounts of data. This suggests that you're missing

Re: Object Lookup after Save

2013-05-29 Thread Martin J. Laubach
Well, that is what repeatable read is supposed to do -- once you do a Foo.objects.all() (or whatever) query, re-running the query will give you the same result. That's why it's called repeatable read. You have to either start a new transaction to break that visibility barrier or not use

Re: Must AUTH_USER_MODEL be in "models.py"?

2013-04-28 Thread Martin J. Laubach
I'd guess it's the usual model-magic dealing with app_label, which causes them not to appear under "app1" (because, well, you defined them somewhere else). Try to set app_label manually in your model's Meta class. Cheers, mjl -- You received this message because you are subscribed to

Re: Django Generic ForeignKey vs Multiple Foreign Key Fields

2013-04-08 Thread Martin J. Laubach
It's simply a question of what you want to model. *GenericFK* means for each instance "I have a relationship with some other (undefined) entity". *MultipleFK* means "I have relationships with both well-known entities A and B". Totally different things. Cheers, mjl -- You received

Re: Getting the selected value on a Django forms.ChoiceField

2013-03-28 Thread Martin J. Laubach
Continent = form.cleaned_data['Continent']Continent = dict(form.fields['Continent'])[Continent] The obvious confusion stemming from the upper case variable aside, the second line is total nonsense. Drop it and you'll be golden. Cheers, mjl -- You received this message because you

Re: Get all objects that don't belong to M2M

2013-03-08 Thread Martin J. Laubach
Something like this (totally untested though) Product.objects.exclude(pk__in=Product.subproducts.through.values_list( 'product_id', flat=True)) perhaps? Cheers, mjl -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe

Re: django 1.4.3 to 1.4.4 upgrade fails - Bad magic number Import Error

2013-02-21 Thread Martin J. Laubach
> > return getpass.getuser().decode(locale.getdefaultlocale()[1]) > TypeError: decode() argument 1 must be string, not None > It needs a valid locale to be set in the environment. Try setting LC_ALL=en_US before running syncdb. mjl -- You received this message because you are

Re: post_save signal getting called twice !

2013-02-08 Thread Martin J. Laubach
> > further, i tried putting a sender argument in receiver, but the sender , i > found (by set_trace) is Cart_cartitems, how can i import this 'shoppingcart.models.Cart_cartitems'> when its only a intermediary model > that django's creating. I think you want Cart.cartitems.through

Re: how to use get_queryset in my code

2012-11-20 Thread Martin J. Laubach
> > I tryed first this part with db models. but mssql doesnt work on it... > BTW, why? I see there's a django-mssql, that should allow you to connect to the database. Doesn't it work with your version? I've never tried it though, I just googled around a bit... -- You received this

Re: how to use get_queryset in my code

2012-11-20 Thread Martin J. Laubach
Okay. You seem to be rather confused about the django approach to things I'm afraid. (a) You use raw sql instead of django's ORM mapper. That's okayish, but then you're on your own for building your queries and have to manually do validation and escaping and whatnot, which is, as you

Re: How to implement pre-save operations for inlines in the admin interface?

2012-11-16 Thread Martin J. Laubach
Don't overthink it. If believe you are likely to run into cascading recursive updates, then those cascades will happen no matter where you put the update. You will need to deal with it some way or another (locking, careful ordering, better data structures, whatever), but just moving things

Re: views on one page

2012-11-14 Thread Martin J. Laubach
Do you actually need both as views proper? The easiest thing would be to factor out the fetching part of the kundendaten view, make that return just a dictionary, then call that and update the context in the first view. -- You received this message because you are subscribed to the Google

Re: How to implement clean() for a model with ManyToMany fields?

2012-10-29 Thread Martin J. Laubach
Basically, you can't. M2m fields are saved after the model is saved, so you either get objects that are not yet ready for that check (as you experienced) or you will test the previous value of the m2m field, neither of which is what you want. You can modify the admin interface and do the

Re: Stop executing template tag

2012-10-19 Thread Martin J. Laubach
Just put something between the {{ so the templating engine will not be tempted to interpret it. {{ should do the trick, for example. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit

Re: reduce number of DB-Queries

2012-09-21 Thread Martin J. Laubach
> > Is this how you meant to set the instance variable or did you mean in > another way? > > def __init__(self, *args, **kwargs): > super(Player, self).__init__(*args, **kwargs) > self.matches = Match.objects.select_related().filter( Q(opp1=self) > | Q(opp2=self) ) Yes,

Re: reduce number of DB-Queries

2012-09-21 Thread Martin J. Laubach
> > My problem is when want to display overall player statistics I get about > 1200 DB-Queries. > This is because for each player there will be 5 Queries due to > matches_won, matches_draw, goals, matches_played functions. > First easy optimisation: keep

Re: View loaded twice / Database entry saved twice

2012-08-22 Thread Martin J. Laubach
Also, you should really only do saves on a POST request, never on GETs. mjl -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/jIUH0iInCQ0J. To

Re: Post data Query Dict - Why not a list ?

2012-02-29 Thread Martin J. Laubach
Also, having a form to parse and validate the POST data is really the way to go. Even if you never actually show the form to the user, for example in an AJAX callback, deferring all that responsibility and just use "form.is_valid()" and "form.cleaned_data" is a lot better than doing parameter

Re: [ANN]: FeinCMS v1.5.0.rc1

2012-02-16 Thread Martin J. Laubach
Well for now you don't NEED to change anything. You'll get those pesky deprecation warnings, but everything should continue to work fine for now, so there's no need to rush things, you can change your code as you go along. mjl -- You received this message because you are subscribed to the

Re: Debug = false ruins template

2012-01-23 Thread Martin J. Laubach
Probably you are not serving your static files any more as the built-in staticfiles app only works in debug mode (that's a feature). mjl -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit

Re: How to intercept password change in admin module ?

2011-12-01 Thread Martin J. Laubach
How about just listening to pre_save or post_save signals on the User model? mjl -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/C65AzRxHDNwJ. To

Re: Python data structures and the GIL

2011-11-06 Thread Martin J. Laubach
One possibility that springs to mind is shared memory, either the sysv shmem variant or memory mapped files. mjl -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit

Re: Translation problem with percent sign

2011-11-04 Thread Martin J. Laubach
Just remove the line with "python-format" from your translation since it isn't a format string after all. mjl -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit

Re: Thread-safeness of templates

2011-10-04 Thread Martin J. Laubach
Are you sure your context is thread-safe, ie. it's rebuilt from scratch every time you render an email and not re-used, stored in a global variable, class variable, whatever? Your problem description very much sounds like someone is fiddling with the context while the template is rendering.

Re: `manage.py syncdb` fails, but what does the error mean?

2011-10-01 Thread Martin J. Laubach
My guess would be that you named your project directory the same as one of your app directories, that causes all kind of weird import errors. mjl -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit

Re: Debud setting behaves weird

2011-08-23 Thread Martin J. Laubach
You might want to read the documentation at https://docs.djangoproject.com/en/1.3/ref/contrib/staticfiles/ -- especially the big boxes labelled "Warning". mjl -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on

Re: Django admin: naming subclass objects, fieldsets and displaying items from other class.

2011-07-17 Thread Martin J. Laubach
1. Define a unicode method on Source that returns whatever you want to display. 2. Missing comma in one-element tuple. mjl -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit

Re: Call SQL function within Model

2011-06-28 Thread Martin J. Laubach
You probably want to use something like https://docs.djangoproject.com/en/1.3/ref/models/querysets/#extra to add custom sql expressions to your querysets. mjl -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this

Aw: More trouble with select_related()

2011-04-14 Thread Martin J. Laubach
Sounds like a join with a table that doesn't have all the rows. Let me guess: the tables have been filled by some other program and you are just reading them from Django -- and you are missing a blank=True, null=True on a ForeignKey in your Django models somewhere. Cheers, mjl --

Re: Creating this query with django Models

2011-04-13 Thread Martin J. Laubach
What problems did you encounter? It's easier to help you knowing what went wrong. mjl -- 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,

Re: Creating this query with django Models

2011-04-13 Thread Martin J. Laubach
What problems did you encounter? It's easier to help you knowing what went wrong. mjl -- 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,

Re: Creating this query with django Models

2011-04-09 Thread Martin J. Laubach
Let's see... Since there is no aggregate on your outer select, the GROUP BY is basically reduced to a DISTINCT, so we can just do a distinct() on the query set. The JOINs come automatically as soon as you have ForeignKey fields (just remember to do a select_related() to avoid excessive

Re: Generate a unique username for django.contrib.auth

2011-01-15 Thread Martin J. Laubach
> I cannot simply copy the email to the username because the username must be > less than 30 characters and, after looking into my database, many email > addresses go over that. Note that you can fix that quite easily by putting something like this for f in User._meta.fields: if

Re: TemplateSyntaxError at /admin/ - 'module' object has no attribute 'rindex'

2010-01-31 Thread Martin J. Laubach
> 1.    (r'^admin/', include(admin.site.urls)), That looks like it. > I tried putting include('admin.site.urls')) but it could not find > 'admin.site.urls' Do you have 'django.contrib.admin' in INSTALLED_APPS? mjl -- You received this message because you are subscribed to the

Re: TemplateSyntaxError at /admin/ - 'module' object has no attribute 'rindex'

2010-01-31 Thread Martin J. Laubach
> Caught an exception while rendering: 'module' object has no attribute > 'rindex' Sounds you are using foo.bar instead of 'foo.bar' somewhere (ie. module instead of string). mjl -- You received this message because you are subscribed to the Google Groups "Django users" group. To

Re: Django 1.1 - Restart required for after creating and saving object for viewing it

2010-01-26 Thread Martin J. Laubach
> post_info_dict = { >     'queryset': Post.objects.all(), You probably don't want to evaluate your queryset here. Drop the .all () and you'll be good. mjl -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send

Re: How to handle platform dependent settings?

2008-08-29 Thread Martin J. Laubach
> > If it's mostly paths that you need to change, check out: > > >http://rob.cogit8.org/blog/2008/Jun/20/django-and-relativity/ There's a much easier (IMO anyway) method that does not involve messing with settings.py. If you just want to find out the directory of the current application, you