Bash autocompletion for django-admin.py/manage.py

2011-02-18 Thread Anurag
I just posted a simple script to autocomplete django-admin.py/manage.py 
commands in bash:

https://github.com/agoel/django-bash-complete

I hope it can save everyone some keystrokes.

Best,
Anurag

-- 
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: Constant signing out on production server - Django 1.2.5

2011-02-18 Thread Shawn Milochik
By chance, is the client running Windows and using IE? If so, is their
system time incorrect?

I've had major problems with session timeouts myself, and ended up
handling session expiration in custom middleware because I never could
figure it out, and over a period of months this list was no help
either. I figured it was some kind of fluke -- I mean, Django's
sessions are being used by plenty of other people with no problems.
But some time after that, someone with a problem that sounded very
similar to mine mentioned that his problem appeared to be due to the
way IE's cookies interacted with the system time.

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.



Constant signing out on production server - Django 1.2.5

2011-02-18 Thread Velian
Hello there

I am having a frustrating issue:

I'm running Apache/modpython with Django 1.2.5.

It seems that every few seconds or so, when I try to load a page after
logging in (either to the site or to the admin interface), I am
bounced back to the login screen as if my session has expired. My
logged-in state is very tenuous.

Any advice on where to look to fix this would be appreciated.

Thanks!

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

2011-02-18 Thread lduros
Did you install dajaxice through apt-get? From the command line: sudo
apt-get install python-django-dajaxice
If not, you might want to try it it might do the trick of installing
it in a much easier way than from the sources.

On Feb 18, 5:04 pm, LJ  wrote:
> Just adding a note for anyone else struggling with a similar
> 'unresolved import' problem...
> This article explains in details how to modify the PYTHONPATH if you
> decide to go that route.
>  http://www.stereoplex.com/blog/understanding-imports-and-pythonpath
> I don't prefer to use this method, but I now understand how django is
> able to find imported libraries.
>
> I am still looking for a good article on how to install/configure a
> 3rd party app in site packages--or dist-packages on Ubuntu (Python
> 2.6).
>
> On Feb 18, 12:39 pm, LJ  wrote:
>
> > I am on Ubuntu 10, using Python 2.6 and Django 1.2.3.
> > Mike Ramirez suggested that I look at the site packages (in my case
> > dist-packages) in my python lib dir.
> > I did not see anything in there that references dajaxice.  I may need
> > to manually edit the PYTHONPATH once I figure out how and where.
>
> > My errors are:
> > Unresolved import: dajaxice_autodiscover
> > Unresolved import: dajaxice_functions
>
> > On Feb 18, 7:17 am, CrabbyPete  wrote:
>
> > > I wouldn't reinstall python because of an unresolved import error.
> > > What's unresolved and what type of system are you on PC/Linux?
>
> > > On Feb 17, 7:48 pm, LJ  wrote:
>
> > > > I installed the latest version of dajaxice, but I am still getting
> > > > Unresolved import errors.
> > > > My guess is that I need to remove and reinstall the Python
> > > > Interpreters.
> > > > Is there a some documentation somewhere that explains how to reinstall
> > > > the Python Interpreters, so I can resolve all of my Unresolved Import
> > > > errors?

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



Integer as select box and prepolutated field as foreignkey

2011-02-18 Thread Aimee
I'm creating a comic book database that will have something like this:

Title (ForeignKey is title)
Issue
Writer
Artist
Cover Artist...
etc

Lots of comic book issues have the same writer, artist and cover
artist, so for the issue #, I'd like to be able to select numbers -
say, select numbers 1 - 10 with a simple command + click. This would
generate separate objects like Issue #1, Issue #2, etc.

Is this possible in Django? I'm thinking I could make abstract
classes. Oh, and please note I'm quite new to Django, so talk in baby
words.

Also, how do I do a slugfield when the name of the slug is a
ForeignKey? I will probably definitely have to make an abstract class
now if I'm going to achieve what I explained above and if I want
prepopulated slugfields.

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



Using success_url with reverse() in class-based generic view

2011-02-18 Thread jnns
Hi users,

I have a CreateView which I'd like to redirect to a custom success_url
defined in my URLconf. As I want to stick to the DRY-principle I just
did the following:

   success_url = reverse("my-named-url")

Unfortunately, this breaks my site by raising an
"ImproperlyConfigured: The included urlconf doesn't have any patterns
in it". Removing success_url and setting the model's
get_absolute_url() to the following works fine:

   def get_absolute_url(self):
   return reverse("my-named-url")

I could reproduce this with a brand new project/application so I don't
think this has something to do with my setup.

Can anyone confirm this issue?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: RE: 'str' object is not callable

2011-02-18 Thread Burhan
Where is 'deletion_time' defined, in reference to the urls.py? The error is 
that urls.py can't resolve deletion_time, which is why its saying that "I 
cannot call a string object".

I would investigate that.  Try qualifying it by giving it the module name.

On another note, you can concatenate your two statements in your method to 
Buchung.object.filter(id=obj_id).delete()

Hope this helps.

-- 
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: list indices must be integers not unicode

2011-02-18 Thread Burhan
id_list = [int(x) for x in data.keys() if x.isdigit()]

-- 
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: Just going to point this out ...

2011-02-18 Thread dave b
>
> is this what you're looking for?
>
> http://www.owasp.org/index.php/OWASP_Application_Security_FAQ
>
> Mike

Hi Mike. Well in this case the page would be
http://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet
 but yes that link is a good starting point.

I should clarify why I emailed this list --> I emailed this list
instead of filing a bug because I thought this was a bit stupid to
file a bug for. I wanted to see what other 'users' thought about it.
The general opinion thus far has been that people _should_ know about
these problems which is a nice assumption but imho not always true
(and in a fair amount of applications no one will care if an xss is
possible).

-- 
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 reinstall Python Interpreters?

2011-02-18 Thread LJ
Just adding a note for anyone else struggling with a similar
'unresolved import' problem...
This article explains in details how to modify the PYTHONPATH if you
decide to go that route.
  http://www.stereoplex.com/blog/understanding-imports-and-pythonpath
I don't prefer to use this method, but I now understand how django is
able to find imported libraries.

I am still looking for a good article on how to install/configure a
3rd party app in site packages--or dist-packages on Ubuntu (Python
2.6).

On Feb 18, 12:39 pm, LJ  wrote:
> I am on Ubuntu 10, using Python 2.6 and Django 1.2.3.
> Mike Ramirez suggested that I look at the site packages (in my case
> dist-packages) in my python lib dir.
> I did not see anything in there that references dajaxice.  I may need
> to manually edit the PYTHONPATH once I figure out how and where.
>
> My errors are:
> Unresolved import: dajaxice_autodiscover
> Unresolved import: dajaxice_functions
>
> On Feb 18, 7:17 am, CrabbyPete  wrote:
>
> > I wouldn't reinstall python because of an unresolved import error.
> > What's unresolved and what type of system are you on PC/Linux?
>
> > On Feb 17, 7:48 pm, LJ  wrote:
>
> > > I installed the latest version of dajaxice, but I am still getting
> > > Unresolved import errors.
> > > My guess is that I need to remove and reinstall the Python
> > > Interpreters.
> > > Is there a some documentation somewhere that explains how to reinstall
> > > the Python Interpreters, so I can resolve all of my Unresolved Import
> > > errors?

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



Python's 20th Birthday (well, public release birthday) Extravaganza Lunch Party!

2011-02-18 Thread Gabriel Gunderson
What: Python's 20th Birthday (well, public release birthday)
Extravaganza Lunch Party!

When: Monday at 12:15

Where: Izeni.  We're located at the Novell TCN, also known as the
building formerly known as OSTC, also known as (but not really
numbered as) building A.  (Campus Map:
http://bit.ly/Pythons_BDay_Party)

Who: Python Users worldwide*, plus a special invitation to Guido van
Rossum: We'll pick up the plane tickets and hotel if you want to join
us :)


Queridos Pythonistas,

As any faithful subject of Guido (the Benevolent Dictator for Life)
must already know, this Sunday marks the 20th anniversary of Python's
first *public* release[1].  (I know, such a tender age...)  Since we
all know that attending a birthday party for the awesomest computer
programming language of all time is on the top on everybody's bucket
list, Izeni would like facilitate the fulfillment of your wildest geek
dreams by throwing perhaps the best programming-language-themed
birthday celebration ever known to mankind.

We'll be gathering Monday to have pizza, giant subs, spam with eggs**,
and a specially commissioned Python-themed cake by Joseph Hall of 3D
TuxCake fame[2].  We're working on getting a snake charmer too!  (Know
anybody?)

Come join us, mingle with other Python users, and enjoy some great
food!  And spread the word!

Please try to RSVP by either by tweeting me @izeni or emailing me
offlist so we can get a (rough) food estimate.


Thanks,
Gabe Gunderson


* While everyone is welcome to join us for cake, there are certain
restrictions for free pizza/subs/spam-and-eggs. Specifically, you must
meet at *least* one of the following qualifications:

0) You have commit privileges for Python.

1) You have read and given *serious* thought and consideration to 'The
Zen of Python'.

2) Your license plate says PEP-0008.

3) You use Python professionally or as a hobby.

4) You have an untrimmed beard that's longer than 1 inch (or are at
least trying).

5) You have a Monty Python tatoo.

6) And lastly, you enjoy playing the game "snake" or just like the name Guido.

Due to what we expect to be an overwhelming response, we *will* be
checking for non-pythonista freeloaders by verifying *basic* knowledge
of the Python language. We also reserve the right to inspect your
keyboard for disproportional wear on your "{" and "}" keys and may
additionally do random spot-checks on your webservers for the
'X-Powered-By' headers for any traces of PHP.

** We really will be serving spam and eggs.

[1] http://python-history.blogspot.com/2009/01/brief-timeline-of-python.html
[2] http://blog.josephhall.com/tutorials/tuxcake/

BTW, if you're looking for a gig writing clean code in Python, we're
always looking for sharp hackers.  Let us know!

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



How To Serve Javascript, CSS, Files

2011-02-18 Thread hank23
Let me preface the following information by saying that I’m trying to
build this into the polls application that I built in the introductory
django tutorial. The document I’m looking at is here:

http://docs.djangoproject.com/en/1.2/howto/static-files/

And it says this:

How to do it¶

Here’s the formal definition of the serve() view:

def serve(request, path, document_root, show_indexes=False)

To use it, just put this in your URLconf:

(r'^site_media/(?P.*)$', 'django.views.static.serve',
{'document_root': '/path/to/media'}),

...where site_media is the URL where your media will be rooted, and /
path/to/media is the filesystem root for your media. This will call
the serve() view, passing in the path from the URLconf and the
(required) document_root parameter.

Given the above URLconf:
•   The file /path/to/media/foo.jpg will be made available at the URL /
site_media/foo.jpg.
•   The file /path/to/media/css/mystyles.css will be made available at
the URL /site_media/css/mystyles.css.
•   The file /path/bar.jpg will not be accessible, because it doesn't
fall under the document root.

Of course, it's not compulsory to use a fixed string for the
'document_root' value. You might wish to make that an entry in your
settings file and use the setting value there. That will allow you and
other developers working on the code to easily change the value as
required. For example, if we have a line in settings.py that says:
STATIC_DOC_ROOT = '/path/to/media'
...we could write the above URLconf entry as:

from django.conf import settings
...
(r'^site_media/(?P.*)$', 'django.views.static.serve',
{'document_root': settings.STATIC_DOC_ROOT}),

...where site_media is the URL where your media will be rooted, and /
path/to/media is the filesystem root for your media. This will call
the serve() view, passing in the path from the URLconf and the
(required) document_root parameter.

