Re: How to save a model...

2009-07-30 Thread zayatzz

I did some thinking over night, but still cant figure this one out on
my own :) If i want to save foreign key like this, then what should i
send to another model, if another object will not work?

Alan.
--~--~-~--~~~---~--~~
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: quick question: how to have *.domainname.com url in django

2009-07-30 Thread weiwei

thanks, i was thinking to have each user have a url as 
http://username.domain.com/

like http://hiphopo.posterous.com/





On Jul 30, 10:20 pm, Graham Dumpleton 
wrote:
> On Jul 31, 3:09 pm, weiwei  wrote:
>
> > Hello all,
>
> > I know there are lots of example for how to sethttp://domainname.com/*
> > url. But how to have http://*.domainname.com   url in django?
>
> Really depends on what you are trying to achieve and how you are
> hosting Django.
>
> Apache provides a way of having wild card alias for hostnames and so
> possible to direct requests for multiple domains to same Django
> instance.
>
> Is that all you are concerned about, or is what you really want to
> know is how then to access the host name from Django handlers so as to
> act on it, or how to have different host names automatically delegated
> to different handlers inside same Django instance.
>
> Graham
--~--~-~--~~~---~--~~
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: quick question: how to have *.domainname.com url in django

2009-07-30 Thread Graham Dumpleton



On Jul 31, 3:09 pm, weiwei  wrote:
> Hello all,
>
> I know there are lots of example for how to sethttp://domainname.com/*
> url. But how to have http://*.domainname.com   url in django?

Really depends on what you are trying to achieve and how you are
hosting Django.

Apache provides a way of having wild card alias for hostnames and so
possible to direct requests for multiple domains to same Django
instance.

Is that all you are concerned about, or is what you really want to
know is how then to access the host name from Django handlers so as to
act on it, or how to have different host names automatically delegated
to different handlers inside same Django instance.

Graham
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



quick question: how to have *.domainname.com url in django

2009-07-30 Thread weiwei

Hello all,

I know there are lots of example for how to set http://domainname.com/*
url. But how to have http://*.domainname.com   url in django?


Thanks


--~--~-~--~~~---~--~~
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: "join" query in Django?

2009-07-30 Thread Malcolm Tredinnick

On Thu, 2009-07-30 at 21:23 -0700, Asinox wrote:
> Hi, guys, how or where is the "join" query in Django?
> 
> i think that Django dont have "join"..but how ill make  join?

SQL-level joins happen automatically when required. You specify your
queryset in terms of filter() and exclude() calls and Django works out
which tables are needed to compute that result. Links between models are
specified using the double-underscore notation. Thus, "foo__bar" means
to use the "foo" field on the current model (a link to a related model)
and follow that to the "bar" field on the other end of the relation.

Regards,
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
-~--~~~~--~~--~--~---



"join" query in Django?

2009-07-30 Thread Asinox

Hi, guys, how or where is the "join" query in Django?

i think that Django dont have "join"..but how ill make  join?

Thanks
--~--~-~--~~~---~--~~
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: Template links when Django not domain root

2009-07-30 Thread Graham Dumpleton

If you are using mod_wsgi then you definitely do not need
FORCE_SCRIPT_NAME as mod_wsgi does the correct think in respect of
setting up SCRIPT_NAME/PATH_INFO. The only time it might not be right
with mod_wsgi is if you used WSGIScriptAliasMatch to map the
application and you didn't set up the directive properly. This can
happen because how you set up pattern and target for that directive
will control how SCRIPT_NAME is calculated. WSGIScriptAliasMatch
should only be used if absolutely required.

So, post how you configured mod_wsgi to mount your application just to
eliminate that as possibility. Verify that FORCE_SCRIPT_NAME isn't set
in settings.py or if it is that it is set to None.

Someone with more Django knowledge would then need to tell you if you
are specifying urls.py correctly, whether any other settings you need
to check and whether how URL references are generated are correct. All
I can tell you is that if mod_wsgi is set up properly, you should
never need FORCE_SCRIPT_NAME with mod_wsgi.

You may need to explain better what is meant by 'This is causing all
my template links to break'. Ie., what errors are you getting, what
are the URLs it is generating and what they should be etc.

Graham

On Jul 31, 12:09 pm, Streamweaver  wrote:
> I'm not actually using {% url %} at this time.  I am setup for
> mod_wsgi and don't know how to go about configuring links in the
> templates when the sites root is on a subdirectory.  There isn't much
> in the way of examples on FORCE_SCRIPT_NAME I can find and I'm not
> really an apache admin so I'm a bit out of my depth here.
>
> Is this the avenue I should be pursuing or is there some way to set
> this up better.  the url filter seems to violate DRY methodology.
>
> Thanks again.
>
> On Jul 30, 9:52 pm, Graham Dumpleton 
> wrote:
>
>
>
> > Using FORCE_SCRIPT_NAME is only appropriate for certain WSGI hosting
> > mechanisms. Using it may simply hide the fact that the OPs application
> > code is wrong to begin with.
>
> > OP should indicate how they are hosting their application for real
> > site. Ie., mod_python, mod_wsgi, fastcgi or other.
>
> > Graham
>
> > On Jul 31, 6:04 am, Alex Koshelev  wrote:
>
> > > If you are using `{% url %}` template tag or `reverse` function you can 
> > > set
> > > FORCE_SCRIPT_NAME [1] settings variable specified for your deployment
> > > project root. Or working with right web-server in front of django project
> > > force it to tell proper SCRIPT_NAME himself.
>
> > > [1]:http://docs.djangoproject.com/en/dev/ref/settings/#force-script-name
>
> > > ---
> > > Alex Koshelev
>
> > > On Thu, Jul 30, 2009 at 10:55 PM, Streamweaver 
> > > wrote:
>
> > > > I have a django project that has worked just fine in development but
> > > > I'm trying to move it to a demo site and the application is not on a
> > > > root domain or sub-domain.
>
> > > > Instead the site root URL is suppose to be something like
> > > >https://site.domain.com/appname/
>
> > > > This is causing all my template links to break.  The {% url %} tag
> > > > seems to work only for the site root and doesn't bring in the
> > > > subdirectory name.
>
> > > > What's the Django way of handling this?  I'm surprised I haven't been
> > > > able to find something about this.
--~--~-~--~~~---~--~~
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: Weird character shifting in mod_python

