Re: Curious int/float/division/math 'gotcha' in py (discussion)

2011-06-29 Thread Geoff Kuenning


On Jun 29, 1:37 am, Tom Evans  wrote:
> Damn, this was the bit I meant to comment upon - hard and fast rules
> are dangerous. Integral types are distinctly different to floating
> point types, and you should be aware of which one you are using and
> why. You definitely should not be using floats when you require
> integral mathematics, or reliable accounting since 1.0 is only an
> approximation to 1.
>
> Cheers
>
> Tom
>
> >>> 1.0 * 1
>
> 9.9996e+27

Actually, 1.0 is NOT an approximation to 1.  It is precisely 1.  All
integral values up to 2^53-1 can be represented exactly.  So can many
rational fractions (roughly, those in which the denominator is a power
of two and the numerator and denominator don't differ by a really big
ratio).

The reason the above example fails isn't the 1.0, it's because the
second number (10^28) is bigger than 2^53, so IT can't be represented
exactly.

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



unable to import Modules Present in subdirectores

2011-06-29 Thread srinivasan panneer

Hi Guys
I am very new to Python and Django and having problem with importing modules in 
my project,
I am following the tutorial, which i downloaded from django website. Where I 
have the following folder hierarchy in my Django project.(using Pycharm IDE)

HelloWorldDjangoHelloWorldDjango/HelloWorldDjangoAppHelloWorldDjango/HelloWorldDjangoApp/polls
I am able to import modules from my site folder which is HelloWorldDjangoApp, 
but having problem in importing from the subfolders. For example I have 
Views.py in polls directory and iam not able to import it.
It is unable to find the modules in the subdirectories like  polls.views 
What do i do?   i believe some Env variable has to be modified, Because 
currently thesys.path has path upto my HelloWorldDjangoApp directory.. What 
do i do for subdirectories.
Thank you in advance.. 

 
Regards, 
Srini
 
 
 
 

 

 
 

  

-- 
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: Curious int/float/division/math 'gotcha' in py (discussion)

2011-06-29 Thread Cal Leeming
Thanks for explaining this Geoff. My math is somewhat basic, so it's always
good to learn new things like this.
On 29 Jun 2011 08:00, "Geoff Kuenning"  wrote:
>
>
> On Jun 29, 1:37 am, Tom Evans  wrote:
>> Damn, this was the bit I meant to comment upon - hard and fast rules
>> are dangerous. Integral types are distinctly different to floating
>> point types, and you should be aware of which one you are using and
>> why. You definitely should not be using floats when you require
>> integral mathematics, or reliable accounting since 1.0 is only an
>> approximation to 1.
>>
>> Cheers
>>
>> Tom
>>
>> >>> 1.0 * 1
>>
>> 9.9996e+27
>
> Actually, 1.0 is NOT an approximation to 1. It is precisely 1. All
> integral values up to 2^53-1 can be represented exactly. So can many
> rational fractions (roughly, those in which the denominator is a power
> of two and the numerator and denominator don't differ by a really big
> ratio).
>
> The reason the above example fails isn't the 1.0, it's because the
> second number (10^28) is bigger than 2^53, so IT can't be represented
> exactly.
>
> --
> 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.
>

-- 
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: Curious int/float/division/math 'gotcha' in py (discussion)

2011-06-29 Thread Cal Leeming [Simplicity Media Ltd]
Thanks for explaining this Geoff. My math is somewhat basic, so it's always
good to learn new things like this.
On 29 Jun 2011 08:00, "Geoff Kuenning"  wrote:
>
>
> On Jun 29, 1:37 am, Tom Evans  wrote:
>> Damn, this was the bit I meant to comment upon - hard and fast rules
>> are dangerous. Integral types are distinctly different to floating
>> point types, and you should be aware of which one you are using and
>> why. You definitely should not be using floats when you require
>> integral mathematics, or reliable accounting since 1.0 is only an
>> approximation to 1.
>>
>> Cheers
>>
>> Tom
>>
>> >>> 1.0 * 1
>>
>> 9.9996e+27
>
> Actually, 1.0 is NOT an approximation to 1. It is precisely 1. All
> integral values up to 2^53-1 can be represented exactly. So can many
> rational fractions (roughly, those in which the denominator is a power
> of two and the numerator and denominator don't differ by a really big
> ratio).
>
> The reason the above example fails isn't the 1.0, it's because the
> second number (10^28) is bigger than 2^53, so IT can't be represented
> exactly.
>
> --
> 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.
>

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



