Re: Recursive one-to-many foreign key on the same table

2018-08-10 Thread Phlip Pretorius
Thank you Marius; the video is worth the watch and thought provoking Phlip On Thursday, August 9, 2018 at 2:42:13 PM UTC+2, Phlip Pretorius wrote: > > I want to build a one-to-many recursive foreign key on a table in Django. > > The concept is something like this: > > T

Recursive one-to-many foreign key on the same table

2018-08-09 Thread Phlip Pretorius
== I get the following error message: no such column: komadm_apps_decisionindex.IndexPredecessor_idno such column: Any help will be welcome. Regards, Phlip -- You received this message because you are subscribed to the Google Groups "Django users" group.

Re: Field forced to not-null

2018-08-09 Thread Phlip Pretorius
Thank you Andréas and Jason That solved my problem Regards, Phlip On Monday, August 6, 2018 at 3:02:01 PM UTC+2, Andréas Kühne wrote: > > Hi Philip, > > The field is required because you haven't allowed it to be blank - and > django admin requires fields to have the fol

Field forced to not-null

2018-08-06 Thread Phlip Pretorius
the null=True. Any idea why this is happening? I have deleted the complete Django project and started from scratch only to find the same scenario; when I click save, I get the following message. Any advice will be welcomed. Regards, Phlip -- You received this message because you are subs

Re: how to get the test runner to only rebuild & populate the test_database if it changed?

2011-05-11 Thread Phlip
" database. It does not even change the file time on the .db file when the tests run. Could someone better at Django internals than me package this system up and contrib it? -- Phlip http://c2.com/cgi/wiki?ZeekLand -- You received this message because you are subscribed to the Google Grou

how to get the test runner to only rebuild & populate the test_database if it changed?

2011-05-11 Thread Phlip
ere an easier way, or has someone already done this? (1.2, BTW - the obese database prevents an upgrade to Django 1.3!) -- Phlip http://c2.com/cgi/wiki?ZeekLand -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this grou

Re: order_by clause to preserve order in list? - redux

2011-02-21 Thread Phlip
eniences" as the .order_by() builder. It insisted on parsing my string instead of simply appending it. > -- >   Phlip >  http://zeekland.zeroplayer.com/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this grou

Re: Select x random rows from DB

2011-02-21 Thread Phlip
On Feb 20, 2:19 pm, galago wrote: > What is the best way, to select X random rows from DB? I know that > method: .all().order_by('?')[:X] is not good idea. > What methods do you use? order_by('RAND()') That might use the same seed each time. To create, for example, a rotating home page with

Re: Unit Testing: temporarily altering django settings

2011-02-21 Thread Phlip
On Feb 21, 12:47 pm, Cody Django wrote: > Thanks -- I didn't know about mock objects, and this is good to know. > But this doesn't feel like this is the solution I'm looking for.  It's > a large project, and your proposal would require extensive patching. Does your project access the CAPTCHA set

order_by clause to preserve order in list? - redux

2011-02-21 Thread Phlip
s.google.com/group/django-users/browse_thread/thread/f23b2bdf24ff7a26/110d3e5c9e69ca63 I will, of course, start with extra(), and see where that takes me! -- Phlip http://zeekland.zeroplayer.com/ -- You received this message because you are subscribed to the Google Groups "Django users"

Re: Unit Testing: temporarily altering django settings

2011-02-17 Thread Phlip
o trivially pass it, without real user input. To test the captcha, mock it to pass or fail. -- Phlip http://c2.com/cgi/wiki?ZeekLand -- 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@

How to pivot a table?

2011-02-17 Thread Phlip
n re-pack the array with a for-loop. Do QuerySet aggregations and annotations offer some way to push that query into the database? -- Phlip http://c2.com/cgi/wiki?ZeekLand -- You received this message because you are subscribed to the Google Groups "Django users" group.

Re: cascading create

