Re: Social Networking basics? -Raj

2011-06-21 Thread Piotr Zalewa

Do we have a group FAQ?

On 06/20/11 22:44, Cal Leeming [Simplicity Media Ltd] wrote:

On Mon, Jun 20, 2011 at 10:32 PM, Shawn Milochik mailto:sh...@milochik.com>> wrote:

Is it just me or are we having a sudden spurt of e-mail that goes
like this:

Q: How do I 
A: You do X.

Q: How do I do X?
A: You use Y.

Q: How do I use Y?


Yup, I was just thinking the same thing.


I'm convinced that these people are either trolls or inherently
"un-helpable," unless you want to write their code for them.

In either case I think the only sane response is to completely
ignore these people as soon as this pattern emerges, because it's an
utter waste of the time we could be using to help others -- the
reason we're on this list in the first place.

Also, ignoring them is probably the only way to discourage repeat
offences.


+1, sound like a sane plan.


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+unsubscribe@__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: Avoiding Repetition

2011-06-21 Thread Derek
On Jun 18, 4:33 am, Nikhil Somaru  wrote:
> Hi,
>
> Is there a way to reduce the repetition in the following form classes:
>
> class ItemsStep2(ModelForm): #approval
>     class Meta:
>         model = OrderItem
>         fields = ('item', 'quantity_requested', 'quantity_approved')
>         widgets = {
>             'quantity_requested': TextInput(attrs={'readonly':'readonly'})
>          }
>
> class ItemsStep3(ModelForm): #ship
>     class Meta:
>         model = OrderItem
>         fields = ('item', 'quantity_requested', 'quantity_approved')
>         widgets = {
>             'quantity_requested': TextInput(attrs={'readonly':'readonly'}),
>             'quantity_approved': TextInput(attrs={'readonly':'readonly'})
>          }
>
> class ItemsStep4(ModelForm): #confirm receipt
>     class Meta:
>         model = OrderItem
>         fields = ('item', 'quantity_requested', 'quantity_approved',
> 'quantity_received')
>         widgets = {
>             'quantity_requested': TextInput(attrs={'readonly':'readonly'}),
>             'quantity_approved': TextInput(attrs={'readonly':'readonly'})
>          }
>
> class ItemsStep5(ModelForm): #order summary
>     class Meta:
>         model = OrderItem
>         fields = ('item', 'quantity_requested', 'quantity_approved',
> 'quantity_received')
>         widgets = {
>             'quantity_requested': TextInput(attrs={'readonly':'readonly'}),
>             'quantity_approved': TextInput(attrs={'readonly':'readonly'}),
>             'quantity_received': TextInput(attrs={'readonly':'readonly'}),
>          }
>
> The model that uses these forms has a ForeignKey (Order hasMany OrderItems)
> to an associated model that has a attribute "step" (order_instance.step)
> which determines the class above to use (this code is in views)
>
Nikil

The topic you need to read up on is "dynamic forms".  A good starting
point is:
http://www.b-list.org/weblog/2008/nov/09/dynamic-forms/
but you'll be able to search for many other blog posts and Q&A on this
as well...

-- 
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: Many user profiles

2011-06-21 Thread gontran
Thank you very much Francesco,

Works like a charm...

On 20 juin, 15:33, francescortiz  wrote:
> Try doing this in your models.py:
>
> def get_profile(self):
>     ...your code to get the profile for a the user...
>
> User.get_profile = get_profile
>
> On Jun 20, 9:54 am,gontran wrote:
>
> > Hello evreybody,
>
> > I wonder how to deal with many user profiles.
> > I need to store different informations depending on the status of my
> > users.
>
> > I have a generic UserProfile class:
>
> > class UserProfile(models.Model):
> >     user = models.OneToOneField(User, primary_key=True)
> >     role = models.CharField(max_length=1, choices=USER_ROLE)
>
> > and other classes for different profiles:
> > CustomerProfile, EmployeProfile, ...
>
> > For the admin part, I managed to separate each category of users with
> > proxy models.
> > I know that I can override get_profile() on each proxy model based on
> > the User class.
>
> > What I want to do:
> > u = User.objects.get(pk=x)
> > u.get_profile() ---> return the profile associated depending on the
> > status of the user. If u is a customer, return a CustomerProfile
> > instance, if u is an employe, return à EmployeProfile instance and so
> > on.
>
> > Is it possible to do it?
>
> > Thanks in advance for your help.
>
> > Regards,
>
> >Gontran

-- 
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: Strange value_from_object() return value (2L returned instead of unicode string)

2011-06-21 Thread Daniel Roseman
On Tuesday, 21 June 2011 01:53:23 UTC+1, Jeff Blaine wrote:
>
> I can't seem to figure out what is causing this:  According to the 
> following 2 models
> and the 'python manage.py shell' session shown after them, I am getting 2L 
> as a
> return value from a certain call when I would expect u'redhat 5.6' or 
> similar.
>

What does the Device model look like? 
-- 
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/LX2NNm2EqBYJ.
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.



Caught DatabaseError while rendering: no such function: IF

2011-06-21 Thread yomguy


Hi !

MySQL and SQLite3 seem to have different behaviour here : 

when I have {% if collections %} in a template, where collections is a queryset,
using SQlite3 gives this exception :

"Caught DatabaseError while rendering: no such function: IF"...

No pb with MySQL... Any idea please ?

Thanks ;)
Yomguy

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/thmhoXIYkN4J.
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: Caught DatabaseError while rendering: no such function: IF

2011-06-21 Thread Daniel Roseman
On Tuesday, 21 June 2011 10:17:35 UTC+1, yomguy wrote:
>
> Hi !
>
> MySQL and SQLite3 seem to have different behaviour here : 
>
> when I have {% if collections %} in a template, where collections is a 
> queryset,
> using SQlite3 gives this exception :
>
> "Caught DatabaseError while rendering: no such function: IF"...
>
> No pb with MySQL... Any idea please ?
>
> Thanks ;)
> Yomguy
>
>
What is `collections`? How are you getting it? How are you passing it to the 
template?
--
DR. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/0J6mmMe9bdkJ.
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: Caught DatabaseError while rendering: no such function: IF

2011-06-21 Thread yomguy
collections is a queryset coming from urls.py:

all_collections = { 'queryset': MediaCollection.objects.enriched(), }

and passed to the template like this:

url(r'^collections/$', 'django.views.generic.list_detail.object_list',
dict(all_collections, paginate_by=20, 
template_name="telemeta/collection_list.html"), 
name="telemeta-collections"),

In the main template:

{% block content %}
{% with object_list as collections %}

{% include "telemeta/inc/collection_list.html" %}

{% endwith %}
{% endblock %}

In the included template:

{% load telemeta_utils %}
{% load i18n %}
{% if collections %}
{% if hits %}
..

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/uxQ3BaQ9LCEJ.
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 : Re: Caught DatabaseError while rendering: no such function: IF

2011-06-21 Thread Daniel Roseman
On Tuesday, 21 June 2011 11:13:35 UTC+1, yomguy wrote:
>
> collections is a queryset coming from urls.py:
>
> all_collections = { 'queryset': MediaCollection.objects.enriched(), }
>

But what is 'enriched()'? Honestly, if you're using custom code to get 
objects, and are having trouble in a view that uses that custom code, don't 
you think you should post the function?
--
DR. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/v_BI5J_ooVYJ.
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 caching not working with SSL(https)

2011-06-21 Thread Anoop Thomas Mathew
Hi all,

A site which was caching through django caching backend db cache) it was
working well. When we changed it to https instead of http, the system
suddenly stopped caching. Is there any thought's regarding this?
Anyone got the same issue?

regards,
Anoop

atm
___
Life is short, Live it hard.

-- 
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: Form with manytomany field

2011-06-21 Thread Rd
Guys i also have a problem. Its like I have a many to many field. My
Models are  :


class Catogary(models.Model):
catogary = models.CharField(max_length=50 , unique=True,
primary_key=True)

def __unicode__(self):
return self.catogary


class Preferences(models.Model):
user= models.ForeignKey(User)
preferences=models.ManyToManyField(Catogary)

And i have a form like :

class Preferencesss(forms.ModelForm):

 preferences =
forms.ModelMultipleChoiceField(widget=forms.CheckboxSelectMultiple,
queryset=Catogary.objects.all(), required=True)


Now my problem is how to save the preferences in my model.
In views i have used sumthing like :

add_inst=Preferences(user=user, preferences =
request.POST['preferences'])
add_inst.save()

But its giving me an error..in request.POST method...please help
me guys

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



Weird django caching problem

2011-06-21 Thread philippw
hi.

i have weird caching problems with the 1.3 version of django. I
probably have something configured wrong, but am not sure what.

A good example is django-avatar, which uses caching and many people
use it. Even if I dont have a cache backend defined the avatar seems
to be cached, which by itself would be ok, but it keeps switching back
and forth between the last values cached. Example: I upload a new
avatar, now on approximately 50% of the requests it will show me the
new one, 50% the old one. If I delete the old one I still get it on
the site 50% of the time. The only way to fix it is to disable the
caching of the avatar by setting it to one second.

First I thought it was because i used
django.core.cache.backends.locmem.LocMemCache, which I never used
before, but it even happens when I dont configure a cache backend at
all.

I found one similar bug:
http://stackoverflow.com/questions/4888470/django-caching-bug-even-if-caching-is-disabled

but my pages render just fine, its the templatetags (for now) that
cause the problems in my setup.

I use django 1.3, postgres, nginx, gunicorn 0.12.0, greenlet==0.3.1,
eventlet==0.9.16

I just did some more testing and realized that it only happens when I
start gunicorn using the config file. If I start it with ./manage.py
run_gunicorn everything is fine. Running "gunicorn_django -c deploy/
gunicorn.conf.py" causes the problems.

The only explanation I can think of is that each worker gets his own
cache (I wonder why, since I did not define a cache).

Update: running ./manage.py run_gunicorn -w 4 also causes the same
problems. Therefore I am almost certain that the multiple workers are
causing the problems and each worker caches the values seperately.

My configuration:

import os
import socket
import sys

PORT = 8000
PROC_NAME = 'myapp_gunicorn'
LOGFILE_NAME = 'gunicorn.log'
TIMEOUT = 3600
IP = '127.0.0.1'
DEPLOYMENT_ROOT = os.path.dirname(os.path.abspath(__file__))
SITE_ROOT = os.path.abspath(os.path.sep.join([DEPLOYMENT_ROOT, '..']))
CPU_CORES = os.sysconf("SC_NPROCESSORS_ONLN")
sys.path.insert(0, os.path.join(SITE_ROOT, "apps"))
bind = '%s:%s' % (IP, PORT)
logfile = os.path.sep.join([DEPLOYMENT_ROOT, 'logs', LOGFILE_NAME])
proc_name = PROC_NAME
timeout = TIMEOUT
worker_class = 'eventlet'
workers = 2 * CPU_CORES + 1

---
I also tried it without using 'eventlet', but got the same errors.


Thanks for any help.
Philipp

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



Caught DatabaseError while rendering: no such function: IF

2011-06-21 Thread Parisson
Hi !

MySQL and SQLite3 seem to have different behaviour here :

when I have {% if collections %} in a template, where collections is a queryset,
using SQlite3 gives this exception :