Database partition strategies and scalability advice

2011-06-29 Thread Jake D
Hello all,

I'm in the development stage of my web app, and I'm trying to think
about model partitioning early. There are some messages on this topic
before there was robust support for multiple databases in Django, and
I wanted to get some advice from the experts, now that routers are
easy to use.

I'd like to partition a few of the apps in my project into their own
database(s). However, each has a ForeignKey to a UserProfile primary
key--in my case, it's the slug. Since I would like to keep the
UserProfile database separate, I'll obviously have to switch from a
ForeignKey field to something else (in my case a SlugField). These are
my questions:

1. When partitioning a database like this, what is the easiest way to
maintain consistency, since I lose functionality like delete cascades.
Is it to use post_delete signals and to wrap everything within single
transactions? Are there tips?

2. Are there other considerations for data consistency that I should
consider? Any suggestions for moving away from ForeignKeys.

3. Are there any links on how to use routers on sharded data?
Specifically, I'd like to know how to aggregate data of a given model
spread over multiple databases.

I very much appreciate any feedback.

best,

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: Possible interest in a webcast/presentation about Django site with 40mil+ rows of data??

2011-06-29 Thread Andre Terra
Can't access google spreadsheets through my corporate proxy (go figure), but
I will vote later today.

Really interested in watching this!


Andre

On Tue, Jun 28, 2011 at 12:30 PM, Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk> wrote:

> Second call for anyone who wants to attend this webcast, 3 days left to
> place your vote.
>
> Cal
>
>
> On Fri, Jun 24, 2011 at 7:34 PM, Cal Leeming [Simplicity Media Ltd] <
> cal.leem...@simplicitymedialtd.co.uk> wrote:
>
>> Really glad to see there has been so much interest in this!
>>
>> If possible, can everyone please use the following form to indicate what
>> week day / timeslot they are available, along with their screen resolution.
>> This will be open until 1st July.
>>
>>
>> https://spreadsheets0.google.com/spreadsheet/viewform?formkey=dENyOVFSSkhSYnhBLVZGTktiN1Z3Y2c6MQ
>>
>> Whichever week day / timeslot / screen resolution has 100% of the votes,
>> will be the chosen one :) If it's split, we'll look at doing the webcast on
>> two separate occasions. Hopefully this should give everyone a fair chance.
>>
>> Thanks
>>
>> Cal
>>
>> On Fri, Jun 24, 2011 at 4:14 PM, Nolan Brubaker > > wrote:
>>
>>> Yes, very interested.  +1
>>>
>>>
>>> On Fri, Jun 24, 2011 at 9:04 AM, bruno desthuilliers <
>>> bruno.desthuilli...@gmail.com> wrote:
>>>
 +1

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


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

-- 
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: unable to import Modules Present in subdirectores

2011-06-29 Thread Tim Shaffer
You do have a __init__.py file in each of the sub folders, correct?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/G33m7AMAv7wJ.
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: unable to import Modules Present in subdirectores

2011-06-29 Thread Bill Freeman
A couple of basic python things for you to check:

1: You must have a file named "__init__.py" (it may be an empty file)
in any directory that is to occur before a "." in an import statement.
 The presence of this file makes the directory a "package", just like
having a name ending in ".py" makes a file a module.  You can import
modules or sub-packages from packages, but not from directorys that
aren't packages, unless the directory is explicitly on sys.path.

2: Python imported names are case sensitive, even if your filesystem
is not.  Thus you cannot import a module named "Views.py" using the
name "views", as in "polls.views".  You would have to use, for
example, "polls.View".  If the name of the package is "Polls" then you
would have to use "Polls.Views".

Bill

On Wed, Jun 29, 2011 at 3:51 AM, srinivasan panneer
 wrote:
> Hi Guys
> I am very new to Python and Django and having problem with importing modules
> in my project,
> I am following the tutorial, which i downloaded from django website. Where I
> have the following folder hierarchy in my Django project.(using Pycharm IDE)
>
> HelloWorldDjango
> HelloWorldDjango/HelloWorldDjangoApp
> HelloWorldDjango/HelloWorldDjangoApp/polls
> I am able to import modules from my site folder which is
> HelloWorldDjangoApp, but having problem in importing from the subfolders.
> For example I have Views.py in polls directory and iam not able to import
> it.
> It is unable to find the modules in the subdirectories like  polls.views
> What do i do?   i believe some Env variable has to be modified, Because
> currently the    sys.path has path upto my HelloWorldDjangoApp directory..
> What do i do for subdirectories.
> Thank you in advance..
>
>
> Regards,
> Srini
>
>
>
>
>
>
>
>
>
>
> --
> 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.
>

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



