message_set filter

2013-08-16 Thread Karl Arunachal
Hello,
I have a model for messaging between the users.

models.py:

class Message(models.Model):
description = models.TextField()
date_added = models.DateTimeField(default=datetime.now)
sender = models.ForeignKey(User, related_name='sent_set')
recipient = models.ForeignKey(User, related_name='recieved_set')

def __unicode__(self):
return "%s sent message: %s to %s" % (self.sender,
self.description, self.recipient)

def save(self, **kwargs):
if self.sender == self.recipient:
raise ValueError("Cannot message yourself")
super(Message, self).save(**kwargs)



Till now I get all the messages (sent/recieved) of a particular user,

from django.db.models import Q

A = request.usermsg = Message.objects.filter(Q(sender=A)|Q(recipient=A))



Suppose, msg has all the messages sent and recieved for user 'A'. Now how
would i filter from this 'msg',  all the message sent to and recieved from
a particular user 'B'.

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


Re: Django Periodic tasks

2013-08-16 Thread Brian Schott
Also, load the page with a busy animated gif and use something like dajaxice to 
fetch and replace the computed value.  Several examples and libraries out ther.

—
Sent from Mailbox for iPad

On Fri, Aug 16, 2013 at 11:22 PM, Some Developer
 wrote:

> On 17/08/13 03:43, Christophe Pettus wrote:
>>
>> On Aug 16, 2013, at 7:36 PM, Some Developer wrote:
>>
>>> Alternately I could get rid of the hourly period task and just work it out 
>>> when a customer visits a certain page but that is likely to lead to long 
>>> load times and heavy database use.
>>>
>>> Any suggestions on what you would do in this situation?
>>
>> Calculate the value on demand, and cache it with an expiration time, most 
>> likely.
>>
>> --
>> -- Christophe Pettus
>> x...@thebuild.com
>>
> Good plan. Thanks.
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.

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


Re: Django Periodic tasks

2013-08-16 Thread Some Developer

On 17/08/13 03:43, Christophe Pettus wrote:


On Aug 16, 2013, at 7:36 PM, Some Developer wrote:


Alternately I could get rid of the hourly period task and just work it out when 
a customer visits a certain page but that is likely to lead to long load times 
and heavy database use.

Any suggestions on what you would do in this situation?


Calculate the value on demand, and cache it with an expiration time, most 
likely.

--
-- Christophe Pettus
x...@thebuild.com



Good plan. Thanks.

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


Re: Greyed out models in Django Admin

2013-08-16 Thread Mike Dewhirst

On 16/08/2013 3:37pm, huw_at1 wrote:

Hi,

I still have this issue and can't really figure out what the problem is.
I have found that if I turn on DEBUG then the apps models become active
again such that I can add new records via the admin interface. However
when turning off DEBUG they become inactive and greyed out again.


I don't think I have ever seen models disabled or greyed out in the 
admin. I wonder how that might be achieved? Maybe there is a read 
attribute which can be negated?


I googled disabled model in the admin and that seemed to bring up 
permissions but I can't think how a DEBUG setting might be involved.


It isn't clear to me where you are switching DEBUG on and off; 
production and/or development. Are you operating as superuser in both?


What web server are you using in production?

It seems like an interest problem. If you solve it please post the answer.



I have tried altering the order in which my apps are loaded and also
altered the permissions on the applications folder however nothing seems
to solve this.

Sorry for the BUMP but does anyone have any further info on this?

Many thanks

Huw Jones

On Thursday, 31 January 2013 22:56:05 UTC, huw_at1 wrote:

Hi,

Using Django 1.4, have registered 3 model classes with admin. When
accessing admin page provided by test server can select each class
and edit entries. However when accessing production admin the
classes are greyed out, only the users, groups and sites are
selectable. I thought this might be database access issues however I
can run syncdb without any problems. Any ideas?

Many thanks

Huw Jones.

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


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