2011-02-01 Thread Phlip
Bump? String together the SQL myself? On Jan 31, 3:40 pm, Phlip wrote: > Djangoists: > > Given a model Tree with many Leaves, I want to write this: > >   t = Tree(data=42) >   t.leaves.add(leafy_data=43) >   t.leaves.add(leafy_data=44) >   t.save() > > I want the s

cascading create

2011-01-31 Thread Phlip
to optimize the database calls. If not, that's okay to. Google doesn't say Django can do this. My specific problem is I have a dozen trees with a couple thousand leaves each, and simply writing them all causes a bottleneck. --   Phlip   http://c2.com/cgi/wiki?ZeekLand -- You rec

Re: How to override handle_uncaught_exception ?

2010-11-08 Thread Phlip
On Nov 8, 8:12 am, Phlip wrote: > I just need the usual features - to log the actual error, and stick it > in the programmer's face during a test run. > > But when I Google for this subject, I get ten thousand newbies asking > why they got some other error, and self.handl

How to override handle_uncaught_exception ?

2010-11-08 Thread Phlip
I just need the usual features - to log the actual error, and stick it in the programmer's face during a test run. But when I Google for this subject, I get ten thousand newbies asking why they got some other error, and self.handle_uncaught_exception appears in their stack trace! --

Re: Factory Squirrel

2010-10-28 Thread Phlip
Tx! But! > http://github.com/dnerdy/factory_boy How does this do aggregation? > Also, there is a more general python > solution:http://farmdev.com/projects/fixture/ that supports django. That one's a little _too_ general. But it supports aggregation (association, etc.).. -- You received this

Factory Squirrel

2010-10-27 Thread Phlip
print self.kozmik_order # does not re-read the record >From here, to be more useful, we need to think of details like records without names (shameful!). Models with CamelCase already work - kozmik_LineItem. Any ideas how to improve this towards a true Squirrel? -- Phlip http://zeek

Re: SELECT * FROM `student` WHERE mark=(select max(mark) from student)

2010-10-26 Thread Phlip
On Oct 26, 10:24 am, Phlip wrote: > > This sounds like what django-reversion[1] does :) > > > [1]:http://github.com/etianen/django-reversion#readme > > We have to cover the situation where some clients might still have > rev(n-1), while some are up-to-date with rev(n

Re: SELECT * FROM `student` WHERE mark=(select max(mark) from student)

2010-10-26 Thread Phlip
> Things.objects.filter(id__in=Things.objects.values('name').annotate(max_id= > Max('id')).values_list('max_id', > flat=True)) I didn't do values_list because I guessed that the inner query would run and produce an array, then the outer query would run. My way, with values() on both sides of the

Re: SELECT * FROM `student` WHERE mark=(select max(mark) from student)

2010-10-26 Thread Phlip
lf._db) max_pids = max_pids.values('name').annotate(Max('pid')).values('pid') return qs.filter(pid__in=max_pids) Now we can write any ORM statement we can think of, and (if those lines continue to pass tests) then we only see the top horizon of the data.

Re: SELECT * FROM `student` WHERE mark=(select max(mark) from student)

2010-10-26 Thread Phlip
> I hope the auditors are only forcing you to do this with records that > aren't referenced as part of relationships, otherwise your database is > going to get hammered updating all the foreign keys. The design spec (which is ours, not any "CPA auditor's"), say to duplicate the living crap out of

Re: SELECT * FROM `student` WHERE mark=(select max(mark) from student)

2010-10-26 Thread Phlip
Tom Evans wrote: > Phlip, I'm going to try and make a non-stupid comment now :) http://xkcd.com/386/ > If you already know precisely the query you want to use, and you can't > coerce django's ORM to produce it, can you simply use Manager.raw()[1] > to generate t

Re: SELECT * FROM `student` WHERE mark=(select max(mark) from student)

2010-10-26 Thread Phlip
> st=Student.objects.filter(marks__in=Student.objects.all().aggregate(Max('ma > rks'))) Aha - a marks__in may point to an aggregate subquery. In conclusion, screw my SQL server's optimizer. It deserves to suffer! (I can't seem to find a self-join to do what I need either...) -- You received t

