Re: Import Error: cannot import name timezone

2013-08-25 Thread Robin Lery
Good to hear that!


On Sun, Aug 25, 2013 at 7:19 AM, Patrick Larmann  wrote:

> Thanks fixed it?
>
>
> On Saturday, August 24, 2013 5:45:47 PM UTC-4, Robin Lery wrote:
>
>> It should be
>> 'from django.utils import timezone'
>> and not
>> 'from django.db.utils import timezone'
>>
>>
>> On Sun, Aug 25, 2013 at 2:58 AM, Patrick Larmann 
>> wrote:
>>
>>> He Guys,
>>> I am currently completing part 1 of the django tutorial and having
>>> trouble with getting on of the modules correctly set up.
>>> I attached my output and my moduls.py file.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@**googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>>
>>> Visit this group at 
>>> http://groups.google.com/**group/django-users
>>> .
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out
>>> .
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


DecimalField

2013-08-25 Thread Derrick Jackson
Hi All,

My Model has a DecimalField:

amount = models.DecimalField(max_digits=19, decimal_places=2,
verbose_name='Amount')

My ModelForm has the following:

self.fields['amount'] = forms.DecimalField(error_messages={
'required': 'Amount is required.',
'invalid': 'Numbers only.',
'max_decimal_places': 'Only 2 decimal places.'})

However the max_decimal_places validation check does not seem to be
working.  Is there a certain way I need to use this that will properly
allow the error to be thrown?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: DecimalField

2013-08-25 Thread Thomas Scrace
You're creating an entirely new DecimalField, rather than altering the error 
messages of your existing field.

I think what you want is:

class  YourForm(forms.ModelForm):

def __init__(self, *args, **kwargs):
super(YourForm, self).__init__(*args, **kwargs)
self.fields["amount"].error_messages= {
'required': 'Amount is required.',
'invalid': 'Numbers only.',
'max_decimal_places': 'Only 2 decimal places.'}

Tom


On 25 Aug 2013, at 10:47, Derrick Jackson  wrote:

> Hi All,
> 
> My Model has a DecimalField:  
> 
> amount = models.DecimalField(max_digits=19, decimal_places=2, 
> verbose_name='Amount')
> 
> My ModelForm has the following:  
> 
> self.fields['amount'] = forms.DecimalField(error_messages={
> 'required': 'Amount is required.',
> 'invalid': 'Numbers only.',
> 'max_decimal_places': 'Only 2 decimal places.'})
> 
> However the max_decimal_places validation check does not seem to be working.  
> Is there a certain way I need to use this that will properly allow the error 
> to be thrown?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Model QuerySet used in base.html template

2013-08-25 Thread Radomir Wojcik
I wanted to add location address in the menu. I have a model called 
locations so this is easy enough to do. But now I have to add the queryset 
to every view, because every view has a template that extends base.html. 
 So do I have to add this queryset as such to every view now?

locations = Location.objects.all()


or is there a way to do this so I associate a view that always runs on 
every page to get the locations queryset? There are many ways to do this 
but I wanted to know what best practice suggests.

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Model QuerySet used in base.html template

2013-08-25 Thread Radomir Wojcik
I am actually thinking using some sort of templatetag now instead of 
passing the query each time since its used in base.html. It can return the 
exact html string that can be displayed in base.html.  Right now I have the 
" locations = Location.objects.all() " passed to the template in every 
single view.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Model QuerySet used in base.html template

2013-08-25 Thread Kamil Gałuszka
Hi Radomir,

If you have something like that you should use in my opinion template 
context processor. It's very easy to write one, because it's simple python 
function.

Here you have some context_processor from django 
core: 
https://github.com/django/django/blob/master/django/core/context_processors.py

And here docs:
https://docs.djangoproject.com/en/dev/ref/templates/api/#basics

Cheers,
Kamil Galuszka

On Sunday, August 25, 2013 1:04:01 PM UTC+2, Radomir Wojcik wrote:
>
> I am actually thinking using some sort of templatetag now instead of 
> passing the query each time since its used in base.html. It can return the 
> exact html string that can be displayed in base.html.  Right now I have the 
> " locations = Location.objects.all() " passed to the template in every 
> single view.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Model QuerySet used in base.html template