Re: Django Periodic tasks

2013-08-16 Thread Christophe Pettus

On Aug 16, 2013, at 7:36 PM, Some Developer wrote:

> Alternately I could get rid of the hourly period task and just work it out 
> when a customer visits a certain page but that is likely to lead to long load 
> times and heavy database use.
> 
> Any suggestions on what you would do in this situation?

Calculate the value on demand, and cache it with an expiration time, most 
likely.

--
-- Christophe Pettus
   x...@thebuild.com

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


Django Periodic tasks

2013-08-16 Thread Some Developer
I'm aware of django-cron and django-celery, both of which are capable of 
doing what I want but I was wondering if I was just making a fundamental 
design mistake and there maybe a better option that someone here could 
explain.


Basically customers pay money into their account in advance so that they 
can use services that we offer. Each service is charged by the minute 
and prices between services can vary wildly. I need to be able to show 
our clients their current running total to the nearest hour so that they 
know when they need to add extra funds to their account.


My initial thought was that I would just have the equivalent of a cron 
job running every hour that queries the database for the state of each 
users application and then used that to produce an estimate for their 
current billing.


Alternately I could get rid of the hourly period task and just work it 
out when a customer visits a certain page but that is likely to lead to 
long load times and heavy database use.


Any suggestions on what you would do in this situation?

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


Re: Can't seem to get "votes" to work right

2013-08-16 Thread bud
Ah, its always the details. Gotta pay attention to those.

Thanks, it works now!

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


Re: Django 1.5 Feature Suggestion

2013-08-16 Thread JJ Zolper
I didn't want to clutter up the ticket that much so I thought we could 
discuss through here. Do you think the following package:

https://github.com/Liberationtech/django-libtech-emailuser

Could be used to merge in a solution to the django core for this?

It sounds like when this package was created it was fairly simple to 
"rename" the necessary parts so that it would operate as desired. Maybe 
this package could be reviewed, and moved into the contrib app like you 
said?

Thanks,

JJ

On Monday, July 29, 2013 9:07:43 PM UTC-4, Russell Keith-Magee wrote:
>
>
> On Tue, Jul 30, 2013 at 8:37 AM, JJ Zolper  > wrote:
>
>> Russell Keith-Magee,
>>
>> Are you the one who is doing "Getting Started With Django" ? Sorry for 
>> getting off topic but just was curious. If so I donated money to that 
>> project and I am glad you are doing it.
>>
>
> Sorry, that's not me. You're thinking of Kenneth Love (@kennethlove on 
> twitter).
>  
>
>> Yes, that's what it seems to be called by other Django devs, "Email 
>> address as username." I prefer more to think of it as just "Email" with the 
>> same exact login handlign as "Username." That's my goal with this post is 
>> keep pushing until the point is reached where we can just call it "Email" 
>> login. I also think it is such a common case that it should be within 
>> Django's core. It is obvious from the large number of posts online about 
>> replacing the username with an email. 
>>
>
> A lot of those posts will be from pre-1.5 days; having the ability to 
> easily use an email address as a username was one of the primary 
> motivations behind introducing swappable users as a new feature. It was 
> always possible; in Django 1.5, it's a lot easier; the next step is to make 
> it trivial by having a custom user model for that purpose available in the 
> box.
>
> If you have heard Jacob discussing it before, that would be wonderful! It 
>> would be awesome if the Django guys accepted this into Django all together. 
>> Given it must be considered with the release of Django 1.5 they did give a 
>> lot more support to people like me trying to have the email as the username 
>> through things like:
>>
>> class CustomUser(AbstractBaseUser, PermissionsMixin):
>>  
>>  email = models.EmailField(max_length=255, unique=True)
>>  
>>
>>  objects = CustomUserManager()
>>
>>  USERNAME_FIELD = 'email'
>>
>>
>> So maybe Jacob and Adrian are already on top of this. 
>>
>
> Jacob and Adrian are only "on top of it" in the sense that Jacob has said 
> it's a good idea. I wouldn't hang around waiting for either of them to 
> commit such a patch -- they're both busy, and don't spend a lot of time 
> committing to Django itself these days. 
>  
>
>> The only thing I have been trying to do is follow the suggestions of 
>> those posts I have found online. I could surely route some possible people 
>> I think might have already banged this out but I'm not sure I'm the best 
>> bet. However, I did go ahead and open a ticket:
>>
>> https://code.djangoproject.com/ticket/20824
>>
>> Thanks again to all the Django developers for their hard work,
>>
>
> Thanks for opening a ticket and driving the discussion. I've added some 
> comments to the ticket and marked it as accepted; next step is a patch :-)
>
> Yours,
> Russ Magee %-)
>
>

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


