Re: Django app and Amazon AWS (beginner)

2011-03-16 Thread Venkatraman S
On Thu, Mar 17, 2011 at 12:21 AM, Nate Aune  wrote:

>
> If you want to get your Django app deployed up on Amazon's infrastructure
> and don't want to mess around with config files and servers, I invite you to
> try out our DjangoZoom service which is built on top of Amazon's AWS
> infrastructure. http://djangozoom.com  We take care of all the server-side
> stuff, so you don't have to.
>

I have signed up - would be interesting to see how you take care of custom
settings.

-V
http://blizzardzblogs.blogspot.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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django Deploy Updates App.

2011-03-16 Thread Mike Dewhirst

Matteius

Check Ryan Kelly's esky - http://pypi.python.org/pypi/esky

This is for "frozen" python apps but the principle you describe is 
central to esky.


Mike

On 17/03/2011 1:36pm, Matteius wrote:

One of the things I've considered lately that I would like for my
Django project is a Word Press like internal update tool.  Something
that would tie into the contrib admin and work to update the app from
either a repository or a deployment file.  This tool app would need to
add new files, update existing files and delete/remove dead files.
It would be easy to tie in an apache restart into the UI also.  Any
thoughts, what is out there that might resemble something like this?>



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



Django Deploy Updates App.

2011-03-16 Thread Matteius
One of the things I've considered lately that I would like for my
Django project is a Word Press like internal update tool.  Something
that would tie into the contrib admin and work to update the app from
either a repository or a deployment file.  This tool app would need to
add new files, update existing files and delete/remove dead files.
It would be easy to tie in an apache restart into the UI also.  Any
thoughts, what is out there that might resemble something like this?>

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



About using Django Auth with my app, Auto saving the User

2011-03-16 Thread AJ
I have a model like this:

class Post (models.Model):
name = models.CharField(max_length=1000, help_text="required, name
of the post")
description = models.TextField(blank=True)
custom_hashed_url = models.CharField(unique=True, max_length=1000,
editable=False)

def save(self, *args, **kwargs):
#How to save User here?
super(Model, self).save()

View code:

if not errors:
f = PostForm(request.POST)
f.save()

There is an old post that I followed but could not do it. And also
this post is old. 
http://www.b-list.org/weblog/2006/nov/02/django-tips-auto-populated-fields/

Even though I have the user field as FK, I get this error: 'Cannot
assign None: "MyModel.user" does not allow null values.'

This essentially means (IMHO) that my View does not send the User
along. How can I auto populate the user field with Django User, the
currently logged in user.

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



Re: Format DateTimeField of a model

2011-03-16 Thread Vinicius Massuchetto
2011/3/16 Daniel Roseman :
> On Wednesday, March 16, 2011 5:37:23 PM UTC, Vinicius Massuchetto wrote:
>>
>> I want to customize the DateTimeField returned in an admin list
>> column. I know there's the DATETIME_FORMAT setting, but I only want to
>> change in one model. I'lm also using L10N, and couldn't figure out if
>> there's a way to override what's in the default po file for my
>> language.
>>
>> What's the right way of doing that? Please note that I want to
>> preserve the sorting feature of this column.

> Create a custom admin method that returns the formatted value, and specify
> that in the `list_display` method. Make sure you set the `admin_order_field`
> property on the method to preserve the ordering functionality.
>     class MyAdmin(admin.ModelAdmin):
>         list_display = ('name', 'my_date_display')
>         def my_date_display(self, obj):
>             return obj.my_date_field.strftime('your-display-format')
>         my_date_display.admin_order_field = 'my_date_field'

Awesome. Thanks.

-- 
Vinicius Massuchetto

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



Decoupling shopping cart from checkout

2011-03-16 Thread Micah Carrick
I have a Django app for a shopping cart, and another for checkout (checkout
form, payment gateway, order processing). I would really like for these to
be completely decoupled but am having a hard time coming up with a solution
that gives me a warm fuzzy feeling.

Here is a simplification:

Checkout is fed line item data (sku, description, qty, price) where a line
item might represent a product, shipping, tax, a discount--anything. This is
the only data checkout needs. Now, the cart has all of this information. So
my current implementations of these applications has the checkout app
depending on the cart to feed it that data. I would checkout to be able to
be fed the line items in a more generic abstract way, but, without having a
redundancy when the cart application is used with it.

I cannot feed checkout with data in a POST or session because you don't want
prices floating around where people could change them. So the data has to be
fed from the DB based on an id stored in the session (wow, that sounds a lot
like a cart, doesn't it!). The goal would be that I could pair the checkout
app with the cart app and it works like it does now, but, also be able to
use the checkout app on sites that don't need a cart at all (say, somebody
who sells one product, accepts donations, one event registration at a time,
etc).

Thoughts?

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



Re: automatically create user profile on user creation

2011-03-16 Thread shantp
Check out this blog post for a one line solution to the same problem.

http://www.turnkeylinux.org/blog/django-profile

On Mar 16, 11:54 am, Ori Livneh  wrote:
> Hi guys,
>
> The Django docs explain that "the method get_profile() does not create the
> profile, if it does not exist. You need to register a handler for the signal
> django.db.models.signals.post_save on the User model, and, in the handler,
> if created=True, create the associated user profile." (http://goo.gl/jNo91)
>
> But there's no code sample. A few weeks ago (with some help from friendly
> people on #django) I came up with this snippet:
>
> # ~ snippet start ~
>
> @receiver(post_save, sender=User)
> def create_profile(sender, instance, created, **kwargs):
>     """Create a matching profile whenever a User is created."""
>     if created:
>         profile, new = UserProfile.objects.get_or_create(user=instance)
>
> # ~ snippet end ~
>
> (I use get_or_create as extra insurance against cases wherein a User is
> created, deleted, and then created anew.)
>
> Is there anything in this snippet that should be fixed or improved?
>
> If it's OK, do you think it makes sense to include it in the docs? I ask
> because getting user profiles to work is liable to be something new Django
> developers want to do, but signals are something of an intermediate/advanced
> topic.
>
> Thanks,
> Ori
>
> PS I wrote this up on my blog with a slightly lengthier explanation, in case
> anyone finds it 
> useful:http://floru.it/2011/using-signals-to-create-user-profiles-in-django-...

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



Re: How to format the "value" attribute of an option in a Select List using the template language for loop

2011-03-16 Thread werefr0g

Well... here is the lin (right into the relevant section) :
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#for

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



Re: How to format the "value" attribute of an option in a Select List using the template language for loop

2011-03-16 Thread werefr0g

Sorry again,

Actually, the doc tell us the way [1]. Simply use {{ forloop.counter }} 
or {{ forloop.counter0 }}.


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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to format the "value" attribute of an option in a Select List using the template language for loop

2011-03-16 Thread werefr0g

Hi,

You'll probably need to prepare the "options" in your view; with 
enumerate(), for example (paginator may be a little too much, sorry).


Regards,

[1] http://docs.python.org/library/functions.html#enumerate


Le 16/03/2011 04:18, Juan Gabriel Aldana Jaramillo a écrit :

Hi,

Check this link.
http://www.djangobook.com/en/2.0/chapter19/

I think this is an example about what you are looking for:


__
 _{% for lang in LANGUAGES %}
 {{ lang.1 }}
 {% endfor %}_
__




On Tue, Mar 15, 2011 at 3:04 PM, werefr0g > wrote:


Hello,

If you use a paginator [1], you'll prepare the "index number" in
the view but this will provide all the context you need in your
template.

Regards,

[1] http://docs.djangoproject.com/en/dev/topics/pagination/

-- 
You received this message because you are subscribed to the Google

Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com
.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.


--
You received this message because you are subscribed to the Google 
Groups "Django users" group.

To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


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



Re: Mingus vs Zinnia

2011-03-16 Thread Nate Aune
We're using Zinnia for http://djangozoom.com/blog and it's working pretty 
well. We wanted to embed Youtube videos and TinyMCE was stripping out the 
 tags, so we had to override the .js to get TinyMCE to allow the 
iframe tags.

Nate

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



natural keys for auth.user and group

2011-03-16 Thread Rainy
Hi, I know natural keys possibly will be added to auth.user and group
in 1.4. I'm using 1.2 currently and I'm trying to add them
dynamically:


class UserManager(models.Manager):
def get_by_natural_key(self, username, first_name):
return self.get(username=username, first_name=first_name)

class GroupManager(models.Manager):
def get_by_natural_key(self, name):
return self.get(name=name)

def unatural_key(self):
return (self.username, self.first_name)

def gnatural_key(instance):
return (self.name,)

User.objects = UserManager()
Group.objects = GroupManager()
User.natural_key = unatural_key
Group.natural_key = gnatural_key


It seems like it should work.. (?) but I get this error when trying
to serialize using natural keys:


Traceback (most recent call last):
  File "data.py", line 362, in 
Backup().main()
  File "data.py", line 333, in main
if   options.dump: self.do_dump(default_datafile,
self.classes)
  File "data.py", line 232, in do_dump
use_natural_keys=True)
  File "/usr/local/lib/python2.6/dist-packages/django/core/serializers/