Re: SELECT * FROM `student` WHERE mark=(select max(mark) from student)

2010-10-26 Thread Phlip
On Oct 26, 2:42 am, Tom Evans wrote: > I'm curious, why can't I talk you into > Student.objects.all().order_by('-score')[0] ? > > It is clearly a superior query :/ > >> ( BTW please don't try to talk me out of it; I've been doing SQL since > >> 1989 and am fully aware of all the alternatives the

SELECT * FROM `student` WHERE mark=(select max(mark) from student)

2010-10-25 Thread Phlip
Does anyone have a QuerySet for that? ( BTW please don't try to talk me out of it; I've been doing SQL since 1989 and am fully aware of all the alternatives there. C-; ) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, sen

Re: Is there some way to log every SQL command sent to the DB?

2010-10-25 Thread Phlip
> You could turn on logging through your DB Hey! Thinking outside the box is MY job!! grumble grumble grumble thanks grumble... -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com.

Re: inheritance of fields and default values from parent model class

2010-10-24 Thread Phlip
> > class MyModel(models.Model): > >     alias = models.ForeignKey('self', blank=True, null=True) > >     manager = [my alias manager here] > >     def getAlias: > >           [whatever I need] > > > class Person(MyModel): > >     name = models.CharField(max_length=255) > > > class Place(MyModel):

Re: inheritance of fields and default values from parent model class

2010-10-24 Thread Phlip
=True, null=True)     manager = [my alias manager here] class Person(models.Model, MyModel):     name = models.CharField(max_length=255) class Place(models.Model, MyModel):     street = models.CharField(max_length=255) And now the model can't see the fields 'alias' or 'ma

Re: Django 1.2.3 test fixtures are slower than creating every model object each time setUp() calls.

2010-10-23 Thread Phlip
When I switch to TransactionTestCase - meaning a test case that does not use the transaction-rollback trick - the test time goes to 2.5s. This sucks. The test cases WITH transaction-rollback around each test case are SLOWER than test cases that just rebuild the DB by hand each time. -- You recei

Is there some way to log every SQL command sent to the DB?

2010-10-23 Thread Phlip
Google leads me to this: from django.db import connection print connection.queries It can't see the queries the test runner used to set up the database. So, how to log every SQL command to a log file? (Like RoR can?) -- Phlip -- You received this message because yo

Re: What does an ideal django workflow setup look like?

2010-10-23 Thread Phlip
ile allows for short command lines: fab run # build a sample database from your test fixtures & launch a server fab shell # use iPython for the best shell. fab ci:'what I did' # run all the tests then integrate Also, read the book "Release It!", if you think you

Django 1.2.3 test fixtures are slower than creating every model object each time setUp() calls.

2010-10-23 Thread Phlip
test case, shouldn't that work at the same speed as manual creation? How on earth could it be slower?? -- Phlip http://zeekland.zeroplayer.com/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send ema

Re: dump sqlite to file when testing