2009-07-30 Thread Graham Dumpleton



On Jul 31, 9:27 am, Andrew  wrote:
> We get these incredibly bizarre errors every once and a while where a
> single character of python gets transformed. The code itself isn't
> changing, and the area where it pops up changes each time. Any ideas?
>
> MOD_PYTHON ERROR
>
> ProcessId:      28165
> Interpreter:    ''
>
> ServerName:     '*'
> DocumentRoot:   '/var/www/'
>
> URI:            '/'
> Location:       '/'
> Directory:      None
> Filename:       '/var/www/'
> PathInfo:       ''
>
> Phase:          'PythonHandler'
> Handler:        'django.core.handlers.modpython'
>
> Traceback (most recent call last):
>
>   File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
> 1537, in HandlerDispatch
>     default=default_handler, arg=req, silent=hlist.silent)
>
>   File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
> 1229, in _process_target
>     result = _execute_target(config, req, object, arg)
>
>   File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
> 1128, in _execute_target
>     result = object(arg)
>
>   File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
> modpython.py", line 222, in handler
>     return ModPythonHandler()(req)
>
>   File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
> modpython.py", line 185, in __call__
>     self.load_middleware()
>
>   File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
> base.py", line 38, in load_middleware
>     mod = __import__(mw_module, {}, {}, [''])
>
>   File "/usr/local/lib/python2.5/site-packages/panda/main/
> middleware.py", line 9, in 
>     from panda.main.alert import get_alert_numnew
>
>   File "/usr/local/lib/python2.5/site-packages/panda/main/alert.py",
> line 5, in 
>     from django.contrib.auth.models import User
>
>   File "/usr/local/lib/python2.5/site-packages/django/contrib/auth/
> models.py", line 5, in 
>     from django.contrib.contenttypes.models import ContentType
>
>   File "/usr/local/lib/python2.5/site-packages/django/contrib/
> contenttypes/models.py", line 64, in 
>     class ContentType(models.Model):
>
>   File "/usr/local/lib/python2.5/site-packages/django/db/models/
> base.py", line 80, in __new__
>     new_class.add_to_class(obj_name, obj)
>
> NameError: global name 'obj_na}e' is not defined

Are you using worker MPM for Apache?

Are you using any third party extension modules which perhaps is not
multithread safe?

If using worker MPM would suggest you change to prefork MPM.
Alternatively, switch to mod_wsgi and configure daemon mode with a
daemon process group where each process is single threaded.

In other words, possibly a multithreading issue, or you just could be
getting hit by some of the still existing bugs in mod_python.

Graham
--~--~-~--~~~---~--~~
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: Template links when Django not domain root

2009-07-30 Thread Streamweaver

I'm not actually using {% url %} at this time.  I am setup for
mod_wsgi and don't know how to go about configuring links in the
templates when the sites root is on a subdirectory.  There isn't much
in the way of examples on FORCE_SCRIPT_NAME I can find and I'm not
really an apache admin so I'm a bit out of my depth here.

Is this the avenue I should be pursuing or is there some way to set
this up better.  the url filter seems to violate DRY methodology.

Thanks again.

On Jul 30, 9:52 pm, Graham Dumpleton 
wrote:
> Using FORCE_SCRIPT_NAME is only appropriate for certain WSGI hosting
> mechanisms. Using it may simply hide the fact that the OPs application
> code is wrong to begin with.
>
> OP should indicate how they are hosting their application for real
> site. Ie., mod_python, mod_wsgi, fastcgi or other.
>
> Graham
>
> On Jul 31, 6:04 am, Alex Koshelev  wrote:
>
> > If you are using `{% url %}` template tag or `reverse` function you can set
> > FORCE_SCRIPT_NAME [1] settings variable specified for your deployment
> > project root. Or working with right web-server in front of django project
> > force it to tell proper SCRIPT_NAME himself.
>
> > [1]:http://docs.djangoproject.com/en/dev/ref/settings/#force-script-name
>
> > ---
> > Alex Koshelev
>
> > On Thu, Jul 30, 2009 at 10:55 PM, Streamweaver 
> > wrote:
>
> > > I have a django project that has worked just fine in development but
> > > I'm trying to move it to a demo site and the application is not on a
> > > root domain or sub-domain.
>
> > > Instead the site root URL is suppose to be something like
> > >https://site.domain.com/appname/
>
> > > This is causing all my template links to break.  The {% url %} tag
> > > seems to work only for the site root and doesn't bring in the
> > > subdirectory name.
>
> > > What's the Django way of handling this?  I'm surprised I haven't been
> > > able to find something about this.
--~--~-~--~~~---~--~~
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: Removing objects with many-to-many relationship

2009-07-30 Thread Brian May

On Thu, Jul 30, 2009 at 04:47:05AM -0700, rudy wrote:
> class ContentTopic(models.Model):
> name = models.CharField()
> code = models.CharField()
> 
> class ContentItem(models.Model):
> topic = models.ManyToManyField(ContentTopic, db_index=True,
> blank=True, related_name='content_item')
> 
> So, I'd like to remove ContentTopic instance using Django admin, but I
> don't need remove all related ContentItems. So, confirmation page
> should display only ContentTopic instance to remove.

My understanding (correct me if I am wrong) is it shouldn't be a problem with
many-to-many relationships.

When deleting a ContentTopic, Django will delete the entry from the mapping
table, and not touch ContentItem table. This is usually what you want - when
you delete the object you can't have the relationship anymore.

One-to-many relationships are a different story. You do have to be
careful here.
-- 
Brian May 

--~--~-~--~~~---~--~~
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: Template links when Django not domain root

2009-07-30 Thread Graham Dumpleton

Using FORCE_SCRIPT_NAME is only appropriate for certain WSGI hosting
mechanisms. Using it may simply hide the fact that the OPs application
code is wrong to begin with.

OP should indicate how they are hosting their application for real
site. Ie., mod_python, mod_wsgi, fastcgi or other.

Graham