Vs: how to override a ModelChoiceField in order to add FKs directly in a TextInput?

2011-06-29 Thread Martin Pajuste
Since ModelChoiceField validates that the given id exists in the queryset, 
there can be no valid choices when you use MyRelatedClass.objects.none().

Try MyRelatedClass.objects.all() or filter by some attribute. If the 
queryset depends on some user input or conditions you can use something 
like:

def __init__(self, some_value, *args, **kwargs):
super(MyForm, self).__init__(*args, **kwargs)
qset= MyRelatedClass.objects.filter(some_field=some_value)
self.fields['myrelation '].queryset = qset



Martin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Cm7-6sNIfeMJ.
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.



Media (JS/CSS) handling outsite Forms

2011-06-29 Thread Thomas Guettler
Hi,

inside Forms including of JS/CSS files is solved: You use the Media-Object.

But outside Forms? I have a python method which returns a HTML snippet, which
gets included in several views. It requires a JS file

How do you handle this dependency?

One solution would be to add all needed media files to a global (thread safe) 
variable and
a middleware includes them into the result. Not a nice solution, but
I see no better solution.

How do you handle this?

  Thomas

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

-- 
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: unable to import Modules Present in subdirectores

2011-06-29 Thread bruno desthuilliers


On Jun 29, 3:41 pm, Bill Freeman  wrote:
> A couple of basic python things for you to check:
(...)
> 2: Python imported names are case sensitive, even if your filesystem
> is not.  Thus you cannot import a module named "Views.py" using the
> name "views", as in "polls.views".  You would have to use, for
> example, "polls.View".  If the name of the package is "Polls" then you
> would have to use "Polls.Views".

The obvious conclusion being: only use all_lower names for your
packages and modules names.

-- 
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: Possible interest in a webcast/presentation about Django site with 40mil+ rows of data??

2011-06-29 Thread Cal Leeming [Simplicity Media Ltd]
Wow, that sucks! :X Never known a corp to block google docs

On Wed, Jun 29, 2011 at 2:16 PM, Andre Terra  wrote:

> Can't access google spreadsheets through my corporate proxy (go figure),
> but I will vote later today.
>
> Really interested in watching this!
>
>
> Andre
>
> On Tue, Jun 28, 2011 at 12:30 PM, Cal Leeming [Simplicity Media Ltd] <
> cal.leem...@simplicitymedialtd.co.uk> wrote:
>
>> Second call for anyone who wants to attend this webcast, 3 days left to
>> place your vote.
>>
>> Cal
>>
>>
>> On Fri, Jun 24, 2011 at 7:34 PM, Cal Leeming [Simplicity Media Ltd] <
>> cal.leem...@simplicitymedialtd.co.uk> wrote:
>>
>>> Really glad to see there has been so much interest in this!
>>>
>>> If possible, can everyone please use the following form to indicate what
>>> week day / timeslot they are available, along with their screen resolution.
>>> This will be open until 1st July.
>>>
>>>
>>> https://spreadsheets0.google.com/spreadsheet/viewform?formkey=dENyOVFSSkhSYnhBLVZGTktiN1Z3Y2c6MQ
>>>
>>> Whichever week day / timeslot / screen resolution has 100% of the votes,
>>> will be the chosen one :) If it's split, we'll look at doing the webcast on
>>> two separate occasions. Hopefully this should give everyone a fair chance.
>>>
>>> Thanks
>>>
>>> Cal
>>>
>>> On Fri, Jun 24, 2011 at 4:14 PM, Nolan Brubaker <
>>> nolan.bruba...@gmail.com> wrote:
>>>
 Yes, very interested.  +1


 On Fri, Jun 24, 2011 at 9:04 AM, bruno desthuilliers <
 bruno.desthuilli...@gmail.com> wrote:

> +1
>
> --
> 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.
>
>
  --
 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.

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

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



"attempt to write a readonly database" with write permissions in database file and folder

2011-06-29 Thread hectoraka
Hello,

I am getting the "attempt to write a readonly database" when trying to
access the admin site. I have read that this is usually due to
incorrect permissions but the error persists even if I make the
database file and folder writable by all:

database file:
 -rw-rw-rw-. 1 hector developers 40960  6月 29 21:55 mialbum.db

