Re: moving to django 1.2.1

2010-07-29 Thread shofty
wasnt there some good stuff on djangoadvent?

http://djangoadvent.com/1.2/django-12-and-csrf/

Matt

On Jul 28, 2:44 pm, knight  wrote:
> Does anybody knows a good post or blog about the changes including
> csrf?
>
> On Jul 28, 4:33 pm, Maksymus007  wrote:
>
> > On Wed, Jul 28, 2010 at 3:29 PM, Massimiliano Ravelli
>
> >  wrote:
> > > On Jul 28, 3:13 pm, knight  wrote:
> > >> What are the minimal changes that I need to make in order to work with
> > >> 1.2.1?
>
> > > Did you have a look 
> > > athttp://code.djangoproject.com/wiki/BackwardsIncompatibleChanges
> > > ?
>
> > This link in worth nothing.
> > The same all the sentences link '1.1 and 1.2 are compatible'.
> > They are not.
>
> > I have quite big application written in 1.1 - still can't fully run it on 
> > 1.2.
> > As I discovered: forms fields set to be blank=True and null=True when
> > left blank on 1.1 get null value as expected, on 1.2 the get empty
> > string - which crashes if database has constraints.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: moving to django 1.2.1

2010-07-29 Thread Russell Keith-Magee
On Wed, Jul 28, 2010 at 9:29 PM, Massimiliano Ravelli
 wrote:
> On Jul 28, 3:13 pm, knight  wrote:
>> What are the minimal changes that I need to make in order to work with
>> 1.2.1?
>
> Did you have a look at 
> http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges
> ?

As it says at the top of that wiki page, that page documents the
backwards incompatible changes that were made in the leadup to Django
1.0.

If you want migration notes for Django 1.1 or 1.2, you should consult
the relevant release notes:

[1] http://docs.djangoproject.com/en/dev/releases/1.1/
[2] http://docs.djangoproject.com/en/dev/releases/1.2/

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-us...@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: moving to django 1.2.1

2010-07-29 Thread Russell Keith-Magee
On Wed, Jul 28, 2010 at 9:33 PM, Maksymus007  wrote:
> On Wed, Jul 28, 2010 at 3:29 PM, Massimiliano Ravelli
>  wrote:
>> On Jul 28, 3:13 pm, knight  wrote:
>>> What are the minimal changes that I need to make in order to work with
>>> 1.2.1?
>>
>> Did you have a look at 
>> http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges
>> ?
>
> This link in worth nothing.
> The same all the sentences link '1.1 and 1.2 are compatible'.
> They are not.
>
> I have quite big application written in 1.1 - still can't fully run it on 1.2.
> As I discovered: forms fields set to be blank=True and null=True when
> left blank on 1.1 get null value as expected, on 1.2 the get empty
> string - which crashes if database has constraints.

That's a very big claim. Simply upgrading to 1.2 shouldn't require any
changes to your source code unless you were relying upon internal APIs
or behavior that was buggy in v1.1.

We take backwards compatibility very seriously, so if you think you've
found a regression, please open a ticket describing the specific
problem. If you have already opened a ticket for this problem, then
please let me know the ticket number.

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-us...@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: moving to django 1.2.1

2010-07-29 Thread knight
Thank you all for the links and advises.
It really helps me.

Regards, Alex A.

On Jul 29, 10:32 am, Russell Keith-Magee 
wrote:
> On Wed, Jul 28, 2010 at 9:29 PM, Massimiliano Ravelli
>
>  wrote:
> > On Jul 28, 3:13 pm, knight  wrote:
> >> What are the minimal changes that I need to make in order to work with
> >> 1.2.1?
>
> > Did you have a look 
> > athttp://code.djangoproject.com/wiki/BackwardsIncompatibleChanges
> > ?
>
> As it says at the top of that wiki page, that page documents the
> backwards incompatible changes that were made in the leadup to Django
> 1.0.
>
> If you want migration notes for Django 1.1 or 1.2, you should consult
> the relevant release notes:
>
> [1]http://docs.djangoproject.com/en/dev/releases/1.1/
> [2]http://docs.djangoproject.com/en/dev/releases/1.2/
>
> 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-us...@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: ModelChoiceField Question

2010-07-29 Thread Daniel Roseman
On Jul 29, 5:23 am, Carlos Daniel Ruvalcaba Valenzuela
 wrote:
> Hello list,
>
> I was wondering which would be the best way to handle this situation
> with ModelChoiceFields:
>
> I have a form with a ModelChoiceField, the options presented in this
> field may change at the view depending on the user, however,
> ModelChoiceField requires the queryset to be given as a parameter when
> defining the form, which is the best way to handle this? is there a
> commonly used way for this? I was thinking on using a Factory method
> like this:
>
> def MyForm_builder(queryset):
>     class MyForm(forms.Form):
>         field = forms.ModelChoiceField(queryset=queryset)
>     return MyForm
>
> Any thoughts on this?
>
> Regards,
> Carlos Daniel Ruvalcaba Valenzuela

You can easily override the __init__ method to change the queryset on
form instantiation, by passing in an extra `user` keyword arg:

def MyForm(forms.Form):
field =
forms.ModelChoiceField(queryset=MyModel.objects.none())

def __init__(self, *args, **kwargs):
user = kwargs.pop('user', None)
super(MyForm, self).__init__(*args, **kwargs)
self.fields['field'].queryset =
MyModel.objects.filter(user=user)

--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Python/Django hosting

2010-07-29 Thread kostia
Currently looking at. So many choices!
I'm a person with not enough money.

What do you think about Canadian https://servqc.net/ one? It is very
cheap from the list.

I live in Ukraine. For me it is better to pick up European or US host?

Kostia

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: HTTP POST sent from app to Django Server returns 403 Forbidden

2010-07-29 Thread Benedict Verheyen
On 28/07/2010 18:22, Kieran Farr wrote:
> Thanks, David -- you're right on, now I just return an HttpResponse
> with result code 404.
> 
> Benedict, could you post the view for /management/statistics/top/user/
> yearly/ that is causing the 403?
> 
> Kieran
> 

Yes,


here it is.
Depending on wether the user logged in is staff (ICT) or not, i use
a different base toe extend my template from (different menu).

@csrf_exempt
def stats_top_callers_per_year(request):
if ( request.user.is_staff ):
extends_from = "management/base.html"
else: extends_from = "management/public_base.html"
stat_type = "top_callers_per_year"
stats_all = {}
message=_(u"Top 30 callers per year")
class Stats(object):
pass
current_year = datetime.datetime.now().year
archive_year = current_year - 4
years = xrange(archive_year, current_year+1)
for year in years:
stats_year = []
counts = {}
# Initialize count dict
# If we don't do this, we get a KeyError
for user in User.objects.all():
counts[user]=0
# Count the times an initiator has been calling
for i in Call.objects.filter(date_created__year=year):
for _init in i.initiator.all():
counts[_init] += 1
# Sort the dictionary
count_sorted = sorted(counts.items(), lambda x, y: cmp(x[1], y[1]), 
reverse=True)
# Make the stats ready for the template
for user_stat in count_sorted[0:30]:
if ( user_stat[1] > 0 ):
st = Stats()
st.calls = user_stat[1]
st.user = user_stat[0]
stats_year.append(st)
stats_all[year]=stats_year
stats_sorted = sorted(stats_all.items(), lambda x, y: cmp(x[0], y[0]), 
reverse=True)
return render_to_response('management/stats.html', {'extends_from': 
extends_from, 'stats_year': stats_sorted, 'message': message,
'stat': stat_type, 'tab': "top_callers_per_year"}, 
context_instance=RequestContext(request))

My goal is to be able to automatically login (seems to work) and then call this 
function so
the page is generated before any user hits the page.

Regards,
Benedict

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Best way to present N items in table row for list

2010-07-29 Thread Roald de Vries

Hi Wadim,

On Jul 27, 2010, at 6:51 PM, Wadim wrote:

Hello.
I have a list that i want to present in a table.
Each row should have 5 items.
For now i create the function that returns me new grouped list, that i
use later in a template.
def groupListByRow(list):
cnt=0
rows=[]
while cnt


First: list is a very unlucky name for a parameter, since it's the  
type of []


Second: list comprehension rules!

def groupListByRow(list):
return [lst[start:start+5] for start in range(0, len(lst), 5)]

Cheers, Roald

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Calculate distance between 2 latitude/longitude Point

2010-07-29 Thread Alexandre González
I going to try it now, but the unique results that I obtain in google
searching [1] gd2gcc is this thread :)

[1]
http://www.google.com/search?hl=en&safe=off&q=gd2gcc&aq=f&aqi=&aql=&oq=&gs_rfai=

Did
you make some mistake writting it?

Thanks,
Álex González

On Wed, Jul 28, 2010 at 19:34, !!CONDORIOUS!!  wrote:

> (lat , lon in radians)
>
> pt 1 = lat, lon, alt=0
> pt 2 = lat, lon, alt=0
>
> p1_gcc = gd2gcc(p1)
> p1_gcc = gd2gcc(p2)
>
> gd2gcc ( is a standard operation found on the itnernet)
>
> dis = sqrt(sum(pow(p1_gcc-p2-gcc, 2)))
>
> cheers,
>
> 2010/7/28 Alexandre González :
> > Hi! I'm using the Django GEOS API [1] in my project to see the distance
> > between two users.
> > I get the coordinates from google maps in latitude/longitude mode and I
> need
> > to calculate the distance between them. I'm testing with .distance()
> method
> > at GEOSGeometry but I receive a strange value.
> > This is the result of one of my test:
> > In [45]: Point(40.96312364002175,
> > -5.661885738372803).distance(Point(40.96116097790996, -5.66283792257309))
> > Out[45]: 0.0021814438604553388
> > In Google Maps Distance Calculator [2] I can see that the result is:
> 0.145
> > miles = 0.233 km = 0.126 nautical miles = 233 meters = 764.436 feet
> > A friend told me on Google that perhaps I must calculate the distance in
> > UTMs and the results surely is a lat/long distance. To test it I need
> pygps
> > that is a project not maintained to import
> > LLtoUTMfrom from LatLongUTMconversion
> > Any idea about this?
> > [1] http://docs.djangoproject.com/en/dev/ref/contrib/gis/geos/
> > [2]
> http://www.daftlogic.com/projects-google-maps-distance-calculator.htm
> >
> > --
> > Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx,
> .ppt
> > and/or .pptx
> > http://mirblu.com
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@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.
> >
>
>
>
> --
> Condor
> 310.951.1177
> condor.c...@gmail.com
>
> :%s/war/peace/g
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>


-- 
Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
and/or .pptx
http://mirblu.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Issue with loading fixtures in tests with multi database in Django 1.2

2010-07-29 Thread Xavier Ordoquy
Hi there.

I'm currently working on a project where I use a legacy database with a django 
one.
I've setup the multi database support and it seems to work pretty well.
However, I'm getting an issue with testing.