"Caught DatabaseError while rendering: no such function: IF"...

No pb with MySQL... Any idea please ?

Thanks ;)

YomGuy

I do LOVE Django :)

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



Re: Weird django caching problem

2011-06-21 Thread Tom Evans
On Tue, Jun 21, 2011 at 9:20 AM, philippw  wrote:
> hi.
>
> i have weird caching problems with the 1.3 version of django. I
> probably have something configured wrong, but am not sure what.
>

You don't mention how you have configured caching, which is relevant.
By default, if you do not configure a a cache Django will use the
'locmem' cache, which uses per-process local memory to act as a cache,
which means you get one cache per process, and consequently the
behaviour you have described.

If you don't want a cache, but want to use code that uses the cache
framework, you must configure Django to use DummyCache.

All of this is documented in the caching documentation:
https://docs.djangoproject.com/en/1.3/topics/cache/

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: Strange value_from_object() return value (2L returned instead of unicode string)

2011-06-21 Thread Malcolm Box
On 21 Jun 2011, at 01:53, Jeff Blaine wrote:

> >>> from hostdb.models import Device, Interface
> >>> hostname = 'beijing.mitre.org'
> >>> dev = Interface.objects.get(fqdn=hostname).device
> >>> dev.status
> 
> >>> f = dev._meta.get_field('status')
> >>> f.value_from_object(dev)
> u'Online'
> >>> # Super -- this is exactly what I would expect.  Now trouble
> >>> dev.distro
> 
> >>> print dev.distro
> redhat 5.6
> >>> f = dev._meta.get_field('distro')
> >>> f.value_from_object(dev)
> 2L
> >>> # what the hell?

Psychic debugging since you didn't post the Device model:

dev.distro is a foreign key to the Distro model. When you ask for the value via 
the get_field, you actually end up with the PK of the Distro rather than the 
distro instance.

Malcolm

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



csrf token driving me crazy

2011-06-21 Thread Divkis
Hi all,
  I am facing some really weird issue with csrf token handling
in django 1.3. Until now I was using 1.2 and my views were working
fine with ajax post requests by setting the X-CSRFToken. I upgraded to
django1.3 and cleared all the cookies in my browser and I see that no
csrktoken cookie is being set and thus breaking my views.

To debug this I looked into django sources and I see that when one my
views is called which is called using post, the csrf token is
generated and put inside request.META['CSRF_COOKIE'] but there are
other static files referred inside the view which are called using GET
but I see that the csrf token is regenerated even for GET calls. Hence
the csrf_token set (using {% csrf_token %}) in one of my templates no
longer matches with what is contained in request.META['CSRF_COOKIE'].
Moreover I tried to use {% csrf_token %} because the csrftoken cookie
is not being found/set in browser cookie.

I am not sure what is causing this. Please help.

In django.middleware.csrf.py: CsrfViewMiddleware: proces_response I
have put the following prints:


def process_response(self, request, response):
if getattr(response, 'csrf_processing_done', False):
return response

print 'CSRF_COOKIE is ', request.META.get('CSRF_COOKIE')
print 'CSRF_COOKIE_USED is ',
request.META.get('CSRF_COOKIE_USED')
print 'CSRF_COOKIE_DOMAIN is ',
request.META.get('CSRF_COOKIE_DOMAIN')

and the output from django development server is :

CSRF_COOKIE is  131b312f5978ae7b80dcebce32a8d71f
CSRF_COOKIE_USED is  None
CSRF_COOKIE_DOMAIN is  None
[21/Jun/2011 05:50:50] "POST / HTTP/1.1" 200 18881
CSRF_COOKIE is  dbba1a4cc2089723019c26d250bcaf22
CSRF_COOKIE_USED is  None
CSRF_COOKIE_DOMAIN is  None
[21/Jun/2011 05:50:53] "GET /static/css/base.css HTTP/1.1" 200 8527
CSRF_COOKIE is  bd14b0b3d4acfc4d5e0581beb6c693af
CSRF_COOKIE_USED is  None
CSRF_COOKIE_DOMAIN is  None
[21/Jun/2011 05:50:53] "GET /static/css/redmond/jquery-
ui-1.8.10.custom.css HTTP/1.1" 200 34080
CSRF_COOKIE is  6c5b8e37943bb61e494fb619a0a4c4a9
CSRF_COOKIE_USED is  None
CSRF_COOKIE_DOMAIN is  None
[21/Jun/2011 05:50:53] "GET /static/js/jquery-1.5.1.js HTTP/1.1" 200
216840
CSRF_COOKIE is  3b158fc50ee44bb222b8001301270916
CSRF_COOKIE_USED is  None
CSRF_COOKIE_DOMAIN is  None
[21/Jun/2011 05:50:54] "GET /static/js/jquery-ui-1.8.10.custom.min.js
HTTP/1.1" 200 207380
CSRF_COOKIE is  c9fbacd13a07019d8d656fba079439d4
CSRF_COOKIE_USED is  None
CSRF_COOKIE_DOMAIN is  None
[21/Jun/2011 05:50:54] "GET /static/js/json.min.js HTTP/1.1" 200 1257
CSRF_COOKIE is  6f9409363d14c7bc565e7f6436650149
CSRF_COOKIE_USED is  None
CSRF_COOKIE_DOMAIN is  None
[21/Jun/2011 05:50:54] "GET /static/css/prettyPhoto.css HTTP/1.1" 200
27294
CSRF_COOKIE is  ff323f081ece38d56734c96b9ecddace
CSRF_COOKIE_USED is  None
CSRF_COOKIE_DOMAIN is  None
[21/Jun/2011 05:50:54] "GET /static/js/jquery.prettyPhoto.js HTTP/1.1"
200 34052
CSRF_COOKIE is  790fa3e999201cadafcaefe84505dd35
CSRF_COOKIE_USED is  None
CSRF_COOKIE_DOMAIN is  None
[21/Jun/2011 05:50:54] "GET /static/js/index.js HTTP/1.1" 200 3681
CSRF_COOKIE is  c5762ae986e245f6da30879f1df15180
CSRF_COOKIE_USED is  None
CSRF_COOKIE_DOMAIN is  None
[21/Jun/2011 05:50:54] "GET /static/js/base.js HTTP/1.1" 200 2579


Thanks & Regards,
Divkis01

-- 
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: syncdb doesn't create UserProfile table

2011-06-21 Thread Tom Evans
On Sat, Jun 18, 2011 at 8:27 AM, Kenneth Gonsalves
 wrote:
> On Thu, 2011-06-16 at 12:13 +0100, Tom Evans wrote:
>> On Thu, Jun 16, 2011 at 11:55 AM, Kenneth Gonsalves
>>  wrote:
>> > those entries are old. The point is that the built in
>> User.get_profile()
>> > only works with onetoone. The difference is in the reverse lookup.
>>
>> That is not correct.
>>
>> It will still work perfectly with ForeignKey(unique=True),
>
> the docs say one2one
>

That doesn't negate my statement.

You said that User.get_profile() will only work with OneToOneField,
which is incorrect, it will also work with ForeignKey(unique=True).
New code should always use OneToOneField though.

Cheers

Tom

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



Re : Re: Re : Re: Caught DatabaseError while rendering: no such function: IF

2011-06-21 Thread yomguy
Sorry Daniel, you're right ! 
I thought the exception pointed out the "if" statement in the template, but 
it is in fact the "IF" command in my MediaCollectionQuerySet.

Here is a part of the MediaCollectionManager with its "enriched" method:

class MediaCollectionManager(CoreManager):
"Manage collection queries"

def get_query_set(self):
"Return the collection query"
return MediaCollectionQuerySet(self.model)

def enriched(self):
"Query set with additional virtual fields such as 
apparent_collector"
return self.get_query_set().virtual('apparent_collector')

 
And the MediaCollectionQuerySet with its "virtual" method:

class MediaCollectionQuerySet(CoreQuerySet): 