2010-10-22 Thread Phlip
On Oct 21, 10:54 pm, Russell Keith-Magee wrote: > On Fri, Oct 22, 2010 at 12:37 PM, Phlip wrote: > > I just tried it: > > > DATABASES = { > >    'default': { > >        'ENGINE': 'django.db.backends.sqlite3', > > #  TODO restore

Re: dump sqlite to file when testing

2010-10-21 Thread Phlip
I just tried it: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', # TODO restore'NAME': ':memory:', 'NAME': '/home/phlip/fun.db', 'USER': '',

Re: call more than one view action from an uri path?

2010-10-21 Thread Phlip
> Well, like I said, I haven't tested that particular regex.  But it > should be possible to write a regex that does work. it turns out your regex works fine: print re.search(r'^((\w+)/(\d+)/)+$', 'fries/4/frobs/9/areas/ 2/').group(1) Django uses groups() instead of group(1), for whatever reason

Re: call more than one view action from an uri path?

2010-10-21 Thread Phlip
> url('^((\w+)/(\d+)/)+$', 'myview', ...) Actually, no, that's only giving the last two matches: (u'areas/2/', u'areas', u'2') -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com.

Re: call more than one view action from an uri path?

2010-10-21 Thread Phlip
> You can't do something like this? > url('^((\w+)/(\d+)/)+$', 'myview', ...) Ah, I started with ^(.*)$ , and put the split on the inside. I will go with your + pattern, because it checks for trivial errors at the correct level. -- You received this message because you are subscribed to the Goo

Re: call more than one view action from an uri path?

2010-10-21 Thread Phlip
> REST, however, has a fairly rigid one-URL-one-action structure which is > ideally suited to Django's URL dispatch. The only way to get what you > want is to layer another dispatching service atop Django's. I don't > think you can do it with urlconfs alone. knp. The point of urlconf is to adapt a

Re: call more than one view action from an uri path?

2010-10-21 Thread Phlip
it like you said. C-: The point is a REST path that can go arbitrarily shallow or deep without excessive code. What I looked for was a lambda here (simplified): url( 'nest', lambda *a,**k: doit(a, k) ) but that terminates the lookup on the last item (rest), instead of calling the la

call more than one view action from an uri path?

2010-10-20 Thread Phlip
be available on some session or file-scope variable.) How to write an url() call in urls.py that handles part of a path, and then dispatches to the next part of the path, if any? -- Phlip http://bit.ly/ZeekLand -- You received this message because you are subscribed to the Google Groups

Re: rake routes

2010-10-19 Thread Phlip
> 2. Add 'django.contrib.admindocs' to your INSTALLED_APPS. Tx! But I will rip the innards of that out, because I'm targeting the test side (as usual!), and because we have no admin yet... -- You received this message because you are subscribed to the Google Groups "Django users" group. To post

rake routes

2010-10-19 Thread Phlip
A web platform which I will refer to as "Rails" lets you print out all the equivalents of the matchers and modules in the tree of urls.py files using "rake routes". Does Django have such a command? Or how could one be written? -- Phlip http://bit.ly/ZeekLand -- You r

Re: db filter comparing a minimum to a range

2010-09-13 Thread Phlip
Curiously, if I add another constraint to the dates, it must go into the Min() itself: Blog.objects.annotate(min_date= Min('comment__date', comment__status='sane')).all() Otherwise the date range check is disjoint from the sanity check (important for modern commenters!), and lots of rec

Re: db filter comparing a minimum to a range

2010-09-13 Thread Phlip
> Maybe this is what you want: > > http://docs.djangoproject.com/en/1.2/topics/db/aggregation/#filtering... Outrageous, thanks. I seem to have reconstructed the rational for .annotate(), which I didn't understand until now! -- You received this message because you are subscribed to the Google Gr

db filter comparing a minimum to a range

2010-09-13 Thread Phlip
whose first comment appears in the date range: SELECT * FROM blog INNER JOIN comment ON comment.blog_id = blog.id WHERE MIN(comment.date) BETWEEN '2010-09-12' AND '2010-09-14' GROUP BY(blog.id) Can I get that without dropping to raw SQL? -- Phlip http://zeekland.zero

python manage.py runserver - can't see error stack traces when an Ajax handler throws an exception

2010-09-07 Thread Phlip
errors to print a simple exception trace to STDOUT, instead of going through all that baloney? -- Phlip http://c2.com/cgi/wiki?SamuraiPrinciple <-- re: django.db! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this grou

Re: do QuerySet joins still suck?

2010-08-10 Thread Phlip
rom a child record; it might follow that notation. Could I trouble you for its home page? Googling for [django queryset join] gives zillions of newbs trying simple queries... --   Phlip   http://c2.com/cgi/wiki?ZeekLand -- You received this message because you are subscribed to the Google Grou

do QuerySet joins still suck?

2010-08-10 Thread Phlip
rlooked something obvious... -- Phlip http://bit.ly/ZeekLand -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django

Re: test's client.post says post but request.method says GET

2010-07-30 Thread Phlip
On Jul 30, 3:28 am, Phlip wrote: > > What's the value of `self.url`? One possibility is that it doesn't end > > with a slash > > Ends with a slash. I'm now checking the response goodies, like > response.status, to see if any other redirections happen! Yup

Re: test's client.post says post but request.method says GET

2010-07-30 Thread Phlip
> What's the value of `self.url`? One possibility is that it doesn't end > with a slash Ends with a slash. I'm now checking the response goodies, like response.status, to see if any other redirections happen! -- You received this message because you are subscribed to the Google Groups "Django u

Re: test's client.post says post but request.method says GET

2010-07-29 Thread Phlip
forgot to mention Django 1.1.2 On Jul 29, 5:18 pm, Phlip wrote: > Django aficionados: > > Here's my test code: > >         from django.test.client import Client >         self.client = Client() >         from django.core.files.base import ContentFile >      

test's client.post says post but request.method says GET

2010-07-29 Thread Phlip
he other absorbs new form data, as usual. However, when I print request.method, I get GET. Is this a bug in Client? or in (ahem) my comprehension? -- Phlip http://c2.com/cgi/wiki?ZeekLand -- You received this message because you are subscribed to the Google Groups "Django users"

Re: django + ajax

2010-06-07 Thread Phlip
On Jun 7, 4:48 am, tazimk wrote: > Also how should I implement the same thing using jquery library ? Isn't that how the online examples all 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-us..

how to call label_tag?

2010-06-03 Thread Phlip
Djangoists: Given a form, I can expand a template with {{ form.my_field.label }} which inserts the string of label into my HTML. How do I call label_tag? It seems to decorate the label string with and similar HTML-correctness. {{ form.my_field.label_tag }} did not work. -- Phlip http://c2

need help writing FactorySquirrel - a custom fixture handler

2010-05-29 Thread Phlip
se. So am I mishandling the exec...globals() part? Is there a better way to register a handler? Help me bring squirrel-like speed to test cases! -- Phlip http://c2.com/cgi/wiki?ZeekLand -- You received this message because you are subscribed to the Google Groups "Django users" group. T

testing client.get('/yo/', {}, HTTPS='on') ?

2010-05-27 Thread Phlip
mewhat fruity if it's off by default! -- Phlip http://zeekland.zeroplayer.com/Hat_Trick/2 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from

Re: pass related_name-s into Model.objects.create()?

2010-05-18 Thread Phlip
> > But what about 'ForeignKey's? May we pass their 'remote_name's in with > > the kwargs? > > Foreign Keys - yes. Reverse Foreign Keys - no. Point: All kwargs takes is the fields on this object. > In the case of a foreign key, just pass in the object instance that > you want your object to be re

pass related_name-s into Model.objects.create()?

2010-05-17 Thread Phlip
emote_name's in with the kwargs? If not, what's some clean way to construct everything all at once? -- Phlip http://c2.com/cgi/wiki?ZeekLand -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send emai

pass related_name-s into Model.objects.create()?

2010-05-17 Thread Phlip
old-fashioned way, after they are created? -- Phlip http://c2.com/cgi/wiki?ZeekLand -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this gro

Re: unit tests: database confusion

2010-05-12 Thread Phlip
> Hi jararaca >               Can u brief me the solution.Even i am not able to access test > database ,some how it fetch production database itself Hear galloping, think horses not zebras. are y'all running your test batch like this? python manage.py test --settings=test_settings.py does tes

Re: assert_match_hash(self, reference, sample)

2010-04-19 Thread Phlip
>         for key, value in reference.items(): >             if value == sample.get(key, value or True): if value == sample.get(key, not(value)): D'oh! C-: -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, s

assert_match_hash(self, reference, sample)

2010-04-19 Thread Phlip
diagnostic or '' ) ) diagnostic = diagnostic.strip() self.assert_equal( reference, sample, diagnostic ) Can anyone improve it? Did I overlook any dict manipulations that could simplify it? And if two hash values are themselves hashes, it could recurse, right? & H