Re: Can't seem to get "votes" to work right

2013-08-16 Thread Daniel Roseman
On Friday, 16 August 2013 21:05:46 UTC+1, bud wrote:

>
> but now an error page came up when I tried to vote for one of the polls:
>
> Environment:
>
>
> Request Method: POST
> Request URL: http://127.0.0.1:8000/polls/1/vote/
>
> Django Version: 1.5.1
> Python Version: 2.7.3
> Installed Applications:
> ('django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'django.contrib.messages',
>  'django.contrib.staticfiles',
>  'django.contrib.admin',
>  'polls')
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.middleware.csrf.CsrfViewMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.contrib.messages.middleware.MessageMiddleware')
>
>
> Traceback:
> File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" 
> in get_response
>   115. response = callback(request, 
> *callback_args, **callback_kwargs)
> File 
> "/home/bud/.local/lib/python2.7/site-packages/django_polls-0.1-py2.7.egg/polls/views.py"
>  
> in vote
>   56. return HttpResponseRedirect(reverse('polls:results', args=(
> p.id)))
> File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" 
> in reverse
>   496. return iri_to_uri(resolver._reverse_with_prefix(view, prefix, 
> *args, **kwargs))
>
> Exception Type: TypeError at /polls/1/vote/
> Exception Value: _reverse_with_prefix() argument after * must be a 
> sequence, not int
>
>
That's a Python error: (p.id) is not a tuple, you need a comma: (p.id,)
--
DR.

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


Re: Can't seem to get "votes" to work right

2013-08-16 Thread bud
I've made some changes to 
*
detail.html*
 

> {{ poll.question }}
>
> {% if error_message %}{{ error_message }}{% endif 
> %}
> 
> {% csrf_token %}
> {% for choice in poll.choice_set.all %}
> 
> {{ choice.choice_text 
> }}
> {% endfor %}
> 
>

>

but now an error page came up when I tried to vote for one of the polls:

Environment:


Request Method: POST
Request URL: http://127.0.0.1:8000/polls/1/vote/

Django Version: 1.5.1
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'polls')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" 
in get_response
  115. response = callback(request, *callback_args, 
**callback_kwargs)
File 
"/home/bud/.local/lib/python2.7/site-packages/django_polls-0.1-py2.7.egg/polls/views.py"
 
in vote
  56. return HttpResponseRedirect(reverse('polls:results', 
args=(p.id)))
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" 
in reverse
  496. return iri_to_uri(resolver._reverse_with_prefix(view, prefix, 
*args, **kwargs))

Exception Type: TypeError at /polls/1/vote/
Exception Value: _reverse_with_prefix() argument after * must be a 
sequence, not int

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


Re: Can't seem to get "votes" to work right

2013-08-16 Thread Daniel Roseman
On Friday, 16 August 2013 16:40:24 UTC+1, bud wrote:

> Hi,
>
> I've finished the Django tutorial but I just can't seem to get my "votes" 
> function to work right. I would start the server, go to polls, and every 
> time I try to vote for something, the KeyError message comes up i.e. "You 
> didn't select a choice." when I did. Maybe if there was some way to define 
> these choices it might fix it, but I'm not sure.
>
 

