AW: PayPAL-IPN-request doesn't call the view

2010-09-10 Thread daqube
Thank you, guys.
I found out what the problem was, now.
It was a stupid error in my middleware, which couldn’t handle
the empty referstring from paypal...
now everything is working fine again

-Ursprüngliche Nachricht-
Von: django-users@googlegroups.com [mailto:django-us...@googlegroups.com] Im
Auftrag von Brian Neal
Gesendet: Samstag, 11. September 2010 02:05
An: Django users
Betreff: Re: PayPAL-IPN-request doesn't call the view

On Sep 10, 12:01 pm, Bill Freeman  wrote:
>
> My advice is to protect everything with try or by using get,
> log your progress (we had a logging model, but you can
> also append to a file, wrapping everything in a try-finally
> that closes the filehandle to be sure things get flushed
> out), and when you get something you haven't provided
> for, log the contents of request.POST.  It will be something
> simple, such as there's some field they no longer provide
> or don't always provide.

I have to echo Bill's advice here. Use the Python logger generously in
your IPN view handling code. Paypal has a habit of subtly changing
their API or their POST parameters periodically. Anyway, unless you
are getting hundreds of IPN's a day, I'd log all kinds of stuff to a
file and study it to see where it is going wrong. Good luck,

BN

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

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



Re: Integrating User Profile with Auth

2010-09-10 Thread Shawn Milochik
I think you just may be missing a call to get_profile() in this view.
You can just do that and do a try block with an except block for
DoesNotExist. That will let you know the situation you're in, whether
the profile already existed or not.

Also, unless I'm misreading something you're trying to pass a User
instance as the instance for a user profile, which will not work. If
anything, you should be doing a .get() on the user profile where user
= request.user, but that doesn't matter anyway because get_profile()
does the same thing and is the correct way to do this.

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



Re: Staticstic app, ask for idea.

2010-09-10 Thread Lucian Romi
Also, need I define "my_float_field__range"? Thanks

On Fri, Sep 10, 2010 at 6:52 PM, Lucian Romi  wrote:
> Hi, Sebastien
>
> Follow your instruction, I was able to create a Cube object and define
> sample_space.
> However, I don't know how to retrieve the measure result. Can you tell
> me how to do that?
> What do you mean by "instantiate a cube with a base queryset, and use
> one of the methods
> provided to calculate the statistics"
>
> Thanks.
>
> On Tue, Aug 31, 2010 at 1:33 AM, sebastien piquemal  wrote:
>> To integrate a calculated value with search features from admin app, I
>> don't know any other way than create and save a calculated field on
>> your model ...
>> This calculated field, you can calculate it with cube ... but if you
>> don't use the Cube for any other statistic than that, it is too much
>> overhead.
>>
>> On Aug 31, 5:30 am, Lucian Romi  wrote:
>>> Thanks Sebastien.
>>>
>>> Can I integrate Cube with filter and search features from the admin app?
>>> Also, to make things simple, I'm going to use GChart, but I need
>>> statistic data.
>>> Let me download Cube and spend some time on it. Thanks.
>>>
>>> On Mon, Aug 30, 2010 at 4:16 PM, sebastien piquemal  
>>> wrote:
>>> > I created an app to easily generate the stats part :
>>> >http://code.google.com/p/django-cube/; however you still have to
>>> > create the chart, for example with matplotlib :
>>> >http://www.scipy.org/Cookbook/Matplotlib/Django.
>>>
>>> > To create your stats with django-cube, you can use this code :
>>>
>>> >    from cube.models import Cube, Dimension
>>>
>>> >    class MyModelCube(Cube):
>>> >        my_dimension = Dimension(field='my_float_field__range',
>>> > sample_space=[(0, 1.5), (1.5, 6.2)])
>>>
>>> >       �...@static
>>> >        def aggregation(queryset):
>>> >            return queryset.count()/MyModel.objects.count() * 100
>>>
>>> > - You specify one dimension for the cube, this dimension refers to the
>>> > field lookup 'my_float_field__range' (where 'my_float_field' is of
>>> > course the name of your field)
>>> > - then you specify a sample space for this dimension, which in fact
>>> > means that you specify for which ranges the stats will be calculated
>>> > (here, on the ranges (0, 1.5) and (1.5, 6.2))
>>> > - then you write your aggregation function, which is in your case a
>>> > percentage calculation ('queryset' is the queryset filtered according
>>> > to the dimensions you will use while querying the cube, divided by the
>>> > total, multiplied by 100)
>>> > - finally, you instantiate a cube with a base queryset, and use one of
>>> > the methods provided to calculate the statistics
>>>
>>> > Ok, the doc is kind of bad for now, but I can help you if you want to
>>> > use it but you don't manage to do so.
>>>
>>> > On Aug 30, 8:24 pm, hollando  wrote:
>>> >> I want to make a statistic app.
>>> >> There is a float field in my model(table).I want to use a chart to
>>> >> show what's the percentage in each range.
>>> >> Any suggestion to make such and app that can fit into django model.
>>> >> Thanks.
>>>
>>> > --
>>> > You received this message because you are subscribed to the Google Groups 
>>> > "Django users" group.
>>> > To post to this group, send email to django-us...@googlegroups.com.
>>> > To unsubscribe from this group, send email to 
>>> > django-users+unsubscr...@googlegroups.com.
>>> > For more options, visit this group 
>>> > athttp://groups.google.com/group/django-users?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>

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



Re: Staticstic app, ask for idea.

2010-09-10 Thread Lucian Romi
Hi, Sebastien

Follow your instruction, I was able to create a Cube object and define
sample_space.
However, I don't know how to retrieve the measure result. Can you tell
me how to do that?
What do you mean by "instantiate a cube with a base queryset, and use
one of the methods
provided to calculate the statistics"

Thanks.

On Tue, Aug 31, 2010 at 1:33 AM, sebastien piquemal  wrote:
> To integrate a calculated value with search features from admin app, I
> don't know any other way than create and save a calculated field on
> your model ...
> This calculated field, you can calculate it with cube ... but if you
> don't use the Cube for any other statistic than that, it is too much
> overhead.
>
> On Aug 31, 5:30 am, Lucian Romi  wrote:
>> Thanks Sebastien.
>>
>> Can I integrate Cube with filter and search features from the admin app?
>> Also, to make things simple, I'm going to use GChart, but I need
>> statistic data.
>> Let me download Cube and spend some time on it. Thanks.
>>
>> On Mon, Aug 30, 2010 at 4:16 PM, sebastien piquemal  wrote:
>> > I created an app to easily generate the stats part :
>> >http://code.google.com/p/django-cube/; however you still have to
>> > create the chart, for example with matplotlib :
>> >http://www.scipy.org/Cookbook/Matplotlib/Django.
>>
>> > To create your stats with django-cube, you can use this code :
>>
>> >    from cube.models import Cube, Dimension
>>
>> >    class MyModelCube(Cube):
>> >        my_dimension = Dimension(field='my_float_field__range',
>> > sample_space=[(0, 1.5), (1.5, 6.2)])
>>
>> >       �...@static
>> >        def aggregation(queryset):
>> >            return queryset.count()/MyModel.objects.count() * 100
>>
>> > - You specify one dimension for the cube, this dimension refers to the
>> > field lookup 'my_float_field__range' (where 'my_float_field' is of
>> > course the name of your field)
>> > - then you specify a sample space for this dimension, which in fact
>> > means that you specify for which ranges the stats will be calculated
>> > (here, on the ranges (0, 1.5) and (1.5, 6.2))
>> > - then you write your aggregation function, which is in your case a
>> > percentage calculation ('queryset' is the queryset filtered according
>> > to the dimensions you will use while querying the cube, divided by the
>> > total, multiplied by 100)
>> > - finally, you instantiate a cube with a base queryset, and use one of
>> > the methods provided to calculate the statistics
>>
>> > Ok, the doc is kind of bad for now, but I can help you if you want to
>> > use it but you don't manage to do so.
>>
>> > On Aug 30, 8:24 pm, hollando  wrote:
>> >> I want to make a statistic app.
>> >> There is a float field in my model(table).I want to use a chart to
>> >> show what's the percentage in each range.
>> >> Any suggestion to make such and app that can fit into django model.
>> >> Thanks.
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups 
>> > "Django users" group.
>> > To post to this group, send email to django-us...@googlegroups.com.
>> > To unsubscribe from this group, send email to 
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group 
>> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: How does django convert string to modules