On Jul 31, 6:04 am, Alex Koshelev  wrote:
> If you are using `{% url %}` template tag or `reverse` function you can set
> FORCE_SCRIPT_NAME [1] settings variable specified for your deployment
> project root. Or working with right web-server in front of django project
> force it to tell proper SCRIPT_NAME himself.
>
> [1]:http://docs.djangoproject.com/en/dev/ref/settings/#force-script-name
>
> ---
> Alex Koshelev
>
> On Thu, Jul 30, 2009 at 10:55 PM, Streamweaver wrote:
>
>
>
>
>
> > I have a django project that has worked just fine in development but
> > I'm trying to move it to a demo site and the application is not on a
> > root domain or sub-domain.
>
> > Instead the site root URL is suppose to be something like
> >https://site.domain.com/appname/
>
> > This is causing all my template links to break.  The {% url %} tag
> > seems to work only for the site root and doesn't bring in the
> > subdirectory name.
>
> > What's the Django way of handling this?  I'm surprised I haven't been
> > able to find something about this.
--~--~-~--~~~---~--~~
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 1.1 returns 500 instead of 404 in non-debug mode

2009-07-30 Thread Luke Seelenbinder

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


Prabhu,

Let's establish the reason the 404.html doesn't show on a supposed 404
error; that is because every single request on the output you posted a
little while ago from the server is responded with a 500 error.
Something is fouled up with the views, or somewhere in the server process.

I'll look through and see if I can spot anything.

Good luck!

Luke
luke.seelenbin...@gmail.com

"I [may] disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire


prabhu S wrote:
> Hi Luke,
> 
> Thanks for your email. The particular source is already fine with
> no /. I also tried adding slash assuming you swapped the particular
> line in your email.
> 
> Can you give another shot and let me know if you can spot something?
> 
> Regards,
> Prabhu
> 
> On Jul 30, 6:46 pm, Luke Seelenbinder 
> wrote:
> Hey, I think I located your problem.
> 
> In file invoicy / guidy / urls.py
> 
> You should change the first url pattern to read:
> url(r'^/$', 'guidy_default', name='guidy-default'),
> instead of:
> url(r'^$', 'guidy_default', name='guidy-default'),
> 
> That should fix your problem. What is actually happening is you are
> raising 500s on 404s. That's why the 404 error page is not showing.
> 
> Luke
> luke.seelenbin...@gmail.com
> 
> "I [may] disapprove of what you say, but I will defend to the death your
> right to say it." -- Voltaire
> 
> 
> 
> 
> 
> prabhu S wrote:
 Hi Karen,
 Thanks for replying. I have put my 404.html in the same place as that
 of500.html. To make sure, I even copy pasted500.html and changed the
 error message text alone.
 Here is an output from the django development server, when I tried to
 access "sdfsa" (Invalid url)
 [30/Jul/2009 18:25:45] "GET /admin/clienty/sdfsa HTTP/1.1"5001387
 [30/Jul/2009 18:25:45] "GET /scripts/jquery-1.3.2.min.js HTTP/1.1"500
 1387
 [30/Jul/2009 18:25:46] "GET /css/style.css HTTP/1.1"5001387
 I have the sources online athttp://github.com/prabhu/invoicy. I would
 appreciate if you can take a look at settings.py and let me know if
 something is obvious.
 Thanks & Regards,
 Prabhu
 On Jul 30, 2:25 pm, Karen Tracey  wrote:
> On Thu, Jul 30, 2009 at 8:40 AM, prabhu S  wrote:
>> Hi All,
>> I am not noticing a weird issue in django 1.1. When DEBUG is true in
>> settings and if I try a non-existent url, django shows me a friendly
>> 404 page. Now I create 404.html and500.html and place this in
>> templates directory. Then If I turn off debug and try a non-existent
>> url, I expect to see my 404 html. Instead django shows me500.html.
>> Infact, even in development I see500error codes for missing css,
>> images and js.
>> Is anyone else noticing the same issue? Am I missing something?
> I cannot recreate this.  Are you absolutely sure everything is set so that
> your 404.html is being found by the server?
> Karen
> 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkpyTG0ACgkQXQrGVCncjPz94gCcCkyRaKjRdf11QcCU1x8qnRXp
lPsAoIjA42jV5QHx/Vrs5pUje+JAnL88
=jGM0
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
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: Is it possible to combine these two queries?

2009-07-30 Thread Tim Chase