I need a fixture to load data to both the legacy and Django's databases.
In order to make this work, I found that I needed to set the multi_db to True 
in my TestCase (otherwise the legacy database data aren't loaded).
However, if I do that, it turns out that Django will throw an exception 
complaining about django_site not existing on my legacy database and would stop 
tests.

I also noticed some weird behavior with the initial data.
My initial_data load fine while the test framework works on the django database 
but it will complains about corrupted file while creating the legacy database 
(whether or not my testcase has the mult_db set).

Has someone a pointer or ideas on how to solve those issues ?
Esp the django_site thing which just blocks any test.

Regards,
Xavier.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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/loaddata through ssh

2010-07-29 Thread mack the finger
$ ./manage.py dumpdata some_app | ssh prgmr "cat | /srv/proj/manage.py
loaddata"

I'm trying to send fixtures over to my production server. Is there a
one liner that can do this without creating an intermediate file? The
above code doesn't seem to work. I get "No fixtures found" returned.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Calculate distance between 2 latitude/longitude Point

2010-07-29 Thread Alexandre González
I've solved translating a JavaScript function to python:

from math import *

RADIUS = 6371 #Earth's mean raadius in km

def distance(origin, destiny):
(latitude1, longitude1) = (origin[0], origin[1])
(latitude2, longitude2) = (destiny[0], destiny[1])

dLat = radians(latitude1 - latitude2)
dLong = radians(longitude1 - longitude2)

# matter of faith
a = sin(dLat/2) * sin(dLat/2) + cos(radians(latitude1)) *
cos(radians(latitude2)) * sin(dLong/2) * sin(dLong/2)
c = 2 * atan2(sqrt(a), sqrt(1-a))

return (RADIUS * c)

# a test
origin = (40.96312364002175, -5.661885738372803)
destiny = (40.96116097790996, -5.66283792257309)
print distance(origin, destiny)


2010/7/29 Alexandre González 

> I going to try it now, but the unique results that I obtain in google
> searching [1] gd2gcc is this thread :)
>
> [1]
> http://www.google.com/search?hl=en&safe=off&q=gd2gcc&aq=f&aqi=&aql=&oq=&gs_rfai=
>
>
> Did
> you make some mistake writting it?
>
> Thanks,
> Álex González
>
>
> On Wed, Jul 28, 2010 at 19:34, !!CONDORIOUS!! wrote:
>
>> (lat , lon in radians)
>>
>> pt 1 = lat, lon, alt=0
>> pt 2 = lat, lon, alt=0
>>
>> p1_gcc = gd2gcc(p1)
>> p1_gcc = gd2gcc(p2)
>>
>> gd2gcc ( is a standard operation found on the itnernet)
>>
>> dis = sqrt(sum(pow(p1_gcc-p2-gcc, 2)))
>>
>> cheers,
>>
>> 2010/7/28 Alexandre González :
>> > Hi! I'm using the Django GEOS API [1] in my project to see the distance
>> > between two users.
>> > I get the coordinates from google maps in latitude/longitude mode and I
>> need
>> > to calculate the distance between them. I'm testing with .distance()
>> method
>> > at GEOSGeometry but I receive a strange value.
>> > This is the result of one of my test:
>> > In [45]: Point(40.96312364002175,
>> > -5.661885738372803).distance(Point(40.96116097790996,
>> -5.66283792257309))
>> > Out[45]: 0.0021814438604553388
>> > In Google Maps Distance Calculator [2] I can see that the result is:
>> 0.145
>> > miles = 0.233 km = 0.126 nautical miles = 233 meters = 764.436 feet
>> > A friend told me on Google that perhaps I must calculate the distance in
>> > UTMs and the results surely is a lat/long distance. To test it I need
>> pygps
>> > that is a project not maintained to import
>> > LLtoUTMfrom from LatLongUTMconversion
>> > Any idea about this?
>> > [1] http://docs.djangoproject.com/en/dev/ref/contrib/gis/geos/
>> > [2]
>> http://www.daftlogic.com/projects-google-maps-distance-calculator.htm
>> >
>> > --
>> > Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx,
>> .ppt
>> > and/or .pptx
>> > http://mirblu.com
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups
>> > "Django users" group.
>> > To post to this group, send email to django-us...@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.
>> >
>>
>>
>>
>> --
>> Condor
>> 310.951.1177
>> condor.c...@gmail.com
>>
>> :%s/war/peace/g
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@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.
>>
>>
>
>
> --
> Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
> and/or .pptx
> http://mirblu.com
>



-- 
Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
and/or .pptx
http://mirblu.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



values with distinct not working as expected

2010-07-29 Thread tuxcanfly
I have this:

class Visitor(models.Model):
user = models.ForeignKey(User)
..
..

I'm trying to get the distinct usernames, so I did this:

Visitor.objects.values("user__username").distinct()

But this stil gives me duplicate usernames. Of course I could use a
flat values_list  and uniquify the result, but...

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: values with distinct not working as expected

2010-07-29 Thread Subhranath Chunder
If you don't want to uniquify yourself, then why not simply do:
User.objects.values('username').order_by('username').distinct()

or, going the way that were already heading, it would be:
Visitor.objects.values('user__username').order_by('user__username'').distinct()

Thanks,
Subhranath Chunder.


On Thu, Jul 29, 2010 at 2:29 PM, tuxcanfly  wrote:

> I have this:
>
> class Visitor(models.Model):
>user = models.ForeignKey(User)
>..
>..
>
> I'm trying to get the distinct usernames, so I did this:
>
>Visitor.objects.values("user__username").distinct()
>
> But this stil gives me duplicate usernames. Of course I could use a
> flat values_list  and uniquify the result, but...
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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.



I live in Ukraine. For me it is better to pick up European or US host?

2010-07-29 Thread KLRUMPF
Kostya, maybe have a look at www.ovh.fr, the language tabs are at the 
bottom. Lots of *ux flavours, too.


Been using them for years, cheap and competent, but I don't know how 
much they know about django.


Karl L. Rumpf
Málaga
klru...@gmail.com


El 29/07/2010 13:05, django-users+nore...@googlegroups.com escribió:
kostia  Jul 29 01:16AM -0700 ^ 



Currently looking at. So many choices!
I'm a person with not enough money.

What do you think about Canadian https://servqc.net/ one? It is very
cheap from the list.

I live in Ukraine. For me it is better to pick up European or US host?

Kostia


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: I live in Ukraine. For me it is better to pick up European or US host?

2010-07-29 Thread Alexander Jeliuc
intoVPS.com eu and us location

On Thu, Jul 29, 2010 at 2:51 PM, KLRUMPF  wrote:

>  Kostya, maybe have a look at www.ovh.fr, the language tabs are at the
> bottom. Lots of *ux flavours, too.
>
> Been using them for years, cheap and competent, but I don't know how much
> they know about django.
>
> Karl L. Rumpf
> málagaklru...@gmail.com
>
>
> El 29/07/2010 13:05, django-users+nore...@googlegroups.com escribió:
>
> kostia   Jul 29
> 01:16AM -0700 ^
>
> Currently looking at. So many choices!
> I'm a person with not enough money.
>
> What do you think about Canadian https://servqc.net/ one? It is very
> cheap from the list.
>
> I live in Ukraine. For me it is better to pick up European or US host?
>
> Kostia
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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.



through/unique_together usage

2010-07-29 Thread Dave
Hi,

In my application I want to enforce a each-image-can-only-be-assigned-
to-a-single-patient and believed I'd be able to do this by adding a
unique_together=("patient", "image") to the PatientImageRecord
definition - summary of my models.py:

class ImageCatagory(models.Model):
...

class ImageRecord(models.Model):
...

class Patient(models.Model):
   ...
   images  = models.ManyToManyField(ImageRecord, blank=True,
through="PatientImageRecord")

class PatientImageRecord(models.Model):
patient = models.ForeignKey(Patient)
image   = models.ForeignKey(ImageRecord)

Before adding the through=... clause my admin pages worked fine
including joins to the referenced images, but one could assign the
same image to more than one patient! Now that I have defined my own
model, PatientImageRecord, linking the two, the Patient admin page
breaks with the message "'NoneType' object has no attribute 'label''
unless I remove images from the page.

Any ideas what I'm doing wrong? Is this the right way to enforce the
desired relationship?

Thanks
Dave

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Python/Django hosting

2010-07-29 Thread Kenneth Gonsalves
On Thursday, July 29, 2010 01:46:33 pm kostia wrote:
> Currently looking at. So many choices!
> I'm a person with not enough money.
> 
> What do you think about Canadian https://servqc.net/ one? It is very
> cheap from the list.
> 
> I live in Ukraine. For me it is better to pick up European or US host?

I do not see the license - if it is under some open source license, I can give 
you shell access and host it on our server free. Please contact me offlist.
-- 
Regards
Kenneth Gonsalves
Senior Associate
NRC-FOSS at AU-KBC

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: generate cache by visiting protected links

2010-07-29 Thread Benedict Verheyen
On 28/07/2010 18:51, Jirka Vejrazka wrote:

> 
>   Hi,
> 
>   is the statistics user-dependent?
> 
>   If not, just create a cron job (or similar, depending on your
> platform) that will calculate the statistics every hour and maybe even
> create the main blocks of the page to be displayed.
> 
>   You can either create a custom management command to do this or
> write a script that uses ORM (and templating system) and Django cache.
> 
>   It very much depends on you setup, but should not be too difficult.
> 
>   Basically, you probably don't need a "view" to populate the cache.
> 
>   HTH
> 
> Jirka
> 
> P.S. http://docs.djangoproject.com/en/dev/howto/custom-management-commands/
> 

The custom commands seems indeed something very handy when one would work
via a cronjob.
However, then i would have to repeat the code i wrote for the statistics in
the code to generate it, and that's something i would like to avoid.

For now, i have found a way that seems acceptable.
When the index is hit, i start a thread where all the statistics pages are
visited. For the moment, to test, i only visit 1 statistics page and then
the thread stops. But it's easily adjusted to visit all statistics urls in
a thread that is kept alive and that visits the pages every x hours.

In my index view, i start the thread:

_thread=threading.Thread(target=visit_pages)
_thread.daemon = True
_thread.start()

then the visit_pages function:

def visit_pages():
_request = HttpRequest()
_request.method = 'GET'
_request.user = User.objects.get(pk=1)
ret_val = stats_top_callers_per_year(_request)
cache.set(reverse("stats_top_callers_per_year"), ret_val)

As you can see, it's very easy.
I do need to make my own HttpRequest it needs a user who is allowed to view the
statistics page. The user with id 1 is able to do so. However, when you would
use the "normal" request as it's passed to your views, you're going to interfere
with the user currently logged in, so it's a big no-no.
I'm not sure the method 'GET' needs to be specified. I have to test it.

Next, i call my function so i don't have to repeat the code and then i put it
on the cache.

Only downside for the moment is that i don't know what Django uses as standard 
key for the cache.
I thought it was the url but i don't know if it's the full url or only the part 
as you get
from using the reverse function (and thus as the urls are specified in urls.py)

Because of this, i needed to add this to my stats_top_callers_per_year function 
to make it work:

@csrf_exempt
def stats_top_callers_per_year(request):
ret = cache.get(reverse("stats_top_callers_per_year"))
if ret is not None:
print "Retrieved cached page"
return ret
...

If i find out exactly what the key needs to be, i can remove the last lines of 
code.

Regards,
Benedict

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: I live in Ukraine. For me it is better to pick up European or US host?

2010-07-29 Thread kostia
Thank you guys.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



error loading sqlite3 module

2010-07-29 Thread jose antunes
Can anyone please help figuring out why I get the following error:
django.core.exceptions.ImproperlyConfigured: Error loading sqlite3 module:
No module named _sqlite3

Using MySql works fine. But not with sqlite3, Sqlite is installed, and both
python/sqlite3 and django/db/backends/sqlite3 exist.

in settings.py for sqlite3 I am just using:
DATABASE_ENGINE = 'sqlite3'
DATABASE_NAME = 'dtabasename.sql'

no entries for user, password, host, or port.

Thank you!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: error loading sqlite3 module

2010-07-29 Thread Alexandre González
You need to install the python sqlite libraries.

On Thu, Jul 29, 2010 at 15:27, jose antunes  wrote:

> Can anyone please help figuring out why I get the following error:
> django.core.exceptions.ImproperlyConfigured: Error loading sqlite3 module:
> No module named _sqlite3
>
> Using MySql works fine. But not with sqlite3, Sqlite is installed, and both
> python/sqlite3 and django/db/backends/sqlite3 exist.
>
> in settings.py for sqlite3 I am just using:
> DATABASE_ENGINE = 'sqlite3'
> DATABASE_NAME = 'dtabasename.sql'
>
> no entries for user, password, host, or port.
>
> Thank you!
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>



-- 
Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
and/or .pptx
http://mirblu.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: generate cache by visiting protected links

2010-07-29 Thread Jirka Vejrazka
>    ret_val = stats_top_callers_per_year(_request)
>    cache.set(reverse("stats_top_callers_per_year"), ret_val)

 Hi,

  it's your code and I won't try talk you out of it :)

  However, I don't see any reason why you couldn't call