> 
> and *detail.html*
>
> {{ poll.question }}
>
> {% if error_message %}{{ error_message }}{% endif 
> %}
> 
> {% csrf_token %}
> {% for choice in poll.choice_set.all %}
> 
> {{ choice.choice_text 
> }}
> {% endfor %}
> 
> 
>
> Any ideas?
>


The problem is in your template, where you define the choice field. You've 
added {{ forloop.counter }} to the name of the field, which means that 
there's no key "choice" in the POST data: there's only "choice1", "choice2" 
etc. Each button in the radio input needs to have the same name, although 
they obviously have different values.
--
DR.

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


Re: RequestContext and request.user

2013-08-16 Thread Lucas Magnum
Robin,
RequestContext, includes TEMPLATE_CONTEXT_PROCESSORS results.
request is a result of "django.core.context_processors.request".

https://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-context-requestcontext

[]'s

Lucas Magnum.


2013/8/16 Robin Lery 

> Hello,
> I am all confused about these two things:
> context_instance = RequestContext and request.user
>
> Are they both equal? I suppose RequestContext includes a user varialble
> from the given template. And request.user would also give the current
> user's info, i guess. Can someone please give me insight about these two.
> Thank you.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

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


Get size of cached item?

2013-08-16 Thread Roy Smith
I'm trying to log some statistics on the sizes of objects I store in memcache, 
for a specific set of keys.  What I'm doing now is pickling the data in my 
application code, and logging len() of the picked string.  This is wasteful 
because the cache machinery is just going to do the pickling all over again.  
Is there any way to find out how much memory each object I store is going to 
use without this extra overhead?

---
Roy Smith
r...@panix.com

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


RequestContext and request.user

2013-08-16 Thread Robin Lery
Hello,
I am all confused about these two things:
context_instance = RequestContext and request.user

Are they both equal? I suppose RequestContext includes a user varialble
from the given template. And request.user would also give the current
user's info, i guess. Can someone please give me insight about these two.
Thank you.

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


Can't seem to get "votes" to work right

2013-08-16 Thread bud
Hi,

I've finished the Django tutorial but I just can't seem to get my "votes" 
function to work right. I would start the server, go to polls, and every 
time I try to vote for something, the KeyError message comes up i.e. "You 
didn't select a choice." when I did. Maybe if there was some way to define 
these choices it might fix it, but I'm not sure.
Here's my* 

views.py*:

from django.http import HttpResponseRedirect
from django.shortcuts import render, get_object_or_404
from django.core.urlresolvers import reverse
from django.views import generic
from django.utils import timezone

from polls.models import Poll, Choice

class IndexView(generic.ListView):
template_name = 'polls/index.html'
context_object_name = 'latest_poll_list'

def get_queryset(self):
"""
Return the last five published polls (not including those set to be
published in the future).
"""
return Poll.objects.filter(
pub_date__lte=timezone.now()
).order_by('-pub_date')[:5]

class DetailView(generic.DetailView):
model = Poll
template_name = 'polls/detail.html'

def get_queryset(self):
"""
Excludes any polls that aren't published yet.
"""
return Poll.objects.filter(pub_date__lte=timezone.now())

class ResultsView(generic.DetailView):
model = Poll
template_name = 'polls/results.html'

def vote(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id)
try:
selected_choice = p.choice_set.get(pk=request.POST['choice'])
except (KeyError, Choice.DoesNotExist):
# Redisplay the poll voting form.
return render(request, 'polls/detail.html', {
'poll': p,
'error_message': "You didn't select a choice",
})
else:
selected_choice.votes +=1
selected_choice.save()
# Always return an HttpResponseRedirect after successfully dealing
# with POST data. This prevents data from being posted twice if a
# user hits the Back button.
return HttpResponseRedirect(reverse('polls:results', args=(p.id)))

