Re: Users getting logged out frequently

2012-01-06 Thread Kevin
Which backend is storing the session data?  If session data is being
stored in the cache(which is normally the recommended way), what
caching backend are you using?  If you are using locmem cache backend,
this might be your problem, change the cache backend to something more
stable for production.

Do you have other Django projects you manage?  If so, is this the only
project seeing this type of problem, or are other projects also having
issues like this as well?

There are many variables in what could cause a session to fail.  For
debugging purposes, write a simple middleware that keeps track of what
is going on with the session cookie.  Create a debugging app which can
store this debugging info to a file or a database table.

If all else fails, set-up a foolproof session set-up, store sessions
directly into the database or as files in the file system to a
directory which you know will not remove any of these files.  If you
use file-based sessions, you can check the timestamps there to see
which ones are becoming stale easily.  You can create a django view
which can list the directory and it's timestamps for easily watching
remotely(be sure to make the view superuser only).

On Jan 5, 4:34 pm, Javier Guerra Giraldez  wrote:
> On Thu, Jan 5, 2012 at 2:35 PM, Dennis Lee Bieber  
> wrote:
>
> >        That would have to be a very erratic clock setting -- are there
> > systems that don't use an NTP server to synchronize the clock? (I think
> > all of my computers synchronize on a weekly basis).
>
> virtual machines can have terribly erratic clock behaviour.  over a
> minute of error in an hour is not unheard of.  of course, most
> hypervisors now specifically handle this problem and keep the VM's
> clock a lot more stable
>
> NTP is the solution, but it's not as trivial to do correctly enough as
> in real hardware.
>
> --
> Javier

-- 
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: Limiting choices for ModelForm's ForeignKey/ManyToMany

2012-01-06 Thread Kevin
Thanks, this was exactly what I was looking for, here's the code I
used:

form.fields["rate"].queryset =
Rate.objects.filter(company_id=the_company.id)

Although with my own fields, and it worked perfectly.

Something else that other users may use more than this type would be
something like this:

form.fields["rate"].queryset = Rate.objects.filter(owner_id=req.user)

The request object cannot be accessed when building the ModelForm
class, for setting a filter such as this.  Although this filter can be
easily done a different way.

On Jan 4, 2:45 am, 
wrote:
> > I'm not sure if this will
>
> work, as the ModelForm's QuerySet for the choiceField cannot be
> changed dynamically during runtime, or can it?
>
> You can change the queryset directly in the view:
>
> http://stackoverflow.com/questions/291945/how-do-i-filter-foreignkey-...
> in-a-django-modelform
>
> Altough having this stored in the model would be more elegant in your case,
> perhaps anyone else has knows more..
>
> Michael
>
>
>
>
>
>
>
> -Original Message-
> From: django-users@googlegroups.com on behalf of Kevin
> Sent: Wed 1/4/2012 8:07 AM
> To: Django users
> Subject: Limiting choices for ModelForm's ForeignKey/ManyToMany
>
> Hello,
>
>   I have many models which have a foreign key to a main model. Eg:
>
> class MainModel:
>   ..
>   ..
>
> class VariousModels:
>   main = ForeignKey(MainModel)
>   ..
>   ..
>
> Now, these VariousModels sometimes have links to each other in the
> form of ForeignKey or ManyToMany.  I need to limit these ForeignKey
> and ManyToMany in various ModelForms to only display other
> VariousModels which share the same MainModel in common.  Here is what
> I tried to do and it didn't work:
>
> item = models.ForeignKey(Item, limit_choices_to={'main__pk':main},
> blank=True, null=True)
>
> I attempted different versions of this on the actual model.  I am now
> looking into how I can perform this using a ModelForm instead of
> placing the limits on the actual model.  I'm not sure if this will
> work, as the ModelForm's QuerySet for the choiceField cannot be
> changed dynamically during runtime, or can it?
>
> Basically, I am creating a multi-user/multi-section application.  The
> main model described above is a section which a user creates and
> manages.  The user should only see choices in the forms for objects
> associated with the current section they are editing.
>
> Perhaps I am going about this entirely wrong and this should be
> implemented in a different form, such as a permission.
>
> Any ideas on how this can be done would be very helpful, 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 
> athttp://groups.google.com/group/django-users?hl=en.
>
>
>
>  winmail.dat
> 5KViewDownload

-- 
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: molecular formulae

2012-01-06 Thread Russell Keith-Magee
On Fri, Jan 6, 2012 at 1:43 PM, Mike Dewhirst  wrote:
> I think I have found a workaround but it will probably blow up in my face
> due to encoding/decoding things I don't fully understand.
>
> Can anyone comment on the robustness of calling the following method in a
> model's save() ...

Well... it will fail as soon as you have an sample of magnetite or
haematite (Fe3O4 and Fe2O3 respectively) -- your code capitalizes all
characters in the final else block, including the "e" in Fe.

However, if you fix the logic problem, and you set the server encoding
of your page to be UTF-8, and serve it with UTF-8 page headers, it
should work fine -- or at least as well as the font on your customer's
browser allows. See [1] for more details on what you need to do to
serve UTF-8.

The other option is to use the  HTML tag; this provides slightly
better typographic support, since it's actually a typographic
subscript, rather than a unicode codepoint trying to emulate the
typography. This also won't be subject to any UTF-8 encoding problems.

If you look at the Wikipedia page for Iron Oxide [2], you'll see that
they use the  approach. Implementing a Django template filter to
convert "Fe2O3" into "Fe2O3" wouldn't be too
hard to do.

[1] http://www.w3.org/International/articles/serving-xhtml/Overview.en.php
[2] http://en.wikipedia.org/wiki/Iron_oxide

Yours,
Russ Magee %-)

-- 
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: Passing variables from a context processor to a template

2012-01-06 Thread Guy Nesher
Thanks,