2010-09-10 Thread Bachir
What if was gibing a string like this: 'math.ceil', and i had to import the
function(not the module) dynamically(from the string), how can i do that?
import_module is for importing... modules, not functions.

2010/9/10 Bachir 

> thanks, éthat's really an awesome explanation. thanks
>
> 2010/9/10 Tom Evans 
>
> On Fri, Sep 10, 2010 at 1:05 AM, Bachir  wrote:
>> > The problem is not the lack of information, the real problem is that i
>> don't
>> > know what to search for .
>> >
>> > 2010/9/9 bruno desthuilliers 
>> >>
>> >>
>> >> On 9 sep, 03:46, maroxe  wrote:
>> >> > Hi, I am trying to understand an other magic thing about django: it
>> >> > can convert strings to modules. In settings.py, INSTALLED_APPS is
>> >> > declared like that:
>> >> >
>> >> > INSTALLED_APPS = (
>> >> > 'django.contrib.auth',
>> >> > 'django.contrib.contenttypes',
>> >> > 'django.contrib.sessions',
>> >> > )
>> >> > All it contains is strings. But django will convert those strings to
>> >> > modules and import them later.
>> >> >
>> >> > I want to do be able to do the same thing. but i don't know how.
>>
>> Well, OK. Lets break down how one could find this out, because you
>> *did* have everything you needed to find this out yourself.
>>
>> You wanted to turn a string into a module name, so you can import from it.
>> You noticed that django does the same thing with the setting
>> INSTALLED_APPS.
>> You have the django source code.
>>
>> So, the first thing to do is to search the django source code for
>> INSTALLED_APPS.
>> For this, I tend to use "ack", which is like grep but better for
>> programmers.
>> This returns lots of files - its used in lots of places. Look at the
>> list of files returned and choose one that looks appropriate to look
>> at.
>>
>> I chose "core/management/commands/syncdb.py", as I knew this file is
>> responsible for creating db models - its the code that runs when you
>> run ./manage.py syncdb.
>>
>> Looking at how INSTALLED_APPS is used in that file:
>>
>> >for app_name in settings.INSTALLED_APPS:
>> >try:
>> >import_module('.management', app_name)
>> >except ImportError, exc:
>>
>> Ah, so theres a function called import_module. Where does that come from?
>>
>> > from django.utils.importlib import import_module
>>
>> Ah, so now I know how it does it's import magic, and I know how to
>> import it myself. I can now play around with this in the shell, so I
>> know I have the usage right:
>>
>> >>> from django.utils.importlib import import_module
>> >>> mod = import_module('math')
>> >>> mod.ceil
>> 
>>
>> There, not so hard, is it? You did know what to search for, as you
>> included it in your original question..
>>
>> 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-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>

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



Re: PayPAL-IPN-request doesn't call the view

2010-09-10 Thread Brian Neal
On Sep 10, 12:01 pm, Bill Freeman  wrote:
>
> My advice is to protect everything with try or by using get,
> log your progress (we had a logging model, but you can
> also append to a file, wrapping everything in a try-finally
> that closes the filehandle to be sure things get flushed
> out), and when you get something you haven't provided
> for, log the contents of request.POST.  It will be something
> simple, such as there's some field they no longer provide
> or don't always provide.

I have to echo Bill's advice here. Use the Python logger generously in
your IPN view handling code. Paypal has a habit of subtly changing
their API or their POST parameters periodically. Anyway, unless you
are getting hundreds of IPN's a day, I'd log all kinds of stuff to a
file and study it to see where it is going wrong. Good luck,

BN

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



Integrating User Profile with Auth

2010-09-10 Thread darren
I am following the information in the docs to add fields to maintain, in
addition to the ones Auth already maintains.  I'm starting with the docs
here:


So far, I have a model form I've created based on the additional fields.
 And, I'm displaying my form in my template.  But, I can't seem to get the
form to work.  My plan is to use the exception encountered when
get_profile() is called in another view, but the profile doesn't yet exist.
I want to catch the error and send the user to a form to fill out the extra
field I want to maintain and pre-populate another.

Mostly I think my problem arises when I try to save my form.  But, it could
be when I create it.  The form is displaying a drop down list box of all of
the users.  So, something odd is going on there.  Also, every time I submit
the form, the submit method is GET, even though the method is set to POST in
the form's attributes.

I believe I may be stumbling over this part of the docs:

"The method 
get_profile()
 does not create the profile, if it does not exist. You need to register a
handler for the
signaldjango.db.models.signals.post_save
 on the User model, and, in the handler, if created=True, create the
associated user profile"

A suggestion is made here
to create the
profile.

*User.profile = property(lambda u:
UserProfile.objects.get_or_create(user=u)[0])*

But, if I automatically create the profile, I can't catch the exception for
a missing profile.

Here's some code:

In my template, I have this code (line 93 seems to be instrumental in my
problem).  I can get a post if I use line 92 instead of line 93.  But, I
still have 2 problems.  First, it's letting me choose the user (I was hoping
the code on line 90 would eliminate that).  And, second, the form simply
won't save.:

 86 @login_required
 87 def createProfile(request):
 88 err_msg = [request.method] # I have this so I can see the method
 89 messages = []
 90 a = User.objects.get(username=request.user.username)
 91 # err_msg = [request.method, a]
 92 # form = UserProfileForm(instance=a)
 93 form = UserProfileForm(request.POST, instance=a)
 94 if request.method == 'POST':
 95 if form.is_valid():
 96 form.save()
 97 return HttpResponseRedirect("/")
 98 else:
 99 err_msg.append("Error Processing File")
100 return render_to_response('fav/createProfile.tpl', {
'ERROR_MSG' : err_msg, 'messages' : messages, 'form' : form  },
RequestContext(request) )
101 return render_to_response('fav/createProfile.tpl', { 'ERROR_MSG' :
err_msg, 'form' : form }, RequestContext(request))

My Model:

  1 from django.db import models
  2 from django.forms import ModelForm
  3 from django.contrib.auth.models import User
  4
  5 class UserProfile(models.Model):
  6 user = models.ForeignKey(User, unique=True)
  7 screenname = models.CharField('Screen Name', max_length=25,
unique=True)
  8 credits = models.PositiveSmallIntegerField('Credits', default=3)
  9
 10 class UserProfileForm(ModelForm):
 11 class Meta:
 12 model = UserProfile
 13 #fields = ['screenname'] # I've tried uncommenting 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Color code not working on admin listing table list_display.

2010-09-10 Thread Lucian Romi
Following http://docs.djangoproject.com/en/dev/ref/contrib/admin/

class Person(models.Model):
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
color_code = models.CharField(max_length=6)

def colored_name(self):
return '%s %s' %
(self.color_code, self.first_name, self.last_name)
colored_name.allow_tags = True