folder containing the database file:
drwxrwsrwx. 2 hector developers 4096  6月 29 21:55 db

Something I am missing?

Thank you,
Hector

-- 
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: "attempt to write a readonly database" with write permissions in database file and folder

2011-06-29 Thread Anoop Thomas Mathew
Hi,
Seems selinux permissions are causing trouble. Try shutting it off and try
again.
Regards,
Anoop
On 29 Jun 2011 21:03, "hectoraka"  wrote:
> Hello,
>
> I am getting the "attempt to write a readonly database" when trying to
> access the admin site. I have read that this is usually due to
> incorrect permissions but the error persists even if I make the
> database file and folder writable by all:
>
> database file:
> -rw-rw-rw-. 1 hector developers 40960 6月 29 21:55 mialbum.db
>
> folder containing the database file:
> drwxrwsrwx. 2 hector developers 4096 6月 29 21:55 db
>
> Something I am missing?
>
> Thank you,
> Hector
>
> --
> 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.
>

-- 
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: unable to import Modules Present in subdirectores

2011-06-29 Thread Andre Terra
This can't be stressed enough.

Please read http://www.python.org/dev/peps/pep-0008/ and try to follow it as
best as you can.



Sincerely,

André Terra

On Wed, Jun 29, 2011 at 12:26 PM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

>
>
> On Jun 29, 3:41 pm, Bill Freeman  wrote:
> > A couple of basic python things for you to check:
> (...)
> > 2: Python imported names are case sensitive, even if your filesystem
> > is not.  Thus you cannot import a module named "Views.py" using the
> > name "views", as in "polls.views".  You would have to use, for
> > example, "polls.View".  If the name of the package is "Polls" then you
> > would have to use "Polls.Views".
>
> The obvious conclusion being: only use all_lower names for your
> packages and modules names.
>
> --
> 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.
>
>

-- 
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: Global generic files? Best practice(s)?

2011-06-29 Thread Andre Terra
If you're using it for multiple apps, but just one project and the apps are
project-specific, then this code could very well lie in your project's
utils.py or any other module.

If you're writing code that's meant to be reused by third-parties, then the
picture is rather different. I recently had a similar problem and I thought
about writing a try/except block that tries to imports your global module
with the necessary utilities and if it fails, it defines the functions
itself. This way you allow for an easy global override of the needed
utilities in case your needs vary.

I'm not sure this is the standard/best practice, but I believe I've seen
similar bits of code in django core. A more experienced developer's point of
view is most welcome here!


Sincerely,
André Terra

On Tue, Jun 28, 2011 at 5:39 PM, Micky Hulse  wrote:

> Hello,
>
> I was going to start a "global" app for a generic "helpers.py" file; I
> plan on using this code in multiple apps.
>
> Question: Is creating a generic app a standard approach to storing
> "global" code?
>
> ...
>
> If the answer to the above question is "yes":
>
> What's your preferred approach to handling generic/global code?
>
> When using a "global" app how do you package apps that have files that
> are not inside app structure? Would you change re-factor/re-arrange
> your code/files or would you include the "global" app in your
> package/packaging?
>
> TIA!
>
> Cheers,
> Micky
>
> --
> Micky Hulse
> Web Content Editor
> The Register-Guard
> 3500 Chad Drive
> Eugene, OR 97408
> Phone: (541) 338-2621
> Fax: (541) 683-7631
> Web: 
>
> --
> 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.
>
>

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



ImportError: No module named site

2011-06-29 Thread Kyle Latham
I searched this group for that error, and browsed through several
pages and dozens of posts...but none of them helped me solve my error.

Yesterday I had my server up and running, and I left it running
overnight. I do not remember changing anything in any of my .py files,
but when I shut down my server to restart it, I was getting an error:

"Import Error: No module named site"

I have no idea what is going wrong, but here is all my code thus far
(I'm following the tutorial to create my own app that will display
various material measurements)

---
models.py
---
from django.db import models

# Create your models here.
class adhesive(models.Model):
measurement_id = models.CharField(max_length = 200)
material_id = models.CharField(max_length = 200)
program_name = models.CharField(max_length = 200)
date = models.DateField()
measurement_method = models.CharField(max_length = 30)
frequency_low = models.IntegerField()
frequency_high = models.IntegerField()

class ceramic(models.Model):
measurement_id = models.CharField(max_length = 200)
material_id = models.CharField(max_length = 200)
program_name = models.CharField(max_length = 200)
date = models.DateField()
measurement_method = models.CharField(max_length = 30)
frequency_low = models.IntegerField()
frequency_high = models.IntegerField()