def virtual(self, *args):
qs = self
for f in args:
if f == 'apparent_collector':
qs = qs.extra(select={f: 
'IF(media_collections.collector_is_creator, '
 'media_collections.creator, 
media_collections.collector)'})
else:
raise Exception("Unsupported virtual field: %s" % f)
return qs


See for more details:
http://telemeta.org/browser/telemeta/models/query.py#L327
http://telemeta.org/browser/telemeta/models/query.py#L279


Thanks for your help Daniel and others,
G

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/jy_GaQJOyU8J.
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 : Caught DatabaseError while rendering: no such function: IF

2011-06-21 Thread yomguy
Sorry for the flood !
yomguy

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/_taQC4J9xTMJ.
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: problems using django-registration

2011-06-21 Thread Tom Evans
On Mon, Jun 20, 2011 at 10:15 PM, Kevin Miller  wrote:
> Hi all,
>
> I am in the process of finishing up an app. However, I just cannot
> integrate django-registration and sessions properly. I can allow a
> user to register and also log in. But
> I am a bit confused in getting in to work with sessions. Eg. I want to
> get information based on the user that is logged in. I have look in
> the django book on session management and understand
> how to create sessions and destroy sessions..etc. So I believe I could
> do the entire process manually without email activation. But
> django-registration allows email activation which I also need. So I
> really want to use it but cannot integrate it with sessions.
>
> sessions do not event work with my templates. I tried to post a link
> only if the user is authenticated by doing this:
>
> {% if user.is_authenticated %}
>    Log Out
>    {% endif %}
>
> and it will not work, even after I log in the system using
> django-registration. I believe there is some broken link in my
> understanding of django-registration.
> Can anyone please tell me how to integrate session management with
> django-registration. Google did not help me that much.
>
>
> Thanks in advance.
>
> Kevin.
>

Use a RequestContext when rendering a template if you want access to
things like 'user' and 'session'.
https://docs.djangoproject.com/en/1.3/ref/templates/api/#subclassing-context-requestcontext

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: csrf token driving me crazy

2011-06-21 Thread Daniel Roseman

On Tuesday, 21 June 2011 12:17:26 UTC+1, Divkis wrote:
>
> Hi all, 
>   I am facing some really weird issue with csrf token handling 
> in django 1.3. Until now I was using 1.2 and my views were working 
> fine with ajax post requests by setting the X-CSRFToken. I upgraded to 
> django1.3 and cleared all the cookies in my browser and I see that no 
> csrktoken cookie is being set and thus breaking my views. 
>
> To debug this I looked into django sources and I see that when one my 
> views is called which is called using post, the csrf token is 
> generated and put inside request.META['CSRF_COOKIE'] but there are 
> other static files referred inside the view which are called using GET 
> but I see that the csrf token is regenerated even for GET calls. Hence 
> the csrf_token set (using {% csrf_token %}) in one of my templates no 
> longer matches with what is contained in request.META['CSRF_COOKIE']. 
> Moreover I tried to use {% csrf_token %} because the csrftoken cookie 
> is not being found/set in browser cookie. 
>
> I am not sure what is causing this. Please help. 
>
 
When you upgrade versions, you should always be sure to read the release 
notes. In this case, the notes point out that there has a been a 
backwards-incompatible change on CSRF in Ajax requests, and points to the 
updated documentation, which you should read, as it explains exactly how to 
get a CSRF token for use in Ajax.
https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/9dKAbkYP8A4J.
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: Possible bug in form validation

2011-06-21 Thread Shawn Milochik

On 06/21/2011 12:17 AM, Ian Clelland wrote:
On Mon, Jun 20, 2011 at 1:49 PM, Shawn Milochik > wrote:


I know that, whenever someone finds a "bug" in Django they're
usually doing something incorrectly. Hopefully someone will point
out what I need to do to make this work.


I don't know if it's considered 'correct' or not, but the max_value 
constructor parameter is only used at instantiation time, to add a 
validator to the field.


You can easily add the validator manually in your own constructor if 
you need to. You may also want to set the max_value attribute, if you 
use it elsewhere, but it is not used internally by the form machinery.




Ian,

Considering that other things, such as setting 'initial' values and 
widgets work after the super().__init__() and that it's impossible to do 
them before said __init__, I think it's definitely a bug. And 
considering that the max_value lives beyond that point but isn't 
enforced certainly violates the "least surprising" rule.


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: How do I create dynamic django models ?

2011-06-21 Thread Andre Terra
+1 on that link needing some review. Questions about dynamic models
pop up often enough to warrant a canonical explanation.

Sincerely,
Andre Terra / airstrike

On 6/21/11, Satyajit Sarangi  wrote:
> I went through this link , but couldn't really understand where to put
> where . A little more help as to how to go about it would be very
> helpful .
> https://code.djangoproject.com/wiki/DynamicModels
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
Sent from my mobile device

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



Re: syncdb doesn't create UserProfile table

2011-06-21 Thread Kenneth Gonsalves
On Tue, 2011-06-21 at 12:49 +0100, Tom Evans wrote:
> >> It will still work perfectly with ForeignKey(unique=True),
> >
> > the docs say one2one
> >
> 
> That doesn't negate my statement.
> 
> You said that User.get_profile() will only work with OneToOneField,
> which is incorrect, it will also work with ForeignKey(unique=True).
> New code should always use OneToOneField though. 

true - I looked at the code and it does not rely on fk or one2one
methods
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Re: How to send the class name from one template to another template both in different apps in django ?

2011-06-21 Thread Andre Terra
It seems you have an issue and you are asking for help on making your
solution work, when you should be telling us what it is that you want
to do. Only then will we be able to advise you.

Sincerely,
Andre Terra

On 6/20/11, Satyajit Sarangi  wrote:
> Lets say I work on a class in one template by a certain view . There
> is a link on that template , that takes  me to another template in a
> different app , where I would like to add certain permissions to that
> particular class_id that I just saved in this app . How do I do that ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
Sent from my mobile device

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



Re: [Forms] Avoiding Repetition

2011-06-21 Thread Nikhil Somaru
Thanks derek.

On Sat, Jun 18, 2011 at 8:03 AM, Nikhil Somaru  wrote:

> Hi,
>
> Is there a way to reduce the repetition in the following form classes:
>
> class ItemsStep2(ModelForm): #approval
> class Meta:
> model = OrderItem
> fields = ('item', 'quantity_requested', 'quantity_approved')
> widgets = {
> 'quantity_requested': TextInput(attrs={'readonly':'readonly'})
>  }
>
>
> class ItemsStep3(ModelForm): #ship
> class Meta:
> model = OrderItem
> fields = ('item', 'quantity_requested', 'quantity_approved')
> widgets = {
> 'quantity_requested': TextInput(attrs={'readonly':'readonly'}),
> 'quantity_approved': TextInput(attrs={'readonly':'readonly'})
>  }
>
>
> class ItemsStep4(ModelForm): #confirm receipt
> class Meta:
> model = OrderItem
> fields = ('item', 'quantity_requested', 'quantity_approved',
> 'quantity_received')
> widgets = {
> 'quantity_requested': TextInput(attrs={'readonly':'readonly'}),
> 'quantity_approved': TextInput(attrs={'readonly':'readonly'})
>  }
>
>
> class ItemsStep5(ModelForm): #order summary
> class Meta:
> model = OrderItem
> fields = ('item', 'quantity_requested', 'quantity_approved',
> 'quantity_received')
> widgets = {
> 'quantity_requested': TextInput(attrs={'readonly':'readonly'}),
> 'quantity_approved': TextInput(attrs={'readonly':'readonly'}),
> 'quantity_received': TextInput(attrs={'readonly':'readonly'}),
>  }
>
> The model that uses these forms has a ForeignKey (Order hasMany OrderItems)
> to an associated model that has a attribute "step" (order_instance.step)
> which determines the class above to use (this code is in views)
>
> Thanks in advance.
> --
> Yours,
> Nikhil Somaru
>
>


-- 
Yours,
Nikhil Somaru

-- 
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: [Forms] Avoiding Repetition

2011-06-21 Thread Andre Terra
I'm reading this on my phone, so I apologize in advice if I missed
something crucial, but what's stopping you from subclassing and
overriding just the relevant parts?

Sincerely,
Andre Terra

On 6/17/11, Nikhil Somaru  wrote:
> Hi,
>
> Is there a way to reduce the repetition in the following form classes:
>
> class ItemsStep2(ModelForm): #approval
> class Meta:
> model = OrderItem
> fields = ('item', 'quantity_requested', 'quantity_approved')
> widgets = {
> 'quantity_requested': TextInput(attrs={'readonly':'readonly'})
>  }
>
>
> class ItemsStep3(ModelForm): #ship
> class Meta:
> model = OrderItem
> fields = ('item', 'quantity_requested', 'quantity_approved')
> widgets = {
> 'quantity_requested': TextInput(attrs={'readonly':'readonly'}),
> 'quantity_approved': TextInput(attrs={'readonly':'readonly'})
>  }
>
>
> class ItemsStep4(ModelForm): #confirm receipt
> class Meta:
> model = OrderItem
> fields = ('item', 'quantity_requested', 'quantity_approved',
> 'quantity_received')
> widgets = {
> 'quantity_requested': TextInput(attrs={'readonly':'readonly'}),
> 'quantity_approved': TextInput(attrs={'readonly':'readonly'})
>  }
>
>
> class ItemsStep5(ModelForm): #order summary
> class Meta:
> model = OrderItem
> fields = ('item', 'quantity_requested', 'quantity_approved',
> 'quantity_received')
> widgets = {
> 'quantity_requested': TextInput(attrs={'readonly':'readonly'}),
> 'quantity_approved': TextInput(attrs={'readonly':'readonly'}),
> 'quantity_received': TextInput(attrs={'readonly':'readonly'}),
>  }
>
> The model that uses these forms has a ForeignKey (Order hasMany OrderItems)
> to an associated model that has a attribute "step" (order_instance.step)
> which determines the class above to use (this code is in views)
>
> Thanks in advance.
> --
> Yours,
> Nikhil Somaru
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
Sent from my mobile device

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



Re: How to send the class name from one template to another template both in different apps in django ?

2011-06-21 Thread Satyajit Sarangi
Lets say one template helps me in uploading a file . When I go to an app
called permissions , directly from that template . I want to carry that file
name with me , so that I can assign permissions to it .

On Tue, Jun 21, 2011 at 5:39 PM, Andre Terra  wrote:

> It seems you have an issue and you are asking for help on making your
> solution work, when you should be telling us what it is that you want
> to do. Only then will we be able to advise you.
>
> Sincerely,
> Andre Terra
>
> On 6/20/11, Satyajit Sarangi  wrote:
> > Lets say I work on a class in one template by a certain view . There
> > is a link on that template , that takes  me to another template in a
> > different app , where I would like to add certain permissions to that
> > particular class_id that I just saved in this app . How do I do that ?
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
> >
> >
>
> --
> Sent from my mobile device
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
*Satyajit Sarangi*

-- 
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: csrf token driving me crazy

2011-06-21 Thread Divkis


On Jun 21, 4:54 pm, Daniel Roseman  wrote:
> On Tuesday, 21 June 2011 12:17:26 UTC+1, Divkis wrote:
>
> > Hi all,
> >           I am facing some really weird issue with csrf token handling
> > in django 1.3. Until now I was using 1.2 and my views were working
> > fine with ajax post requests by setting the X-CSRFToken. I upgraded to
> > django1.3 and cleared all the cookies in my browser and I see that no
> > csrktoken cookie is being set and thus breaking my views.
>
> > To debug this I looked into django sources and I see that when one my
> > views is called which is called using post, the csrf token is
> > generated and put inside request.META['CSRF_COOKIE'] but there are
> > other static files referred inside the view which are called using GET
> > but I see that the csrf token is regenerated even for GET calls. Hence
> > the csrf_token set (using {% csrf_token %}) in one of my templates no
> > longer matches with what is contained in request.META['CSRF_COOKIE'].
> > Moreover I tried to use {% csrf_token %} because the csrftoken cookie
> > is not being found/set in browser cookie.
>
> > I am not sure what is causing this. Please help.
>
> When you upgrade versions, you should always be sure to read the release
> notes. In this case, the notes point out that there has a been a
> backwards-incompatible change on CSRF in Ajax requests, and points to the
> updated documentation, which you should read, as it explains exactly how to
> get a CSRF token for use in 
> Ajax.https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax


Yeah, I did read the updated documentation but I did not find anything
that seems to point to backward incompatible change w.r.t. 1.2. May be
I have overlooked something. Please point me to the right section in
the documentation.

Moreover  it does not explain that why a GET request seems to change
the request.META['CSRF_COOKIE'].

Thanks & Regards,
DivKis01

-- 
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 send the class name from one template to another template both in different apps in django ?

2011-06-21 Thread Daniel Roseman
On Tuesday, 21 June 2011 13:16:47 UTC+1, Satyajit Sarangi wrote:
>
> Lets say one template helps me in uploading a file . When I go to an app 
> called permissions , directly from that template . I want to carry that file 
> name with me , so that I can assign permissions to it . 
>
>
You really don't make it easy to help you, do you?

Firstly, why are you thinking in terms of templates? A template is a file 
that (usually) produces HTML to render some or all of a page's contents. It 
has nothing to do with uploading or navigation.

Secondly, what does it even mean to "go to an app called permissions, 
directly from that template"? How will you get to this "app" from that 
"template"?

I *think* what you mean is that you have a view that deals with file 
uploading, and another one (for some reason) that deals with assigning 
permissions on uploaded files. Why you don't do it at the same time is 
anyone's guess. But presumably, in your uploading view, you redirect 
somewhere after the form is submitted. Why can't you just redirect to the 
new "app" (sic) from there? You can pass parameters in the URL of the 
redirect in the normal way.
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/adAzmAWwRV0J.
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: Strange value_from_object() return value (2L returned instead of unicode string)

2011-06-21 Thread Jeff Blaine
Yes, seems that way, Malcom, but *why*

class Device(models.Model):
# ...
status  = models.ForeignKey(Status,
blank=True,
null=True,
verbose_name="Status",
on_delete=models.DO_NOTHING)

distro  = models.ForeignKey(Distro,
blank=True,
null=True,
verbose_name="Distro",
on_delete=models.DO_NOTHING)
# ...

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/e24WN7NmnxEJ.
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: problems using django-registration

2011-06-21 Thread Kevin Miller
Oh silly me. I was not returning user in the HttpResponse. I don't why
I assumed that it would be automatically available.
Thanks all.

On Mon, Jun 20, 2011 at 9:13 PM, Kenneth Gonsalves
 wrote:
> On Mon, 2011-06-20 at 16:15 -0500, Kevin Miller wrote:
>> Can anyone please tell me how to integrate session management with
>> django-registration. Google did not help me that much.
>
> do you have this line in settings.py:
> TEMPLATE_CONTEXT_PROCESSORS = (
>    'django.core.context_processors.request',
> --
> regards
> KG
> http://lawgon.livejournal.com
> Coimbatore LUG rox
> http://ilugcbe.techstud.org/
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>



-- 
Kevin Miller
Acting Data Controller
Department of Computing
UWI, Mona
Kingston 7

-- 
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: problems using django-registration

2011-06-21 Thread Kevin Miller
Oh silly me. I was not returning user in the HttpResponse. I don't why
I assumed that it would be automatically available.
Thanks all.


2011/6/20 没必要吧 :
> Do you remember return user in HttpResponse?
>
> --
> 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.
>
>



-- 
Kevin Miller
Acting Data Controller
Department of Computing
UWI, Mona
Kingston 7

-- 
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 use django-profile with django registration ?

2011-06-21 Thread Satyajit Sarangi
https://bitbucket.org/ubernostrum/django-registration This is what I
am using for user registration . Once , I log in the user is not able
to get into the userprofile page .

Thus I installed this https://bitbucket.org/ubernostrum/django-profiles/
for user profile .

Now , this produces a conflict in urls.py and also settings.py file .

How to resolve it . What changes needs to be done with urls.py and
settings.py so that , when a user logs in , he/she is redirected to
the profile page .

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



Re: How to use django-profile with django registration ?

2011-06-21 Thread Piotr Zalewa

On 06/21/11 14:15, Satyajit Sarangi wrote:

https://bitbucket.org/ubernostrum/django-registration This is what I
am using for user registration . Once , I log in the user is not able
to get into the userprofile page .

Thus I installed this https://bitbucket.org/ubernostrum/django-profiles/
for user profile .


Recent commits were done 2 years ago.
Which version of Django do you use?



Now , this produces a conflict in urls.py and also settings.py file .


Would you provide any errors?


How to resolve it . What changes needs to be done with urls.py and
settings.py so that , when a user logs in , he/she is redirected to
the profile page .


How your current urls.py and settings.py do look like?
Please use some dpaste or similar sites.

zalun


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



Re: How to use django-profile with django registration ?

2011-06-21 Thread Satyajit Sarangi
I am using 1.3
This is my settings.py
http://dpaste.com/556954/

This is my urls.py
http://dpaste.com/556955/

On Tue, Jun 21, 2011 at 7:14 PM, Piotr Zalewa  wrote:

> On 06/21/11 14:15, Satyajit Sarangi wrote:
>
>> https://bitbucket.org/**ubernostrum/django-**registrationThis
>>  is what I
>> am using for user registration . Once , I log in the user is not able
>> to get into the userprofile page .
>>
>> Thus I installed this https://bitbucket.org/**
>> ubernostrum/django-profiles/
>> for user profile .
>>
>
> Recent commits were done 2 years ago.
> Which version of Django do you use?
>
>
>
>> Now , this produces a conflict in urls.py and also settings.py file .
>>
>
> Would you provide any errors?
>
>
>  How to resolve it . What changes needs to be done with urls.py and
>> settings.py so that , when a user logs in , he/she is redirected to
>> the profile page .
>>
>
> How your current urls.py and settings.py do look like?
> Please use some dpaste or similar sites.
>
> zalun
>
>
> --
> 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+unsubscribe@**
> googlegroups.com .
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en
> .
>
>


-- 
*Satyajit Sarangi*

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



Re: How to use django-profile with django registration ?

2011-06-21 Thread Piotr Zalewa

In urls.py you've got:
   url(r'^accounts/', include('registration.urls')),

and later:
(r'^accounts/', include('userprofile.urls')),

/me is no expert, but that smells like asking for trouble.

zalun


On 06/21/11 14:48, Satyajit Sarangi wrote:

I am using 1.3
This is my settings.py
http://dpaste.com/556954/

This is my urls.py
http://dpaste.com/556955/

On Tue, Jun 21, 2011 at 7:14 PM, Piotr Zalewa mailto:zal...@gmail.com>> wrote:

On 06/21/11 14:15, Satyajit Sarangi wrote:

https://bitbucket.org/__ubernostrum/django-__registration
 This is
what I
am using for user registration . Once , I log in the user is not
able
to get into the userprofile page .

Thus I installed this
https://bitbucket.org/__ubernostrum/django-profiles/

for user profile .


Recent commits were done 2 years ago.
Which version of Django do you use?



Now , this produces a conflict in urls.py and also settings.py
file .


Would you provide any errors?


How to resolve it . What changes needs to be done with urls.py and
settings.py so that , when a user logs in , he/she is redirected to
the profile page .


How your current urls.py and settings.py do look like?
Please use some dpaste or similar sites.

zalun


--
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+unsubscribe@__googlegroups.com
.
For more options, visit this group at
http://groups.google.com/__group/django-users?hl=en
.




--
_Satyajit Sarangi_

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


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



Re: How to use django-profile with django registration ?

2011-06-21 Thread Satyajit Sarangi
Yes I know thats the problem . But , want to know whats the way out .

On Tue, Jun 21, 2011 at 7:52 PM, Piotr Zalewa  wrote:

> In urls.py you've got:
>   url(r'^accounts/', include('registration.urls')),
>
> and later:
>(r'^accounts/', include('userprofile.urls')),
>
> /me is no expert, but that smells like asking for trouble.
>
> zalun
>
>
>
> On 06/21/11 14:48, Satyajit Sarangi wrote:
>
>> I am using 1.3
>> This is my settings.py
>> http://dpaste.com/556954/
>>
>> This is my urls.py
>> http://dpaste.com/556955/
>>
>> On Tue, Jun 21, 2011 at 7:14 PM, Piotr Zalewa > > wrote:
>>
>>On 06/21/11 14:15, Satyajit Sarangi wrote:
>>
>>
>> https://bitbucket.org/__**ubernostrum/django-__**registration
>>
>> >
>> This is
>>what I
>>am using for user registration . Once , I log in the user is not
>>able
>>to get into the userprofile page .
>>
>>Thus I installed this
>>
>> https://bitbucket.org/__**ubernostrum/django-profiles/
>>
>> 
>> >
>>for user profile .
>>
>>
>>Recent commits were done 2 years ago.
>>Which version of Django do you use?
>>
>>
>>
>>Now , this produces a conflict in urls.py and also settings.py
>>file .
>>
>>
>>Would you provide any errors?
>>
>>
>>How to resolve it . What changes needs to be done with urls.py and
>>settings.py so that , when a user logs in , he/she is redirected to
>>the profile page .
>>
>>
>>How your current urls.py and settings.py do look like?
>>Please use some dpaste or similar sites.
>>
>>zalun
>>
>>
>>--
>>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+unsubscribe@__goo**glegroups.com
>>
>> > **>.
>>
>>For more options, visit this group at
>>
>> http://groups.google.com/__**group/django-users?hl=en
>>
>> 
>> >.
>>
>>
>>
>>
>> --
>> _Satyajit Sarangi_
>>
>> --
>>
>> 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+unsubscribe@**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+unsubscribe@**
> googlegroups.com .
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en
> .
>
>


-- 
*Satyajit Sarangi*

-- 
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: Unit-Testing Dilemma

2011-06-21 Thread Nan


> Your view function may indeed be too complex to test properly, and it sounds
> like it is too tightly coupled with with the API call -- there is no way to
> call the view without having it call the actual 3rd-party API as imported at
> the top of the file.

I'd be a little confused as to how to factor that out.  I mean, in the
actual app that call is refactored behind a function that wraps the
third-party API, and I could theoretically monkey-patch something over
that function call for unit testing.  But the view still has to return
an HttpResponse, and a blank one.

> The other way is to make your view function as simple as possible -- simple
> enough that it is obviously correct, without any unit tests. Take
> *everything* that can affect the message which is passed to the API, and
> abstract that into another function that the view can call. Then test *that*
> function as a unit.

Yes, it is very complex: it has to assess about 30 different potential
states via nested conditionals.  It's actually broken down into a
number of sub-functions that each deal with a few sub-states; and
while refactoring might be a good idea, I wouldn't want to even
attempt that before having some good unit tests in place!

I think what you're suggesting (correct me if I'm wrong) is to have
the top-level view function be the only place the API is called, and
to use only a single call; every other sub-function that reaches an
exit state should instead return a string containing the message to
send?

Thinking aloud, my concern then becomes that some of the sub-functions
must actually make multiple API calls.  So we'd have to be returning
tuples or something instead.

> If theAPI is a class, then give it methods like setTestMode() and
> resetTestMode(), and use them in your setUp and tearDown methods. Then, if
> test mode is enabled, don't actually make the third party call, just store
> the passed-in message in a module-level or class-level list and return
> success. After your view returns, check the list to see that the message was
> correct.

Oh!  Thank you!  I didn't understand before how a mock API might make
that possible -- it makes a lot more sense now.  That soudns like the
perfect way to do it.

At least until we've got enough tests to make sure the refactoring is
correct, I need to be able to create the tests without touching the
actual view logic, so testing what the API receives makes the most
sense to me.


-- 
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: Strange value_from_object() return value (2L returned instead of unicode string)

2011-06-21 Thread Jeff Blaine
Okay, here's the problem.

>>> f = dev._meta.get_field('distro')
>>> f.value_from_object(dev)
2L

value_from_object is defined as:


def value_from_object(self, obj):
"Returns the value of this field in the given model instance."
return getattr(obj, self.attname)


>>> f.attname
'distro_id'
>>>

As others guessed, value_from_object() is returning the pk ID in this
case.

Model "Distro" is the only model of mine showing this behavior, as it is the
only foreign key "target" model I have defined without named primary key.

>From what I can tell, value_from_object() is actually mis-named, and should
be named pkvalue_from_object(), no?  Or is there some case where 
self.attname
for a field is *not* set to the primary key attribute name?

Any ideas?  I really want (concept) 
"myfield.unicode_representation_of_object(myobject)"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/VwIWznE_R-QJ.
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: Strange value_from_object() return value (2L returned instead of unicode string)

2011-06-21 Thread Tom Evans
On Tue, Jun 21, 2011 at 3:47 PM, Jeff Blaine  wrote:
> Any ideas?  I really want (concept)
> "myfield.unicode_representation_of_object(myobject)"
>

unicode(myobject.myfield) // unicode(getattr(myobject, 'myfield'))

Am I being dense?

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: Strange value_from_object() return value (2L returned instead of unicode string)

2011-06-21 Thread Malcolm Box
On 21 June 2011 15:47, Jeff Blaine  wrote:

> Okay, here's the problem.
>
> >>> f = dev._meta.get_field('distro')
> >>> f.value_from_object(dev)
> 2L
>
> >>> f.attname
> 'distro_id'
> >>>
>
> As others guessed, value_from_object() is returning the pk ID in this
> case.
>
>
Model "Distro" is the only model of mine showing this behavior, as it is the
> only foreign key "target" model I have defined without named primary key.
>
>
No, I think you're seeing the same behaviour for all fields - ie you're
retrieving the value of the key for the related item. However for the Status
model, that value is a string since you've defined a charfield as the
primary key.

Under the hood, related fields store the key of the related item, not the
item itself. Clever Stuff (TM) in the ORM then reifies those objects as
needed.


Malcolm

-- 
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: Strange value_from_object() return value (2L returned instead of unicode string)

2011-06-21 Thread Daniel Roseman
On Tuesday, 21 June 2011 15:47:32 UTC+1, Jeff Blaine wrote:
>
> Okay, here's the problem.
>
> >>> f = dev._meta.get_field('distro')
> >>> f.value_from_object(dev)
> 2L
>
> value_from_object is defined as:
>
> 
> def value_from_object(self, obj):
> "Returns the value of this field in the given model instance."
> return getattr(obj, self.attname)
> 
>
> >>> f.attname
> 'distro_id'
> >>>
>
> As others guessed, value_from_object() is returning the pk ID in this
> case.
>
> Model "Distro" is the only model of mine showing this behavior, as it is 
> the
> only foreign key "target" model I have defined without named primary key.
>
> From what I can tell, value_from_object() is actually mis-named, and should
> be named pkvalue_from_object(), no?  Or is there some case where 
> self.attname
> for a field is *not* set to the primary key attribute name?
>
> Any ideas?  I really want (concept) 
> "myfield.unicode_representation_of_object(myobject)"
>


But why do you need to get that value via the *field* object? The usual way 
to do it is simply to access the attribute directly on the model instance:

unicode(dev.distro)

or, if you have the field name as a string as you imply originally, use 
`getattr`:

unicode(getattr(dev, 'distro'))
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Ch9SdssM6FoJ.
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: Unit-Testing Dilemma

2011-06-21 Thread Ian Clelland
On Tue, Jun 21, 2011 at 7:30 AM, Nan  wrote:

>
>
> > Your view function may indeed be too complex to test properly, and it
> sounds
> > like it is too tightly coupled with with the API call -- there is no way
> to
> > call the view without having it call the actual 3rd-party API as imported
> at
> > the top of the file.
>
> I'd be a little confused as to how to factor that out.  I mean, in the
> actual app that call is refactored behind a function that wraps the
> third-party API, and I could theoretically monkey-patch something over
> that function call for unit testing.  But the view still has to return
> an HttpResponse, and a blank one.
>

You're right, the view does need to return an HttpResponse; there's nothing
you can do about that. My point about tight coupling was that your view has
also been made responsible for instantiating the API wrapper that it thinks
it needs, and there's no way to tell it not to. In other frameworks, I would
immediately suggest using dependency injection -- the view depends on an API
wrapper instance, so it shouldn't be creating that instance; that should be
provided to it:

def my_view(request, api):
...
result = api.call(msg)

because then you could call my_view(request, theAPI()) in most
circumstances, but my_view(request, fake_api) in test code. Unfortunately,
the view is almost always called directly by Django, and you don't have much
control over its parameters.


> > The other way is to make your view function as simple as possible --
> simple
> > enough that it is obviously correct, without any unit tests. Take
> > *everything* that can affect the message which is passed to the API, and
> > abstract that into another function that the view can call. Then test
> *that*
> > function as a unit.
>
> Yes, it is very complex: it has to assess about 30 different potential
> states via nested conditionals.  It's actually broken down into a
> number of sub-functions that each deal with a few sub-states; and
> while refactoring might be a good idea, I wouldn't want to even
> attempt that before having some good unit tests in place!
>
> I think what you're suggesting (correct me if I'm wrong) is to have
> the top-level view function be the only place the API is called, and
> to use only a single call; every other sub-function that reaches an
> exit state should instead return a string containing the message to
> send?
>