> al_1 = Alert.objects.filter(creation_date__regex=today).values
> ('dimension1').annotate(Sum('metric1')).order_by('dimension1')
> 
> and
> 
> al_2 = Alert.objects.filter(creation_date__regex=yesterday).values
> ('dimension1').annotate(Sum('metric1')).order_by('dimension1')
> 
> They are almost the same except that al_1 is for today's data and al_2
> is for yesterday's data. They summarize data in column "metric1" that
> is grouped and ordered by "dimension1".
> 
> Sample data from al_1:
> 
> [{'metric1__sum': 0.0, 'dimension1': u'1'}, {'metric1__sum': 14.0,
[snip]
> What I need to do is to find a ratio value for each "dimension1"
> between its today's value and yesterday's value.  For example, for
> dimension1 = '110085', I need to find 2758.0 / 2658.0 = 1.04.
> Then I compare this value "1.04" with a threshold and process
> further.

You can do something like

 >>> map1 = dict((d['dimension1'], d['metric1__sum']) for d in al_1)
 >>> map2 = dict((d['dimension1'], d['metric1__sum']) for d in al_2)
 >>> ratios = [(dim, metric/map2[dim]) for dim, metric in 
map1.iteritems() if map2.get(dim, 0) != 0]
 >>> results = [(dim, ratio) for dim, ratio in ratios if ratio >= 
threshold]

It may lose ordering if that is significant (dicts aren't ordered 
by default), and skips over those where there are problems (items 
don't exist in the opposite map, or the previous value was 0 
making for a divide-by-zero problem).

Things might change a little depending on what you'd expect on 
those edge cases (dim in a1 but not in a2; dim in a2 but not in 
a1; a2.metric = 0)

-tim





--~--~-~--~~~---~--~~
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: Simple query on a ManyToMany field?

2009-07-30 Thread Adam Olsen

On Thu, Jul 30, 2009 at 6:21 PM, Malcolm
Tredinnick wrote:
> I've written a couple of solutions for this over the years. Here's a
> summary of some of them:
>
> http://www.pointy-stick.com/blog/2009/03/10/using-djangos-aggregation-features/
>

That did it, thanks!

-- 
Adam Olsen
http://www.vimtips.org
http://last.fm/user/synic

--~--~-~--~~~---~--~~
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: Custom Manage.py Commands

2009-07-30 Thread mviamari

On Jul 30, 5:24 pm, Malcolm Tredinnick 
wrote:
> On Thu, 2009-07-30 at 17:18 -0700, mviamari wrote:
> > I'm trying to create a custom manage.py command for my project.  The
> > example in the documentation only shows how to do this for custom
> > commands inside of an app.  Is it possible to do the same at the
> > project level?
>
> The concept doesn't particularly make sense, since Django is app-based.
> "Projects" are a bit of a convenient way of grouping things, but they're
> just a settings file, a root URL conf and some apps. Which is a way of
> saying that isn't supported.
>
> It's fairly logical, however, to create an app that only provides your
> support for things like that this. Lots of people have apps that just
> contain template tags or just contain templates or even management
> commands. They don't need to contain models or anything like that.
>
> Regards,
> Malcolm

The problem I had was that the commands weren't specific to a given
app, and I didn't want to have to replicate them in each one.  A
special app just for additional commands makes much more sense.
Thanks.

Mike
--~--~-~--~~~---~--~~
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: Custom Manage.py Commands

2009-07-30 Thread Malcolm Tredinnick

On Thu, 2009-07-30 at 17:18 -0700, mviamari wrote:
> I'm trying to create a custom manage.py command for my project.  The
> example in the documentation only shows how to do this for custom
> commands inside of an app.  Is it possible to do the same at the
> project level?

The concept doesn't particularly make sense, since Django is app-based.
"Projects" are a bit of a convenient way of grouping things, but they're
just a settings file, a root URL conf and some apps. Which is a way of
saying that isn't supported.

It's fairly logical, however, to create an app that only provides your
support for things like that this. Lots of people have apps that just
contain template tags or just contain templates or even management
commands. They don't need to contain models or anything like that.

Regards,
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
-~--~~~~--~~--~--~---



Re: Simple query on a ManyToMany field?

2009-07-30 Thread Malcolm Tredinnick

On Thu, 2009-07-30 at 18:14 -0600, Adam Olsen wrote:
> Suppose I have the following models:
> 
> class Tag(models.Model):
>   card = models.ForeignKey('Card')
>   name = models.CharField(max_length=10)
> 
> class Card(models.Model):
>   # whatever
> 
> Say I have a list, like the following:  words = ['christmas', 'mother']
> 
> This list can be of variable length.  How can I write a query that
> will return a list of Card objects that match ALL (not any) of the
> words?  Is there a way to do it in a line or two without traversing
> all of the card objects?

I've written a couple of solutions for this over the years. Here's a
summary of some of them:

http://www.pointy-stick.com/blog/2009/03/10/using-djangos-aggregation-features/

Regards,
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
-~--~~~~--~~--~--~---



Custom Manage.py Commands

2009-07-30 Thread mviamari

I'm trying to create a custom manage.py command for my project.  The
example in the documentation only shows how to do this for custom
commands inside of an app.  Is it possible to do the same at the
project level?

I'm currently specifying a Command class in a module file within a
management/commands package as suggested in the documentation, but it
doesn't seem to be finding the command.

Any help would be appreciated.

Mike
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Simple query on a ManyToMany field?

2009-07-30 Thread Adam Olsen

Suppose I have the following models:

class Tag(models.Model):
  card = models.ForeignKey('Card')
  name = models.CharField(max_length=10)

class Card(models.Model):
  # whatever

Say I have a list, like the following:  words = ['christmas', 'mother']

This list can be of variable length.  How can I write a query that
will return a list of Card objects that match ALL (not any) of the
words?  Is there a way to do it in a line or two without traversing
all of the card objects?

-- 
Adam Olsen
http://www.vimtips.org
http://last.fm/user/synic

--~--~-~--~~~---~--~~
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: clean_() doesn't handle images?

2009-07-30 Thread Karen Tracey
On Thu, Jul 30, 2009 at 4:02 PM, Martje  wrote:

>
> Hey,
>
> I've got the following code in my models.py:
>
> from django import forms
> class Foto(models.Model):
>omschrijving = models.CharField(max_length=100)
>afbeelding = models.ImageField(upload_to='media/afbeeldingen/
> header/fotos')
>
>def clean_afbeelding(self):
>raise forms.ValidationError("Never good! :-)")
>
> Still, if I upload an image it validates, where it shouldn't, right?
>

Custom clean methods need to be added to the form you are using, not the
model.

Karen

--~--~-~--~~~---~--~~
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: custom admin actions

2009-07-30 Thread Vasil Vangelovski

You can get the model class for the modeladmin, it's the model property. So
modeladmin.model will give you the model class. You can just do a
check of equality
modeladmin.model == OurModel.

On Thu, Jul 30, 2009 at 1:22 PM, selcukcihan wrote:
>
> Hi, i have django 1.1
>
> I have a user profile model, call it OurUser. I have defined a custom
> action, "send mail". This action is available in OurUser and django
> auth's User models. It is handled via a global function with this
> signature
>
> def send_mail_to_users(modeladmin, request, queryset):
>    selected = request.POST.getlist(admin.ACTION_CHECKBOX_NAME)
>    return HttpResponseRedirect(reverse('some view') + '?ids=%s' %
> ",".join(selected))
>
> This works well only for auth's User model(since it gets the correct
> ids). What i need is an if else of the form
> if modeladmin belongs to "User" then do something
> else if modeladmin belongs to "OurUser" then do something
>
> so that i can extract the User ids from OurUser and then redirect
> properly
> >
>

--~--~-~--~~~---~--~~
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: Oracle 11g + mod_wsgi + Apache + Django on Windows 2003 does not work

2009-07-30 Thread tcpipmen

thanks for your reply.  i removed oracle 11g and installed 10g
express. uninstalled python 2.6 and everything related.  and now it is
working. so i'm not sure it has to do with 11g???  i just need to test
with 11g again in current setup.

regards,

On Jul 30, 5:23 pm, Xiong Chiamiov  wrote:
> On Jul 29, 11:57 am, tcpipmen  wrote:
>
> > Hi All, I have no problem running Oracle 11g with django on build-in
> > development server and everything is fine.  But When I setup with
> > mod_wsgi with Apache I'm getting messages like below
> [snip]
> > The specified module could not be found.
>
> I'm not quite sure how this works on Windows, but Apache is probably
> running as a different user (rather than as you).  This means that it
> has its own set of environment variables, including PATH and
> PYTHONPATH, which are likely to not include the directory your module
> is in.  I'm afraid I can't tell you how you would go about checking or
> fixing that, however, but perhaps it'll get you off to the right start.
--~--~-~--~~~---~--~~
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 1.1 returns 500 instead of 404 in non-debug mode

2009-07-30 Thread prabhu S

Hi Luke,

Thanks for your email. The particular source is already fine with
no /. I also tried adding slash assuming you swapped the particular
line in your email.

Can you give another shot and let me know if you can spot something?

Regards,
Prabhu

On Jul 30, 6:46 pm, Luke Seelenbinder 
wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Hey, I think I located your problem.
>
> In file invoicy / guidy / urls.py
>
> You should change the first url pattern to read:
> url(r'^/$', 'guidy_default', name='guidy-default'),
> instead of:
> url(r'^$', 'guidy_default', name='guidy-default'),
>
> That should fix your problem. What is actually happening is you are
> raising 500s on 404s. That's why the 404 error page is not showing.
>
> Luke
> luke.seelenbin...@gmail.com
>
> "I [may] disapprove of what you say, but I will defend to the death your
> right to say it." -- Voltaire
>
>
>
>
>
> prabhu S wrote:
> > Hi Karen,
>
> > Thanks for replying. I have put my 404.html in the same place as that
> > of500.html. To make sure, I even copy pasted500.html and changed the
> > error message text alone.
>
> > Here is an output from the django development server, when I tried to
> > access "sdfsa" (Invalid url)
>
> > [30/Jul/2009 18:25:45] "GET /admin/clienty/sdfsa HTTP/1.1"5001387
> > [30/Jul/2009 18:25:45] "GET /scripts/jquery-1.3.2.min.js HTTP/1.1"500
> > 1387
> > [30/Jul/2009 18:25:46] "GET /css/style.css HTTP/1.1"5001387
>
> > I have the sources online athttp://github.com/prabhu/invoicy. I would
> > appreciate if you can take a look at settings.py and let me know if
> > something is obvious.
>
> > Thanks & Regards,
> > Prabhu
>
> > On Jul 30, 2:25 pm, Karen Tracey  wrote:
> >> On Thu, Jul 30, 2009 at 8:40 AM, prabhu S  wrote:
>
> >>> Hi All,
> >>> I am not noticing a weird issue in django 1.1. When DEBUG is true in
> >>> settings and if I try a non-existent url, django shows me a friendly
> >>> 404 page. Now I create 404.html and500.html and place this in
> >>> templates directory. Then If I turn off debug and try a non-existent
> >>> url, I expect to see my 404 html. Instead django shows me500.html.
> >>> Infact, even in development I see500error codes for missing css,
> >>> images and js.
> >>> Is anyone else noticing the same issue? Am I missing something?
> >> I cannot recreate this.  Are you absolutely sure everything is set so that
> >> your 404.html is being found by the server?
>
> >> Karen
>
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.9 (GNU/Linux)
>
> iEYEARECAAYFAkpx3HAACgkQXQrGVCncjPyTCACfR6jyWAfXScSgM9STXKN5nksa
> zRYAoJv2zvJnLpI47kuuArFS+tO5X6MW
> =7wa6
> -END PGP SIGNATURE-
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Create a web application

2009-07-30 Thread susanne

Hello Mr.pallavi, Mr.George and other members,
I have similar application like palavi. I followed this hints but not
success.
Please let me know how did you proceed.

my python application has functions to perform different
calculations.

1) The program reads input file called IN.txt.
the IN.txt file contains names of three other files( x.dat, y.txt,
z.dat) that are
in the same directory.

2) then the application reads the data in the files x.dat, y.txt,
z.dat and performs some calculations.