Re: what lines in the templates are culpable?

2010-04-12 Thread Phlip
> If you posted some specifics of what you are actually seeing, someone might > be able to help. I mean, actually copy-paste the traceback into your post > (or put it someplace like dpaste.com and point to it). I am not asking "oo help I can't get my template working". That part's done - by clampi

Re: what lines in the templates are culpable?

2010-04-12 Thread Phlip
> Uusually the first line in the traceback tells you pretty explicitly > where the error is. Without the traceback, it's hard to say where your > problem lies. One of the templates is "basket.html", and "basket.html" does not appear in the transcript. All the lines are only django's internal rend

what lines in the templates are culpable?

2010-04-12 Thread Phlip
Djangoists: When code below a template throws an error, we get an insanely detailed stack trace of all the lines AROUND the template. How do I tell what lines INSIDE the templates caused the error? -- Phlip http://c2.com/cgi/wiki?ZeekLand -- You received this message because you are

Re: manage.py loaddata silently fails

2010-04-12 Thread Phlip
warning. The fixtures= line also has this bug. -- Phlip -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to

manage.py loaddata silently fails

2010-04-12 Thread Phlip
Djangoists: (Under version 1.1.1) loaddata (and the fixtures= line in tests) silently fails if the data cannot load. How do I access the error message? -- Phlip http://c2.com/cgi/wiki?ZeekLand -- You received this message because you are subscribed to the Google Groups "Django