That's what I was suggesting; that way the view becomes simple enough that
anyone looking at it can be assured of its correctness, without a host of
unit tests. Those tests can be applied to the functions that actually
construct the messages. But, see below -- I didn't realise that this effort
was to aid in refactoring the code.


>
> Thinking aloud, my concern then becomes that some of the sub-functions
> must actually make multiple API calls.  So we'd have to be returning
> tuples or something instead.
>
> > If theAPI is a class, then give it methods like setTestMode() and
> > resetTestMode(), and use them in your setUp and tearDown methods. Then,
> if
> > test mode is enabled, don't actually make the third party call, just
> store
> > the passed-in message in a module-level or class-level list and return
> > success. After your view returns, check the list to see that the message
> was
> > correct.
>
> Oh!  Thank you!  I didn't understand before how a mock API might make
> that possible -- it makes a lot more sense now.  That soudns like the
> perfect way to do it.
>
> At least until we've got enough tests to make sure the refactoring is
> correct, I need to be able to create the tests without touching the
> actual view logic, so testing what the API receives makes the most
> sense to me.
>

If this is all for a refactoring, then you're probably on the right track
there -- instrument the existing object for testing, rather than
restructuring the view first. Get the code into a state where you can trust
it, and then you can start restructuring it to make it more easily testable
in the future.