Given the above URLconf:
•   The file /path/to/media/foo.jpg will be made available at the URL /
site_media/foo.jpg.
•   The file /path/to/media/css/mystyles.css will be made available at
the URL /site_media/css/mystyles.css.
•   The file /path/bar.jpg will not be accessible, because it doesn't
fall under the document root.

Of course, it's not compulsory to use a fixed string for the
'document_root' value. You might wish to make that an entry in your
settings file and use the setting value there. That will allow you and
other developers working on the code to easily change the value as
required. For example, if we have a line in settings.py that says:

STATIC_DOC_ROOT = '/path/to/media'

I’m trying to be able to have screen files be able to  reference
javascript and css code which is in external files.Based on what the
documentation above says I’ve coded my view code to look like this:

def serve(request, path, document_root, show_indexes=False)

I’ve also coded STATIC_DOC_ROOT like this:

STATIC_DOC_ROOT = '/polls/'

And I’ve coded the entry in my polls\urls.py like this:

(r'^site_media/(?P.*)$', 'django.views.static.serve',
{ 'document_root': settings.STATIC_DOC_ROOT }),

My folder where I have my javascript.js file is in this folder:

polls\site_media

where I  later hope to also add one or more other app-specific files/
folders for css as well. So any idea where I missing something to get
this to work properly? Currently I’m getting a TemplateSyntaxError.
Thanks for the help.

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



Re: How to reinstall Python Interpreters?

2011-02-18 Thread LJ
I am on Ubuntu 10, using Python 2.6 and Django 1.2.3.
Mike Ramirez suggested that I look at the site packages (in my case
dist-packages) in my python lib dir.
I did not see anything in there that references dajaxice.  I may need
to manually edit the PYTHONPATH once I figure out how and where.

My errors are:
Unresolved import: dajaxice_autodiscover
Unresolved import: dajaxice_functions

On Feb 18, 7:17 am, CrabbyPete  wrote:
> I wouldn't reinstall python because of an unresolved import error.
> What's unresolved and what type of system are you on PC/Linux?
>
> On Feb 17, 7:48 pm, LJ  wrote:
>
> > I installed the latest version of dajaxice, but I am still getting
> > Unresolved import errors.
> > My guess is that I need to remove and reinstall the Python
> > Interpreters.
> > Is there a some documentation somewhere that explains how to reinstall
> > the Python Interpreters, so I can resolve all of my Unresolved Import
> > errors?

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



GeometryCollectionField with MultiPolygon

2011-02-18 Thread jordi
I have a class with a GeometryCollectionField, when I try to save a
MultiPolygon object in the GeometryCollectionField I always get a NULL
value in the GeometryCollectionField.
Other types of objects saved in the GeometryCollectionField work fine.
Somebody knows whats happening?


from django.contrib.gis.db import models
class gcol(models.Model):
name = models.CharField(max_length=50)
geom = models.GeometryCollectionField()
objects = models.GeoManager()

from gcollection.models import gcol
from django.contrib.gis.geos import  GeometryCollection,
MultiPolygon,  Polygon

p1 = Polygon( ((0, 0), (0, 1), (1, 1), (0, 0)) )
p2 = Polygon( ((1, 1), (1, 2), (2, 2), (1, 1)) )
mp = MultiPolygon(p1,p2)

a=gcol.objects.get(name='a')
a.geom=GeometryCollection((p1, p2))
a.save()
a.geom=GeometryCollection(mp)
a.save()

/usr/lib64/python2.7/site-packages/django/db/backends/sqlite3/base.py
in execute(self, query, params)
198 query = self.convert_query(query)
199 try:
--> 200 return Database.Cursor.execute(self, query,
params)
201 except Database.IntegrityError, e:
202 raise utils.IntegrityError,
utils.IntegrityError(*tuple(e)), sys.exc_info()[2]

IntegrityError: gcollection_gcol.geom may not be NULL

-- 
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: Admin - click through to parent / child

2011-02-18 Thread Daniel Roseman
On Friday, February 18, 2011 5:02:43 PM UTC, Alec wrote:
>
> Thanks for the ideas, but those projects are more for arbitrary 
> relationships.  I'm thinking about just extending the basic 
> functionality of the admin site like in this image: 
>
> http://i53.tinypic.com/16h10m0.png 
>
 
If you want something to happen when you change the selected item in a 
drop-down box, you need to use Javascript. You could easily write an 
onchange event handler for that select box which adds the relevant URL 
underneath.
-- 
DR. 

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



Re: Messages framework is not showing messages in my templates

2011-02-18 Thread Daniel Roseman
On Friday, February 18, 2011 10:56:54 AM UTC, Gabriel Prat wrote:
>
> Hi all, I'm trying to use messages framework, I've checked that 
> middleware, context processor and app is well configured (I'm running 
> django development version which a standard manage.py startproject 
> includes all needed stuff) 
>
> So, let me write a little bit of code, assume a model like: 
>
> class MyModel(models.Model): 
> name= models.TextField(max_length = 100) 
> url = models.URLField() 
>
> And a simple form: 
>
> class mymodelForm(forms.ModelForm): 
> name = forms.CharField() 
> url = forms.URLField() 
> class Meta: 
> model = MyModel 
>
> A basic view (assuming all needed imports in top of my views.py file): 
>
> def mymodel_create(request): 
> from forms import mymodelForm 
> if request.method == 'POST': 
> form = mymodelForm(request.POST) 
> if form.is_valid(): 
> form.save() 
> messages.success(request, _('Model has been saved')) 
> else: 
> form = projectForm() 
>
> return render_to_response('mymodel_create.html', {'form' : form}) 
>
> 

The context processor is not invoked, because you're not using a 
RequestContext. So the messages variable is not added to your context. The 
last line should be:

return render_to_response('mymodel_create.html', {'form' : form}, 
context_instance=RequestContext)

See the documentation:
 
http://docs.djangoproject.com/en/1.2/ref/templates/api/#subclassing-context-requestcontext
(the Note box, a couple of screens down - unfortunately there's no handy id 
to link to directly)
--
DR.

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



Re: Messages framework is not showing messages in my templates

2011-02-18 Thread Xavier Ordoquy
Hi,

It's been some time I haven't used the messages framework but don't you see 
your messages with some lags ?
Like try to submit twice your form and see if you don't get the messages after 
the second post (and don't go in the admin between those requests).
When forms are valid, I usually redirects to the same page (or another one 
depending on edit/create mode) and the messages show up.

Regards,
Xavier.

Le 18 févr. 2011 à 11:56, Gabriel Prat a écrit :

> Hi all, I'm trying to use messages framework, I've checked that
> middleware, context processor and app is well configured (I'm running
> django development version which a standard manage.py startproject
> includes all needed stuff)
> 
> So, let me write a little bit of code, assume a model like:
> 
> class MyModel(models.Model):
>name= models.TextField(max_length = 100)
>url = models.URLField()
> 
> And a simple form:
> 
> class mymodelForm(forms.ModelForm):
>name = forms.CharField()
>url = forms.URLField()
>class Meta:
>model = MyModel
> 
> A basic view (assuming all needed imports in top of my views.py file):
> 
> def mymodel_create(request):
>from forms import mymodelForm
>if request.method == 'POST':
>form = mymodelForm(request.POST)
>if form.is_valid():
>form.save()
>messages.success(request, _('Model has been saved'))
>else:
>form = projectForm()
> 
>return render_to_response('mymodel_create.html', {'form' : form})
> 
> and my template (basic as well)
> 
>   {% if messages %}
>   
>   {% for message in messages %}
>   > {{ message }}
>   {% endfor %}
>   
>   {% else %}
>No messages to show
>{% endif %}
> 
>   {% csrf_token %}
>   
>   {{ form.as_ul }}
>   
>   Save
>   
>   
> 
> I load it, fill my form up in my browser, submit it and it saves my
> model correctly but don't shows any messages, always goes to {% else
> %} template part.
> 
> So, If I change my URL to /admin the login (or dashboard if logged in)
> is showed and my messages appears there!
> 
> Someone can help me to fix this problem? I've been searching over
> Django docs and Google with no helping topic.
> 
> Thanks in advance,
> 
> Gabriel
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



Re: Django pagination is repeating results

2011-02-18 Thread David De La Harpe Golden
On 18/02/11 17:38, diogobaeder wrote:
> Hi,

> Any ideas of what might be happening?
> 

Have you set a Meta.ordering on your Model (or applied an .order_by()
to the QuerySet?)


-- 
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: Just going to point this out ...

2011-02-18 Thread Mike Ramirez
On Friday, February 18, 2011 06:07:57 am dave b wrote:
>  On 19 February 2011 00:57, Shawn Milochik  wrote:
> > I also didn't see the part where they state that you shouldn't put your
> > database login information in a template. That's probably because Django
> > is designed to allow Web developers to do their jobs more easily, not
> > allow people who don't know what they're doing make Web applications. If
> > you're going to do something really stupid then blame Django in some
> > way, then you're probably not competent at the job.
> 
> Um. While it might be obvious to us it might not be so obvious to others.
> So this comment,
> " If you're going to do something really stupid then blame Django in
> some way, then  you're probably not competent at the job" shows a lack
> of thought  for other users given the way the django documentation
> found at [0] is presented.
> 
> [0] -
> http://docs.djangoproject.com/en/dev/topics/templates/#automatic-html-esca
> ping


is this what you're looking for?

http://www.owasp.org/index.php/OWASP_Application_Security_FAQ

Mike
-- 
"And what will you do when you grow up to be as big as me?"
asked the father of his little son.
"Diet."

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



Django pagination is repeating results

2011-02-18 Thread diogobaeder
Hi,

I have this weird pagination bug in Django: using object_list as a
return of a view, but passing a "paginate_by" argument to it, it's
repeating some of the results; Otherwise, if I remove the argument or
set as "paginate_by=None", the results are correct.

If using pagination, the quantity of results is maintained at a total,
so, because there are repeated results, the last results are left out
of the list, so they don't appear in the template.

Any ideas of what might be happening?

Thanks!

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

2011-02-18 Thread Alec
Thanks for the ideas, but those projects are more for arbitrary
relationships.  I'm thinking about just extending the basic
functionality of the admin site like in this image:

http://i53.tinypic.com/16h10m0.png

On Feb 18, 2:03 am, Derek  wrote:
> On Feb 16, 7:22 pm, Alec  wrote:
>
> > Hi,
>
> > I'm wondering if there are any add-ons that show a list of children
> > and give the ability to click through to parent or children records.
> > I'm aware of the InlineAdmin feature, but I'm thinking of a non-
> > editable list of children for all relations that automatically (i.e.
> > no need to edit admin.py for each model) appears below the record you
> > are currently editing.  For lookup/parent fields, where there is
> > currently the drop down to select the parent, you would also be able
> > to click the name to go directly to that parent record.
>
> > Any ideas?  Google didn't find me anything yet.
>
> Closest I could find was this 
> question:http://stackoverflow.com/questions/4334302/django-best-way-for-simple...
>
> Maybe this is something that could be done in a Django app.  A
> potential problem is that apps tend to shy away from having/using
> templates; but I guess if this was based on standard Admin code, then
> it could be do-able?

-- 
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: South - when to start?

2011-02-18 Thread ShawnMilo
Just to add my tiny bit to this:

I say start with South right away. But when you're ready to deploy for the 
first time, wipe it all and to another --initial. 

The reason is that South is awesome for letting you upgrade a production app 
that isn't allowed to stop working. So at first deployment, it's nice to 
start clean so you don't have all those extra migrations for each run of 
your unittests, etc.

Shawn

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



Re: django book example HELP..

2011-02-18 Thread Dipo Elegbede
Thumbs up Tom.