class PersonAdmin(admin.ModelAdmin):
list_display = ('first_name', 'last_name', 'colored_name')

It's not showing any color. I checked the html source code. It did
have these style codes.
What's the reason. How to fix? thanks.

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



Re: django-simple-freinds: template tags and Friendship request

2010-09-10 Thread justin jools
Hi Preston thanks for your response but still having problem with
this:

views.py (full list below) passes:

extra_context['friendship_requests'] = {'incoming':
incoming_requests,
'outgoing':
outgoing_requests}

I have tried looping through this to extract from_user and to_user as
seperate variables but it doesnt work:

  test for friendship_requests
  {% for friendship_requests in friendsrequest_list %}
 {{ friendship_requests.incoming.from_user}}
  {% endfor %}
  

although not producing an error it write out no data...

Could you suggest how to extract from_user and to_user variables.


My other question is regarding the templatetags (full listing add
bottom)

I think it works like this:
{% load friends_tags %}

{% add_to_friends target_user %}

it then redirects to _add_to.htmtl template, I'm not entirely sure
what I should have in this template: something like 'User1 was added
to your friends'

Thanks for your help

views

@login_required
def friend_list(request,
username=None,
paginate_by=None,
page=None,
allow_empty=True,
template_name='friends/friends_list.html',
extra_context=None,
template_object_name='friends'):
if username:
user = get_object_or_404(User, username=username)
else:
user = request.user
friends = Friendship.objects.friends_of(user)
if extra_context is None:
extra_context = {}
incoming_requests = FriendshipRequest.objects.filter(
 to_user=request.user,
accepted=False)
outgoing_requests = FriendshipRequest.objects.filter(
   from_user=request.user,
accepted=False)
extra_context['sender_user'] = request.user
extra_context['target_user'] = user
extra_context['friendship_requests'] = {'incoming':
incoming_requests,
'outgoing':
outgoing_requests}
extra_context['user_blocks'] =
request.user.user_blocks.blocks.all()
return object_list(request,
   queryset=friends,
   paginate_by=paginate_by,
   page=page,
   allow_empty=allow_empty,
   template_name=template_name,
   extra_context=extra_context,
   template_object_name=template_object_name)

models
class FriendshipRequest(models.Model):
from_user = models.ForeignKey(User,
related_name="invitations_from")
to_user = models.ForeignKey(User, related_name="invitations_to")
message = models.CharField(max_length=200, blank=True)
created = models.DateTimeField(default=datetime.datetime.now,
   editable=False)
accepted = models.BooleanField(default=False)

class Meta:
verbose_name = _(u'friendship request')
verbose_name_plural = _(u'friendship requests')
unique_together = (('to_user', 'from_user'),)

def __unicode__(self):
return _(u'%(from_user)s wants to be friends with %
(to_user)s') % \
{'from_user': unicode(self.from_user),
 'to_user': unicode(self.to_user)}

def accept(self):
Friendship.objects.befriend(self.from_user, self.to_user)
self.accepted = True
self.save()
signals.friendship_accepted.send(sender=self)

def decline(self):
signals.friendship_declined.send(sender=self, cancelled=False)
self.delete()

def cancel(self):
signals.friendship_declined.send(sender=self, cancelled=True)
self.delete()

template tags
full version at : 
http://github.com/muhuk/django-simple-friends/blob/master/friends/templatetags/friends_tags.py

@register.tag
def add_to_friends(parser, token):
bits = token.split_contents()
tag_name, bits = bits[0], bits[1:]
if not bits:
raise template.TemplateSyntaxError(
   '%s tag requires at least one argument' %
tag_name)
elif len(bits) > 3:
raise template.TemplateSyntaxError(
'%s tag takes at most three arguments' %
tag_name)
if len(bits) == 3:
if bits[2].startswith('"') and bits[2].endswith('"'):
bits[2] = bits[2][1:-1]
else:
raise template.TemplateSyntaxError(
  'Third argument for %s tag must be a string' %
tag_name)
return AddToFriendsNode(*bits)


class AddToFriendsNode(template.Node):
def __init__(self, target_user, current_user='user',
   template_name='friends/_add_to.html'):
self.target_user = template.Variable(target_user)
self.current_user = template.Variable(current_user)
self.template_name = template_name

def render(self, context):
target_user = self.target_user.resolve(context)
current_user = self.curren

released source code of tipsforlinux.com

2010-09-10 Thread Gustavo Henrique
Hi!
I'm think the beginners can enjoy the source code...

website: http://tipsforlinux.com
source: http://github.com/gustavohenrique/TipsForLinux

Suggestions are welcome!


-- 
Gustavo Henrique
blog.gustavohenrique.net

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



tracking down a login issue (django 1.2)

2010-09-10 Thread Cindy
I'm not completely certain what is going on here, but somewhere in the
authentication stuff, a bad MySQL query is being generated:

ListType

TupleType

args
[]
charset
'utf8'
db

exc

exc_info

query
'\n SELECT ct.`app_label`, p.`codename`\n FROM `auth_permission` p,
`auth_group_permissions` gp, `auth_group` g, `django_content_type` ct
\n WHERE p.`id` = gp.`permission_id`\n AND gp.`group_id` = g.`id`\n
AND ct.`id` = p.`content_type_id`\n AND g.`name` IN ()'
self