*models.py *:

from django.db import models
import datetime
from django.utils import timezone

class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')

def __unicode__(self):
return self.question

def was_published_recently(self):
now = timezone.now()
return now - datetime.timedelta(days=1) <= self.pub_date < now
# return self.pub_date >= timezone.now() - 
datetime.timedelta(days=1)
was_published_recently.admin_order_field = 'pub_date'
was_published_recently.boolean = True
was_published_recently.short_description = 'Published recently?'

class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)

def __unicode__(self):
return self.choice_text

 */polls/urls.py *:

from django.conf.urls import patterns, url

from polls import views

urlpatterns = patterns('',
url(r'^$', views.IndexView.as_view(), name='index'),
url(r'^(?P\d+)/$', views.DetailView.as_view(), name='detail'),
url(r'^(?P\d+)/results/$', views.ResultsView.as_view(), 
name='results'),
url(r'^(?P\d+)/vote/$', views.vote, name='vote'),
)

and *detail.html*

{{ poll.question }}

{% if error_message %}{{ error_message }}{% endif %}

{% csrf_token %}
{% for choice in poll.choice_set.all %}

{{ choice.choice_text 
}}
{% endfor %}



Any ideas?

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


Re: My poll doesn't work when I start using related_name, help please.

2013-08-16 Thread Daniel Roseman
On Friday, 16 August 2013 14:06:38 UTC+1, Pepsodent Cola wrote:

> ### PART A
>
> My altword_list template file receives a primary key ID from my Index 
> template file.
>
> #___
> *altword_list.html*
>
> {{ poll.rosword }}
> {% if error_message %}{{ error_message }}{% endif 
> %}
>
> Filter 5
> 
> *{% for choice in poll.altword_set.all %}*
> 
> *{{ choice.rosword }}*  = {{ choice.votes }} votes
> {% endfor %}
> 
>
> #___
>
>
>
> ### PART B
>
> * Things work as intended when the rosword field just contain a simple 
> "FK(Word)".
> * But when I use the other rosword field instead containing "FK(Word, 
> related_name='altword_rosword')", then
>   my altword_list template file doesn't receive a primary key ID from my 
> Index template file anymore.
>
> What am I doing wrong when using related_name in my rosword field?
>
> #___
>
> class Altword(models.Model):
> #rosword = models.ForeignKey(Word, related_name='altword_rosword') *# 
> altword_list.html doesn't receive pk ID anymore why?*
> *rosword = models.ForeignKey(Word) # OK*
> alt_ros_word = models.CharField(max_length=200)
> #wordy = models.OneToOneField(Word, related_name='wordy', 
> primary_key=True)
> votes = models.IntegerField(default=0)
>
> def __unicode__(self):
> return self.alt_ros_word
>
> #___
>
>
I have no idea what "primary key ID" has to do with anything. However, if 
you've changed the related name in the field, you should change it in the 
template as well:

  {% for choice in poll.altword_rosword.all %}
--
DR.

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


Re: As a New Bee

2013-08-16 Thread Apokalyptica Painkiller
Hello Sujeet try this IDE: http://ninja-ide.org/

I hope you like it!


2013/8/16 Sujeet Buddiga 

> Hi Djano'ans,
>Im a new bee to Django and would like to work with an
> IDE. Please suggest proper tutorials with IDE that can make my learning
> process simpler,easire and faster.
>
> *Please Dont mind if my English is not good.
>
>
>
> Thanks in Advance,
> Sujeet
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
I live each day
Like it's my last
I live for rock and roll
I never look back

I'm a rocker
Do as I feel as I say
I'm a rocker
And no one can take that away

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


As a New Bee

2013-08-16 Thread Sujeet Buddiga
Hi Djano'ans,
   Im a new bee to Django and would like to work with an
IDE. Please suggest proper tutorials with IDE that can make my learning
process simpler,easire and faster.