class composite(models.Model):
measurement_id = models.CharField(max_length = 200)
material_id = models.CharField(max_length = 200)
program_name = models.CharField(max_length = 200)
date = models.DateField()
measurement_method = models.CharField(max_length = 30)
frequency_low = models.IntegerField()
frequency_high = models.IntegerField()


---
settings.py
---
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add
'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'materials',  # Or path to
database file if using sqlite3.
'USER': 'root',  # Not used with sqlite3.
'PASSWORD': 'x',  # Not used with sqlite3.
'HOST': '',  # Set to empty string for
localhost. Not used with sqlite3.
'PORT': '',  # Set to empty string for
default. Not used with sqlite3.
}
}

...

ROOT_URLCONF = 'material_measurements/urls'

TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/
django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
"C:/Django/material_measurements.materials"
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'material_measurements.materials',
# 'django.contrib.messages',
# 'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)




---
urls.py
---
from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
# Examples:
# url(r'^$', 'material_measurements.views.home', name='home'),
# url(r'^material_measurements/',
include('material_measurements.foo.urls')),

# Uncomment the admin/doc line below to enable admin
documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
(r'^admin/(.*)', admin.site.root),
)





Thanks for the help!

-- 
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: let the users download files

2011-06-29 Thread Jagdeep Singh Malhi


On Jun 29, 10:34 am, pankaj sharma  wrote:
> hello friends ,
> i have a database in which i have some files say photos...
Why you store you files in database? You need to store the path of
file in database and files area stored in that path or folder.

> {i am uploading photos from django admin.}
> i want to make a template so that the users of my website can download
> these photos ..
> so can anyone provide me some useful information or any link

Code for retrieve file in django template, if file path is store in
database and file store in that path or folder.

{% if variable1   %}
{% for variable2 in variable1 %}
{% if variable2.database_field_name %} 
{% endif %}
{% endfor %}
{% endif %}

-- 
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: Global generic files? Best practice(s)?

2011-06-29 Thread Micky Hulse
Hi Andre!

Thanks so much for the reply, I really appreciate the help! :)

On Wed, Jun 29, 2011 at 9:51 AM, Andre Terra  wrote:
> If you're using it for multiple apps, but just one project and the apps are
> project-specific, then this code could very well lie in your project's
> utils.py or any other module.

Doh, sorry, I should have been more clear...

This code would be for one project. We do have multiple projects
installed... I had not considered sharing between projects! :)

I like your suggestion of using a utils.py file! I assume this would
exist at the same level as the apps? For example:

/my_project:

__init__.py
app1
app2
app3
manage.py
settings.py
templates/
urls.py
utils.py

This would be one example of code functionality that I would like to
share between my various apps:

https://gist.github.com/1027898

...

Just thinking out loud here... Bear with me for a moment.

Is it best to just copy code (like above) and duplicate it for each
app, or is it better to share one piece of code between apps?

Pros/cons of sharing code (like above) between apps:

PRO:

1. Following DRY principle.
2. Faster development times (common code in one place)?
3. Other?

CON:

1. When connected to many apps, the code becomes more risky if/when
re-factoring is needed.
2. Not self-contained to application.
3. Things become more splintered/abstracted/other?
4. Other?

> If you're writing code that's meant to be reused by third-parties, then the
> picture is rather different. I recently had a similar problem and I thought
> about writing a try/except block that tries to imports your global module
> with the necessary utilities and if it fails, it defines the functions
> itself. This way you allow for an easy global override of the needed
> utilities in case your needs vary.

Ooh, I like that idea! I think I have seen similar things in other
programming languages myself.

That's a great suggestion, thanks! :)

> I'm not sure this is the standard/best practice, but I believe I've seen
> similar bits of code in django core. A more experienced developer's point of
> view is most welcome here!

That's actually a great tip... I should probably browse through the
Django source code to find working examples. :)

Thanks so much for the informative and helpful reply Andre, I greatly
appreciate the help.

Have a great day!

Cheers,
Micky

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



How to make comment view redirect me directly to my next field instead to preview view

2011-06-29 Thread Ariel
Hi everybody, I am using comments framework in django, but I need that when
the comment form is not valid the comment post view doens't send me to a
preview view to show me the errors in the form instead of that I need the
view send me directly to the 'next' url and show me there the form errors.
Any Idea how to solve that ?
Help it is really appreciate it.