"stats_top_caller_per_year" from an external script, unless you do
some magic related to request in that function. You're overriding the
user to be the one with pk=1 anyway, so you can do the same in a
script launched by cron the same way.

  As long as you have a system-wide cache (ideally memcached backend),
nothing prevents you from doing that.

  As for the cache key, it can be anything you want as long as it's
unique, less than the backend allows (I think it's 250 chars for
memcached, see the docs) and does not contain whitespaces (some cache
backends do allow those). A common idiom is an md5 of something that
uniquely identifies the cache object, but in your case you'd be free
to call it "stats_top_callers_per_year" or similar. No need to play
with reverse().

  It's all just Python and Django does not really get much in a way
unless needed. So, no one tells you what the cache keys must look
like, and it's unlikely that you'd stumble upon cache keys Django uses
internally.

 HTH

   Jirka

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Calculate distance between 2 latitude/longitude Point

2010-07-29 Thread Alex Robbins
Geopy has a distance function build in, if you want something a little
more widely used/tested:
http://code.google.com/p/geopy/wiki/GettingStarted#Calculating_distances

Alex

On Jul 29, 5:23 am, Alexandre González  wrote:
> I've solved translating a JavaScript function to python:
>
> from math import *
>
> RADIUS = 6371 #Earth's mean raadius in km
>
> def distance(origin, destiny):
>     (latitude1, longitude1) = (origin[0], origin[1])
>     (latitude2, longitude2) = (destiny[0], destiny[1])
>
>     dLat = radians(latitude1 - latitude2)
>     dLong = radians(longitude1 - longitude2)
>
>     # matter of faith
>     a = sin(dLat/2) * sin(dLat/2) + cos(radians(latitude1)) *
> cos(radians(latitude2)) * sin(dLong/2) * sin(dLong/2)
>     c = 2 * atan2(sqrt(a), sqrt(1-a))
>
>     return (RADIUS * c)
>
> # a test
> origin = (40.96312364002175, -5.661885738372803)
> destiny = (40.96116097790996, -5.66283792257309)
> print distance(origin, destiny)
>
> 2010/7/29 Alexandre González 
>
>
>
> > I going to try it now, but the unique results that I obtain in google
> > searching [1] gd2gcc is this thread :)
>
> > [1]
> >http://www.google.com/search?hl=en&safe=off&q=gd2gcc&aq=f&aqi=&aql=&o...
>
> > Did
> > you make some mistake writting it?
>
> > Thanks,
> > Álex González
>
> > On Wed, Jul 28, 2010 at 19:34, !!CONDORIOUS!! wrote:
>
> >> (lat , lon in radians)
>
> >> pt 1 = lat, lon, alt=0
> >> pt 2 = lat, lon, alt=0
>
> >> p1_gcc = gd2gcc(p1)
> >> p1_gcc = gd2gcc(p2)
>
> >> gd2gcc ( is a standard operation found on the itnernet)
>
> >> dis = sqrt(sum(pow(p1_gcc-p2-gcc, 2)))
>
> >> cheers,
>
> >> 2010/7/28 Alexandre González :
> >> > Hi! I'm using the Django GEOS API [1] in my project to see the distance
> >> > between two users.
> >> > I get the coordinates from google maps in latitude/longitude mode and I
> >> need
> >> > to calculate the distance between them. I'm testing with .distance()
> >> method
> >> > at GEOSGeometry but I receive a strange value.
> >> > This is the result of one of my test:
> >> > In [45]: Point(40.96312364002175,
> >> > -5.661885738372803).distance(Point(40.96116097790996,
> >> -5.66283792257309))
> >> > Out[45]: 0.0021814438604553388
> >> > In Google Maps Distance Calculator [2] I can see that the result is:
> >> 0.145
> >> > miles = 0.233 km = 0.126 nautical miles = 233 meters = 764.436 feet
> >> > A friend told me on Google that perhaps I must calculate the distance in
> >> > UTMs and the results surely is a lat/long distance. To test it I need
> >> pygps
> >> > that is a project not maintained to import
> >> > LLtoUTMfrom from LatLongUTMconversion
> >> > Any idea about this?
> >> > [1]http://docs.djangoproject.com/en/dev/ref/contrib/gis/geos/
> >> > [2]
> >>http://www.daftlogic.com/projects-google-maps-distance-calculator.htm
>
> >> > --
> >> > Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx,
> >> .ppt
> >> > and/or .pptx
> >> >http://mirblu.com
>
> >> > --
> >> > You received this message because you are subscribed to the Google
> >> Groups
> >> > "Django users" group.
> >> > To post to this group, send email to django-us...@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.
>
> >> --
> >> Condor
> >> 310.951.1177
> >> condor.c...@gmail.com
>
> >> :%s/war/peace/g
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Django users" group.
> >> To post to this group, send email to django-us...@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.
>
> > --
> > Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
> > and/or .pptx
> >http://mirblu.com
>
> --
> Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
> and/or .pptxhttp://mirblu.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: generate cache by visiting protected links

2010-07-29 Thread Benedict Verheyen
On 29/07/2010 15:41, Jirka Vejrazka wrote:
>>ret_val = stats_top_callers_per_year(_request)
>>cache.set(reverse("stats_top_callers_per_year"), ret_val)
> 
>  Hi,
> 
>   it's your code and I won't try talk you out of it :)
> 
>   However, I don't see any reason why you couldn't call
> "stats_top_caller_per_year" from an external script, unless you do
> some magic related to request in that function. You're overriding the
> user to be the one with pk=1 anyway, so you can do the same in a
> script launched by cron the same way.
> 
>   As long as you have a system-wide cache (ideally memcached backend),
> nothing prevents you from doing that.
> 
>   As for the cache key, it can be anything you want as long as it's
> unique, less than the backend allows (I think it's 250 chars for
> memcached, see the docs) and does not contain whitespaces (some cache
> backends do allow those). A common idiom is an md5 of something that
> uniquely identifies the cache object, but in your case you'd be free
> to call it "stats_top_callers_per_year" or similar. No need to play
> with reverse().
> 
>   It's all just Python and Django does not really get much in a way
> unless needed. So, no one tells you what the cache keys must look
> like, and it's unlikely that you'd stumble upon cache keys Django uses
> internally.
> 
>  HTH
> 
>Jirka
> 


I could indeed, as you correctly point out, put it in a cronjob provided
that i can access the cache that is currently used byt the site.
I haven't yet found how to do that. Probably not that hard.
But i don't see a benefit to putting the code in a cronjob.
Apparently, you do, so could you enlighten me? :)
There are probably some good and valid reasons.

The reason why i like the current approach, is that it's just 1 action to start
the site and there is no need to check other things if something goes
wrong. I can tell my colleagues to just start the site and that's it.

As for the cache key, i did the reverse because i thought i had
read in the documentation that this was the standard way Django puts
stuff in the cache.
But it's not the link as returned by reverse, though i haven't found yet
what it is. If i find it, i can set i correctly in the thread so that I don't
have to manually check to see if the page is cached when a statistics page
is called.

Regards,
Benedict


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 to access a MySQL table in Django?

2010-07-29 Thread Alex Robbins
Whenever I have to pull data from legacy databases, I use './manage.py
inspectdb > models.py'. That will dump models for the database. Then I
rename the models to make more sense, and use the orm to get my data.

Alex

On Jul 28, 12:58 pm, snipinben 
wrote:
> I have the python-mysqldb installed already and i have  django up and
> running. when i installed the python-mysqldb i had to hack the code kind of
> so that it didnt check if the versions were the same so that it would work.
> I got this idea from online. but anyways, I am wondering how to access
> records that were already in the database before I started the project. i
> know how to access records from data that i inserted through tables in the
> models.py file. but i have no idea how to access them straight from the
> database itself. please give me any info you got. thanks
> --
> View this message in 
> context:http://old.nabble.com/How-to-access-a-MySQL-table-in-Django--tp292893...
> Sent from the django-users mailing list archive at Nabble.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Calculate distance between 2 latitude/longitude Point

2010-07-29 Thread Tomi Pieviläinen
> *
> In [45]: Point(40.96312364002175,
> -5.661885738372803).distance(Point(40.96116097790996, -5.66283792257309))
> Out[45]: 0.0021814438604553388

The results are what you get from the db. The thing is, you can't
assume that the distance in degrees is the same everywhere, so you
can't use a simple formula like multiplying by the circumference at
equator. Instead let the db do the work for you by telling what
coordinate system your input is and what do you want as output. Good
examples can be found in PostGIS (Postgresql with GIS) documentation:

http://postgis.refractions.net/documentation/manual-1.5/ST_Distance.html

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Django has incorrect time

2010-07-29 Thread Alex
I'm having some strange behavior when using Django and Postgres.  My
system time zone is EDT and when running datetime.now( ) from a
*Python* shell I get the correct time.  If I run a Django shell
through manage.py it is an hour behind.  I similarly have set up a
view on a web page to display the time and it is also an hour behind.
Now this is where things get tricky.  I have some database fields that
default to datetime.now( ) and get updated to the same when changes
occur to the objects the fields are contained in.  The database gets
the correct local time (say 10:30) but when these values are displayed
by Django on a page they are again an hour behind.

So, Django cannot present the correct value (one hour behind) to me,
but somehow the correct time gets inserted in the database, and when
directly displaying this value from the database in Django it is again
one hour behind.

It sounds like a time zone thing but I've tried setting Django to an
eastern zone and also None (to use the system TZ) but neither seemed
to make a difference.  Any help here?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Using sqlite3 to test locally

2010-07-29 Thread Zo
I fixed this by commenting out 'django.contrib.auth' from
INSTALLED_APPS in settings.py

Also, to run doctests in PyDev for eclipse, all you need to do is go
to run configuration and add -v as an argument.
Then right click on the file with the doctest and run as 'Python Run'

Hope this helps anyone else with these problems.

On Jul 28, 12:43 pm, Zo  wrote:
> I had not, i ran it and created a superuser. should I be changing my
> setting file for my user info?
>
> I also changed DATABASE_ROUTERS = [] because it was previously set to
> ['test.ReportAdmin.routers.ReportAdminRouter']
>
> and I went back to
>
> DATABASES = {
>                 'default' : {
>                 'NAME' : 'C:/python-dev/pythonproject/test/sqlite3.db'
>                 ,'ENGINE' : 'django.db.backends.sqlite3'
>                 }
>
> }
>
> those changes caused my tests to actually run, but now I get lots of
> tests...
>
> --
> Ran 59 tests in 0.828s
>
> FAILED (failures=16, errors=4)
> Destroying test database 'default'...
>
> It looks like all failures come from Python26/lib/site-packages/django/
> contrib/auth/tests
>
> Here are a few of the errors/failures
>
> ==
> ERROR: test_no_remote_user
> (django.contrib.auth.tests.remote_user.RemoteUserCust
> omTest)
> --
> Traceback (most recent call last):
>   File "C:\Python26\lib\site-packages\django\contrib\auth\tests
> \remote_user.py",
>  line 33, in test_no_remote_user
>     self.assert_(response.context['user'].is_anonymous())
> TypeError: 'NoneType' object is unsubscriptable
>
> ==
> ERROR: test_no_remote_user
> (django.contrib.auth.tests.remote_user.RemoteUserNoCr
> eateTest)
> --
> Traceback (most recent call last):
>   File "C:\Python26\lib\site-packages\django\contrib\auth\tests
> \remote_user.py",
>  line 33, in test_no_remote_user
>     self.assert_(response.context['user'].is_anonymous())
> TypeError: 'NoneType' object is unsubscriptable
>
> ==
> ERROR: test_unknown_user
> (django.contrib.auth.tests.remote_user.RemoteUserNoCrea
> teTest)
> --
> Traceback (most recent call last):
>   File "C:\Python26\lib\site-packages\django\contrib\auth\tests
> \remote_user.py",
>  line 118, in test_unknown_user
>     self.assert_(response.context['user'].is_anonymous())
> TypeError: 'NoneType' object is unsubscriptable
>
> ==
> ERROR: test_no_remote_user
> (django.contrib.auth.tests.remote_user.RemoteUserTest
> )
> --
> Traceback (most recent call last):
>   File "C:\Python26\lib\site-packages\django\contrib\auth\tests
> \remote_user.py",
>  line 33, in test_no_remote_user
>     self.assert_(response.context['user'].is_anonymous())
> TypeError: 'NoneType' object is unsubscriptable
>
> ==
> FAIL: test_password_change_fails_with_invalid_old_password
> (django.contrib.auth.
> tests.views.ChangePasswordTest)
> --
> Traceback (most recent call last):
>   File "C:\Python26\lib\site-packages\django\contrib\auth\tests
> \views.py", line
> 143, in test_password_change_fails_with_invalid_old_password
>     self.login()
>   File "C:\Python26\lib\site-packages\django\contrib\auth\tests
> \views.py", line
> 127, in login
>     self.assertEquals(response.status_code, 302)
> AssertionError: 200 != 302
>
> ==
> FAIL: test_password_change_fails_with_mismatched_passwords
> (django.contrib.auth.
> tests.views.ChangePasswordTest)
> --
> Traceback (most recent call last):
>   File "C:\Python26\lib\site-packages\django\contrib\auth\tests
> \views.py", line
> 154, in test_password_change_fails_with_mismatched_passwords
>     self.login()
>   File "C:\Python26\lib\site-packages\django\contrib\auth\tests
> \views.py", line
> 127, in login
>     self.assertEquals(response.status_code, 302)
>
> Can i disable these or should all these be passing?
>
> Thanks,
> Zo
>
> On Jul 28, 12:20 pm, Shawn Milochik  wrote:
>
> > Did you run ./manage.py syncdb?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://group