__init__.py", line 87, in serialize
s.serialize(queryset, **options)
  File "/usr/local/lib/python2.6/dist-packages/django/core/serializers/
base.py", line 39, in serialize
for obj in queryset:
  File "/usr/local/lib/python2.6/dist-packages/django/db/models/
query.py", line 106, in _result_iter
self._fill_cache()
  File "/usr/local/lib/python2.6/dist-packages/django/db/models/
query.py", line 760, in _fill_cache
self._result_cache.append(self._iter.next())
  File "/usr/local/lib/python2.6/dist-packages/django/db/models/
query.py", line 230, in iterator
fields = self.model._meta.fields
AttributeError: 'NoneType' object has no attribute '_meta'



Is there a way to do this without patching django?

thanks, -ak

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



user confused with select_related and a one_to_one field

2011-03-16 Thread Sells, Fred
I'm using python 2.4 and django 1.2.4 with MySQL 5.0 FWIW

I have the following models (code deleted to simplify)

class Message(models.Model):
facility= models.CharField(max_length=2, null=True, blank=True)
msgtype = models.CharField(max_length=3)


class Pv(models.Model):
message =  models.OneToOneField(Message, primary_key=True,
db_column='id')
location= models.CharField(max_length=6, null=True,
blank=True)
priorfacility   = models.CharField(max_length=2, null=True,
blank=True)


Now I've discovered that on rare occasions Pv does not exists and thus
referencing it like this

for message in  models.Message.objects.select_related():
new = [message.pv.facility, ... 

throws
django.db.models.base.DoesNotExist: Pv matching query does not exist.
When I encounter a missing PV record.

Is this my improper use of OneToOneField and I should have used
ForeignKeyField ?
Is there a way to see if the PV object exists other than surrounding it
with a try/except clause ?

The times when Pv is missing are rare; would it make more sense to just
create a record with nulls and maintain the 1-to-1 relationship?

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



RE: using Django from cron

2011-03-16 Thread Sells, Fred
Thanks to all who responded and especially Shawn who said much the same
thing in a way I could grasp.

...

import os

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'


>From the docs:
http://docs.djangoproject.com/en/dev/topics/settings/

Shawn


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



Re: permissions don't get added

2011-03-16 Thread tom
hey tom,

thanks for pointing me to that error. Have looked at it for a while,
but haven't recognized the obvious.
it is working now, surprise. :)

best regards, tom

On 16 Mrz., 16:10, Daniel Roseman  wrote:
> On Wednesday, March 16, 2011 2:50:05 PM UTC, Tom Evans wrote:
>
> > On Wed, Mar 16, 2011 at 1:28 PM, tom  wrote:
> > > Hello,
>
> > > I have a model, which was already created within the DB, and I added
> > > following permissions:
> > >    class META:
>
> > ^^ Django looks for an inner class named 'Meta', not 'META'.
>
> > Cheers
>
> > Tom
>
> Since version 0.91, over five years ago, anyway...
> --
> 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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How i can get username into the error mail?

2011-03-16 Thread emonk
thanks Margie, I already did with the info you gave me Tom.

2011/3/16 Margie Roginski 

> I found the basics for this by googling around, and I can't remember
> where I got it, but thanks to whomever gave me the basics because it
> is very useful.  Put this in your middleware and it will make the mail
> that you receive have the name of the user and their email:
>
> class ExceptionUserInfoMiddleware(object):
>"""
>Adds user details to request context on receiving an exception, so
> that they show up in the error emails.
>Add to settings.MIDDLEWARE_CLASSES and keep it outermost(i.e. on
> top if possible). This allows
>it to catch exceptions in other middlewares as well.
>
>"""
>
>def process_exception(self, request, exception):
>"""
>Process the exception.
>
>:Parameters:
>- `request`: request that caused the exception
>- `exception`: actual exception being raised
>"""
>
>try:
> if request.user.is_authenticated():
> request.META['USERNAME'] = str(request.user.username)
>request.META['USER_EMAIL'] = str(request.user.email)
>else:
>request.META['USERNAME'] = "UNKNOWN"
>request.META['USER_EMAIL'] = "UNKNOWN"
>except:
>request.META['USERNAME'] = "UNKNOWN"
>request.META['USER_EMAIL'] = "UNKNOWN"
>pass
>
> And for the record, I of course agree that being able to google and
> then adapt things is very important.  But this is a common need so it
> seems worthwhile to post it explicitly to help the django community.
>
> Margie
>
>
> On Mar 16, 11:49 am, Shawn Milochik  wrote:
> > On Wed, Mar 16, 2011 at 2:47 PM, emonk  wrote:
> > > I'm tired of searching and found many examples of middleware but not
> the one
> > > I seek
> >
> > You almost certainly will not find the exact code you need to cut &
> > paste. You need to read the examples you did find and learn something.
> > Use that knowledge to write what you need. That's what the rest of us
> > do.
> >
> > Shawn
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: How i can get username into the error mail?

2011-03-16 Thread emonk
The only one who respone me an good help is Tom Evans. The rest just
repeats like
a parrot what is in the documentation; please before you say "seach in
google" say nothing is better.

2011/3/16 Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk>

> (last email, as i dont want to drag this out any more)
>
> I don't mean it in a nasty way, but I'm so sick and tired of lazy
> developers. Solving problems should be one of the best percs of the job for
> a coder.
>
> If this was something really complex, then I'd understand, but it's not.
> This is a *very* simple piece of functionality, which has plenty of public
> documentation.
>
> On Wed, Mar 16, 2011 at 6:50 PM, emonk  wrote:
>
>> aamh ok
>>
>>
>> 2011/3/16 Cal Leeming [Simplicity Media Ltd] <
>> cal.leem...@simplicitymedialtd.co.uk>
>>
>>> Then this isn't the job for you. Simple.
>>>
>>> On Wed, Mar 16, 2011 at 6:47 PM, emonk  wrote:
>>>
 I'm tired of searching and found many examples of middleware but not the
 one I seek

 2011/3/16 Cal Leeming [Simplicity Media Ltd] <
 cal.leem...@simplicitymedialtd.co.uk>

 Actually, I've gotta side with Shawn on this one.
>
> There are *TONS* of examples of how to do this, I know this because I
> created one and put it on djangosnippets. :S
>
> If two people are telling you there are answers on Google, then trust
> me, there are.
>
> If you can't find them, then perhaps this isn't the job for you?
>
> On Wed, Mar 16, 2011 at 6:42 PM, emonk  wrote:
>
>> I repeat, i dont have found (in all entire internet) midlleware
>> classes about email error.
>> Thanks, dont need to be a troll :)
>>
>>
>> 2011/3/16 Shawn Milochik 
>>
>>> On Wed, Mar 16, 2011 at 1:16 PM, emonk  wrote:
>>> > Yep, but i need an example and I have not found any.
>>> >
>>>
>>> If you haven't found any then you haven't looked. Have you heard of
>>> Google?
>>>
>>> Here are the docs:
>>>
>>> http://docs.djangoproject.com/en/1.2/topics/http/middleware/#writing-your-own-middleware
>>>
>>> For a full working example of middleware that modifies the request,
>>> do
>>> a Google search for "django middleware" and click the link for
>>> "Chapter 16: Middleware" of "The Django Book."
>>>
>>> Shawn
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>

>>>
>>
>

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



Re: How i can get username into the error mail?

2011-03-16 Thread Margie Roginski
I found the basics for this by googling around, and I can't remember
where I got it, but thanks to whomever gave me the basics because it
is very useful.  Put this in your middleware and it will make the mail
that you receive have the name of the user and their email:

class ExceptionUserInfoMiddleware(object):
"""
Adds user details to request context on receiving an exception, so
that they show up in the error emails.
Add to settings.MIDDLEWARE_CLASSES and keep it outermost(i.e. on
top if possible). This allows
it to catch exceptions in other middlewares as well.

"""

def process_exception(self, request, exception):
"""
Process the exception.

:Parameters:
- `request`: request that caused the exception
- `exception`: actual exception being raised
"""

try:
if request.user.is_authenticated():
request.META['USERNAME'] = str(request.user.username)
request.META['USER_EMAIL'] = str(request.user.email)
else:
request.META['USERNAME'] = "UNKNOWN"
request.META['USER_EMAIL'] = "UNKNOWN"
except:
request.META['USERNAME'] = "UNKNOWN"
request.META['USER_EMAIL'] = "UNKNOWN"
pass

And for the record, I of course agree that being able to google and
then adapt things is very important.  But this is a common need so it
seems worthwhile to post it explicitly to help the django community.

Margie


On Mar 16, 11:49 am, Shawn Milochik  wrote:
> On Wed, Mar 16, 2011 at 2:47 PM, emonk  wrote:
> > I'm tired of searching and found many examples of middleware but not the one
> > I seek
>
> You almost certainly will not find the exact code you need to cut &
> paste. You need to read the examples you did find and learn something.
> Use that knowledge to write what you need. That's what the rest of us
> do.
>
> Shawn

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



Re: Help with Apache/Nginx combo

