Re: RemoteUserBackend not creating user

2012-02-20 Thread Babatunde Akinyanmi
I'm not too sure what you are trying to do but there's no part of your
code that tries to create a user.

Maybe you should give more information

On 2/21/12, Roberto Bouza  wrote:
> Hello,
>
> I've been hitting my head pretty hard trying to figure out what the
> problem is hope someone here can help.
>
> I've set up the remote backends and middleware as per the docs and
> blatantly I'm coding the META remote_user and nothing happens. like
> this:
>
> MIDDLEWARE_CLASSES = (
> 'django.middleware.common.CommonMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.auth.middleware.RemoteUserMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> )
>
> AUTHENTICATION_BACKENDS = (
> 'django.contrib.auth.backends.RemoteUserBackend',
> )
>
> Then on my view:
>
> def login_(request):
> request.META['REMOTE_USER'] = 'test123'
> try:
> user = User.objects.get(username=request.META['REMOTE_USER'])
> logger.debug("got user: %s, %s", user.last_name,
> user.first_name)
> except ObjectDoesNotExist:
> logger.debug("username: %s, does not exist",
> request.META['REMOTE_USER'])
>
> return render_to_response('myapp/dashboard.html',
> {'section':'dashboard'}, context_instance=RequestContext(request))
>
> All goes as planned, but the user is not being created. Am I missing
> something here?
>
> Thank you!!!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-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.
>
>

-- 
Sent from my mobile device

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



Re: handling multiple parallel request

2012-02-20 Thread Derek
On Feb 20, 11:32 pm, "rafiee.nima"  wrote:
> tnx alot
> but actually my scenario dose not deal with user so I thing cookies do
> not help a lot
> suppose there are 3 airline counter which fill ticket forms and send
> them to the cashier maybe  simultaneously  .forms are sent to the
> cashier which is just a function in my view ,,I want to know how I can
> handle these simultaneous request ..I also should be concern about
> power failure ( actually  It is important not to miss queued request
> if there is any queue  )

If you genuinely need to queue requests for processing at some later
point, you probably need to use Celery:
http://celeryproject.org/
or, for a useful overview:
http://ericholscher.com/blog/2010/jun/23/large-problems-django-mostly-solved-delayed-execut/

(Note: there are really no such things as "simultaneous requests" as
far as the backend is concerned; things always arrive in an order,
even if there are just milliseconds between them.  If it is in
important to know *when* they were sent by the user, then possibly
consider using Javascript in the browser to "time stamp" them... but
bear in mind that local time accuracy may vary significantly between
different systems.)

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



Re: doubt in the tutorial

2012-02-20 Thread kalyani ram
I will tell you what, You are just awesome :) Thanks a million. I was
so worried :)
As you told i tried all the way and only then posted. I ll take care
of indentation from now on :)
Thanks again.

On Feb 20, 5:20 pm, akaariai  wrote:
> Check the indentation of __unicode__ method (and other methods too)...
>
>  - Anssi
>
> On Feb 20, 1:50 pm, kalyani ram  wrote:
>
>
>
>
>
>
>
> > hey all,
>
> > I am learning the db connectivity using this 
> > tutorialhttps://docs.djangoproject.com/en/dev/intro/tutorial01/
> > Now, i followed every single step and yet, when i give
> > Polls.objects.all() is gives the output as 
> > But then it should be returning the fields right? I checked the db
> > also. I has records. I have not used __Str__ i ve used unicode.
> > Where i have gone wrong. When i execute i get empty fields :(
>
> > my models.py is as follows:
>
> > from django.db import models
> > import datetime
> > # Create your models here.
> > 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_today(self):
> >         return self.pub_date.date() == datetime.date.today()
>
> > class Choice(models.Model):
> >     poll = models.ForeignKey(Poll)
> >     choice = models.CharField(max_length=200)
> >     votes = models.IntegerField()
>
> > def __unicode__(self):
> >         return self.choice

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



Re: doubt in the tutorial

2012-02-20 Thread kalyani ram
did u try this by any chance?? I found the way out, but it doesn
return what i want.
When is give Poll.objects.all() it is equivalent to SELECT * from
Poll; and for me it returns 

in your case, poll  is an object ryt? now wer is the attribute?
print [e.question for e in Poll.objects.all()] = SELECT question from
Poll; and this works perfect for me.

I already tried your way and only then posted :/ Help me if u ve any
other way.
thank you :)

On Feb 20, 5:11 pm, waax  wrote:
> I'm as well new to django/python but did you tried
>
> for poll in Polls.objects.all():
>    print poll
>
> ?
>
> Thanks!
>
> On Feb 20, 12:50 pm, kalyani ram  wrote:
>
>
>
>
>
>
>
> > hey all,
>
> > I am learning the db connectivity using this 
> > tutorialhttps://docs.djangoproject.com/en/dev/intro/tutorial01/
> > Now, i followed every single step and yet, when i give
> > Polls.objects.all() is gives the output as 
> > But then it should be returning the fields right? I checked the db
> > also. I has records. I have not used __Str__ i ve used unicode.
> > Where i have gone wrong. When i execute i get empty fields :(
>
> > my models.py is as follows:
>
> > from django.db import models
> > import datetime
> > # Create your models here.
> > 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_today(self):
> >         return self.pub_date.date() == datetime.date.today()
>
> > class Choice(models.Model):
> >     poll = models.ForeignKey(Poll)
> >     choice = models.CharField(max_length=200)
> >     votes = models.IntegerField()
>
> > def __unicode__(self):
> >         return self.choice

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



Re: Installation steps for Ubuntu 11.10 users

2012-02-20 Thread Jigish Chawda
I am facing problems in configuring geodjango with Postgresql 9.1 DB.

With engine== django.contrib.gis.db.backends.postgis , I get an error
saying it doesnot exist.
I have put up this question here also :
http://stackoverflow.com/questions/9359082/setting-up-postgresql-9-1-database-in-django-for-ubuntu-11-10
.

Kindly check it out and comment on where am I going wrong.

On Mon, Feb 20, 2012 at 7:39 PM, Tom Evans  wrote:

> On Mon, Feb 20, 2012 at 10:49 AM, jigbox  wrote:
> > The installation guide has instructions for Ubuntu 10.10 and below
> > users.
> > However, there is no help for Ubuntu 11.10 users. since I am facing
> > some uncommon problems, I request to put up installation steps for
> > Ububtu 11.10 users.
> > Any help will be appreciated.
> >
>
> sudo easy_install virtualenv
> cd my/project/base/folder
> virtualenv environ
> source environ/bin/activate
> pip install django==1.3.1
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: dropdown select box in django

2012-02-20 Thread Mario Gudelj
Hey there,

Try this:

In your forms.py create a field such as this

message = forms.ChoiceField(label='Event Type', choices=EVENT_TYPE_CHOICES)

That will create a dropdown.

Also, I think that the first thing in the tuple is a value and shouldn't
have a space, so change:

EVENT_TYPE_CHOICES = (('Event Created', 'EventCreated'),('Event Changed',
'EventChanged'),)

to:

EVENT_TYPE_CHOICES = (('event_created', 'Event Created'),('event_changed',
'Event Changed'),)

See if that works for you.

Cheers,

-m

 message = models.CharField("Event Type", max_length=12,
> > choices=EVENT_TYPE_CHOICES)

On 21 February 2012 12:28, larry.mart...@gmail.com
wrote:

> On Feb 20, 5:54 pm, Anurag Chourasia 
> wrote:
> > This is weird
> >
> > I simply copy pasted your code in my environment and it shows me a Drop
> > Down.
> >
> > Could you save the models file again and close your browser (or even try
> > clearing cache) and restart your apache/django dev server whatever may be
> > the case and try again?
>
> Tried all that, still no joy. Also tried 2 different browsers, no
> difference. In the dev server also tried setting a breakpoint and then
> printing out message.choices, and it has the choices I expected:
>
> (Pdb) print message.choices
> (('Event Created', 'EventCreated'), ('Event Changed', 'EventChanged'))
>
>
>
> >
> > Regards,
> > Anurag
> >
> > On Mon, Feb 20, 2012 at 9:32 PM, larry.mart...@gmail.com <
> >
> >
> >
> >
> >
> >
> >
> > larry.mart...@gmail.com> wrote:
> > > I'm fairly new to django, still getting my feet wet. I want to have a
> > > dropdown menu (django seems to call this a select box). I read this:
> >
> > >https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.mo.
> ..
> >
> > > So I did this:
> >
> > > class EventsTable(models.Model):
> > >EVENT_TYPE_CHOICES = (
> > >('Event Created', 'EventCreated'),
> > >('Event Changed', 'EventChanged'),
> > >)
> >
> > >message = models.CharField("Event Type", max_length=12,
> > > choices=EVENT_TYPE_CHOICES)
> >
> > > But I get a standard text entry field where I can type in anything.
> >
> > > I did more googling, and I read a lot of confusing stuff about having
> > > to use javascrpt, ajax, CSS, etc. I read some pages about using a
> > > ChoiceField, but that is not part of the model class (it's in the
> > > forms class). I'm not sure how that would be used with a class that
> > > inherits form models.
> >
> > > What am I missing here? I can't imagine something as common as this
> > > would be hard in django. Shouldn't the first thing I did work?
> >
> > > TIA!
> > > -larry
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Django users" group.
> > > To post to this group, send email to django-users@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: registration forms.py

2012-02-20 Thread Stanwin Siow
Thanks akaarial and bill,

Much appreciated for the help on getting me to understand more about django. :)