2013-08-25 Thread Radomir Wojcik
I simply added an assignment tag instead as follows:

@register.assignment_tag
def get_locations():
from store.models import Location

locations = list(Location.objects.all())

return locations 


And use it like so in template

{% get_locations as all_locations %}

then can iterate through it 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Model QuerySet used in base.html template

2013-08-25 Thread Radomir Wojcik
Hey Kamil,

Isn't that overkill though? templatetag was an easy solution but you still 
do a query on the locations model on each page load.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Model QuerySet used in base.html template

2013-08-25 Thread Kamil Gałuszka
I'm just preferring if something have to be done before template rendering 
and store that in context variable.

Difference to your solution is that variables are just only created before 
starting template rendering.

In your solution you evaluate QuerySet in template rendering time. 
Sometimes is just bad idea because, you want to separate view stuff from 
template rendering (especially that django rendering time is sometimes just 
slower than for example jinja2). 

But it's just my opinion. I'm maybe wrong :) . Feel free to do what you 
suits best your needs. :)

Cheers,
Kamil 

On Sunday, August 25, 2013 3:58:55 PM UTC+2, Radomir Wojcik wrote:
>
> Hey Kamil,
>
> Isn't that overkill though? templatetag was an easy solution but you still 
> do a query on the locations model on each page load.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: pycharm constant error

2013-08-25 Thread Patrick Larmann
Hello,
Thx Mike for the advice. Will do!

On Sunday, August 25, 2013 12:09:13 AM UTC-4, Mike Dewhirst wrote:
>
> On 25/08/2013 1:21pm, Patrick Larmann wrote: 
> > Hello, 
> > Thanks for your response. I reinstalled it but am still getting the 
> > error. How would I do a full revert? 
>
> $ pip uninstall django 
>
> followed by 
>
> $ pip install django 
>
> If you haven't got pip installed you need to get it. 
> https://pypi.python.org/pypi/pip 
>
> Also, I would start again with the tutorials in a fresh directory and 
> use a plain text editor (Notepad++ or Textpad for me) with Python syntax 
> highlighting rather than Pycharm. 
>
> Once you get your head around the tutorials and have a reasonable feel 
> for Django you will be more comfortable with Pycharm. I think an IDE is 
> vital if you are developing a project with your own separate libraries 
> and you are in and out of them making changes all the time. Otherwise, 
> (for me) it is easier to have a bunch of Textpad or Notepad++ windows 
> with all the code I want to work on or refer to. 
>
> Mike 
>
> > Thx! 
> > 
> > On Saturday, August 24, 2013 11:02:38 PM UTC-4, Mike Dewhirst wrote: 
> > 
> > On 25/08/2013 11:56am, Patrick Larmann wrote: 
> >  > Hello guys, 
> >  > I really appreciate the help. I have a problem with Pycharm. I am 
> >  > getting this constant error in my runserver.py in both of my 
> > projects. I 
> >  > did not modify or touch the file, and yet the error persists. 
> >  > I attached a screenshot. 
> > 
> > It looks (to me) as though you are editing a part of Django itself. 
> > Although it is open source you need to really know what you are 
> > doing if 
> > that is your focus. 
> > 
> > I would revert any changes made to django and stay within my own 
> code. 
> > 
> > hth 
> > 
> > 
> >  > Thanks for the help, guys. 
> >  > 
> >  > -- 
> >  > You received this message because you are subscribed to the 
> Google 
> >  > Groups "Django users" group. 
> >  > To unsubscribe from this group and stop receiving emails from it, 
> > send 
> >  > an email to django-users...@googlegroups.com . 
> >  > To post to this group, send email to django...@googlegroups.com 
> > . 
> >  > Visit this group at http://groups.google.com/group/django-users 
> > . 
> >  > For more options, visit https://groups.google.com/groups/opt_out 
> > . 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Django users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> > an email to django-users...@googlegroups.com . 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > Visit this group at http://groups.google.com/group/django-users. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Passing variables to css file in django