Good luck! :)


-- 
Regards,
Ian Clelland


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



QuerySet .annotate().extra() issues

2011-06-21 Thread Michał Sawicz
Hi all,

I'm not sure it's actually supposed to work, but looks like a common
enough approach that it should.

Say you have an aggregate query:
> Model.objects.values('field').annotate(Sum('count'))
that results in an aggregate query that follows:
> SELECT "models_model"."field", SUM("models_model"."count") AS
> "count__sum" FROM "models_model" GROUP BY "models_model"."field"

And that's all fine, but if you want to get additional fields:
> Model.objects.values('field').annotate(Sum('count')).values('field',
> 'field2', 'count_sum')
the additional fields get added to the GROUP BY clause:
> SELECT "models_model"."field", "models_model"."field2",
> SUM("models_model"."count") AS "count__sum" FROM "models_model" GROUP
> BY "models_model"."field", "models_model"."field",
> "models_model"."field2"

That doesn't, in itself, pose any problems. "field" is added twice, but
that's probably optimized down within SQL itself. I'm only afraid that
grouping by "field" and "field2" is slower than grouping by "field" is.
Maybe my approach here is wrong? What would you do to group by "field",
annotate with SUM("count") and retrieve "field2", too?

Now, if you want to leverage some more advanced queries:
> Model.objects.values('field').annotate(Sum('count')).values('field',
> 'field2', 'count_sum').extra({'value': 'SUM("models_model"."field3" *
> "models_model"."count")'})
that breaks with:
> DatabaseError: aggregate functions are not allowed in the GROUP BY
> clause
because the resulting query looks like this:
> SELECT (SUM("models_model"."field3" * "models_model"."count")) AS
> "value", "models_model"."field", "models_model"."field2",
> SUM("models_model"."count") AS "count__sum" FROM "models_model" GROUP
> BY "models_model"."field", "models_model"."field",
> "models_model"."field2", (SUM("models_model"."field3" *
> "models_model"."count"))
As you can see, the field definitions from extra() gets added to the
GROUP BY clause, and fails.
If I drop the last added GROUP BY element (or even all of them, bar
"field"), the query is working fine, and the results are as expected.

Is this an eccentric enough usecase that I should forget about that? Or
is my approach simply wrong?

Best regards,
-- 
Michał (Saviq) Sawicz 


signature.asc
Description: This is a digitally signed message part


csrf protection and testing with tsung

2011-06-21 Thread Ivan Uemlianin
Dear All

I have a live(ish) django website which I'm testing with tsung.

With tsung you record a site visit (called a session) --- log in, view
various pages, do a few things, log out --- and tsung will then hit
the site with lots of randomised versions of this session.

Many of the views are csrf protected, and the automated requests tsung
generates don't get through the protection.  For the moment I'm just
commenting out the csrf middleware in settings.py, but this is
obviously inconvenient.

Has anyone used tsung on csrf-protected views?  If so, how did you do
it?

Has anyone done similar automated requests on csrf-protected views?
How?

I've read the django docs about csrf protection, but I'm not quite
clear how it works.  Can anyone point me to documentation on how it
works (and then I might be able to write something into the tsung
scripts to comply with it).

With thanks and best wishes

Ivan

-- 
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: Unit-Testing Dilemma

2011-06-21 Thread Nan


> That's what I was suggesting; that way the view becomes simple enough that
> anyone looking at it can be assured of its correctness, without a host of
> unit tests. Those tests can be applied to the functions that actually
> construct the messages.

Right, it's really those supporting functions that I need to test, but
they currently don't return anything more informative than the view
does (i.e. blank HttpResponse)

> If this is all for a refactoring, then you're probably on the right track
> there -- instrument the existing object for testing, rather than
> restructuring the view first. Get the code into a state where you can trust
> it, and then you can start restructuring it to make it more easily testable
> in the future.

Well, it's not just for refactoring -- we're planning to add
additional features that will make the state logic even more complex.
But if more testable code would require refactoring, I'd like to
already have some form of tests in place anyway because there's a
decent chance that refactoring without them would break something.

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



Re: Strange value_from_object() return value (2L returned instead of unicode string)

2011-06-21 Thread Jeff Blaine
On Tuesday, June 21, 2011 11:00:37 AM UTC-4, Tom Evans wrote:
>
> On Tue, Jun 21, 2011 at 3:47 PM, Jeff Blaine  wrote:
> > Any ideas?  I really want (concept)
> > "myfield.unicode_representation_of_object(myobject)"
> >
>
> unicode(myobject.myfield) // unicode(getattr(myobject, 'myfield'))
>
> Am I being dense?
>
Nope, you're just dealing with a newbie.  The second form works perfectly
for my needs.  Thanks! 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/ISb3Re7hHYYJ.
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: Strange value_from_object() return value (2L returned instead of unicode string)

2011-06-21 Thread Jeff Blaine

>
> But why do you need to get that value via the *field* object? The usual way 
> to do it is simply to access the attribute directly on the model instance:
>
> unicode(dev.distro)
>
> or, if you have the field name as a string as you imply originally, use 
> `getattr`:
>
> unicode(getattr(dev, 'distro'))
>

Indeed, that's what I am doing now:

for field in Device._meta.fields:
vname = field.verbose_name
val = unicode(getattr(dev, field.name))
val = sanitized_value(val)
self.stdout.write("%s: %s\n" % (vname, val))
 
Thank you all.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/vTfXKM6K914J.
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.



making instance of auth User results in: maximum recursion depth exceeded while calling a Python object

2011-06-21 Thread T'mas
Hi there,

I am having problem with User model from django.contrib.auth.models.
When making instance in view:

user = User.objects.get(username='tmas')

it results in error: maximum recursion depth exceeded while calling a
Python object

I am running Xubuntu 11.04, python 2.7.1+ and django 1.3.
Running it on development server, didn't use on apache.


regards,

Tomas Debnar

-- 
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: making instance of auth User results in: maximum recursion depth exceeded while calling a Python object

2011-06-21 Thread T'mas
sorry. Problem is not User object but login from django.contrib.auth.

login(request,user)

On Jun 21, 6:21 pm, "T'mas"  wrote:
> Hi there,
>
> I am having problem with User model from django.contrib.auth.models.
> When making instance in view:
>
> user = User.objects.get(username='tmas')
>
> it results in error: maximum recursion depth exceeded while calling a
> Python object
>
> I am running Xubuntu 11.04, python 2.7.1+ and django 1.3.
> Running it on development server, didn't use on apache.
>
> regards,
>
> Tomas Debnar

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



Re: How to use django-profile with django registration ?

2011-06-21 Thread Cal Leeming [Simplicity Media Ltd]
You are kidding right?

The job of a developer isn't just to write code, it's to solve problems.

django-users is *not* your personal tutor.

On Tue, Jun 21, 2011 at 3:27 PM, Satyajit Sarangi  wrote:

> Yes I know thats the problem . But , want to know whats the way out .
>
>
> On Tue, Jun 21, 2011 at 7:52 PM, Piotr Zalewa  wrote:
>
>> In urls.py you've got:
>>   url(r'^accounts/', include('registration.urls')),
>>
>> and later:
>>(r'^accounts/', include('userprofile.urls')),
>>
>> /me is no expert, but that smells like asking for trouble.
>>
>> zalun
>>
>>
>>
>> On 06/21/11 14:48, Satyajit Sarangi wrote:
>>
>>> I am using 1.3
>>> This is my settings.py
>>> http://dpaste.com/556954/
>>>
>>> This is my urls.py
>>> http://dpaste.com/556955/
>>>
>>> On Tue, Jun 21, 2011 at 7:14 PM, Piotr Zalewa >> > wrote:
>>>
>>>On 06/21/11 14:15, Satyajit Sarangi wrote:
>>>
>>>
>>> https://bitbucket.org/__**ubernostrum/django-__**registration
>>>
>>> >
>>> This is
>>>what I
>>>am using for user registration . Once , I log in the user is not
>>>able
>>>to get into the userprofile page .
>>>
>>>Thus I installed this
>>>
>>> https://bitbucket.org/__**ubernostrum/django-profiles/
>>>
>>> 
>>> >
>>>for user profile .
>>>
>>>
>>>Recent commits were done 2 years ago.
>>>Which version of Django do you use?
>>>
>>>
>>>
>>>Now , this produces a conflict in urls.py and also settings.py
>>>file .
>>>
>>>
>>>Would you provide any errors?
>>>
>>>
>>>How to resolve it . What changes needs to be done with urls.py and
>>>settings.py so that , when a user logs in , he/she is redirected
>>> to
>>>the profile page .
>>>
>>>
>>>How your current urls.py and settings.py do look like?
>>>Please use some dpaste or similar sites.
>>>
>>>zalun
>>>
>>>
>>>--
>>>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+unsubscribe@__goo**glegroups.com
>>>
>>> >> **>.
>>>
>>>For more options, visit this group at
>>>
>>> http://groups.google.com/__**group/django-users?hl=en
>>>
>>> 
>>> >.
>>>
>>>
>>>
>>>
>>> --
>>> _Satyajit Sarangi_
>>>
>>> --
>>>
>>> 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+unsubscribe@**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+unsubscribe@**
>> googlegroups.com .
>> For more options, visit this group at http://groups.google.com/**
>> group/django-users?hl=en
>> .
>>
>>
>
>
> --
> *Satyajit Sarangi*
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: How to use django-profile with django registration ?

2011-06-21 Thread Piotr Zalewa

On 06/21/11 15:27, Satyajit Sarangi wrote:

Yes I know thats the problem . But , want to know whats the way out .


Theway out is to read documentation:
https://docs.djangoproject.com/en/1.3/
especially
https://docs.djangoproject.com/en/1.3/topics/http/urls/

zalun



On Tue, Jun 21, 2011 at 7:52 PM, Piotr Zalewa mailto:zal...@gmail.com>> wrote:

In urls.py you've got:
   url(r'^accounts/', include('registration.urls')),

and later:
(r'^accounts/', include('userprofile.urls')),

/me is no expert, but that smells like asking for trouble.

zalun



On 06/21/11 14:48, Satyajit Sarangi wrote:

I am using 1.3
This is my settings.py
http://dpaste.com/556954/

This is my urls.py
http://dpaste.com/556955/

On Tue, Jun 21, 2011 at 7:14 PM, Piotr Zalewa mailto:zal...@gmail.com>
>> wrote:

On 06/21/11 14:15, Satyajit Sarangi wrote:

https://bitbucket.org/ubernostrum/django-registration

> This is
what I
am using for user registration . Once , I log in the
user is not
able
to get into the userprofile page .

Thus I installed this
https://bitbucket.org/ubernostrum/django-profiles/

>
for user profile .


Recent commits were done 2 years ago.
Which version of Django do you use?



Now , this produces a conflict in urls.py and also
settings.py
file .


Would you provide any errors?


How to resolve it . What changes needs to be done with
urls.py and
settings.py so that , when a user logs in , he/she is
redirected to
the profile page .


How your current urls.py and settings.py do look like?
Please use some dpaste or similar sites.

zalun


--
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+unsubscribe@__goo__glegroups.com

__>.

For more options, visit this group at
http://groups.google.com/group/django-users?hl=en

>.




--
_Satyajit Sarangi_

--

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+unsubscribe@__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+unsubscribe@__googlegroups.com
.
For more options, visit this group at
http://groups.google.com/__group/django-users?hl=en
.




--
_Satyajit Sarangi_

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

Re: csrf protection and testing with tsung

2011-06-21 Thread Malcolm Box
On 21 June 2011 16:48, Ivan Uemlianin  wrote:
> With tsung you record a site visit (called a session) --- log in, view
> various pages, do a few things, log out --- and tsung will then hit
> the site with lots of randomised versions of this session.
>

> Many of the views are csrf protected, and the automated requests tsung
> generates don't get through the protection.  For the moment I'm just
> commenting out the csrf middleware in settings.py, but this is
> obviously inconvenient.
>

I think you'll need to do some work with dyn_variable to pull the csrf
token out of the original form and re-inject it into the post you send
back. As far as I understand it, all that the csrf protection is is an
opaque value hidden in any form that needs to be present in the
submitted version to be valid. That stops "loose" posts from CSRF
attacks working as they don't know the magic key.

Malcolm

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



Tests got ~10x slower after upgrading to Django 1.3

2011-06-21 Thread Cesar Canassa
I am working in a large Django project that is currently using the 1.2.3
version. The project test suite has around 500 test which take ~50 seconds
to run in my machine.

I recently did a upgrade to the Django 1.3 version, the upgrade was smooth
so far, most problems came from the SQL Server driver but these are not used
in the test suite, since the test database is SQLite. The only thing I had
to change in the project itself was removing the jogging app since the 1.3
has built-in logging facilities.

The problem is that the test suite now takes ~500 seconds to run, that's
about 10 times longer than it did with the 1.2.3 version.

Has anyone had a similar issue? I have a felling that this related to
running Django under Windows.


Regards,
Cesar Canassa

-- 
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: QuerySet .annotate().extra() issues

2011-06-21 Thread Andre Terra
BIG FAT DISCLAIMER
I'm not sure this has anything to do with your issue, but it's easy to miss
when reading the docs.


https://docs.djangoproject.com/en/dev/topics/db/aggregation/#interaction-with-default-ordering-or-order-by

If your model has an 'ordering' attribute defined in Meta, make sure you add
a "blank" .order_by()  to your query.


Sincerely,
André Terra


On Tue, Jun 21, 2011 at 10:58 AM, Michał Sawicz  wrote:

> Hi all,
>
> I'm not sure it's actually supposed to work, but looks like a common
> enough approach that it should.
>
> Say you have an aggregate query:
> > Model.objects.values('field').annotate(Sum('count'))
> that results in an aggregate query that follows:
> > SELECT "models_model"."field", SUM("models_model"."count") AS
> > "count__sum" FROM "models_model" GROUP BY "models_model"."field"
>
> And that's all fine, but if you want to get additional fields:
> > Model.objects.values('field').annotate(Sum('count')).values('field',
> > 'field2', 'count_sum')
> the additional fields get added to the GROUP BY clause:
> > SELECT "models_model"."field", "models_model"."field2",
> > SUM("models_model"."count") AS "count__sum" FROM "models_model" GROUP
> > BY "models_model"."field", "models_model"."field",
> > "models_model"."field2"
>
> That doesn't, in itself, pose any problems. "field" is added twice, but
> that's probably optimized down within SQL itself. I'm only afraid that
> grouping by "field" and "field2" is slower than grouping by "field" is.
> Maybe my approach here is wrong? What would you do to group by "field",
> annotate with SUM("count") and retrieve "field2", too?
>
> Now, if you want to leverage some more advanced queries:
> > Model.objects.values('field').annotate(Sum('count')).values('field',
> > 'field2', 'count_sum').extra({'value': 'SUM("models_model"."field3" *
> > "models_model"."count")'})
> that breaks with:
> > DatabaseError: aggregate functions are not allowed in the GROUP BY
> > clause
> because the resulting query looks like this:
> > SELECT (SUM("models_model"."field3" * "models_model"."count")) AS
> > "value", "models_model"."field", "models_model"."field2",
> > SUM("models_model"."count") AS "count__sum" FROM "models_model" GROUP
> > BY "models_model"."field", "models_model"."field",
> > "models_model"."field2", (SUM("models_model"."field3" *
> > "models_model"."count"))
> As you can see, the field definitions from extra() gets added to the
> GROUP BY clause, and fails.
> If I drop the last added GROUP BY element (or even all of them, bar
> "field"), the query is working fine, and the results are as expected.
>
> Is this an eccentric enough usecase that I should forget about that? Or
> is my approach simply wrong?
>
> Best regards,
> --
> Michał (Saviq) Sawicz 
>

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



saving related objects in overridden save method on model

2011-06-21 Thread lingrlongr
I have these models:

class Widget(models.Model):
name

class Person(models.Model):
requested = models.ForeignKey(Widget, related_name='requested')
considered = models.ManyToManyField(Widget,
related_name='considered')

def save(self, *args, **kwargs):
if not self.considered.filter(id=self.requested.id):
self.considered.add(self.requested)

I'm trying to make sure that when a Person has requested a widget,
that value automatically gets selected added as a considered value
too.  I find that this does work if I do this when no considered
values are selected:

>>> p = Person.objects.get(pk=1)
>>> p.save()

The relationship gets saved.  But when I attempt in the Django admin,
the two fields are not sync'd.  Any reason why this would be?

Thx.

-- 
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: saving related objects in overridden save method on model

2011-06-21 Thread lingrlongr
Woops, I forgot to include the super's save method call in my
example.  Just want to make sure no one thinks that was the problem...

def save(self, *args, **kwargs):
if not self.considered.filter(id=self.requested.id):
   self.considered.add(self.requested)
super(Person, self).save(*args, **kwargs)

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



Signals and model instances with deferred attributes

2011-06-21 Thread Christian Joergensen
Hello,

I am experiencing an inconvenience in regards to working with signals
on model instances with deferred attributes. Specifically I am trying
to get a post_save signal to fire from a save() call on such a model
instance.

The problem is that the sender class (`origin` in
django.db.models.base.ModelBase.save_base) will be the special
deferred class as returned by
django.db.models.query_utils.deferred_class_factory and not the actual
model class. Thus a subscription to post_save on the real model class
will not receive the signal signaled by the deferred class.

An obvious workaround would be to just override the save() method. If
however this behavior is intentional, I think this should be at least
noted in the documentation (on the defer() method) to save others
wasting time on debugging why their signals doesn't fire.

Regards,
Christian

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



WMD-editor: Where's wmd/urls.py?

2011-06-21 Thread Micky Hulse
Anyone here using django-wmd-editor?

https://github.com/jpartogi/django-wmd-editor

If so, could you tell me what its url.py file is supposed to look like? :D

Maybe I am missing something obvious here, but wmd/urls.py does not
exist... What am I missing?

Thanks so much!
Micky

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



set language from user lang in DB?

2011-06-21 Thread galgal


What is the best way to set language that is in DB in UserProfile? I have 
option to select language for users and after selecting it, I update 
UserProfile table to set the language. While logging in, i need to get user 
language from his profile and set it. User changes are made by selecting 
options from list of languages.

How can I dod that in the best way?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/v2GQZXcaz0UJ.
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.



Odp: Re: Change language on login

2011-06-21 Thread galgal
Which solution did You use?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/cTfGWDuX48UJ.
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.



Detecting write to readonly DB slave

2011-06-21 Thread Marty
I'm trying to add functionality to my django project to catch anybody
accidentally sending a write to a readonly replicated DB slave.  Is
there a "best practices" way to do 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.



Re: csrf protection and testing with tsung

2011-06-21 Thread Ivan Uemlianin

Dear Malcolm

Thanks, this is a good clue.  I'll try it out tomorrow and report back.

Best wishes

Ivan


On 21/06/11 17:54, Malcolm Box wrote:

On 21 June 2011 16:48, Ivan Uemlianin  wrote:

With tsung you record a site visit (called a session) --- log in, view
various pages, do a few things, log out --- and tsung will then hit
the site with lots of randomised versions of this session.




Many of the views are csrf protected, and the automated requests tsung
generates don't get through the protection.  For the moment I'm just
commenting out the csrf middleware in settings.py, but this is
obviously inconvenient.



I think you'll need to do some work with dyn_variable to pull the csrf
token out of the original form and re-inject it into the post you send
back. As far as I understand it, all that the csrf protection is is an
opaque value hidden in any form that needs to be present in the
submitted version to be valid. That stops "loose" posts from CSRF
attacks working as they don't know the magic key.

Malcolm




--

Ivan A. Uemlianin
Speech Technology Research and Development

i...@llaisdy.com
 www.llaisdy.com
 llaisdy.wordpress.com
 www.linkedin.com/in/ivanuemlianin

"Froh, froh! Wie seine Sonnen, seine Sonnen fliegen"
 (Schiller, Beethoven)


--
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: QuerySet .annotate().extra() issues

2011-06-21 Thread Michał Sawicz
Dnia 2011-06-21, wto o godzinie 14:31 -0300, Andre Terra pisze:
> I'm not sure this has anything to do with your issue, but it's easy to
> miss when reading the docs.

It's kind of related, but not directly. The similarity to the issue
mentioned above is that the default ordering field is added to the GROUP
BY clause, too.

Not exactly my issue, but good input nevertheless, since that kind of
confirms that the behavior is "on purpose".

Any way to circumvent that in that case?

Cheers,
-- 
Michał (Saviq) Sawicz 


signature.asc
Description: This is a digitally signed message part


ANN: django-kolibri - a concept for Asynchronous Processors/Workflow management for django.

2011-06-21 Thread Thomas Weholt
Proof of concept. Need comments. Released under a modified BSD-license.

http://pypi.python.org/pypi/Kolibri/0.1.0a

or better

https://bitbucket.org/weholt/django-kolibri

There's a blogpost with two screencasts at http://weholt.blogspot.com/ as well.

NB! If anybody can tell me why my my pypi-entry don't get formatted
like restructured text that would be swell. Thanks!

-- 
Mvh/Best regards,
Thomas Weholt
http://www.weholt.org

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



Re: ANN: django-kolibri - a concept for Asynchronous Processors/Workflow management for django.

2011-06-21 Thread Calvin Spealman
Interesting project. My first question was going to be "Why aren't you
just using Celery?" until I got to the part of the description that
says it is built on *top* of celery.

The first question that comes up for me is how or if you track which
processes have already been run, to keep them from being executed more
than they should. For example, if you had a process that blurred
uploaded images, you wouldn't want it run more than once, because it
is destructive.

On Tue, Jun 21, 2011 at 5:09 PM, Thomas Weholt  wrote:
> Proof of concept. Need comments. Released under a modified BSD-license.
>
> http://pypi.python.org/pypi/Kolibri/0.1.0a
>
> or better
>
> https://bitbucket.org/weholt/django-kolibri
>
> There's a blogpost with two screencasts at http://weholt.blogspot.com/ as 
> well.
>
> NB! If anybody can tell me why my my pypi-entry don't get formatted
> like restructured text that would be swell. Thanks!
>
> --
> Mvh/Best regards,
> Thomas Weholt
> http://www.weholt.org
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>



-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy

-- 
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: ANN: django-kolibri - a concept for Asynchronous Processors/Workflow management for django.

2011-06-21 Thread Thomas Weholt
On Tue, Jun 21, 2011 at 11:16 PM, Calvin Spealman  wrote:
> Interesting project. My first question was going to be "Why aren't you
> just using Celery?" until I got to the part of the description that
> says it is built on *top* of celery.

Yes, it might be a good idea to put that in the beginning of the info.

> The first question that comes up for me is how or if you track which
> processes have already been run, to keep them from being executed more
> than they should. For example, if you had a process that blurred
> uploaded images, you wouldn't want it run more than once, because it
> is destructive.

Well, each time a processor is executed it creates a record in the
database, with a link to the item it processed. The current system
will show if some processor has been used on a given model instance
before, but nothing is stopping you from processing that instance
again. Perhaps the processor could have some extra property saying if
it should only be executed once for any given item? A possible 0.2.0
feature :-).

Thanks for your interest :-)