2011-03-16 Thread Nate Aune
You might want to try Nginx proxying to Gunicorn. This is what we use for 
DjangoZoom and it works really well. Pretty easy to set up as well. Here are 
a few resources that provide instructions for how to set it up:
http://www.rkblog.rk.edu.pl/w/p/deploying-django-project-gunicorn-and-nginx/
http://ericholscher.com/blog/2010/aug/16/lessons-learned-dash-easy-django-deployment/
http://davidpoblador.com/run-django-apps-using-gunicorn-and-nginx/

Or if you don't want to mess around with Nginx/Apache/Gunicorn 
configuration, our DjangoZoom service takes care of all of this stuff for 
you. We check out your code and in less than a minute, return a public URL 
of your live running app. You never even have to touch the server! 

We're focused on providing the best deployment and hosting experience for 
Django developers. 

If you want to try it out, sign up for the beta and we'll try to get you an 
invite soon! http://bit.ly/ezSkKA

thanks,
Nate

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



Re: How i can get username into the error mail?

2011-03-16 Thread Cal Leeming [Simplicity Media Ltd]
(last email, as i dont want to drag this out any more)

I don't mean it in a nasty way, but I'm so sick and tired of lazy
developers. Solving problems should be one of the best percs of the job for
a coder.

If this was something really complex, then I'd understand, but it's not.
This is a *very* simple piece of functionality, which has plenty of public
documentation.

On Wed, Mar 16, 2011 at 6:50 PM, emonk  wrote:

> aamh ok
>
>
> 2011/3/16 Cal Leeming [Simplicity Media Ltd] <
> cal.leem...@simplicitymedialtd.co.uk>
>
>> Then this isn't the job for you. Simple.
>>
>> On Wed, Mar 16, 2011 at 6:47 PM, emonk  wrote:
>>
>>> I'm tired of searching and found many examples of middleware but not the
>>> one I seek
>>>
>>> 2011/3/16 Cal Leeming [Simplicity Media Ltd] <
>>> cal.leem...@simplicitymedialtd.co.uk>
>>>
>>> Actually, I've gotta side with Shawn on this one.

 There are *TONS* of examples of how to do this, I know this because I
 created one and put it on djangosnippets. :S

 If two people are telling you there are answers on Google, then trust
 me, there are.

 If you can't find them, then perhaps this isn't the job for you?

 On Wed, Mar 16, 2011 at 6:42 PM, emonk  wrote:

> I repeat, i dont have found (in all entire internet) midlleware classes
> about email error.
> Thanks, dont need to be a troll :)
>
>
> 2011/3/16 Shawn Milochik 
>
>> On Wed, Mar 16, 2011 at 1:16 PM, emonk  wrote:
>> > Yep, but i need an example and I have not found any.
>> >
>>
>> If you haven't found any then you haven't looked. Have you heard of
>> Google?
>>
>> Here are the docs:
>>
>> http://docs.djangoproject.com/en/1.2/topics/http/middleware/#writing-your-own-middleware
>>
>> For a full working example of middleware that modifies the request, do
>> a Google search for "django middleware" and click the link for
>> "Chapter 16: Middleware" of "The Django Book."
>>
>> Shawn
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>


>>>
>>
>

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



automatically create user profile on user creation

2011-03-16 Thread Ori Livneh
Hi guys,

The Django docs explain that "the method get_profile() does not create the
profile, if it does not exist. You need to register a handler for the signal
django.db.models.signals.post_save on the User model, and, in the handler,
if created=True, create the associated user profile." (http://goo.gl/jNo91)

But there's no code sample. A few weeks ago (with some help from friendly
people on #django) I came up with this snippet:

# ~ snippet start ~

@receiver(post_save, sender=User)
def create_profile(sender, instance, created, **kwargs):
"""Create a matching profile whenever a User is created."""
if created:
profile, new = UserProfile.objects.get_or_create(user=instance)

# ~ snippet end ~

(I use get_or_create as extra insurance against cases wherein a User is
created, deleted, and then created anew.)

Is there anything in this snippet that should be fixed or improved?

If it's OK, do you think it makes sense to include it in the docs? I ask
because getting user profiles to work is liable to be something new Django
developers want to do, but signals are something of an intermediate/advanced
topic.

Thanks,
Ori

PS I wrote this up on my blog with a slightly lengthier explanation, in case
anyone finds it useful:
http://floru.it/2011/using-signals-to-create-user-profiles-in-django-1-3/

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



Re: How i can get username into the error mail?

2011-03-16 Thread Shawn Milochik
On Wed, Mar 16, 2011 at 2:47 PM, emonk  wrote:
> I'm tired of searching and found many examples of middleware but not the one
> I seek
>

You almost certainly will not find the exact code you need to cut &
paste. You need to read the examples you did find and learn something.
Use that knowledge to write what you need. That's what the rest of us
do.

Shawn

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



Re: Django app and Amazon AWS (beginner)

2011-03-16 Thread Nate Aune
Hi Nai,

It takes some tinkering to get a production deployment of a Django app 
working well. One of the founders of Django, Jacob Kaplan Moss, presented a 
Django deployment workshop at last year's PyCon.  Video: 
http://pycon.blip.tv/file/3632436/  
Code: https://github.com/jacobian/django-deployment-workshop  

If you want to get your Django app deployed up on Amazon's infrastructure 
and don't want to mess around with config files and servers, I invite you to 
try out our DjangoZoom service which is built on top of Amazon's AWS 
infrastructure. http://djangozoom.com  We take care of all the server-side 
stuff, so you don't have to. 

You just point us at your code repo and in less than a minute, we return a 
public URL of your live running app. The service is in a private beta right 
now, but if you sign up for the beta, we'll try to get an invite to you 
soon.  We welcome any feedback on how to make it the best hosting service 
for Django developers!

thanks,
Nate

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



Re: How i can get username into the error mail?

2011-03-16 Thread emonk
aamh ok

2011/3/16 Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk>

> Then this isn't the job for you. Simple.
>
> On Wed, Mar 16, 2011 at 6:47 PM, emonk  wrote:
>
>> I'm tired of searching and found many examples of middleware but not the
>> one I seek
>>
>> 2011/3/16 Cal Leeming [Simplicity Media Ltd] <
>> cal.leem...@simplicitymedialtd.co.uk>
>>
>> Actually, I've gotta side with Shawn on this one.
>>>
>>> There are *TONS* of examples of how to do this, I know this because I
>>> created one and put it on djangosnippets. :S
>>>
>>> If two people are telling you there are answers on Google, then trust me,
>>> there are.
>>>
>>> If you can't find them, then perhaps this isn't the job for you?
>>>
>>> On Wed, Mar 16, 2011 at 6:42 PM, emonk  wrote:
>>>
 I repeat, i dont have found (in all entire internet) midlleware classes
 about email error.
 Thanks, dont need to be a troll :)


 2011/3/16 Shawn Milochik 

> On Wed, Mar 16, 2011 at 1:16 PM, emonk  wrote:
> > Yep, but i need an example and I have not found any.
> >
>
> If you haven't found any then you haven't looked. Have you heard of
> Google?
>
> Here are the docs:
>
> http://docs.djangoproject.com/en/1.2/topics/http/middleware/#writing-your-own-middleware
>
> For a full working example of middleware that modifies the request, do
> a Google search for "django middleware" and click the link for
> "Chapter 16: Middleware" of "The Django Book."
>
> Shawn
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
  --
 You received this message because you are subscribed to the Google
 Groups "Django users" group.
 To post to this group, send email to django-users@googlegroups.com.
 To unsubscribe from this group, send email to
 django-users+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/django-users?hl=en.

>>>
>>>
>>
>

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



Re: How i can get username into the error mail?

2011-03-16 Thread Cal Leeming [Simplicity Media Ltd]
Then this isn't the job for you. Simple.

On Wed, Mar 16, 2011 at 6:47 PM, emonk  wrote:

> I'm tired of searching and found many examples of middleware but not the
> one I seek
>
> 2011/3/16 Cal Leeming [Simplicity Media Ltd] <
> cal.leem...@simplicitymedialtd.co.uk>
>
> Actually, I've gotta side with Shawn on this one.
>>
>> There are *TONS* of examples of how to do this, I know this because I
>> created one and put it on djangosnippets. :S
>>
>> If two people are telling you there are answers on Google, then trust me,
>> there are.
>>
>> If you can't find them, then perhaps this isn't the job for you?
>>
>> On Wed, Mar 16, 2011 at 6:42 PM, emonk  wrote:
>>
>>> I repeat, i dont have found (in all entire internet) midlleware classes
>>> about email error.
>>> Thanks, dont need to be a troll :)
>>>
>>>
>>> 2011/3/16 Shawn Milochik 
>>>
 On Wed, Mar 16, 2011 at 1:16 PM, emonk  wrote:
 > Yep, but i need an example and I have not found any.
 >

 If you haven't found any then you haven't looked. Have you heard of
 Google?

 Here are the docs:

 http://docs.djangoproject.com/en/1.2/topics/http/middleware/#writing-your-own-middleware

 For a full working example of middleware that modifies the request, do
 a Google search for "django middleware" and click the link for
 "Chapter 16: Middleware" of "The Django Book."

 Shawn

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


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

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