2013-08-25 Thread Robin Lery
Is it possible to pass variables in css files, like in html file. Example:


In views.py:

def home(request):
bgcolor = "#999"
...
...

In the css file:

body {
background-color : {{bgcolor}};
}


If yes, can you please guide me how to achieve this? I would really
appreciate. Thank you!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Research study: Structuring software documentation around tasks and concepts

2013-08-25 Thread Christoph Treude
Hi,

We are a group of researchers in the School of Computer Science at McGill 
University working on a tool to extract meaningful tasks and concepts from 
the documentation available on https://docs.djangoproject.com/en/dev/. To 
evaluate whether our extraction was successful, we are looking for 
participants for a study. As a participant, you will be asked to answer a 
simple yes/no question for a sample of 25 tasks and 25 concepts we have 
extracted. We expect that this will take half an hour of your time at most.

All participants will be entered in a draw for two gift certificates from 
Amazon. Each certificate will be worth $100. With 20 participants, chances 
of winning a gift certificate will be 1 in 10.

If you're interested in participating in this study, please contact me via 
e-mail at christoph.treude[at]mail.mcgill.ca. 

The ultimate goal of this research is to help you search and navigate the 
documentation available on https://docs.djangoproject.com/en/dev/. By the 
end of our project, we hope to develop a search interface to make it easier 
and more efficient to navigate the Django documentation.

Thank you!
  Christoph

--
Christoph Treude, Principal Investigator
Postdoctoral Fellow at School of Computer Science, McGill University
3480 University Street
Montréal, QC  H3A 0E9  Canada

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Passing variables to css file in django

2013-08-25 Thread Andy McKay
Any string can be rendered as a template. This is covered pretty well in
the docs:

https://docs.djangoproject.com/en/dev/ref/templates/api/

For example:

>>> from django.template import Context, Template
>>> t = Template("body { background-color: {{ bgcolor }} }")
>>> c = Context({'bgcolor': '#999'})
>>> t.render(context=c)
u'body { background-color: #999 }'

However, CSS is served fastest if it's static and on a CDN and not using a
template and CPU resources to render.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Single form displayed multiple times on one page with different values.

2013-08-25 Thread Brian Millham
I have the this simple form:

class MistagForm(forms.Form):
artist = forms.CharField()

And I want to display it on a page more than once. The page is a list of 
artists, and each artist has a link to the above form that will be a popup 
form.

I want the default value of artist in the form to show as the actual name 
of the artist, so each instance of the form will be bound to a different 
artist name.

I can't figure out a way in the template to set the value of the artist 
input field to the name of each different artist. I don't think that 
setting the initial values of the form(s) in the view would work, as there 
can be hundreds of artists on a page.

I need something like {{form.artist|default:model.artist}} but I know from 
research (and trying) that this does not work.

I didn't mention that the popup forms are generated when the page loads, 
not when the link to the popup is clicked. (they are hidden until the link 
is clicked)

And I'm avoiding the use of the javascript virus :-D

Thanks for any pointers!
Brian

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Passing variables to css file in django

2013-08-25 Thread Robin Lery
Oh! I am sorry. What I meant was, how do I let users customize their page
if they wanted to? I suppose I could have done this without using external
stylesheet, but yes, CSS is served fastest if it's static. I hope, I made
myself clear. Please guide me if there's a way to achive this


On Mon, Aug 26, 2013 at 5:39 AM, Andy McKay  wrote:

> Any string can be rendered as a template. This is covered pretty well in
> the docs:
>
> https://docs.djangoproject.com/en/dev/ref/templates/api/
>
> For example:
>
> >>> from django.template import Context, Template
> >>> t = Template("body { background-color: {{ bgcolor }} }")
> >>> c = Context({'bgcolor': '#999'})
> >>> t.render(context=c)
> u'body { background-color: #999 }'
>
> However, CSS is served fastest if it's static and on a CDN and not using a
> template and CPU resources to render.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Model QuerySet used in base.html template

2013-08-25 Thread Radomir Wojcik
I have to run some benchmarks and see. I am using SQLite and I have heard 
some people say that it cannot handle concurrent transactions. From what I 
read it can handle some 50,000 transactions/ sec depending on your disk IO. 
 For a small deli website I take it should be fine, even if the user plans 