Works perfectly now (and yeah I'm fairly new to Python/Django)

On Jan 5, 5:44 pm, Rainy  wrote:
> On Jan 5, 12:38 pm, Rainy  wrote:
>
>
>
>
>
>
>
>
>
> > On Jan 5, 12:35 pm, Guy Nesher  wrote:
>
> > > Thanks,
>
> > > I've initially tried to use a dictionary but was still unable to pull
> > > the data in the template.
>
> > > I'm using your updated context processor:
> > > def swiss_context_processors(request):
> > >     added_context = { 'mytest': 'aaa', }
> > >     return added_context
>
> > > and trying to call {{added_context.mytest}} in the template which
> > > returns nothing
>
> > It should be just {{ mytest }}
>
> I should add that in Python, it doesn't matter what is the
> variable name of value being returned. So if you have
>
> def x(): a=1; return a
>
> def y(): b=x()
>
> There is no way for y() to know that inside x(), the
> variable was called 'a'. It receives the value only. It's
> effectively equivalent to x() being:
>
> def x(): return 1
>
> So you need to understand that django template
> processing receives the dictionary {'mytest':'aaa'} and
> could not possibly know what you mean by 'added_context'.
>
>  -ak

-- 
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: molecular formulae

2012-01-06 Thread Mike Dewhirst


On 06/01/2012, at 8:03 PM, Russell Keith-Magee  wrote:

> On Fri, Jan 6, 2012 at 1:43 PM, Mike Dewhirst  wrote:
>> I think I have found a workaround but it will probably blow up in my face
>> due to encoding/decoding things I don't fully understand.
>> 
>> Can anyone comment on the robustness of calling the following method in a
>> model's save() ...
> 
> Well... it will fail as soon as you have an sample of magnetite or
> haematite (Fe3O4 and Fe2O3 respectively) -- your code capitalizes all
> characters in the final else block, including the "e" in Fe.
> 
> However, if you fix the logic problem,

Ah!  I'll remove the upper(). Thanks. 

For the rest of your advice, I'll go straight back to the drawing board - er, 
docs. 

Much appreciated

Mike


> and you set the server encoding
> of your page to be UTF-8, and serve it with UTF-8 page headers, it
> should work fine -- or at least as well as the font on your customer's
> browser allows. See [1] for more details on what you need to do to
> serve UTF-8.
> 
> The other option is to use the  HTML tag; this provides slightly
> better typographic support, since it's actually a typographic
> subscript, rather than a unicode codepoint trying to emulate the
> typography. This also won't be subject to any UTF-8 encoding problems.
> 
> If you look at the Wikipedia page for Iron Oxide [2], you'll see that
> they use the  approach. Implementing a Django template filter to
> convert "Fe2O3" into "Fe2O3" wouldn't be too
> hard to do.
> 
> [1] http://www.w3.org/International/articles/serving-xhtml/Overview.en.php
> [2] http://en.wikipedia.org/wiki/Iron_oxide
> 
> Yours,
> Russ Magee %-)
> 
> -- 
> 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: molecular formulae

2012-01-06 Thread aastrand
Unfortunately, an automatic capitalization routine would not work in
general. Take Co (the element cobolt) and CO (the molecule
carbonmonoxide) as an example. Nickel, Ni, would be another case; NI3
(nitrogen triiodide) is an explosive wheras Ni3 would be a small Ni
cluster. Capitalization has a meaning in chemistry and needs to be
provided by the user.

Per-Olof Åstrand

-- 
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: Users getting logged out frequently

2012-01-06 Thread Arun P
@Kevin:

The backend used is the default Database backend.
There are no other projects which share the same domain space.

I guess will have to write a middleware to see what is happening to the
cookies.

Thanks.

On Fri, Jan 6, 2012 at 2:26 PM, Kevin  wrote:

> Which backend is storing the session data?  If session data is being
> stored in the cache(which is normally the recommended way), what
> caching backend are you using?  If you are using locmem cache backend,
> this might be your problem, change the cache backend to something more
> stable for production.
>
> Do you have other Django projects you manage?  If so, is this the only
> project seeing this type of problem, or are other projects also having
> issues like this as well?
>
> There are many variables in what could cause a session to fail.  For
> debugging purposes, write a simple middleware that keeps track of what
> is going on with the session cookie.  Create a debugging app which can
> store this debugging info to a file or a database table.
>
> If all else fails, set-up a foolproof session set-up, store sessions
> directly into the database or as files in the file system to a
> directory which you know will not remove any of these files.  If you
> use file-based sessions, you can check the timestamps there to see
> which ones are becoming stale easily.  You can create a django view
> which can list the directory and it's timestamps for easily watching
> remotely(be sure to make the view superuser only).
>
> On Jan 5, 4:34 pm, Javier Guerra Giraldez  wrote:
> > On Thu, Jan 5, 2012 at 2:35 PM, Dennis Lee Bieber 
> wrote:
> >
> > >That would have to be a very erratic clock setting -- are there
> > > systems that don't use an NTP server to synchronize the clock? (I think
> > > all of my computers synchronize on a weekly basis).
> >
> > virtual machines can have terribly erratic clock behaviour.  over a
> > minute of error in an hour is not unheard of.  of course, most
> > hypervisors now specifically handle this problem and keep the VM's
> > clock a lot more stable
> >
> > NTP is the solution, but it's not as trivial to do correctly enough as
> > in real hardware.
> >
> > --
> > Javier
>
> --
> 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.
>
>


-- 
Digitally,
Arun Prabhakar
https://www.facebook.com/digitalpbk

-- 
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: Taking a sample mysql dump

2012-01-06 Thread Arun P
You may have to look at mysqldump manual
http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html

On Fri, Jan 6, 2012 at 12:03 AM, Amit Sethi wrote:

> Is there a way one could take the dump of just a few sample fields using
> mysqldump or some other similar tool. ?? Such that you can use it similar
> to fixture data
>
> --
> A-M-I-T S|S
>
> --
> 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.
>



-- 
Digitally,
Arun Prabhakar 


-- 
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: Users getting logged out frequently

2012-01-06 Thread Jacco Flenter
What kind of software stack are you running? Apache and... or nginx and...?

On Fri, Jan 6, 2012 at 10:51 AM, Arun P  wrote:

> @Kevin:
>
> The backend used is the default Database backend.
> There are no other projects which share the same domain space.
>
> I guess will have to write a middleware to see what is happening to the
> cookies.
>
> Thanks.
>
>
> On Fri, Jan 6, 2012 at 2:26 PM, Kevin  wrote:
>
>> Which backend is storing the session data?  If session data is being
>> stored in the cache(which is normally the recommended way), what
>> caching backend are you using?  If you are using locmem cache backend,
>> this might be your problem, change the cache backend to something more
>> stable for production.
>>
>> Do you have other Django projects you manage?  If so, is this the only
>> project seeing this type of problem, or are other projects also having
>> issues like this as well?
>>
>> There are many variables in what could cause a session to fail.  For
>> debugging purposes, write a simple middleware that keeps track of what
>> is going on with the session cookie.  Create a debugging app which can
>> store this debugging info to a file or a database table.
>>
>> If all else fails, set-up a foolproof session set-up, store sessions
>> directly into the database or as files in the file system to a
>> directory which you know will not remove any of these files.  If you
>> use file-based sessions, you can check the timestamps there to see
>> which ones are becoming stale easily.  You can create a django view
>> which can list the directory and it's timestamps for easily watching
>> remotely(be sure to make the view superuser only).
>>
>> On Jan 5, 4:34 pm, Javier Guerra Giraldez  wrote:
>> > On Thu, Jan 5, 2012 at 2:35 PM, Dennis Lee Bieber <
>> wlfr...@ix.netcom.com> wrote:
>> >
>> > >That would have to be a very erratic clock setting -- are there
>> > > systems that don't use an NTP server to synchronize the clock? (I
>> think
>> > > all of my computers synchronize on a weekly basis).
>> >
>> > virtual machines can have terribly erratic clock behaviour.  over a
>> > minute of error in an hour is not unheard of.  of course, most
>> > hypervisors now specifically handle this problem and keep the VM's
>> > clock a lot more stable
>> >
>> > NTP is the solution, but it's not as trivial to do correctly enough as
>> > in real hardware.
>> >
>> > --
>> > Javier
>>
>> --
>> 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.
>>
>>
>
>
> --
> Digitally,
> Arun Prabhakar
> https://www.facebook.com/digitalpbk
>
> --
> 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: Users getting logged out frequently

2012-01-06 Thread Arun P
Hi Jacco

The stack is nginx -> apache with wsgi.
nginx caching is turned for some url patterns.

Thanks


On Fri, Jan 6, 2012 at 3:50 PM, Jacco Flenter wrote:

> What kind of software stack are you running? Apache and... or nginx and...?
>
>
> On Fri, Jan 6, 2012 at 10:51 AM, Arun P  wrote:
>
>> @Kevin:
>>
>> The backend used is the default Database backend.
>> There are no other projects which share the same domain space.
>>
>> I guess will have to write a middleware to see what is happening to the
>> cookies.
>>
>> Thanks.
>>
>>
>> On Fri, Jan 6, 2012 at 2:26 PM, Kevin  wrote:
>>
>>> Which backend is storing the session data?  If session data is being
>>> stored in the cache(which is normally the recommended way), what
>>> caching backend are you using?  If you are using locmem cache backend,
>>> this might be your problem, change the cache backend to something more
>>> stable for production.
>>>
>>> Do you have other Django projects you manage?  If so, is this the only
>>> project seeing this type of problem, or are other projects also having
>>> issues like this as well?
>>>
>>> There are many variables in what could cause a session to fail.  For
>>> debugging purposes, write a simple middleware that keeps track of what
>>> is going on with the session cookie.  Create a debugging app which can
>>> store this debugging info to a file or a database table.
>>>
>>> If all else fails, set-up a foolproof session set-up, store sessions
>>> directly into the database or as files in the file system to a
>>> directory which you know will not remove any of these files.  If you
>>> use file-based sessions, you can check the timestamps there to see
>>> which ones are becoming stale easily.  You can create a django view
>>> which can list the directory and it's timestamps for easily watching
>>> remotely(be sure to make the view superuser only).
>>>
>>> On Jan 5, 4:34 pm, Javier Guerra Giraldez  wrote:
>>> > On Thu, Jan 5, 2012 at 2:35 PM, Dennis Lee Bieber <
>>> wlfr...@ix.netcom.com> wrote:
>>> >
>>> > >That would have to be a very erratic clock setting -- are
>>> there
>>> > > systems that don't use an NTP server to synchronize the clock? (I
>>> think
>>> > > all of my computers synchronize on a weekly basis).
>>> >
>>> > virtual machines can have terribly erratic clock behaviour.  over a
>>> > minute of error in an hour is not unheard of.  of course, most
>>> > hypervisors now specifically handle this problem and keep the VM's
>>> > clock a lot more stable
>>> >
>>> > NTP is the solution, but it's not as trivial to do correctly enough as
>>> > in real hardware.
>>> >
>>> > --
>>> > Javier
>>>
>>> --
>>> 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.
>>>
>>>
>>
>>
>> --
>> Digitally,
>> Arun Prabhakar
>> https://www.facebook.com/digitalpbk
>>
>> --
>> 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.
>



-- 
Digitally,
Arun Prabhakar 


-- 
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: This Week In History

2012-01-06 Thread Tim Sawyer
That's cunning - hadn't thought of doing it that way, though I'm using 
postgres 8.4.  This has something similar: 
http://www.postgresql.org/docs/7.4/static/functions-formatting.html


Cheers,

Tim.

On 05/01/12 23:09, Thorsten Sanders wrote:

You dont mention the database you use if mysql you could do

SELECT * FROM  WHERE DATE_FORMAT(, "%u") =
DATE_FORMAT(curdate(), "%u")

dont know if there is a django orm way to do it, but could always use a
raw query.

Am 05.01.2012 21:14, schrieb Tim Sawyer:

Hi Folks,

Does anyone have a strategy for selecting from a database where the
date is this week, but a random year in the past?

I have ~100 years of events in a database, each with a datefield - I
would like to do a "this week in history" box that lists one or two on
the homepage, randomly taken from the set.

Ideas/pointers appreciated.

Cheers,

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.



Model for images with thumbnails

2012-01-06 Thread MeME
Hello,

I'm new to Django. I started to write something for personal
purposes.
I have doubts about writing model for media files, especially images.
In my app thumbnails should be automatically created when image is
uploaded. Each such image can have thumnails with different
dimensions. Images can be attached to posts.

The question is how to store such information in database?

Should it be separate records for each thumbnail and main image? And
how to keep relationship?

Or maybe I could store everything in one record as a serialized data
(as in Wordpress)? Then I could as well store there HTML for image and
metadata.

--
Regards
MM

-- 
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: project root or its parent in pythonpath?

2012-01-06 Thread Waldek Herka
Hi,
how about creating a proper package and installing it as an egg? That
would be a proper way I think.

See this tutorial:
http://peak.telecommunity.com/DevCenter/setuptools

It is only a matter of creating the setup.py with the list of the
stuff you need to package,  then you run(from the project dir):
python setup.py build
python setup.py install
.. or even
easy_install ./

Then, if you use PyDev or any othe IDE you have to remember to refresh
the list of the locations/eggs if your list is strict(you don't need
to if you rely on dirs only).

