Any reason not to make the total 0 instead of None? Null in database
(or None in Python) has a special meaning, and it doesn't always make
sense to sort a list of (mostly) integers with some null values.
-Jeff
On Jun 30, 2:01 am, J wrote:
> Hello,
>
> I developed an app
You can actually do something like it fairly simply, by using the
classmethod decorator, like so:
class Thing:
@classmethod
def do_something(cls, some_arg):
# do something with some_arg
Then you could call it:
Thing.do_something(3)
Notice that you don't pass the "cls"
Take a look in the database itself (use the sqlite3 shell) and see if
the full phrase is being stored. If it is, then there is an issue
with how you are pulling the data out and displaying it in the form;
if it isn't, then there is an issue with how you are saving the data
in the first place.
Have a choice of "Other", and provide a separate field for the user to
type in their own data. That's a pretty standard way to handle that.
If you wanted to make it fancier, you could even have javascript to
only show the "other" text box if they've chosen the "Other" option.
-Jeff
On May 29,
something wrong,) then I'm not too worried
about it. I guess I won't know what they see until it happens to me,
though :-)
Thanks for your help,
Jeff
On May 25, 6:59 am, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:
> On May 25, 4:53 am, Jeff FW <jeff...@gmail.com> wrote:
>
&
,
'wsgi.file_wrapper': ,
'wsgi.input': ,
'wsgi.multiprocess': True,
'wsgi.multithread': False,
'wsgi.run_once': False,
'wsgi.url_scheme': 'http',
'wsgi.version': (1, 0)}>
Thanks a lot,
Jeff
On May 21, 10:47 pm, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:
> On May 22, 12:31 pm,
I've had the same problem, and can't figure out how to resolve it. It
seems to have nothing to do with the amount of data being transfered:
it happens occasionally on the smallest of page requests/responses.
It also doesn't seem to be related to browser, unless several
different versions of IE
Sure--those are totally reasonable in most cases. However, the OP
just said that all that's in the form is a single button, meaning most
of those won't be an issue in this case.
-Jeff
On May 15, 10:03 am, Tim Chase wrote:
> > If the form is just a single
If the form is just a single button, why not use GET and not have to
deal with POST at all?
-Jeff
On May 14, 11:28 am, aa56280 wrote:
> Tim,
>
> Thanks for the fantastic insight into the browser issues with 307
> redirects. I'll explore this a bit further and see which route
It looks like you're missing (or at least, didn't mention) the
templates. In documentation:
http://docs.djangoproject.com/en/dev/ref/contrib/syndication/#ref-contrib-syndication
make sure to read the paragraph starting with "One thing's left to do"
under "A simple example".
-Jeff
On Apr 15,
http://docs.djangoproject.com/en/dev/topics/http/sessions/#session-expire-at-browser-close
On Apr 1, 2:26 am, veeravendhan wrote:
> Say a user is logged in to the system, If he closes the browser how
> will I handle the Logout for that user ? Any idea ??
Changing request.user.id doesn't make sense--that would be trying to
change the id of the user object itself. I think what you're trying
to do is change the user that is actually logged in... right? If
that's true, then you need to set request.user *not* request.user.id--
but that seems like a
My original suggestion would still work--run a cron job every minute
(or so) that finds all of the sessions that have an expiration date
since the last time the script was run--delete those, then log an
entry in your audit table. Seems pretty simple to me, and I can't see
any reason why it
t;
> I appreciate your responses and I stand corrected. With that being
> said, are either of you (or anyone reading this) aware of a method
> that would allow me to track idle session timeouts? I'd like to audit
> when a user has been logged out due to a timeout.
>
> Huuu
It's not a bug. When a cookie expires, the browser stops sending it
with its requests--therefore, there is *no* way for Django to know
that the cookie (and therefore, the session) has expired. There is no
"timeout" happening on the server side, so the session can't get
cleared out. Hence, why
Especially since international phone numbers can start with 0--try
storing that in an integer field, and you'll immediately run into
problems.
On Mar 13, 8:43 am, Ozan Onay wrote:
> As Karen pointed out, you should consider a phone number to be a
> string, not an integer.
se, the object has to be serializable.)
>
> > If that doesn't work, post the full (relevant) code.
>
> > -Jeff
>
> > On Mar 5, 7:01 am, Marek Wawrzyczek <mwawrzyc...@gmail.com> wrote:
>
> >> > Thomas Guettler wrote:
>
>
Clearly, you get to work on cooler projects than I :-) I had thought
of the keywords/phrases case, but the other ones are far more
interesting. Thanks for the explanation!
-Jeff
On Mar 5, 7:02 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:
> On Thu, 2009-03-05 at 12:54 -0
Marek said for anything other
than models (of course, the object has to be serializable.)
If that doesn't work, post the full (relevant) code.
-Jeff
On Mar 5, 7:01 am, Marek Wawrzyczek <mwawrzyc...@gmail.com> wrote:
> Thomas Guettler wrote:
>
> > Jeff FW schrieb:
>
Well, then, that is quite a strange use case :-) Nevermind my simple
methods. Malcom's suggestion of an extension for postgres seems like
a good idea--writing functions in various languages (like Python!) is
_really_ easy in postgres.
Just out of curiosity (for either of you,) what is a search
The serializers are for serializing querysets/models. I'm surprised
you're not getting an error message there--are you catching all
exceptions?
What you want is in django.utils.simplejson:
from django.utils.simplejson import encoder
encoder.JSONEncoder().encode(ret)
-Jeff
On Mar 4, 6:55 pm,
You'd have to split() the string (probably on spaces, though I don't
know exactly what you're going for,) then build a query that checks
for each piece OR'd with every other piece. That would probably be
the best way--check out:
as sum--in Python, and in SQL.
On Mar 3, 11:36 am, Jeff FW <jeff...@gmail.com> wrote:
> Responded too quickly :-)
>
> If you're already getting a list of the top 100 products (and
> displaying them, I assume, in a loop,) then totalling up the prices in
> Python really won't h
products.
-Jeff
On Mar 3, 11:34 am, Jeff FW <jeff...@gmail.com> wrote:
> The behavior is there because you can't limit an aggregate function in
> (AFAIK) SQL in that way. It just doesn't make sense--what would this
> actually mean?
>
> select sum(price) from product limit 1
The behavior is there because you can't limit an aggregate function in
(AFAIK) SQL in that way. It just doesn't make sense--what would this
actually mean?
select sum(price) from product limit 100;
Really, you'd be limiting the number of *rows* of sum returned, which,
unless you're using GROUP,
I just tried running the code that the "U" date-formatting parameter
uses, and for me, it was off by about 11.5 days. According to the
documentation, the "U" parameter is not implemented:
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#now
According to this ticket, someone might
As much as I hate to suggest it, this sounds like a good time to use
XML. Store each report as XML (in a file, or in a database row), then
use templates to render the data.
-Jeff
On Feb 9, 3:24 pm, Dids wrote:
> > This is extremely unlikely to work, not to mention
You need to make sure that the user apache is running as (usually
"apache") has write access to the database file *and* the directory
that the database file is in.
The development server would work because *you* probably have write
access to those paths.
As for the sqlite3 version, run python,
Yes, that's what I was suggesting. Sorry for not being more clear.
As for storing the field twice, unless you're planning to have huge
amounts of records, you wouldn't really noticed any difference at
all. Also, you can have the admin interface set to *not* display the
stripped version, so
The issue has nothing to do with your templates--it has to do with
your data, and how you're searching it. In the database, you have
stored "Survival of Shigella". If you do a regular text
search (field__contains, or similar) for "Survival of Shigella",
you'll never get a match, because those
xander.j.robb...@gmail.com>
wrote:
> It might be even easier to just set up an NFS mount of the other
> machines. It would be a lot like Jeff's idea, but NFS is pretty tried
> and true. (I don't know anything about SSHFS, it might be really good
> too.)
>
> On Jan 30, 9:54 am,
Instead of trying to get Django to do something like that, have you
looked into using sshfs? That would make it essentially transparent--
all Django would know is that it's saving a file to a filesystem.
http://en.wikipedia.org/wiki/SSHFS
On Jan 29, 9:05 am, Andrew Ingram
What you're looking for is explained in the documentation on writing
your own template tags:
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/
Specifically, I'd look into inclusion tags:
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#inclusion-tags
-Jeff
On Jan
Mark,
You should really use Forms and FormSets--they'll make this problem
essentially go away.
http://docs.djangoproject.com/en/dev/topics/forms/#topics-forms-index
http://docs.djangoproject.com/en/dev/topics/forms/formsets/
-Jeff
On Jan 12, 12:46 am, Mark Jones wrote:
>
Post the code for DataForm--I'll bet it's hitting the database a
number of times. That would be the only reason I can think of that it
would take that long. I just created a formset containing simple
forms, and it instantiated almost instantly--even with 2000 forms.
-Jeff
On Jan 6, 3:21 pm,
Yup, that's exactly what formsets are for. You essentially take the
form you've already written, and pass it to formset_factory() to
create a list of identical forms.
http://docs.djangoproject.com/en/dev/topics/forms/formsets/#topics-forms-formsets
-Jeff
On Jan 6, 1:02 am, "Kottiyath Nair"
I think you've got a small typo in the code there, that might be
confusing to the OP--shouldn't the get_model() call have quotes around
"tag"? Like so:
model_class = get_model("test", "tag")
-Jeff
On Dec 23, 5:03 pm, bruno desthuilliers
wrote:
> On 23 déc,
That error is occuring because you don't have a URL defined for
password_reset_done, which, presumably, is being referred to in your
forgotpassword.html in a {% url %} tag. Check out this brief
tutorial, it's rather handy:
http://www.rkblog.rk.edu.pl/w/p/password-reset-django-10/
-Jeff
On Dec
Wow, you're right. I've been programming Python for years, and I
somehow never noticed that. I'll be quiet not :-)
On Dec 17, 6:33 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:
> On Wed, 2008-12-17 at 15:09 -0800, Jeff FW wrote:
> > You've got a s
> the last line of the error is
>
> *
> OperationalError: unable to open database file
> **
>
> NOtes: I have put the complete path for the DB /home/XXX/djangoProys/
> mysite2/DBmysite2, and I tried change permissions for database file
Make sure that apache can read and write the
Looking at
http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/__init__.py#L46
it doesn't look like it clears the session. It *does* generate a new
key, but that shouldn't affect anything. It should only take you
about two minutes to test it though--just try it out.
-Jeff
Check out:
http://www.doughellmann.com/PyMOTW/contents.html
He's got tutorials on quite a lot of the python stdlib--very handy
resource. csv and zipfile are on there.
-Jeff
On Dec 19, 9:40 pm, Brandon Taylor wrote:
> I've been looking at the methods from those libs.
You've got a space in between "HttpResponseRedirect" and "('../
shop')" .
On Dec 17, 2:44 pm, Bobby Roberts wrote:
> > Have a look at theflush() method; I believe that might well be close to
> > what you are after.
>
> > Regards,
> > Malcolm
>
> I'm trying to call the view
e, but it's strange since my template extends
> the "admin/change_form.html".
>
> On Dec 12, 9:05 pm, Jeff FW <jeff...@gmail.com> wrote:
>
> > You're passing your queryset in, but you're never using it in your
> > widget. In my code, see how I have:
>
> &g
f.widget = admin_widgets.RelatedFieldWidgetWrapper(
> forms.Select(),
> TournamentResult._meta.get_field('tournament').rel,
> admin.site,
> )
>
> class UploadFormInitial(forms.Form):
> tournament = TournamentChoiceField(Tournament.objects.all())
>
> B
Sure do: it should be __str__() with two underscores on either side,
not one.
-Jeff
On Dec 12, 7:33 am, ben852 wrote:
> Hi,
> I am new to django and programming.
> I have a problem with the method _str_( ).
> Following the tutorial, I edited my models.py file in
n, oh man, was that frustrating,
> but hopefully now it won't bite me again. Yes, I had made a "root"
> user and a "norm" user, I was logged in as norm, and norm's not an
> admin.
>
> All set now! Thanks again!
>
> Norm
>
> On Dec 11, 10:13 am, Jeff FW <jeff...@
er, so I feel like
> it's unlikely to be a Dreamhost issue.
> Norm
>
> On Dec 11, 6:11 am, Jeff FW <jeff...@gmail.com> wrote:
>
> > Possibly a silly question--but did you run syncdb after adding
> > staticimage2 to your INSTALLED_APPS?
>
> > -Jeff
>
> >
Possibly a silly question--but did you run syncdb after adding
staticimage2 to your INSTALLED_APPS?
-Jeff
On Dec 10, 9:49 pm, Norm Aleks <[EMAIL PROTECTED]> wrote:
> I'm using Django 1.0.2 (on Dreamhost, if that matters) and having
> trouble getting a new model to show up. I'm cringing a
b.sites' modules and in some cases, they are worse than
> good.
>
> Maybe I'm facing one of those cases, so I should get ride of those
> modules and deploy an "extras" application with just views and
> templates but no models (no database).
>
> If someone has some other hints
Do you have CommonMiddleware enabled in your settings.py?
http://docs.djangoproject.com/en/dev/ref/middleware/#module-django.middleware.common
On Dec 9, 7:29 pm, Nuno Machado <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm using flatpages to display some static content in a site. The
> "about" page is
Also, as an aside to all of that--what you're generating is in no way
guaranteed to be unique. If you really need a unique string, use a
UUID or hash of the primary key.
On Dec 9, 3:48 pm, bruno desthuilliers <[EMAIL PROTECTED]>
wrote:
> On 9 déc, 11:32, Chris <[EMAIL PROTECTED]> wrote:
>
> >
issue that I
> described. I tried passing it as default instead of using the save
> method but does not work and since I am not passing random to default
> directly, I cannot do this default=random.random. Any Ideas how I can
> fix this? thanks.
>
> On Dec 9, 6:00 am, Jeff FW <[EMA
Chris,
It depends on where you're calling random.random(). If you're trying
to do it in a model definition, then you're always going to have the
value it chose when it first executed the model's class definition--
when the server starts up. In that case, you should be able to pass
an argument
To get the plus icon back, you need to wrap the field in a
RelatedFieldWidgetWrapper. Here's an example from my code--obviously,
you'll have to adapt it to fit your situation.
class CategoryChoiceField(forms.ModelChoiceField):
def __init__(self, *args, **kwargs):
You could write a very simple filter to do this. Something like
(untested):
def range(top):
return xrange(0, top)
then use {% for i in someInt|range %}
I think it would still be better to pass it in the context--why can't
you do that?
-Jeff
On Dec 7, 5:12 pm, Berco Beute <[EMAIL
You can pass the settings object into your context when you render
your template, or you can write a context processor that adds the
settings object to the template's context. Take a look at the docs on
context processors, especially the section about writing your own:
Do you mean when a user is added via the admin interface, or when a
user registers on the site through a view you have set up? If it's
through a view you've made, then just add the call to send_mail() in
the view. For the admin site, you'll want to look at signals:
What do you mean by "disappears"? How are you trying to output it?
There's nothing special about the string that line generates, and I
doubt anything would have changed between versions of Django that
would stop that string from doing something it used to do.
-Jeff
On Nov 30, 10:56 am, Log0
too.
>
> Thanks a ton.
>
> Saurabh.
>
> On Wed, Nov 26, 2008 at 7:39 PM, Jeff FW <[EMAIL PROTECTED]> wrote:
>
> > This sounds, to me, like a great candidate for using Django. Each of
> > the separate modules you described could be a distinct application
>
s making 300+ save()'s in a try/except, 90% of which won't be committed
> to the database?
>
> On Wed, Nov 26, 2008 at 9:00 AM, Jeff FW <[EMAIL PROTECTED]> wrote:
>
> > If you already have a unique key on the project's name field, then
> > you're good to go--no duplicates will
;
> I think not much networking is involved here, right, apart of course from
> accessing the database server?
>
> I guess, now that I have read your emails and have noted down my
> requirements, I would rather go with django, right?
>
> Thanks once again!
>
> Regard
If you already have a unique key on the project's name field, then
you're good to go--no duplicates will ever get inserted. No need to
do any filtering ahead of time--just put each save() in a try/except
block that catches the error you get and does nothing.
-Jeff
On Nov 25, 4:53 pm, "Alex
Alessandro,
I'm not exactly sure what you're asking, but I think you want to know
how to check multiple fields (possibly against each other) when
submitting a form in the admin. Let me know if I'm off-base here.
Take a look at:
Saurabh,
I have spent the past year developing a GUI application (using
wxPython) that communicates with a server (using Twisted), which
connects to a PostgresQL database (using SQLAlchemy.) It has been a
very rewarding experience learning and using all of these tools.
However, the learning
You could define the CHOICES as a member of your model class, like so:
class Movie( Relic ):
CHOICES=((u'1','one'), (u'2',u'two'))
disk_type = models.CharField( 'Type', max_length=8,
choices=CHOICES)
Then, in your form:
class MovieForm( BasicRelicForm ):
disk_type =
You need a trailing slash after /myapp/media/admin. The final URL
will then come out to:
http://localhost/media/admin/css/dashboard.css
-Jeff
On Nov 16, 11:37 am, Chris <[EMAIL PROTECTED]> wrote:
> I'm trying to setup my app so it's accessible from a /myapp sub-
> directory. I defined BASEURL
I also wrote middleware for SQLAlchemy--I'd post it, but it depends on
other libraries that I wrote that I can't really share. What I found
is that, at least while using the dev server, the process_response
method would get called when serving media files, even if the
process_request hadn't.
Can you be more specific? What are you trying to do?
-Jeff
On Nov 1, 3:52 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> I have found some post of 2007 on this argument but maybe with django
> 1.0 something is changed.
>
> how do you do that ?
>
> thanks everyone :)
If you know the length of the string that you want to cut off the
beginning, you could use slice:
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#slice
Really, though, you might be going about this in a strange way. It
might be better to use the url tag to get the correct URL that
And you don't need root access to install/run Apache either. It might
be a pain to install w/o root, depending on your OS, but running it
wouldn't be too hard, as long as you pick a port above 1024. One very
good reason (I think) to avoid using Django's development server is
the inability to
the future.
-Jeff
On Oct 24, 1:01 am, ramya <[EMAIL PROTECTED]> wrote:
> I wanted to write one all purpose generic template..
>
> Now I have split that and extended multiple specific templates.. :(
>
> Thanks,
> ~ramyak/
>
> On Oct 23, 6:34 pm, Jeff FW <[EMAIL PROTECT
To my knowledge, no, it's not possible to do that. Even if it was,
however, I would strongly argue against it, as it would make your
templates unreadable--how would you know what filter/tag would be
called without mucking through the rest of your code? Maybe there's a
better way to get the
That's because when you define unicode(), inside the scope of that
function, the name "unicode" is now bound to the function you just
defined. So, the line "date = unicode(self.dated)" is calling
Letter.unicode() instead of Python's builtin unicode(), and you get an
(almost) infinite recursive
Thank you all, yet again, for making it feel like the past decade or
so that I've been using other languages/frameworks was completely
wasted :-) Keep it up, please.
-Jeff
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Sounds like you're looking at the oldforms documentation--that's all
been deprecated. Read this instead:
http://www.djangoproject.com/documentation/newforms/
Especially this part:
http://www.djangoproject.com/documentation/newforms/#custom-form-and-field-validation
-Jeff
On Jul 21, 8:14 am,
If you just want to apply the formatting in the change_list view, then
define a method in the class in question that returns the formatted
string you want. Then, in the corresponding Admin class, put the name
of that function in list_display, and that's it.
If you're talking about modifying it
Check out:
http://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html
However, instead of dealing with it that way, you could also use this:
http://www.djangoproject.com/documentation/db-api/#iexact
-Jeff
On Jul 16, 5:54 am, "Peter Melvyn" <[EMAIL PROTECTED]> wrote:
> On Wed, Jul 16, 2008 at
According to:
http://code.djangoproject.com/wiki/VersionOneRoadmap#must-have-features
newforms-admin is a high priority.
If you haven't already, take a look at:
http://code.djangoproject.com/wiki/NewformsAdminBranch
http://code.djangoproject.com/wiki/NewformsHOWTO
They're both *really* helpful,
s.CharField(label=i.name)
>
> Regards,
> Srikanth
>
> On Jul 15, 7:14 pm, Jeff FW <[EMAIL PROTECTED]> wrote:
>
> > You have to pass the data into the form when instantiating it, eg:
> > form = MyForm(request.POST)
>
> > However, that means (for your exam
You have to pass the data into the form when instantiating it, eg:
form = MyForm(request.POST)
However, that means (for your example), the fields wouldn't exist yet--
move them into __init__ instead.
Some other things to note: you don't need to "title" and "email" to
the form dynamically--might
Misspoke in that last post--if you want a select tag, obviously you
won't be using li tags. You'd use option tags, and maybe throw in
some text in front of each option to indicate the level. Everything
else still applies the same.
-Jeff
On Jul 12, 11:57 am, Nenillo <[EMAIL PROTECTED]> wrote:
I recently had to do something similar. The way I went about it (and
I'm not sure this is the best way) is to select all of the categories,
then iterate through them and build a tree, using each category's
parent_id to figure out where in the tree it fits.
Then, once you've got a tree, you have
Are you getting a particular error code, like 501 (not implemented)?
I would check Apache's error logs, as the issue might be happening
before Django ever gets the request. If nothing useful shows up in
those logs, try increasing the logging level.
Oh, just a note--you may want to strip secret
I haven't tried this (I'll try it when I get home), but looking at the
session code shows that you should be able to call:
request.session.delete()
to delete the whole session at once.
On Jul 3, 3:52 am, Daniel Hepper <[EMAIL PROTECTED]> wrote:
> Try:
>
> for key in request.session.keys():
>
Why do you need to put the value back into a form? I'm assuming that
this is on the second page of a multi-part form, or something along
those lines. A safer way to do it might be to store the value in the
session, and not rely on the data coming back from the form to be
correct. (The user can
w passed a parameter called show_feed.
> > you need to use it accordingly
>
> > On Jun 24, 10:02 am, sebey <[EMAIL PROTECTED]> wrote:
>
> > > either way its still the same thanks though but it still is not
> > > working
>
> > > On Jun 24, 1:44 pm,
The regex you're using has a trailing /, so you need to have that in
your link as well:
/shows/1/
The other option is to make the trailing slash optional like so:
r'^shows/(?P\d{1})[/]?$'
On Jun 24, 7:09 am, sebey <[EMAIL PROTECTED]> wrote:
> it works but (thanks for the tips) it still is
Looks like you forgot a return statement in the if statement. Not
sure if that would cause what you're seeing, but it certainly couldn't
help.
-Jeff
On Jun 21, 6:46 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I forgot to post the problem. After clicking the 'Login' button,
>
n Sat, Jun 21, 2008 at 10:19 PM, Jeff FW <[EMAIL PROTECTED]> wrote:
>
> > On Jun 21, 12:46 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
> > wrote:
> >> AFAICT, that's the same idea suggested on #3615. The discussion on
> >> that ticket describe
On Jun 21, 12:46 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On Fri, Jun 20, 2008 at 9:14 PM, Jeff FW <[EMAIL PROTECTED]> wrote:
>
> > I haven't yet used Django's dumpdata and loaddata, but I've used
> > mysqldump about a million times. (That's
I haven't yet used Django's dumpdata and loaddata, but I've used
mysqldump about a million times. (That's mostly what we use at my
job, though I've been slowly pushing us towards postgres.) Try
adding:
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS,
FOREIGN_KEY_CHECKS=0 */;
at the
92 matches
Mail list logo