to load up the database with over 1000 items.  I'll see how it copes with 
transaction handling as its more mature, and then maybe I will switch to a 
context processor and maybe a different database :)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: pycharm constant error

2013-08-25 Thread Ezequiel Bertti
isn't a pycharm error, is your's.

Your *args must to be on end of method definition, before of **kwargs






On Sun, Aug 25, 2013 at 12:41 PM, Patrick Larmann <
rails4product...@gmail.com> wrote:

> Hello,
> Thx Mike for the advice. Will do!
>
>
> On Sunday, August 25, 2013 12:09:13 AM UTC-4, Mike Dewhirst wrote:
>
>> On 25/08/2013 1:21pm, Patrick Larmann wrote:
>> > Hello,
>> > Thanks for your response. I reinstalled it but am still getting the
>> > error. How would I do a full revert?
>>
>> $ pip uninstall django
>>
>> followed by
>>
>> $ pip install django
>>
>> If you haven't got pip installed you need to get it.
>> https://pypi.python.org/pypi/**pip 
>>
>> Also, I would start again with the tutorials in a fresh directory and
>> use a plain text editor (Notepad++ or Textpad for me) with Python syntax
>> highlighting rather than Pycharm.
>>
>> Once you get your head around the tutorials and have a reasonable feel
>> for Django you will be more comfortable with Pycharm. I think an IDE is
>> vital if you are developing a project with your own separate libraries
>> and you are in and out of them making changes all the time. Otherwise,
>> (for me) it is easier to have a bunch of Textpad or Notepad++ windows
>> with all the code I want to work on or refer to.
>>
>> Mike
>>
>> > Thx!
>> >
>> > On Saturday, August 24, 2013 11:02:38 PM UTC-4, Mike Dewhirst wrote:
>> >
>> > On 25/08/2013 11:56am, Patrick Larmann wrote:
>> >  > Hello guys,
>> >  > I really appreciate the help. I have a problem with Pycharm. I
>> am
>> >  > getting this constant error in my runserver.py in both of my
>> > projects. I
>> >  > did not modify or touch the file, and yet the error persists.
>> >  > I attached a screenshot.
>> >
>> > It looks (to me) as though you are editing a part of Django itself.
>> > Although it is open source you need to really know what you are
>> > doing if
>> > that is your focus.
>> >
>> > I would revert any changes made to django and stay within my own
>> code.
>> >
>> > hth
>> >
>> >
>> >  > Thanks for the help, guys.
>> >  >
>> >  > --
>> >  > You received this message because you are subscribed to the
>> Google
>> >  > Groups "Django users" group.
>> >  > To unsubscribe from this group and stop receiving emails from
>> it,
>> > send
>> >  > an email to django-users...@googlegroups.**com .
>> >  > To post to this group, send email to django...@googlegroups.com
>> > .
>> >  > Visit this group at http://groups.google.com/**
>> group/django-users 
>> > 
>> > >.
>>
>> >  > For more options, visit https://groups.google.com/**
>> groups/opt_out 
>> > 
>> > >.
>>
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "Django users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an email to django-users...@**googlegroups.com.
>> > To post to this group, send email to django...@googlegroups.com.
>> > Visit this group at 
>> > http://groups.google.com/**group/django-users.
>>
>> > For more options, visit 
>> > https://groups.google.com/**groups/opt_out.
>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Ezequiel Bertti
E-Mail: eber...@gmail.com
Cel: (21) 9188-4860

VÁ PARA BÚZIOS!!!
http://www.agh.com.br/
Ane Guest House

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Single form displayed multiple times on one page with different values.

2013-08-25 Thread Lachlan Musicman
I think I solved a similar problem with Formsets and Model Formsets?

cheers
L.