Hope it helps.

Cheers,
Waldek

On Jan 5, 11:19 pm, "d.w. harks"  wrote:
> On Thursday, January 05, 2012 2:21:30 PM, Demetrio Girardi wrote:
>
> > I have two apps which are inter-dependent and import stuff from one
> > another; if I decide to go for the project.app route, is there a way
> > to import
> > things without a reference to the project name? otherwise the imports
> > would
> > have to be rewritten when the apps are installed in another projcet.
>
> If you have two apps that import from one another, then I'd suggest
> merging them into a single app -- it indicates that the features of the
> two are coupled and not useful without each other anyhow.
>
> That said, I would vote that it's better to add to your PYTHONPATH in
> the IDE settings than it is to have the apps import stuff via an 'import
> project.app'.
>
> --
> David W. Harks

-- 
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: molecular formulae

2012-01-06 Thread Mike Dewhirst
I agree. I was wrong to try anything with the non-numerics. They need to be 
left as the user entered them. 

Thanks

Mike

On 06/01/2012, at 8:46 PM, aastrand  wrote:

> Unfortunately, an automatic capitalization routine would not work in
> general. Take Co (the element cobolt) and CO (the molecule
> carbonmonoxide) as an example. Nickel, Ni, would be another case; NI3
> (nitrogen triiodide) is an explosive wheras Ni3 would be a small Ni
> cluster. Capitalization has a meaning in chemistry and needs to be
> provided by the user.
> 
> Per-Olof Åstrand
> 
> -- 
> 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: molecular formulae

2012-01-06 Thread aastrand
Also note that you have a math tag in html. Something like

 Fe_2_^2+^Cr_2_O_4_

might do the job for you.

Per-Olof

On Jan 6, 1:41 pm, Mike Dewhirst  wrote:
> I agree. I was wrong to try anything with the non-numerics. They need to be 
> left as the user entered them.
>
> Thanks
>
> Mike
>
> On 06/01/2012, at 8:46 PM, aastrand  wrote:
>
>
>
>
>
>
>
> > Unfortunately, an automatic capitalization routine would not work in
> > general. Take Co (the element cobolt) and CO (the molecule
> > carbonmonoxide) as an example. Nickel, Ni, would be another case; NI3
> > (nitrogen triiodide) is an explosive wheras Ni3 would be a small Ni
> > cluster. Capitalization has a meaning in chemistry and needs to be
> > provided by the user.
>
> > Per-Olof Åstrand
>
> > --
> > 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 
> > athttp://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.



{% url 'admin:jsi18n' as jsi18nurl %} error as urls.py

2012-01-06 Thread MikeKJ
This is probably an oldie and I remember coming across it before but
damned if I remember the solution:

upgrading an old django site

Request Method: GET
Request URL:
http://nortonsdairy.paston2.webfactional.com/admin/products/item/
Django Version: 1.3.1
Exception Type: TemplateSyntaxError
Exception Value:

Caught SyntaxError while rendering: invalid syntax (urls.py, line 7)

Exception Location: /home/paston2/webapps/nortons/lib/python2.7/
django/utils/importlib.py in import_module, line 35
Python Executable:  /usr/local/bin/python
Python Version: 2.7.1
Python Path:

['/home/paston2/webapps/nortons',
 '/home/paston2/webapps/nortons/nortons',
 '/home/paston2/webapps/nortons/nortons/paston_stuff',
 '/home/paston2/webapps/nortons/lib/python2.7',
 '/home/paston2/webapps/nortons',
 '/home/paston2/webapps/nortons/lib/python2.7',
 '/usr/local/lib/python27.zip',
 '/usr/local/lib/python2.7',
 '/usr/local/lib/python2.7/plat-linux2',
 '/usr/local/lib/python2.7/lib-tk',
 '/usr/local/lib/python2.7/lib-old',
 '/usr/local/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/site-packages',
 '/usr/local/lib/python2.7/site-packages/PIL']
In template /home/paston2/webapps/nortons/lib/python2.7/django/contrib/
admin/templates/admin/change_list.html, error at line 11
Caught SyntaxError while rendering: invalid syntax (urls.py, line 7)
1   {% extends "admin/base_site.html" %}
2   {% load adminmedia admin_list i18n %}
3   {% load url from future %}
4   {% block extrastyle %}
5   {{ block.super }}
6   
7   {% if cl.formset %}
8   
9   {% endif %}
10  {% if cl.formset or action_form %}
11  {% url 'admin:jsi18n' as jsi18nurl %}
12  
13  {% endif %}
14  {{ media.css }}
15  {% if not actions_on_top and not actions_on_bottom %}
16  
17  #changelist table thead th:first-child {width: inherit}
18  
19  {% endif %}
20  {% endblock %}
21

urls.py
from django.conf.urls.defaults import *
from django.conf import settings
from django.contrib import admin

admin.autodiscover()

urlpatterns = patterns('',
(r'^r/', include('django.conf.urls.shortcut')), # For the 'View on
site' button in the admin
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
(r'^admin/', include(admin.site.urls)),
(r'^account/', include('accounts.urls')),
(r'^order/', include('order.urls')),
(r'^customer/', include('customers.urls')),
(r'^news/', include('news.urls')),
(r'^', include('smartpages.urls')),
)

any clues please?

-- 
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: Model for images with thumbnails

2012-01-06 Thread francescortiz
you can try https://github.com/francescortiz/image

On 6 ene, 12:35, MeME  wrote:
> Hello,
>
> I'm new to Django. I started to write something for personal
> purposes.
> I have doubts about writing model for media files, especially images.
> In my app thumbnails should be automatically created when image is
> uploaded. Each such image can have thumnails with different
> dimensions. Images can be attached to posts.
>
> The question is how to store such information in database?
>
> Should it be separate records for each thumbnail and main image? And
> how to keep relationship?
>
> Or maybe I could store everything in one record as a serialized data
> (as in Wordpress)? Then I could as well store there HTML for image and
> metadata.
>
> --
> Regards
> MM

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



Having trouble passing a parent table record “id” to a new record in a child table

2012-01-06 Thread BillB1951
I am having trouble passing a parent table record “id” to a new record
in a child table.  My urlconf calls add_childtable in my views.py and
passes the parenttable_id to it.  I have excluded the parenttable from
my ChildTableForm(ModelForm) because I do not want it to be available
to the users.  When I hit submit – from my form.html I get a
“KeyError” error message.  The parenttable field/column (a ForeighKey
field) does not want to accept the parenttable_id I am passing to it.

