> 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
> 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
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
;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
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
> >>> (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
> 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
> > 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
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
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
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
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
> 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?
"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
> 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...
>
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
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
#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/
.
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
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"
;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
> 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.
> 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
> * 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...
-
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
> 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
> 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
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
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
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
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
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
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
> 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
> 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
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
" 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
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
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
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.
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@
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"
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
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
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
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
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
==
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.
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
101 - 149 of 149 matches
Mail list logo