*Please Dont mind if my English is not good.



Thanks in Advance,
Sujeet

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


Overriding admin/actions.html

2013-08-16 Thread Chris Stoyles
Hi All,

I've been hunting around (without luck) for a way to override the 
admin/actions.html template in my app.

I've tried overriding it globally in templates/admin as well as app 
specific in [app]/templates/admin. If anyone out there can give me a quick 
hint on where to look or what I'm doing wrong that would be greatly 
appreciated. I figure that I'm going to need to override a method in my 
model admin class or potentially in one of the other templates that I've 
overridden (e.g. change_list.html and change_list_results.html).

Thanks in advance!
Chris.

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


My poll doesn't work when I start using related_name, help please.

2013-08-16 Thread Pepsodent Cola
### PART A

My altword_list template file receives a primary key ID from my Index 
template file.
#___
*altword_list.html*

{{ poll.rosword }}
{% if error_message %}{{ error_message }}{% endif %}

Filter 5

*{% for choice in poll.altword_set.all %}*

*{{ choice.rosword }}*  = {{ choice.votes }} votes
{% endfor %}

#___



### PART B

* Things work as intended when the rosword field just contain a simple 
"FK(Word)".
* But when I use the other rosword field instead containing "FK(Word, 
related_name='altword_rosword')", then
  my altword_list template file doesn't receive a primary key ID from my 
Index template file anymore.

What am I doing wrong when using related_name in my rosword field?
#___

class Altword(models.Model):
#rosword = models.ForeignKey(Word, related_name='altword_rosword') *# 
altword_list.html doesn't receive pk ID anymore why?*
*rosword = models.ForeignKey(Word) # OK*
alt_ros_word = models.CharField(max_length=200)
#wordy = models.OneToOneField(Word, related_name='wordy', 
primary_key=True)
votes = models.IntegerField(default=0)

def __unicode__(self):
return self.alt_ros_word
#___

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


How to store an object in django sessions framework

2013-08-16 Thread shiva krishna
I have an django and i am trying to store an object in django session 
varaible, and trying to access that in the redirected view, but its showing 
`keyerror`  as below

def payment(request):
if request.method == 'POST':
form = CardForm(request.POST)
if form.is_valid():
data = form.cleaned_data
response = response_from_payment_gateway(data)
request.session['response'] = response
return 
HttpResponseRedirect(reverse('paygate:payment_success'))
else:
form = CardForm(initial={'number':'4242424242424242'})
return render_to_response('payment_form.html',{'form': form})


def PaymentSuccess(request):
print request.session['response'],"=>"
response = None
return render_to_response("payment_success.html", 
{'response':response}, context_instance=RequestContext(request))


**Result**

Internal Server Error: /payment/success/
Traceback (most recent call last):
  File 
"/home/Envs/app/local/lib/python2.7/site-packages/django/core/handlers/base.py",
 
line 115, in get_response
response = callback(request, *callback_args, **callback_kwargs)
  File "/home/user/virtualenvironment/apps/app/payment/views.py", line 
120, in PaymentSuccess
print request.session['response'],"=>"
  File 
"/home/Envs/app/local/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py",
 
line 46, in __getitem__
return self._session[key]
KeyError: 'response'


So i am getting back a response object from the payment gateway that 
contains the transaction details, and i am trying to save that in `session 
framework variable` called `response` as above.

And i am trying to access the variable called `response` in the redirected 
view `PaymentSuccess` as `request.session['response']`, and getting the 
above mentioned error.

so how can we send/save the objects in the `sessions` in django ?

In above the response object will be of the following form 

{'status': 'SUCCESS', 'response':  JSON: {
  "amount": 100, 
  "amount_refunded": 0, 
  "balance_transaction": "txxxn_O", 
  "captured": true, 
 "currency": "usd", 
  "customer": null, 
  "description": null, 
}}

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