Re: How i can get username into the error mail?

2011-03-16 Thread emonk
Thanks for the answers.
topic closed to me

2011/3/16 emonk 

> I'm tired of searching and found many examples of middleware but not the
> one I seek
>
> 2011/3/16 Cal Leeming [Simplicity Media Ltd] <
> cal.leem...@simplicitymedialtd.co.uk>
>
> Actually, I've gotta side with Shawn on this one.
>>
>> There are *TONS* of examples of how to do this, I know this because I
>> created one and put it on djangosnippets. :S
>>
>> If two people are telling you there are answers on Google, then trust me,
>> there are.
>>
>> If you can't find them, then perhaps this isn't the job for you?
>>
>> On Wed, Mar 16, 2011 at 6:42 PM, emonk  wrote:
>>
>>> I repeat, i dont have found (in all entire internet) midlleware classes
>>> about email error.
>>> Thanks, dont need to be a troll :)
>>>
>>>
>>> 2011/3/16 Shawn Milochik 
>>>
 On Wed, Mar 16, 2011 at 1:16 PM, emonk  wrote:
 > Yep, but i need an example and I have not found any.
 >

 If you haven't found any then you haven't looked. Have you heard of
 Google?

 Here are the docs:

 http://docs.djangoproject.com/en/1.2/topics/http/middleware/#writing-your-own-middleware

 For a full working example of middleware that modifies the request, do
 a Google search for "django middleware" and click the link for
 "Chapter 16: Middleware" of "The Django Book."

 Shawn

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


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

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



Re: How i can get username into the error mail?

2011-03-16 Thread emonk
I'm tired of searching and found many examples of middleware but not the one
I seek

2011/3/16 Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk>

> Actually, I've gotta side with Shawn on this one.
>
> There are *TONS* of examples of how to do this, I know this because I
> created one and put it on djangosnippets. :S
>
> If two people are telling you there are answers on Google, then trust me,
> there are.
>
> If you can't find them, then perhaps this isn't the job for you?
>
> On Wed, Mar 16, 2011 at 6:42 PM, emonk  wrote:
>
>> I repeat, i dont have found (in all entire internet) midlleware classes
>> about email error.
>> Thanks, dont need to be a troll :)
>>
>>
>> 2011/3/16 Shawn Milochik 
>>
>>> On Wed, Mar 16, 2011 at 1:16 PM, emonk  wrote:
>>> > Yep, but i need an example and I have not found any.
>>> >
>>>
>>> If you haven't found any then you haven't looked. Have you heard of
>>> Google?
>>>
>>> Here are the docs:
>>>
>>> http://docs.djangoproject.com/en/1.2/topics/http/middleware/#writing-your-own-middleware
>>>
>>> For a full working example of middleware that modifies the request, do
>>> a Google search for "django middleware" and click the link for
>>> "Chapter 16: Middleware" of "The Django Book."
>>>
>>> Shawn
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>

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



Re: How i can get username into the error mail?

2011-03-16 Thread Cal Leeming [Simplicity Media Ltd]
Actually, I've gotta side with Shawn on this one.

There are *TONS* of examples of how to do this, I know this because I
created one and put it on djangosnippets. :S

If two people are telling you there are answers on Google, then trust me,
there are.

If you can't find them, then perhaps this isn't the job for you?

On Wed, Mar 16, 2011 at 6:42 PM, emonk  wrote:

> I repeat, i dont have found (in all entire internet) midlleware classes
> about email error.
> Thanks, dont need to be a troll :)
>
>
> 2011/3/16 Shawn Milochik 
>
>> On Wed, Mar 16, 2011 at 1:16 PM, emonk  wrote:
>> > Yep, but i need an example and I have not found any.
>> >
>>
>> If you haven't found any then you haven't looked. Have you heard of
>> Google?
>>
>> Here are the docs:
>>
>> http://docs.djangoproject.com/en/1.2/topics/http/middleware/#writing-your-own-middleware
>>
>> For a full working example of middleware that modifies the request, do
>> a Google search for "django middleware" and click the link for
>> "Chapter 16: Middleware" of "The Django Book."
>>
>> Shawn
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Problem with DECIMAL_SEPARATOR

2011-03-16 Thread emonk
I think DECIMAL_SEPARATOR = ','  wasnt neccesary when USE_L10N=True

2011/3/16 Siara 

> Thx for help,
> DECIMAL_SEPARATOR = ','  wasnt neccesary when USE_L10N=False cause its
> default delimeter
> On 15 Mar, 20:07, emonk  wrote:
> > try this in settings.py
> >
> > USE_L10N = False
> > DECIMAL_SEPARATOR = ','
> >
> > 2011/3/15 Siara 
> >
> >
> >
> > > Hi
> > > I tried to find solution to my problem on django-developers group and
> > > they send me here ;)
> > > Ant there is my problem:
> > > I'm writing application which return json with data for another app.
> > > I'm from Poland so I set LANGUAGE_CODE = 'pl', the problem is that we
> > > are using coma instead of dot in float numbers, and setting language
> > > to polish changing dot for coma in jsons, but i need dot.
> > > I tried DECIMAL_SEPARATOR = '.'  but its doesnt work, it looks like
> > > LANGUAGE_CODE is overwriting DECIMAL_SEPARATOR settings.
> > > So any ideas how to keep polish internatiolization with
> > > DECIMAL_SEPARATOR as dot intead coma ?
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Django users" group.
> > > To post to this group, send email to django-users@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: How i can get username into the error mail?

2011-03-16 Thread emonk
I repeat, i dont have found (in all entire internet) midlleware classes
about email error.
Thanks, dont need to be a troll :)

2011/3/16 Shawn Milochik 

> On Wed, Mar 16, 2011 at 1:16 PM, emonk  wrote:
> > Yep, but i need an example and I have not found any.
> >
>
> If you haven't found any then you haven't looked. Have you heard of Google?
>
> Here are the docs:
>
> http://docs.djangoproject.com/en/1.2/topics/http/middleware/#writing-your-own-middleware
>
> For a full working example of middleware that modifies the request, do
> a Google search for "django middleware" and click the link for
> "Chapter 16: Middleware" of "The Django Book."
>
> Shawn
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: How i can get username into the error mail?

2011-03-16 Thread Shawn Milochik
On Wed, Mar 16, 2011 at 1:16 PM, emonk  wrote:
> Yep, but i need an example and I have not found any.
>

If you haven't found any then you haven't looked. Have you heard of Google?

Here are the docs:
http://docs.djangoproject.com/en/1.2/topics/http/middleware/#writing-your-own-middleware

For a full working example of middleware that modifies the request, do
a Google search for "django middleware" and click the link for
"Chapter 16: Middleware" of "The Django Book."

Shawn

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



Re: Problem with DECIMAL_SEPARATOR

2011-03-16 Thread Siara
Thx for help,
DECIMAL_SEPARATOR = ','  wasnt neccesary when USE_L10N=False cause its
default delimeter
On 15 Mar, 20:07, emonk  wrote:
> try this in settings.py
>
> USE_L10N = False
> DECIMAL_SEPARATOR = ','
>
> 2011/3/15 Siara 
>
>
>
> > Hi
> > I tried to find solution to my problem on django-developers group and
> > they send me here ;)
> > Ant there is my problem:
> > I'm writing application which return json with data for another app.
> > I'm from Poland so I set LANGUAGE_CODE = 'pl', the problem is that we
> > are using coma instead of dot in float numbers, and setting language
> > to polish changing dot for coma in jsons, but i need dot.
> > I tried DECIMAL_SEPARATOR = '.'  but its doesnt work, it looks like
> > LANGUAGE_CODE is overwriting DECIMAL_SEPARATOR settings.
> > So any ideas how to keep polish internatiolization with
> > DECIMAL_SEPARATOR as dot intead coma ?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Re: Django projects, apps, and git repos

2011-03-16 Thread br
Thanks for the feedback.  I've looked at git submodules and think that
will be a useful tool in django projects that share apps, once I'm
comfortable with the submodule functionality & understand how it fits
in with my prjoects.  And once I get my apps so they actually are in
fact "pluggable" (not there yet) I'll be looking at making them
installable with pip via pypi.

In the mean time, I've thought through our site and how i want to
structure the projects & repos and thought I would share what I've
come up with.

Basically what I've come up with for our specific scenario, is a
realization that our site consists of three or four distinct
"projects" or Applications (not talking about django apps) with fairly
distinct and modular sets of functionalities. Within each of these
projects will be various django apps, which i would like to make as
pluggable as possible. Our client users will need to have access to
each of the Applications (corresponding to the projects) from a
central dashboard, with a corresponding wrapper templates.  So in
addition to each separate Application project, I a have a "glue"
project that includes the general site functionality (e.g., user
accounts & permissions, wrapper templates, etc.) For now, I'm setting
up each project as its own repository, since releases might be
different for each one, and I want the projects themselves, in
addition to their apps, to be fairly pluggable, and even stand on
their own as deployable sites. The "glue" project for the dashboard &
common functionality will have a settings.py for the whole site, which
is cognizant of all the included projects, although individual
projects will have their own settings.py that can be used to deploy
them individually.  We'll see how this set up goes.