Re: User Registration: Looking for tips

2010-07-29 Thread Wiiboy
Would it be possible to just use two ModelForms?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django has incorrect time

2010-07-29 Thread Baurzhan Ismagulov
On Thu, Jul 29, 2010 at 07:33:26AM -0700, Alex wrote:
> system time zone is EDT and when running datetime.now( ) from a
> *Python* shell I get the correct time.  If I run a Django shell
> through manage.py it is an hour behind.

Works fine here with Django 1.0.2-1+lenny1; which version do you have?

With kind regards,
Baurzhan.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: through/unique_together usage

2010-07-29 Thread Shawn Milochik
Are you using sqlite3? It doesn't support the unique_together constraint.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django has incorrect time

2010-07-29 Thread Alex

> Works fine here with Django 1.0.2-1+lenny1; which version do you have?

Django 1.2.1 (installed manually, not through apt) on Kubuntu 10.04,
Python 2.6.5, Postgres 8.4.4.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django has incorrect time

2010-07-29 Thread Jason
Try changing time zones in your settings.py

For example:

TIME_ZONE = 'America/Los_Angeles'

And make sure if you're running on Windows it matches your system's
time zone. Regardless, you should see some kind of change when you do
this. If you don't perhaps the settings.py isn't loading properly.

On Jul 29, 7:33 am, Alex  wrote:
> I'm having some strange behavior when using Django and Postgres.  My
> system time zone is EDT and when running datetime.now( ) from a
> *Python* shell I get the correct time.  If I run a Django shell
> through manage.py it is an hour behind.  I similarly have set up a
> view on a web page to display the time and it is also an hour behind.
> Now this is where things get tricky.  I have some database fields that
> default to datetime.now( ) and get updated to the same when changes
> occur to the objects the fields are contained in.  The database gets
> the correct local time (say 10:30) but when these values are displayed
> by Django on a page they are again an hour behind.
>
> So, Django cannot present the correct value (one hour behind) to me,
> but somehow the correct time gets inserted in the database, and when
> directly displaying this value from the database in Django it is again
> one hour behind.
>
> It sounds like a time zone thing but I've tried setting Django to an
> eastern zone and also None (to use the system TZ) but neither seemed
> to make a difference.  Any help here?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: User Registration: Looking for tips

2010-07-29 Thread strayhand
Euan,

Thank you for the response. I agree with what you're saying and it
seems that I have two options before me.

1. Define simple form class for my registration process. Write a save
method that posts to both the "User" model and the "UserProfile"
model.

I could start this process from scratch but I came across this post
that I'm interested in. Have you by chance looked at any of the work
James Bennett (http://www.b-list.org/) has done with registration? He
has essentially taken the UserCreationForm as a guide and reworked it
to save the form to two models. In this example he's storing
activation key in the UserProfile model.

http://www.b-list.org/weblog/2006/sep/02/django-tips-user-registration/

I think that I could use what he's demonstrating here and add my own
fields. What are your thoughts on this code? There are a few comments
below his post that I'll need to keep in mind. My main concern is how
old the post is. I don't want to waste a lot of time with this
approach only to find out that Django has gone in a different
direction.

2. The second option would be to try the django-registration module
and make some tweaks.

Do you (or anyone else out there) have any experience with this
module?

http://bitbucket.org/ubernostrum/django-registration/overview

Seems like this would get me up and running with a registration system
a little more advanced than I currently have but it would still need
to be tweaked to include all of my profile fields. Here's a blog post
about tweaking the django-registration form by extending the class:

http://dewful.com/?p=70

Please let me know if you guys have opinions one way or another about
these two approaches. Thank you.


On Jul 28, 11:47 pm, "euan.godd...@googlemail.com"
 wrote:
> For the UserProfle model you've provided you won't be able to user
> the  UserCreationForm as there are a load of extra fields. Moreover
> because User is a foreign key from that model it isn't a straight-
> forward matter of using a model form. To get a single model form to
> split the work to two underlying models would be a fair bit of work.
>
> Although ModelForm is great, if you want to do things which are a bit
> off what they were intended to do I'd use a simple Form and create a
> custom save method that writes out the data to the two models. That's
> how we do our registration process since we create at least 6 model
> instances at join time.
>
> Euan
>
> On 29 July, 06:45, strayhand  wrote:
>
> > I'm using the auth module for my project and I've got a registration
> > form that's based on the "UserCreationForm" provided by
> > "django.contrib.auth.forms" but it's only showing the username and
> > password fields.
>
> > I want a registration process that requires users to fill out ALL of
> > the "User" fields plus the fields in my "UserProfile" model.
>
> > If someone has some basic suggestions for how to modify the
> > UserCreationForm to include these additional fields I'm all ears. I
> > managed to find some basic examples of how to hide certain ModelForm
> > fields or change their labels but nothing about adding additional
> > fields, particularly from other models.
>
> > In addition to modifying the UserCreationForm I've come across a
> > couple of leads:
>
> > 1. Build my own registration process following this example:
>
> >http://www.b-list.org/weblog/2006/sep/02/django-tips-user-registration/
>
> > I'm concerned with how old this post is. Is this approach still valid
> > given that it was posted in 2006? The author is using both the User
> > model and his own UserProfile model. I think that I could adapt this
> > for my purpose.
>
> > 2. Use the django-registration package provided by the same author
>
> >http://bitbucket.org/ubernostrum/django-registration/overview
>
> > I'm concerned with having to install additional packages into Django.
> > It seems like this will make deploying my application on a Web host
> > more difficult. Can anyone speak to this?
>
> > Thank you for your suggestions. I've provided my code thus far below.
>
> > # forms.py
>
> > from django import forms
> > from django.contrib.auth.forms import UserCreationForm
> > from django.http import HttpResponseRedirect
> > from django.shortcuts import render_to_response
> > from django.template import RequestContext
>
> > def register(request):
> >         if request.method == 'POST':
> >                 form = UserCreationForm(request.POST)
> >                 if form.is_valid():
> >                         new_user = form.save()
> >                         return HttpResponseRedirect("/somewhere/")
> >         else:
> >                 form = UserCreationForm()
> >         return render_to_response("registration/register.html",
> > {'form':form,}, context_instance=RequestContext(request))
>
> > # profiles.models.py
>
> > from django.db import models
> > from django.contrib.auth.models import User
> > from ylbbq.areas.models import Area
>
> > class UserProfile(models.Model):
> >     user = models.Forei

Re: generate cache by visiting protected links

2010-07-29 Thread Jirka Vejrazka
> I could indeed, as you correctly point out, put it in a cronjob provided
> that i can access the cache that is currently used byt the site.
> I haven't yet found how to do that. Probably not that hard.
> But i don't see a benefit to putting the code in a cronjob.
> Apparently, you do, so could you enlighten me? :)

  Well, it probably depends on the frequency od data change as well as
other factors. I personally don't like spawning another thread in a
request-response cycle, but if it works for you, be happy with it :)

  Based on the print statement on your code I assume your website does
run under the development server, so you may have very different
requirements than a usual production (read: always running) site :)

> As for the cache key, i did the reverse because i thought i had
> read in the documentation that this was the standard way Django puts
> stuff in the cache.

  Sure - you can do it, no problem. The reason Django uses it is that
it caches various pages and the url pattern is a good way to make sure
that the cache key is unique for each page. You could put anything
there, even a static string :)

> But it's not the link as returned by reverse, though i haven't found yet
> what it is. If i find it, i can set i correctly in the thread so that I don't
> have to manually check to see if the page is cached when a statistics page
> is called.

  You will always have to check it, as it's not guarranteed to stay in
the cache forever. Assuming that the data is in cache is a Bad Thing
:)

  If you set your cache key to "yearly_statistics" or something
similar, you will have no issue with figuring out what the key is :)

  Cheers

Jirka

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django has incorrect time

2010-07-29 Thread Alex


> TIME_ZONE = 'America/Los_Angeles'

This actually led to the solution, which was a stupid error on my
part.  Somehow TIME_ZONE got into my settings.py file twice and I was
changing the first instance, which was getting overwritten with the
second instance (default Chicago TZ) later.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 to access a MySQL table in Django?

2010-07-29 Thread snipinben

yeah, i was able to find that exact thing yesterday, and it works and i am so
happy.  now i have one more problem, i cnat get oracle-cx to work. it says
that "no software installation was found" or something like that. i have the
python-mysql working but i cant seem to get the oracle database connector to
work. got anny suggestions? im running a linux platform with Ubuntu.

Alex Robbins wrote:
> 
> Whenever I have to pull data from legacy databases, I use './manage.py
> inspectdb > models.py'. That will dump models for the database. Then I
> rename the models to make more sense, and use the orm to get my data.
> 
> Alex
> 
> On Jul 28, 12:58 pm, snipinben 
> wrote:
>> I have the python-mysqldb installed already and i have  django up and
>> running. when i installed the python-mysqldb i had to hack the code kind
>> of
>> so that it didnt check if the versions were the same so that it would
>> work.
>> I got this idea from online. but anyways, I am wondering how to access
>> records that were already in the database before I started the project. i
>> know how to access records from data that i inserted through tables in
>> the
>> models.py file. but i have no idea how to access them straight from the
>> database itself. please give me any info you got. thanks
>> --
>> View this message in
>> context:http://old.nabble.com/How-to-access-a-MySQL-table-in-Django--tp292893...
>> Sent from the django-users mailing list archive at Nabble.com.
> 
> -- 
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/How-to-access-a-MySQL-table-in-Django--tp29289314p29297565.html
Sent from the django-users mailing list archive at Nabble.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: User Registration: Looking for tips

2010-07-29 Thread Colleen A Josephson
Actually, just yesterday I extended the django-registration form to deal with 
my profile @ registration time
For reference I used:

http://dmitko.ru/?p=546

and the link you previously posted,

http://dewful.com/?p=70

It didn't require much code. The hardest part was sifting through some of the 
older irrelevant documentation in order to find instructions that worked.

-Colleen

From: django-users@googlegroups.com [django-us...@googlegroups.com] On Behalf 
Of strayhand [tobyb...@gmail.com]
Sent: Thursday, July 29, 2010 11:13 AM
To: Django users
Subject: Re: User Registration: Looking for tips

Euan,

Thank you for the response. I agree with what you're saying and it
seems that I have two options before me.

1. Define simple form class for my registration process. Write a save
method that posts to both the "User" model and the "UserProfile"
model.