I didn't even bother to open the links you sent, I just finished the
tutorial.
The name of the link said it all, capturing-text-in urls.

I am most grateful.

thanks all.

I would have to read the links however to master these things.

Regards.

On Fri, Feb 18, 2011 at 4:20 PM, Tom Evans  wrote:

> On Fri, Feb 18, 2011 at 3:04 PM, Dipo Elegbede 
> wrote:
> >
> > Hi all,
> > i am currently reading the django book and following the examples step by
> step.
> > I have a view defined as follows:
> > from django.http import Http404, HttpResponse
> > import datetime
> > #def myhome(request):
> > #message = """
> > #MY HOME
> > #
> > #
> > #
> > #
> > # 
> > #"""
> > #return HttpResponse(message)
> > #
> > #def hello(request):
> > #return HttpResponse("Hello World")
> > #
> > #def current_time(request):
> > #now = datetime.datetime.now()
> > #html = "It is now %s." % now
> > #return HttpResponse(html)
> >
> > def hours_ahead(request, offset):
> > try:
> > offset = int(offset)
> > except ValueError:
> > raise Http404()
> > dt = datetime.datetime.now() + datetime.timedelta(hours=offset)
> > html = "In %s hour(s), it will be %s." %
> (offset, dt)
> > return HttpResponse(html)
> > (All the commented area work just fine )
> > and I have a url.py like this:
> > from django.conf.urls.defaults import *
> > from mysite.views import *
> > from django.contrib import admin
> > admin.autodiscover()
> > urlpatterns = patterns('',
> > (r'^$', myhome),
> > (r'^polls/', include('mysite.polls.urls')),
> > (r'^hello/$', hello),
> > (r'^time/$', current_time),
> > (r'^time/plus/\d{1,2}/$', hours_ahead),
> > )
> > when i try to run localhost:8000/time/plus/3, I get the following error:
> > TypeError at /time/plus/4/
> > hours_ahead() takes exactly 2 arguments (1 given)
> > Request Method: GET
> > Request URL: http://localhost:8000/time/plus/4/
> > Django Version: 1.2.1
> > Exception Type: TypeError
> > Exception Value:
> > hours_ahead() takes exactly 2 arguments (1 given)
> > Exception Location:
> c:\Python26\lib\site-packages\django-1.2.1-py2.6.egg\django\core\handlers\base.py
> in get_response, line 100
> > Python Executable: c:\Python26\python.exe
> > Python Version: 2.6.4
> > Server time: Fri, 18 Feb 2011 15:51:57 +0100
> > My understanding of the error message is that I supplied, 1 argument when
> the view function, hours_ahead was expecting 2 but really, i don't have a
> hang of where to put the other argument. I am following the examples in the
> book.
> > I must be missing something, kindly help me out.
> > thank you.
> >
> >
> >
>
> These should help you:
>
> http://docs.djangoproject.com/en/1.2/topics/http/urls/#named-groups
>
> http://docs.djangoproject.com/en/1.2/topics/http/urls/#notes-on-capturing-text-in-urls
>
> Also, please configure your MUA to wrap lines at ~78 characters when
> sending emails to mailing lists.
>
> 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.
>
>


-- 
Elegbede Muhammed Oladipupo
OCA
+2348077682428
+2347042171716
www.dudupay.com
Mobile Banking Solutions | Transaction Processing | Enterprise Application
Development

-- 
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: db_manager with add method

2011-02-18 Thread beyond liu
Sorry I forgot to give the link to the ticket:
http://code.djangoproject.com/ticket/13358

On Fri, Feb 18, 2011 at 9:16 PM, Leon Liu  wrote:
> Regarding the ticket13358, the status of it is fixed.
>
> Does this work for RelatedManager's add() method as well? I tried with
> all(), and it did pick the right database. But with add(), it doesn't
> seem to work. I am using django 1.2.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.



Re: django book example HELP..

2011-02-18 Thread Tom Evans
On Fri, Feb 18, 2011 at 3:04 PM, Dipo Elegbede  wrote:
>
> Hi all,
> i am currently reading the django book and following the examples step by 
> step.
> I have a view defined as follows:
> from django.http import Http404, HttpResponse
> import datetime
> #def myhome(request):
> #    message = """
> #                        MY HOME
> #                        
> #                            
> #                            
> #                        
> #                 
> #                """
> #    return HttpResponse(message)
> #
> #def hello(request):
> #    return HttpResponse("Hello World")
> #
> #def current_time(request):
> #    now = datetime.datetime.now()
> #    html = "It is now %s." % now
> #    return HttpResponse(html)
>
> def hours_ahead(request, offset):
>     try:
>         offset = int(offset)
>     except ValueError:
>         raise Http404()
>     dt = datetime.datetime.now() + datetime.timedelta(hours=offset)
>     html = "In %s hour(s), it will be %s." % 
> (offset, dt)
>     return HttpResponse(html)
> (All the commented area work just fine )
> and I have a url.py like this:
> from django.conf.urls.defaults import *
> from mysite.views import *
> from django.contrib import admin
> admin.autodiscover()
> urlpatterns = patterns('',
>     (r'^$', myhome),
>     (r'^polls/', include('mysite.polls.urls')),
>     (r'^hello/$', hello),
>     (r'^time/$', current_time),
>     (r'^time/plus/\d{1,2}/$', hours_ahead),
> )
> when i try to run localhost:8000/time/plus/3, I get the following error:
> TypeError at /time/plus/4/
> hours_ahead() takes exactly 2 arguments (1 given)
> Request Method: GET
> Request URL: http://localhost:8000/time/plus/4/
> Django Version: 1.2.1
> Exception Type: TypeError
> Exception Value:
> hours_ahead() takes exactly 2 arguments (1 given)
> Exception Location: 
> c:\Python26\lib\site-packages\django-1.2.1-py2.6.egg\django\core\handlers\base.py
>  in get_response, line 100
> Python Executable: c:\Python26\python.exe
> Python Version: 2.6.4
> Server time: Fri, 18 Feb 2011 15:51:57 +0100
> My understanding of the error message is that I supplied, 1 argument when the 
> view function, hours_ahead was expecting 2 but really, i don't have a hang of 
> where to put the other argument. I am following the examples in the book.
> I must be missing something, kindly help me out.
> thank you.
>
>
>

These should help you:

http://docs.djangoproject.com/en/1.2/topics/http/urls/#named-groups
http://docs.djangoproject.com/en/1.2/topics/http/urls/#notes-on-capturing-text-in-urls

Also, please configure your MUA to wrap lines at ~78 characters when
sending emails to mailing lists.

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: confused about ModelForm Field validation

2011-02-18 Thread Roman Klesel
2011/2/18 Roman Klesel :

>> I would use pre_save signal for data modification

did not really work. In any case I need to use to_python so that the
ModelForm displays the right value, and then I'm in *BEEP*, since
to_python not only receives the values from the db but also get's
passed the return value from the FormField.clean() method...

So I still see no other way then what I'm doing in the first post.

Anyone else having a weird legacy database and a solution/idea for this?

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



django book example HELP..

2011-02-18 Thread Dipo Elegbede
Hi all,

i am currently reading the django book and following the examples step by
step.

I have a view defined as follows:

from django.http import Http404, HttpResponse
import datetime

#def myhome(request):
#message = """
#MY HOME
#
#
#This is my
way of
saying welcome!
#
#
# 
#"""
#return HttpResponse(message)
#
#def hello(request):
#return HttpResponse("Hello World")
#
#def current_time(request):
#now = datetime.datetime.now()
#html = "It is now %s." % now
#return HttpResponse(html)

def hours_ahead(request, offset):
try:
offset = int(offset)
except ValueError:
raise Http404()
dt = datetime.datetime.now() + datetime.timedelta(hours=offset)
html = "In %s hour(s), it will be %s." %
(offset, dt)
return HttpResponse(html)

(All the commented area work just fine )

and I have a url.py like this:

from django.conf.urls.defaults import *
from mysite.views import *
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
(r'^$', myhome),
(r'^polls/', include('mysite.polls.urls')),
(r'^hello/$', hello),
(r'^time/$', current_time),
(r'^time/plus/\d{1,2}/$', hours_ahead),
)

when i try to run localhost:8000/time/plus/3, I get the following error:

TypeError at /time/plus/4/
hours_ahead() takes exactly 2 arguments (1 given)
Request Method: GET
Request URL: http://localhost:8000/time/plus/4/
Django Version: 1.2.1
Exception Type: TypeError
Exception Value:
hours_ahead() takes exactly 2 arguments (1 given)
Exception Location:
c:\Python26\lib\site-packages\django-1.2.1-py2.6.egg\django\core\handlers\base.py
in get_response, line 100
Python Executable: c:\Python26\python.exe
Python Version: 2.6.4
Python Path: ['c:\\users\\owner\\desktop\\djtask\\mysite',
'c:\\Python26\\lib\\site-packages\\django-1.2.1-py2.6.egg',
'c:\\Python26\\lib\\site-packages\\pip-0.8.2-py2.6.egg',
'C:\\Windows\\system32\\python26.zip', 'c:\\Python26\\DLLs',
'c:\\Python26\\lib', 'c:\\Python26\\lib\\plat-win',
'c:\\Python26\\lib\\lib-tk', 'c:\\Python26',
'c:\\Python26\\lib\\site-packages', 'c:\\Python26\\lib\\site-packages\\PIL',
'c:\\Python26\\lib\\site-packages\\wx-2.8-msw-unicode']
Server time: Fri, 18 Feb 2011 15:51:57 +0100

My understanding of the error message is that I supplied, 1 argument when
the view function, hours_ahead was expecting 2 but really, i don't have a
hang of where to put the other argument. I am following the examples in the
book.

I must be missing something, kindly help me out.

thank you.







-- 
Elegbede Muhammed Oladipupo
OCA
+2348077682428
+2347042171716
www.dudupay.com
Mobile Banking Solutions | Transaction Processing | Enterprise Application
Development

-- 
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: Just going to point this out ...

2011-02-18 Thread dave b
> Which of course it can't - it is properly escaped.
>
> Cheers
>
> Tom
>

Yes.

-- 
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: Just going to point this out ...

2011-02-18 Thread Tom Evans
On Fri, Feb 18, 2011 at 1:52 PM, dave b  wrote:
> Hi I cannot see where in the django documentation it states that you
> shouldn't do something like this:
>   ** (as an example of a potential
> attribute injection vector[0] - where you are not using a URLField or
> failure to call full_clean (on a URLField) ).
> That is I cannot see where django states that 'oh by the way our
> autoescape isn't safe in a few cases' and 'you should watch out for
> attribute injection!'.
>
> So did I miss it?
>
> [0] - the user-controlled link could be javascript:alert(1)
>
>
>