Regards,
Ariel

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



getting objects unique in several ways (annotate?)

2011-06-29 Thread elliot
Sorry about the vague title.  Its hard for me to summarize this in one
short sentence.
Lets say I have two models (using pseudo code):

Book(model.Model):
  name = charfield()

Transaction(model.Model):
  start_date = DateTimeField()
  item = ManytoMany(Book)
  recipient = CharField()

Now for every book, I want to know the recipient of only the most
recent transaction.  I can get the start date of the most recent
transaction for each book with

Book.objects.annotate(mostrecent = Max('transaction__start_date'))

but what I would like is the pk of that transaction, so I can get more
information about it.  Can this be done even in multiple queries?
Must I hack a solution using lists instead of queries?

I have simplified my question quite a bit, I hope not too much.

thanks for reading,
Elliot

-- 
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: getting objects unique in several ways (annotate?)

2011-06-29 Thread Michał Sawicz
Dnia 2011-06-29, śro o godzinie 16:31 -0700, elliot pisze:
> Book.objects.annotate(mostrecent = Max('transaction__start_date'))

.values('pk')

Or whatever values you want.
-- 
Michał Sawicz 


signature.asc
Description: This is a digitally signed message part


Re: Possible interest in a webcast/presentation about Django site with 40mil+ rows of data??

2011-06-29 Thread Matteius
If I am unable to attend at the scheduled time I absolutely must watch
the resulting recording.  Thanks for your efforts.

On Jun 22, 5:50 pm, "Cal Leeming [Simplicity Media Ltd]"
 wrote:
> Nice!
>
> On Wed, Jun 22, 2011 at 11:39 PM, Thomas Weholt 
> wrote:
>
>
>
>
>
> > On Wed, Jun 22, 2011 at 4:47 PM, Cal Leeming [Simplicity Media Ltd]
> >  wrote:
>
> > > On Wed, Jun 22, 2011 at 3:25 PM, Andre Terra 
> > wrote:
>
> > >> Hello, Cal
>
> > >> First of all, congrats on the newborn! The Django community will surely
> > >> benefit from having yet another success story, especially considering
> > how
> > >> big this project sounds. Is there any chance you could open-source some
> > of
> > >> your custom made improvements so that they could eventually be merged to
> > >> trunk?
>
> > > Thank you! Yeah, the plan is to release as much of the improvements as
> > open
> > > source as possible. Although I'd rely heavily on the community to make
> > them
> > > 'patch worthy' for the core, as the amount of spare time I have is
> > somewhat
> > > limited.
> > > The improvements list is growing by the day, and I usually try and post
> > as
> > > many snippets as I can, and/or tickets etc.
> > > It sounds like Thomas's DSE might be the perfect place for the bulk
> > update
> > > code too.
>
> > FYI: Inspired by this discussion I've allready started on a similar
> > feature ( allthough somewhat simplified ) for DSE v2.2.0 and you're
> > right; the speed increase is huge using the method described here,
> > even compared to my current solution ( using cursor.executemany ),
> > which is considerably faster than the django orm allready. My testing
> > so far have been using postgresql, not sure how mysql will perform. I
> > expect to release DSE v.2.2.0 with this feature in the next few days.
>
> Nice! Looking forward to seeing this :)
>
>
>
> > --
> > Mvh/Best regards,
> > Thomas Weholt
> >http://www.weholt.org
>
> > --
> > 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.

-- 
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: ImportError: No module named site

2011-06-29 Thread Andre Terra
As you can see from your urls.py, there is a reference to admin.site
and that is probably what's not working on your setup.

Try this:
$ ./manage.py shell
>>> import django
>>> django.get_version()
>>> from django.contrib import admin
>>> admin.site

..and see how far you can go before the first exception. Feel free to
paste the results in a reply.

Sincerely,
André Terra