Re: How do I properly unit test a Django session?

2010-03-31 Thread Phlip
E_NAME] = store.session_key session = self.client.session session.update(dictionary) session.save() # and now remember to re-login! -- Phlip http://c2.com/cgi/wiki?ZeekLand -- You received this message because you are subscribed to the Google Groups "Django users

assert_compliant_sql

2010-03-30 Thread Phlip
tput The source appears below my sig (where I am aware archivers might trim it). Warning: Per my other thread, calling EXPLAIN on an a SQLite3 connection seems to scramble it. Not sure why, but I don't care, because one should not use SQLite3 in production. -- Phlip http://c2.com

Re: assert_performant(query_set)

2010-03-29 Thread Phlip
do with Django - is ... cursor.execute('EXPLAIN ' + query) ...seems to scramble a sqlite3 database. If I take the EXPLAIN out I don't get unrelated test failures (tho the new assertion naturally does not work!). I will make it work for MySQL! -- Phlip -- You received this message becaus

Re: I am having issues with django test

2010-03-29 Thread Phlip
>     def setUp(self): >         user = User.objects.create_user(USER, '@nowhere.com', PASS) That's what fixtures are for! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. T

Re: How to share settings file in multiprogrammer project

2010-03-29 Thread Phlip
> The test_settings and dev_settings should point to a PASSWORDLESS > database with localhost-only permissions. The production_settings file > should not be committed. It's the one copied up to the server. Come to think of it, what I'm screaming about here is three separate things: - developer d

Re: How to share settings file in multiprogrammer project

2010-03-29 Thread Phlip
e one copied up to the server. All sub-settings files should start with from settings import * to pull in the common settings, and should override them if they need to. One important override is test_settings should use sqlite3 :memory: database. -- Phlip http://c2.com/cgi/wiki?ZeekLand -- You

Re: assert_performant(query_set)

2010-03-29 Thread Phlip
>  * Similarly, connection.cursor() will only work in the single > database case. connections[qs.db].cursor() Aaaand that's not working either. (No connections, no qs.db.) I must take a break until someone unravels all this, because I don't know enough about the architecture inside QuerySet... -

Re: assert_performant(query_set)