Aha, I thought this was more interesting than it was. Obviously, if
you stick user generated input into a HTML attribute, then the value
of that HTML attribute is controlled by the user (and that should be
obvious enough that it shouldn't need to be mentioned..)

I thought you were inferring that something like this could be dangerous:
ctxt=Context({'user_input': '" onclick="alert(\'pwned\')'})
tmpl=Template('foo')
tmpl.render(ctxt)

Which of course it can't - it is properly escaped.

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: Just going to point this out ...

2011-02-18 Thread dave b
On 19 February 2011 01:36, Masklinn  wrote:
> On 2011-02-18, at 15:31 , dave b wrote:
>> On 19 February 2011 01:29, Shawn Milochik  wrote:
>>> By the way -- I realized what happened. You CC'd me on the e-mail to the 
>>> list. So when I replied it went directly to you.
>>
>> Ah sorry about the mix up then!
>> Yeah :P
>>
>> My view on this is that documentation can always be improved !
> Sure, but the way to do it is usually to open a bug on the tracker and 
> provide a documentation patch (or alternatively find a way to fix the issue 
> itself, but as far as I can tell if you're putting unchecked unvalidated data 
> in your links there isn't much that can be done to help you).

Um, no I am not. I was using href with javascript as an example.

Example for Cal:

views.py
from django.shortcuts import render_to_response

def show_lol(response):
   return render_to_response("lol.html", {"lol" :
"javascript:alert(document.cookie)"} )

lol.html


   

OKOKOKOK
   



Yes this is very contrived.
If you used a URLField and the validator runs - this will not be saved
in the first place. Please do keep in mind that this is just a dumb
example of attribute abuse.
(./sleep &) Sorry I am very tired atm - it isn't attribute injection -
just abuse.

-- 
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: Just going to point this out ...

2011-02-18 Thread Masklinn
On 2011-02-18, at 15:31 , dave b wrote:
> On 19 February 2011 01:29, Shawn Milochik  wrote:
>> By the way -- I realized what happened. You CC'd me on the e-mail to the 
>> list. So when I replied it went directly to you.
> 
> Ah sorry about the mix up then!
> Yeah :P
> 
> My view on this is that documentation can always be improved !
Sure, but the way to do it is usually to open a bug on the tracker and provide 
a documentation patch (or alternatively find a way to fix the issue itself, but 
as far as I can tell if you're putting unchecked unvalidated data in your links 
there isn't much that can be done to help 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: Just going to point this out ...

2011-02-18 Thread Cal Leeming [Simplicity Media Ltd]
Dave, may I ask you to provide some proof of concept code in regards to
this? It'll also make life a lot easier for you when submitting a bug report
to the django devs.

On Fri, Feb 18, 2011 at 2:22 PM, dave b  wrote:

> On 19 February 2011 01:19, Shawn Milochik  wrote:
> > Don't take my comment as a personal attack. I was just pointing out that
> injection attacks are one of those things we're all responsible for being
> aware of and not opening ourselves up to.
> >
> > To the extent that Django protects us from such things, it's generally to
> ensure that the boilerplate Django saves us from writing (by baking it in)
> is safe.
> >
> > My point is that using Django doesnt relieve us of the responsibility of
> knowing what we're doing.
> >
> > Shawn
>
> Oh how nice you sent this to me off the list?
>
> Ok great. How about you get off your damn high horse and settle with
> us mortals ?
>
> Wait a second when I read your email it sounds like you accept the
> fact that people "should know what they are doing" ... but you didn't
> answer my question or _suggest_ that some minor note be added to the
> template documentation.
>
> --
> 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: Just going to point this out ...

2011-02-18 Thread dave b
On 19 February 2011 01:29, Shawn Milochik  wrote:
> By the way -- I realized what happened. You CC'd me on the e-mail to the 
> list. So when I replied it went directly to you.

Ah sorry about the mix up then!
Yeah :P

My view on this is that documentation can always be improved !

-- 
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: list indices must be integers not unicode

2011-02-18 Thread gladys
Since the question ids are just positive integers, you might want to
check them like this
for i in temp_list:
if i.is_digit():# this line determines whether the key is
a positive integer or not
   # code goes here
   ...

Your design is not very good. I would suggest you use a FormSet
instead (http://docs.djangoproject.com/en/dev/topics/forms/formsets/)
and have the Question-Answer association defined within a Form.

--
Gladys
http://bixly.com


On Feb 18, 10:24 pm, balu  wrote:
> All my question Ids are integers only. Should I use regular
> expressions to filter them?? How to exclude the remaining keys.
>
> On Feb 18, 6:09 pm, balu  wrote:
>
>
>
>
>
>
>
> > Can you please show the way to filter. Please...
>
> > On Feb 18, 5:36 pm, Burhan  wrote:
>
> > > You need to filter your search in request.POST for fields that match
> > > your forms. The post querydict will hold all fields submitted in the
> > > form, in your case the error is because you are trying to convert
> > > 'csrfmiddlewaretoken' (a key in POST) to an integer which is not
> > > possible.
>
> > > On Feb 18, 3:27 pm, balu  wrote:
>
> > > > now it is showing a ValueError.
>
> > > > Exception Value: invalid literal for int() with base 10.
> > > > 'csrfmiddlewaretoken'
>
> > > > On Feb 18, 5:06 pm, Chris Matthews  wrote:
>
> > > > > Then you probably want:
> > > > >     id_list = [int(x) for x in data.keys()]
>
> > > > > -Original Message-
> > > > > From: django-users@googlegroups.com 
> > > > > [mailto:django-users@googlegroups.com] On Behalf Of balu
> > > > > Sent: 18 February 2011 13:56
> > > > > To: Django users
> > > > > Subject: Re: list indices must be integers not unicode
>
> > > > > Thank you Chris Matthews for your reply.
>
> > > > > I'm working on a online examination system. I could able to generate
> > > > > some random questions from a data base containg hundreds of questions.
> > > > > So when ever a user answer and submit those random questions a
> > > > > dictionary contating a "Question_id and Answer" pair will be send as a
> > > > > request.
>
> > > > > Now I have to get those dictionary keys first, i.e., the Question_id
> > > > > and then I have to cross  check the values i.e., the values with the
> > > > > database values.
>
> > > > > On Feb 18, 4:37 pm, Chris Matthews  wrote:
> > > > > > Oh and you probably wanted:
>
> > > > > >     if request.method=="POST":
>
> > > > > >         data = request.POST
>
> > > > > >        id_list = [int(x) for x in data.values()]
>
> > > > > >        questions = MyModel.objects.filter(id__in = id_list)
>
> > > > > > From: django-users@googlegroups.com 
> > > > > > [mailto:django-users@googlegroups.com] On Behalf Of Chris Matthews
> > > > > > Sent: 18 February 2011 13:34
> > > > > > To: django-users@googlegroups.com
> > > > > > Subject: RE: list indices must be integers not unicode
>
> > > > > > Hi Balu,
>
> > > > > > Numeric data from the form must be converted to int. I suspect you 
> > > > > > wanted to index data; not id_list.
>
> > > > > >     if request.method=="POST":
>
> > > > > >         data = request.POST
>
> > > > > >         temp_list = data.keys()
>
> > > > > >         id_list = []
>
> > > > > >        for i in temp_list:
>
> > > > > >              id_list.append(id_list[i])
>
> > > > > >        questions = MyModel.objects.filter(id__in = id_list)
>
> > > > > > Should
>
> > > > > > id_list.append(id_list[i])
>
> > > > > > Not be
>
> > > > > > id_list.append(data[i])
>
> > > > > > -Original Message-
> > > > > > From: django-users@googlegroups.com 
> > > > > > [mailto:django-users@googlegroups.com] On Behalf Of balu
> > > > > > Sent: 18 February 2011 13:24
> > > > > > To: Django users
> > > > > > Subject: list indices must be integers not unicode
>
> > > > > > Hi all :)
>
> > > > > > I'm processing a user submitted form. In that the user will answer a
>
> > > > > > series of multiple choice questions. Depending on the question "id"
>
> > > > > > which are submitted I'll find the compare the values and increment 
> > > > > > the
>
> > > > > > score to count his marks.
>
> > > > > > The question ids are  keys from the dictionary request.POST. But it 
> > > > > > is
>
> > > > > > showing an error the list indices must be integers not unicode. I
>
> > > > > > wrote the code as follows.
>
> > > > > > // In the view function
>
> > > > > >     if request.method=="POST":
>
> > > > > >         data = reques.POST
>
> > > > > >         temp_list = data.keys()
>
> > > > > >         id_list = []
>
> > > > > >        for i in temp_list:
>
> > > > > >              id_list.append(id_list[i])
>
> > > > > >        questions = MyModel.objects.filter(id__in = id_list)
>
> > > > > > --
>
> > > > > > You received this message because you are subscribed to the Google 
> > > > > > Groups "Django users" group.
>
> > > > > > To post to this group, 

Re: How to pivot a table?

2011-02-18 Thread Derek
On Feb 17, 10:52 pm, Phlip  wrote:
> Djangoists:
>
> I have a database table like this...
>
>   red, 1
>   red, 2
>   red, 15
>   blue, 18
>   blue, 20
>
> ...and I want to read it into an array like this:
>
>   [ ['red', [1,2,15]], ['blue', [18,20]], ]
>
> Of course I can use values_list('color', 'number'), and then re-pack
> the array with a for-loop.
>
> Do QuerySet aggregations and annotations offer some way to push that
> query into the database?

Assuming you want an output in array format (as per the first part of
your question):
http://stackoverflow.com/questions/1859031/how-could-create-a-crosstab-sql-query-with-django-orm

-- 
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: Just going to point this out ...

2011-02-18 Thread dave b
On 19 February 2011 01:19, Shawn Milochik  wrote:
> Don't take my comment as a personal attack. I was just pointing out that 
> injection attacks are one of those things we're all responsible for being 
> aware of and not opening ourselves up to.
>
> To the extent that Django protects us from such things, it's generally to 
> ensure that the boilerplate Django saves us from writing (by baking it in) is 
> safe.
>
> My point is that using Django doesnt relieve us of the responsibility of 
> knowing what we're doing.
>
> Shawn

Oh how nice you sent this to me off the list?

Ok great. How about you get off your damn high horse and settle with
us mortals ?

Wait a second when I read your email it sounds like you accept the
fact that people "should know what they are doing" ... but you didn't
answer my question or _suggest_ that some minor note be added to the
template documentation.

-- 
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 reinstall Python Interpreters?

2011-02-18 Thread CrabbyPete
I wouldn't reinstall python because of an unresolved import error.
What's unresolved and what type of system are you on PC/Linux?

On Feb 17, 7:48 pm, LJ  wrote:
> I installed the latest version of dajaxice, but I am still getting
> Unresolved import errors.
> My guess is that I need to remove and reinstall the Python
> Interpreters.
> Is there a some documentation somewhere that explains how to reinstall
> the Python Interpreters, so I can resolve all of my Unresolved Import
> errors?

-- 
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: Just going to point this out ...

2011-02-18 Thread dave b
 On 19 February 2011 00:57, Shawn Milochik  wrote:
> I also didn't see the part where they state that you shouldn't put your
> database login information in a template. That's probably because Django is
> designed to allow Web developers to do their jobs more easily, not allow
> people who don't know what they're doing make Web applications. If you're
> going to do something really stupid then blame Django in some way, then
> you're probably not competent at the job.

Um. While it might be obvious to us it might not be so obvious to others.
So this comment,
" If you're going to do something really stupid then blame Django in
some way, then  you're probably not competent at the job" shows a lack
of thought  for other users given the way the django documentation
found at [0] is presented.

[0] - 
http://docs.djangoproject.com/en/dev/topics/templates/#automatic-html-escaping

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



db_manager with add method

2011-02-18 Thread Leon Liu
Regarding the ticket13358, the status of it is fixed.

Does this work for RelatedManager's add() method as well? I tried with
all(), and it did pick the right database. But with add(), it doesn't
seem to work. I am using django 1.2.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.



Re: Just going to point this out ...

2011-02-18 Thread Shawn Milochik
I also didn't see the part where they state that you shouldn't put your 
database login information in a template. That's probably because Django 
is designed to allow Web developers to do their jobs more easily, not 
allow people who don't know what they're doing make Web applications. If 
you're going to do something really stupid then blame Django in some 
way, then you're probably not competent at the job.





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



Just going to point this out ...

2011-02-18 Thread dave b
Hi I cannot see where in the django documentation it states that you
shouldn't do something like this:
  ** (as an example of a potential
attribute injection vector[0] - where you are not using a URLField or
failure to call full_clean (on a URLField) ).
That is I cannot see where django states that 'oh by the way our
autoescape isn't safe in a few cases' and 'you should watch out for
attribute injection!'.

So did I miss it?

[0] - the user-controlled link could be javascript:alert(1)



--
The fashion wears out more apparel than the man.-- William
Shakespeare, "Much Ado About Nothing"

-- 
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: list indices must be integers not unicode

2011-02-18 Thread balu
How to recognize a key. All the question Ids will be integers only.
Should I have to use regular expressions to use that?? How to exclude
the remaining keys

On Feb 18, 6:09 pm, balu  wrote:
> Can you please show the way to filter. Please...
>
> On Feb 18, 5:36 pm, Burhan  wrote:
>
>
>
> > You need to filter your search in request.POST for fields that match
> > your forms. The post querydict will hold all fields submitted in the
> > form, in your case the error is because you are trying to convert
> > 'csrfmiddlewaretoken' (a key in POST) to an integer which is not
> > possible.
>
> > On Feb 18, 3:27 pm, balu  wrote:
>
> > > now it is showing a ValueError.
>
> > > Exception Value: invalid literal for int() with base 10.
> > > 'csrfmiddlewaretoken'
>
> > > On Feb 18, 5:06 pm, Chris Matthews  wrote:
>
> > > > Then you probably want:
> > > >     id_list = [int(x) for x in data.keys()]
>
> > > > -Original Message-
> > > > From: django-users@googlegroups.com 
> > > > [mailto:django-users@googlegroups.com] On Behalf Of balu
> > > > Sent: 18 February 2011 13:56
> > > > To: Django users
> > > > Subject: Re: list indices must be integers not unicode
>
> > > > Thank you Chris Matthews for your reply.
>
> > > > I'm working on a online examination system. I could able to generate
> > > > some random questions from a data base containg hundreds of questions.
> > > > So when ever a user answer and submit those random questions a
> > > > dictionary contating a "Question_id and Answer" pair will be send as a
> > > > request.
>
> > > > Now I have to get those dictionary keys first, i.e., the Question_id
> > > > and then I have to cross  check the values i.e., the values with the
> > > > database values.
>
> > > > On Feb 18, 4:37 pm, Chris Matthews  wrote:
> > > > > Oh and you probably wanted:
>
> > > > >     if request.method=="POST":
>
> > > > >         data = request.POST
>
> > > > >        id_list = [int(x) for x in data.values()]
>
> > > > >        questions = MyModel.objects.filter(id__in = id_list)
>
> > > > > From: django-users@googlegroups.com 
> > > > > [mailto:django-users@googlegroups.com] On Behalf Of Chris Matthews
> > > > > Sent: 18 February 2011 13:34
> > > > > To: django-users@googlegroups.com
> > > > > Subject: RE: list indices must be integers not unicode
>
> > > > > Hi Balu,
>
> > > > > Numeric data from the form must be converted to int. I suspect you 
> > > > > wanted to index data; not id_list.
>
> > > > >     if request.method=="POST":
>
> > > > >         data = request.POST
>
> > > > >         temp_list = data.keys()
>
> > > > >         id_list = []
>
> > > > >        for i in temp_list:
>
> > > > >              id_list.append(id_list[i])
>
> > > > >        questions = MyModel.objects.filter(id__in = id_list)
>
> > > > > Should
>
> > > > > id_list.append(id_list[i])
>
> > > > > Not be
>
> > > > > id_list.append(data[i])
>
> > > > > -Original Message-
> > > > > From: django-users@googlegroups.com 
> > > > > [mailto:django-users@googlegroups.com] On Behalf Of balu
> > > > > Sent: 18 February 2011 13:24
> > > > > To: Django users
> > > > > Subject: list indices must be integers not unicode
>
> > > > > Hi all :)
>
> > > > > I'm processing a user submitted form. In that the user will answer a
>
> > > > > series of multiple choice questions. Depending on the question "id"
>
> > > > > which are submitted I'll find the compare the values and increment the
>
> > > > > score to count his marks.
>
> > > > > The question ids are  keys from the dictionary request.POST. But it is
>
> > > > > showing an error the list indices must be integers not unicode. I
>
> > > > > wrote the code as follows.
>
> > > > > // In the view function
>
> > > > >     if request.method=="POST":
>
> > > > >         data = reques.POST
>
> > > > >         temp_list = data.keys()
>
> > > > >         id_list = []
>
> > > > >        for i in temp_list:
>
> > > > >              id_list.append(id_list[i])
>
> > > > >        questions = MyModel.objects.filter(id__in = id_list)
>
> > > > > --
>
> > > > > 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 
> > > > > athttp://groups.google.com/group/django-users?hl=en.
>
> > > > > --
> > > > > You received this message because you are subscribed to the Google 
> > > > > Groups "Django users" group.
> > > > > To post to this group, send email to django-users@googlegroups.com.
> > > > > To unsubscribe from this group, send email to 
> > > > > django-users+unsubscr...@googlegroups.com.
> > > > > For more options, visit this group 
> > > > > 

Re: list indices must be integers not unicode

2011-02-18 Thread balu
All my question Ids are integers only. Should I use regular
expressions to filter them?? How to exclude the remaining keys.

On Feb 18, 6:09 pm, balu  wrote:
> Can you please show the way to filter. Please...
>
> On Feb 18, 5:36 pm, Burhan  wrote:
>
>
>
> > You need to filter your search in request.POST for fields that match
> > your forms. The post querydict will hold all fields submitted in the
> > form, in your case the error is because you are trying to convert
> > 'csrfmiddlewaretoken' (a key in POST) to an integer which is not
> > possible.
>
> > On Feb 18, 3:27 pm, balu  wrote:
>
> > > now it is showing a ValueError.
>
> > > Exception Value: invalid literal for int() with base 10.
> > > 'csrfmiddlewaretoken'
>
> > > On Feb 18, 5:06 pm, Chris Matthews  wrote:
>
> > > > Then you probably want:
> > > >     id_list = [int(x) for x in data.keys()]
>
> > > > -Original Message-
> > > > From: django-users@googlegroups.com 
> > > > [mailto:django-users@googlegroups.com] On Behalf Of balu
> > > > Sent: 18 February 2011 13:56
> > > > To: Django users
> > > > Subject: Re: list indices must be integers not unicode
>
> > > > Thank you Chris Matthews for your reply.
>
> > > > I'm working on a online examination system. I could able to generate
> > > > some random questions from a data base containg hundreds of questions.
> > > > So when ever a user answer and submit those random questions a
> > > > dictionary contating a "Question_id and Answer" pair will be send as a
> > > > request.
>
> > > > Now I have to get those dictionary keys first, i.e., the Question_id
> > > > and then I have to cross  check the values i.e., the values with the
> > > > database values.
>
> > > > On Feb 18, 4:37 pm, Chris Matthews  wrote:
> > > > > Oh and you probably wanted:
>
> > > > >     if request.method=="POST":
>
> > > > >         data = request.POST
>
> > > > >        id_list = [int(x) for x in data.values()]
>
> > > > >        questions = MyModel.objects.filter(id__in = id_list)
>
> > > > > From: django-users@googlegroups.com 
> > > > > [mailto:django-users@googlegroups.com] On Behalf Of Chris Matthews
> > > > > Sent: 18 February 2011 13:34
> > > > > To: django-users@googlegroups.com
> > > > > Subject: RE: list indices must be integers not unicode
>
> > > > > Hi Balu,
>
> > > > > Numeric data from the form must be converted to int. I suspect you 
> > > > > wanted to index data; not id_list.
>
> > > > >     if request.method=="POST":
>
> > > > >         data = request.POST
>
> > > > >         temp_list = data.keys()
>
> > > > >         id_list = []
>
> > > > >        for i in temp_list:
>
> > > > >              id_list.append(id_list[i])
>
> > > > >        questions = MyModel.objects.filter(id__in = id_list)
>
> > > > > Should
>
> > > > > id_list.append(id_list[i])
>
> > > > > Not be
>
> > > > > id_list.append(data[i])
>
> > > > > -Original Message-
> > > > > From: django-users@googlegroups.com 
> > > > > [mailto:django-users@googlegroups.com] On Behalf Of balu
> > > > > Sent: 18 February 2011 13:24
> > > > > To: Django users
> > > > > Subject: list indices must be integers not unicode
>
> > > > > Hi all :)
>
> > > > > I'm processing a user submitted form. In that the user will answer a
>
> > > > > series of multiple choice questions. Depending on the question "id"
>
> > > > > which are submitted I'll find the compare the values and increment the
>
> > > > > score to count his marks.
>
> > > > > The question ids are  keys from the dictionary request.POST. But it is
>
> > > > > showing an error the list indices must be integers not unicode. I
>
> > > > > wrote the code as follows.
>
> > > > > // In the view function
>
> > > > >     if request.method=="POST":
>
> > > > >         data = reques.POST
>
> > > > >         temp_list = data.keys()
>
> > > > >         id_list = []
>
> > > > >        for i in temp_list:
>
> > > > >              id_list.append(id_list[i])
>
> > > > >        questions = MyModel.objects.filter(id__in = id_list)
>
> > > > > --
>
> > > > > 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 
> > > > > athttp://groups.google.com/group/django-users?hl=en.
>
> > > > > --
> > > > > You received this message because you are subscribed to the Google 
> > > > > Groups "Django users" group.
> > > > > To post to this group, send email to django-users@googlegroups.com.
> > > > > To unsubscribe from this group, send email to 
> > > > > django-users+unsubscr...@googlegroups.com.
> > > > > For more options, visit this group 
> > > > > athttp://groups.google.com/group/django-users?hl=en.-Hidequotedtext-
>
> > > > > - Show quoted 

Re: South - when to start?

2011-02-18 Thread Piotr Zalewa
I'm mostly looking for a solution which would work for front-end devs
who start early in the process (some part of app is written and they may
jump on the UI). I guess South before 2 is a must then.

I heard it's dead simple, I guess a little practice in writing
migrations will not kill me.

Thanks
zalun
On 02/18/11 13:11, Grigoriy Petukhov wrote:
> I have found nice way to do quick development on 1st and 2nd steps you
> have mentioned.
> 
> I've put following instructions in reset.sh:
>  * Drop database
>  * Create new database
>  * Run ./manage.py syncdb
>  * Generate sample data
> 
> When I change some model then I just run reset.sh. That works even for
> several developers. If you pull someone changes then you run reset.sh
> and get actual database state. It really saves time because you do not
> need to spend your time writing migrations for schema and data.
> 
> Of course, this method is not good if generating sample data takes a
> lot of time. In such case migrating could be better solution.
> 
> On 18 фев, 16:24, Piotr Zalewa  wrote:
>> Where is the best moment to start with south?
>>
>> 1. The very beginning, as the first app added to the project?
>> 2. At the moment when more devs will be involved?
>> 3. When real data will start to show?
>>
>> I'm building a new system, I think the current model progress is about
>> 20%, where 100% is the moment I will put the site on the server. I'm
>> very close to point 2.
>>
>> zalun
>> --
>> blog  http://piotr.zalewa.info
>> jobs  http://webdev.zalewa.info
>> twit  http://twitter.com/zalun
>> face  http://facebook.com/zaloon
> 


-- 
blog  http://piotr.zalewa.info
jobs  http://webdev.zalewa.info
twit  http://twitter.com/zalun
face  http://facebook.com/zaloon

-- 
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: South - when to start?

2011-02-18 Thread Grigoriy Petukhov
I have found nice way to do quick development on 1st and 2nd steps you
have mentioned.

I've put following instructions in reset.sh:
 * Drop database
 * Create new database
 * Run ./manage.py syncdb
 * Generate sample data

When I change some model then I just run reset.sh. That works even for
several developers. If you pull someone changes then you run reset.sh
and get actual database state. It really saves time because you do not
need to spend your time writing migrations for schema and data.

Of course, this method is not good if generating sample data takes a
lot of time. In such case migrating could be better solution.

On 18 фев, 16:24, Piotr Zalewa  wrote:
> Where is the best moment to start with south?
>
> 1. The very beginning, as the first app added to the project?
> 2. At the moment when more devs will be involved?
> 3. When real data will start to show?
>
> I'm building a new system, I think the current model progress is about
> 20%, where 100% is the moment I will put the site on the server. I'm
> very close to point 2.
>
> zalun
> --
> blog  http://piotr.zalewa.info
> jobs  http://webdev.zalewa.info
> twit  http://twitter.com/zalun
> face  http://facebook.com/zaloon

-- 
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: list indices must be integers not unicode

2011-02-18 Thread balu
Can you please show the way to filter. Please...

On Feb 18, 5:36 pm, Burhan  wrote:
> You need to filter your search in request.POST for fields that match
> your forms. The post querydict will hold all fields submitted in the
> form, in your case the error is because you are trying to convert
> 'csrfmiddlewaretoken' (a key in POST) to an integer which is not
> possible.
>
> On Feb 18, 3:27 pm, balu  wrote:
>
>
>
> > now it is showing a ValueError.
>
> > Exception Value: invalid literal for int() with base 10.
> > 'csrfmiddlewaretoken'
>
> > On Feb 18, 5:06 pm, Chris Matthews  wrote:
>
> > > Then you probably want:
> > >     id_list = [int(x) for x in data.keys()]
>
> > > -Original Message-
> > > From: django-users@googlegroups.com 
> > > [mailto:django-users@googlegroups.com] On Behalf Of balu
> > > Sent: 18 February 2011 13:56
> > > To: Django users
> > > Subject: Re: list indices must be integers not unicode
>
> > > Thank you Chris Matthews for your reply.
>
> > > I'm working on a online examination system. I could able to generate
> > > some random questions from a data base containg hundreds of questions.
> > > So when ever a user answer and submit those random questions a
> > > dictionary contating a "Question_id and Answer" pair will be send as a
> > > request.
>
> > > Now I have to get those dictionary keys first, i.e., the Question_id
> > > and then I have to cross  check the values i.e., the values with the
> > > database values.
>
> > > On Feb 18, 4:37 pm, Chris Matthews  wrote:
> > > > Oh and you probably wanted:
>
> > > >     if request.method=="POST":
>
> > > >         data = request.POST
>
> > > >        id_list = [int(x) for x in data.values()]
>
> > > >        questions = MyModel.objects.filter(id__in = id_list)
>
> > > > From: django-users@googlegroups.com 
> > > > [mailto:django-users@googlegroups.com] On Behalf Of Chris Matthews
> > > > Sent: 18 February 2011 13:34
> > > > To: django-users@googlegroups.com
> > > > Subject: RE: list indices must be integers not unicode
>
> > > > Hi Balu,
>
> > > > Numeric data from the form must be converted to int. I suspect you 
> > > > wanted to index data; not id_list.
>
> > > >     if request.method=="POST":
>
> > > >         data = request.POST
>
> > > >         temp_list = data.keys()
>
> > > >         id_list = []
>
> > > >        for i in temp_list:
>
> > > >              id_list.append(id_list[i])
>
> > > >        questions = MyModel.objects.filter(id__in = id_list)
>
> > > > Should
>
> > > > id_list.append(id_list[i])
>
> > > > Not be
>
> > > > id_list.append(data[i])
>
> > > > -Original Message-
> > > > From: django-users@googlegroups.com 
> > > > [mailto:django-users@googlegroups.com] On Behalf Of balu
> > > > Sent: 18 February 2011 13:24
> > > > To: Django users
> > > > Subject: list indices must be integers not unicode
>
> > > > Hi all :)
>
> > > > I'm processing a user submitted form. In that the user will answer a
>
> > > > series of multiple choice questions. Depending on the question "id"
>
> > > > which are submitted I'll find the compare the values and increment the
>
> > > > score to count his marks.
>
> > > > The question ids are  keys from the dictionary request.POST. But it is
>
> > > > showing an error the list indices must be integers not unicode. I
>
> > > > wrote the code as follows.
>
> > > > // In the view function
>
> > > >     if request.method=="POST":
>
> > > >         data = reques.POST
>
> > > >         temp_list = data.keys()
>
> > > >         id_list = []
>
> > > >        for i in temp_list:
>
> > > >              id_list.append(id_list[i])
>
> > > >        questions = MyModel.objects.filter(id__in = id_list)
>
> > > > --
>
> > > > 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 
> > > > athttp://groups.google.com/group/django-users?hl=en.
>
> > > > --
> > > > You received this message because you are subscribed to the Google 
> > > > Groups "Django users" group.
> > > > To post to this group, send email to django-users@googlegroups.com.
> > > > To unsubscribe from this group, send email to 
> > > > django-users+unsubscr...@googlegroups.com.
> > > > For more options, visit this group 
> > > > athttp://groups.google.com/group/django-users?hl=en.-Hidequotedtext -
>
> > > > - Show quoted text -
>
> > > --
> > > 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 
> > > 