Thomas

-- 
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: Re : Re: Caught DatabaseError while rendering: no such function: IF

2011-06-21 Thread yomguy
OK, this "virtual" method calls a MySQL command that need to be translated 
in SQLite language if I need it.
One solution is to check the engine used in settings.
Y

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/P7KyyzqjfUgJ.
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: ANN: django-kolibri - a concept for Asynchronous Processors/Workflow management for django.

2011-06-21 Thread Andre Terra
I only got as far as reading the project overview, but it looks incredibly
sweet. Will have to give it a try over the weekend.

Keep up the good work!


Sincerely,
André Terra

On Tue, Jun 21, 2011 at 6:29 PM, Thomas Weholt wrote:

> On Tue, Jun 21, 2011 at 11:16 PM, Calvin Spealman 
> wrote:
> > Interesting project. My first question was going to be "Why aren't you
> > just using Celery?" until I got to the part of the description that
> > says it is built on *top* of celery.
>
> Yes, it might be a good idea to put that in the beginning of the info.
>
> > The first question that comes up for me is how or if you track which
> > processes have already been run, to keep them from being executed more
> > than they should. For example, if you had a process that blurred
> > uploaded images, you wouldn't want it run more than once, because it
> > is destructive.
>
> Well, each time a processor is executed it creates a record in the
> database, with a link to the item it processed. The current system
> will show if some processor has been used on a given model instance
> before, but nothing is stopping you from processing that instance
> again. Perhaps the processor could have some extra property saying if
> it should only be executed once for any given item? A possible 0.2.0
> feature :-).
>
> Thanks for your interest :-)
>
> Thomas
>
> --
> 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.