On 6/29/11, Kyle Latham  wrote:
> I searched this group for that error, and browsed through several
> pages and dozens of posts...but none of them helped me solve my error.
>
> Yesterday I had my server up and running, and I left it running
> overnight. I do not remember changing anything in any of my .py files,
> but when I shut down my server to restart it, I was getting an error:
>
> "Import Error: No module named site"
>
> I have no idea what is going wrong, but here is all my code thus far
> (I'm following the tutorial to create my own app that will display
> various material measurements)
>
> ---
> models.py
> ---
> from django.db import models
>
> # Create your models here.
> class adhesive(models.Model):
> measurement_id = models.CharField(max_length = 200)
> material_id = models.CharField(max_length = 200)
> program_name = models.CharField(max_length = 200)
> date = models.DateField()
> measurement_method = models.CharField(max_length = 30)
> frequency_low = models.IntegerField()
> frequency_high = models.IntegerField()
>
> class ceramic(models.Model):
> measurement_id = models.CharField(max_length = 200)
> material_id = models.CharField(max_length = 200)
> program_name = models.CharField(max_length = 200)
> date = models.DateField()
> measurement_method = models.CharField(max_length = 30)
> frequency_low = models.IntegerField()
> frequency_high = models.IntegerField()
>
> class composite(models.Model):
> measurement_id = models.CharField(max_length = 200)
> material_id = models.CharField(max_length = 200)
> program_name = models.CharField(max_length = 200)
> date = models.DateField()
> measurement_method = models.CharField(max_length = 30)
> frequency_low = models.IntegerField()
> frequency_high = models.IntegerField()
>
>
> ---
> settings.py
> ---
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.mysql', # Add
> 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
> 'NAME': 'materials',  # Or path to
> database file if using sqlite3.
> 'USER': 'root',  # Not used with sqlite3.
> 'PASSWORD': 'x',  # Not used with sqlite3.
> 'HOST': '',  # Set to empty string for
> localhost. Not used with sqlite3.
> 'PORT': '',  # Set to empty string for
> default. Not used with sqlite3.
> }
> }
>
> ...
>
> ROOT_URLCONF = 'material_measurements/urls'
>
> TEMPLATE_DIRS = (
> # Put strings here, like "/home/html/django_templates" or "C:/www/
> django/templates".
> # Always use forward slashes, even on Windows.
> # Don't forget to use absolute paths, not relative paths.
> "C:/Django/material_measurements.materials"
> )
>
> INSTALLED_APPS = (
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.sites',
> 'material_measurements.materials',
> # 'django.contrib.messages',
> # 'django.contrib.staticfiles',
> # Uncomment the next line to enable the admin:
> 'django.contrib.admin',
> # Uncomment the next line to enable admin documentation:
> # 'django.contrib.admindocs',
> )
>
>
>
>
> ---
> urls.py
> ---
> from django.conf.urls.defaults import *
>
> # Uncomment the next two lines to enable the admin:
> from django.contrib import admin
> admin.autodiscover()
>
> urlpatterns = patterns('',
> # Examples:
> # url(r'^$', 'material_measurements.views.home', name='home'),
> # url(r'^material_measurements/',
> include('material_measurements.foo.urls')),
>
> # Uncomment the admin/doc line below to enable admin
> documentation:
> # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
> # Uncomment the next line to enable the admin:
> (r'^admin/(.*)', admin.site.root),
> )
>
>
>
>
>
> Thanks for the help!
>
> --
> 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.
>
>

-- 
Sent from my mobile device

-- 

Re: Comparing ManyToManyFields

2011-06-29 Thread Andre Terra
You'll first have to explain what you mean by 'reading from a file'
and 'comparing'.

Are we comparing against serialized model exports? Is the user
importing data from a csv file? What column(s) is(are) you using as
keys for matching db objects against the file?

Give us a little more details and we'll try giving some suggestions in return =)


Sincerely,
André Terra

On 6/28/11, Josh Lothian  wrote:
> So I'm working on my first Django application, and I've run into a
> stumbling block.  In simplest terms, I've got two objects:
>
> def Package(models.Model):
> name=models.CharField(max_length=255)
> version=models.CharField(max_length=128)
>
> def Machine(models.Model):
> hostname=models.CharField(max_length=255)
> installed_packages=models.ManyToManyField(Package)
>
> I'm reading in information from some file, and need to compare against
> objects already in the database.  Ideally, I could just create these
> objects in my code, compare to the existing Django objects, and add a
> new entry if it's different from anything that exists already.
>
> However, I've got that dang ManyToManyField in there, meaning I need
> to first commit a Machine to the DB, and then add Packages to it.
> Otherwise, of course I get:
>
> ValueError: 'Machine' instance needs to have a primary key value before a
> many-to-many relationship can be used.
>
> This seems non-ideal, since there's a pretty good chance I'll just
> need to delete it from the database as a dupe of an existing Machine.
>
> I see a couple of ways around this:
>
> - Instantiate a Machine and a list of Packages, and compare them
> separately.  This isn't ideal, as my real objects likely have more
> than 1 many-to-many relationship.
>
> - Do database queries and whatnot directly.  Yuck!
>
> - Punt and just add/remove things from the database.  This would
> probably work fine now, but later on could definitely lead to scaling
> issues.
>
> Am I missing an obvious solution here?  I've scoured the docs and
> can't seem to come up with anything that doesn't make me feel icky.
>
> -josh
>
> --
> 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.
>
>