password_reset only for not loggedin

2011-02-18 Thread galago
is it possible, to deny access to django.contrib.auth.views.password_reset 
for users who are authenticated?
I want to use it, and make it only for not logged in.

I can't figure out how to do that. I have done all things with reset, but 
all users can enter 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.



Re: request in urls.py

2011-02-18 Thread Burhan
urls.py doesn't do anything with GET or POST requests, its just
regular expression to method mapping.

So you can pass whatever you want to the link, and they will all work.

For example, in your urls.py you have:

(r'^logout$', logout_user)

All these requests will be passed to your logout_user method:

/logout
/logout?next=/home
/logout?next=/home/=bar


def logout_user(request):

   # - do your logout routine
   next = request.GET.get('next','/home')
   return redirect(next)

Hope this helps,
--
Burhan Khalid

On Feb 18, 1:15 pm, galago  wrote:
> Is it possible to pass request.path in urls.py? I want to pass it as next
> parameter in logout declaration.

-- 
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: list indices must be integers not unicode

2011-02-18 Thread Burhan
You need to filter your search in request.POST for fields that match
your forms. The post querydict will hold all fields submitted in the
form, in your case the error is because you are trying to convert
'csrfmiddlewaretoken' (a key in POST) to an integer which is not
possible.

On Feb 18, 3:27 pm, balu  wrote:
> now it is showing a ValueError.
>
> Exception Value: invalid literal for int() with base 10.
> 'csrfmiddlewaretoken'
>
> On Feb 18, 5:06 pm, Chris Matthews  wrote:
>
>
>
> > Then you probably want:
> >     id_list = [int(x) for x in data.keys()]
>
> > -Original Message-
> > From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] 
> > On Behalf Of balu
> > Sent: 18 February 2011 13:56
> > To: Django users
> > Subject: Re: list indices must be integers not unicode
>
> > Thank you Chris Matthews for your reply.
>
> > I'm working on a online examination system. I could able to generate
> > some random questions from a data base containg hundreds of questions.
> > So when ever a user answer and submit those random questions a
> > dictionary contating a "Question_id and Answer" pair will be send as a
> > request.
>
> > Now I have to get those dictionary keys first, i.e., the Question_id
> > and then I have to cross  check the values i.e., the values with the
> > database values.
>
> > On Feb 18, 4:37 pm, Chris Matthews  wrote:
> > > Oh and you probably wanted:
>
> > >     if request.method=="POST":
>
> > >         data = request.POST
>
> > >        id_list = [int(x) for x in data.values()]
>
> > >        questions = MyModel.objects.filter(id__in = id_list)
>
> > > From: django-users@googlegroups.com 
> > > [mailto:django-users@googlegroups.com] On Behalf Of Chris Matthews
> > > Sent: 18 February 2011 13:34
> > > To: django-users@googlegroups.com
> > > Subject: RE: list indices must be integers not unicode
>
> > > Hi Balu,
>
> > > Numeric data from the form must be converted to int. I suspect you wanted 
> > > to index data; not id_list.
>
> > >     if request.method=="POST":
>
> > >         data = request.POST
>
> > >         temp_list = data.keys()
>
> > >         id_list = []
>
> > >        for i in temp_list:
>
> > >              id_list.append(id_list[i])
>
> > >        questions = MyModel.objects.filter(id__in = id_list)
>
> > > Should
>
> > > id_list.append(id_list[i])
>
> > > Not be
>
> > > id_list.append(data[i])
>
> > > -Original Message-
> > > From: django-users@googlegroups.com 
> > > [mailto:django-users@googlegroups.com] On Behalf Of balu
> > > Sent: 18 February 2011 13:24
> > > To: Django users
> > > Subject: list indices must be integers not unicode
>
> > > Hi all :)
>
> > > I'm processing a user submitted form. In that the user will answer a
>
> > > series of multiple choice questions. Depending on the question "id"
>
> > > which are submitted I'll find the compare the values and increment the
>
> > > score to count his marks.
>
> > > The question ids are  keys from the dictionary request.POST. But it is
>
> > > showing an error the list indices must be integers not unicode. I
>
> > > wrote the code as follows.
>
> > > // In the view function
>
> > >     if request.method=="POST":
>
> > >         data = reques.POST
>
> > >         temp_list = data.keys()
>
> > >         id_list = []
>
> > >        for i in temp_list:
>
> > >              id_list.append(id_list[i])
>
> > >        questions = MyModel.objects.filter(id__in = id_list)
>
> > > --
>
> > > 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 
> > > athttp://groups.google.com/group/django-users?hl=en.
>
> > > --
> > > You received this message because you are subscribed to the Google Groups 
> > > "Django users" group.
> > > To post to this group, send email to django-users@googlegroups.com.
> > > To unsubscribe from this group, send email to 
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group 
> > > athttp://groups.google.com/group/django-users?hl=en.-Hidequoted text -
>
> > > - Show quoted text -
>
> > --
> > 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 
> > athttp://groups.google.com/group/django-users?hl=en.-Hide quoted text -
>
> > - Show quoted text -

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