3) outputs the results in a file called out.txt

The application is running perfectly from command mode. I need to make
it a web application so that it can be run in a browser from anywhere.
I tried with cherrypy and django tutorials, but could not succeed, as
i am completely new to this field. can some one help with steps to
proceed.

Thanks in advance!
Susanne

> My main python program is science.py
> it have several modules.in it (each definition reads some parameters
> and results some data, that will be read
> by next module). but at the end, only few of the results are printed
> to a data file.


> science.py
> ---
> def function1(parameter1,parmeter2) :
>   {
>-
>-
>   }
>   return data1


> def function2(data1,parmeter3) :
>   {
>-
>-
>   }
>   return data2


> #output is printed to a file as data.dat that contains data1, data2


> view.py
> 
> from django.http import HttpResponse
> from science import function1
> from science import function2


> def science_service(request):
>  return HttpResponse(
>  # function1 reads parameter1, and parameter2
>  function1 (parameter1, parameter2), , mimetype="text/plain"
>  )


> def science_service(request):
>  return HttpResponse(
>  function2 (data1, parameter3), , mimetype="text/plain"
>  )


> is this the correct way to write my view based on George's
> suggestion:
> i keep my science.py in the current working directory.
> pls shed some lightyour suggestions are very valuable for novice
> like me.



You're on the right track.

1. You can't name both views the same, if they're in the same module.
Otherwise the second definition will override the first one.
2. There's a slight mistake in your response:
{{{
def science_service(request):
 return HttpResponse(
 function1(p1, p2), mimetype="text/plain"
 )



}}}


Of course you'll have to instantiate p1 and p2 somewhere in the
module,
if you're not passing those in through the request somehow.

--
George



--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



ANN: django-forms-builder

2009-07-30 Thread opensou...@citrus.com.au