What am I doing wrong?  Example code snippets are always appreciated.

Thanks,
Bill

PS.   I notice that the code pasted in below seems to have messed up
some of the indenting, but its correct in my python files.




# models.py

class ChildTable(models.Model):
field1 = models.IntegerField(null=True, blank=True)
field2 = models.CharField(max_length=35, blank=True)
field3 = models.CharField(max_length=35, blank=True)
parenttable = models.ForeignKey(ParentTable)


class ChildTableForm(ModelForm):
class Meta:
model = ChildTable
exclude = ('parenttable',)

# views.py

def add_childtable(request, parenttable_id):
if request.method == 'POST':
form = ChildTableForm(request.POST)
if form.is_valid():
# create a new listing
childtable = ChildTable.objects.create(
field1=form.cleaned_data['field1'],built'],
field2=form.cleaned_data['field2'],built'],
field3=form.cleaned_data['field3'],built'],
parenttable=form.cleaned_data[parenttable_id],
)
# Always redirect after a POST
return http.HttpResponseRedirect('/appdir/childtable/%s/'
% childtable.id)
else:
# This the the first page load, display a blank form
form = ChildTableForm()
  context = Context({'title': 'Add ChildTableData', 'form': form})
context.update(csrf(request))
return render_to_response('appdir/form.html', context)

# form.html

http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
http://www.w3.org/1999/xhtml";>

  {{ title }}


  {{ title }}
   {% csrf_token %}
 
 {{ form.as_p }}

 
 
  




-- 
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: Model for images with thumbnails

2012-01-06 Thread Иван Иванов
На Fri, 6 Jan 2012 07:08:59 -0800 (PST)
francescortiz  написа:

> you can try https://github.com/francescortiz/image

or you can try https://github.com/SmileyChris/easy-thumbnails

> On 6 ene, 12:35, MeME  wrote:
> > Hello,
> >
> > I'm new to Django. I started to write something for personal
> > purposes.
> > I have doubts about writing model for media files, especially
> > images. In my app thumbnails should be automatically created when
> > image is uploaded. Each such image can have thumnails with different
> > dimensions. Images can be attached to posts.
> >
> > The question is how to store such information in database?
> >
> > Should it be separate records for each thumbnail and main image? And
> > how to keep relationship?
> >
> > Or maybe I could store everything in one record as a serialized data
> > (as in Wordpress)? Then I could as well store there HTML for image
> > and metadata.
> >
> > --
> > Regards
> > MM
> 

-- 
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: Model for images with thumbnails

2012-01-06 Thread Andres Reyes
I've found that the most flexible approach is the one taken by
http://thumbnail.sorl.net/

2012/1/6 Иван Иванов :
> На Fri, 6 Jan 2012 07:08:59 -0800 (PST)
> francescortiz  написа:
>
>> you can try https://github.com/francescortiz/image
>
> or you can try https://github.com/SmileyChris/easy-thumbnails
>
>> On 6 ene, 12:35, MeME  wrote:
>> > Hello,
>> >
>> > I'm new to Django. I started to write something for personal
>> > purposes.
>> > I have doubts about writing model for media files, especially
>> > images. In my app thumbnails should be automatically created when
>> > image is uploaded. Each such image can have thumnails with different
>> > dimensions. Images can be attached to posts.
>> >
>> > The question is how to store such information in database?
>> >
>> > Should it be separate records for each thumbnail and main image? And
>> > how to keep relationship?
>> >
>> > Or maybe I could store everything in one record as a serialized data
>> > (as in Wordpress)? Then I could as well store there HTML for image
>> > and metadata.
>> >
>> > --
>> > Regards
>> > MM
>>
>
> --
> 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.
>



-- 
Andrés Reyes Monge
armo...@gmail.com
+(505)-8873-7217

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



dumpdata and self referencing foreign keys

2012-01-06 Thread Michael Elkins
I have a model which represents a tree structure using a foreign 
key to itself:


class Foo(models.Model):
name = models.CharField(max_length=30)
parent = models.ForeignKey('Foo')