Re: list indices must be integers not unicode

2011-02-18 Thread balu
now it is showing a ValueError.

Exception Value: invalid literal for int() with base 10.
'csrfmiddlewaretoken'

On Feb 18, 5:06 pm, Chris Matthews  wrote:
> Then you probably want:
>     id_list = [int(x) for x in data.keys()]
>
>
>
> -Original Message-
> From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
> Behalf Of balu
> Sent: 18 February 2011 13:56
> To: Django users
> Subject: Re: list indices must be integers not unicode
>
> Thank you Chris Matthews for your reply.
>
> I'm working on a online examination system. I could able to generate
> some random questions from a data base containg hundreds of questions.
> So when ever a user answer and submit those random questions a
> dictionary contating a "Question_id and Answer" pair will be send as a
> request.
>
> Now I have to get those dictionary keys first, i.e., the Question_id
> and then I have to cross  check the values i.e., the values with the
> database values.
>
> On Feb 18, 4:37 pm, Chris Matthews  wrote:
> > Oh and you probably wanted:
>
> >     if request.method=="POST":
>
> >         data = request.POST
>
> >        id_list = [int(x) for x in data.values()]
>
> >        questions = MyModel.objects.filter(id__in = id_list)
>
> > From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] 
> > On Behalf Of Chris Matthews
> > Sent: 18 February 2011 13:34
> > To: django-users@googlegroups.com
> > Subject: RE: list indices must be integers not unicode
>
> > Hi Balu,
>
> > Numeric data from the form must be converted to int. I suspect you wanted 
> > to index data; not id_list.
>
> >     if request.method=="POST":
>
> >         data = request.POST
>
> >         temp_list = data.keys()
>
> >         id_list = []
>
> >        for i in temp_list:
>
> >              id_list.append(id_list[i])
>
> >        questions = MyModel.objects.filter(id__in = id_list)
>
> > Should
>
> > id_list.append(id_list[i])
>
> > Not be
>
> > id_list.append(data[i])
>
> > -Original Message-
> > From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] 
> > On Behalf Of balu
> > Sent: 18 February 2011 13:24
> > To: Django users
> > Subject: list indices must be integers not unicode
>
> > Hi all :)
>
> > I'm processing a user submitted form. In that the user will answer a
>
> > series of multiple choice questions. Depending on the question "id"
>
> > which are submitted I'll find the compare the values and increment the
>
> > score to count his marks.
>
> > The question ids are  keys from the dictionary request.POST. But it is
>
> > showing an error the list indices must be integers not unicode. I
>
> > wrote the code as follows.
>
> > // In the view function
>
> >     if request.method=="POST":
>
> >         data = reques.POST
>
> >         temp_list = data.keys()
>
> >         id_list = []
>
> >        for i in temp_list:
>
> >              id_list.append(id_list[i])
>
> >        questions = MyModel.objects.filter(id__in = id_list)
>
> > --
>
> > 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 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.-Hide quoted text -
>
> > - Show quoted text -
>
> --
> 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 
> athttp://groups.google.com/group/django-users?hl=en.- Hide quoted text -
>
> - Show quoted text -