Hello django-users,

My company has allowed me to open source a small django application
I've built that I've named django-forms-builder.

What it does is allow admin users to create their own front-end
website forms for capturing data.

I've chosen google code to host the project and welcome any feedback.

http://code.google.com/p/django-forms-builder/

Regards,

Stephen McDonald
TECHNICAL RESEARCH & DEVELOPMENT
Citrus
Level 5, 100 Albert Road South Melbourne Victoria Australia 3205
T. +613 9681 5333F. +613 9682 5586   W. www.citrus.com.au

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Weird character shifting in mod_python

2009-07-30 Thread Andrew

We get these incredibly bizarre errors every once and a while where a
single character of python gets transformed. The code itself isn't
changing, and the area where it pops up changes each time. Any ideas?

MOD_PYTHON ERROR

ProcessId:  28165
Interpreter:''

ServerName: '*'
DocumentRoot:   '/var/www/'

URI:'/'
Location:   '/'
Directory:  None
Filename:   '/var/www/'
PathInfo:   ''

Phase:  'PythonHandler'
Handler:'django.core.handlers.modpython'

Traceback (most recent call last):

  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)

  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1229, in _process_target
result = _execute_target(config, req, object, arg)

  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1128, in _execute_target
result = object(arg)

  File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
modpython.py", line 222, in handler
return ModPythonHandler()(req)

  File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
modpython.py", line 185, in __call__
self.load_middleware()

  File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
base.py", line 38, in load_middleware
mod = __import__(mw_module, {}, {}, [''])

  File "/usr/local/lib/python2.5/site-packages/panda/main/
middleware.py", line 9, in 
from panda.main.alert import get_alert_numnew

  File "/usr/local/lib/python2.5/site-packages/panda/main/alert.py",
line 5, in 
from django.contrib.auth.models import User

  File "/usr/local/lib/python2.5/site-packages/django/contrib/auth/
models.py", line 5, in 
from django.contrib.contenttypes.models import ContentType

  File "/usr/local/lib/python2.5/site-packages/django/contrib/
contenttypes/models.py", line 64, in 
class ContentType(models.Model):

  File "/usr/local/lib/python2.5/site-packages/django/db/models/
base.py", line 80, in __new__
new_class.add_to_class(obj_name, obj)

NameError: global name 'obj_na}e' is not defined
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



multiple admin forms for one model

2009-07-30 Thread sico

Is it possible to have more than one admin interface for a form in the
same AdminSite ?

I'd like to have an admin form for just editing the model, and another
one for editing the model and some sub-records.  Is this possible
within the same AdminSite ??

You're not allowed to do more than one:

admin.site.register(MyModel, )

So it doesn't look like it will and that I will need to have a
different Admin Site, but this becomes cumbersome as I'd quite like to
have several different interfaces here.

I suppose I can do a view for each one here, but then I have to
duplicate a lot of functionality that is already in the admin site...
e.g. displaying the label, widget, and errors, handling adding, saving
etc, and writing to the admin log.

thanks,
Simon
--~--~-~--~~~---~--~~
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:

2009-07-30 Thread Vasil Vangelovski

Hi

I've hacked up something quick which will work in most simple cases,
but I don't suggest you use the same code as it is. It's just to show
you an example of how this can be done. This is the html markup:

http://dpaste.com/hold/73500/

And this is the js with jquery:

http://dpaste.com/hold/73501/

On Thu, Jul 30, 2009 at 8:41 PM, Margie wrote:
>
> Hi Vasil,
>
> Could you clarify how I access the variable from the javascript?  For
> example, using my DateWidget as an example, say in my wdigets.py I
> have this (note I've added ?myVar='xyz' in second line:
>
> class DateWidget(widgets.DateInput):
>    class Media:
>        js = ("js/jquery.datePicker.min-2.1.2.js",
>               "js_custom/date_widget.js?myVar='xyz''")
>
> The complete contents of date_widget.js is currently:
>
>  $(document).ready(function() {
>                      Date.firstDayOfWeek = 0;
>                      Date.format = 'mm/dd/';
>                      $('.chipvision_date_widget').datePicker();
>                    });
>
> How do I access myVar from inside date_widget.js?
>
> I know the .js files listed in the Media class get output into my html
> via my inclusion of  {{ media }} in my template.  So I see that I get
> this in my html
>
> 
> 
>
> But I seem to have some missing piece - I don't get how to get access
> to xyz from the .js script itself.  Sorry if this is a dumb question -
> I've written various bits of javascript/jquery but haven't encountered
> this.
>
> Margie
>
>
>
> On Jul 29, 5:51 pm, Vasil Vangelovski  wrote:
>> Of course that the files specified in the class Media are accessed via
>> GET. How else would they be accessed? It's possible to fetch a js file
>> with additional get arguments and access those values from the js. So
>> you can pass prePopulateString as a get parameter to the js file in
>> class Media for example:
>>
>> class Media:
>>    js = ('myAutoCompleteInit.js?prepopString=%s'%prePopulateString)
>>
>> Then pass that parameter to the js method you need inside 
>> myAutoCompleteInit.js.
>>
>> On Thu, Jul 30, 2009 at 1:53 AM, Margie wrote:
>>
>> >> There's no easy way of passing dynamic javascript in the Media class.
>> >> However, you can fake it, with a bit of work, by passing the parameter
>> >> to the script in a querystring. So, for example, in the list of js
>> >> files to be included you would have
>> >>     'js/myfile.js?renderclass=%s' % self.prePopulateString
>>
>> >> Then your js can find its own 

user in template tag without passing it

2009-07-30 Thread Jake

Hey all,

I have a custom template tag like this currently {% extras
user.is_authenticated %}

basically it returns the results of a different template based on
whether the arg is true (user.is_authenticated)
I want to make it simpler, just {% extras %} and have the code inside
be able to access user to do the check itself.

Any ideas how i can find the user in the template tag? it's not in
'context' that gets passed to the Node, I'm guessing i need to get it
in there somehow. context processors don't seem to affect the contexts
passed to these Nodes

Thanks in advance,
Jake
--~--~-~--~~~---~--~~
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: view/form with fields from multiple models

2009-07-30 Thread sico

Hey,

I've been a little distracted but I'm back on to this now...

Thanks for the information, I'm going to try it out now (assuming no
more interruptions!) and I'll  get back to you on how I get on...