My problem is that "django-admin dumpdata" does not sort the rows 
such that it avoids forward references for the foriegn key values, 
which is a problem since I'm using MySQL InnoDB tables.  I see 
that this problem seems to be fixed in the devel tree 
(https://code.djangoproject.com/ticket/3615), but I just wanted to 
make sure there wasn't something I could easily do in the interim.


Since I know there are no circular references, I can write a 
script to postprocess the dumpdata output and reorder to avoid 
forward references.


Is there an easier alternative that I've missed?

Thanks!

me

--
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: Having trouble passing a parent table record “id” to a new record in a child table

2012-01-06 Thread Andre Terra
I introduce to you django-mptt: "utilities for implementing a modified
pre-order traversal tree in django".

https://github.com/django-mptt/django-mptt
http://django-mptt.github.com/django-mptt/


Cheers,
AT

On Fri, Jan 6, 2012 at 1:12 PM, BillB1951  wrote:

> I am having trouble passing a parent table record “id” to a new record
> in a child table.  My urlconf calls add_childtable in my views.py and
> passes the parenttable_id to it.  I have excluded the parenttable from
> my ChildTableForm(ModelForm) because I do not want it to be available
> to the users.  When I hit submit – from my form.html I get a
> “KeyError” error message.  The parenttable field/column (a ForeighKey
> field) does not want to accept the parenttable_id I am passing to it.
>
> What am I doing wrong?  Example code snippets are always appreciated.
>
> Thanks,
> Bill
>
> PS.   I notice that the code pasted in below seems to have messed up
> some of the indenting, but its correct in my python files.
>
>
>
>
> # models.py
>
> class ChildTable(models.Model):
>field1 = models.IntegerField(null=True, blank=True)
>field2 = models.CharField(max_length=35, blank=True)
>field3 = models.CharField(max_length=35, blank=True)
>parenttable = models.ForeignKey(ParentTable)
>
>
> class ChildTableForm(ModelForm):
>class Meta:
>model = ChildTable
>exclude = ('parenttable',)
>
> # views.py
>
> def add_childtable(request, parenttable_id):
>if request.method == 'POST':
>form = ChildTableForm(request.POST)
>if form.is_valid():
># create a new listing
>childtable = ChildTable.objects.create(
>field1=form.cleaned_data['field1'],built'],
>field2=form.cleaned_data['field2'],built'],
>field3=form.cleaned_data['field3'],built'],
>parenttable=form.cleaned_data[parenttable_id],
>)
># Always redirect after a POST
>return http.HttpResponseRedirect('/appdir/childtable/%s/'
> % childtable.id)
>else:
># This the the first page load, display a blank form
>form = ChildTableForm()
>  context = Context({'title': 'Add ChildTableData', 'form': form})
>context.update(csrf(request))
>return render_to_response('appdir/form.html', context)
>
> # form.html
>
>   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
> http://www.w3.org/1999/xhtml";>
> 
>  {{ title }}
> 
> 
>  {{ title }}
>   {% csrf_token %}
> 
> {{ form.as_p }}
>
> 
> 
>  
> 
> 
>
>
> --
> 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.



Avoid m2m relations to be saved

2012-01-06 Thread Mario8k
Hi,

I need to prevent to save a model overriding the ModelAdmin
save_model() method. When i try to avoid obj.save(), direct fields are
not saved, but related m2m fields are saved as well.

def save_model(self, request, obj, form, change):
if request.user.is_superuser:
obj.save()
else:
if change:
  #here i save another model but i never execute
obj.save()

How can I prevent to save m2m relations too? How I can achieve the
original object not be changed?

There is an old thread with the same issue:
http://groups.google.com/group/django-users/browse_thread/thread/1d6c03b2464a486/07b31c5c0acb6302?lnk=gst&q=save_model+%2B+m2m#07b31c5c0acb6302
Any solution?
Thanks,
Mario.

-- 
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: Having trouble passing a parent table record “id” to a new record in a child table

2012-01-06 Thread Daniel Roseman


On Friday, 6 January 2012 15:12:29 UTC, BillB1951 wrote:
>
> I am having trouble passing a parent table record “id” to a new record 
> in a child table.  My urlconf calls add_childtable in my views.py and 
> passes the parenttable_id to it.  I have excluded the parenttable from 
> my ChildTableForm(ModelForm) because I do not want it to be available 
> to the users.  When I hit submit – from my form.html I get a 
> “KeyError” error message.  The parenttable field/column (a ForeighKey 
> field) does not want to accept the parenttable_id I am passing to it. 
>
> What am I doing wrong?  Example code snippets are always appreciated. 
>
> Thanks, 
> Bill 
>
> PS.   I notice that the code pasted in below seems to have messed up 
> some of the indenting, but its correct in my python files. 
>
 
 

parenttable=form.cleaned_data[parenttable_id], 
>

Since parenttable_id isn't coming from the form, this won't work. It's a 
local variable, so just
parenttable = parenttable_id
should work.

However you're doing extra work by specifying the fields automatically - a 
modelform does that for you:

if form.is_valid(): 
childtable = form.save(commit=False)
childdtable.parenttable_id = parenttable_id
childtable.save()

Also, next time please remember to provide the actual error message + 
traceback when asking for help.
--
DR.

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



memcached, django 1.3: per-site caching with middleware

2012-01-06 Thread trewq
Hi Folks,

I am trying to get memcached working with django, and based on stats from 
the memcached, it is getting requests, but django is not sending it any 
thing. 

I created a question on 
stackoverflowand
 looks like a debugger and peering into the middleware maybe the next 
step. I wanted to find out if are aware of any issues for site-level 
caching with middleware. I upgraded memcached to 1.4.10 and am using django 
1.3.

-- 
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/-/nW2lLrWaw1YJ.
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: Model for images with thumbnails

2012-01-06 Thread BillB1951
You may want to check out a tutorial on lightbird.net

 link is:  http://www.lightbird.net/dbe/photo.html

Bill


On Jan 6, 6:35 am, MeME  wrote:
> Hello,
>
> I'm new to Django. I started to write something for personal
> purposes.
> I have doubts about writing model for media files, especially images.
> In my app thumbnails should be automatically created when image is
> uploaded. Each such image can have thumnails with different
> dimensions. Images can be attached to posts.
>
> The question is how to store such information in database?
>
> Should it be separate records for each thumbnail and main image? And
> how to keep relationship?
>
> Or maybe I could store everything in one record as a serialized data
> (as in Wordpress)? Then I could as well store there HTML for image and
> metadata.
>
> --
> Regards
> MM

-- 
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: molecular formulae

2012-01-06 Thread Mike Dewhirst

On 6/01/2012 8:03pm, Russell Keith-Magee wrote:

On Fri, Jan 6, 2012 at 1:43 PM, Mike Dewhirst  wrote:

I think I have found a workaround but it will probably blow up in my face
due to encoding/decoding things I don't fully understand.

Can anyone comment on the robustness of calling the following method in a
model's save() ...


Well... it will fail as soon as you have an sample of magnetite or
haematite (Fe3O4 and Fe2O3 respectively) -- your code capitalizes all
characters in the final else block, including the "e" in Fe.

However, if you fix the logic problem, and you set the server encoding
of your page to be UTF-8, and serve it with UTF-8 page headers, it
should work fine -- or at least as well as the font on your customer's
browser allows. See [1] for more details on what you need to do to
serve UTF-8.


I'm totally over quirks and IE6 so I'll stick to html5 for utf-8 in this 
project. It is only the prototype phase. When it acquires a team it will 
probably be a different story.




The other option is to use the  HTML tag; this provides slightly
better typographic support, since it's actually a typographic
subscript, rather than a unicode codepoint trying to emulate the
typography. This also won't be subject to any UTF-8 encoding problems.

If you look at the Wikipedia page for Iron Oxide [2], you'll see that
they use the  approach. Implementing a Django template filter to
convert "Fe2O3" into "Fe2O3" wouldn't be too
hard to do.


It does look much better. How does one persuade the Admin app that such 
data is safe?


Perhaps I'll stick with unicode for the prototype.

Thanks

Mike


[1] http://www.w3.org/International/articles/serving-xhtml/Overview.en.php
[2] http://en.wikipedia.org/wiki/Iron_oxide

Yours,
Russ Magee %-)



--
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: molecular formulae

2012-01-06 Thread Mike Dewhirst

On 7/01/2012 12:09am, aastrand wrote:

Also note that you have a math tag in html. Something like

  Fe_2_^2+^Cr_2_O_4_


I'd like to make it look really nice but I don't have a CSS expert (nor 
a chemical engineer!) on the team yet. It is just me at the moment and I 
think unicode is my limit for now. :)


Thanks

Mike



might do the job for you.

Per-Olof