Using multiple forms to manage a model under admin

2011-06-21 Thread Eiji Kobayashi
Hello,

I have a question for all you django wizards. I want to use different forms
for managing a model in Django's admin. I thought it's common problem, but I
cannot find a good solution even after reading through google, stackoverflow
and django's source code. (My apologies if this is a often asked newbie
question).

For example, I have a model like this:

# users/models.py
...
REG_STATUS_TYPE = (
( 'queued', 'Queued' ),
( 'sent', 'Sent' ),
( 'accepted', 'Accepted' ),
( 'declined', 'Declined' ),
( 'blocked', 'Blocked' ),
)
class RegistrationQueue(models.Model):
  user = models.ForeignKey(User)
  created = models.DateTimeField(default=datetime.datetime.now,
editable=False)
  status = models.CharField(max_length=10, choices=REG_STATUS_TYPE,
default='queued')
  accepted = models.DateTimeField(editable=False, null=True)
...

# users/admin.py
...
class RegistrationViewForm(models.ModelForm):
  class Meta:
model = RegistrationQueue

class RegistrationAddForm(models.ModelForm):
  class Meta:
model = User

class RegistrationQueueAdmin(admin.ModelAdmin):
add_form = RegistrationAddForm
view_form = RegistrationViewForm

def get_form(self, request, obj=None, **kwargs):
defaults = {}
if obj is None:
defaults.update({
'form': self.add_form,
})
else:
defaults.update({
'form': self.view_form
})
defaults.update(kwargs)
return super(RegistrationAdmin, self).get_form(request, obj,
**defaults)
admin.site.register(RegistrationQueue, RegistrationQueueAdmin)

What I'm trying to do is simple really. When creating a new
RegistrationQueue entry, I would like Django's admin to use a form derived
from the User model (which would let me create a temporary user, and then I
can take some of the information from that and other things to automatically
create a RegistrationQueue entry).

However, when listing or changing the RegistrationQueue, I would like to use
a form derived from the RegistrationQueue model.

So, as you can see above, I tried to replace ModelAdmin's get_form method
with a custom one that just checks the incoming obj variable. If it's set to
None, I know it's trying a create a new entry. Otherwise, it's something
else.

The problem is that the admin always uses the form derived from the
RegistrationQueue, and never the User. Whenever I click to add a
RegistrationQueue, I get a form with fields belonging to the
RegistrationQueue model.

Please tell me what I'm doing wrong. Thank you very much in advance.

Eiji

-- 
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: Unit-Testing Dilemma

2011-06-21 Thread Andy McKay

On 2011-06-20, at 12:52 PM, Nan wrote:

> I'm not testing the third-party service.  I need to test *what I send
> to them*. 

Use Mock and assert_called_with:

http://www.voidspace.org.uk/python/mock/mock.html#mock.Mock.assert_called_with

In this case you'd set theAPI.call as your mock and check that under different 
conditions it is called correctly.
--
  Andy McKay
  a...@clearwind.ca
  twitter: @andymckay
 

-- 
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 display form data with original values after validation failure?

2011-06-21 Thread snfctech
In the case of editing a form, I want to display the original value of
a field prior to validation failure, as well as the validation
errors.  This doesn't seem to work:

if fs.is_valid():
fs.save()
else:
# return original data - not default changed data
errors = fs._errors
q =
JosJeventsRegistration.objects.using('default').filter(user=user,
status='cart')
fs = RegistrationFormSet(queryset=q)
fs._errors = errors

Context:

For my UI on a class registration shopping cart, a user can edit the
number of guests.  Some classes have limited availability for certain
roles - e.g. there may only be 2 spaces available, so the user can
only enter 2 guests (including themselves).  The current error
messaging says "There are only x more spaces available for this
role."  If the user already had 1 guest and then enters 4 guests, then
it's unclear how many spaces the user can enter to correct the error
unless they remembered the original value.  I think it would be more
straight forward if the form reset to its original values and
displayed the error.

Any tips on how to best accomplish this would be greatly appreciated.

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