On Jul 24, 8:55 pm, Matthias Kestenholz
 wrote:
> On Fri, Jul 24, 2009 at 10:46 AM, Benjamin  Wohlwend 
> wrote:
>
> > On Jul 24, 10:37 am, Benjamin  Wohlwend  wrote:
>
> >> if all(f.is_valid() for f in (form1, form2, form3)):
> >>     # ok, save
>
> > Oops, forgot to mention that I had to implement my own version of all
> > (), which doesn't short cut:
>
> > def really_all(iter):
> >    all_true = True
> >    for val in iter:
> >        if not val:
> >            all_true = False
> >    return all_true
>
> There is a function in Django proper which does exactly that:
> django.forms.formsets.all_valid
>
> Since is_valid works the same for forms and formsets you can use this
> for plain forms too.
>
> Matthias
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



overriding clean method on ModelForm class

2009-07-30 Thread sico

Hey,

I had a problem recently that caused me some confusion!

I have a model that has a OneToOne field as the primary key.  When
adding a new record in the admin form and entering a key that already
existed, I wasn't getting the expected "record already exists" error,
instead it was just overwriting the existing record!!

The problem was because I was implementing my own "clean" method on
the AdminForm.  e.g.

class MyModelAdminForm(forms.ModelForm):
def clean(self):

return self.cleaned_data

as per the doco:
http://docs.djangoproject.com/en/1.0/ref/forms/validation/#cleaning-and-validating-fields-that-depend-on-each-other

But this then ignores the standard form validation that should still
occur.  By adding a call to the super class clean method everything
became fine!

class MyModelAdminForm(forms.ModelForm):
def clean(self):
self.cleaned_data = super(MyModelAdminForm, self).clean()

return self.cleaned_data

Just be aware that any invalid data will be removed from cleaned_data

This is really a bug in the documentation I think... Can the doco be
updated??

Regards,
Simon
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Is it possible to combine these two queries?

2009-07-30 Thread David

Hi,

I have two queries as follows.


al_1 = Alert.objects.filter(creation_date__regex=today).values
('dimension1').annotate(Sum('metric1')).order_by('dimension1')

and

al_2 = Alert.objects.filter(creation_date__regex=yesterday).values
('dimension1').annotate(Sum('metric1')).order_by('dimension1')

They are almost the same except that al_1 is for today's data and al_2
is for yesterday's data. They summarize data in column "metric1" that
is grouped and ordered by "dimension1".

Sample data from al_1:

[{'metric1__sum': 0.0, 'dimension1': u'1'}, {'metric1__sum': 14.0,
'dimension1': u'110044'}, {'metric1__sum': 2658.0, 'dimension1':
u'110085'}, {'metric1__sum': 0.0, 'dimension1': u'110181'},
{'metric1__sum': 71.0, 'dimension1': u'110208'}, {'metric1__sum':
5850.0, 'dimension1': u'110219'}, {'metric1__sum': 97.0, 'dimension1':
u'110235'}, {'metric1__sum': 48253.0, 'dimension1': u'110251'}, ...]

and sample data from al_2:

[{'metric1__sum': 0.0, 'dimension1': u'1'}, {'metric1__sum': 16.0,
'dimension1': u'110044'}, {'metric1__sum': 2758.0, 'dimension1':
u'110085'}, {'metric1__sum': 67.0, 'dimension1': u'110208'},
{'metric1__sum': 5783.0, 'dimension1': u'110219'}, {'metric1__sum':
100.0, 'dimension1': u'110235'}, {'metric1__sum': 50688.0,
'dimension1': u'110251'},]


What I need to do is to find a ratio value for each "dimension1"
between its today's value and yesterday's value.  For example, for
dimension1 = '110085', I need to find 2758.0 / 2658.0 = 1.04.
Then I compare this value "1.04" with a threshold and process
further.

I know that I can use a for loop to traverse those results (al_1 and
al_2), get ratio values, compare them, etc. However, I wonder if there
is a way to do all this work with one query instead of using two
queries and one for loop?

Any ideas and suggestions?

Thanks so much.











--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



clean_() doesn't handle images?

2009-07-30 Thread Martje

Hey,

I've got the following code in my models.py:

from django import forms
class Foto(models.Model):
omschrijving = models.CharField(max_length=100)
afbeelding = models.ImageField(upload_to='media/afbeeldingen/
header/fotos')

def clean_afbeelding(self):
raise forms.ValidationError("Never good! :-)")

Still, if I upload an image it validates, where it shouldn't, right?

--~--~-~--~~~---~--~~
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 save data into more than one table?

2009-07-30 Thread derek

How about posting the code here for a review?

On Jul 30, 5:21 pm, Asinox  wrote:
> Thanks, i did it, i dont know if in the best way but im saving data in
> two tables :) thanks :)

--~--~-~--~~~---~--~~
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: about a web site

2009-07-30 Thread Lic . José M . Rodriguez Bacallao

second one, any advice?

On 7/17/09, Diego Eduardo Ahumada - SICO S.I. S.A.  wrote:
>
> 2009/7/17 Michael :
>> On Fri, Jul 17, 2009 at 1:30 PM, Lic. José M. Rodriguez Bacallao
>>  wrote:
>>>
>>> anyone?
>>>
>>>
>>> On 7/17/09, Lic. José M. Rodriguez Bacallao  wrote:
>>> > hi folks, it's be a long time without writing to the list but now I'm
>>> > back with a simple question, I need to know how much can cost to make
>>> > a site like this:
>>> >
>>> > --
>>> > Lic. José M. Rodriguez Bacallao
>>> > Centro de Biofisica Medica
>>> > -
>>> > Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo
>>> > mismo.
>>> >
>>
>
> Hi! Why you ask? What's your plan? That someone build a site for you,
> or build it for someone and want to know how much you can earn?
>
> Diego
>
> >
>


-- 
Lic. José M. Rodriguez Bacallao
Centro de Biofisica Medica
-
Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.