value
ProgrammingError(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 ')' at line 6")

Notice the empty join clause in that query :/

This seemed to start up after I added a group permission and set all
the users except the superuser to that group permission, but I have a
development setup (using django 1.1) set up the same way that works.
Any thoughts?  I may well have set something here that isn't kosher,
but neither do I think that django's authentication should be throwing
up a query with IN () ... !  Note that though I have ldap
authentication set up, this seems to be having issues before getting
to ldap (and simple ldap queries are working fine, as are other mysql
queries, so I know these are good to go) based on where it hangs up:

Request Method: GET
Request URL:[...]/admin
Django Version: 1.2.1
Exception Type: DatabaseError
Exception Value:

(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 ')' at line 6")

Exception Location: /usr/local/lib/python2.6/site-packages/
MySQLdb/
connections.py in defaulterrorhandler, line 35
Python Executable:  /usr/local/bin/python
Python Version: 2.6.5

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



Re: Filter for non-True NullBooleanField

2010-09-10 Thread Christos Jonathan Hayward
P.S. Setting:

.filter(is_invisible__in = [False, None])

is not working as intended; I seem to be getting no matches when I should be
getting matches.

On Fri, Sep 10, 2010 at 4:19 PM, Christos Jonathan Hayward <
christos.jonathan.hayw...@gmail.com> wrote:

> How can I filter for instances having a NullBooleanField that is not True
> (i.e. is either False or a null)?
>
> --
> [image: Christos Jonathan Hayward] 
> Christos Jonathan Hayward, an Orthodox Christian author.
>
> Author Bio  • 
> Books
>  • *Email * • 
> Facebook
>  • LinkedIn  • 
> Twitter
>  • *Web * • What's 
> New?
> I invite you to visit my "theology, literature, and other creative works"
> site.
>
>


-- 
[image: Christos Jonathan Hayward] 
Christos Jonathan Hayward, an Orthodox Christian author.

Author Bio  • Books
 • *Email * •
Facebook
 • LinkedIn  •
Twitter
 • *Web * • What's
New?
I invite you to visit my "theology, literature, and other creative works"
site.

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



tracking down a login issue (django 1.2)

2010-09-10 Thread Cindy
I'm not completely certain what is going on here, but somewhere in the
authentication stuff, a bad MySQL query is being generated:

ListType

TupleType

args
[]
charset
'utf8'
db

exc

exc_info

query
'\n SELECT ct.`app_label`, p.`codename`\n FROM `auth_permission` p,
`auth_group_permissions` gp, `auth_group` g, `django_content_type` ct
\n WHERE p.`id` = gp.`permission_id`\n AND gp.`group_id` = g.`id`\n
AND ct.`id` = p.`content_type_id`\n AND g.`name` IN ()'
self

value
ProgrammingError(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 ')' at line 6")


Notice the empty join clause in that query :/

This seemed to start up after I added a group permission and set all
the users except the superuser to that group permission, but I have a
development setup (using django 1.1) set up the same way that works.
Any thoughts?  I may well have set something here that isn't kosher,
but neither do I think that django's authentication should be throwing
up a query with IN () ... !  Note that though I have ldap
authentication set up, this seems to be having issues before getting
to ldap (and simple ldap queries are working fine, as are other mysql
queries, so I know these are good to go) based on where it hangs up:

Request Method: GET
Request URL:https://sysnet.ucsd.edu/sysnetinfo/admin/
Django Version: 1.2.1
Exception Type: DatabaseError
Exception Value:

(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 ')' at line 6")

Exception Location: /usr/local/lib/python2.6/site-packages/MySQLdb/
connections.py in defaulterrorhandler, line 35
Python Executable:  /usr/local/bin/python
Python Version: 2.6.5

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



Re: Admin / Login / "Permission Denied" Message Dilemma

2010-09-10 Thread ringemup

On a related note, the admin login screen doesn't seem to be willing
to redirect users to a "next"  destination outside the admin app,
which means having two separate login screens for different purposes,
which doesn't make any sense at all.

On Sep 10, 5:12 pm, ringemup  wrote:
> I'm a little frustrated trying to set up logins for my site.  Using
> @permission_required, if a user is already logged in but doesn't have
> sufficient permissions for a particular view, they just get redirected
> to the login form, with no explanation.
>
> I can set up a custom login view that will give the user to a
> "permission denied" page if they're already logged in or redirect them
> to the login screen otherwise.
>
> However, due to the way that admin handles logins there's still no way
> to give the user a useful error message if they try to log into the
> admin and log into the site successfully but don't have permission to
> use the admin at all.  Any suggestions?

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



Filter for non-True NullBooleanField

2010-09-10 Thread Christos Jonathan Hayward
How can I filter for instances having a NullBooleanField that is not True
(i.e. is either False or a null)?

-- 
[image: Christos Jonathan Hayward] 
Christos Jonathan Hayward, an Orthodox Christian author.

Author Bio  • Books
 • *Email * •
Facebook
 • LinkedIn  •
Twitter
 • *Web * • What's
New?
I invite you to visit my "theology, literature, and other creative works"
site.

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



django-simple-friends help

2010-09-10 Thread justin jools
Hi,

I am using django-simple-friends app and was hoping you would give me
some guidance.
http://github.com/muhuk/django-simple-friends

I have set up friends_list.html no problem:
 Friend List
Friends for {{ user }}
  
  {% for friends in friends_list %}
  {{ friends.username }}
  {% endfor %}
  
 and understand how to send friend request via url:
 http://127.0.0.1:8000/friends/add/jim
 but I am having problems listing friend requests:
 {{ friendship_requests.incoming }} spits out (below) and I coudn't
work how to remove the [< >]
or access the User sending the friend request.
 []

So I figured this is wrong to do it.
So I tried templatetags:

{% load friends_tags %}
{% add_to_friends 3 %}

which works, and redirects to _add_to.html
which I'm guessing should have a message like You have made a friend
request to User _
don't know how to get User being sent to.

 Does anyone have a working example or can you help me clear up these
issues. Thanks for your help

Sincerely,
JusinJools

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



django simple friends help

2010-09-10 Thread justin jools
Hi Muhuk,

I am using django-simple-friends app and I was hoping someone would
give me some guidance.
http://github.com/muhuk/django-simple-friends

I have set up friends_list.html no problem:
 Friend List
Friends for {{ user }}
  
  {% for friends in friends_list %}
  {{ friends.username }}
  {% endfor %}
  
 and understand how to send friend request via url:
 http://127.0.0.1:8000/friends/add/jim
 but I am having problems listing friend requests:
 {{ friendship_requests.incoming }} spits out (below) and I coudn't
work how to remove the [< >]
or access the User sending the friend request.
 []

So I figured this is wrong to do it.
So I tried templatetags:

{% load friends_tags %}
{% add_to_friends 3 %}

which works, and redirects to _add_to.html
which I'm guessing should have a message like You have made a friend
request to User _
don't know how to get User being sent to.

Does anyone have a working example or can you help me clear up these
issues. Thanks for your help

Sincerely,
JusinJools

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



Admin / Login / "Permission Denied" Message Dilemma

2010-09-10 Thread ringemup
I'm a little frustrated trying to set up logins for my site.  Using
@permission_required, if a user is already logged in but doesn't have
sufficient permissions for a particular view, they just get redirected
to the login form, with no explanation.

I can set up a custom login view that will give the user to a
"permission denied" page if they're already logged in or redirect them
to the login screen otherwise.

However, due to the way that admin handles logins there's still no way
to give the user a useful error message if they try to log into the
admin and log into the site successfully but don't have permission to
use the admin at all.  Any suggestions?

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



Re: Change variable value after a click

2010-09-10 Thread Felix Dreissig
It's definitely a good idea to gain some AJAX experience first, but on
how to integrate it with Django:
You'll have to write a special view to retrieve the additional elements
to be displayed on the page.
That's "how to do it" in general, hope it'll help you a bit

Regards,
Felix


On 10.09.2010 22:02, nick.l...@gmail.com wrote:
> I don't think you can do this with a view and NOT refresh the page. 
> 
> To get the functionality you want you need to use AJAX (and jquery would
> make it easier).
> 
> do some research on how to use jquery to manipulate the dom and add HTML
> elments to the page live.
> There some jquery bits out there that'll allow you to manipulate the
> document (read: page your on) through various click based events.
> 
> Start with a page that has a button on it (or a link) and put a
> "you're code goes here" in there that gets called on
> the "onClick" event that will then put a Hello World on the page.
> That'll get you the basic functionality that you need (sorry I'm low on
> resources for you, but there's plenty of stuff out there if you google it!)
> 
> n
> 
> On Fri, Sep 10, 2010 at 11:39 AM, mf  > wrote:
> 
> I'm working in a django view and I'd like to duplicate the
> items_rating value of myview when I click to "see more categories" in
> the template. All of this without refreshing the web.
> 
> I think that I have to use jquery and Ajax to perform this action but
> I don't know how to do it. The examples I read about were about form
> submissions and I couldn't find a way to use it.
> 
> views.py:
> 
> def myview(request):
>items_rating = 5
> html:
> 
> See more categories
> 
> --
> 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.
> 
> 
> 
> 
> -- 
> Guadajuko! Vamos a correr!
>  -"Cool! we are going to run!"
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: Change variable value after a click

2010-09-10 Thread nick.l...@gmail.com
I don't think you can do this with a view and NOT refresh the page.

To get the functionality you want you need to use AJAX (and jquery would
make it easier).

do some research on how to use jquery to manipulate the dom and add HTML
elments to the page live.
There some jquery bits out there that'll allow you to manipulate the
document (read: page your on) through various click based events.

Start with a page that has a button on it (or a link) and put a
"you're code goes here" in there that gets called on the
"onClick" event that will then put a Hello World on the page.
That'll get you the basic functionality that you need (sorry I'm low on
resources for you, but there's plenty of stuff out there if you google it!)

n

On Fri, Sep 10, 2010 at 11:39 AM, mf  wrote:

> I'm working in a django view and I'd like to duplicate the
> items_rating value of myview when I click to "see more categories" in
> the template. All of this without refreshing the web.
>
> I think that I have to use jquery and Ajax to perform this action but
> I don't know how to do it. The examples I read about were about form
> submissions and I couldn't find a way to use it.
>
> views.py:
>
> def myview(request):
>items_rating = 5
> html:
>
> See more categories
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Guadajuko! Vamos a correr!
 -"Cool! we are going to run!"

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



Re: ModelName.objects.none().update() makes changes to db

2010-09-10 Thread David Somers Harris
I haven't set a custom manager as far as I'm aware. Here is what happens to
me:

>>> from cube.books.models import Book
>>> no_books = Book.objects.none()
>>> Book.objects.all().count()
1667
>>> Book.objects.filter(status='O').count()
1
>>> no_books.update(status='O')
1667
>>> Book.objects.filter(status='O').count()
1667
>>>

and here is my model

class Book(models.Model):
"""
For when a student lists a particular copy of a book.
Keeps track of
* when and who listed (is selling) it
* if and who is currently holding it
* when it was last put on hold
* when it finally got sold
* whether the book is flagged for deletion or not
"""
STATUS_CHOICES = (
(u'F', u'For Sale'),
(u'M', u'Missing'),
(u'O', u'On Hold'),
(u'P', u'Seller Paid'),
(u'S', u'Sold'),
(u'D', u'Deleted'),
(u'T', u'To Be Deleted'),
)

metabook = models.ForeignKey(MetaBook)
list_date = models.DateTimeField('Date Listed', default=datetime.now)
seller = models.ForeignKey(User, related_name="selling")
sell_date = models.DateTimeField('Date Sold', blank=True, null=True)
holder = models.ForeignKey(User, related_name="holding",
   blank=True, null=True)
hold_date = models.DateTimeField('Date Held', blank=True, null=True)
price = models.DecimalField(max_digits=7, decimal_places=2)
status = models.CharField(max_length=1, choices=STATUS_CHOICES,
default='F')
is_legacy = models.BooleanField(default=False)

def __unicode__(self):
return "%s listed by %s on %s" % (self.metabook, self.seller,
  self.list_date.date())

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



Change variable value after a click

2010-09-10 Thread mf
I'm working in a django view and I'd like to duplicate the
items_rating value of myview when I click to "see more categories" in
the template. All of this without refreshing the web.

I think that I have to use jquery and Ajax to perform this action but
I don't know how to do it. The examples I read about were about form
submissions and I couldn't find a way to use it.

views.py:

def myview(request):
items_rating = 5
html:

See more categories

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



Re: import Error

2010-09-10 Thread nick.l...@gmail.com
Rav,

There's an environmental variable called PYTHONPATH that often tripped me up
when I was learning python and django. You need to make sure that the
django-chat module is on your PYTHONPATH.

To check that you've properly added the app to your PYTHONPATH start up
python then type `import dojango`

n

On Thu, Sep 9, 2010 at 9:37 PM, ravi krishna  wrote:

> Hi,
> For installing i followed their instructions
> Setup¶ 
>
>- unzip django-chat archive or checkout it
>- install dojango (
>http://dojango.googlecode.com/files/dojango-0.3.tar.gz) in the python
>path
>- create database (python manage.py syncdb --noinput), the superuser is
>"admin" password "chat"
>- python manage.py runserver
>   - url of the test page: http://localhost:8000/chat
>
> After doing the syncdb i am getting this import error. Can u please tell me
> how to install it via set.py
>
> Thanks & Regards,
> Rav!
>
>
> On Thu, Sep 9, 2010 at 1:12 PM, Jitesh  wrote:
>
>> Have you installed the django-chat-0.2 using setup.py, (make sure it
>> is there in python site-packages and also check its application name
>> there)
>> and have you specified python's bin path in enviornment variables?
>>
>> On Sep 8, 11:21 am, ravi krishna  wrote:
>> > Hi,
>> > I am newbie with python and django. I am trying out various examples in
>> > order to learn it. I wanted to try using django- chat application.
>> > downloaded the code from site and installed dojango as instructed. But
>> when
>> > i start the server it gives me an error "ImportError: No module named
>> > django-chat-0.2", where django-chat-0.2 is the apllication name.
>> Somebody
>> > please give a solution.
>> >
>> > --
>> > Regards,
>> > Rav!
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>
>
> --
> Regards,
> Rav!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Guadajuko! Vamos a correr!
 -"Cool! we are going to run!"

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



Re: PayPAL-IPN-request doesn't call the view

2010-09-10 Thread Bill Freeman
When I did this I dummied up a static page on the filesystem
of my desktop with a suitable post (I got the fields to expect
by running the server IPN was pointed at - needs to be a
routeable IP - with pdb and a break point at the start of the
view).

Then when we wen't live, it bombed.  I had been checking for
the test mode indicater, and it just wasn't there, rather than
set to false, when not in test mode, and I didn't adequately
guard my code when accessing the parameters.  And, of
course, you don't get to see the server error because it's
not you posting to the view.

My advice is to protect everything with try or by using get,
log your progress (we had a logging model, but you can
also append to a file, wrapping everything in a try-finally
that closes the filehandle to be sure things get flushed
out), and when you get something you haven't provided
for, log the contents of request.POST.  It will be something
simple, such as there's some field they no longer provide
or don't always provide.

Bill

On Thu, Sep 9, 2010 at 10:26 AM,   wrote:
> ok thanks; I should have mentioned that.
> the view is called when loaded from a browser.
> even with GET or POST method.
> But it is obviously that the error occurs in the wsgi handler
> This is really strange
>
>
>
> On Sep 8, 11:47 pm, Max_  wrote:
>> Hello,
>> I created a website, using the IPN-Function.
>> Everything worked fine at first - the notification view was called and
>> the signal was sent.
>> But now (without any changes on the code), the IPN-Request from PayPAL
>> doesn't call the IPN-view anymore. The Request is logged in the apache
>> access-log but with an internal server error (500) response.
>> (216.113.191.33 - - [08/Sep/2010:14:25:43 +0200] "POST /payPalNotify/
>> HTTP/1.0" 500 25992 "-" "-").
>> Same problem if I set another view (even an empty view) as notifiy-
>> url. It works (the request is logged with a HTTP200 response), if I
>> let PayPAL respond to a php-File. It seems like the wsgi-handler can't
>> handle the PayPAL-Request. The error.log somtimes logs:
>> [Wed Sep 08 16:19:20 2010] [error] [client 216.113.191.33] mod_wsgi
>> (pid=2699): Exception occurred processing WSGI script '/usr/local/
>> django/binner/apache/django.wsgi'.
>> [Wed Sep 08 16:19:20 2010] [error] [client 216.113.191.33] IOError:
>> failed to write data
>> The website is running on a Ubuntu 10.4LTS-Server/Django 1.2.1/wsgi
>> Has anyone else experienced this problem? Any Ideas?
>>
>> WSGI-Handler:
>> import os
>> import sys
>> import django.core.handlers.wsgi
>>
>> os.environ['DJANGO_SETTINGS_MODULE'] = 'binner.settings'
>>
>> sys.path.append('/usr/local/django')
>> sys.path.append('/usr/local/django/binner')
>> sys.path.append('/usr/local/django/binner/templates')
>>
>> application = django.core.handlers.wsgi.WSGIHandler()
>
> you don't say whether you've tried just loading the notification view
> in your browser (simulate PayPals response)
>
> -P
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



facebook comments

2010-09-10 Thread Bobby Roberts
Hi group.  I know this isn't purely a django question, but it is on a
django website and therefore relevant.  I am using the facebook
comment social plug-in.  It is working fine on the site but is not
posting comments over to facebook.  Has anyone ever run into this
before?  Any ideas?

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



Re: Django - Multiple columns primary key

2010-09-10 Thread Russell Keith-Magee
On Fri, Sep 10, 2010 at 7:47 PM, naoy.teruh  wrote:
> Hello,
>
> I would like to implement multicolumns primary keys in django.
...
> Did I miss something ?

Yes - Multicolumn primary keys aren't currently supported in Django.
It's a long-standing feature request, logged as ticket #373.

Yours,
Russ Magee %-)

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



Re: ANN: PyMySQL 0.3

2010-09-10 Thread Andy
On Sep 10, 11:18 am, Andy Dustman  wrote:

> Uh, no.
>
> MySQLdb releases the GIL on any blocking call, so other threads can run.
>
> Django is *not* asynchronous. It's threaded.

The default Django behavior is threaded.

But it can be made to run in async mode, where socket communication
doesn't block. That way one Django thread can serve multiple users
concurrently.

Check out gevent for details.

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



Facebook Comments

2010-09-10 Thread Bobby Roberts
hi i know that this isn't a django related question, but i'm using
Facebook's comment plugin and am having a strange issue.  I've got it
installed and you can post comments fine but they never get uploaded
to facebook.  Is there something you have to do to get them to post
over to facebook (other than checking the box to do so)?  Has anyone
else had this issue?

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



Re: ANN: PyMySQL 0.3

2010-09-10 Thread Andy Dustman
On Sun, Sep 5, 2010 at 12:48 AM, Andy  wrote:
> Thanks Pete.
>
> I'm definitely interested in using PyMySQL for production.
>
> I'm interested in running Django in an async mode using gevent (http://
> www.gevent.org/). gevent provides a money patch that turns any Python
> code into non-blocking. The problem is that MySQLdb is written in C,
> so it'd still block, which would kinda defeat the whole purpose of
> having an async Django app if every database access is blocking.

Uh, no.

MySQLdb releases the GIL on any blocking call, so other threads can run.

Django is *not* asynchronous. It's threaded.
-- 
Question the answers

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



Re: ModelName.objects.none().update() makes changes to db

2010-09-10 Thread bruno desthuilliers


On 10 sep, 11:57, David  wrote:
> if I do
>
> nothing = ModelName.objects.none()
> nothing.update(status='new_status')
>
> Then all of my objects in the database get updated. I would expect
> nothing to happen but... is an empty QuerySet really supposed to apply
> changes like that?

Don't have this behaviour here. Are you sure your ModelName.objects is
the default manager ?


br...@bruno:/var/www/myproject/$ ./manage.py shell
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from reservations.models import *
>>> print "\n".join("%s - %s" % (str(r.id), r.status) for r in 
>>> Reservation.objects.all())
1 - nouveau
2 - nouveau
3 - nouveau
4 - nouveau
5 - nouveau
6 - nouveau
7 - nouveau
8 - nouveau
9 - nouveau
10 - nouveau
11 - nouveau
12 - nouveau
13 - nouveau
14 - nouveau
15 - nouveau
16 - nouveau
17 - nouveau
18 - nouveau
19 - nouveau
20 - nouveau
21 - nouveau
>>> Reservation.objects.none()
[]
>>> Reservation.objects.none().update

>>> Reservation.objects.none().update(status='encours')
0
>>> print "\n".join("%s - %s" % (str(r.id), r.status) for r in 
>>> Reservation.objects.all())
1 - nouveau
2 - nouveau
3 - nouveau
4 - nouveau
5 - nouveau
6 - nouveau
7 - nouveau
8 - nouveau
9 - nouveau
10 - nouveau
11 - nouveau
12 - nouveau
13 - nouveau
14 - nouveau
15 - nouveau
16 - nouveau
17 - nouveau
18 - nouveau
19 - nouveau
20 - nouveau
21 - nouveau
>>>


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



Re: ModelName.objects.none().update() makes changes to db

2010-09-10 Thread bruno desthuilliers


On 10 sep, 11:57, David  wrote:
> if I do
>
> nothing = ModelName.objects.none()
> nothing.update(status='new_status')
>
> Then all of my objects in the database get updated. I would expect
> nothing to happen but... is an empty QuerySet really supposed to apply
> changes like that?

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



Re: Any Django/Python Chat application ??

2010-09-10 Thread hcarvalhoalves
Best thing for chat (or any push applications) is to use something
like Hookbox [1]

They have an example chat application, check it out.

[1] http://hookbox.org/

On Sep 10, 8:26 am, ravi krishna  wrote:
> Hi,
>
> Can somebody tell me some django Chat application which can be used to embed
> inside a Django web application. Both private and group chat should be
> possible. Can u suggest some ??
>
> --
> Regards,
> Rav!

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



Re: How does django convert string to modules

2010-09-10 Thread Bachir
thanks, éthat's really an awesome explanation. thanks

2010/9/10 Tom Evans 

> On Fri, Sep 10, 2010 at 1:05 AM, Bachir  wrote:
> > The problem is not the lack of information, the real problem is that i
> don't
> > know what to search for .
> >
> > 2010/9/9 bruno desthuilliers 
> >>
> >>
> >> On 9 sep, 03:46, maroxe  wrote:
> >> > Hi, I am trying to understand an other magic thing about django: it
> >> > can convert strings to modules. In settings.py, INSTALLED_APPS is
> >> > declared like that:
> >> >
> >> > INSTALLED_APPS = (
> >> > 'django.contrib.auth',
> >> > 'django.contrib.contenttypes',
> >> > 'django.contrib.sessions',
> >> > )
> >> > All it contains is strings. But django will convert those strings to
> >> > modules and import them later.
> >> >
> >> > I want to do be able to do the same thing. but i don't know how.
>
> Well, OK. Lets break down how one could find this out, because you
> *did* have everything you needed to find this out yourself.
>
> You wanted to turn a string into a module name, so you can import from it.
> You noticed that django does the same thing with the setting
> INSTALLED_APPS.
> You have the django source code.
>
> So, the first thing to do is to search the django source code for
> INSTALLED_APPS.
> For this, I tend to use "ack", which is like grep but better for
> programmers.
> This returns lots of files - its used in lots of places. Look at the
> list of files returned and choose one that looks appropriate to look
> at.
>
> I chose "core/management/commands/syncdb.py", as I knew this file is
> responsible for creating db models - its the code that runs when you
> run ./manage.py syncdb.
>
> Looking at how INSTALLED_APPS is used in that file:
>
> >for app_name in settings.INSTALLED_APPS:
> >try:
> >import_module('.management', app_name)
> >except ImportError, exc:
>
> Ah, so theres a function called import_module. Where does that come from?
>
> > from django.utils.importlib import import_module
>
> Ah, so now I know how it does it's import magic, and I know how to
> import it myself. I can now play around with this in the shell, so I
> know I have the usage right:
>
> >>> from django.utils.importlib import import_module
> >>> mod = import_module('math')
> >>> mod.ceil
> 
>
> There, not so hard, is it? You did know what to search for, as you
> included it in your original question..
>
> 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Django - Multiple columns primary key

2010-09-10 Thread naoy.teruh
Hello,

I would like to implement multicolumns primary keys in django.

I've tried to implement an AutoSlugField() which concatenate my
columns values(foreignkey/dates) ...

models.py :

class ProductProduction(models.Model):
enterprise = models.ForeignKey('Enterprise')
product = models.ForeignKey('Product')
date = models.DateTimeField() count = models.IntegerField()
slug = AutoSlugField(populate_from=lambda instance:
instance.enterprise.username + '-' + instance.product.name + '-' +
str(instance.date))

When I pass the following parameters : -
'Megacorp','robot','09/10/2010',5 => slug = 'Megacorp-
robot-09/10/2010' ... the next time in pass the triplet, a new value
has been inserted : - 'Megacorp','robot','09/10/2010',10 => slug =
'Megacorp-robot-09/10/2010' => same slug value => insert 

I tried to add primary_key=True parameter to the slug... but it
creates new instance with a "-1" "-2" ... and NO update is made at
all...

Did I miss something ?

Thanks,

Yoan

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



custom model fields are always "modified" when saving from the admin change form

2010-09-10 Thread Evgeny Sizikov
Hi.

I've wrote a custom model field which splits strings by commas and
returns a list of values. Everything works fine except the admin -
after editing a record admin treats the custom fields as modified even
if they were actually not, issuing an UPDATE query for (not modified)
record and adding a history record.

How could I have that been fixed?

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



ModelName.objects.none().update() makes changes to db

2010-09-10 Thread David
if I do

nothing = ModelName.objects.none()
nothing.update(status='new_status')

Then all of my objects in the database get updated. I would expect
nothing to happen but... is an empty QuerySet really supposed to apply
changes like that?

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



Deleted rows available in a transaction

2010-09-10 Thread Anurag
I am facing a very peculiar problem that even when I delete some rows,
I can just get them back again in same transaction.

Edit:
I have created a sample app to test it out, so that I can be sure that
none of my code is culprit.

I created a testapp with following code

**models.py**

import uuid
from django.db import models

class TestTable(models.Model):
id = models.CharField(max_length=36, primary_key=True)
name = models.CharField(max_length=50)

@classmethod
def get_row(cls, name):
return TestTable(id=str(uuid.uuid4()), name=name)

def __unicode__(self):
return u"%s[%s]"%(self.name, self.id)

**views.py**

import traceback
import time
from django.db import transaction
from django.http import HttpResponse

from testapp.models import TestTable

@transaction.commit_manually
def test_view(request):
time.sleep(1)
out = []
try:
# delete 3 rows
for row in TestTable.objects.all()[:3]:
ID=row.id
out.append("deleting %s"%row)
row.delete()
# check fi really deleted
try:
TestTable.objects.get(id=ID)
out.append("row not deleted?")
except TestTable.DoesNotExist,e:
out.append("row deleted.")

# create 5 rows
for i in range(5):
row = TestTable.get_row("row %s"%i)
row.save()

except Exception,e:
out.append("Error:%s"%traceback.format_exc())
transaction.rollback()
else:
transaction.commit()

return HttpResponse('\n'.join(out), 'text/text'

**urls.py**

from django.conf.urls.defaults import *

urlpatterns = patterns('testapp.views', (r'^test_bug$',
'test_view')

I am running this under apache and mod_wsgi

**TestScript**

import urllib2
from multiprocessing import Process

def get_data():
r = urllib2.urlopen("http://localhost:81/timeapp/test/
test_bug")
print "-"
print r.read()

if __name__ == "__main__":
for i in range(2):
p = Process(target=get_data)
p.start()

**Output:**

$ python test.py
-
deleting row 1[3ad3a82e-830f-4540-8148-88479175ed5e]
row deleted.
deleting row 0[544462d1-8588-4a8c-a809-16a060054479]
row deleted.
deleting row 3[55d422f3-6c39-4c26-943a-1b4db498bf25]
row deleted.
-
deleting row 1[3ad3a82e-830f-4540-8148-88479175ed5e]
row not deleted?
deleting row 0[544462d1-8588-4a8c-a809-16a060054479]
row not deleted?
deleting row 3[55d422f3-6c39-4c26-943a-1b4db498bf25]
row not deleted?

So my question is how come deleted row is again retrievable by
TestTable.objects.get, also even if I sleep more in second call so
that first call can commit code I still get deleted rows in second
call.

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



Re: Please wait page trouble

2010-09-10 Thread Alec Shaner
Excellent. Glad you got it working.

On Fri, Sep 10, 2010 at 8:54 AM, Bradley Hintze  wrote:

> I got to work! I needed a good nights sleep to see it. the url was
> '/DHM_run/' NOT '/run_DHM/'.
>
> Thanks Alec
>
>

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



Re: Please wait page trouble

2010-09-10 Thread Bradley Hintze
I got to work! I needed a good nights sleep to see it. the url was
'/DHM_run/' NOT '/run_DHM/'.

Thanks Alec

On Thu, Sep 9, 2010 at 4:20 PM, Bradley Hintze
 wrote:
> Ok, cant quite get it. Here is what I have:
>
> please_wait.html
> ...
>  src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js";>
> 
>  $.get({{ calculation_url }}, function(data) {
>    if (data == 'OK') {
>        window.location.href = {{ view_url }};
>    }
>    else {
>       alert(data);
>    }
>    });
> 
> ...
>
> url.py
> url(r'^DHM_run_start/$', please_wait, kwargs={'calculation_url':
> '/run_DHM/', 'view_url':'/DHM_display/'}, name='run_DHM_start'),
> url(r'^analyze_start/$', please_wait, kwargs={'calculation_url':
> '/analyze_compare/', 'view_url':'/results_display/'},
> name='analyze_start'),
>
> view.py
> ...
> def please_wait(request, calculation_url, view_url):
>    c = {'calculation_url': calculation_url, 'view_url': view_url}
>    return render_to_response('please_wait.html', c,
> context_instance=RequestContext(request))
>
> def run_DHM(request):
>    #run calculations
>    return HttpResponse('OK')
>
>
> def analyze_compare(request):
>    #run calculations
>    return HttpResponse('OK')
> ...
>
> I could have run_DHM and analyze_compare return views rather than the
> HTTPResponse "OK" as you indicated but was unsure how to change the
> javascript to make it work. This seems like it should work but I just
> get the "please_wait" page indefinitely. Seems as if its not calling
> {{ calculation_url }}.
>
> Any ideas or elaborations (hold my hand) on JSON would be great.
>
> Thanks,
> Bradley
>
> On Thu, Sep 9, 2010 at 12:44 PM, Alec Shaner  wrote:
>> A lot of ways to do this. Yes you could do it as above, but that can get
>> ugly as you start adding more views. You can indeed access the context
>> dictionary in please_wait.html. It's hard to say without knowing more
>> details about your application. How does the user pass arguments (if any)
>> used in these calculations? If you're looking for a simple way to abstract
>> this process, consider using URL confs:
>>
>> # Create a url specific to the DHM calulcation
>> url(r'^DHM_run_start/$', please_wait, kwargs={'calculation_url': 'run_DHM'},
>> name='run_DHM_start'),
>>
>> and you'd call it like /DHM_run_start/
>>
>> or
>>
>> # Create a URL with a regex pattern to capture a calculation_url
>> url(r'^please_wait/(?P[\d\w]+)/$', please_wait),
>>
>> and you'd call it like /please_wait/run_DHM/
>>
>> The second option is more generic, but you'll need to validate the url
>> argument. The first option means adding more url entries. In either case
>> your please_wait view would be defined like:
>>
>> def please_wait(request, calculation_url):
>>     return render_to_response('please_wait.html', {'calculation_url':
>> calculation_url}, ...)
>>
>> please_wait.html could then substitute the {{ calculation_url }} context
>> variable as the argument to the {% url %} tag.
>>
>> Your run_DHM view could now return the url to redirect to instead of just
>> 'OK'. You'll have to return the full URL, e.g., '/display_DHM/', from your
>> run_DHM view. This is probably where you'd start thinking about a JSON
>> response as you might return a dictionary with an result code ('OK' or
>> 'error') along with a url to redirect the user to.
>>
>> window.location.href = data;
>>
>> Or if you've switched to a JSON response it might be data.display_url after
>> checking that data.result = 'OK'.
>>
>> Hope that all makes sense.
>>
>> On Thu, Sep 9, 2010 at 12:00 PM, Bradley Hintze
>>  wrote:
>>>
>>> OK,
>>>
>>> Got it working. Sorry one more question. I have a couple of places
>>> where I'd like to display the 'Please Wait' page. I'd imagine I'd do
>>> something similar to the following::
>>>
>>> # please_wait.html
>>> ...
>>> >>
>>> src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js";>
>>> 
>>>    if (If_come_from_pageA) {
>>>        $.get('{% url run_DHM %}', function(data) {
>>>            if (data == 'OK') {
>>>                  window.location.href = '{% url display_DHM %}';
>>>            } else {
>>>                  alert(data);
>>>            }
>>>    }
>>>    else if (If_come_from_pageB) {
>>>        $.get('{% url run_analysis %}', function(data) {
>>>            if (data == 'OK') {
>>>                  window.location.href = '{% url display_analysis %}';
>>>            } else {
>>>                  alert(data);
>>>            }
>>>    }
>>>    });
>>> 
>>>
>>> an of course configure url.py and view.py as explained previously. Is
>>> there an easy way to do this? In other words, what are the
>>> If_come_from_pageA and If_come_from_pageB conditions? Can I access the
>>> context dictionary that I passed to please_wait.html?
>>>
>>> On Thu, Sep 9, 2010 at 11:23 AM, Bradley Hintze
>>>  wrote:

Any Django/Python Chat application ??

2010-09-10 Thread ravi krishna
Hi,

Can somebody tell me some django Chat application which can be used to embed
inside a Django web application. Both private and group chat should be
possible. Can u suggest some ??

-- 
Regards,
Rav!

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



Re: 404 handler not working on live hosting environment

2010-09-10 Thread Sithembewena Lloyd Dube
:) If I had my way, we'd be using Linux for dev. The design guys need
Windows for all the Adobe software (although technically, there's
VirtualBox, Wine et al).

On Fri, Sep 10, 2010 at 10:55 AM, Kenneth Gonsalves wrote:

> On Fri, 2010-09-10 at 09:55 +0200, Sithembewena Lloyd Dube wrote:
> > Thanks Kenneth, we were also discussing yesterday how we need to have
> > a
> > "safer" deployment strategy.
> >
> > We are using TortoiseSVN for version Control.
>
> you could look into upgrading from windows also ;-)
> --
> regards
> Kenneth Gonsalves
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

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



Re: How does django convert string to modules

2010-09-10 Thread Tom Evans
On Fri, Sep 10, 2010 at 1:05 AM, Bachir  wrote:
> The problem is not the lack of information, the real problem is that i don't
> know what to search for .
>
> 2010/9/9 bruno desthuilliers 
>>
>>
>> On 9 sep, 03:46, maroxe  wrote:
>> > Hi, I am trying to understand an other magic thing about django: it
>> > can convert strings to modules. In settings.py, INSTALLED_APPS is
>> > declared like that:
>> >
>> > INSTALLED_APPS = (
>> >     'django.contrib.auth',
>> >     'django.contrib.contenttypes',
>> >     'django.contrib.sessions',
>> > )
>> > All it contains is strings. But django will convert those strings to
>> > modules and import them later.
>> >
>> > I want to do be able to do the same thing. but i don't know how.

Well, OK. Lets break down how one could find this out, because you
*did* have everything you needed to find this out yourself.

You wanted to turn a string into a module name, so you can import from it.
You noticed that django does the same thing with the setting INSTALLED_APPS.
You have the django source code.

So, the first thing to do is to search the django source code for
INSTALLED_APPS.
For this, I tend to use "ack", which is like grep but better for programmers.
This returns lots of files - its used in lots of places. Look at the
list of files returned and choose one that looks appropriate to look
at.

I chose "core/management/commands/syncdb.py", as I knew this file is
responsible for creating db models - its the code that runs when you
run ./manage.py syncdb.

Looking at how INSTALLED_APPS is used in that file:

>for app_name in settings.INSTALLED_APPS:
>try:
>import_module('.management', app_name)
>except ImportError, exc:

Ah, so theres a function called import_module. Where does that come from?

> from django.utils.importlib import import_module

Ah, so now I know how it does it's import magic, and I know how to
import it myself. I can now play around with this in the shell, so I
know I have the usage right:

>>> from django.utils.importlib import import_module
>>> mod = import_module('math')
>>> mod.ceil


There, not so hard, is it? You did know what to search for, as you
included it in your original question..

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



Re: 404 handler not working on live hosting environment

2010-09-10 Thread Kenneth Gonsalves
On Fri, 2010-09-10 at 09:55 +0200, Sithembewena Lloyd Dube wrote:
> Thanks Kenneth, we were also discussing yesterday how we need to have
> a
> "safer" deployment strategy.
> 
> We are using TortoiseSVN for version Control. 

you could look into upgrading from windows also ;-)
-- 
regards
Kenneth Gonsalves

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



Re: 404 handler not working on live hosting environment

2010-09-10 Thread Sithembewena Lloyd Dube
Thanks Kenneth, we were also discussing yesterday how we need to have a
"safer" deployment strategy.

We are using TortoiseSVN for version Control.

On Fri, Sep 10, 2010 at 4:31 AM, Kenneth Gonsalves wrote:

> On Thu, 2010-09-09 at 14:31 +0200, Sithembewena Lloyd Dube wrote:
> > Yes, both the Django and Python versions on dev and prod match. We are
> > running Django 1.2.1. and Python 2.6.5.
> >
> > On our dev server, we use Django's server instead of Apache.
> >
> >
>
> actually to avoid problems like this in production you should use a
> 3-stage deployment:
>
> 1. develop with runserver
> 2. have a staging server (maybe on the same devel machine) which tries
> to replicate the production environment
> 3. then move the code/changes to the production server.
>
> (I hope you are using some VCS?)
> --
> regards
> Kenneth Gonsalves
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

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



Re: Returning an inclusion tagLLKKJJ

2010-09-10 Thread bruno desthuilliers
on 10 sep, 01:06, maroxe  wrote:
> Hi, I am suffering whereever i try to do something in django that is
> not common(in django, not in python in general)
>
> For example, i don't know how to return an inclusion tag. This.
> obviously, won't work:
>
> @register.inclusion_tag('template.tpl')
> def myinclusiontag(parameter):
>     return {'var': parameter.attr1}
>
> @register.inclusion_tag('template2.tpl')
> def myinclusiontag2(parameter):
>     return {'var': parameter.attr2}
>
> @register.simple_tag
> def mysimpletag(paramter):
>     if parameter.attr: return myinclusiontag(parameter)
>     else: return myinclusiontag2(paramter)
>
> mysimpletag return a dict(first returned by the inclusion tag),

s/the inclusion tag/the function used to build the inclusion tag/

Reading the source code helps once again: register.inclusion_tag
dynamically build the appropriate Node object and compiler function,
calls register.tag with these, and returns the original function
unchanged.

There's surely a way to hack around this, but at this point I strongly
suggest you learn to write a proper custom tag (Node and compiler
func). It's by far easier than it seems at first and it's really
something every Django developper should learn.

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