Re: how to display form data with original values after validation failure?

2011-06-21 Thread Shawn Milochik
One good way is to just use AJAX: If it's a 'get' request, return your 
rendered template as normal. If it's a 'post' request, return a JSON 
response that has a success/failure status and confirmation/error 
messages (form.errors.as_text()).


I'm doing this using jquery-notify to tell the user that it went great 
or what the problem was:

http://www.erichynds.com/examples/jquery-notify/

If you need to redirect or refresh the page on success you can handle 
that with JavaScript as well. In addition to being faster than a 
full-page refresh this happens to solve your 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: Tests got ~10x slower after upgrading to Django 1.3

2011-06-21 Thread Russell Keith-Magee
On Wed, Jun 22, 2011 at 1:31 AM, Cesar Canassa  wrote:
> I am working in a large Django project that is currently using the 1.2.3
> version. The project test suite has around 500 test which take ~50 seconds
> to run in my machine.
> I recently did a upgrade to the Django 1.3 version, the upgrade was smooth
> so far, most problems came from the SQL Server driver but these are not used
> in the test suite, since the test database is SQLite. The only thing I had
> to change in the project itself was removing the jogging app since the 1.3
> has built-in logging facilities.
> The problem is that the test suite now takes ~500 seconds to run, that's
> about 10 times longer than it did with the 1.2.3 version.
> Has anyone had a similar issue? I have a felling that this related to
> running Django under Windows.

I can't say I've heard any such reports -- if anything, 1.3 testing
should be faster, due to a number of optimizations in the test startup
process.

If you identify the source of the slowdown, I'd be interested in
hearing about it in case it is a serious regression on Django's part.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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 display form data with original values after validation failure?

2011-06-21 Thread snfctech
Thanks for your reply, Shawn.

I'll think about that - but I think I would prefer to use more boiler-
plate Django form behavior and just get a formset with errors returned
to my template in the full-page response.

On Jun 21, 5:44 pm, Shawn Milochik  wrote:
> One good way is to just use AJAX: If it's a 'get' request, return your
> rendered template as normal. If it's a 'post' request, return a JSON
> response that has a success/failure status and confirmation/error
> messages (form.errors.as_text()).
>
> I'm doing this using jquery-notify to tell the user that it went great
> or what the problem was:http://www.erichynds.com/examples/jquery-notify/
>
> If you need to redirect or refresh the page on success you can handle
> that with JavaScript as well. In addition to being faster than a
> full-page refresh this happens to solve your 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.



syncdb error

2011-06-21 Thread T4 Phage
Hello!

When I run syncdb it returns an error ending in
"_mysql_exceptions.OperationalError: (1050, "Table 'people_person'
already exists")."  I know that the table 'people_person' already
exists because I used syncdb to make it earlier (and because I can see
it in my database).

Of course if I dump all the problem tables manually syncdb runs fine
and creates everything anew.  Obviously this is problematic (every
time I add a new app I have to reset the tables for all my old
apps).

I thought that syncdb didn't do anything to already existing tables,
and that it only tried to create tables for apps that didn't already
have tables.  Does anyone know what my problem might be?

Phage

-- 
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: Unit-Testing Dilemma

2011-06-21 Thread Andrew Brookins
You don't need mocks or dependency injection in this case. Just separate the 
message construction code, so you can test it in isolation:

# myapp.views
from django.http import HttpResponse
from myapp.models import CurrentState
from myapp.exceptions import ApiFailureException
from third_party.api import theAPI 


def my_view(request):
state = CurrentState.get(pk=request. session.get('state'))
new_data = request.POST.get('new_data')
state.update(new_data)
msg = _get_message(state, new_data)
result = theAPI.call(msg)
if result is None:
return ApiFailureException()
return HttpResponse('success')

def _get_message(state, new_data):
message = None
if state.x() and state.y():
message = '%s/%s' % (state.a(), new_data)
elif state.z():
message = '%s/%s' % (state.b(), new_data)
else:
message = state.c()
return message


# third_party.api
import urllib, urllib2
from django.conf import settings

class theAPI(object):
def call(self, msg=''):
data = urllib.urlencode({'message': msg})
req = urllib2.Request(url=settings.THIRD_PARTY_API_URL, data=data)
resp = urllib2.urlopen(req)
return resp.status == '200' 


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/sx939cizEBYJ.
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: csrf token driving me crazy

2011-06-21 Thread Divkis
Is there no one who has had similar problem with django1.3? Could
anyone please help me on this? I have almost hit a dead on this one.

Thanks & Regards,
Divkis01

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



Upcoming Django conference in Asia Pacific

2011-06-21 Thread Dealshelve Team
Hey guys,

Do we have any upcoming Django conference in Asia Pacific region or any
Django conference at all here?

Cheers,
Dealshelve Team
http://dealshelve.com

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



Re: Upcoming Django conference in Asia Pacific

2011-06-21 Thread Russell Keith-Magee
On Wed, Jun 22, 2011 at 1:59 PM, Dealshelve Team  wrote:
> Hey guys,
>
> Do we have any upcoming Django conference in Asia Pacific region or any
> Django conference at all here?

There is usually a Django presence (i.e., a core developer or two, a
few talks, and many Django users) at PyCon.AU, PyCon.NZ and
PyCon.APAC.

However, at present, there are no concrete plans to hold a
DjangoCon.AU, DjangoCon.NZ or DjangoCon.APAC.

There have been many expressions of interest in attending such an
event; however, what is missing is a group of community members
willing to step up and organize the event. If such a group were to
emerge, the Django Software Foundation would do whatever it can to
support the organization process.

Yours,
Russ Magee %-)

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



updating a user form?

2011-06-21 Thread raj
I'm trying to create an update_profile form. This form will be able to
update extended user information that is not in the original form.

So, I have a form that allows you to create an account. There a lot of
other fields that aren't listed in this form. The rest of these fields
will be found when the user actually logs in. What I can't figure out
is how to make the class that allows them to update this information.
Like in the extended user class that I made, I have a save function
that creates a user and saves it. But I don't want to create another
user with this form. I simply want to update the current authenticated
user. I thought there would be an update_user type function in the
UserManager(), but there isn't. I tried googling and didn't come up
with much. Help Please?

-- 
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: updating a user form?

2011-06-21 Thread Herman Schistad
On Wed, Jun 22, 2011 at 08:28, raj  wrote:
> I'm trying to create an update_profile form. This form will be able to
> update extended user information that is not in the original form.
>
> So, I have a form that allows you to create an account. There a lot of
> other fields that aren't listed in this form. The rest of these fields
> will be found when the user actually logs in. What I can't figure out
> is how to make the class that allows them to update this information.
> Like in the extended user class that I made, I have a save function
> that creates a user and saves it. But I don't want to create another
> user with this form. I simply want to update the current authenticated
> user. I thought there would be an update_user type function in the
> UserManager(), but there isn't. I tried googling and didn't come up
> with much. Help Please?

I don't quite understand what you mean...

When you say load the url: /userprofile/1234/ at got your urls.py to
get  from the URL.
Then you could load that userprofile from the db with e.g.

def a_nice_view(request, id):
from django.auth.models import User
userprofile = User.objects.get(pk=id)
## Then do updating on that profile here ##
userprofile.username = "Somethingnew"

It's the same way with a form/request, and you can get the userprofile
with: request.user

All this is pretty basic stuff, and as I've seen you ask a lot of
these questions on django-users I would really advise you to read a
introductory book or do some more tutorials before trying to make
something advanced yourselves.

-- 
With regards, Herman Schistad

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



MemoryError

2011-06-21 Thread Gagan (GPS)
Hi,

I am building a website that can access data from my server, plot it
and present it in a pdf format. I am experiencing the following error
and am unable to understand what to do. Kindly help.

Traceback (most recent call last):
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
  File "/usr/lib/python2.7/dist-packages/django/contrib/staticfiles/
handlers.py", line 68, in __call__
return self.application(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/django/core/handlers/
wsgi.py", line 247, in __call__
response = self.get_response(request)
  File "/usr/lib/python2.7/dist-packages/django/core/handlers/
base.py", line 169, in get_response
response = self.handle_uncaught_exception(request, resolver,
sys.exc_info())
  File "/usr/lib/python2.7/dist-packages/django/core/handlers/
base.py", line 203, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
  File "/usr/lib/python2.7/dist-packages/django/views/debug.py", line
63, in technical_500_response
html = reporter.get_traceback_html()
  File "/usr/lib/python2.7/dist-packages/django/views/debug.py", line
268, in get_traceback_html
return t.render(c)
  File "/usr/lib/python2.7/dist-packages/django/template/base.py",
line 124, in render
return self._render(context)
  File "/usr/lib/python2.7/dist-packages/django/template/base.py",
line 118, in _render
return self.nodelist.render(context)
  File "/usr/lib/python2.7/dist-packages/django/template/base.py",
line 747, in render
bits.append(self.render_node(node, context))
  File "/usr/lib/python2.7/dist-packages/django/template/debug.py",
line 73, in render_node
result = node.render(context)
  File "/usr/lib/python2.7/dist-packages/django/template/
defaulttags.py", line 313, in render
return self.nodelist_true.render(context)
  File "/usr/lib/python2.7/dist-packages/django/template/base.py",
line 747, in render
bits.append(self.render_node(node, context))
  File "/usr/lib/python2.7/dist-packages/django/template/debug.py",
line 73, in render_node
result = node.render(context)
  File "/usr/lib/python2.7/dist-packages/django/template/
defaulttags.py", line 78, in render
output = self.nodelist.render(context)
  File "/usr/lib/python2.7/dist-packages/django/template/base.py",
line 747, in render
bits.append(self.render_node(node, context))
  File "/usr/lib/python2.7/dist-packages/django/template/debug.py",
line 73, in render_node
result = node.render(context)
  File "/usr/lib/python2.7/dist-packages/django/template/
defaulttags.py", line 229, in render
nodelist.append(node.render(context))
  File "/usr/lib/python2.7/dist-packages/django/template/
defaulttags.py", line 313, in render
return self.nodelist_true.render(context)
  File "/usr/lib/python2.7/dist-packages/django/template/base.py",
line 747, in render
bits.append(self.render_node(node, context))
  File "/usr/lib/python2.7/dist-packages/django/template/debug.py",
line 73, in render_node
result = node.render(context)
  File "/usr/lib/python2.7/dist-packages/django/template/
defaulttags.py", line 238, in render
return nodelist.render(context)
  File "/usr/lib/python2.7/dist-packages/django/template/base.py",
line 750, in render
return mark_safe(''.join([force_unicode(b) for b in bits]))
TemplateSyntaxError: Caught MemoryError while rendering:[22/Jun/2011
14:48:01] "GET /plot/plot/12.pdf HTTP/1.1" 500 59

-- 
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: Upcoming Django conference in Asia Pacific

2011-06-21 Thread Kenneth Gonsalves
On Wed, 2011-06-22 at 14:08 +0800, Russell Keith-Magee wrote:
> > Do we have any upcoming Django conference in Asia Pacific region or
> any
> > Django conference at all here?
> 
> There is usually a Django presence (i.e., a core developer or two, a
> few talks, and many Django users) at PyCon.AU, PyCon.NZ and
> PyCon.APAC. 

and inpycon (although so far no core people)
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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