Best Regards,

Stanwin Siow



On Feb 20, 2012, at 5:11 AM, akaariai wrote:

> On Feb 19, 1:42 pm, Stanwin Siow  wrote:
>> Hello,
>> 
>> The below method is an excerpt taken from the default registration forms.py 
>> with a few additional inputs.
>> 
>> class RegistrationForm(forms.Form):
>> 
>> keywords = forms.ModelMultipleChoiceField(queryset=Keyword.objects.all())
>> 
>> def save(self, profile_callback=None):
>> 
>> new_user = 
>> RegistrationProfile.objects.create_inactive_user(username=self.cleaned_data['username'],password=self.cleaned_data['password1'],email=self.cleaned_data['email'],profile_callback=profile_callback)
>> new_profile = 
>> UserProfile(user=new_user,username=self.cleaned_data['username'], 
>> keywords_subscribed=self.cleaned_data['keywords'],first_name=self.cleaned_data['first_name'],last_name=self.cleaned_data['last_name'],email=self.cleaned_data['email'])
>> new_profile.save()
>> return new_user
>> 
>> The highlighted portions will draw your attention to what i'm doing. As you 
>> can see i'm using a modelmultiplechoicefield which allows me to select 
>> multiple choices.
>> 
>> However when it gets stored into the database, it appends strange characters 
>> ( [> 
>> Is there a way to get rid of the special characters? or how is it even 
>> appearing or getting populated?
> 
> If keywords_subscribed is a character field (as it seems), you should
> store something like [keyword.text for keyword in
> self.cleaned_data['keywords']] in the field, not the model list
> directly. Another option is to store the keywords in a
> ManyToManyField. In any case, the problem seems to be the mismatch of
> saving models instances into a field that doesn't expect model
> instances.
> 
> - Anssi
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



About managing dependencies in a collaborative development team and good practices.

2012-02-20 Thread Santiago Basulto
Hello people,

some time ago with a couple of friends started a project with Django.
We are really getting into it now, and have made several progress in
the last 3 months. But, as the code starts to grow up, everything
start to get complicated.

Right now we have our project hosted on Bitbucket, and is simple to
set the enviroment to develop. Just clone the repo, syncdb, run a
script that install some fixtures, and runserver.

But, we started to use some externa apps, and add extra code, and it
started to look like a mess. Furthermore, we are 3 guys coding, it
starts to get complicated to all have the dependencies right.

After taking a look how pinax handle it, it seems a good option to
make use of PIP for the external apps, and create virtual envs.

First question then: Is that good? To use PIP with the external apps?
Will it be easy to deploy it?

Second question: What about our own apps? Should i let them live in
the project root directory? Should i try to pack them as "egg"
packages?

Finally: Do you have any good practice to tell me? Experience is
really needed!!

Thank you all!

PD: I have no much experience with Python, i'm a Java guy, and don't
think you like Maven ;)

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



Re: Creating a hospital erp (hospital management) in Django

2012-02-20 Thread Alec Taylor
...

Design doesn't matter one bit for what you're doing.

Don't try and win design awards by having CSS dropdowns.

Concentrate on solving their business logic rather than adding images
of sexy nurses

And get that book. There are free books online, there's the official
django tutorial also.

On Tue, Feb 21, 2012 at 1:12 AM, Saadat  wrote:
> Hello all
> I'm stuck on static files since yesterday. It gives me an error that
> no module called "staticfiles" found.  What my requirement is that i
> have a header file where I'm including a css dropdown menu. how do i
> include that file, without using staticfiles. What all needs to be
> done to include that file. Thanks a lot.
>
> Saadat
>
> On Feb 18, 7:09 pm, Marc Aymerich  wrote:
>> On Sat, Feb 18, 2012 at 2:52 PM, Saadat  wrote:
>> > Alec, I've tried including this css file everywhere, but it doesn't show 
>> > up anywhere. What exactly do i do with it to include this script on any 
>> > page, say index. i tried doing it through html as well as django. I don't 
>> > know what I'm doing wrong?
>>
>> check this:https://docs.djangoproject.com/en/dev/howto/static-files/
>>
>> btw, this seems to me a very basic web dev related question, so maybe
>> it will be better for you to spend some time learning general web dev
>> related stuff before doing things by your own.
>>
>> --
>> Marc
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: dropdown select box in django

2012-02-20 Thread larry.mart...@gmail.com
On Feb 20, 5:54 pm, Anurag Chourasia 
wrote:
> This is weird
>
> I simply copy pasted your code in my environment and it shows me a Drop
> Down.
>
> Could you save the models file again and close your browser (or even try
> clearing cache) and restart your apache/django dev server whatever may be
> the case and try again?

Tried all that, still no joy. Also tried 2 different browsers, no
difference. In the dev server also tried setting a breakpoint and then
printing out message.choices, and it has the choices I expected:

(Pdb) print message.choices
(('Event Created', 'EventCreated'), ('Event Changed', 'EventChanged'))



>
> Regards,
> Anurag
>
> On Mon, Feb 20, 2012 at 9:32 PM, larry.mart...@gmail.com <
>
>
>
>
>
>
>
> larry.mart...@gmail.com> wrote:
> > I'm fairly new to django, still getting my feet wet. I want to have a
> > dropdown menu (django seems to call this a select box). I read this:
>
> >https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.mo...
>
> > So I did this:
>
> > class EventsTable(models.Model):
> >    EVENT_TYPE_CHOICES = (
> >        ('Event Created', 'EventCreated'),
> >        ('Event Changed', 'EventChanged'),
> >    )
>
> >    message = models.CharField("Event Type", max_length=12,
> > choices=EVENT_TYPE_CHOICES)
>
> > But I get a standard text entry field where I can type in anything.
>
> > I did more googling, and I read a lot of confusing stuff about having
> > to use javascrpt, ajax, CSS, etc. I read some pages about using a
> > ChoiceField, but that is not part of the model class (it's in the
> > forms class). I'm not sure how that would be used with a class that
> > inherits form models.
>
> > What am I missing here? I can't imagine something as common as this
> > would be hard in django. Shouldn't the first thing I did work?
>
> > TIA!
> > -larry
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Re: dropdown select box in django

2012-02-20 Thread Micky Hulse
Your code looks good to me.

Maybe you need to restart apache (or similar)?

This is typically the format I use for choice fields:

LIVE_STATUS = 1
DRAFT_STATUS = 2
HIDDEN_STATUS = 3
STATUS_CHOICES = (
(LIVE_STATUS, u'Live'),
(DRAFT_STATUS, u'Draft'),
(HIDDEN_STATUS, u'Hidden'),
)
status = models.IntegerField(_(u'status'), choices=STATUS_CHOICES,
default=LIVE_STATUS)

Which is a technique taken from:



Maybe that article will help?

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



Re: dropdown select box in django

2012-02-20 Thread Anurag Chourasia
This is weird

I simply copy pasted your code in my environment and it shows me a Drop
Down.

Could you save the models file again and close your browser (or even try
clearing cache) and restart your apache/django dev server whatever may be
the case and try again?

Regards,
Anurag

On Mon, Feb 20, 2012 at 9:32 PM, larry.mart...@gmail.com <
larry.mart...@gmail.com> wrote:

> I'm fairly new to django, still getting my feet wet. I want to have a
> dropdown menu (django seems to call this a select box). I read this:
>
>
> https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.Field.choices
>
> So I did this:
>
> class EventsTable(models.Model):
>EVENT_TYPE_CHOICES = (
>('Event Created', 'EventCreated'),
>('Event Changed', 'EventChanged'),
>)
>
>message = models.CharField("Event Type", max_length=12,
> choices=EVENT_TYPE_CHOICES)
>
>
> But I get a standard text entry field where I can type in anything.
>
> I did more googling, and I read a lot of confusing stuff about having
> to use javascrpt, ajax, CSS, etc. I read some pages about using a
> ChoiceField, but that is not part of the model class (it's in the
> forms class). I'm not sure how that would be used with a class that
> inherits form models.
>
> What am I missing here? I can't imagine something as common as this
> would be hard in django. Shouldn't the first thing I did work?
>
> TIA!
> -larry
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: dropdown select box in django

2012-02-20 Thread larry.mart...@gmail.com
On Feb 20, 5:39 pm, Stanwin Siow  wrote:
> Try removing
>
> "Event Type",
>
> in the following
>
> message = models.CharField("Event Type", max_length=12,
> choices=EVENT_TYPE_CHOICES)
>
> Best Regards,
>
> Stanwin Siow


No difference.


>
> On Feb 21, 2012, at 8:32 AM, larry.mart...@gmail.com wrote:
>
>
>
>
>
>
>
> > ield("Event Type", max_length=12,
> > choices=EVENT_TYPE_CHOICES)

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



Re: dropdown select box in django

2012-02-20 Thread Stanwin Siow
Try removing

"Event Type",

in the following

message = models.CharField("Event Type", max_length=12,
choices=EVENT_TYPE_CHOICES)

Best Regards,

Stanwin Siow



On Feb 21, 2012, at 8:32 AM, larry.mart...@gmail.com wrote:

> ield("Event Type", max_length=12,
> choices=EVENT_TYPE_CHOICES)

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



dropdown select box in django

2012-02-20 Thread larry.mart...@gmail.com
I'm fairly new to django, still getting my feet wet. I want to have a
dropdown menu (django seems to call this a select box). I read this:

https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.Field.choices

So I did this:

class EventsTable(models.Model):
EVENT_TYPE_CHOICES = (
('Event Created', 'EventCreated'),
('Event Changed', 'EventChanged'),
)

message = models.CharField("Event Type", max_length=12,
choices=EVENT_TYPE_CHOICES)


But I get a standard text entry field where I can type in anything.

I did more googling, and I read a lot of confusing stuff about having
to use javascrpt, ajax, CSS, etc. I read some pages about using a
ChoiceField, but that is not part of the model class (it's in the
forms class). I'm not sure how that would be used with a class that
inherits form models.

What am I missing here? I can't imagine something as common as this
would be hard in django. Shouldn't the first thing I did work?

TIA!
-larry

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



RemoteUserBackend not creating user

2012-02-20 Thread Roberto Bouza
Hello,

I've been hitting my head pretty hard trying to figure out what the
problem is hope someone here can help.

I've set up the remote backends and middleware as per the docs and
blatantly I'm coding the META remote_user and nothing happens. like
this:

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.RemoteUserMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)

AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.RemoteUserBackend',
)

Then on my view:

def login_(request):
request.META['REMOTE_USER'] = 'test123'
try:
user = User.objects.get(username=request.META['REMOTE_USER'])
logger.debug("got user: %s, %s", user.last_name,
user.first_name)
except ObjectDoesNotExist:
logger.debug("username: %s, does not exist",
request.META['REMOTE_USER'])

return render_to_response('myapp/dashboard.html',
{'section':'dashboard'}, context_instance=RequestContext(request))

All goes as planned, but the user is not being created. Am I missing
something here?

Thank you!!!

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



Re: I am getting TypeError: coercing to Unicode: need string or buffer, long found. Please help.

2012-02-20 Thread Furbee
As an aside, I would assume you want your phone number field to be a string
(models.CharField) instead of integer.

Furbee

On Mon, Feb 20, 2012 at 2:39 PM, Babatunde Akinyanmi
wrote:

> @Daniel
> Your __unicode__ should always return a string  so like Shawn said,
> when you check your phone model, its __unicode__ method should be
> returning str() or unicode() not int
>
> On 2/20/12, Shawn Milochik  wrote:
> > Read the error message in your subject line. Then look at the
> > __unicode__ method of your Phone model. It appears that this is the
> > problem, and not the Device model.
> >
> > --
> > 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.
> >
> >
>
> --
> Sent from my mobile device
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: I am getting TypeError: coercing to Unicode: need string or buffer, long found. Please help.

2012-02-20 Thread Babatunde Akinyanmi
@Daniel
Your __unicode__ should always return a string  so like Shawn said,
when you check your phone model, its __unicode__ method should be
returning str() or unicode() not int

On 2/20/12, Shawn Milochik  wrote:
> Read the error message in your subject line. Then look at the
> __unicode__ method of your Phone model. It appears that this is the
> problem, and not the Device model.
>
> --
> 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.
>
>

-- 
Sent from my mobile device

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



Re: Associating Form Data with Users

2012-02-20 Thread Thorsten Sanders

You could do for example:

exclude the user field from the form and in your view something like this:

form = YourModelForm(request.POST)  #fill the modelform with the data
if form.is_valid(): # check if valid
mynewobject = form.save(commit=False) #save it to create 
the object but dont send to database

mynewobject.user = request.user # attach the user to it
mynewobject.save() # now do the real save and send it to 
the database


Am 20.02.2012 22:59, schrieb ds39:

I hate to keep bringing this issue up, but I'm still not entirely sure
how to implement this. I've tried a number of different ways to
connect some kind of user ID with form data without much success. Is
the idea that after authenticating the user in the view, request.user
be set to some variable that allows the user ID to be added to the
model or ModelForm ? Would this make the user object associated with
the form or model object accessible by filtering in the API ?

Thanks again


On Feb 19, 9:48 pm, Shawn Milochik  wrote:

On 02/19/2012 09:29 PM, ds39 wrote:


Thanks for your response. But, would you mind expanding on it a little
bit ?