I could start this process from scratch but I came across this post
that I'm interested in. Have you by chance looked at any of the work
James Bennett (http://www.b-list.org/) has done with registration? He
has essentially taken the UserCreationForm as a guide and reworked it
to save the form to two models. In this example he's storing
activation key in the UserProfile model.

http://www.b-list.org/weblog/2006/sep/02/django-tips-user-registration/

I think that I could use what he's demonstrating here and add my own
fields. What are your thoughts on this code? There are a few comments
below his post that I'll need to keep in mind. My main concern is how
old the post is. I don't want to waste a lot of time with this
approach only to find out that Django has gone in a different
direction.

2. The second option would be to try the django-registration module
and make some tweaks.

Do you (or anyone else out there) have any experience with this
module?

http://bitbucket.org/ubernostrum/django-registration/overview

Seems like this would get me up and running with a registration system
a little more advanced than I currently have but it would still need
to be tweaked to include all of my profile fields. Here's a blog post
about tweaking the django-registration form by extending the class:

http://dewful.com/?p=70

Please let me know if you guys have opinions one way or another about
these two approaches. Thank you.


On Jul 28, 11:47 pm, "euan.godd...@googlemail.com"
 wrote:
> For the UserProfle model you've provided you won't be able to user
> the  UserCreationForm as there are a load of extra fields. Moreover
> because User is a foreign key from that model it isn't a straight-
> forward matter of using a model form. To get a single model form to
> split the work to two underlying models would be a fair bit of work.
>
> Although ModelForm is great, if you want to do things which are a bit
> off what they were intended to do I'd use a simple Form and create a
> custom save method that writes out the data to the two models. That's
> how we do our registration process since we create at least 6 model
> instances at join time.
>
> Euan
>
> On 29 July, 06:45, strayhand  wrote:
>
> > I'm using the auth module for my project and I've got a registration
> > form that's based on the "UserCreationForm" provided by
> > "django.contrib.auth.forms" but it's only showing the username and
> > password fields.
>
> > I want a registration process that requires users to fill out ALL of
> > the "User" fields plus the fields in my "UserProfile" model.
>
> > If someone has some basic suggestions for how to modify the
> > UserCreationForm to include these additional fields I'm all ears. I
> > managed to find some basic examples of how to hide certain ModelForm
> > fields or change their labels but nothing about adding additional
> > fields, particularly from other models.
>
> > In addition to modifying the UserCreationForm I've come across a
> > couple of leads:
>
> > 1. Build my own registration process following this example:
>
> >http://www.b-list.org/weblog/2006/sep/02/django-tips-user-registration/
>
> > I'm concerned with how old this post is. Is this approach still valid
> > given that it was posted in 2006? The author is using both the User
> > model and his own UserProfile model. I think that I could adapt this
> > for my purpose.
>
> > 2. Use the django-registration package provided by the same author
>
> >http://bitbucket.org/ubernostrum/django-registration/overview
>
> > I'm concerned with having to install additional packages into Django.
> > It seems like this will make deploying my application on a Web host
> > more difficult. Can anyone speak to this?
>
> > Thank you for your suggestions. I've provided my code thus far below.
>
> > # forms.py
>
> > from django import forms
> > from django.contrib.auth.forms import UserCreationForm
> > from django.http import HttpResponseRedirect
> > from django.shortcuts import render_to_response
> > from django.template import RequestContext
>
> > def register(request):
> > if request.metho

Re: generate cache by visiting protected links

2010-07-29 Thread David De La Harpe Golden
On 29/07/10 16:16, Jirka Vejrazka wrote:


> I personally don't like spawning another thread in a
> request-response cycle, but if it works for you, be happy with it :)

IIRC it's not really safe, at least in the django/apache case, the whole
serving process may be considered fair game to be killed by process pool
management once the response is returned, any extra threads in it too
(and child processes if they don't detach from the pgrp)

Try celery+django-celery if you want something designed for
background processing...

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: generate cache by visiting protected links

2010-07-29 Thread Benedict Verheyen
On 29/07/2010 17:53, David De La Harpe Golden wrote:
> On 29/07/10 16:16, Jirka Vejrazka wrote:
> 
> 
>> I personally don't like spawning another thread in a
>> request-response cycle, but if it works for you, be happy with it :)
> 
> IIRC it's not really safe, at least in the django/apache case, the whole
> serving process may be considered fair game to be killed by process pool
> management once the response is returned, any extra threads in it too
> (and child processes if they don't detach from the pgrp)
> 
> Try celery+django-celery if you want something designed for
> background processing...
> 

So calling a thread once from within a view is not safe ?
I'm planning on using Apache for production.

Regards,
Benedict


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Python/Django hosting

2010-07-29 Thread kostia
We are PROJECTOR team. We have a web site, developed on Django /
Python.

The site is temporarily launched with test data here http://kostia.pythonic.nl/

We are working with github here http://github.com/vaxXxa/projector

The web site contains User Profiles, Projects and Events for these
Projects. All data is text-based and there will be not much traffic.

People will be uploading small videos on youtube/vimeo/etc and link
them on the site. The content of the video is a 3-5 minutes of
author's presentation, where he is trying to describe what he is
doing, what he needs and what the effect it will cause on the society.
An idea just to bring so-called value-business on the top and help
authors to find people to help with their ideas/projects.

The web site is social oriented and we are looking for any hosting
solution.

I will consider any propositions.

Thank you very much.

Kostia

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: error loading sqlite3 module

2010-07-29 Thread jose antunes
thanks very much, Installing the libraries did it.


2010/7/29 Alexandre González 

> You need to install the python sqlite libraries.
>
> On Thu, Jul 29, 2010 at 15:27, jose antunes  wrote:
>
>> Can anyone please help figuring out why I get the following error:
>> django.core.exceptions.ImproperlyConfigured: Error loading sqlite3 module:
>> No module named _sqlite3
>>
>> Using MySql works fine. But not with sqlite3, Sqlite is installed, and
>> both python/sqlite3 and django/db/backends/sqlite3 exist.
>>
>> in settings.py for sqlite3 I am just using:
>> DATABASE_ENGINE = 'sqlite3'
>> DATABASE_NAME = 'dtabasename.sql'
>>
>> no entries for user, password, host, or port.
>>
>> Thank you!
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@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.
>>
>
>
>
> --
> Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
> and/or .pptx
> http://mirblu.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django 1.2 modelformset_factory fails with meta: widgets

2010-07-29 Thread Jason
Can anyone confirm that passing in a form with Meta.widgets set to
modelformset_factory() does in fact work?

I've tried stripping my code down to the basics and still get the same
exception. Debugging Django code doesn't help me because it fails
during a lamda function that I don't quite understand.

If anyone else has this problem I'll go ahead and submit a bug report.

On Jul 28, 12:50 pm, Jason  wrote:
> Traceback:
> File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in
> get_response
>   100.                     response = callback(request,
> *callback_args, **callback_kwargs)
> File "C:\Documents and Settings\goodrich\PycharmProjects\CCC\Aggregator
> \newsmail\views.py" in manage_articles
>   174.                                           form = ArticleForm)
> File "C:\Python25\lib\site-packages\django\forms\models.py" in
> modelformset_factory
>   669.
> formfield_callback=formfield_callback)
> File "C:\Python25\lib\site-packages\django\forms\models.py" in
> modelform_factory
>   407.     return ModelFormMetaclass(class_name, (form,),
> form_class_attrs)
> File "C:\Python25\lib\site-packages\django\forms\models.py" in __new__
>   220.                                       opts.exclude,
> opts.widgets, formfield_callback)
> File "C:\Python25\lib\site-packages\django\forms\models.py" in
> fields_for_model
>   178.         formfield = formfield_callback(f, **kwargs)
>
> Exception Type: TypeError at /newsmail/manage/
> Exception Value: () got an unexpected keyword argument
> 'widget'
>
> On Jul 28, 12:00 pm, Daniel Roseman  wrote:
>
> > On Jul 28, 7:08 pm, Jason  wrote:
>
> > > For example:
>
> > > class ArticleForm(ModelForm):
> > >     class Meta:
> > >         model = Article
> > >         widgets = {
> > >              'pub_date': SplitSelectDateTimeWidget(),
> > >              'expire_date': CalendarWidget(attrs={'class':'date-
> > > pick'})
> > >         }
>
> > > And in a view function:
> > > ...
> > >     ArticleFormSet = modelformset_factory(Article,
> > >                                           form = ArticleForm,
> > >                                           extra=0)
> > > ...
>
> > > Removing 'widgets' from the Meta in ArticleForm fixes the error.
>
> > > The new widgets convention here is really handy. I don't want to lose
> > > it!
>
> > > Any tips?
>
> > How does it fail? What error do you get? If there's a traceback,
> > please post it here.
> > --
> > DR.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Python/Django hosting

2010-07-29 Thread CrabbyPete
www.webfaction.com

On Jul 29, 12:02 pm, kostia  wrote:
> We are PROJECTOR team. We have a web site, developed on Django /
> Python.
>
> The site is temporarily launched with test data herehttp://kostia.pythonic.nl/
>
> We are working with github herehttp://github.com/vaxXxa/projector
>
> The web site contains User Profiles, Projects and Events for these
> Projects. All data is text-based and there will be not much traffic.
>
> People will be uploading small videos on youtube/vimeo/etc and link
> them on the site. The content of the video is a 3-5 minutes of
> author's presentation, where he is trying to describe what he is
> doing, what he needs and what the effect it will cause on the society.
> An idea just to bring so-called value-business on the top and help
> authors to find people to help with their ideas/projects.
>
> The web site is social oriented and we are looking for any hosting
> solution.
>
> I will consider any propositions.
>
> Thank you very much.
>
> Kostia

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: generate cache by visiting protected links

2010-07-29 Thread David De La Harpe Golden
On 29/07/10 16:58, Benedict Verheyen wrote:

> So calling a thread once from within a view is not safe ?

Depends on what your expectations are...

I haven't managed to dig up the paragraph discussing the issue that I
recall existing. I've a strong feeling it was by Graham Dumpleton, he
mentions in passing here:

http://groups.google.com/group/django-users/msg/e6e6b182fcd23d39

"You also don't have to deal with possibility of Apache killing off one
its processes, which might contain running jobs, when it is recycling
its processes."

but there was a somewhat more detailed writeup somewhere else.

> I'm planning on using Apache for production.

Not a reason not to, just a reason not to use that particular approach
when doing so.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: MySQL error -1

2010-07-29 Thread Dennis Kaarsemaker
On wo, 2010-07-28 at 22:25 -0700, shacker wrote:

> Well, I think I've got a culprit on this one. I was seeing occasional
> "/tmp is out of space" messages from the server lately as well, 

That is more than likely as mysql will store temporary tables there and
your error is one that can be seen if the server runs out of diskspace
for creating temporary tables.

If you do 'select @@tmpdir', it'll probably say /tmp as that is the
default. You can change this in /etc/my.cnf if you want.

-- 
Dennis K.

They've gone to plaid!


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Python/Django hosting

2010-07-29 Thread kostia
Thanks, I already know about webfraction. Great site.

If anyone can provide cheaper solution, hosted in Europe, please write
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-us...@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: MySQL error -1

2010-07-29 Thread shacker
On Jul 29, 10:03 am, Dennis Kaarsemaker 
wrote:

> If you do 'select @@tmpdir', it'll probably say /tmp as that is the
> default. You can change this in /etc/my.cnf if you want.

Yep, that was the fix I applied (see above). So far everything's
working fine. Thanks for all the responses.

./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-us...@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: generate cache by visiting protected links

2010-07-29 Thread Benedict Verheyen
On 29/07/2010 17:16, Jirka Vejrazka wrote:
>   Well, it probably depends on the frequency od data change as well as
> other factors. I personally don't like spawning another thread in a
> request-response cycle, but if it works for you, be happy with it :)
> 
>   Based on the print statement on your code I assume your website does
> run under the development server, so you may have very different
> requirements than a usual production (read: always running) site :)
> 
>> As for the cache key, i did the reverse because i thought i had
>> read in the documentation that this was the standard way Django puts
>> stuff in the cache.
> 
>   Sure - you can do it, no problem. The reason Django uses it is that
> it caches various pages and the url pattern is a good way to make sure
> that the cache key is unique for each page. You could put anything
> there, even a static string :)
> 
>> But it's not the link as returned by reverse, though i haven't found yet
>> what it is. If i find it, i can set i correctly in the thread so that I don't
>> have to manually check to see if the page is cached when a statistics page
>> is called.
> 
>   You will always have to check it, as it's not guarranteed to stay in
> the cache forever. Assuming that the data is in cache is a Bad Thing
> :)
> 
>   If you set your cache key to "yearly_statistics" or something
> similar, you will have no issue with figuring out what the key is :)
> 
>   Cheers
> 
> Jirka
> 