2010-03-29 Thread Phlip
>   AttributeError: 'BaseQuery' object has no attribute 'get_compiler' qs._as_sql() returns a tuple of a SELECT statement, and a (), presumably with wildcards; I will start there. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this

Re: assert_performant(query_set)

2010-03-29 Thread Phlip
> qs.query.get_compiler(qs.db).as_sql() That gives this error message with the usual zero Google hits for that error message: AttributeError: 'BaseQuery' object has no attribute 'get_compiler' -- You received this message because you are subscribed to the Google Groups "Django users" group.

Re: Testing email with the testserver

2010-03-26 Thread Phlip
;s why the documentation assumed you started there. -- Phlip -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-us

Re: automatically import lots of modules at python manage.py shell time?

2010-03-26 Thread Phlip
local_dict[model_class.__name__] = model_class del local_dict, appcache, os ''') os.system('ipython -i -nobanner .ipython') -- Phlip http://c2.com/cgi/wiki?ZeekLand -- You received this message because you are subscribed to the Google Groups "Django users"

automatically import lots of modules at python manage.py shell time?

2010-03-26 Thread Phlip
. How can we fix the first problem? How can this (otherwise useful) shell use a minimal or invisible import rubric, to grab, say, a bunch of models so they are all ready & available for use? -- Phlip http://penbird.deviantart.com/ -- You received this message because you are subscribed to

new_records = assert_latest(query_set, lambda)

2010-03-24 Thread Phlip
#x27;s only one - we sample the lambda source, to make the error message as clear as possible; this works best if the lambda's on its own line - every assert needs a deny; I will write deny_latest as soon as a need appears. -- Phlip http://zeekland.zeroplayer.com/Pigleg_Too/

Re: assert_performant(query_set)

2010-03-24 Thread Phlip
orrect, we will pin down their behavior if we parse back the intermediate value - the actual SELECT statement, and then interrogate it. Oh, yeah, and such a test is also perform...ing. Well. Because it doesn't build records or read them. I will see when I have time to code that up... -- Phlip

assert_performant(query_set)

2010-03-23 Thread Phlip
at, I have used this technique, copiously, on other projects, and whenever that assertion failed it indeed saved us from accidentally deploying a slow SQL statement to our server! -- Phlip http://zeekland.zeroplayer.com/Pigleg_Too/1 -- You received this message because you are subscribed to t

Re: Negate querysets

2010-03-23 Thread Phlip
> I want to be able to answer your question, forever. Is there a way, > from a developer test, to query "what SQL statement does this QuerySet > generate"? Oh, duh, it's QuerySet.query, as a string. Brand X makes that one inconceivably hard, due to poor factoring... >

Re: Negate querysets

2010-03-23 Thread Phlip
"SELECT * WHERE id not in (SELECT id WHERE ...)" might just snocker the database worse than two SELECTs. You never know; that's why I'd like to see an EXPLAIN on it! -- Phlip http://c2.com/cgi/wiki?ZeekLand -- You received this message because you are subscribed to the Googl

Re: Negate querysets

2010-03-22 Thread Phlip
> Just create another queryset that excludes everything in your first > queryset: > > negated_queryset = User.objects.exclude(id__in=queryset.values("id")) QuerySets are already so easy to plug-n-play... Ain't there a way to do it without whacking the database twice?

Re: PyCharm IDE - Anyone using it yet

2010-03-12 Thread Phlip
ecades do we have to wait until editors support testing as aggressively as debugging? -- Phlip http://penbird.deviantart.com/art/Uncle-Wiggily-Wants-You-156969773 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this

Re: def reload(model): model.__dict__ = model.__class__.objects.get(pk=model.pk).__dict__ ; return model

2010-03-11 Thread Phlip
iously - reload(instance) does nothing to the instance we already have, and its internals are still dirty... -- Phlip http://c2.com/cgi/wiki?ZeekLand -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send emai

def reload(model): model.__dict__ = model.__class__.objects.get(pk=model.pk).__dict__ ; return model

2010-03-10 Thread Phlip
ort (or fail to prevent) assigning a .__dict__ like that? -- Phlip http://c2.com/cgi/wiki?ZeekLand -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe fr

SNIPPET: assert_model_changes(record, 'field', 41, 42, lambda: money_line())

2010-03-10 Thread Phlip
eval() a string instead of serve an attribute? self.assert_model_changes( blog, 'post.count()', 41, 42, lambda: blog.write_one_post('yack yack yack') ) The code shows how to .reload() in Django, because (unless I'm wrong), Django models don't ha

Re: Adding a new convenience filter 'contains_any'

2010-03-08 Thread Phlip
> > And if the PEP8 told you to ... just jump off a cliff... would you? > > Sounds like you might benefit from actually reading it: This thread arc is about me lamenting the positive value of style guides, even those with wrong line-items. Nobody here has said to get creative with any style guide

Re: Adding a new convenience filter 'contains_any'

2010-03-08 Thread Phlip
> In this case, it's not just a team style guide - it's PEP8, which clearly > says: And if the PEP8 told you to ... just jump off a cliff... would 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

Re: Adding a new convenience filter 'contains_any'

2010-03-05 Thread Phlip
> >>> (I also disagree with leaving out the spaces around =, but obviously > >>> obeying a team style guide supersedes improving it...) > > >> ... the goal of clarity/legibility > > > uh... > > ;)  I meant *having* a style guide was consistent with said goal. right - following an aesthetic style g

Re: Adding a new convenience filter 'contains_any'

2010-03-05 Thread Phlip
On Mar 5, 8:41 am, Peter Herndon wrote: > On Mar 4, 2010, at 7:37 PM, Phlip wrote: > > (I also disagree with leaving out the spaces around =, but obviously > > obeying a team style guide supersedes improving it...) > > ... the goal of clarity/legibility uh... -- You

Re: Adding a new convenience filter 'contains_any'

2010-03-04 Thread Phlip
;list's) in fields, the =[] event is free to be "overloaded" by its type. So id=[] would resolve to id__in=[], id=Scalar to id__exact=Scalar, and the explicit versions are available if you suspect that overloading is fragile. (I also disagree with leaving out the spaces around =, but obvi

Re: Adding a new convenience filter 'contains_any'

2010-03-04 Thread Phlip
Peter Herndon wrote: > Won't the "in" filter do exactly what you need? > > http://docs.djangoproject.com/en/1.1/ref/models/querysets/#in Why do you need even __in? Given... Entry.objects.filter(id__in=[1, 3, 4]) ...couldn't id=[] overload if the target is

Re: shortest way to recover from a QuerySet "object not found"

2010-03-04 Thread Phlip
> The only condescension I've seen in this thread is from you. And, to > be fair, if I wanted to be condescending I'd have simply pointed you > at Tony Hoare's explanation of null values That's why I said NullObject, in the first post. -- You received this message because you are subscribed to t

Re: shortest way to recover from a QuerySet "object not found"

2010-03-04 Thread Phlip
> Just create your own Manager and override the default (named 'objects') in > your models. Have 'get' behave any way you like. > > http://docs.djangoproject.com/en/1.1/topics/db/managers/ > > Shawn Ding! http://docs.djangoproject.com/en/1.1/topics/db/managers/#adding-extra-manager-methods luv

Re: shortest way to recover from a QuerySet "object not found"

2010-03-04 Thread Phlip
Oh, look! "123"[:7] ! The string doesn't have 7 characters! Gee, shouldn't that throw an exception? -- Phlip -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googl

Re: shortest way to recover from a QuerySet "object not found"

2010-03-04 Thread Phlip
method to use .get(). So to squeeze my attempt into one line, we get foo = (list(Foo.objects.filter(name='bar')) + [Foo()])[0], which is way too much typing. Doesn't anyone in Django-land have experience with the platforms that make this problem incredibly easy? -- Phlip -- You

  1   2   >