How about you give it a try and see what you can figure out? In your
view, request.user will return the currently logged-in user (or an
AnonymousUser if they're not logged in). Since you said your view
requires login, you'll have a User object all ready to go.

Shawn


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



Re: Associating Form Data with Users

2012-02-20 Thread ds39
I hate to keep bringing this issue up, but I'm still not entirely sure
how to implement this. I've tried a number of different ways to
connect some kind of user ID with form data without much success. Is
the idea that after authenticating the user in the view, request.user
be set to some variable that allows the user ID to be added to the
model or ModelForm ? Would this make the user object associated with
the form or model object accessible by filtering in the API ?

Thanks again


On Feb 19, 9:48 pm, Shawn Milochik  wrote:
> On 02/19/2012 09:29 PM, ds39 wrote:
>
> > Thanks for your response. But, would you mind expanding on it a little
> > bit ?
>
> How about you give it a try and see what you can figure out? In your
> view, request.user will return the currently logged-in user (or an
> AnonymousUser if they're not logged in). Since you said your view
> requires login, you'll have a User object all ready to go.
>
> Shawn

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



Re: handling multiple parallel request

2012-02-20 Thread rafiee.nima
tnx alot
but actually my scenario dose not deal with user so I thing cookies do
not help a lot
suppose there are 3 airline counter which fill ticket forms and send
them to the cashier maybe  simultaneously  .forms are sent to the
cashier which is just a function in my view ,,I want to know how I can
handle these simultaneous request ..I also should be concern about
power failure ( actually  It is important not to miss queued request
if there is any queue  )

On Feb 19, 7:29 pm, Dennis Lee Bieber  wrote:
> On Sun, 19 Feb 2012 06:27:19 -0800 (PST), "rafiee.nima"
>
>  wrote:
> >hi
> >I want to develop a VIEW for cashier system which my receives multiple
> >parallel form as request  from deferent clients
> >I want to know how can I handle these request  ...is there any thing
> >like queue in django
>
>         The first thing you need to understand is that HTML is stateless; by
> itself it has no knowledge or history of other activity -- not even for
> a single user, much less multiple users. Everything a server receives
> from a client is a new activity.
>
>         This is why browser "cookies" were invented. On the first connection
> a cookie is generated to identify the user-session and passed to the
> browser; all related connections have to return the cookie in order to
> identify which session this post applies to. The cookie may be used to
> retrieve transient information from a database (this is how the history
> of previous posts is maintained).
>
>         Since going back to the server for minor updates may be so costly,
> one may find lots of JavaScript in a page -- to handle collection and
> verification of data on a form, and only sending a complete transaction
> back to the server at the end. Or one advances into AJAX processing
> which may  be able to bypass the webserver itself for some stuff; this
> way the session/user information stays on the client browser while the
> JavaScript goes around the webserver [the "asynchronous" part of AJAX].
> --
>         Wulfraed                 Dennis Lee Bieber         AF6VN
>         wlfr...@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

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



Re: Count values grouped by date

2012-02-20 Thread Martin Tiršel
On Mon, 20 Feb 2012 18:33:40 +0100, Tom Evans   
wrote:


On Mon, Feb 20, 2012 at 5:17 PM, Martin Tiršel   
wrote:


(btw, are you sure that works for views? looks like it is counting
clicks as well)


Yes, that was counting all records.



This type of query is tricky to do in django. In SQL, you would simply  
do:


SELECT action, count(*) as num_events
FROM bannerstats where banner_id = N group by action;


Ok, I will use raw query. Btw. it should be (pgsql):

SELECT (date(date)) AS "date", action, count(*) as num_events
FROM bannerstats
WHERE banner_id = N
GROUP BY (date(date)), action;

This gives the correct results. I only need to fill out programatically
missing counts for days where the action didn't happened  (no views or  
clicks).





In django, with this kind of table structure, you have to do two
queries (or use SQL):

BS.objects.filter(banner=b, action=0).aggregate(num_views=Count('id'))
BS.objects.filter(banner=b, action=1).aggregate(num_clicks=Count('id'))

If you altered the table structure to have two columns, one for clicks
and one for views, and use the value '1' for each (so an event
registering a click would log (1,0), for a view (0,1), then you could
do it in one query:

BS.objects.filter(banner=b).aggregate(num_views=Sum('views'),
num_clicks=Sum('clicks'))

From a DB perspective, I prefer the original structure though.



There will be more actions as time passes so it is easier to add new value  
to action than new columns to the table.



Cheers

Tom



Regards,
Martin

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



Re: I am getting TypeError: coercing to Unicode: need string or buffer, long found. Please help.

2012-02-20 Thread Shawn Milochik
Read the error message in your subject line. Then look at the 
__unicode__ method of your Phone model. It appears that this is the 
problem, and not the Device model.


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



I am getting TypeError: coercing to Unicode: need string or buffer, long found. Please help.

2012-02-20 Thread Daniel Marquez
Hey all,

I am a beginner django user. I am going through the tutorial, but when
I post the following I get the TypeError: coercing to unicode:


class Phone(models.Model):
phonenumber = models.IntegerField()
pub_date = models.DateTimeField('date published')

def __unicode__(self):
return self.phonenumber


class Device(models.Model):
phone = models.ForeignKey(Phone)
carrier = models.CharField(max_length=200)
modelnumber = models.CharField(max_length=200)

def __unicode__(self):
return self.carrier

I've tried other solutions posted by others, such as, change return
self.carrier to return unicode(self.carrier), but Im still getting the
error when I do this.

Any suggestions? I would greatly appreciate it.


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



How do I display non-field errors at the bottom of a form?

2012-02-20 Thread richard.prosser
Essentially I want to ensure that a DB record provided via a form is
unique AND be able to handle the error(s) produced in my own way.
After lengthy and often fruitless searching I decided that a
Model.validate_unique() call to trap the ValidationError would be
suitable, so that I could populate my own 'error_message' form
variable with the Django-produced "[model] with this [fields] already
exists" message.

However this message is still displayed at the top of the form, via
'top_errors' in django.forms I believe.

I have looked for a way to (artifically) declare the 'unique_together'
fields to be OK once I have captured the ValidationError message - so
as to inhibit the above behaviour - but there doesn't seem to be one.

So can anyone suggest a better approach?

Apologies in advance for not being able to supply any code but it is
subject to IPR restrictions.


Thanks ...

Richard

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



Re: Count values grouped by date

2012-02-20 Thread Tom Evans
On Mon, Feb 20, 2012 at 5:17 PM, Martin Tiršel  wrote:
> Hi,
>
> I have:
>
> class BannerStats(models.Model):
>    ACTION_TYPE_VIEW = 0
>    ACTION_TYPE_CLICK = 1
>
>    ACTION_TYPES = (
>        (ACTION_TYPE_VIEW, 'view'),
>        (ACTION_TYPE_CLICK, 'click'),
>    )
>
>    banner = models.ForeignKey(
>        Banner
>    )
>    date = models.DateTimeField(
>        auto_now_add=True
>    )
>    action = models.PositiveSmallIntegerField(
>        choices=ACTION_TYPES,
>        default=ACTION_TYPE_VIEW
>    )
>
> I need to get list of dates with sum of views and sum of clicks grouped by
> date. I use:
>
> BannerStats.objects.filter(
>    banner=banner
> ).extra(
>    {'date': 'date(date)'}
> ).values(
>    'date',
> ).annotate(
>    views=models.Count('id')
> )
>
> But this works only for vies, is there a way how can I get views and click
> in one query? Or have I to do two queries and join it in Python? Or should I
> remove action column and split it to views and clicks columns?
>
> Thanks,
> Martin
>

(btw, are you sure that works for views? looks like it is counting
clicks as well)

This type of query is tricky to do in django. In SQL, you would simply do:

SELECT action, count(*) as num_events
FROM bannerstats where banner_id = N group by action;

In django, with this kind of table structure, you have to do two
queries (or use SQL):

BS.objects.filter(banner=b, action=0).aggregate(num_views=Count('id'))
BS.objects.filter(banner=b, action=1).aggregate(num_clicks=Count('id'))

If you altered the table structure to have two columns, one for clicks
and one for views, and use the value '1' for each (so an event
registering a click would log (1,0), for a view (0,1), then you could
do it in one query:

BS.objects.filter(banner=b).aggregate(num_views=Sum('views'),
num_clicks=Sum('clicks'))

>From a DB perspective, I prefer the original structure though.

Cheers

Tom

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



Count values grouped by date

2012-02-20 Thread Martin Tiršel

Hi,

I have:

class BannerStats(models.Model):
ACTION_TYPE_VIEW = 0
ACTION_TYPE_CLICK = 1

ACTION_TYPES = (
(ACTION_TYPE_VIEW, 'view'),
(ACTION_TYPE_CLICK, 'click'),
)

banner = models.ForeignKey(
Banner
)
date = models.DateTimeField(
auto_now_add=True
)
action = models.PositiveSmallIntegerField(
choices=ACTION_TYPES,
default=ACTION_TYPE_VIEW
)

I need to get list of dates with sum of views and sum of clicks grouped by  
date. I use:


BannerStats.objects.filter(
banner=banner
).extra(
{'date': 'date(date)'}
).values(
'date',
).annotate(
views=models.Count('id')
)

But this works only for vies, is there a way how can I get views and click  
in one query? Or have I to do two queries and join it in Python? Or should  
I remove action column and split it to views and clicks columns?


Thanks,
Martin

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



Re: Installing Django from GIT/Subversion - package dependency in virtual environment

2012-02-20 Thread Denis Darii
Yes Mateusz, you understood right.

On Mon, Feb 20, 2012 at 4:07 PM, Mateusz Marzantowicz <
mmarzantow...@gmail.com> wrote:

> Yes, it works!
>
> Although I was previously installing Django according to docs at
> https://docs.djangoproject.com/en/1.3/topics/install/#installing-development-version,
>  your method works perfectly so far.
>
> I understand that keep in sync with trunk/master is as easy as invoking
> git pull (svn up) and then setup.py install in src/django directory in
> virtualenv root?
>
>
> Mateusz Marzantowicz
>
>
> On Mon, Feb 20, 2012 at 1:53 PM, Denis Darii wrote:
>
>> Do you mean django-trunk installation?
>>
>> If so, I use this in my requirements.txt:
>>
>> -e svn+http://code.djangoproject.com/svn/django/trunk/#egg=django-trunk
>>
>> or directly with pip:
>>
>> $ pip install -e svn+
>> http://code.djangoproject.com/svn/django/trunk/#egg=django-trunk
>>
>> Hope it helps.
>>
>> On Mon, Feb 20, 2012 at 1:36 PM, Mateusz Marzantowicz <
>> mmarzantow...@gmail.com> wrote:
>>
>>> Hello,
>>>
>>> I'm having a problem with managing Django installation which was done
>>> from git repository
>>> (might be svn as well) in clean virtual environment. The problem is that
>>> when I install some
>>> other package via pip which has a Django as a dependency, it doesn't
>>> find my django installation
>>> and then downloads official release. I really need only one Django
>>> installation in my virtualenv,
>>> the one from git :) It is more related to how pip works but does anyone
>>> has any idea how to do it the right way?
>>>
>>>
>>> Thanks,
>>> Mateusz Marzantowicz
>>>
>>>  --
>>> 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.
>>>
>>
>>
>>
>> --
>> This e-mail and any file transmitted with it is intended only for the
>> person or entity to which is addressed and may contain information that is
>> privileged, confidential or otherwise protected from disclosure. Copying,
>> dissemination or use of this e-mail or the information herein by anyone
>> other than the intended recipient is prohibited. If you are not the
>> intended recipient, please notify the sender immediately by return e-mail,
>> delete this communication and destroy all copies.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
This e-mail and any file transmitted with it is intended only for the
person or entity to which is addressed and may contain information that is
privileged, confidential or otherwise protected from disclosure. Copying,
dissemination or use of this e-mail or the information herein by anyone
other than the intended recipient is prohibited. If you are not the
intended recipient, please notify the sender immediately by return e-mail,
delete this communication and destroy all copies.

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



Re: template tag that iterates over list with for loop

2012-02-20 Thread Bill Freeman
Perhaps a filter rather than a tag.  You will need to provide input
for the filter, but it can ignore it.  So:

{% for a in random_variable|list_print %}

Bill

On 2/19/12, brian  wrote:
> Is it possible to create a template tag that will create a list that a
> for loop can loop over? I know I can create a template tag that will
> store the list in a variable and then iterate over that variable.  I
> want to do it in one step.
>
> For example the template tag with be “list_print” that will create a
> list.  I want something like the following in the template:
> {% for a in list_print %}
>
> Below is my code.  When I call it the loop never iterates.
> @register.tag(name="list_print")
> def do_list_print(parser, token):
> #test that don't have arguments
> try:
> tokenList = token.split_contents()
>
> except Exception:
> raise template.TemplateSyntaxError("%r tag throw unexpected
> exception(token.split_contents)" % token.contents.split()[0])
>
> if len(tokenList)>1:
> raise template.TemplateSyntaxError("%r tag does not take
> arguments" % token.contents.split()[0])
>
> return ListPrintNode()
>
> class ListPrintNode(Node):
> """
> thread safe version based on CycleNode from
> https://docs.djangoproject.com/en/dev/howto/custom-template-tags/
> """
>
> def __init__(self):
> self.myList = ['a', 'b']
>
> def render(self, context):
>
> if self not in context.render_context:
> context.render_context[self] =
> itertools.cycle(self.myList)
>
> cycle_iter = context.render_context[self]
> return cycle_iter.next()
>
> Brian
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Installing Django from GIT/Subversion - package dependency in virtual environment

2012-02-20 Thread Mateusz Marzantowicz
Yes, it works!

Although I was previously installing Django according to docs at
https://docs.djangoproject.com/en/1.3/topics/install/#installing-development-version,
your method works perfectly so far.

I understand that keep in sync with trunk/master is as easy as invoking git
pull (svn up) and then setup.py install in src/django directory in
virtualenv root?


Mateusz Marzantowicz

On Mon, Feb 20, 2012 at 1:53 PM, Denis Darii  wrote:

> Do you mean django-trunk installation?
>
> If so, I use this in my requirements.txt:
>
> -e svn+http://code.djangoproject.com/svn/django/trunk/#egg=django-trunk
>
> or directly with pip:
>
> $ pip install -e svn+
> http://code.djangoproject.com/svn/django/trunk/#egg=django-trunk
>
> Hope it helps.
>
> On Mon, Feb 20, 2012 at 1:36 PM, Mateusz Marzantowicz <
> mmarzantow...@gmail.com> wrote:
>
>> Hello,
>>
>> I'm having a problem with managing Django installation which was done
>> from git repository
>> (might be svn as well) in clean virtual environment. The problem is that
>> when I install some
>> other package via pip which has a Django as a dependency, it doesn't find
>> my django installation
>> and then downloads official release. I really need only one Django
>> installation in my virtualenv,
>> the one from git :) It is more related to how pip works but does anyone
>> has any idea how to do it the right way?
>>
>>
>> Thanks,
>> Mateusz Marzantowicz
>>
>>  --
>> 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.
>>
>
>
>
> --
> This e-mail and any file transmitted with it is intended only for the
> person or entity to which is addressed and may contain information that is
> privileged, confidential or otherwise protected from disclosure. Copying,
> dissemination or use of this e-mail or the information herein by anyone
> other than the intended recipient is prohibited. If you are not the
> intended recipient, please notify the sender immediately by return e-mail,
> delete this communication and destroy all copies.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Year dropdown in Django admin

2012-02-20 Thread grimmus
Excellent,

Thanks very much

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



Re: Year dropdown in Django admin

2012-02-20 Thread Denis Darii
I was in the same situation as you and I found this solution...
in your models.py:

import datetime
YEAR_CHOICES = []for r in range(1980,
(datetime.datetime.now().year+1)):YEAR_CHOICES.append((r,r))


so, your field can now use YEAR_CHOICES:

year = models.IntegerField(_('year'), max_length=4,
choices=YEAR_CHOICES, default=datetime.datetime.now().year)



On Mon, Feb 20, 2012 at 3:47 PM, grimmus  wrote:

> Hi,
>
> I have a car model that contains many fields including a 'year' field. I
> need the dropdown for this field to display the current year as the first
> option and also display the previous 25 years as individual options.
>
> I was thinking i could create a list object and then populate the list
> based on the current year and work my way back to 25 years earlier.
>
> I am not sure how to implement this so it would work in the Django admin
> area.
>
> Could someone please point me in the right direction with this ?
>
> Thank you in advance.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/NUO22GxW7UEJ.
> 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.
>



-- 
This e-mail and any file transmitted with it is intended only for the
person or entity to which is addressed and may contain information that is
privileged, confidential or otherwise protected from disclosure. Copying,
dissemination or use of this e-mail or the information herein by anyone
other than the intended recipient is prohibited. If you are not the
intended recipient, please notify the sender immediately by return e-mail,
delete this communication and destroy all copies.

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



Year dropdown in Django admin

2012-02-20 Thread grimmus
Hi,

I have a car model that contains many fields including a 'year' field. I 
need the dropdown for this field to display the current year as the first 
option and also display the previous 25 years as individual options.

I was thinking i could create a list object and then populate the list 
based on the current year and work my way back to 25 years earlier.

I am not sure how to implement this so it would work in the Django admin 
area.

Could someone please point me in the right direction with this ?

Thank you in advance.


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



Re: Creating a hospital erp (hospital management) in Django

2012-02-20 Thread Saadat
Hello all
I'm stuck on static files since yesterday. It gives me an error that
no module called "staticfiles" found.  What my requirement is that i
have a header file where I'm including a css dropdown menu. how do i
include that file, without using staticfiles. What all needs to be
done to include that file. Thanks a lot.

Saadat

On Feb 18, 7:09 pm, Marc Aymerich  wrote:
> On Sat, Feb 18, 2012 at 2:52 PM, Saadat  wrote:
> > Alec, I've tried including this css file everywhere, but it doesn't show up 
> > anywhere. What exactly do i do with it to include this script on any page, 
> > say index. i tried doing it through html as well as django. I don't know 
> > what I'm doing wrong?
>
> check this:https://docs.djangoproject.com/en/dev/howto/static-files/
>
> btw, this seems to me a very basic web dev related question, so maybe
> it will be better for you to spend some time learning general web dev
> related stuff before doing things by your own.
>
> --
> Marc

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



Re: Installation steps for Ubuntu 11.10 users

2012-02-20 Thread Tom Evans
On Mon, Feb 20, 2012 at 10:49 AM, jigbox  wrote:
> The installation guide has instructions for Ubuntu 10.10 and below
> users.
> However, there is no help for Ubuntu 11.10 users. since I am facing
> some uncommon problems, I request to put up installation steps for
> Ububtu 11.10 users.
> Any help will be appreciated.
>

sudo easy_install virtualenv
cd my/project/base/folder
virtualenv environ
source environ/bin/activate
pip install django==1.3.1

Cheers

Tom

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



Re: Installation steps for Ubuntu 11.10 users

2012-02-20 Thread Leonardo Giordani
Can you detail your problems? I installed it on a 11.10 some time ago and
perhaps I can help you

2012/2/20 jigbox 

> The installation guide has instructions for Ubuntu 10.10 and below
> users.
> However, there is no help for Ubuntu 11.10 users. since I am facing
> some uncommon problems, I request to put up installation steps for
> Ububtu 11.10 users.
> Any help will be appreciated.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Request Context problem

2012-02-20 Thread Roald
On 20 feb, 00:03, Reinout van Rees  wrote:
> On 19-02-12 14:16, dummyman dummyman wrote:
>
> The solution is simple: just add a {{ csrf_token }} somewhere in your
> form. That ought to do it.

A typo there, Reinout ;-). You meant:

{% csrf_token %}

Cheers, Roald

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



Re: Installing Django from GIT/Subversion - package dependency in virtual environment

2012-02-20 Thread Denis Darii
Do you mean django-trunk installation?

If so, I use this in my requirements.txt:

-e svn+http://code.djangoproject.com/svn/django/trunk/#egg=django-trunk

or directly with pip:

$ pip install -e svn+
http://code.djangoproject.com/svn/django/trunk/#egg=django-trunk

Hope it helps.

On Mon, Feb 20, 2012 at 1:36 PM, Mateusz Marzantowicz <
mmarzantow...@gmail.com> wrote:

> Hello,
>
> I'm having a problem with managing Django installation which was done from
> git repository
> (might be svn as well) in clean virtual environment. The problem is that
> when I install some
> other package via pip which has a Django as a dependency, it doesn't find
> my django installation
> and then downloads official release. I really need only one Django
> installation in my virtualenv,
> the one from git :) It is more related to how pip works but does anyone
> has any idea how to do it the right way?
>
>
> Thanks,
> Mateusz Marzantowicz
>
> --
> 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.
>



-- 
This e-mail and any file transmitted with it is intended only for the
person or entity to which is addressed and may contain information that is
privileged, confidential or otherwise protected from disclosure. Copying,
dissemination or use of this e-mail or the information herein by anyone
other than the intended recipient is prohibited. If you are not the
intended recipient, please notify the sender immediately by return e-mail,
delete this communication and destroy all copies.

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



Re: Cannot import django.core ??

2012-02-20 Thread Andreas Rehn
Tnx alot for the quick response Anssi!

Your were absolutely right, I downloaded the django tarball and installed from 
scratch again and it works. Funny how the disk failure corrupted both the 
django module under site-packages and the raw unpacked tarball from home 
dir 

/andreas

20 feb 2012 kl. 09:53 skrev akaariai:

> On Feb 20, 10:39 am, Andreas  wrote:
>> Hi,
>> 
>> I'm trying to get graphite hooked up with apache and it has a wsgi
>> script that uses django. I did a std installation according to the
>> graphite wiki and it worked fine, but then we experienced a disk
>> failure and after recovery the graphite.wsgi does not work anymore, it
>> fails on this line:
>> 
>> import django.core.handlers.wsgi
>> 
>> With this error:
>> 
>> mod_wsgi (pid=25614): Target WSGI script '/opt/spirit/graphite/conf/
>> graphite.wsgi' cannot be loaded as Python module.
>> [Mon Feb 06 15:32:25 2012] [error] [client 127.0.0.1] mod_wsgi
>> (pid=25614): Exception occurred processing WSGI script '/opt/spirit/
>> graphite/conf/graphite.wsgi'.
>> [Mon Feb 06 15:32:25 2012] [error] [client 127.0.0.1] Traceback (most
>> recent call last):
>> [Mon Feb 06 15:32:25 2012] [error] [client 127.0.0.1]   File "/opt/
>> spirit/graphite/conf/graphite.wsgi", line 5, in ?
>> [Mon Feb 06 15:32:25 2012] [error] [client 127.0.0.1] import
>> django.core.handlers.wsgi
>> [Mon Feb 06 15:32:25 2012] [error] [client 127.0.0.1] ImportError: No
>> module named core.handlers.wsgi
>> 
>> After recovery I also moved the entire graphite installation but I
>> have triple checked to change all path references...
>> 
>> I have googled and read all the posts concerning similar problem and
>> checked file permissions to django module, python version on
>> mod_wsgi.so and all that but I still can't figure out why this is
>> broken.
>> 
>> When I try a simple python cli test loading  django.core I get the
>> same:
>> 
>> root@usbeta13 graphite]# python
>> Python 2.4.3 (#1, Nov  3 2010, 12:52:40)
>> [GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.>>> 
>> import django
> print django.__file__
>> 
>> /usr/lib/python2.4/site-packages/django/__init__.pyc>>> import django.core
>> 
>> Traceback (most recent call last):
>>   File "", line 1, in ?
>> ImportError: No module named core
>> 
>> 
>> 
>> All help appreciated!
>> 
>> Tnx
>> 
>> /Andreas
> 
> You might have a corrupted Django installation. I would suggest
> getting rid of the whole site-packages/django directory and
> reinstalling. Of course with proper backups etc. I am not that good at
> Python deployment issues, so this is just a guess.
> 
> - Anssi
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



Installation steps for Ubuntu 11.10 users

2012-02-20 Thread jigbox
The installation guide has instructions for Ubuntu 10.10 and below
users.
However, there is no help for Ubuntu 11.10 users. since I am facing
some uncommon problems, I request to put up installation steps for
Ububtu 11.10 users.
Any help will be appreciated.

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



(One-way) Communicate between processes

2012-02-20 Thread Ervin Hegedüs
Hello list,

I've a long time run process, which started by a method of a Django
model object. It runs through djutils.decorators.async decorator,
like this:

  @djutils.decorators.async
  def my_long_time_process(self, foo):


When this process starts, it creates a file, and write the lines
to that (messages).

It works perfectly, till it runs, clients (http browsers) calls
a view, which reads that file above, and shows up the state of
long time process to customers.


Is there any more elegant way to implement this?


Thank you:


a.

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



[ANN]: FeinCMS v1.5.0

2012-02-20 Thread Matthias Kestenholz
Hello everyone

FeinCMS v1.5.0 has been released this noon and is available from
usual places. The differences to v1.5.0.rc1 are very small, only
an update of the AUTHORS file and a few fixes to the thumbnail
template filters.



What is FeinCMS anyway?
===


FeinCMS is one of the most advanced Content Management Systems built on top
of Django. FeinCMS not only includes a page module with many bundled content
types (plugins), a media library and up-to-date documentation but also the
tools to build your own CMS if our view of how a page CMS is supposed to
act like does not fit your requirements.


PyPI: http://pypi.python.org/pypi/FeinCMS/
Github: https://github.com/feincms/feincms/
Docs: http://www.feinheit.ch/media/labs/feincms/

Please report any issues you find in the issue tracker of github:
https://github.com/feincms/feincms/issues


This release would not have been possible without the contributions by the
community. Thanks for all the patches, bug reports and ideas which went into
this release.




=
FeinCMS 1.5 release notes
=


Explicit reversing of URLs from ``ApplicationContent``-embedded apps


URLs from third party apps embedded via ``ApplicationContent`` have
been traditionally made reversable by an ugly monkey patch of
``django.core.urlresolvers.reverse``. This mechanism has been deprecated
and will be removed in future FeinCMS versions. To reverse an URL
of a blog entry, instead of this::

# deprecated
from django.core.urlresolvers import reverse
reverse('blog.urls/blog_detail', kwargs={'year': 2011, 'slug': 'some-slug'})

do this::

from feincms.content.application.models import app_reverse
app_reverse('blog_detail', 'blog.urls', kwargs={'year': 2011,
'slug': 'some-slug'})

If you do not want to use the monkey patching behavior anymore, set
``FEINCMS_REVERSE_MONKEY_PATCH = False`` in your settings file.

The new method is accessible inside a template too::

{% load applicationcontent_tags %}

{# You have to quote the view name and the URLconf as in Django's
future {% url %} tag. #}
{% app_reverse "blog_detail" "blog.urls" year=2011 slug='some-slug' %}


Inheritance 2.0
===

It's possible to use Django's template inheritance from third party
applications embedded through ``ApplicationContent`` too. To use this
facility, all you have to do is return a tuple consisting of the
template and the context. Instead of::

def my_view(request):
# ...
return render_to_response('template.html', {'object': ...})

simply use::

def my_view(request):
# ...
return 'template.html', {'object': ...}

.. note::

   ``template.html`` should extend a base template now.


Better support of ``InlineModelAdmin`` options for content types


The ``FeinCMSInline`` only differs from a stock StackedInline in
differing defaults of ``form``, ``extra`` and ``fk_name``. All inline
options should be supported now, especially ``raw_id_fields`` and
``fieldsets``.




Minor changes
=

* The main CMS view is now based on Django's class-based generic
  views. Inheritance 2.0 will not work with the old views. You don't
  have to do anything if you use ``feincms.urls`` (as is recommended).

* Request and response processors have been moved out of the
  ``Page`` class into their own module, ``feincms.module.page.processors``.
  They are still accessible for some time at the old place.

* ``django.contrib.staticfiles`` is now a mandatory dependency for
  the administration interface.

* The ``active`` and ``in_navigation`` booleans on the ``Page``
  class now default to ``True``.

* The minimum version requirements have changed. Django versions older than
  1.3 aren't supported anymore, django-mptt must be 0.4 upwards.

* The mptt tree rebuilders have been removed; django-mptt offers tree
  rebuilding functionality itself.

* ``django-queryset-transform`` has been imported under ``feincms.utils``
  and is used for speeding up various aspects of the media library. The
  prefilled attributes have been deprecated, because
  ``django-queryset-transform`` can be used to do everything they did,
  and better.

* ``PageManager.active_filters`` has been converted from a list to a
  ``SortedDict``. This means that replacing or removing individual
  filters has become much easier than before. If you only used the
  public methods for registering new filters you don't have to change
  anything.

* The same has been done with the request and response processors.

* The ``TemplateContent`` has been changed to use the ``filesystem`` and
  the ``app_directories`` template loaders directly. It can be used
  together with the cached template loader now.

* The tree editor has received a few usability fixes with (hopefully)
  more to come.

* ``Page.setup_reques

Installing Django from GIT/Subversion - package dependency in virtual environment

2012-02-20 Thread Mateusz Marzantowicz
Hello,

I'm having a problem with managing Django installation which was done from
git repository
(might be svn as well) in clean virtual environment. The problem is that
when I install some
other package via pip which has a Django as a dependency, it doesn't find
my django installation
and then downloads official release. I really need only one Django
installation in my virtualenv,
the one from git :) It is more related to how pip works but does anyone has
any idea how to do it the right way?


Thanks,
Mateusz Marzantowicz

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



Re: Script to call loaddata on multiple fixtures

2012-02-20 Thread Tom Evans
On Sat, Feb 18, 2012 at 4:46 PM, LJ  wrote:
> I have quite a number of fixtures that I call loaddata to insert
> fixtures into my sqlite database using the following syntax:
>
> python ./manage.py loaddata ./apps/addresses/fixtures/cities.json
> python ./manage.py loaddata ./apps/addresses/fixtures/addresses.json
> ...
>
> I would like to create a script to call all of these, so I can insert
> them all at once.
> I do not want to combine all of the json files.
> To do this, would I create a py script similar to my bootstrap.py
> script?
> My bootstrap.py script executes subprocess.call() on all packages
> listed in my requirements txt file.
> Am I going down the right path with this, or is there an easier way?
>
> L J
>

Management commands. You can write custom management commands, and you
can programatically invoke other management commands:


from django.core.management.base import NoArgsCommand
from django.core import management

class Command(NoArgsCommand):
  help = 'Meta command which calls other commands'

  def handle_noargs(self, **options):
management.call_command('loaddata', './apps/addresses/fixtures/cities.json')


https://docs.djangoproject.com/en/1.3/howto/custom-management-commands/

Cheers

Tom

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



Re: doubt in the tutorial

2012-02-20 Thread akaariai
Check the indentation of __unicode__ method (and other methods too)...

 - Anssi

On Feb 20, 1:50 pm, kalyani ram  wrote:
> hey all,
>
> I am learning the db connectivity using this 
> tutorialhttps://docs.djangoproject.com/en/dev/intro/tutorial01/
> Now, i followed every single step and yet, when i give
> Polls.objects.all() is gives the output as 
> But then it should be returning the fields right? I checked the db
> also. I has records. I have not used __Str__ i ve used unicode.
> Where i have gone wrong. When i execute i get empty fields :(
>
> my models.py is as follows:
>
> from django.db import models
> import datetime
> # Create your models here.
> 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_today(self):
>         return self.pub_date.date() == datetime.date.today()
>
> class Choice(models.Model):
>     poll = models.ForeignKey(Poll)
>     choice = models.CharField(max_length=200)
>     votes = models.IntegerField()
>
> def __unicode__(self):
>         return self.choice

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



Re: doubt in the tutorial

2012-02-20 Thread waax
I'm as well new to django/python but did you tried

for poll in Polls.objects.all():
   print poll

?

Thanks!

On Feb 20, 12:50 pm, kalyani ram  wrote:
> hey all,
>
> I am learning the db connectivity using this 
> tutorialhttps://docs.djangoproject.com/en/dev/intro/tutorial01/
> Now, i followed every single step and yet, when i give
> Polls.objects.all() is gives the output as 
> But then it should be returning the fields right? I checked the db
> also. I has records. I have not used __Str__ i ve used unicode.
> Where i have gone wrong. When i execute i get empty fields :(
>
> my models.py is as follows:
>
> from django.db import models
> import datetime
> # Create your models here.
> 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_today(self):
>         return self.pub_date.date() == datetime.date.today()
>
> class Choice(models.Model):
>     poll = models.ForeignKey(Poll)
>     choice = models.CharField(max_length=200)
>     votes = models.IntegerField()
>
> def __unicode__(self):
>         return self.choice

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



Re: How to show the template reserved keyword on html.

2012-02-20 Thread Morris
It works, thanks for your great help.

On Feb 20, 4:19 pm, kahara  wrote:
> Hi,
>
> the doc says "argument tells which template bit to output", so
> shouldn't this be:
>
> {% templatetag openvariable %} sample {% templatetag closevariable %}
>
>     /j
>
> On 20 helmi, 09:35, Morris  wrote:
>
>
>
>
>
>
>
> > Hi Karen,
>
> > Thanks a lot, I tried the method.
>
> > {% openvariable %} sample {% closevariable %}
>
> > But , I got error message as below:
>
> > Invalid block tag: 'openvariable'
> > Request Method: GET
> > Request URL:    http://10.7.40.190/document/doc/
> > Django Version: 1.3.1
> > Exception Type: TemplateSyntaxError
> > Exception Value:
> > Invalid block tag: 'openvariable'
> > Exception Location:     /usr/local/lib/python2.6/dist-packages/django/
> > template/base.py in invalid_block_tag, line 291
> > Python Executable:      /usr/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-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.



doubt in the tutorial

2012-02-20 Thread kalyani ram
hey all,

I am learning the db connectivity using this tutorial
https://docs.djangoproject.com/en/dev/intro/tutorial01/
Now, i followed every single step and yet, when i give
Polls.objects.all() is gives the output as 
But then it should be returning the fields right? I checked the db
also. I has records. I have not used __Str__ i ve used unicode.
Where i have gone wrong. When i execute i get empty fields :(

my models.py is as follows:

from django.db import models
import datetime
# Create your models here.
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_today(self):
return self.pub_date.date() == datetime.date.today()

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

def __unicode__(self):
return self.choice

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



Re: TypeError: 'tuple' object is not callable

2012-02-20 Thread kalyani ram
Thank you. :) i ll do my best and sort this issue out :)

On Feb 20, 2:32 pm, akaariai  wrote:
> On Feb 20, 11:16 am, kalyani ram  wrote:
>
>
>
>
>
>
>
>
>
> > Thank you very much Anssi. I just got it perfect :D I know i am so
> > silly with errors. but i am  beginner. Thanks alot.
> > Can u help me one more error?
> > I trying to make a db connection using postgresql and python2.7
> > when i type import postgresql and enter I get the following error:
>
> > Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit
> > (Intel)] on win32
> > Type "copyright", "credits" or "license()" for more information.
>
> > >>> import postgresql
>
> > Traceback (most recent call last):
> >   File "", line 1, in 
> >     import postgresql
> > ImportError: No module named postgresql
>
> > Help me plz
>
> You probably want to import psycopg2. I don't believe that there is a
> module called postgresql. Or if there is, it will not be usable with
> Django. If you are using Django, you should set the DATABASES in
> settings.py correctly, and just use "from django.db import connection"
> and use that. See the documentation for how to do this.
>
> I understand you are a beginner and things can seem cryptic at first.
> However, I must encourage you to solve these issues on your own as
> much as possible. For example the first problem you had was pretty
> well pointed out to you by Python's exception message:
> TypeError at /time/plus/1
> 'tuple' object is not callable
> Exception location: mysite\urls.py in , line 6
>
>  - Anssi

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



Re: TypeError: 'tuple' object is not callable

2012-02-20 Thread akaariai
On Feb 20, 11:16 am, kalyani ram  wrote:
> Thank you very much Anssi. I just got it perfect :D I know i am so
> silly with errors. but i am  beginner. Thanks alot.
> Can u help me one more error?
> I trying to make a db connection using postgresql and python2.7
> when i type import postgresql and enter I get the following error:
>
> Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit
> (Intel)] on win32
> Type "copyright", "credits" or "license()" for more information.
>
> >>> import postgresql
>
> Traceback (most recent call last):
>   File "", line 1, in 
>     import postgresql
> ImportError: No module named postgresql
>
> Help me plz

You probably want to import psycopg2. I don't believe that there is a
module called postgresql. Or if there is, it will not be usable with
Django. If you are using Django, you should set the DATABASES in
settings.py correctly, and just use "from django.db import connection"
and use that. See the documentation for how to do this.

I understand you are a beginner and things can seem cryptic at first.
However, I must encourage you to solve these issues on your own as
much as possible. For example the first problem you had was pretty
well pointed out to you by Python's exception message:
TypeError at /time/plus/1
'tuple' object is not callable
Exception location: mysite\urls.py in , line 6

 - Anssi

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



Re: TypeError: 'tuple' object is not callable

2012-02-20 Thread kalyani ram
Thank you very much Anssi. I just got it perfect :D I know i am so
silly with errors. but i am  beginner. Thanks alot.
Can u help me one more error?
I trying to make a db connection using postgresql and python2.7
when i type import postgresql and enter I get the following error:

Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit
(Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import postgresql

Traceback (most recent call last):
  File "", line 1, in 
import postgresql
ImportError: No module named postgresql
>>>
Help me plz

On Feb 20, 1:49 pm, akaariai  wrote:
> On Feb 20, 10:01 am, kalyani ram  wrote:
>
> > My urls.py is as follows.
>
> > from django.conf.urls.defaults import *
> > from mysite.views import current_datetime, hours_ahead
>
> > urlpatterns = patterns('',
> >     (r'^time/$', current_datetime)
> > (r'^time/plus/(\d{1,2})/$', hours_ahead),
> > )
>
> Missing comma after the first pattern. Thus you have (r'^time/$',
> current_datetime)(...), which is syntax for calling the first tuple.
> That causes the error.
>
> > def hours_ahead(request, offset):
> >     offset = int(offset)
> >     dt = datetime.datetime.now() + datetime.timedelta(hours=offset)
> >     return render_to_response('temp.html', {'hour_offset': offset},
> > {'next_time': dt })
>
> If I am not mistaken you should not have two dictionaries on the last
> line, just one:
> {'hour_offset': offset, 'next_time': dt }
>
>  - Anssi

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



Re: Cannot import django.core ??

2012-02-20 Thread akaariai
On Feb 20, 10:39 am, Andreas  wrote:
> Hi,
>
> I'm trying to get graphite hooked up with apache and it has a wsgi
> script that uses django. I did a std installation according to the
> graphite wiki and it worked fine, but then we experienced a disk
> failure and after recovery the graphite.wsgi does not work anymore, it
> fails on this line:
>
> import django.core.handlers.wsgi
>
> With this error:
>
> mod_wsgi (pid=25614): Target WSGI script '/opt/spirit/graphite/conf/
> graphite.wsgi' cannot be loaded as Python module.
> [Mon Feb 06 15:32:25 2012] [error] [client 127.0.0.1] mod_wsgi
> (pid=25614): Exception occurred processing WSGI script '/opt/spirit/
> graphite/conf/graphite.wsgi'.
> [Mon Feb 06 15:32:25 2012] [error] [client 127.0.0.1] Traceback (most
> recent call last):
> [Mon Feb 06 15:32:25 2012] [error] [client 127.0.0.1]   File "/opt/
> spirit/graphite/conf/graphite.wsgi", line 5, in ?
> [Mon Feb 06 15:32:25 2012] [error] [client 127.0.0.1]     import
> django.core.handlers.wsgi
> [Mon Feb 06 15:32:25 2012] [error] [client 127.0.0.1] ImportError: No
> module named core.handlers.wsgi
>
> After recovery I also moved the entire graphite installation but I
> have triple checked to change all path references...
>
> I have googled and read all the posts concerning similar problem and
> checked file permissions to django module, python version on
> mod_wsgi.so and all that but I still can't figure out why this is
> broken.
>
> When I try a simple python cli test loading  django.core I get the
> same:
>
> root@usbeta13 graphite]# python
> Python 2.4.3 (#1, Nov  3 2010, 12:52:40)
> [GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.>>> 
> import django
> >>> print django.__file__
>
> /usr/lib/python2.4/site-packages/django/__init__.pyc>>> import django.core
>
> Traceback (most recent call last):
>   File "", line 1, in ?
> ImportError: No module named core
>
>
>
> All help appreciated!
>
> Tnx
>
> /Andreas

You might have a corrupted Django installation. I would suggest
getting rid of the whole site-packages/django directory and
reinstalling. Of course with proper backups etc. I am not that good at
Python deployment issues, so this is just a guess.

 - Anssi

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



Re: TypeError: 'tuple' object is not callable

2012-02-20 Thread akaariai
On Feb 20, 10:01 am, kalyani ram  wrote:
> My urls.py is as follows.
>
> from django.conf.urls.defaults import *
> from mysite.views import current_datetime, hours_ahead
>
> urlpatterns = patterns('',
>     (r'^time/$', current_datetime)
> (r'^time/plus/(\d{1,2})/$', hours_ahead),
> )

Missing comma after the first pattern. Thus you have (r'^time/$',
current_datetime)(...), which is syntax for calling the first tuple.
That causes the error.

> def hours_ahead(request, offset):
>     offset = int(offset)
>     dt = datetime.datetime.now() + datetime.timedelta(hours=offset)
>     return render_to_response('temp.html', {'hour_offset': offset},
> {'next_time': dt })

If I am not mistaken you should not have two dictionaries on the last
line, just one:
{'hour_offset': offset, 'next_time': dt }

 - Anssi

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



Cannot import django.core ??

2012-02-20 Thread Andreas
Hi,

I'm trying to get graphite hooked up with apache and it has a wsgi
script that uses django. I did a std installation according to the
graphite wiki and it worked fine, but then we experienced a disk
failure and after recovery the graphite.wsgi does not work anymore, it
fails on this line:

import django.core.handlers.wsgi

With this error:

mod_wsgi (pid=25614): Target WSGI script '/opt/spirit/graphite/conf/
graphite.wsgi' cannot be loaded as Python module.
[Mon Feb 06 15:32:25 2012] [error] [client 127.0.0.1] mod_wsgi
(pid=25614): Exception occurred processing WSGI script '/opt/spirit/
graphite/conf/graphite.wsgi'.
[Mon Feb 06 15:32:25 2012] [error] [client 127.0.0.1] Traceback (most
recent call last):
[Mon Feb 06 15:32:25 2012] [error] [client 127.0.0.1]   File "/opt/
spirit/graphite/conf/graphite.wsgi", line 5, in ?
[Mon Feb 06 15:32:25 2012] [error] [client 127.0.0.1] import
django.core.handlers.wsgi
[Mon Feb 06 15:32:25 2012] [error] [client 127.0.0.1] ImportError: No
module named core.handlers.wsgi

After recovery I also moved the entire graphite installation but I
have triple checked to change all path references...

I have googled and read all the posts concerning similar problem and
checked file permissions to django module, python version on
mod_wsgi.so and all that but I still can't figure out why this is
broken.

When I try a simple python cli test loading  django.core I get the
same:

root@usbeta13 graphite]# python
Python 2.4.3 (#1, Nov  3 2010, 12:52:40)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> print django.__file__
/usr/lib/python2.4/site-packages/django/__init__.pyc
>>> import django.core
Traceback (most recent call last):
  File "", line 1, in ?
ImportError: No module named core
>>>


All help appreciated!

Tnx

/Andreas

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



Re: How to show the template reserved keyword on html.

2012-02-20 Thread kahara
Hi,

the doc says "argument tells which template bit to output", so
shouldn't this be:

{% templatetag openvariable %} sample {% templatetag closevariable %}


/j


On 20 helmi, 09:35, Morris  wrote:
> Hi Karen,
>
> Thanks a lot, I tried the method.
>
> {% openvariable %} sample {% closevariable %}
>
> But , I got error message as below:
>
> Invalid block tag: 'openvariable'
> Request Method: GET
> Request URL:    http://10.7.40.190/document/doc/
> Django Version: 1.3.1
> Exception Type: TemplateSyntaxError
> Exception Value:
> Invalid block tag: 'openvariable'
> Exception Location:     /usr/local/lib/python2.6/dist-packages/django/
> template/base.py in invalid_block_tag, line 291
> Python Executable:      /usr/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-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.



TypeError: 'tuple' object is not callable

2012-02-20 Thread kalyani ram
Hey all,

I am recently trying out the examples from the link
http://www.djangobook.com/en/1.0/chapter03/, where the current time
have to be displayed and then modify and display the offset. I was
able to display the time without any issue, but with the offset part,
i get the error
TypeError at /time/plus/1
'tuple' object is not callable
Exception location: mysite\urls.py in , line 6

My urls.py is as follows.

from django.conf.urls.defaults import *
from mysite.views import current_datetime, hours_ahead

urlpatterns = patterns('',
(r'^time/$', current_datetime)
(r'^time/plus/(\d{1,2})/$', hours_ahead),
)

my views.py is as follows.

from django.shortcuts import render_to_response
import datetime

def current_datetime(request):
now = datetime.datetime.now()
return render_to_response('temp.html', {'current_date': now})

def hours_ahead(request, offset):
offset = int(offset)
dt = datetime.datetime.now() + datetime.timedelta(hours=offset)
return render_to_response('temp.html', {'hour_offset': offset},
{'next_time': dt })

my temp.html is as follows:





Future time


My helpful timestamp site
In {{ hour_offset }} hour(s), it will be {{ next_time }}.


Thanks for visiting my site.




pls help. I am really lost :(

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