-- 
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: South - when to start?

2011-02-18 Thread gladys
On Feb 18, 7:28 pm, Tom Evans  wrote:
> On Fri, Feb 18, 2011 at 10:24 AM, Piotr Zalewa  wrote:
> > Where is the best moment to start with south?
>
> > 1. The very beginning, as the first app added to the project?
> > 2. At the moment when more devs will be involved?
> > 3. When real data will start to show?
>
> > I'm building a new system, I think the current model progress is about
> > 20%, where 100% is the moment I will put the site on the server. I'm
> > very close to point 2.
>
> > zalun
>
> Personally, I wouldn't bother until either you have more than one
> person developing the code base, or when to update a model means
> updating more than one database schema. Until you are at that point,
> the benefit is not huge, but the cost remains the same.
>
> Cheers
>
> Tom

Here is a nice discussion about using South, you might want to check
it out:
http://stackoverflow.com/questions/5021800/why-use-south-during-initial-development

-- 
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: query set on a manytomany table

2011-02-18 Thread gladys bixly
Why would you want to query the table directly? I believe the only way you
could access data from a ManyToManyField is through the Model in which it is
related.


On Fri, Feb 18, 2011 at 11:35 AM, Bobby Roberts  wrote:

> I have a Manytomanyfield in a model called "registrants" on a
> fieldname called locations.  It stores the person's facility values in
> a table in the database in something called like
> registrants_locations_values  (just as an example).
>
>
> How can i do a query on the registrants_locations_values table since
> it's not a model?
>
> I'm trying something like this:
>
> tms = registrants_locations_values.objects.filter(id=user.id)
>
> but that is not working... how can i pull data from this Manytomany
> table?
>
>
> --
> 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.
>
>


-- 
Gladys
http://bixly.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.



Messages framework is not showing messages in my templates

2011-02-18 Thread Gabriel Prat
Hi all, I'm trying to use messages framework, I've checked that
middleware, context processor and app is well configured (I'm running
django development version which a standard manage.py startproject
includes all needed stuff)

So, let me write a little bit of code, assume a model like:

class MyModel(models.Model):
name= models.TextField(max_length = 100)
url = models.URLField()

And a simple form:

class mymodelForm(forms.ModelForm):
name = forms.CharField()
url = forms.URLField()
class Meta:
model = MyModel

A basic view (assuming all needed imports in top of my views.py file):

def mymodel_create(request):
from forms import mymodelForm
if request.method == 'POST':
form = mymodelForm(request.POST)
if form.is_valid():
form.save()
messages.success(request, _('Model has been saved'))
else:
form = projectForm()

return render_to_response('mymodel_create.html', {'form' : form})

and my template (basic as well)

{% if messages %}

{% for message in messages %}
{{ message }}
{% endfor %}

{% else %}
No messages to show
{% endif %}

{% csrf_token %}

{{ form.as_ul }}

Save



I load it, fill my form up in my browser, submit it and it saves my
model correctly but don't shows any messages, always goes to {% else
%} template part.

So, If I change my URL to /admin the login (or dashboard if logged in)
is showed and my messages appears there!

Someone can help me to fix this problem? I've been searching over
Django docs and Google with no helping topic.

Thanks in advance,

Gabriel

-- 
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: South - when to start?

2011-02-18 Thread dave b
On 18 February 2011 21:24, Piotr Zalewa  wrote:
> Where is the best moment to start with south?
>
> 1. The very beginning, as the first app added to the project?
> 2. At the moment when more devs will be involved?
> 3. When real data will start to show?
>

now!
(just start using 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.



RE: list indices must be integers not unicode

2011-02-18 Thread Chris Matthews
Then you probably want:
id_list = [int(x) for x in data.keys()]

-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of balu
Sent: 18 February 2011 13:56
To: Django users
Subject: Re: list indices must be integers not unicode

Thank you Chris Matthews for your reply.

I'm working on a online examination system. I could able to generate
some random questions from a data base containg hundreds of questions.
So when ever a user answer and submit those random questions a
dictionary contating a "Question_id and Answer" pair will be send as a
request.


Now I have to get those dictionary keys first, i.e., the Question_id
and then I have to cross  check the values i.e., the values with the
database values.

On Feb 18, 4:37 pm, Chris Matthews  wrote:
> Oh and you probably wanted:
>
>     if request.method=="POST":
>
>         data = request.POST
>
>        id_list = [int(x) for x in data.values()]
>
>        questions = MyModel.objects.filter(id__in = id_list)
>
> From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
> Behalf Of Chris Matthews
> Sent: 18 February 2011 13:34
> To: django-users@googlegroups.com
> Subject: RE: list indices must be integers not unicode
>
> Hi Balu,
>
> Numeric data from the form must be converted to int. I suspect you wanted to 
> index data; not id_list.
>
>     if request.method=="POST":
>
>         data = request.POST
>
>         temp_list = data.keys()
>
>         id_list = []
>
>        for i in temp_list:
>
>              id_list.append(id_list[i])
>
>        questions = MyModel.objects.filter(id__in = id_list)
>
> Should
>
> id_list.append(id_list[i])
>
> Not be
>
> id_list.append(data[i])
>
>
>
> -Original Message-
> From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
> Behalf Of balu
> Sent: 18 February 2011 13:24
> To: Django users
> Subject: list indices must be integers not unicode
>
> Hi all :)
>
> I'm processing a user submitted form. In that the user will answer a
>
> series of multiple choice questions. Depending on the question "id"
>
> which are submitted I'll find the compare the values and increment the
>
> score to count his marks.
>
> The question ids are  keys from the dictionary request.POST. But it is
>
> showing an error the list indices must be integers not unicode. I
>
> wrote the code as follows.
>
> // In the view function
>
>     if request.method=="POST":
>
>         data = reques.POST
>
>         temp_list = data.keys()
>
>         id_list = []
>
>        for i in temp_list:
>
>              id_list.append(id_list[i])
>
>        questions = MyModel.objects.filter(id__in = id_list)
>
> --
>
> 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 
> athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.- Hide quoted text -
>
> - Show quoted text -

-- 
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: list indices must be integers not unicode

2011-02-18 Thread balu
Thank you Chris Matthews for your reply.

I'm working on a online examination system. I could able to generate
some random questions from a data base containg hundreds of questions.
So when ever a user answer and submit those random questions a
dictionary contating a "Question_id and Answer" pair will be send as a
request.


Now I have to get those dictionary keys first, i.e., the Question_id
and then I have to cross  check the values i.e., the values with the
database values.

On Feb 18, 4:37 pm, Chris Matthews  wrote:
> Oh and you probably wanted:
>
>     if request.method=="POST":
>
>         data = request.POST
>
>        id_list = [int(x) for x in data.values()]
>
>        questions = MyModel.objects.filter(id__in = id_list)
>
> From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
> Behalf Of Chris Matthews
> Sent: 18 February 2011 13:34
> To: django-users@googlegroups.com
> Subject: RE: list indices must be integers not unicode
>
> Hi Balu,
>
> Numeric data from the form must be converted to int. I suspect you wanted to 
> index data; not id_list.
>
>     if request.method=="POST":
>
>         data = request.POST
>
>         temp_list = data.keys()
>
>         id_list = []
>
>        for i in temp_list:
>
>              id_list.append(id_list[i])
>
>        questions = MyModel.objects.filter(id__in = id_list)
>
> Should
>
> id_list.append(id_list[i])
>
> Not be
>
> id_list.append(data[i])
>
>
>
> -Original Message-
> From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
> Behalf Of balu
> Sent: 18 February 2011 13:24
> To: Django users
> Subject: list indices must be integers not unicode
>
> Hi all :)
>
> I'm processing a user submitted form. In that the user will answer a
>
> series of multiple choice questions. Depending on the question "id"
>
> which are submitted I'll find the compare the values and increment the
>
> score to count his marks.
>
> The question ids are  keys from the dictionary request.POST. But it is
>
> showing an error the list indices must be integers not unicode. I
>
> wrote the code as follows.
>
> // In the view function
>
>     if request.method=="POST":
>
>         data = reques.POST
>
>         temp_list = data.keys()
>
>         id_list = []
>
>        for i in temp_list:
>
>              id_list.append(id_list[i])
>
>        questions = MyModel.objects.filter(id__in = id_list)
>
> --
>
> 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 
> athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.- Hide quoted text -
>
> - Show quoted text -

-- 
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: Displaying a table and make its columns sortable

2011-02-18 Thread Arun K.Rajeevan
Thanks, very good community!

On Feb 18, 3:49 am, Shawn Milochik  wrote:
> On Thu, Feb 17, 2011 at 4:44 PM, Arun K.Rajeevan  wrote:
> > Show me the django way to do this.
>
> The "Django" way to do this is to learn basic programming skills. You
> originally asked a mess of random questions which didn't have anything
> to do with Django. We answered anyway. Now you're basically us to
> write your application logic for you.
>
> You'll get much more helpful responses when your requests indicate
> you've actually tried to do something and run into a problem.
>
> 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: list indices must be integers not unicode

2011-02-18 Thread Chris Matthews
Oh and you probably wanted:

if request.method=="POST":

data = request.POST

   id_list = [int(x) for x in data.values()]



   questions = MyModel.objects.filter(id__in = id_list)


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Chris Matthews
Sent: 18 February 2011 13:34
To: django-users@googlegroups.com
Subject: RE: list indices must be integers not unicode


Hi Balu,



Numeric data from the form must be converted to int. I suspect you wanted to 
index data; not id_list.





if request.method=="POST":

data = request.POST

temp_list = data.keys()

id_list = []



   for i in temp_list:

 id_list.append(id_list[i])



   questions = MyModel.objects.filter(id__in = id_list)



Should

id_list.append(id_list[i])

Not be

id_list.append(data[i])





-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of balu
Sent: 18 February 2011 13:24
To: Django users
Subject: list indices must be integers not unicode



Hi all :)



I'm processing a user submitted form. In that the user will answer a