Recuerda: El arca de Noe fue construida por aficionados, el titanic
por profesionales
-

--~--~-~--~~~---~--~~
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: MEDIA_URL MEDIA_ROOT

2009-07-30 Thread cootetom

If you are using the django development server whilst developing then
you can use django.views.static.serve to download static or media
files. You should not use this method in production however as it is
not considered stable. Just place this in your url.py file:

from settings import DEBUG, STATIC_DOC_ROOT, MEDIA_ROOT

if DEBUG:
urlpatterns += patterns('',
(r'^.*/?static/(?P.*)$', 'django.views.static.serve',
{'document_root': STATIC_DOC_ROOT}),
(r'^site_media/(?P.*)$', 'django.views.static.serve',
{'document_root': MEDIA_ROOT})
)

Then you can access static files from /static/path/to/file and you can
access your uploaded media using /site_media/path/to/file

You can of course use settings variables for the URL's as well as the
roots but that's upto you. Not sure why files aren't being put into
the /user_files/ directory that you have specified, they should be!


On Jul 30, 11:38 am, Salvatore Leone 
wrote:
> Hi again,
>
> I have configured MEDIA_ROOT =
> '/home/testpec/public_html/pecwizard/uploads/' and the file uploads
> works fine, so in the 'uploads' directory there are all my uploaded files.
>
> Two questions:
>
> 1.
> in models.py I have the following:
>
> class Attach(models.Model):
>   attached_file = models.FileField(upload_to='user_files')
>   # other stuff
>
> why all of the files are stored in 'uploads' and not in
> 'uploads/user_files/'?
>
> 2.
> I can't download the files, probably I don't understand the MEDIA_URL
> parameter. Here it is:
> MEDIA_URL = 'http://localhost:8000/wiz/uploads/'
>
> but trying to access the files returns me a 404 error.
>
> I can workaround this configuring urls.py for serving static files. Is
> this the right way to do it??
>
> regards,
> Salvatore
--~--~-~--~~~---~--~~
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: Oracle 11g + mod_wsgi + Apache + Django on Windows 2003 does not work

2009-07-30 Thread Xiong Chiamiov

On Jul 29, 11:57 am, tcpipmen  wrote:
> Hi All, I have no problem running Oracle 11g with django on build-in
> development server and everything is fine.  But When I setup with
> mod_wsgi with Apache I'm getting messages like below
[snip]
> The specified module could not be found.

I'm not quite sure how this works on Windows, but Apache is probably
running as a different user (rather than as you).  This means that it
has its own set of environment variables, including PATH and
PYTHONPATH, which are likely to not include the directory your module
is in.  I'm afraid I can't tell you how you would go about checking or
fixing that, however, but perhaps it'll get you off to the right start.
--~--~-~--~~~---~--~~
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: MEDIA_URL MEDIA_ROOT

2009-07-30 Thread Xiong Chiamiov

On Jul 30, 3:38 am, Salvatore Leone 
wrote:
> I can't download the files, probably I don't understand the MEDIA_URL
> parameter. Here it is:
> MEDIA_URL = 'http://localhost:8000/wiz/uploads/'
>
> but trying to access the files returns me a 404 error.

You shouldn't have to use MEDIA_URL at all for local development.  You
should be able to access anything located in the directory specified
by MEDIA_ROOT with /media/.
--~--~-~--~~~---~--~~
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:

2009-07-30 Thread Margie

Are you referring to $.data()?   I think that's a great solution.  I
could attach my data to the  tag that the autocomplete is
associated with, and then in my jquery function that finds all of
those tags and then calls the autocomplete plugin on them, just pull
off the stored initialization data and then call the autocomplete
plugin using that as the argument.

Very nice.  I have seen $.data() used, but haven't used it myself yet,
so it wasn't on the top of my brain. It seems like a great solution
here.  Thanks for that idea!

Margie



On Jul 30, 11:46 am, Jim Garrison  wrote:
> > But what do you do for a widget where the jquery function being called
> > requires an argument.  For example, I have an autocomplete widget that
> > takes as a "prePopulate" argument that contains the value it should
> > initialized with.
>
> Have you considered using the jquery metadata plugin?  It should allow
> you to store the information you need right in the DOM, and then
> access it from javascript.
--~--~-~--~~~---~--~~
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: Subclassing CharField

2009-07-30 Thread Xiong Chiamiov

On Jul 30, 7:27 am, Michael Anckaert 
wrote:
> Hello everyone,
>
> I subclassed the CharField but have run into this problem:

How did you subclass CharField?  It's difficult to say what the
problem is without seeing what you've done.
--~--~-~--~~~---~--~~
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:

2009-07-30 Thread Margie

Ah - ok, I finally see what you are saying.  Sorry, I somehow began
thinking there was some additional "GET" happening that I just really
didn't understand. I didn't understand that "src" was referring to the
"src" in the  tag.  My world had become very confused.   Ok,
the world is back to one that I understand.

Yes, I agree this is too complicated for my case (especially since I
am calling my autocomplete jquery function multiple times per single
html page, and each time it has a different initial input).

Anyway, thanks for the clarification.  It was just bugging me that I
didn't understand!

Margie

On Jul 30, 12:25 pm, Daniel Roseman  wrote:
> On Jul 30, 7:41 pm, Margie  wrote:
>
>
>
> > Hi Vasil,
>
> > Could you clarify how I access the variable from the javascript?  For
> > example, using my DateWidget as an example, say in my wdigets.py I
> > have this (note I've added ?myVar='xyz' in second line:
>
> > class DateWidget(widgets.DateInput):
> >     class Media:
> >         js = ("js/jquery.datePicker.min-2.1.2.js",
> >                "js_custom/date_widget.js?myVar='xyz''")
>
> > The complete contents of date_widget.js is currently:
>
> >   $(document).ready(function() {
> >                       Date.firstDayOfWeek = 0;
> >                       Date.format = 'mm/dd/';
> >                       $('.chipvision_date_widget').datePicker();
> >                     });
>
> > How do I access myVar from inside date_widget.js?
>
> > I know the .js files listed in the Media class get output into my html
> > via my inclusion of  {{ media }} in my template.  So I see that I get
> > this in my html
>
> >