On Jan 6, 1:41 pm, Mike Dewhirst  wrote:

I agree. I was wrong to try anything with the non-numerics. They need to be 
left as the user entered them.

Thanks

Mike

On 06/01/2012, at 8:46 PM, aastrand  wrote:








Unfortunately, an automatic capitalization routine would not work in
general. Take Co (the element cobolt) and CO (the molecule
carbonmonoxide) as an example. Nickel, Ni, would be another case; NI3
(nitrogen triiodide) is an explosive wheras Ni3 would be a small Ni
cluster. Capitalization has a meaning in chemistry and needs to be
provided by the user.



Per-Olof Åstrand



--
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 
athttp://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: dumpdata and self referencing foreign keys

2012-01-06 Thread Michael Elkins

On Fri, Jan 06, 2012 at 07:47:45AM -0800, Michael Elkins wrote:
My problem is that "django-admin dumpdata" does not sort the rows such 
that it avoids forward references for the foriegn key values, which is 
a problem since I'm using MySQL InnoDB tables.  I see that this 
problem seems to be fixed in the devel tree 
(https://code.djangoproject.com/ticket/3615), but I just wanted to 
make sure there wasn't something I could easily do in the interim.


Since I know there are no circular references, I can write a script to 
postprocess the dumpdata output and reorder to avoid forward 
references.


For future reference, I found a couple of interesting things:

If the model has "ordering = ('id',)" in its Meta, forward 
references will be avoided because the objects will be listed in 
the order they were created

http://www.pragmar.com/2010/01/16/django-dumpdataloaddata-import-errors-on-recursive-model/

The django-data-tools app 
(http://pypi.python.org/pypi/django-data-tools/0.1) enhances the 
dumpdata command in django-admin to deal with sorting tables by 
dependencies, including self-references.


I ended up creating a script using Django's serialization directly 
to create a dump of my table that can be imported with loaddata:


from django.core import serializers
import models

print serlializers.serialize('json', 
models.Foo.objects.all().ordered_by('id'), use_natural_keys=True)

--
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 the django coummity converging on a preferred REST API package?

2012-01-06 Thread JohnA
I’ve looked on this group, stackoverflow and the web at large for
indication that the django community is converging on a single REST
API package that is “preferred” and a potential candidate for
inclusion in a future django distribution.  So far all I’ve seen is
people saying positive or negative things about various packages or
the alternatives of writing yet another package or just winging it
with urlconfs and views.

It doesn’t seem to be a matter of "it depends what you want to
do" (though maybe required use or not of HTTP PUT and DELETE methods
could be a deciding factor).  I’m not an expert in REST, but the basic
requirements seem pretty clear to me – clean urls, multiple output
formats (xml, json etc.) and reliable and reasonably nonintrusive
authentication procedures – plus of course ease of implementation
including achieving wide coverage of base functionality with minimal
incremental code.

I guess what I'm asking is, what if any REST API package is emerging
as the leading solution, and if none, why not?   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: Url rewrite for search engines

2012-01-06 Thread Lie Ryan

On 01/07/2012 11:04 AM, Barış Bilgiç wrote:

Hi,

I am looking for how to implement URL rewrite in Django which is
explained inhttp://en.wikipedia.org/wiki/Rewrite_engine .

For example,I would like to convert

|http://127.0.0.1:8000/employer/details/20/| 
to|http://127.0.0.1:8000/employername-20.htm|

How can I implement this in Django? could suggest me a document or give
an example ?


you write your url to view mapping in urls.py, note that in django, you 
don't need to do a crude hack like "rewriting url" instead you specify 
that an url is to be specified by certain views.



--
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: {% url 'admin:jsi18n' as jsi18nurl %} error as urls.py

2012-01-06 Thread Brett Epps
I don't see an obvious problem with your urls.py file.  Have you tried
checking that you're not mixing tabs and spaces in that file's whitespace?

Brett


On 1/6/12 8:48 AM, "MikeKJ"  wrote:

>This is probably an oldie and I remember coming across it before but
>damned if I remember the solution:
>
>upgrading an old django site
>
>Request Method:GET
>Request URL: 
>   http://nortonsdairy.paston2.webfactional.com/admin/products/item/
>Django Version:1.3.1
>Exception Type:TemplateSyntaxError
>Exception Value:
>
>Caught SyntaxError while rendering: invalid syntax (urls.py, line 7)
>
>Exception Location:/home/paston2/webapps/nortons/lib/python2.7/
>django/utils/importlib.py in import_module, line 35
>Python Executable: /usr/local/bin/python
>Python Version:2.7.1
>Python Path:
>
>['/home/paston2/webapps/nortons',
> '/home/paston2/webapps/nortons/nortons',
> '/home/paston2/webapps/nortons/nortons/paston_stuff',
> '/home/paston2/webapps/nortons/lib/python2.7',
> '/home/paston2/webapps/nortons',
> '/home/paston2/webapps/nortons/lib/python2.7',
> '/usr/local/lib/python27.zip',
> '/usr/local/lib/python2.7',
> '/usr/local/lib/python2.7/plat-linux2',
> '/usr/local/lib/python2.7/lib-tk',
> '/usr/local/lib/python2.7/lib-old',
> '/usr/local/lib/python2.7/lib-dynload',
> '/usr/local/lib/python2.7/site-packages',
> '/usr/local/lib/python2.7/site-packages/PIL']
>In template /home/paston2/webapps/nortons/lib/python2.7/django/contrib/
>admin/templates/admin/change_list.html, error at line 11
>Caught SyntaxError while rendering: invalid syntax (urls.py, line 7)
>1  {% extends "admin/base_site.html" %}
>2  {% load adminmedia admin_list i18n %}
>3  {% load url from future %}
>4  {% block extrastyle %}
>5  {{ block.super }}
>6  
>7  {% if cl.formset %}
>8  
>9  {% endif %}
>10 {% if cl.formset or action_form %}
>11 {% url 'admin:jsi18n' as jsi18nurl %}
>12 
>13 {% endif %}
>14 {{ media.css }}
>15 {% if not actions_on_top and not actions_on_bottom %}
>16 
>17 #changelist table thead th:first-child {width: inherit}
>18 
>19 {% endif %}
>20 {% endblock %}
>21
>
>urls.py
>from django.conf.urls.defaults import *
>from django.conf import settings
>from django.contrib import admin
>
>admin.autodiscover()
>
>urlpatterns = patterns('',
>(r'^r/', include('django.conf.urls.shortcut')), # For the 'View on
>site' button in the admin
>(r'^admin/doc/', include('django.contrib.admindocs.urls')),
>(r'^admin/', include(admin.site.urls)),
>(r'^account/', include('accounts.urls')),
>(r'^order/', include('order.urls')),
>(r'^customer/', include('customers.urls')),
>(r'^news/', include('news.urls')),
>(r'^', include('smartpages.urls')),
>)
>
>any clues please?
>
>-- 
>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: Is the django coummity converging on a preferred REST API package?

2012-01-06 Thread Brett Epps
I used Tastypie for a project recently and was pretty happy with it.  I
think Piston was the preferred package before Tastypie came about, but
Piston hasn't seen as much development recently.  Then again, Piston seems
to be good enough for Bitbucket, so it's probably good enough for many
projects.

Sorry I can't offer much technical advice on this topic, as I'm no expert
on either package.  To answer your question, though: to me, Tastypie
"feels" like the preferred package currently.

Brett


On 1/6/12 3:25 PM, "JohnA"  wrote:

>I¹ve looked on this group, stackoverflow and the web at large for
>indication that the django community is converging on a single REST
>API package that is ³preferred² and a potential candidate for
>inclusion in a future django distribution.  So far all I¹ve seen is
>people saying positive or negative things about various packages or
>the alternatives of writing yet another package or just winging it
>with urlconfs and views.
>
>It doesn¹t seem to be a matter of "it depends what you want to
>do" (though maybe required use or not of HTTP PUT and DELETE methods
>could be a deciding factor).  I¹m not an expert in REST, but the basic
>requirements seem pretty clear to me ­ clean urls, multiple output
>formats (xml, json etc.) and reliable and reasonably nonintrusive
>authentication procedures ­ plus of course ease of implementation
>including achieving wide coverage of base functionality with minimal
>incremental code.
>
>I guess what I'm asking is, what if any REST API package is emerging
>as the leading solution, and if none, why not?   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.
>