I'm indeed running the development server for the moment but i'll
switch to a Apache/wsgi/nginx setup (i've already tested it).

I've just installed memcached and now i can see what links Django uses
ask keys. As for your comment, that i always have to check, you're right
but i rely on the Django caching mechanism to do that by specifying
cache_page in my urls.py (first i used the cache_page decorator):
...
url(r'^statistics/top/user/yearly/$', 
cache_page(stats_top_callers_per_year,60*60*24), 
name='stats_top_callers_per_year'),
...

I want to put the data in the cache with a key that Django generates itself
to fetch the data from the cache.

That's why i asked on what Django uses as a key to set and entry in the cache.
If i generate the page and put it on the cache and then rely on Django to get 
it,
the key i use needs to be the same as Django uses otherwise the page isn't 
found in the
cache and the page is generated again and then cached by Django.
And that's just what i want to avoid.
I'm happy to leave the caching to Django, i just want to "help" cache it 
initially :)

Anyway, thank you, you have given me lot's of info & insights !

Regards,
Benedict

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Need Help!

2010-07-29 Thread Ken
Looking for a django developer in the NYC area!
I would appreciate any help, if you know of anyone!
Thank you!

Ken

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



for httplib2, serialization or singleton?

2010-07-29 Thread yifan
I got a django web app where there is a httplib2 object used to do
HTTPS with client authentication connections to a apache server.

The problem is that for every request, my httplib2 object has to do a
SSL hand-shaking to apache, which is extremely slow.

I tried to save the httplib2 to the django's session but no luck.

Or anyone have any idea to build a singleton httplib2 object so as
long as the django is running, the object is there so it can be used
to do the HTTPS without re-connecting to apache?

thanks a lot

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: generate cache by visiting protected links

2010-07-29 Thread Jirka Vejrazka
> That's why i asked on what Django uses as a key to set and entry in the cache.
> If i generate the page and put it on the cache and then rely on Django to get 
> it,
> the key i use needs to be the same as Django uses otherwise the page isn't 
> found in the
> cache and the page is generated again and then cached by Django.
> And that's just what i want to avoid.
> I'm happy to leave the caching to Django, i just want to "help" cache it 
> initially :)

 OK - now I see what you're trying to achieve :)

 What is slow for you? Is it the data calculation, or actualy
constructing the HTML page from the data (read:context) and page
template?

  If it's the former, I'd still cache inside the function that
calculates the data (with a fixed string key) to get the "transparency
of the program". Using the "hack" with the cache key you plan to use
sounds clever, but a bit difficult to pick up if someone else needs to
read and understand the code later.

  Just my 2 cents :)

Jirka

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



When doing select_related, the sql query produced is an INNER JOIN can that be changed to LEFT JOIN

2010-07-29 Thread thusjanthan
Hi,

I have the following relation:

class Email(models.Model):
id = models.CharField(max_length=15,primary_key=True)

...

class Person(models.Model):
id= models.CharField(max_length=15,primary_key=True)
email = models.ForeignKey(Email, db_column='id')


When I do: Person.objects.select_related().all()
The query that is run is:

SELECT id,email FROM Person INNER JOIN Email ON (Person.id =
Email.id)

As you can see if a person did not have an email address, this will
produce an empty list. Is there any way to force select_related to do
a LEFT JOIN so that even if email is null, the person is returned with
email set to null.

Cheers,
Thusjanthan.







-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: unit testing and not creating database for read only database

2010-07-29 Thread thusjanthan
Any suggestions?

On Jul 7, 2:21 pm, thusjanthan  wrote:
> Hi,
>
> So I have a read only database called "information" which has been
> modeled in the django framework with the managed=false for the META on
> all its tables. When I run unit tests on another app I do not want the
> unit tests to go and create a test database for "information" but
> would rather like to use the information's table's values to compute
> some other tests for this app. Is there any way to do that in django?
>
> Thusjanthan.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



django_session not in "default" DB

2010-07-29 Thread Jocelo
Hi,

I have two DB configured on my django project... one in oracle and the
other one in MySQL...
My Oracle DB is the default one, and on MySQL I store data that is not
really related to my main application.

I want to store session data in MySQL, since oracle is legacy but
whenever I try to store something on my session object
("request.session['temp']=1"), django looks for django_session table
on Oracle, crashing completely my app.

I have read something about dabatase routing, but I'm not sure if this
is the way to go for this.

How can I make django look for django_session's table on my
"secondary" MySQL  DB ?

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



RegexURLPattern that matched of a specific HttpRequest?

2010-07-29 Thread Jari Pennanen
Hi!