btw, I'm using virtualenv & pip for managing site-packages & external
packages, and using Fabric for deploying to development, staging,
production virtual hosts. I've currently set it up so each project has
its own corresponding virtualenv environment and fabric script but
haven't quite figured the long term vision for all of this out yet
since i'm still familiarizing myself with the different tools.  If
someone sees any pitfalls to be aware of, let me know.

Any feedback is, of course, welcomed.

Thanks,

Ben

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



Re: Format DateTimeField of a model

2011-03-16 Thread Daniel Roseman
On Wednesday, March 16, 2011 5:37:23 PM UTC, Vinicius Massuchetto wrote:
>
> I want to customize the DateTimeField returned in an admin list
> column. I know there's the DATETIME_FORMAT setting, but I only want to
> change in one model. I'lm also using L10N, and couldn't figure out if
> there's a way to override what's in the default po file for my
> language.
>
> What's the right way of doing that? Please note that I want to
> preserve the sorting feature of this column.
>
> Many thanks.
> -- 
> Vinicius Massuchetto
>

Create a custom admin method that returns the formatted value, and specify 
that in the `list_display` method. Make sure you set the `admin_order_field` 
property on the method to preserve the ordering functionality.

class MyAdmin(admin.ModelAdmin):
list_display = ('name', 'my_date_display')

def my_date_display(self, obj):
return obj.my_date_field.strftime('your-display-format')
my_date_display.admin_order_field = 'my_date_field' 

--
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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Format DateTimeField of a model

2011-03-16 Thread Vinicius Massuchetto
I want to customize the DateTimeField returned in an admin list
column. I know there's the DATETIME_FORMAT setting, but I only want to
change in one model. I'lm also using L10N, and couldn't figure out if
there's a way to override what's in the default po file for my
language.

What's the right way of doing that? Please note that I want to
preserve the sorting feature of this column.

Many thanks.
-- 
Vinicius Massuchetto

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



Re: How to use extra to count based on the value of a field?

2011-03-16 Thread Jason Culverhouse

On Mar 16, 2011, at 8:49 AM, Margie Roginski wrote:

> Hmmm ... so I just got back to trying this and I actually don't think
> the annotate call as suggested does what I am looking for.  Say I want
> to annotate queues with the number of closed tasks. This call:
> 
> Queue.objects.filter(task__status=Task.STATUS_CLOSED).annotate(num_tasks=Count('task'))
> 
> finds all queues that have tasks that are closed, but then it
> annotates the queue with the total number of tasks that point to the
> queue, not just the number of closed tasks that point to the queue.
> It seems like I really need something like this (which doesn't exist):
> 
> Queue.objects.annotate(num_tasks=Count('task__status=Task.CLOSED_STATUS'))
> 
Would something like this work?

Queue.objects.extra(
select = 
{ 'num_tasks' = 'SELECT COUNT(*) FROM app_task WHERE 
app_task.queue_id = app_queue.id' and app_task.status=%s'),
select_params=(Task.CLOSED_STATUS,)

> 
> At a higher level, I am trying to find a way to sort my queues based
> on the number of tasks that point to the queue of a particular status.
> IE, the user would be able to sort their queues based on number of
> open tasks or number of closed tasks. Perhaps there is some other
> approach that I am missing ...
> 
> Margie
> 
> 
> 
> 
> On Mar 15, 2:43 am, Tom Evans  wrote:
>> On Mon, Mar 14, 2011 at 8:57 PM,MargieRoginski
>> 
>>  wrote:
>>> class Queue(models.Model):
>>>  # fields here, not relevant for this discussion
>> 
>>> class Task(models.Mode):
>>>  queue = models.ForeignKey("Queue")
>>>  status = models.IntegerField(choices=STATUS_CHOICES)
>> 
>>> I am trying to create a Queue queryset that willannotateeach Queue
>>> with the number of tasks whose queue field is pointing to that Queue
>>> and status field has a certain value.
>> 
>>> I don't thinkannotatewill work for me due to me needing to count up
>>> only tasks whose status field has a certain value.  I think I might
>>> need extra?  But I'm having touble making that work.
>> 
>> No, this is precisely whatannotateis for.
>> 
>> Queue.objects.filter(task__status=Task.SOME_CHOICE).annotate(num_tasks=Count('task'))
>> 
>> Cheers
>> 
>> Tom
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



Re: How i can get username into the error mail?

2011-03-16 Thread emonk
Yep, but i need an example and I have not found any.

2011/3/16 Tom Evans 

> On Tue, Mar 15, 2011 at 6:32 PM, emonk  wrote:
> > Hi django-users.
> >
> > I have a django project running in apache2 with  mod_wsgi and I need get
> the
> > username logged into the mail error; the user is registered in the same
> data
> > base of the project, i mean in the auth_user table (request.user.username
> > called in the views).
> >
> > This is an example of the error mail generated by a some user request
> with
> > an error and received by me (the admin) using DEBUG = False in
> settings.py:
> >
>
> Write some middleware which runs after AuthenticationMiddleware and
> inserts the user's name into request.META.
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: How to use extra to count based on the value of a field?

2011-03-16 Thread Margie Roginski
Right again!  I agree what you are saying works.  I tried to take it a
step further and OR together two querysets.  I was then looking at the
results of that OR, and it was not what I expected.  One qs had been
annotated with num_tasks_open, the other had been annotated with
num_tasks_closed.  I was thinking I could just OR them together and
get a single queryset where each queue would would be annotated with
num_tasks_open and num_tasks_closed.  But that does not seem to work.

> qsOpen = Queue.objects.filter(name="foo", 
> task__status=Task.OPEN_STATUS).annotate(num_tasks_open=Count('task'))
> qsClosed = Queue.objects.filter(name="foo", 
> task__status=Task.CLOSED_STATUS).annotate(num_tasks_closed=Count('task'))
> qsOpen[0].num_tasks_open
Out[37]: 1

> qsClosed[0].num_tasks_closed
Out[38]: 4

> newQs = qsOpen | qsClosed

> newQs[0].num_tasks_open <<== Was expecting this to still show 1 task open
Out[41]: 5

> newQs[0].num_tasks_closed  <<== Was expecting this to show 4 tasks open
---
AttributeErrorTraceback (most recent call
last)
/home/mlevine/django/chipvision74/chip_vision_2/ in
()
AttributeError: 'Queue' object has no attribute 'num_tasks_closed'


Margie


On Mar 16, 9:13 am, Tom Evans  wrote:
> On Wed, Mar 16, 2011 at 3:49 PM, Margie Roginski
>
>  wrote:
> > Hmmm ... so I just got back to trying this and I actually don't think
> > the annotate call as suggested does what I am looking for.  Say I want
> > to annotate queues with the number of closed tasks. This call:
>
> > Queue.objects.filter(task__status=Task.STATUS_CLOSED).annotate(num_tasks=Count('task'))
>
> > finds all queues that have tasks that are closed, but then it
> > annotates the queue with the total number of tasks that point to the
> > queue, not just the number of closed tasks that point to the queue.
>
> No, you are incorrect. An example with similar models:
>
> >>> qs = TVSeries.objects.filter(name='South 
> >>> Park').filter(tvepisode__title__contains='hero').annotate(num_episodes_with_hero_in_title=Count('tvepisode'))
> >>> qs[0].num_episodes_with_hero_in_title
> 1
> >>> qs2 = TVSeries.objects.filter(name='South 
> >>> Park').annotate(num_episodes=Count('tvepisode'))
> >>> qs2[0].num_episodes
>
> 202
>
> As you can see, the annotate is clearly correctly affected by the
> earlier filter.
>
> Cheers
>
> Tom

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



Re: file upload size problem

2011-03-16 Thread Michal Petrucha
> > I've set a custom error page for the 413 error when the upload file
> > size exceeds the maximum set in apache LimitRequestBody directive (500
> > KB).
> > This is working fine for all files upto 3 MB. However when the size
> > exceeds this limit, the browser is showing the below message instead
> > of my custom error page. Can someone point me in the right direction?
> >
> > Connection Interrupted
> >
> > The connection to the server was reset while the page was
> > loading.
> >
> > The network link was interrupted while negotiating a connection.
> > Please try again.
My guess is that the webserver hangs up as soon as it sees the
request size exceeds some multiple of the limit.

I think this is reasonable, just imagine that somebody would try to
upload for example /dev/urandom or /dev/zero (i. e. an infinite amount
of data). Would you want the server to suck it all in and then give an
error message saying that the limit has been exceeded?

Michal Petrucha


signature.asc
Description: Digital signature


Screen Fields Rendered Incorrectly

2011-03-16 Thread hank23
I have a new html screen which has fields on it which are not
rendering properly as month, day and year fields like this:

Month Day
   Year


I have copied much of this code from anothe html screen on which these
same fields do render properly. So what might cause them and all of
the other fields of the form from which they're supposed to be
rendered to display like this?  Thanks for the help.

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



Re: How to use extra to count based on the value of a field?

2011-03-16 Thread Tom Evans
On Wed, Mar 16, 2011 at 3:49 PM, Margie Roginski
 wrote:
> Hmmm ... so I just got back to trying this and I actually don't think
> the annotate call as suggested does what I am looking for.  Say I want
> to annotate queues with the number of closed tasks. This call:
>
> Queue.objects.filter(task__status=Task.STATUS_CLOSED).annotate(num_tasks=Count('task'))
>
> finds all queues that have tasks that are closed, but then it
> annotates the queue with the total number of tasks that point to the
> queue, not just the number of closed tasks that point to the queue.

No, you are incorrect. An example with similar models:

>>> qs = TVSeries.objects.filter(name='South 
>>> Park').filter(tvepisode__title__contains='hero').annotate(num_episodes_with_hero_in_title=Count('tvepisode'))
>>> qs[0].num_episodes_with_hero_in_title
1
>>> qs2 = TVSeries.objects.filter(name='South 
>>> Park').annotate(num_episodes=Count('tvepisode'))
>>> qs2[0].num_episodes
202

As you can see, the annotate is clearly correctly affected by the
earlier filter.

Cheers

Tom

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



Re: Best Way To Update Multiple Fields In Model

2011-03-16 Thread octopusgrabbus
This seems to fit the bill just fine.
 DrReadRange.objects.update(reading_width_days=read_range_in)

On Mar 16, 9:28 am, octopusgrabbus  wrote:
> Django 1.2
> mod_wsgi
> Python 2.6.6
>
> When I create an object of a model of a table, what is the best way to
> update two columns? I can update one easily, but not two of them. I
> also noted the model, does not list the third key, at least that I can
> recognize.
>
> What am I asking is what constructs should be use -- pointer to code
> sample(s) to update two columns in one row or all rows?
>
> This code does not work the way I want it to:
>
> def save_dr_read_range(cycle_num, read_range_in, load_date,
> updating_user, max_read_range_in, errors, update_ok):
>     try:
>         read_range_obj = DrReadRange(cycle=cycle_num, \
>             reading_width_days=read_range_in, \
>             creation_date=load_date, \
>             created_by=str(updating_user), \
>             max_read_width=max_read_range_in)
>
>         read_range_obj.save()
>         del read_range_obj
>
>     except IntegrityError as e:
>         errors.append('Error: modifying read range table ' + e)
>         update_ok  = False
>
>     except:
>         e = sys.exc_info()[1]
>         errors.append('Error: ' + str(e) + ' occurred')
>         update_ok = False
>
>     return errors, update_ok
>
> tnx
> cmn
>
> Model:
>
> from django.db import models
>
> class DrReadRange(models.Model):
>     cycle = models.IntegerField(primary_key=True)
>     reading_width_days = models.IntegerField(primary_key=True)
>     creation_date = models.DateField(primary_key=False)
>     created_by = models.CharField(max_length=30)
>     max_read_width = models.IntegerField(null=True, blank=True)
>     class Meta:
>         db_table = u'dr_read_range'
>
> SQL that created the table:
> CREATE TABLE `dr_read_range` (
>   `cycle` smallint(6) NOT NULL default '0',
>   `reading_width_days` int(11) NOT NULL default '0',
>   `creation_date` date NOT NULL,
>   `created_by` char(10) NOT NULL default 'amr',
>   `max_read_width` smallint(6) default '3',
>   PRIMARY KEY  (`cycle`,`reading_width_days`,`creation_date`),
>   KEY `creation_date_ix1` (`creation_date`)
> ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='holds daily reads
> range';
> SE

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



Re: How to use extra to count based on the value of a field?

2011-03-16 Thread Margie Roginski
Hmmm ... so I just got back to trying this and I actually don't think
the annotate call as suggested does what I am looking for.  Say I want
to annotate queues with the number of closed tasks. This call:

Queue.objects.filter(task__status=Task.STATUS_CLOSED).annotate(num_tasks=Count('task'))

finds all queues that have tasks that are closed, but then it
annotates the queue with the total number of tasks that point to the
queue, not just the number of closed tasks that point to the queue.
It seems like I really need something like this (which doesn't exist):

Queue.objects.annotate(num_tasks=Count('task__status=Task.CLOSED_STATUS'))


At a higher level, I am trying to find a way to sort my queues based
on the number of tasks that point to the queue of a particular status.
IE, the user would be able to sort their queues based on number of
open tasks or number of closed tasks. Perhaps there is some other
approach that I am missing ...

Margie




On Mar 15, 2:43 am, Tom Evans  wrote:
> On Mon, Mar 14, 2011 at 8:57 PM,MargieRoginski
>
>  wrote:
> > class Queue(models.Model):
> >  # fields here, not relevant for this discussion
>
> > class Task(models.Mode):
> >  queue = models.ForeignKey("Queue")
> >  status = models.IntegerField(choices=STATUS_CHOICES)
>
> > I am trying to create a Queue queryset that willannotateeach Queue
> > with the number of tasks whose queue field is pointing to that Queue
> > and status field has a certain value.
>
> > I don't thinkannotatewill work for me due to me needing to count up
> > only tasks whose status field has a certain value.  I think I might
> > need extra?  But I'm having touble making that work.
>
> No, this is precisely whatannotateis for.
>
> Queue.objects.filter(task__status=Task.SOME_CHOICE).annotate(num_tasks=Count('task'))
>
> Cheers
>
> Tom

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



How to work with views like classes

2011-03-16 Thread Isaac XxX
Hi folks,

Currently i'm getting trouble with a single feature in django. When i've
some inheritance in templates, like the following

TemplateA

TemplateB inherits A

TemplateC inherits B
TemplateD inherits B

If I need to define something depending on provided data in TemplateA or
TemplateB, then all views that render TemplateC and TemplateD should provide
the needed data. For example

Template A
...
{% my_var %}
...

How can define "my_var" as global variable for all views that would render
an inherited template of A (or B, or whatelse needed) without recurring to
middlewares?

I've have programmed many time in RoR, and is really simple to define global
vars, or complex inheritance patterns to share common data.

BTW, I though about decorators, implement some "pre-post" processment, but
it's not as clean as i want, because I should get the specific context
(normally RequestContext, but it can be another one in other projects)
rendered by view.

Thanks in advance

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



Re: permissions don't get added

2011-03-16 Thread Daniel Roseman
On Wednesday, March 16, 2011 2:50:05 PM UTC, Tom Evans wrote:
>
> On Wed, Mar 16, 2011 at 1:28 PM, tom  wrote:
> > Hello,
> >
> > I have a model, which was already created within the DB, and I added
> > following permissions:
> >class META:
>
> ^^ Django looks for an inner class named 'Meta', not 'META'.
>
> Cheers
>
> Tom
>

Since version 0.91, over five years ago, anyway...
--
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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: What do you use to build facebook applications with django?

2011-03-16 Thread OrazioPirataDelloSpazio (Lorenzo)
Hello,
I was in your same situation some weeks ago.
I checked almost all the django-facebook integration projects and each
one of the uses old and not-documented api (facebook recently changed
apis, and deprecated other stuff such as fbml in favor of the modern
graph api).

At the end I gave up.
Now I am using only javascript with fb official graph api the works well.


Lorenzo


Il 16/03/11 15:46, mongoose ha scritto:
> Hi,
> 
> I've been struggling so much trying to get a Facebook app to work on
> the Django framework. Mostly battling with pyFacebook. For some
> particular reason the login just doesn't work for me. I've posted some
> help questions and still come up with nothing. Perhaps the pyFacebook
> is outdated?
> 
> But my question is What do you use to build facebook applications with
> django? Why am I having such a hard time when I believe this is
> supposed to be reasonably easy to accomplish.
> 




signature.asc
Description: OpenPGP digital signature


Re: permissions don't get added

2011-03-16 Thread Tom Evans
On Wed, Mar 16, 2011 at 1:28 PM, tom  wrote:
> Hello,
>
> I have a model, which was already created within the DB, and I added
> following permissions:
>    class META:

^^ Django looks for an inner class named 'Meta', not 'META'.

Cheers

Tom

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



What do you use to build facebook applications with django?

2011-03-16 Thread mongoose
Hi,

I've been struggling so much trying to get a Facebook app to work on
the Django framework. Mostly battling with pyFacebook. For some
particular reason the login just doesn't work for me. I've posted some
help questions and still come up with nothing. Perhaps the pyFacebook
is outdated?

But my question is What do you use to build facebook applications with
django? Why am I having such a hard time when I believe this is
supposed to be reasonably easy to accomplish.

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



permissions don't get added

2011-03-16 Thread tom
Hello,

I have a model, where I need to add some permissions to the Meta
class. I've added the permissions, synched the database, but the
permissions do not show up in the database. Therefore I wiped the DB
and re-synced it. Still no custom permissions in the DB. This is the
code I use:

class META:
permissions = (
('view_all_projects', 'Can view all projects'),
)
verbose_name = _("project")
verbose_name_plural = _("projects")

Does someone have any ideas?

regards, Tom

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



Re: Help with Apache/Nginx combo

2011-03-16 Thread maciekjbl
I'm still fighting with this configutarion.

What I manage is that I don't have any error's in apache, but media
still don't work.

I try to use example from lincolnloop and it's fail for me completly.

Any help ?

On 11 Mar, 20:23, maciekjbl  wrote:
> Reload, restart and still nothing.
>
> I have my admin-media syn-linked to my media folder, is it wrong ?
> Because I see alias to this folder.
>
> From apache error log I know only that every request get [error
> 500].
>
> On 11 Mar, 13:42, krzysiekpl  wrote:
>
> > In my opinion you should add alias in nginx.conf for admin media
> > files. Put this code in server{}
>
> > # admin uses admin-media/
> >         # alias works different than root above by dropping admin-
> > media
> >         location ^~ /media/admin/ {
> >             alias /usr/local/lib/python2.6/dist-packages/django/
> > contrib/admin/media/;
> >         }
>
> > or this code for your static files
>
> > location  /static/ {
> >                 root      /path/to/project/where/static_folder_is;
> >                 expires max;
> >                 autoindex off;
> >         }
>
> > On 11 Mar, 11:41, maciekjbl  wrote:
>
> > > Hi,
>
> > > I know this topic was discussed a lot, but in every post for this
> > > topic there are diffrent configuration and this stop helping for me.
>
> > > Long story short : I changed DEBUG = True to False and all static
> > > media are gone, so this is something wrong in web server conf.
>
> > > #settings.py#
>
> > > import os.path
> > > PROJECT_DIR = os.path.dirname(__file__)
>
> > > MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media')
>
> > > MEDIA_URL = 'http://aplikacje/media/'
>
> > > ADMIN_MEDIA_PREFIX = '/media/admin/'
>
> > > nginx configuration 
> > > nginx.conf:
>
> > > user www-data;
> > > worker_processes  1;
>
> > > error_log  /var/log/nginx/error.log;
> > > pid        /var/run/nginx.pid;
>
> > > events {
> > >     worker_connections  1024;
> > >     # multi_accept on;
>
> > > }
>
> > > http {
> > >     include       /etc/nginx/mime.types;
>
> > >     access_log  /var/log/nginx/access.log;
>
> > >     sendfile        on;
> > >     #tcp_nopush     on;
>
> > >     #keepalive_timeout  0;
> > >     keepalive_timeout  65;
> > >     tcp_nodelay        on;
>
> > >     gzip  on;
> > >     gzip_disable "MSIE [1-6]\.(?!.*SV1)";
>
> > >     upstream webcluster {
> > >         server aplikacje:8000;
> > >     }
>
> > >     include /etc/nginx/conf.d/*.conf;
> > >     include /etc/nginx/sites-enabled/*;
>
> > > }
>
> > > #sites conf :
>
> > > server {
> > >         listen 80;
> > >         server_name media.aplikacje;
> > >         access_log /var/log/nginx/aplikacje.media.access.log;
> > >         location / {
> > >                 autoindex on;
> > >                 index index.html;
> > >                 root /var/www/web_aplikacje/web_aplikacje/media;
> > >         }
>
> > > }
>
> > > server {
> > >         listen 80;
> > >         server_name aplikacje;
> > >         access_log /var/log/nginx/aplikacje.django.access.log;
> > >         if ($host !~* "^aplikacje") {
> > >                 rewrite ^(.*)$http://aplikacje/$1permanent;
> > >                 break;
> > >         }
> > >         location / {
> > >                 proxy_passhttp://webcluster;
> > >                 include /etc/nginx/proxy.conf;
> > >         }
>
> > > }
>
> > > ###Apache conf ##
> > > 
>
> > >         #Basic Setup
> > >         ServerAdmin maciej.jablon...@hydrosolar.pl
> > >         ServerName aplikacje
> > >         ServerAlias media.aplikacje
> > >         ServerAlias aplikacje
>
> > >         DocumentRoot /var/www/web_aplikacje/web_aplikacje/media
>
> > >         WSGIScriptAlias / /var/www/web_aplikacje/web_aplikacje/apache/
> > > django.wsgi
>
> > >         
> > >                 Order deny,allow
> > >                 Allow from all
> > >         
> > > 
>
> > > Server is for the intranet use only. I have dns pointing 
> > > tohttp://aplikacje/
> > > and django works fine, only media ( css, img, admin media) gone.
>
> > > I will be every thankful if someone can point what is wrong with this
> > > conf a why it is wrong.

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



Optimizing a Postgres query using custom operator classes

2011-03-16 Thread benbeec...@gmail.com
Hey!

I'm having some trouble optimizing a query that uses a custom operator
class.
#Postgres has given me a solution for natural sort -
http://www.rhodiumtoad.org.uk/junk/naturalsort.sql

I'm trying to run it over a huge table - when running it on demand,
the data needs to be dumped to memory and sorted.

Sort  (cost=31299.83..31668.83 rows=369 width=31)
 Sort Key: name
 ->  Seq Scan on solutions_textbookpage  (cost=0.00..25006.55
rows=369 width=31)
   Filter: (active AND (textbook_id = 263))

That's obviously too slow. I've created an index using the custom
operator class, so I don't have to do the sort every time I try to
sort.

 Index Scan Backward using natural_page_name_textbook on
solutions_textbookpage  (cost=0.00..650.56 rows=371 width=31) (actual
time=0.061..0.962 rows=369 loops=1)
  Index Cond: (textbook_id = 263)
  Filter: active

Obviously a little faster!

The wrinkle is that because operator classes have a low
cost estimation pg missestimates and tries to do the sort on demand
rather than using the index using the default settings.

I can get pg to use the index on a repl by either jacking up
cpu_operator_cost
or lowering random_page_cost inside of postgres. However, when using
django to make the queries, I'm never seeing the index be used,
regardless of my settings.

I tried to force it with the following code:

def naturalsort_query(queryset, naturalsortop="<#"):
"""converts a sorted query from using asc or dec into using the
natual sort operators
postgre doesn't have a way to define custom operators as having a
cost - so it assumes that our
alphanumeric sorts are 'free' and uses them over the indexes. To
get around that, we have to jack up the cost of
cpu calcuations, run the query and then set the costs back to
normal (.0025 is the default)
"""

assert naturalsortop in ("<#","<=#","=#",">=#",">#",), "%s isn't a
recognised natural sort operation" % naturalsortop
assert queryset.query.order_by, "You need to include an order by
before sorting this query"
query_string = str(queryset.query)
db = queryset.db
cursor = connections[db].cursor()
cursor.execute('set cpu_operator_cost = 1;')
query_string =  re.sub("(ASC|DEC)","using %s" % naturalsortop,
query_string)
querymanager = queryset.model.objects
results =  querymanager.raw(query_string)
cursor.execute('set cpu_operator_cost = .0025;')
return results


But looking at my psql logs I can tell from the duration of the query
that the index still isn't being used. I'm at a loss! How can I make
sure that index is used?

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



aggregate produces incorrect sql statement

2011-03-16 Thread zeroos
Hi folks!

I have following model:

class Solution(models.Model):
griddler = models.ForeignKey(Griddler)
user = models.ForeignKey(User)
user_time = models.IntegerField(null=True)
date = models.DateTimeField(auto_now_add=True)

class Griddler(models.Model):

solved_by = models.ManyToManyField(Uesr, through='Solution')


What I am trying to do is to find the Griddler that has the biggest
avg user time. I've written the following query:
Solution.objects.values('griddler').annotate(a=Avg('user_time')).aggregate(Max('a'))

Unfortunately, after executing it I get DatabaseError: (1064, "You
have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'FROM
(SELECT `griddlers_solution`.`griddler_id` AS `griddler_id`,
AVG(`griddlers' at line 1")

>>> connection.queries[-1]
{'time': '0.000', 'sql': u'SELECT  FROM (SELECT
`griddlers_solution`.`griddler_id` AS `griddler_id`,
AVG(`griddlers_solution`.`user_time`) AS `a` FROM `griddlers_solution`
GROUP BY `griddlers_solution`.`griddler_id`,
`griddlers_solution`.`griddler_id` ORDER BY NULL) subquery'}



The problem is that Max('a') is skipped in the sql query. It should
look like this: SELECT Max(`a`) FROM...

I am using Django from SVN. >>> django.get_version()
'1.3 beta 1'

and MySQL backend.

Is it a Django bug that I should report or am I missing something?

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



Best Way To Update Multiple Fields In Model

2011-03-16 Thread octopusgrabbus
Django 1.2
mod_wsgi
Python 2.6.6

When I create an object of a model of a table, what is the best way to
update two columns? I can update one easily, but not two of them. I
also noted the model, does not list the third key, at least that I can
recognize.

What am I asking is what constructs should be use -- pointer to code
sample(s) to update two columns in one row or all rows?

This code does not work the way I want it to:

def save_dr_read_range(cycle_num, read_range_in, load_date,
updating_user, max_read_range_in, errors, update_ok):
try:
read_range_obj = DrReadRange(cycle=cycle_num, \
reading_width_days=read_range_in, \
creation_date=load_date, \
created_by=str(updating_user), \
max_read_width=max_read_range_in)

read_range_obj.save()
del read_range_obj

except IntegrityError as e:
errors.append('Error: modifying read range table ' + e)
update_ok  = False

except:
e = sys.exc_info()[1]
errors.append('Error: ' + str(e) + ' occurred')
update_ok = False

return errors, update_ok

tnx
cmn

Model:

from django.db import models

class DrReadRange(models.Model):
cycle = models.IntegerField(primary_key=True)
reading_width_days = models.IntegerField(primary_key=True)
creation_date = models.DateField(primary_key=False)
created_by = models.CharField(max_length=30)
max_read_width = models.IntegerField(null=True, blank=True)
class Meta:
db_table = u'dr_read_range'

SQL that created the table:
CREATE TABLE `dr_read_range` (
  `cycle` smallint(6) NOT NULL default '0',
  `reading_width_days` int(11) NOT NULL default '0',
  `creation_date` date NOT NULL,
  `created_by` char(10) NOT NULL default 'amr',
  `max_read_width` smallint(6) default '3',
  PRIMARY KEY  (`cycle`,`reading_width_days`,`creation_date`),
  KEY `creation_date_ix1` (`creation_date`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='holds daily reads
range';
SE

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



permissions don't get added

2011-03-16 Thread tom
Hello,

I have a model, which was already created within the DB, and I added
following permissions:
class META:
permissions = (
('view_all_projects', 'Can view all projects'),
)
verbose_name = _("project")
verbose_name_plural = _("projects")

When I started a syncdb, the permissions did not appear in the
database. I whiped the database and synced again, also no success.
This permission does not show up.

Has anyone an idea, what I am doing wrong?

thanks, tom

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



Re: Help using internationalization feature

2011-03-16 Thread Andres Lucena
El lun, 14-03-2011 a las 11:45 -0500, Juan Gabriel Aldana Jaramillo
escribió:
> Thanks for your comprehensive reply. Now everything is clear to me.
> 

Also you should check django-rosetta, it permits translating through an
admin like interface, with google translate integration; very nice ;) 

http://code.google.com/p/django-rosetta/

Bye,
Andres



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



Re: Mingus vs Zinnia

2011-03-16 Thread Gabriel - Iulian Dumbrava
I believe, yes. From what I read about it, it's using other apps and
it does not create any new models. So, as long as you can extend the
other apps, you can extend it.

Gabriel

On 16 mar., 13:45, Venkatraman S  wrote:
> On Wed, Mar 16, 2011 at 4:28 PM, Gabriel - Iulian Dumbrava <
>
> gabriel.dumbr...@gmail.com> wrote:
> > I have no experience with Mingus, but from I've seen on their web
> > site, it is much simpler.
>
> Does 'simpler' also mean 'easy to extend'?

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



Re: Fwd: [OT] Django Sprint Weekend

2011-03-16 Thread Kenneth Gonsalves
On Wed, 2011-03-16 at 17:41 +0530, Venkatraman S wrote:
> Posting this in django-user - I am from India and would be great if we
> have
> some local talent in this group who can jam up for a sprint.
> Otherwise, if remote members want to help, its *always* possible. 

it would be a good idea to give a link to the project
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Fwd: [OT] Django Sprint Weekend

2011-03-16 Thread Venkatraman S
Posting this in django-user - I am from India and would be great if we have
some local talent in this group who can jam up for a sprint.
Otherwise, if remote members want to help, its *always* possible.

Contact me offline if interested.

-- Forwarded message --
From: Venkatraman S 
Date: Tue, Mar 15, 2011 at 11:23 PM
Subject: [OT] Django Sprint Weekend
To: Bangalore Python Users Group - India 


Hi,

Was wondering whether anyone who has intermediate to advanced level of
Django knowledge would be interested in a paid code sprint over the weekend
to refactor an open source project.

I am looking for 2-3 developers; please do not reply if you are not
sufficiently conversation with Django+Python. The existing code is a little
prolix and needs to be broken down into chunks and dead code needs to be
removed.

I am not sure, but think i can pay a nominal amount or reimburse for the
food/refreshments along with a complimentary gift :)

Please contact me off-list.

-Venkat
PS:I havent tagged this commercial, as i think is under OSS arena.

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



Re: search in docs seem to have some problem

2011-03-16 Thread Kenneth Gonsalves
On Wed, 2011-03-16 at 11:45 +, Tom Evans wrote:
> > I am probably mistaken but from the thread I get a feeling that
> there is
> > not much urgency about it (maybe because of the pending release).
> But
> > people like me with poor memory *really* need it ;-)
> >
> >
> 
> It's not like that is the only way of finding information on the
> internet:
> 
> http://www.google.com/search?q="objects.create"+site:docs.djangoproject.com 

agreed - but after several years of using the internal search, difficult
to break old habits, that said even my favourite search engine gives it
as the top result:

http://duckduckgo.com/?q=site%3Adocs.djangoproject.com+objects.create
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Re: search in docs seem to have some problem

2011-03-16 Thread Tom Evans
On Wed, Mar 16, 2011 at 11:37 AM, Kenneth Gonsalves
 wrote:
> On Wed, 2011-03-16 at 07:21 -0400, Karen Tracey wrote:
>> Yes, it's been noted on django-developers:
>>
>> http://groups.google.com/group/django-developers/browse_thread/thread/41ee450a4687e1d8
>>
>> I don't know what the status of fixing it is.
>
> I am probably mistaken but from the thread I get a feeling that there is
> not much urgency about it (maybe because of the pending release). But
> people like me with poor memory *really* need it ;-)
>
>

It's not like that is the only way of finding information on the internet:

http://www.google.com/search?q="objects.create"+site:docs.djangoproject.com

Cheers

Tom

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



Re: Mingus vs Zinnia

2011-03-16 Thread Venkatraman S
On Wed, Mar 16, 2011 at 4:28 PM, Gabriel - Iulian Dumbrava <
gabriel.dumbr...@gmail.com> wrote:

> I have no experience with Mingus, but from I've seen on their web
> site, it is much simpler.
>

Does 'simpler' also mean 'easy to extend'?

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



Re: search in docs seem to have some problem

2011-03-16 Thread Kenneth Gonsalves
On Wed, 2011-03-16 at 07:21 -0400, Karen Tracey wrote:
> Yes, it's been noted on django-developers:
> 
> http://groups.google.com/group/django-developers/browse_thread/thread/41ee450a4687e1d8
> 
> I don't know what the status of fixing it is.

I am probably mistaken but from the thread I get a feeling that there is
not much urgency about it (maybe because of the pending release). But
people like me with poor memory *really* need it ;-) 


-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Re: search in docs seem to have some problem

2011-03-16 Thread Karen Tracey
On Wed, Mar 16, 2011 at 5:13 AM, Kenneth Gonsalves
wrote:

> hi,
>
> of late I notice that search in docs using the search on the right hand
> side is not getting results or is pointing to the wrong thing. For
> example I tried to search for 'objects.create', which I am pretty sure
> is in the docs, but get 'No results found'. Same thing with 'set.all()'
> or even 'foo_set.all()' which I used to find regularly before. Any one
> else seen this?
>

Yes, it's been noted on django-developers:

http://groups.google.com/group/django-developers/browse_thread/thread/41ee450a4687e1d8

I don't know what the status of fixing it is.

Karen
-- 
http://tracey.org/kmt/

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



Re: Mingus vs Zinnia

2011-03-16 Thread Gabriel - Iulian Dumbrava
Hi,
I did work with Zinnia, and I'm very pleased with it.

Some cool features:
- It's easy to extend and it comes with useful template tags.
- Integration with Django CMS
- Automatic sitemaps
- more, more

I have no experience with Mingus, but from I've seen on their web
site, it is much simpler.

Perhaps it depends on what you need.

Gabriel

On 16 mar., 09:18, Venkatraman S  wrote:
> Hi,
>
> I see both these projects being quiet noteworthy for their features.
> Any personal experiences using either of them in your projects that members
> can share -- mainly +/-'s w.r.t extensibility and maintainability.
>
> -Venkat

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



Re: How i can get username into the error mail?

2011-03-16 Thread Tom Evans
On Tue, Mar 15, 2011 at 6:32 PM, emonk  wrote:
> Hi django-users.
>
> I have a django project running in apache2 with  mod_wsgi and I need get the
> username logged into the mail error; the user is registered in the same data
> base of the project, i mean in the auth_user table (request.user.username
> called in the views).
>
> This is an example of the error mail generated by a some user request with
> an error and received by me (the admin) using DEBUG = False in settings.py:
>

Write some middleware which runs after AuthenticationMiddleware and
inserts the user's name into request.META.

Cheers

Tom

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



search in docs seem to have some problem

2011-03-16 Thread Kenneth Gonsalves
hi,

of late I notice that search in docs using the search on the right hand
side is not getting results or is pointing to the wrong thing. For
example I tried to search for 'objects.create', which I am pretty sure
is in the docs, but get 'No results found'. Same thing with 'set.all()'
or even 'foo_set.all()' which I used to find regularly before. Any one
else seen this?
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Mingus vs Zinnia

2011-03-16 Thread Venkatraman S
Hi,

I see both these projects being quiet noteworthy for their features.
Any personal experiences using either of them in your projects that members
can share -- mainly +/-'s w.r.t extensibility and maintainability.

-Venkat

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