-- 
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 many Django web pages does it take . . .

2012-01-06 Thread Bill Beal
Hi all,

I've been doing Django and mostly backend Python for a few months, and
I don't really know the limits of what can be done without resorting
to JavaScript and Ajax. Here's what I need to do: the user wants to
pick an individual from one of a number of lists and have the detailed
information come up editable for the one picked. My top-level list is
[Lions, Tigers, Bears, All]. The user picks Tigers, and then I present
the second-level Tigers list: [Tony, Hobbes, Tigger, Rajah]. The user
picks Hobbes, and then I present the detailed information for Hobbes
in an editable form: name, address etc. How clunky does this have to
be, in terms of mouse clicks and pages downloaded? I've read in more
than one place that if you use JavaScript you'd better have a version
of your page that works OK without it.

For extra credit, what high-powered tools would be needed to do
autocompletion, for example the user starts typing "Hobbes" into the
Name field and as soon as I find a unique match I present the details?
Or, show a list of possible matches when the partial field is not
unique?

I've been reading books, but most of them just show me how to build a
particular kind of website using Django.

Thanks for any help you can lend!

Bill Beal

-- 
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: many-to-many queryset question

2012-01-06 Thread Peter of the Norse
One possibility is to try two excludes.

bad_authors = Authors.objects.exclude(pk__in=SetOfAuthors)
qs = Entry.objects.exclude(authors__in=bad_authors)

This will return all entries that don't have authors in SetOfAuthors. It might 
even be easier, if you can skip creating SetOfAuthors in the first place.

On Dec 6, 2011, at 12:19 PM, Felipe Morales wrote:

> could you possibly show the query generated?... 
> 
> # print qs.query
> 
> 2011/12/6 Carsten Fuchs 
> Hi all,
> 
> looking at the example models Author and Entry at 
> https://docs.djangoproject.com/en/1.3/topics/db/queries/, I would like to run 
> a query like this:
> 
>SetOfAuthors = Authors.objects.filter(...)
>qs = Entry.objects.filter(authors__in=SetOfAuthors)
> 
> such that (pseudo-code):
> 
>for e in qs:
>"e.authors is a subset of (or equal to) SetOfAuthors"
> 
> However, when I try it, the true result seems to be an intersection:
> 
>for e in qs:
>"There is (at least one) an author in e.authors that is also 
> in SetOfAuthors"
> 
> 
> How do I have to phrase the query in order to obtain only entries whose 
> authors are all in SetOfAuthors?
> 
> Best regards,
> Carsten
> 
> 
> 
> -- 
>   Cafu - the open-source Game and Graphics Engine
> for multiplayer, cross-platform, real-time 3D Action
>  Learn more at http://www.cafu.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.
> 
> 
> 
> 
> -- 
> Felipe Morales C.
> Ingenierío de Ejecución en Computación e Informática.
> 
> 
> -- 
> 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.

Peter of the Norse
rahmc...@radio1190.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.



Re: How many Django web pages does it take . . .

2012-01-06 Thread Alec Taylor
What you are talking about is a form.

Form: https://docs.djangoproject.com/en/dev/topics/forms/
Autocomplete: https://code.djangoproject.com/wiki/AutoCompleteSolutions
Unique fields: https://docs.djangoproject.com/en/1.3/ref/forms/validation/

On Sat, Jan 7, 2012 at 11:56 AM, Bill Beal  wrote:
> Hi all,
>
> I've been doing Django and mostly backend Python for a few months, and
> I don't really know the limits of what can be done without resorting
> to JavaScript and Ajax. Here's what I need to do: the user wants to
> pick an individual from one of a number of lists and have the detailed
> information come up editable for the one picked. My top-level list is
> [Lions, Tigers, Bears, All]. The user picks Tigers, and then I present
> the second-level Tigers list: [Tony, Hobbes, Tigger, Rajah]. The user
> picks Hobbes, and then I present the detailed information for Hobbes
> in an editable form: name, address etc. How clunky does this have to
> be, in terms of mouse clicks and pages downloaded? I've read in more
> than one place that if you use JavaScript you'd better have a version
> of your page that works OK without it.
>
> For extra credit, what high-powered tools would be needed to do
> autocompletion, for example the user starts typing "Hobbes" into the
> Name field and as soon as I find a unique match I present the details?
> Or, show a list of possible matches when the partial field is not
> unique?
>
> I've been reading books, but most of them just show me how to build a
> particular kind of website using Django.
>
> Thanks for any help you can lend!
>
> Bill Beal
>
> --
> 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.