I'm doing app that needs to list all urlconf patterns, thats easy,
just looping and flattening the includes inside urlpatterns of current
settings urlconf. But, the hard part is that I also need to know which
one is the current RegexURLPattern of executed view (specific
request's RegexURLPattern)?

I've tried to implement Middleware but there doesn't seem to be easy
way to get "current RegexURLPattern" of the request.

One way would probably be of re-resolving the URL in the request, but
that is unnecessary duplication since Django did that already because
it got to the view.

Any ideas? Any help is appreciated, 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-us...@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: When doing select_related, the sql query produced is an INNER JOIN can that be changed to LEFT JOIN

2010-07-29 Thread Daniel Roseman
On Jul 29, 8:49 pm, thusjanthan  wrote:
> Hi,
>
> I have the following relation:
>
> class Email(models.Model):
>     id = models.CharField(max_length=15,primary_key=True)
>
> ...
>
> class Person(models.Model):
>     id= models.CharField(max_length=15,primary_key=True)
>     email = models.ForeignKey(Email, db_column='id')
>
> When I do: Person.objects.select_related().all()
> The query that is run is:
>
> SELECT id,email FROM Person INNER JOIN Email ON (Person.id =
> Email.id)
>
> As you can see if a person did not have an email address, this will
> produce an empty list. Is there any way to force select_related to do
> a LEFT JOIN so that even if email is null, the person is returned with
> email set to null.
>
> Cheers,
> Thusjanthan.

It's not possible for a Person to exist without an Email in that model
structure, as the foreignkey does not have null=True. So an inner join
is the correct relationship. If you have null=True, it will correctly
create a left outer join (although you do have to explicitly specify
'email' inside the select_related call, as it doesn't follow null=True
relationships by default).
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: When doing select_related, the sql query produced is an INNER JOIN can that be changed to LEFT JOIN

2010-07-29 Thread akaariai
On 29 heinä, 22:49, thusjanthan  wrote:
> Hi,
>
> I have the following relation:
>
> class Email(models.Model):
>     id = models.CharField(max_length=15,primary_key=True)
>
> ...
>
> class Person(models.Model):
>     id= models.CharField(max_length=15,primary_key=True)
>     email = models.ForeignKey(Email, db_column='id')
>
> When I do: Person.objects.select_related().all()
> The query that is run is:
>
> SELECT id,email FROM Person INNER JOIN Email ON (Person.id =
> Email.id)
>
> As you can see if a person did not have an email address, this will
> produce an empty list. Is there any way to force select_related to do
> a LEFT JOIN so that even if email is null, the person is returned with
> email set to null.

You have set the email field (implicitly) as null=False, that is,
every person must have an associated email, hence left join will not
make sense in this query.

However, your example shows a validation bug: setting the
db_column='id' and having a column named id should clearly be an
error. I have opened a ticket for this (#14028).

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: through/unique_together usage

2010-07-29 Thread Dennis Kaarsemaker
On do, 2010-07-29 at 05:35 -0700, Dave wrote:

> In my application I want to enforce a each-image-can-only-be-assigned-
> to-a-single-patient 

So why do you use a ManyToManyField instead of a ForeignKey?
-- 
Dennis K.

They've gone to plaid!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django_session not in "default" DB

2010-07-29 Thread Dennis Kaarsemaker
On do, 2010-07-29 at 13:03 -0700, Jocelo wrote:
> Hi,
> 
> I have two DB configured on my django project... one in oracle and the
> other one in MySQL...
> My Oracle DB is the default one, and on MySQL I store data that is not
> really related to my main application.
> 
> I want to store session data in MySQL, since oracle is legacy but
> whenever I try to store something on my session object
> ("request.session['temp']=1"), django looks for django_session table
> on Oracle, crashing completely my app.
> 
> I have read something about dabatase routing, but I'm not sure if this
> is the way to go for this.

It is the way to go.

> How can I make django look for django_session's table on my
> "secondary" MySQL  DB ?

http://docs.djangoproject.com/en/dev/topics/db/multi-db/#automatic-database-routing
 has all the details. your router would look like:

class MyRouter(object):
def db_for_read(model, **hints):
if model == Session:
return 'secondary'
db_for_write = db_for_read


-- 
Dennis K.

They've gone to plaid!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



uncomplete internationalization of 'auth' in admin panel

2010-07-29 Thread bagheera
Internationalization of 'auth' app in django 1.2 isn't complete. In
user edit form there are user permissions displayed in two windows,
like "auth | permission | Can add permission", etc. I want it all
fully localized, but i can't digg up right code. Any ideas how to
solve that?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



'python manage.py startproject survey' does not add 'survey' to INSTALLED _APPS.

2010-07-29 Thread to_see
I am still new to Django, and am typing my way through some tutorials
(not running demo code).  I could not figure out why I was getting
incorrect results in an Admin demo, until I looked at the sample
code.

When I did this:

django-admin.py startproject marketr
cd marketr
python manage.py startapp survey

I got a full set of default filed, but settings.py did not include
'survey' at the end of the INSTALLED_APPS list, as the demos
indicate.  I have made several attempts, and not once have I gotten my
app in the list.  It's seems easy enough, so I would like to find out
what I'm doing wrong.

I'm running Django 1.2.1 with Python 2.6.5 on Ubuntu 10.04.
Considering that so many files are generated, correctly as far as I
can tell, I do not see why this one piece is missing.  Especially
since I read the FAQ and searched this forum, and looked at the list
of tickets and don't see anything that matches.

Help?

John.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: 'python manage.py startproject survey' does not add 'survey' to INSTALLED _APPS.

2010-07-29 Thread Martin Melin
On Thu, Jul 29, 2010 at 10:51 PM, to_see  wrote:
> I am still new to Django, and am typing my way through some tutorials
> (not running demo code).  I could not figure out why I was getting
> incorrect results in an Admin demo, until I looked at the sample
> code.
>
> When I did this:
>
> django-admin.py startproject marketr
> cd marketr
> python manage.py startapp survey
>
> I got a full set of default filed, but settings.py did not include
> 'survey' at the end of the INSTALLED_APPS list, as the demos
> indicate.  I have made several attempts, and not once have I gotten my
> app in the list.  It's seems easy enough, so I would like to find out
> what I'm doing wrong.
>
> I'm running Django 1.2.1 with Python 2.6.5 on Ubuntu 10.04.
> Considering that so many files are generated, correctly as far as I
> can tell, I do not see why this one piece is missing.  Especially
> since I read the FAQ and searched this forum, and looked at the list
> of tickets and don't see anything that matches.

I think it would be bad form for startapp to edit your settings file.
As far as the tutorial goes, adding your newly created app to
INSTALLED_APPS is covered right here:
http://docs.djangoproject.com/en/dev/intro/tutorial01/#activating-models

Cheers,
Martin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: uncomplete internationalization of 'auth' in admin panel

2010-07-29 Thread Dennis Kaarsemaker
On do, 2010-07-29 at 13:43 -0700, bagheera wrote:
> Internationalization of 'auth' app in django 1.2 isn't complete. In
> user edit form there are user permissions displayed in two windows,
> like "auth | permission | Can add permission", etc. I want it all
> fully localized, but i can't digg up right code. Any ideas how to
> solve that?

These strings do not come from the code but from the database.
Unfortunately django does not yet have a built-in mechanism for
internationalizing and translating those. There are third party addons
for this, though I have no idea whether they can be used for standard
django models.

-- 
Dennis K.

They've gone to plaid!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: 'python manage.py startproject survey' does not add 'survey' to INSTALLED _APPS.

2010-07-29 Thread to_see


Martin Melin wrote:
> On Thu, Jul 29, 2010 at 10:51 PM, to_see  wrote:
> > I am still new to Django, and am typing my way through some tutorials
> > (not running demo code).  I could not figure out why I was getting
> > incorrect results in an Admin demo, until I looked at the sample
> > code.
> >
> > When I did this:
> >
> > django-admin.py startproject marketr
> > cd marketr
> > python manage.py startapp survey
> >
> > I got a full set of default filed, but settings.py did not include
> > 'survey' at the end of the INSTALLED_APPS list, as the demos
> > indicate.  I have made several attempts, and not once have I gotten my
> > app in the list.  It's seems easy enough, so I would like to find out
> > what I'm doing wrong.
> >
> > I'm running Django 1.2.1 with Python 2.6.5 on Ubuntu 10.04.
> > Considering that so many files are generated, correctly as far as I
> > can tell, I do not see why this one piece is missing.  Especially
> > since I read the FAQ and searched this forum, and looked at the list
> > of tickets and don't see anything that matches.
>
> I think it would be bad form for startapp to edit your settings file.
> As far as the tutorial goes, adding your newly created app to
> INSTALLED_APPS is covered right here:
> http://docs.djangoproject.com/en/dev/intro/tutorial01/#activating-models
>
> Cheers,
> Martin

Thanks, Martin.

Huh.  I missed that one, I was working from a book I bought, which did
not explain that I needed to do that, as far as I can tell (but maybe
I am a bit careless?).  I will try to be more careful!

John.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Regex problem in urls

2010-07-29 Thread Gordy
I'm a rookie at Django so this is probably something obvious.

My urls.py looks like this:

from django.conf.urls.defaults import *

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


urlpatterns = patterns('',
# Example:
# (r'^sunlight/', include('sunlight.foo.urls')),

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

# Uncomment the next line to enable the admin:
(r'^admin/(.*)', 'admin.site.root'),
(r'^start/', 'sunlight.start.views.index'),
(r'req/','sunlight.requests.views.index'),
)
~


When I hit the site, I get:

Page not found (404)
Request Method: GET
Request URL:http://server2/start/

Using the URLconf defined in sunlight.urls, Django tried these URL
patterns, in this order:

   1. ^admin/doc/
   2. ^admin/(.*)
   3. ^[/]$
   4. req/

The current URL, start/, didn't match any of these.

So it looks like it isn't properly interpreting the regex on line 3.

Any help would be appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



field.label in template converts to lower case in 1.2.1

2010-07-29 Thread Jeff Green
With Django 1.2.1 it seems that my html template causes the
field.label to display
in lower case except for the first character. Has anyone experienced
this before and how do you
get it display without lower case conversion


My html template snippet is:

{% for field in form %}

{{ field.label_tag}}

Thanks,
Jeff

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



LANGUAGES var isn't in all views

2010-07-29 Thread Alexandre González
Hi!

I have this templates:

39 
40 
41 
42 {% for lang in LANGUAGES %}
43 {{ lang.1 }}
44 {% endfor %}
45 
46 
47 

That show my languages in the webpage. I made it with tutorial:
http://djangobook.com/en/2.0/chapter19/ (at the end).

It works perfectly in some webs, but in others the var LANGUAGES isn't
provide automatically, do i need to send it in the views? I've done it
sometimes with request.user, example:

10 def show_business(request):
11 objects = Business.objects.filter(user=request.user)
12 return render_to_response('business/show.html', {'objects': objects,
*'user': request.user* })

This is my settings options:

  6 LANGUAGES = (
  7 ('es', 'Español'),
  8 ('en', 'English'),
  9 )
...
 71 MIDDLEWARE_CLASSES = (
 72 'django.contrib.sessions.middleware.SessionMiddleware',
 73 'django.middleware.locale.LocaleMiddleware',
 74 'django.middleware.common.CommonMiddleware',
 75 'django.contrib.auth.middleware.AuthenticationMiddleware',
 76 )

Thanks for the help!

Bye,
Álex González

-- 
Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
and/or .pptx
http://mirblu.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Best way to find near people

2010-07-29 Thread Alexandre González
Hi!

I'm searching near people in my app. I'm doing it a this way:

37 people = Person.objects.all().exclude(user=request.user)
38
39 near_people = list()
40 for person in people:
41 if self.is_near(me.coordinates, person.coordinates):
near_people.append(person)

Now, I'm getting all the the Person objects. This is a inefficient way.

The coordinates are latitude/longitude coordinates, so I think in test the
variation and get only latitude +/- 1 and longitude +/- 1 and after this, do
the test exactly (the funcion is_near).

But instead this, can I "draw" a circle and search only Person objects
inside it?

Thanks!

-- 
Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
and/or .pptx
http://mirblu.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: field.label in template converts to lower case in 1.2.1

2010-07-29 Thread Jason
I think Django's been doing that for a long time (not just 1.2.1).

Probably the quick and easy way to change case would be to use just
field.label and pump it into whatever format you want:

{{ field.label|upper }}

You'll have to manually create the rest of the html for the label
using field.html_name

I've run into some slight problems figuring out the proper id's for
the corresponding labels... Normally it's just
id_{{ field.html_name }} but if you get into auto_id's as well as
labels for more complex things (radio button lists, etc) it can get a
little bit funky.


On Jul 29, 2:42 pm, Jeff Green  wrote:
> With Django 1.2.1 it seems that my html template causes the
> field.label to display
> in lower case except for the first character. Has anyone experienced
> this before and how do you
> get it display without lower case conversion
>
> My html template snippet is:
>
> {% for field in form %}
>
>     {{ field.label_tag}}
>
> Thanks,
> Jeff

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Best way to find near people

2010-07-29 Thread Bill Freeman
Circle is hard.  What you can do is create a bounding box which is
rectangular in lat/long space (if not in physical space) whose sides
are tangent to your desired distance circle.  You will search a few
more users than if you could really restrict them to the distance
circle a priori, but it will significantly cut down the number of trig
functions you execute.  (Limiting to the bounding box takes at most
four floating compares - I do it in the data base.)

The northern and southern boundaries are easy.  Getting the eastern
and western sides requires realizing that (your choice of) pole, the
center of the distance circle, and the point at which the distance
circle is tangent to a line of longitude, form a spherical right triangle,
with the tangent point being the right angle.  I found a suitable
formula in my old DRC math tables, but I'm sure that you can find
it on the web as well.

Bill


2010/7/29 Alexandre González :
> Hi!
> I'm searching near people in my app. I'm doing it a this way:
> 37             people = Person.objects.all().exclude(user=request.user)
> 38
> 39             near_people = list()
> 40             for person in people:
> 41                 if self.is_near(me.coordinates, person.coordinates):
> near_people.append(person)
> Now, I'm getting all the the Person objects. This is a inefficient way.
> The coordinates are latitude/longitude coordinates, so I think in test the
> variation and get only latitude +/- 1 and longitude +/- 1 and after this, do
> the test exactly (the funcion is_near).
> But instead this, can I "draw" a circle and search only Person objects
> inside it?
> Thanks!
> --
> Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
> and/or .pptx
> http://mirblu.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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: field.label in template converts to lower case in 1.2.1

2010-07-29 Thread Jeff Green
For example, the field name is Programmer Serial Number but it is being
displayed
as Programmer serial number

I have not had this issue in 1.1.1. I was wondering if there was a way to
ignore the conversion.

On Thu, Jul 29, 2010 at 5:02 PM, Jason  wrote:

> I think Django's been doing that for a long time (not just 1.2.1).
>
> Probably the quick and easy way to change case would be to use just
> field.label and pump it into whatever format you want:
>
> {{ field.label|upper }}
>
> You'll have to manually create the rest of the html for the label
> using field.html_name
>
> I've run into some slight problems figuring out the proper id's for
> the corresponding labels... Normally it's just
> id_{{ field.html_name }} but if you get into auto_id's as well as
> labels for more complex things (radio button lists, etc) it can get a
> little bit funky.
>
>
> On Jul 29, 2:42 pm, Jeff Green  wrote:
> > With Django 1.2.1 it seems that my html template causes the
> > field.label to display
> > in lower case except for the first character. Has anyone experienced
> > this before and how do you
> > get it display without lower case conversion
> >
> > My html template snippet is:
> >
> > {% for field in form %}
> >
> > {{ field.label_tag}}
> >
> > Thanks,
> > Jeff
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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.



UnicodeEncodeError

2010-07-29 Thread Eric
I am getting this error in the Django Administration section when I
add an entry for a Dashboard object.

When I return to the item in the Admin section, the record has been
added and it displays correctly in the list of Dashboard objects. When
I click on it, it shows correctly. Only when I add a new one or save
one does that happend. And, I noticed that the history is not
populated.

The traceback is:

Environment:

Request Method: POST
Request URL: http://127.0.0.1:8000/admin/dashboard/dashboard/1/
Django Version: 1.2.1
Python Version: 2.6.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.admin',
 'ManagementReview.dashboard']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/django/core/handlers/base.py" in get_response
  100. response = callback(request,
*callback_args, **callback_kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/django/contrib/admin/options.py" in wrapper
  239. return self.admin_site.admin_view(view)(*args,
**kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/django/utils/decorators.py" in _wrapped_view
  76. response = view_func(request, *args,
**kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/django/views/decorators/cache.py" in
_wrapped_view_func
  69. response = view_func(request, *args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/django/contrib/admin/sites.py" in inner
  190. return view(request, *args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/django/utils/decorators.py" in _wrapper
  21. return decorator(bound_func)(*args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/django/utils/decorators.py" in _wrapped_view
  76. response = view_func(request, *args,
**kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/django/utils/decorators.py" in bound_func
  17. return func(self, *args2, **kwargs2)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/django/db/transaction.py" in
_commit_on_success
  299. res = func(*args, **kw)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/django/contrib/admin/options.py" in
change_view
  901. self.log_change(request, new_object,
change_message)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/django/contrib/admin/options.py" in log_change
  443. object_repr = force_unicode(object),
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/django/utils/encoding.py" in force_unicode
  66. s = unicode(s)
File "/Users/Eric/Documents/DjangoProjects/ManagementReview/../
ManagementReview/dashboard/models.py" in __unicode__
  47. return u"%s" % self.name.decode('utf-8')
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/encodings/utf_8.py" in decode
  16. return codecs.utf_8_decode(input, errors, True)

Exception Type: UnicodeEncodeError at /admin/dashboard/dashboard/1/
Exception Value: ('ascii', u"Eric's Nifty D\xe4shboard Entry", 14, 15,
'ordinal not in range(128)')


The model looks like this:

class Dashboard(models.Model):
name = models.CharField("Dashboard name",max_length=100)
fiscal_year = models.IntegerField("Fiscal year")
region = models.CharField("Region", max_length=30)
review_date = models.DateField("Review date")
date_completed = models.DateField("Date Completed")

def __unicode__(self):
return u"%s" % self.name.decode('utf-8')

Can somebody help me figure out what is going on here?

Thanks
Eric

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: field.label in template converts to lower case in 1.2.1

2010-07-29 Thread Jason
Post the form class (or model if you are generating it from a model).

On Jul 29, 3:17 pm, Jeff Green  wrote:
> For example, the field name is Programmer Serial Number but it is being
> displayed
> as Programmer serial number
>
> I have not had this issue in 1.1.1. I was wondering if there was a way to
> ignore the conversion.
>
> On Thu, Jul 29, 2010 at 5:02 PM, Jason  wrote:
> > I think Django's been doing that for a long time (not just 1.2.1).
>
> > Probably the quick and easy way to change case would be to use just
> > field.label and pump it into whatever format you want:
>
> > {{ field.label|upper }}
>
> > You'll have to manually create the rest of the html for the label
> > using field.html_name
>
> > I've run into some slight problems figuring out the proper id's for
> > the corresponding labels... Normally it's just
> > id_{{ field.html_name }} but if you get into auto_id's as well as
> > labels for more complex things (radio button lists, etc) it can get a
> > little bit funky.
>
> > On Jul 29, 2:42 pm, Jeff Green  wrote:
> > > With Django 1.2.1 it seems that my html template causes the
> > > field.label to display
> > > in lower case except for the first character. Has anyone experienced
> > > this before and how do you
> > > get it display without lower case conversion
>
> > > My html template snippet is:
>
> > > {% for field in form %}
>
> > >     {{ field.label_tag}}
>
> > > Thanks,
> > > Jeff
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@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-us...@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.



Raw sql and admin site

2010-07-29 Thread Spoksss
Hi,

I try to use raw sql in admin site, it is possible somehow?

I use postresql and have some problem with ordering.

I have in database something like:
Category(id=1, name='first', parent_category=None,
materialised_path='1')
Category(id=2, name='child1 of first', parent_category=1,
materialised_path='1.2')
Category(id=1, name='child2 of first', parent_category=1,
materialised_path='1.3')
...
Category(id=10, name='second', parent_category=None,
materialised_path='10')

and now if i use normal sql 'select name, materialised_path from
category order by materialised_path'
and i get:
first 1
second 10
child1 of first 1.2
child2 of first 1.3

but i need:
first 1
child1 of first 1.2
child2 of first 1.3
second 10

because postgres is set to use utf collate, so in this moment i try
use ~<~ operator in raw query:

categories = models.Category.objects.raw('''SELECT "category"."id",
"category"."name", "category"."idname", "category"."prio",
"category"."description", "category"."materialised_path",
"category"."parent_category_id", "category"."category_container_id"
FROM "category  ORDER BY materialised_path using ~<~''')

of course in def queryset(self, request) of CategoryAdmin.

But I get database error, I think admin not supports raw query or I
use it not correct in this place.

Do You know how can I use "~<~" in admin site?


regards

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



test's client.post says post but request.method says GET

2010-07-29 Thread Phlip
Django aficionados:

Here's my test code:

from django.test.client import Client
self.client = Client()
from django.core.files.base import ContentFile
file_content = ContentFile(sample_inventory_update_cvs())
file_content.name = 'response.csv'

response = self.client.post( self.url,
 data={'csv_file':file_content} )

Disregard all that ContentFile nonsense (unless it's causing the bug).

Inside the action code, I want to distinguish GETting from POSTing.
One paints the page and the other absorbs new form data, as usual.

However, when I print request.method, I get GET.

Is this a bug in Client? or in (ahem) my comprehension?

--
  Phlip
  http://c2.com/cgi/wiki?ZeekLand

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: test's client.post says post but request.method says GET

2010-07-29 Thread Phlip
forgot to mention Django 1.1.2

On Jul 29, 5:18 pm, Phlip  wrote:
> Django aficionados:
>
> Here's my test code:
>
>         from django.test.client import Client
>         self.client = Client()
>         from django.core.files.base import ContentFile
>         file_content = ContentFile(sample_inventory_update_cvs())
>         file_content.name = 'response.csv'
>
>         response = self.client.post( self.url,
>                                      data={'csv_file':file_content} )
>
> Disregard all that ContentFile nonsense (unless it's causing the bug).
>
> Inside the action code, I want to distinguish GETting from POSTing.
> One paints the page and the other absorbs new form data, as usual.
>
> However, when I print request.method, I get GET.
>
> Is this a bug in Client? or in (ahem) my comprehension?
>
> --
>   Phlip
>  http://c2.com/cgi/wiki?ZeekLand

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Best way to find near people

2010-07-29 Thread Tim Chase

On 07/29/10 16:58, Alexandre González wrote:

Hi!

I'm searching near people in my app. I'm doing it a this way:

37 people = Person.objects.all().exclude(user=request.user)
38
39 near_people = list()
40 for person in people:
41 if self.is_near(me.coordinates, person.coordinates):
near_people.append(person)

Now, I'm getting all the the Person objects. This is a inefficient way.


You might be able to use F() objects and limit by the square of 
the difference...but I can't figure out how to annotate an object 
with a F()something like this (untested)


  THRESHOLD = 10 # miles
  Person.objects.filter(THRESHOLD_gt=
   ((F('coordinates__x') - me.coordinates.x) *
(F('coordinates__x') - me.coordinates.x)) +
   ((F('coordinates__y') - me.coordinates.y) *
(F('coordinates__y') - me.coordinates.y))
   )

However, it could be done with a .extra() call something like 
(using "coord" instead of "coordinates" because I'm lazy)


  x = float(user.coords.x) # or int() or whatever
  y = float(user.coords.y)
  people = Person.objects.exclude(user=user)
  annotated_people = people.extra(select={
'distance': """
   ((coord.x - %s) * (coord.x - %s)) +
   ((coord.y - %s) * (coord.y - %s))
   """ % (x, x, y, y),
}
  THRESHOLD = 10
  near_people = annotated_people.filter(
distance__lt=THRESHOLD**2
)

It's using raw Python string interpolation which should be safe 
with float() or int() for the user.coordinates and not open to a 
SQL injection as a string would.


The normal distance calculation is sqrt(dx*dx + dy*dy) but you 
can remove the often-expensive sqrt() calculation by simply 
squaring the threshold (THRESHOLD**2) and comparing it to the sum 
of the squares of the differences. (a little algebra/geometry there).


Alternatively, you could .order('-distance') and then slice those 
results, taking the top 10 nearest or paginate them by distance 
putting the nearest people at the front.


-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-us...@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: Best way to find near people

2010-07-29 Thread Christophe Pettus

On Jul 29, 2010, at 2:58 PM, Alexandre González wrote:

> Hi!
> 
> I'm searching near people in my app. I'm doing it a this way:
> 
> 37 people = Person.objects.all().exclude(user=request.user)
> 38 
> 39 near_people = list()
> 40 for person in people:
> 41 if self.is_near(me.coordinates, person.coordinates): 
> near_people.append(person)
> 
> Now, I'm getting all the the Person objects. This is a inefficient way.
> 
> The coordinates are latitude/longitude coordinates, so I think in test the 
> variation and get only latitude +/- 1 and longitude +/- 1 and after this, do 
> the test exactly (the funcion is_near).
> 
> But instead this, can I "draw" a circle and search only Person objects inside 
> it?

I'm not sure what database you are using, but if you are using PostgreSQL, it 
has built-in geometric operators specifically for this kind of thing.  You 
might have to drop down into SQL, but in 1.2, that's nice and easy.

The PostgreSQL documentation on this is at:

http://www.postgresql.org/docs/8.4/interactive/datatype-geometric.html
--
-- Christophe Pettus
   x...@thebuild.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Newbie: how to tell a URL for a page?

2010-07-29 Thread BobAalsma
Thanks very much!

Yes, I agree, probably not specifically Django, but it is the
environment where I needed the answer.

At least this will give me something to work with/from :-)

Regards,
Bob

On Jul 29, 8:03 am, Carlos Daniel Ruvalcaba Valenzuela
 wrote:
> Hello, your question probably does not have much to do with Django (as
> a framework), but you may be able to check at the iframeurlby
> quering the DOM using javascript, either directly or via a library
> like jquery if you are already using one.
>
> Check the W3C documentation for the frame/iframe DOM:
>
> http://www.w3schools.com/jsref/dom_obj_frame.asp
>
> The iframe should contain a document object which should contain theURLloaded 
> on the frame.
>
> Regards,
> Carlos Daniel Ruvalcaba Valenzuela
>
> On Wed, Jul 28, 2010 at 10:57 PM, BobAalsma  wrote:
> > This question has been in the forum for about almost a week & no
> > response. So please help anewbieout: is it too easy or too difficult
> > to answer?
>
> > On Jul 24, 7:29 pm, BobAalsma  wrote:
> >> I'm working on a programme where I want the user to register comments
> >> on a third party webpage.
> >> To show this third partypage, I intend to use frames or iframes, but
> >> I discovered that some of the URLs redirect. This means that thepage
> >> shown in the (i)frame will have a differentURLfrom theURLI use.
> >> The redirection is in itself also information I want to show.
>
> >> So my question is: how can I tell theURLof thepage(finally) shown
> >> in the (i)frame?
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@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-us...@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.



Django Dev server doesn't reflect changes

2010-07-29 Thread barun
Hi Developers,

I'm using Django and it's development server to test my pages.
However, the Dev server behaves strangely. It doesn't always reflect
the recent changes made in code. For example, a file demo.js has an
image reference. I had changed the image URL (and saved). But when I
run the application, it still displays image with the old URL.

I've restarted the server, browser. Do I need to do anything else?

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-us...@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: Best way to find near people

2010-07-29 Thread Jani Tiainen
> On Jul 29, 2010, at 2:58 PM, Alexandre González wrote:
> > Hi!
> > 
> > I'm searching near people in my app. I'm doing it a this way:
> > 
> > 37 people = Person.objects.all().exclude(user=request.user)
> > 38
> > 39 near_people = list()
> > 40 for person in people:
> > 41 if self.is_near(me.coordinates, person.coordinates):
> > near_people.append(person)
> > 
> > Now, I'm getting all the the Person objects. This is a inefficient way.
> > 
> > The coordinates are latitude/longitude coordinates, so I think in test
> > the variation and get only latitude +/- 1 and longitude +/- 1 and after
> > this, do the test exactly (the funcion is_near).
> > 
> > But instead this, can I "draw" a circle and search only Person objects
> > inside it?
> 
> I'm not sure what database you are using, but if you are using PostgreSQL,
> it has built-in geometric operators specifically for this kind of thing. 
> You might have to drop down into SQL, but in 1.2, that's nice and easy.
> 
> The PostgreSQL documentation on this is at:
> 
>   http://www.postgresql.org/docs/8.4/interactive/datatype-geometric.html
> --
> -- Christophe Pettus
>x...@thebuild.com

Or if spatial operations are really needed, why not to use real spatial 
database and GeoDjango (django.contrib.gis). Spatialite, Postgis, Mysql or 
oracle. All supports at spatial to some extent. And there you can do easily 
simple filtering:

Person.objects.filter(person_coordinates__dwithin(me.coordinates, distance))

...and geodjango + spatial engine behind it will take care of all that complex 
stuff.

Note: you can still use GEOS parts from geodjango to do calculations so you 
don't have to reinvent wheel if you want to keep coordinates as you already 
have.

-- 

Jani Tiainen

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



django autocomplete search with jQuery

2010-07-29 Thread Joel Klabo
I have been looking around for some examples but I can't find anything
recent. This is my first AJAX experience so I would love to just see
an example because it's not quite making sense to me. Does anyone know
of a tutorial? Or have some code samples I could check out? I have
checked google btw.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django Dev server doesn't reflect changes

2010-07-29 Thread barun
I guess I found the solution. I cleared the browser cache, and then
all the files were retrieved afresh. All changes were reflected.

On Jul 30, 10:25 am, barun  wrote:
> Hi Developers,
>
> I'm using Django and it's development server to test my pages.
> However, the Dev server behaves strangely. It doesn't always reflect
> the recent changes made in code. For example, a file demo.js has an
> image reference. I had changed the image URL (and saved). But when I
> run the application, it still displays image with the old URL.
>
> I've restarted the server, browser. Do I need to do anything else?
>
> 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django Dev server doesn't reflect changes

2010-07-29 Thread Kenneth Gonsalves
On Friday, July 30, 2010 10:55:13 am barun wrote:
> I've restarted the server, browser. Do I need to do anything else?

browser cache?
-- 
Regards
Kenneth Gonsalves
Senior Associate
NRC-FOSS at AU-KBC

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.