-- 
Sent from my mobile device

-- 
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: Comparing ManyToManyFields

2011-06-29 Thread Josh Lothian
Heh, whoops.

So I'm reading in all the information about a machine from a file that
is generated periodically on the machine (XML right now).  I need to
compare all the data about that machine to what's currently in the
database, and create a new entry if anything has changed.  

The models are really more complicated than I posted (obviously) but
the current idea is to key on the hostname, but to compare every
single little bit of data in the model to detect changes.

-josh

On Wed, Jun 29, 2011 at 09:40:24PM -0400, Andre Terra wrote:
> You'll first have to explain what you mean by 'reading from a file'
> and 'comparing'.
> 
> Are we comparing against serialized model exports? Is the user
> importing data from a csv file? What column(s) is(are) you using as
> keys for matching db objects against the file?
> 
> Give us a little more details and we'll try giving some suggestions in return 
> =)
> 
> 
> Sincerely,
> André Terra
> 
> On 6/28/11, Josh Lothian  wrote:
> > So I'm working on my first Django application, and I've run into a
> > stumbling block.  In simplest terms, I've got two objects:
> >
> > def Package(models.Model):
> > name=models.CharField(max_length=255)
> > version=models.CharField(max_length=128)
> >
> > def Machine(models.Model):
> > hostname=models.CharField(max_length=255)
> > installed_packages=models.ManyToManyField(Package)

-- 
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: unable to import Modules Present in subdirectores

2011-06-29 Thread Kenneth Gonsalves
On Wed, 2011-06-29 at 03:51 -0400, srinivasan panneer wrote:
> For example I have Views.py

is it Views.py or views.py?
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Managing objects spred among several tables/databases.

2011-06-29 Thread qMax
Hello here.

My application task is to integrate several applications, and it
should manipulate objects, spread among several tables in several
databases. Final object is constructed by 'joining' tables by single
field (or derivatives).
A user should see such objects as solid entities and manipulate them
with basic CRUD operations (with search).
Backend should synchronize all changes in all databases.
And i wish i could use admin site for that.

If i guess correctly, all required magic should go into custom
QuerySet implementation to properly translate CRUD operations on
models into various distributed requests on databases, like zigzag-
joins, etc instead of usual sql.Queries.

I wonder if QuerySet is the only consolidation of such interface.
What else should i customize to make it work? (i see at least
db.models.Manager should be customized to use another queryset impl)
Also, how to figure out what subset of QuerySet interface is used in
admin site?

Maybe, someone already managed similar task and there are some recipes?

-- 
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: Possible interest in a webcast/presentation about Django site with 40mil+ rows of data??

2011-06-29 Thread Wagner Vaz
Please, count me in.
On Jun 22, 2011 10:15 AM, "Cal Leeming [Simplicity Media Ltd]" <
cal.leem...@simplicitymedialtd.co.uk> wrote:
> Hi all,
>
> Some of you may have noticed, in the last few months I've done quite a few
> posts/snippets about handling large data sets in Django. At the end of
this
> month (after what seems like a lifetime of trial and error), we're finally
> going to be releasing a new site which holds around 40mil+ rows of data,
> grows by about 300-500k rows each day, handles 5GB of uploads per day, and
> can handle around 1024 requests per second on stress test on a moderately
> spec'd server.
>
> As the entire thing is written in Django (and a bunch of other open source
> products), I'd really like to give something back to the community. (stack
> incls Celery/RabbitMQ/Sphinx SE/PYQuery/Percona
> MySQL/NGINX/supervisord/debian etc)
>
> Therefore, I'd like to see if there would be any interest in webcast in
> which I would explain how we handle such large amounts of data, the trial
> and error processes we went through, some really neat tricks we've done to
> avoid bottlenecks, our own approach to smart content filtering, and some
of
> the valuable lessons we have learned. The webcast would be completely free
> of charge, last a couple of hours (with a short break) and anyone can
> attend. I'd also offer up a Q&A session at the end.
>
> If you're interested, please reply on-list so others can see.
>
> Thanks
>
> Cal
>
> --
> 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.
>

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