On 26 August 2013 10:48, Brian Millham  wrote:
> I have the this simple form:
>
> class MistagForm(forms.Form):
> artist = forms.CharField()
>
> And I want to display it on a page more than once. The page is a list of
> artists, and each artist has a link to the above form that will be a popup
> form.
>
> I want the default value of artist in the form to show as the actual name of
> the artist, so each instance of the form will be bound to a different artist
> name.
>
> I can't figure out a way in the template to set the value of the artist
> input field to the name of each different artist. I don't think that setting
> the initial values of the form(s) in the view would work, as there can be
> hundreds of artists on a page.
>
> I need something like {{form.artist|default:model.artist}} but I know from
> research (and trying) that this does not work.
>
> I didn't mention that the popup forms are generated when the page loads, not
> when the link to the popup is clicked. (they are hidden until the link is
> clicked)
>
> And I'm avoiding the use of the javascript virus :-D
>
> Thanks for any pointers!
> Brian
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
Maya Otos (@maya_otos) tweeted at 9:27 PM on Tue, Jul 30, 2013:
When you used to be punk, and now you are still punk but not as punk,
are you post-punk or decaying punk or ex-punk or just not punk anymore

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Unicode sort order for CharField data in several scripts

2013-08-25 Thread Will Tuladhar-Douglas
Gentlefolk,

We have a research database (GeoDjango 1.5.1 on Postgres 9.2/PostGIS 2.0) 
including one model for words in any human language, where these words are 
entered in locally legible scripts (thus Sanskrit or Newari terms are in 
Devanagari, Persian in Perso-Arabic, Mandarin in Traditional Chinese, and 
Latin or English in Roman script). The problem is that the only script that 
sorts correctly is the Roman. This makes sense given the limits of 
LC_COLLATE in Postgres; collations are always local, such as en_gb.UTF8, 
and the only ‘global’ collations are C and POSIX, which sort by bit order 
and not by the Unicode Collation Algorithm. So far as I know there is no 
implementation of the Unicode Collation Algorithm within Postgres.

There is a pyuca module available on pypi, but I'm not a good enough coder 
to see how to wire it into the Django ORM to enable true Unicode sorts. Has 
anyone tackled this problem before? 


The relevant bit of the model reads:

class Name(models.Model):
def __unicode__(self):
return self.nomen + u" (" + self.language + u")"

class Meta:
ordering = ('language', 'nomen',)
verbose_name = 'lexical item'
verbose_name_plural = 'lexical items'

name_id = models.AutoField(primary_key=True)
uuid = uuidfield.UUIDField(auto=True)
nomen = models.CharField(max_length=200, help_text="Please enter the 
name in an accurate script.")
language = models.CharField(max_length=40, default="Latin", 
help_text="Please use standard language names or codes as defined in the 
ISO 639 standard.")


Many thanks,

-WBTD.
- - -- --- -  -
Will Tuladhar-Douglas
University of Aberdeen

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: django template loop collections.defaultdict(lambda: collections.defaultdict(list))

2013-08-25 Thread Daviddd
Thanks Tom for replying! 

The code used to create the dict is:

my_dict = collections.defaultdict(lambda: collections.defaultdict(list))
for obj in queryset:

my_dict[int(obj.position.split('-')[0])][int(obj.position.split('-')[2])].append(obj)

Basically I have one field in the queryset called position (the format is 
N-N-N-N) and I need to create the dict as in my question.
Sincerely, I don't know how I can create the dict without using defaultdict.

D

On Saturday, August 24, 2013 2:51:56 PM UTC+2, tom wrote:
>
> On 23 Aug 2013, at 16:58, Daviddd > 
> wrote:
>
> In my template I tried:
>
> {% for key, groups in queryset.iteritems %}
> groups = {{ groups }} 
> {% for group_key, cols in groups.iteritems %}
>   cols = {{ group_key }} 
>   {% for objs in cols %}
>   {# rest of the code #}  
>
>
> But only the first loop is evaluated
>
> groups = (1, defaultdict(, {1: [,  Obj 2 by daviddd>, ], 2: [], 3: 
> [, , ]}))
> groups = (2, defaultdict(, {1: []}))
> groups = (3, defaultdict(, {1: []}))
>
>
>
> Maybe I'm misreading, but aren't your inner "groupses" still defaultdicts? 
> I think they need to be coerced to normal dicts in order for Django's 
> template system to be able to properly iterate over them.
>
> Tom
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.