series of multiple choice questions. Depending on the question "id"

which are submitted I'll find the compare the values and increment the

score to count his marks.



The question ids are  keys from the dictionary request.POST. But it is

showing an error the list indices must be integers not unicode. I

wrote the code as follows.





// In the view function



if request.method=="POST":

data = reques.POST

temp_list = data.keys()

id_list = []



   for i in temp_list:

 id_list.append(id_list[i])



   questions = MyModel.objects.filter(id__in = id_list)



--

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: list indices must be integers not unicode

2011-02-18 Thread Chris Matthews
Hi Balu,



Numeric data from the form must be converted to int. I suspect you wanted to 
index data; not id_list.





if request.method=="POST":

data = request.POST

temp_list = data.keys()

id_list = []



   for i in temp_list:

 id_list.append(id_list[i])



   questions = MyModel.objects.filter(id__in = id_list)



Should

id_list.append(id_list[i])

Not be

id_list.append(data[i])





-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of balu
Sent: 18 February 2011 13:24
To: Django users
Subject: list indices must be integers not unicode



Hi all :)



I'm processing a user submitted form. In that the user will answer a

series of multiple choice questions. Depending on the question "id"

which are submitted I'll find the compare the values and increment the

score to count his marks.



The question ids are  keys from the dictionary request.POST. But it is

showing an error the list indices must be integers not unicode. I

wrote the code as follows.





// In the view function



if request.method=="POST":

data = reques.POST

temp_list = data.keys()

id_list = []



   for i in temp_list:

 id_list.append(id_list[i])



   questions = MyModel.objects.filter(id__in = id_list)



--

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.



list indices must be integers not unicode

2011-02-18 Thread balu
Hi all :)

I'm processing a user submitted form. In that the user will answer a
series of multiple choice questions. Depending on the question "id"
which are submitted I'll find the compare the values and increment the
score to count his marks.

The question ids are  keys from the dictionary request.POST. But it is
showing an error the list indices must be integers not unicode. I
wrote the code as follows.


// In the view function

if request.method=="POST":
data = reques.POST
temp_list = data.keys()
id_list = []

   for i in temp_list:
 id_list.append(id_list[i])

   questions = MyModel.objects.filter(id__in = id_list)

-- 
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: confused about ModelForm Field validation

2011-02-18 Thread Roman Klesel
Hello Piotr,

2011/2/18 Piotr Zalewa :
>
> I would use pre_save signal for data modification
>

hmm ... this sounds like a good idea. It would make the whole thing a
lot more compact ... I'll give it a try.

Thank's!

Roman

-- 
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: South - when to start?

2011-02-18 Thread Tom Evans
On Fri, Feb 18, 2011 at 10:24 AM, Piotr Zalewa  wrote:
> Where is the best moment to start with south?
>
> 1. The very beginning, as the first app added to the project?
> 2. At the moment when more devs will be involved?
> 3. When real data will start to show?
>
> I'm building a new system, I think the current model progress is about
> 20%, where 100% is the moment I will put the site on the server. I'm
> very close to point 2.
>
> zalun

Personally, I wouldn't bother until either you have more than one
person developing the code base, or when to update a model means
updating more than one database schema. Until you are at that point,
the benefit is not huge, but the cost remains the same.

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.



South - when to start?

2011-02-18 Thread Piotr Zalewa
Where is the best moment to start with south?

1. The very beginning, as the first app added to the project?
2. At the moment when more devs will be involved?
3. When real data will start to show?

I'm building a new system, I think the current model progress is about
20%, where 100% is the moment I will put the site on the server. I'm
very close to point 2.

zalun
-- 
blog  http://piotr.zalewa.info
jobs  http://webdev.zalewa.info
twit  http://twitter.com/zalun
face  http://facebook.com/zaloon

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



request in urls.py

2011-02-18 Thread galago
Is it possible to pass request.path in urls.py? I want to pass it as next 
parameter in logout declaration.

-- 
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: confused about ModelForm Field validation

2011-02-18 Thread Piotr Zalewa

On 02/18/11 09:44, Roman Klesel wrote:
> [..] in some cases the values
> stored in the tables have to be converted before the can be displayed
> and also have to be converted bevore bein saved to the database.
> [...]

> def clean(self,value):
> "convert the literal value to the db representation"
> [...]

> On top of that, I feel like working against the ideas of whole validation 
> thing.

I think you may consider it a hack

> Can someone suggest a better solution? Maybe an easier one. Or a more
> stable one? There are quite some fields where I have to do such
> conversions. I'm really trying to find a clean solution which is not
> just tricking the framework.

I would use pre_save signal for data modification

http://docs.djangoproject.com/en/dev/topics/signals/
http://docs.djangoproject.com/en/dev/ref/signals/#django.db.models.signals.pre_save

Piotr
-- 
blog  http://piotr.zalewa.info
jobs  http://webdev.zalewa.info
twit  http://twitter.com/zalun
face  http://facebook.com/zaloon

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



confused about ModelForm Field validation

2011-02-18 Thread Roman Klesel
Hello guys,

I'm running django on a legacy database and in some cases the values
stored in the tables have to be converted before the can be displayed
and also have to be converted bevore bein saved to the database.

Example:

A table for storing IP addresses:

The address field contains values that are  packed binary format
representations of the human readable value e.g:
d55f026c resolves to 213.95.2.108.

I already figured out how to convert between those tow back and forth
with the socket module.
I also figured out how I can make it work in django.

But I'm not happy with the solution I found and I suspect that there
might be a better way to do it.

Currently I'm doing it in the following way:

I have a custom ModelField:

class IpAddrField(models.CharField):
__metaclass__ = models.SubfieldBase
default_error_messages = {
'invalid' : _('%s ist keine valide IP-Adresse.')
}
def get_internal_type(self):
return "CharField"

def to_python(self, value):
print "   -- ModelField to_python got: %s" % value
value = db_to_ipaddr(value)
print "   -- ModellField to_python
returning: %s" % value

return value

def clean(self,value,model_instance):
print "   -- ModelField clean got: %s" % value
try:
value =  ipaddr_to_db(value)
except (socket.error, ValueError):
raise
exceptions.ValidationError(self.error_messages['invalid'] % value)
self.validate(value, model_instance)
self.run_validators(value)
print "   -- ModelField clean returning: %s" % value
return value

def get_prep_value(self,value):
print "   -- MoldelField get_prep got: %s" % value
value =  ipaddr_to_db(value)
print "   -- MoldelField get_prep
returning: %s" % value
return value

def formfield(self, **kwargs):
defaults = {'form_class': IpAddrFormField}
defaults.update(kwargs)
return super(IpAddrField, self).formfield(**defaults)


The code for the custom formField looks like this:

class IpAddrFormField(forms.CharField):
default_error_messages = {
'invalid' : _('%s ist keine valide IP-Adresse.')
}

def to_python(self,value):

print "   -- FormField to_python got: %s" % value

try:
value = ipaddr_to_db(value)
except socket.error:
raise
exceptions.ValidationError(self.error_messages['invalid'] % value)

print "   -- FormField to_python
returning: %s" % value

return value

def clean(self,value):
"convert the literal value to the db representation"
print "   -- FormField clean got: %s" % value

try:
value = self.to_python(value)
except socket.error:
raise
exceptions.ValidationError(self.error_messages['invalid'] % value)
self.validate(value)
self.run_validators(value)
print "   -- FormField clean return: %s" % value

return value


So when I run this code and send a form with a valid IP address it works.

Here is the log output of a successful update:

   -- ModelField to_python got:
d55f026d
   -- ModellField to_python returning: 213.95.2.109
   -- FormField clean got: 213.95.2.108
   -- FormField to_python got: 213.95.2.108
   -- FormField to_python returning:
d55f026c
   -- FormField clean return:
d55f026c
   -- ModelField to_python got:
d55f026c
   -- ModellField to_python returning: 213.95.2.108
   -- ModelField clean got: 213.95.2.108
   -- ModelField clean returning:
d55f026c
   -- ModelField to_python got:
d55f026c
   -- ModellField to_python returning: 213.95.2.108
   -- ModelField to_python got:
d55f026d
   -- ModellField to_python returning: 213.95.2.109
   -- MoldelField get_prep got: 213.95.2.108
   -- MoldelField get_prep returning:
d55f026c
 in post save (this is a post_save hook, not sure if
this is relevant here)
   -- MoldelField get_prep got: 213.95.2.108
   -- MoldelField get_prep returning:
d55f026c
 in post save  (this is a post_save hook, not sure if
this is relevant here)
 in post save  (this is a post_save hook, not 

Broken link emails

2011-02-18 Thread Peter Harley
Hi all,

I recently turned on the broken link emails setting on my site, and
I've got a couple that really confused me.

I assume these emails get sent to me when a user gets a 404, and the
referrer is internal. But here is one example I got:

Referrer: 
http://www.example.com/photos/gallery/singapore-malaysia-and-thailand/wat-phra-mahathat-3/
Requested URL: 
/photos/gallery/singapore-malaysia-and-thailand/wat-phra-mahathat-3/#submitted
User agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
IP address: 127.0.0.1

As far as I can tell, the URL is identical to the referrer (which is a
valid page), except the anchor, which I thought the server doesn't
care about (I didn't even think the server got sent the anchor?)

On that page, the reference to that address is in a forms submit
target - the idea being that users will be taken straight back to the
form if validation fails, rather than the top of the page.

Could this be an IE bug (all the emails have had that user agent) that
is handling the forms target incorrectly, or is that just not
something you're supposed to do?

On a slightly related note, could any webfaction customers (or anyone
else) shed any light on how I would  stop all of requests from
appearing to be internal? Notice the IP address there - I guess it's
because of the webfaction set up of nginx proxying for apache. Anyone
know any config changes I can make? All my comments have that as the
users IP too, which isn't ideal.

Any light you could shed on this would be great!

Peter

-- 
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: ManyToMany problem

2011-02-18 Thread Amar
Thank you, it solved this problem :)

Now, I've encountered another issue, which you can see below. When
using only single item in annotation it works, but when using two, it
returns the same result.
I've added default ordering in all of my models, and as you can se,
I've tried including it directly, with no success.

>>> Event.objects.all().annotate(c=Count('comments'))[0].c
1
>>> Event.objects.all().annotate(p=Count('participants'))[0].p
2
>>> Event.objects.all().annotate(c=Count('comments'), 
>>> p=Count('participants'))[0].c
2
>>> Event.objects.all().annotate(c=Count('comments'), 
>>> p=Count('participants'))[0].p
2
>>> Event.objects.all().annotate(c=Count('comments'), 
>>> p=Count('participants')).order_by('-c', 'p')[0].p
2
>>> Event.objects.all().annotate(c=Count('comments'), 
>>> p=Count('participants')).order_by('-c', 'p')[0].c
2

Thank you for you 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.



lxml usage with django

2011-02-18 Thread Henrik Genssen
Hi,

has anybody used lxml.objectify with Django? I am reading XML files and want to 
put the content into ORM.
I have unicode problems as the default conversion of strings is str, not 
unicode.
Of course I could convert it back to unicode again, but then objectify makes no 
real sense to me.

Anyone?

regards

Henrik

Henrik Genssen

h...@miadi.net
Tel. +49 (0)451/6195650
Fax. +49 (0)451/6195655

miadi GmbH
Geschäftsführer: Henrik Genssen
Sitz der Gesellschaft: Hüxstraße 1 - 9, 23552 Lübeck
Amtsgericht Lübeck HRB 10223, USt-IdNr DE
Lieferungen und Leistungen erfolgen ausschließlich auf Grundlage unserer 
allgemeinen Geschäftsbedingungen

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