Re: __unicode__() addition not working in basic poll application.

2011-05-17 Thread maaz muqri
but still I am getting same problem

On May 16, 6:58 pm, AJ  wrote:
> I think you are getting the poll object back. You need to specify the method
> for your model class(es)
>
> def __unicode__(self):
>         return "%s %s %s" % (self.poll_name)
>
>
>
>
>
>
>
>
>
> On Mon, May 16, 2011 at 8:32 AM, maaz muqri  wrote:
> > Hi,
> > 
> > class Poll(models.Model):
> >    # ...
> >    def __unicode__(self):
> >        return self.question
>
> > class Choice(models.Model):
> >    # ...
> >    def __unicode__(self):
> >        return self.choice
> > 
>
> > after adding the above code also I am not able to retrieve the
> > question by the command:
>
> > I am getting this
>
> > >>>Poll.objects.all()
> > []
>
> > instead of this
>
> > >>>Poll.objects.all()
> > []
>
> > --
> > 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.
>
> --
> AJ

-- 
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: __unicode__() addition not working in basic poll application.

2011-05-17 Thread Roman Klesel
2011/5/16 maaz muqri :

> I am getting this
>
Poll.objects.all()
> []

What do you get when you do:

print unicode(Poll.objects.all()[0])

?

Regards
 Roman

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



Re: performance of model instgance save()

2011-05-17 Thread Lucian Nicolescu
I had at similar problem at some point and found that the fasest way
was to generate raw sql insert/copy commands - if you're still
experimenting you might want to try that as well.

On Tue, May 17, 2011 at 12:39 AM, Brian  wrote:
>> > I'd think you'll find it's significantly more than a factor of 2. For bulk
>> > inserts, raw SQL is often several orders of magnitude faster.
>>
>> You might want to check outhttp://pypi.python.org/pypi/dse/. My tests
>> using postgres showed a 3Xperformancegain on inserts compared to
>> using the orm and nearly 10X when doing heavy updates on existing
>> data. It takes care of creating SQL for you and respects default
>> values defined in your models.
>
> Common sense is telling me that any further performance gains I get
> for this test script will be more than
> offset by the time I've spent on them :-)
>
> I switched to using psycopg2 directly to do the inserts (committing in
> batches of several thousand) and found
> roughly another factor of 2. For what it's worth, that single sample
> point is in the same ballpark as the 10x improvement
> mentioned for dse.
>
> One thing that was confusing for a while was that the first batch of
> inserts takes 5 times as long
> as subsequent  batches. I didn't really get to the bottom of why that
> might be. It might be fixed by using a server-side
> cursor (maybe the first batch expands the client-side memory
> inefficiently, but hangs on to it for subsequent
> batches), but when I seemed to hit a bug when I tried using a named
> cursor (psycopg2 2.2.1).
>
> And then I climbed back out of the rabbit hole.
>
> --
> 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.



Memcached backend - caching data with infinite timeout

2011-05-17 Thread Paweł Roman
Python-memcached docstring for set() says this:

"""
@param time: Tells memcached the time which this value should expire,
either
as a delta number of seconds, or an absolute unix time-since-the-epoch
value. See the memcached protocol docs section "Storage Commands"
for more info on . We default to 0 == cache forever.
"""

So it says, zero means forever. But django wrapper class for memcache
has this line in set():

timeout = timeout or self.default_timeout

Which means that it will never accept zero as a value unless I specify
a default timeout of zero in settings (which I don't want to do,
because I want to have the default value other than 'forever'), I only
need infinite timeout in few cases.

Either python-memcached docstring is wrong (i.e. setting time to zero
doesnt mean "forever") or django doesnt implement it 100% correctly.

-- 
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: Memcached backend - caching data with infinite timeout

2011-05-17 Thread Malcolm Box
That looks like a bug in Django. I suggest you file a ticket. 

The fix would be to compare timeout to None 

Sent from my iPhone, please excuse any typos

On 17 May 2011, at 10:54, Paweł Roman  wrote:

> Python-memcached docstring for set() says this:
> 
> """
> @param time: Tells memcached the time which this value should expire,
> either
> as a delta number of seconds, or an absolute unix time-since-the-epoch
> value. See the memcached protocol docs section "Storage Commands"
> for more info on . We default to 0 == cache forever.
> """
> 
> So it says, zero means forever. But django wrapper class for memcache
> has this line in set():
> 
> timeout = timeout or self.default_timeout
> 
> Which means that it will never accept zero as a value unless I specify
> a default timeout of zero in settings (which I don't want to do,
> because I want to have the default value other than 'forever'), I only
> need infinite timeout in few cases.
> 
> Either python-memcached docstring is wrong (i.e. setting time to zero
> doesnt mean "forever") or django doesnt implement it 100% correctly.
> 
> -- 
> 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: Memcached backend - caching data with infinite timeout

2011-05-17 Thread Tom Evans
On Tue, May 17, 2011 at 11:03 AM, Malcolm Box  wrote:
> That looks like a bug in Django. I suggest you file a ticket.
>
> The fix would be to compare timeout to None
>

A ticket has already been submitted about this. The issue is that
although memcache allows setting 'infinite' timeouts (its not
infinite, it just pushes out old data on LRU basis), other backends do
not.

http://code.djangoproject.com/ticket/9595

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.



How to register JS event handler

2011-05-17 Thread Thomas Guettler
Hi,

I want to register some jquery event handler for some widgets of a form 
(FooForm). The
form gets used in several views.

It would be a pain to insert $(function(){...}) in every page which uses this 
form.

The Media Form objects only handles links to JS files.

Any hints how to insert the js/jquery lines in every page which uses FooForm?

  Thomas

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

-- 
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: __unicode__() addition not working in basic poll application.

2011-05-17 Thread maaz muqri
im just getting "Poll object" as output

On May 17, 1:14 pm, Roman Klesel  wrote:
> 2011/5/16 maaz muqri :
>
> > I am getting this
>
> Poll.objects.all()
> > []
>
> What do you get when you do:
>
> print unicode(Poll.objects.all()[0])
>
> ?
>
> Regards
>  Roman

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



Re: How to register JS event handler

2011-05-17 Thread Michal Petrucha
On Tue, May 17, 2011 at 12:34:05PM +0200, Thomas Guettler wrote:
> Hi,
> 
> I want to register some jquery event handler for some widgets of a form 
> (FooForm). The
> form gets used in several views.
> 
> It would be a pain to insert $(function(){...}) in every page which uses this 
> form.
> 
> The Media Form objects only handles links to JS files.
> 
> Any hints how to insert the js/jquery lines in every page which uses FooForm?
> 
>   Thomas

Why not create a separate js file that you'll include in relevant
pages? Yes, you'll have one small js file but it will probably be less
painful than trying to hack this around in some way.

Moreover, should the js code grow at any point in time, you'll
decrease redundancy in your rendered HTML. (-;

Michal


signature.asc
Description: Digital signature


Re: __unicode__() addition not working in basic poll application.

2011-05-17 Thread Roman Klesel
hmm... strange...

the __unicode__ thing is nothing django-specific. It works in plain
python as well:

It's supposed to work like this:

>>> class TestClass(object):
... def __unicode__(self):
... return "unicode"
... def __repr__(self):
... return "buh"
... def __str__(self):
... return "str"
...
>>> o=TestClass()
>>> o
buh
>>> print o
str
>>> print unicode(o)
unicode
>>>


2011/5/17 maaz muqri :
> im just getting "Poll object" as output

-- 
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: Custom Managers and Q() Objects

2011-05-17 Thread Michal Petrucha
On Mon, May 16, 2011 at 11:54:14PM +0200, Marc Aymerich wrote:
> > > when I call Model.objects.active_during(Q(Q(ini=some_date, end=some_date)
> > |
> > > Q(ini=other_date, fin=other_date))) I get This error:
> > >
> > >
> > > active_during() takes exactly 3 arguments (2 given)
> 
> Hi Michal,
> Yep, this is actually what I want to do, pass a Q() object to the
> active_during() method. My question is, how the active_during method should
> be in order to work with a Q() object passed as a parameter?
> 
> sorry if I wasn't clear in my firts mail.

Eh, now I probably see what you're trying to do. Well, I don't say it
is impossible, however, here you're trying to misuse Q objects in a
way they are not supposed to work.

A Q object is intended to represent a primitive filter on a model
field or a composition of such filters. If I understand right, you're
trying to make a single Q object represent a composition of primitive
filters.

I see two options here:
1) modify the active_during method to accept a list of tuples where
   each tuple would be (ini, end) and then build a disjunction of such
   individual filters
2) modify active_during to return the constructed Q object instead of
   adding it to the QuerySet directly and then add their disjunction
   to the QuerySet like this:

   Model.objects.filter(Model.objects.active_during(start1, end1) |
Model.objects.active_during(start2, end2))

   In this case, however, making it a manager method would be pretty
   much pointless.

Of course, you can always try to parse the Q object structure inside
active_during to make your example work but I'd strongly advise
against it, that would be way more difficult and dependent on the
internal implementation of the Q class.

Michal


signature.asc
Description: Digital signature


Re: boolean default

2011-05-17 Thread Derek
On May 15, 8:53 pm, Christophe Pettus  wrote:
> On May 15, 2011, at 2:15 PM, Greg Donald wrote:
>
> > How do I set a default for a BooleanField() ?
>
> > I tried
>
> > foo = models.BooleanField( default=False )
>
> > but that only produces
>
> > foo boolean NOT NULL,
>
> The default= parameter in Django doesn't generate a DEFAULT in the SQL; the 
> default is implemented in the Django ORM.
>

This is a very subtle point.  The docs for "default":
http://docs.djangoproject.com/en/1.3/ref/models/fields/#default
do not explicitly say anything about creating any SQL-related code;
therefore perhaps best to assume that Django does not.  In effect (and
this is a very crude way of putting it), a Django model is a
"superset" of a SQL table.

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



Re: Custom Managers and Q() Objects

2011-05-17 Thread Marc Aymerich
On Tue, May 17, 2011 at 2:57 PM, Michal Petrucha wrote:

> On Mon, May 16, 2011 at 11:54:14PM +0200, Marc Aymerich wrote:
> > > > when I call Model.objects.active_during(Q(Q(ini=some_date,
> end=some_date)
> > > |
> > > > Q(ini=other_date, fin=other_date))) I get This error:
> > > >
> > > >
> > > > active_during() takes exactly 3 arguments (2 given)
> >
> > Hi Michal,
> > Yep, this is actually what I want to do, pass a Q() object to the
> > active_during() method. My question is, how the active_during method
> should
> > be in order to work with a Q() object passed as a parameter?
> >
> > sorry if I wasn't clear in my firts mail.
>
> Eh, now I probably see what you're trying to do. Well, I don't say it
> is impossible, however, here you're trying to misuse Q objects in a
> way they are not supposed to work.
>
> A Q object is intended to represent a primitive filter on a model
> field or a composition of such filters. If I understand right, you're
> trying to make a single Q object represent a composition of primitive
> filters.
>
> I see two options here:
> 1) modify the active_during method to accept a list of tuples where
>   each tuple would be (ini, end) and then build a disjunction of such
>   individual filters
>


Hi Michal,
Thanks for your answer,
Just right now I have finished the implementation of the the manager with a
list of tuples  :)

-- 
Marc

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



Re: Google motion chart problem in django template

2011-05-17 Thread sushanth Reddy
Hi Tarkeshwar,

Thank you for the response,But here i am directly passing list to the 
template, 
Can you please help me how to extract that list into that date format.

Thanks in advance

sushanth

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



Re: south django etc.

2011-05-17 Thread William Hudspeth
http://stackoverflow.com/questions/4840102/how-come-my-south-migrations-doesnt-work-for-django



On Fri, 2011-05-13 at 07:27 -0700, wilbur wrote:
> When loading a Django page, I get the error:
> 
> IntegrityError while rendering: duplicate key value violates unique
> constraint "menus_cachekey_pkey"
> 
> I am using Django 1.2.4
> 


-- 
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 use this snippet

2011-05-17 Thread Tonton
hello

i'd like to uderstand how to use this snippet

http://djangosnippets.org/snippets/2225/

i don't understand how it works and if it's work

does anyone use it before  ?

regards

T.

-- 
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 use this snippet

2011-05-17 Thread Tom Evans
On Tue, May 17, 2011 at 4:49 PM, Tonton  wrote:
> hello
>
> i'd like to uderstand how to use this snippet
>
> http://djangosnippets.org/snippets/2225/
>
> i don't understand how it works and if it's work
>
> does anyone use it before  ?
>
> regards
>
> T.
>

It's a management command. It belongs in
/management/commands/.py, and you then run it by
calling "python manage.py ".

More on management commands:
http://docs.djangoproject.com/en/1.3/howto/custom-management-commands/

I've never used this, so can't comment on whether it works, what it does, etc.

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: how use this snippet

2011-05-17 Thread AJ
Many times I do not know how to use some snippets on djangosnippets.org. has
anyone else felt the same? I, obviously, am a newbie.





On Tue, May 17, 2011 at 12:00 PM, Tom Evans wrote:

> On Tue, May 17, 2011 at 4:49 PM, Tonton  wrote:
> > hello
> >
> > i'd like to uderstand how to use this snippet
> >
> > http://djangosnippets.org/snippets/2225/
> >
> > i don't understand how it works and if it's work
> >
> > does anyone use it before  ?
> >
> > regards
> >
> > T.
> >
>
> It's a management command. It belongs in
> /management/commands/.py, and you then run it by
> calling "python manage.py ".
>
> More on management commands:
> http://docs.djangoproject.com/en/1.3/howto/custom-management-commands/
>
> I've never used this, so can't comment on whether it works, what it does,
> etc.
>
> 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.
>
>


-- 
AJ

-- 
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 use this snippet

2011-05-17 Thread Tom Evans
On Tue, May 17, 2011 at 5:04 PM, AJ  wrote:
> Many times I do not know how to use some snippets on djangosnippets.org. has
> anyone else felt the same? I, obviously, am a newbie.
>

I don't mean to sound glib, but (almost) everything is detailed in the
very fine manual. Read, re-read and re-re-read the manual - even the
boring bits!

Also, try to read the django source code - don't start out by trying
to understand the very complicated ORM code, but if you want to write
a template tag, have a look at the django supplied template tags.
Similarly, if you want to write a management command, look at the
source of a management command.

Finally, the more code you read/write, the easier it will be to read/write code.

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: best framework/reusable app for caching model instances (object level cache) ?

2011-05-17 Thread stargazer
After looking at these libraries... I think the best solution would be
not use these kind of libraries (ORM cache) at all.

The @cached decorator like from this library:
   https://bitbucket.org/kmike/django-cache-utils
caches ***and invalidates!*** function based on function name and
exact parameter set.

my idea is to add @cached decorators to the model manager methods and
call ...invalidate for these methods in post_save() and pre_delete()
Some manual work required, but the end result is quite transparent.

Somebody use this approach?

-- 
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: boolean default

2011-05-17 Thread Greg Donald
On Tue, May 17, 2011 at 8:53 AM, Derek  wrote:
> This is a very subtle point.  The docs for "default":
> http://docs.djangoproject.com/en/1.3/ref/models/fields/#default
> do not explicitly say anything about creating any SQL-related code;
> therefore perhaps best to assume that Django does not.  In effect (and
> this is a very crude way of putting it), a Django model is a
> "superset" of a SQL table.

If you say so.

In practice the BooleanField() is forcing me to provide a value when
I'd rather just have this particular field default to false and not
provide a value at all when I created a new record.



-- 
Greg Donald
destiney.com | gregdonald.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: Google motion chart problem in django template

2011-05-17 Thread Tarkeshwar Thakur
Sorry my syntax was incorrect.

Change your list construction to be:
*ml.append([str(m[selected_mode]),year, month, day, m['total']])*
then in template
[
{% for mode, year, month, day, total in ml %}
  '["{{ mode}}", "new Date({{ year }}, {{ month }}, {{ date }})", {{ total
}}],'
{% endfor %}
]

On Tue, May 17, 2011 at 7:40 PM, sushanth Reddy wrote:

> Hi Tarkeshwar,
>
> Thank you for the response,But here i am directly passing list to the
> template,
> Can you please help me how to extract that list into that date format.
>
> Thanks in advance
>
> sushanth
>
> --
> 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.
>



-- 
- Tarkeshwar
blog:  tarkeshwar.com 
work: chatimity.com
fun:operty.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: how use this snippet

2011-05-17 Thread AJ
Thanks for the great advice Tom.

On Tue, May 17, 2011 at 12:33 PM, Tom Evans wrote:

> On Tue, May 17, 2011 at 5:04 PM, AJ  wrote:
> > Many times I do not know how to use some snippets on djangosnippets.org.
> has
> > anyone else felt the same? I, obviously, am a newbie.
> >
>
> I don't mean to sound glib, but (almost) everything is detailed in the
> very fine manual. Read, re-read and re-re-read the manual - even the
> boring bits!
>
> Also, try to read the django source code - don't start out by trying
> to understand the very complicated ORM code, but if you want to write
> a template tag, have a look at the django supplied template tags.
> Similarly, if you want to write a management command, look at the
> source of a management command.
>
> Finally, the more code you read/write, the easier it will be to read/write
> code.
>
> 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.
>
>


-- 
AJ

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



default group for new users

2011-05-17 Thread Brian Craft
Is there a good way to add new users to a default group when they are
created (e.g. via django-registration)? I just tried binding the
post_save signal for User, and adding the group in the signal handler
(if "created" is true). However, I haven't found a good place (file)
to put the connect() call, so the signal will be caught: i.e. some
file that will consistently be loaded before a User is created.

I'm currently thinking I will override the django-registration
activate url, and add the code there, before calling
registration.views.activate. Obviously this isn't the most general
solution.

-- 
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: Basic Django Support

2011-05-17 Thread Mateusz Marzantowicz
On Sun, May 15, 2011 at 6:07 PM, David Biglin  wrote:

> Hi,
> I have been playing with Python for the past year now and enjoying it.
> I am trying Django to make a web site for a friend. I am Following the
> Django Tutorial on there web site to get the basic concepts here;
> http://docs.djangoproject.com/en/dev/intro/tutorial01/
>
> During the set up i am using SQLite3 which comes with python, how ever
> when i try and create the DB tables i get the following errors
>
> Command to create DBTables :
>
>python manage.py syncdb
>
>
>
> The Traceback :
>
>Traceback (most recent call last):
>  File "manage.py", line 11, in 
>execute_manager(settings)
>  File "/usr/lib/pymodules/python2.7/django/core/management/
> __init__.py", line 438, in execute_manager
>utility.execute()
>  File "/usr/lib/pymodules/python2.7/django/core/management/
> __init__.py", line 379, in execute
>self.fetch_command(subcommand).run_from_argv(self.argv)
>  File "/usr/lib/pymodules/python2.7/django/core/management/
> base.py", line 191, in run_from_argv
>self.execute(*args, **options.__dict__)
>  File "/usr/lib/pymodules/python2.7/django/core/management/
> base.py", line 220, in execute
>output = self.handle(*args, **options)
>  File "/usr/lib/pymodules/python2.7/django/core/management/
> base.py", line 351, in handle
>return self.handle_noargs(**options)
>  File "/usr/lib/pymodules/python2.7/django/core/management/
> commands/syncdb.py", line 56, in handle_noargs
>cursor = connection.cursor()
>  File "/usr/lib/pymodules/python2.7/django/db/backends/
> __init__.py", line 75, in cursor
>cursor = self._cursor()
>  File "/usr/lib/pymodules/python2.7/django/db/backends/sqlite3/
> base.py", line 174, in _cursor
>self.connection = Database.connect(**kwargs)
>sqlite3.OperationalError: unable to open database file
>
>
>
>
> Any help would be amazing also any other tutorials anyone could
> recommend for starting python web development would be much
> appreciated!
> Thanks again
>
>
Someone already mentioned that your problem might be related to
file/directory permissions. I spent a lot of time to figure that out in my
case.

Depending on your deployment method you might need to adjust your user/group
settings.
If you're using mod_wsgi with Apache http server set user and/or group
parameter in WSGIDaemonProcess directive in your apache config file to the
same user and group as your Djnago project files. In practice I create
separate system user accounts for my django projects, than create apache
virtual hosts and I also use python virtual environment. I can than easily
and quickly deploy everything and file permissions are fine.

Of course you can always play with chmod/chown to allow web server to access
your SQLite database.

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



REMOTE_USER authentication to 'Admin'?

2011-05-17 Thread Jeff Blaine
Hi folks,

I'm successfully using Apache with mod_authnz_ldap, WSGI, Django 1.3.  If I 
hit
'/admin', I get asked to authenticate (BasicAuth done through LDAP).  I 
succeed.
However, this just results in me then seeing the Django admin login screen 
instead
of logging me in to Admin.

What am I missing?

Apache relevant portion
===

# If this directive is set, the value of the REMOTE_USER environment 
variable will be set
# to the value of the attribute specified.
AuthLDAPRemoteUserAttribute uid

Django
==

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

# Try django auth first, failover to LDAP
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'django.contrib.auth.backends.RemoteUserBackend',
)

-- 
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: default group for new users

2011-05-17 Thread creecode
Hello Brian,

I have a similar signal setup for an app of mine.  I put it at the end of 
the models.py file.  I seem to recall reading a tip somewhere that this was 
a good place for something like this.  Perhaps it was the Django or 
django-registration docs?

Toodle-lo...
creecode

-- 
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: default group for new users

2011-05-17 Thread Brian Craft
After much googling, I created a new app called "core" and put the
connect() in the __init__.py. That seems to be working. The problem
with the "put it in models.py" solution is that it isn't really
related to any of my existing apps. Previously I tried putting it in
the project __init__.py, but that works inconsistently, apparently
because django isn't fully initialized when the project __init__.py is
loaded.

On Tue, May 17, 2011 at 11:07 AM, Brian Craft  wrote:
> Is there a good way to add new users to a default group when they are
> created (e.g. via django-registration)? I just tried binding the
> post_save signal for User, and adding the group in the signal handler
> (if "created" is true). However, I haven't found a good place (file)
> to put the connect() call, so the signal will be caught: i.e. some
> file that will consistently be loaded before a User is created.
>
> I'm currently thinking I will override the django-registration
> activate url, and add the code there, before calling
> registration.views.activate. Obviously this isn't the most general
> solution.
>

-- 
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: REMOTE_USER authentication to 'Admin'?

2011-05-17 Thread Jacob Kaplan-Moss
On Tue, May 17, 2011 at 1:31 PM, Jeff Blaine  wrote:
> Hi folks,
> I'm successfully using Apache with mod_authnz_ldap, WSGI, Django 1.3.  If I
> hit
> '/admin', I get asked to authenticate (BasicAuth done through LDAP).  I
> succeed.
> However, this just results in me then seeing the Django admin login screen
> instead
> of logging me in to Admin.
> What am I missing?

It's hard to be certain, but I'm fairly sure that you need to make
sure that the user in question (i.e. the one authenticated via
mod_authnz_ldap) has the "is_staff" flag set on the Django user
object.

Django requires that there be a User object in the database for each
user, so RemoteUserBackend creates missing User objects on demand (see
http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/backends.py#L68
for the code). However, these automatically-created users won't have
any permissions or the "is_staff" flag set, so they won't be allowed
to log into the admin.

The solution is to subclass RemoteUserBackend and override the
"configure_user" method, setting permissions and staff/superuser flags
appropriately (perhaps via an LDAP query?) This is briefly mentioned
in the documentation (see
http://docs.djangoproject.com/en/dev/howto/auth-remote-user/#remoteuserbackend)
which has a few other details in case you need 'em.

Jacob

-- 
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: REMOTE_USER authentication to 'Admin'?

2011-05-17 Thread Jeff Blaine
[ *sigh* - I wish the web UI to google groups had an 80-column marker. ]
[ Sorry for the formatting in the previous message.  I'm used to hitting ]
[ enter. ]

Thanks for the reply, Jacob.

That gets us somewhere, because authenticating to Apache/LDAP as jblaine
did NOT make a Django user jblaine.

So that's one part of the problem.

The second is that creating jblaine by hand, and setting it is_staff and 
also
superuser, did not then do anything.  I authenticate to Apache/LDAP fine
then see the Django 'Admin' login screen with empty username/password
form fields.

Here's the whole Apache Directory section for the WSGI, in case something
jumps out:

  
AuthType Basic
AuthName "G06A Host Database: Secure"
AuthBasicProvider ldap
AuthzLDAPAuthoritative off
AuthLDAPRemoteUserAttribute uid
AuthLDAPUrl "ldap://ldap-prod.our.org:389/o=our.org";
Require ldap-attribute departmentname=RCF
Order allow,deny
Allow from all
  

Any clever ideas for where to shim some debugging code to see what is
happening in the native Django stuff?

-- 
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: REMOTE_USER authentication to 'Admin'?

2011-05-17 Thread Jacob Kaplan-Moss
On Tue, May 17, 2011 at 2:00 PM, Jeff Blaine  wrote:
> That gets us somewhere, because authenticating to Apache/LDAP as jblaine
> did NOT make a Django user jblaine.

That's interesting - perhaps LDAP is reporting a different username?
You could check in the auth_user table to see what's getting created
when you authenticate; you should see a entry get created the first
time you authenticate as a given user.

> Any clever ideas for where to shim some debugging code to see what is
> happening in the native Django stuff?

I'd start by subclassing RemoteUserBackend and throwing some logging
code into the configure_user (and perhaps clean_username) callbacks.
After that you could try subclassing RemoeUserMiddleware and again
adding some logging callbacks (in process_request, I think).

Jacob

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



Problem in Part2 of the tutorial "DoesNotExist at /admin/"

2011-05-17 Thread igalic
Hi,

I went through the first part of the tutorial without problems, but
when trying to turn on the admin app in tutorial 2, I got this error
page with the message stated in subject line.

Here's more info:

Django: latest version from the trunk
Python: 2.6.1
OS: OSX 10.6.7

Here's the info it gives me:

DoesNotExist at /admin/
Site matching query does not exist.


Traceback:
File "/Users/nightition/Development/django-trunk/django/core/handlers/
base.py" in get_response
  111. response = callback(request,
*callback_args, **callback_kwargs)
File "/Users/nightition/Development/django-trunk/django/contrib/admin/
sites.py" in wrapper
  213. return self.admin_view(view, cacheable)(*args,
**kwargs)
File "/Users/nightition/Development/django-trunk/django/utils/
decorators.py" in _wrapped_view
  91. response = view_func(request, *args,
**kwargs)
File "/Users/nightition/Development/django-trunk/django/views/
decorators/cache.py" in _wrapped_view_func
  77. response = view_func(request, *args, **kwargs)
File "/Users/nightition/Development/django-trunk/django/contrib/admin/
sites.py" in inner
  195. return self.login(request)
File "/Users/nightition/Development/django-trunk/django/views/
decorators/cache.py" in _wrapped_view_func
  77. response = view_func(request, *args, **kwargs)
File "/Users/nightition/Development/django-trunk/django/contrib/admin/
sites.py" in login
  330. return login(request, **defaults)
File "/Users/nightition/Development/django-trunk/django/utils/
decorators.py" in _wrapped_view
  91. response = view_func(request, *args,
**kwargs)
File "/Users/nightition/Development/django-trunk/django/views/
decorators/cache.py" in _wrapped_view_func
  77. response = view_func(request, *args, **kwargs)
File "/Users/nightition/Development/django-trunk/django/contrib/auth/
views.py" in login
  58. current_site = get_current_site(request)
File "/Users/nightition/Development/django-trunk/django/contrib/sites/
models.py" in get_current_site
  92. current_site = Site.objects.get_current()
File "/Users/nightition/Development/django-trunk/django/contrib/sites/
models.py" in get_current
  25. current_site = self.get(pk=sid)
File "/Users/nightition/Development/django-trunk/django/db/models/
manager.py" in get
  132. return self.get_query_set().get(*args, **kwargs)
File "/Users/nightition/Development/django-trunk/django/db/models/
query.py" in get
  349. % self.model._meta.object_name)


Does anyone have an idea of what I'm doing wrong?

Needless to say, these are my first steps with Django and I don't
really have an idea where to go from here - I've searched google, the
list.. no luck.

Thanks,
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: Email app is breaking long lines, any fix?

2011-05-17 Thread John Crawford
Actually, upon looking more at the output, it has *both* "utf-8" and
"us-ascii" as the charset. I'm not sure if this is the result of code
changes I've made, or I just missed it the first time around - but my
Django email output now looks like this:

-- MESSAGE FOLLOWS --
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Subject: some_subject
From: m...@test.com
To: m...@test.com
Date: Tue, 17 May 2011 19:58:16 -
Message-ID: <20110517195816.16624.1004@CRAY>
X-Peer: 127.0.0.1

Content-Type: text/us-ascii; charset=3D"us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

this is a test of a really long line that has more words that could
possibl=
y fit in a single column of text.
 END MESSAGE 

So although I'm creating a MIMEText object with a plain, "us-ascii"
string - somewhere, Django is sending a charset of "utf-8". At least
if I read this correctly.

So does anyone know how to tell Django to *not* send "utf-8"? Thanks.

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



Re: REMOTE_USER authentication to 'Admin'?

2011-05-17 Thread Jeff Blaine
On Tuesday, May 17, 2011 3:10:03 PM UTC-4, Jacob Kaplan-Moss wrote:
>
> On Tue, May 17, 2011 at 2:00 PM, Jeff Blaine  wrote:
> > That gets us somewhere, because authenticating to Apache/LDAP as jblaine
> > did NOT make a Django user jblaine.
>
> That's interesting - perhaps LDAP is reporting a different username?
> You could check in the auth_user table to see what's getting created
> when you authenticate; you should see a entry get created the first
> time you authenticate as a given user
>
I guess I'll start the debugging then, because:

DELETE FROM auth_user WHERE username != 'admin';
Query OK, 1 row affected (0.00 sec)

Auth to Apache/LDAP as jblaine, get Admin login screen.

mysql> SELECT username FROM auth_user;
+--+
| username |
+--+
| admin|
+--+
1 row in set (0.00 sec)

mysql>

-- 
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: boolean default

2011-05-17 Thread Lucian Nicolescu
AFAIK Django does not create SQL instructions for default values. But
if you specify a default value inside the model field declaration and
use the orm for inserts it will correctly assign it.

Lucian

On Tue, May 17, 2011 at 7:49 PM, Greg Donald  wrote:
> On Tue, May 17, 2011 at 8:53 AM, Derek  wrote:
>> This is a very subtle point.  The docs for "default":
>> http://docs.djangoproject.com/en/1.3/ref/models/fields/#default
>> do not explicitly say anything about creating any SQL-related code;
>> therefore perhaps best to assume that Django does not.  In effect (and
>> this is a very crude way of putting it), a Django model is a
>> "superset" of a SQL table.
>
> If you say so.
>
> In practice the BooleanField() is forcing me to provide a value when
> I'd rather just have this particular field default to false and not
> provide a value at all when I created a new record.
>
>
>
> --
> Greg Donald
> destiney.com | gregdonald.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.
>
>

-- 
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: REMOTE_USER authentication to 'Admin'?

2011-05-17 Thread Jeff Blaine
Also, FWIW, the REMOTE_USER is definitely getting set to 'jblaine'

1xx.xx.xx.231 - jblaine [17/May/2011:16:12:41 -0400] "GET 
/static/admin/img/admin/nav-bg.gif HTTP/1.1" 200 273 
"http://rcf-hostdb.our.org/admin/"; "Mozilla/4.0 (compatible; MSIE 7.0; 
Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 
3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)"

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



Pre fork or worker MPM

2011-05-17 Thread ydjango
I am using Python 2.5, django 1.1 with mod_wsgi 2.5

Does it matter if I use prefork or worker MPM for apache?

Which one is recommended for production use?

-- 
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: Memcached backend - caching data with infinite timeout

2011-05-17 Thread Malcolm Box
On 17 May 2011 11:15, Tom Evans  wrote:

> On Tue, May 17, 2011 at 11:03 AM, Malcolm Box 
> wrote:
> > That looks like a bug in Django. I suggest you file a ticket.
> >
> > The fix would be to compare timeout to None
> >
>
> A ticket has already been submitted about this. The issue is that
> although memcache allows setting 'infinite' timeouts (its not
> infinite, it just pushes out old data on LRU basis), other backends do
> not.
>
> http://code.djangoproject.com/ticket/9595
>
>
Looking at this ticket, the argument is that this would be inconsistent with
other backends, and that therefore there should be another "special" way to
mean infinite timeout.

However, current behaviour isn't consistent: behaviour on passing 0 as
timeout to cache.set() is:

- filecache - deletes the key (sets expiry to now, so that the key will be
deleted on get)
- memcached - sets the expiry time to the default timeout
- locmem - deletes the key (sets expiry time to now).

Changing the memcached backend to make 0 = infinite cache doesn't strike me
as worse than having memcache have 0 = default timeout, and it means that
the useful memcache behaviour of infinite timeout is available.

I'd propose that the behaviour is modified to:

timeout = None : set default timeout on all backends
timeout = 0 : set "longest possible" expiry on all backends. If people are
already relying on 0 = delete on some backends their code already won't work
on memcache.  Alternatively, if this is felt to be a too-big incompatibility
then simply document 0 as special with backend dependant behaviour (the
current situation), and change memcache behaviour to be infinite timeout.

Cheers,

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: boolean default

2011-05-17 Thread Greg Donald
On Tue, May 17, 2011 at 3:20 PM, Lucian Nicolescu  wrote:
> AFAIK Django does not create SQL instructions for default values. But
> if you specify a default value inside the model field declaration and
> use the orm for inserts it will correctly assign it.

That's the behavior I expected, but that's not what I get.  See the
code I posted.  My Form Model complains that my BooleanField type is
missing when I do not supply it explicitly.

Further, if I exclude it, to make my Form Model happy, I get a
DatabaseError exception since the field in my database has no default
set.


-- 
Greg Donald
destiney.com | gregdonald.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: Email app is breaking long lines, any fix?

2011-05-17 Thread Ian Clelland
On Tue, May 17, 2011 at 1:02 PM, John Crawford wrote:

> Actually, upon looking more at the output, it has *both* "utf-8" and
> "us-ascii" as the charset.


Actually, it doesn't. It only has utf-8. The first nine lines of your pasted
output are the actual email headers. Following the blank line is the email
body, which begins with three lines that *look* like headers, but are
actually just part of the message, and any email client would just render
them as text at the top of the message.

(In addition to the blank line, this is alse evidenced by the fact that the
'=' in 'charset='us-ascii'" was escaped as '=3D', as is normal for
quoted-printable-encoded text)


> I'm not sure if this is the result of code
> changes I've made, or I just missed it the first time around - but my
> Django email output now looks like this:
>
> -- MESSAGE FOLLOWS --
> Content-Type: text/plain; charset="utf-8"
> MIME-Version: 1.0
> Content-Transfer-Encoding: quoted-printable
> Subject: some_subject
> From: m...@test.com
> To: m...@test.com
> Date: Tue, 17 May 2011 19:58:16 -
> Message-ID: <20110517195816.16624.1004@CRAY>
> X-Peer: 127.0.0.1
>
> Content-Type: text/us-ascii; charset=3D"us-ascii"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
>
> this is a test of a really long line that has more words that could
> possibl=
> y fit in a single column of text.
>  END MESSAGE 
>
> So although I'm creating a MIMEText object with a plain, "us-ascii"
> string - somewhere, Django is sending a charset of "utf-8". At least
> if I read this correctly.
>
> So does anyone know how to tell Django to *not* send "utf-8"? Thanks.
>

What are you *actually* doing to send this email? It sounds like you are
creating some kind of object and passing that as the body to send_mail,
while send_mail is expecting text, and is just coercing your object into a
string and using that as the message body.

It is definitely possible to tell Django not to use UTF-8 encoding, but you
won't be able to use the send_mail shortcut to do it. You will have to use
an EmailMessage object directly[1]. You should be able to instantiate an
EmailMessage, set the headers yourself, and call send() on it.

(Also, 'text/us-ascii' is not a registered MIME type; you probably want to
say something like 'text/plain; charset=us-ascii')


[1]
http://docs.djangoproject.com/en/1.3/topics/email/#the-emailmessage-class


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



Re: Pre fork or worker MPM

2011-05-17 Thread creecode
Hello ydjango,

On Tuesday, May 17, 2011 2:15:37 PM UTC-7, ydjango wrote:

I am using Python 2.5, django 1.1 with mod_wsgi 2.5 
>
> Does it matter if I use prefork or worker MPM for apache? 
>
> Which one is recommended for production use?


Which one you choose depends on what you are trying to accomplish.  If you 
could tell us a bit more about your project we might be able to give you 
better advice.  Googleing should produce some results that may be of help.

Toodle-loo..
creecode

-- 
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: Pre fork or worker MPM

2011-05-17 Thread Jacob Kaplan-Moss
On Tue, May 17, 2011 at 4:15 PM, ydjango  wrote:
> I am using Python 2.5, django 1.1 with mod_wsgi 2.5
>
> Does it matter if I use prefork or worker MPM for apache?

In general, worker will use less RAM, thus allowing higher concurrency
and usually higher perceived performance.

But take that suggestion with a huge grain of salt: without knowing
specifics about your application the question is basically
unanswerable. worker's probably the right choice maybe 90% of the time
though.

> Which one is recommended for production use?

They're both fine for production.

Jacob

-- 
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: Email app is breaking long lines, any fix?

2011-05-17 Thread John Crawford
> What are you *actually* doing to send this email?

This is the basic version - the one with two headers, I was
experimenting with a MIMEText object:

from django.core.mail import send_mail

def page_worked(request):
the_text = u'this is a test of a really long line that has more
words that could possibly fit in a single column of text.'
send_mail('some_subject', the_text, 'm...@test.com',
['m...@test.com'])

However - this is not the *actual* problem, only sample code - the
*actual* problem is with the django-registration app. Given a text
template to create a registration email, it's breaking the lines.

Although it would be nice to understand everything that's going on
here - all I *really* want to do is have the app send non-broken
email. :)

-- 
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: Email app is breaking long lines, any fix?

2011-05-17 Thread John Crawford
> Actually, it doesn't. It only has utf-8. The first nine lines of your pasted
output are the actual email headers.

Okay, that makes more sense. That particular experiment I was using a
MIMEObject's to_string() function. Although I had passed in plain text
to the object, clearly it put its own headers on the string output.

Also minor note - my test string usually does *not* have the 'u'
Unicode prefix on it, that was just the last change I had made, I
forgot to remove it. :)

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



Re: Pre fork or worker MPM

2011-05-17 Thread ydjango
Thank you,

I remembered reading this long back - "Django requires Apache 2.x and
mod_python 3.x, and you should use Apache’s prefork MPM, as opposed to
the worker MPM."

I was not sure if prefork is required because of some limitation (like
threading issues) in Django 1.1 or python 2.5 or was it because of
modPython issues.


On May 17, 2:56 pm, Jacob Kaplan-Moss  wrote:
> On Tue, May 17, 2011 at 4:15 PM, ydjango  wrote:
> > I am using Python 2.5, django 1.1 with mod_wsgi 2.5
>
> > Does it matter if I use prefork or worker MPM for apache?
>
> In general, worker will use less RAM, thus allowing higher concurrency
> and usually higher perceived performance.
>
> But take that suggestion with a huge grain of salt: without knowing
> specifics about your application the question is basically
> unanswerable. worker's probably the right choice maybe 90% of the time
> though.
>
> > Which one is recommended for production use?
>
> They're both fine for production.
>
> Jacob

-- 
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: Pre fork or worker MPM

2011-05-17 Thread Jacob Kaplan-Moss
On Tue, May 17, 2011 at 6:00 PM, ydjango  wrote:
> I remembered reading this long back - "Django requires Apache 2.x and
> mod_python 3.x, and you should use Apache’s prefork MPM, as opposed to
> the worker MPM."

That statement dates back to when Django wasn't threadsafe (so we're
talking pre-1.0 here). These days Django's perfectly threadsafe
(though your may not be...) so worker isn't out of the question.

Jacob

-- 
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: boolean default

2011-05-17 Thread Karen Tracey
On Tue, May 17, 2011 at 5:45 PM, Greg Donald  wrote:

> On Tue, May 17, 2011 at 3:20 PM, Lucian Nicolescu 
> wrote:
> > AFAIK Django does not create SQL instructions for default values. But
> > if you specify a default value inside the model field declaration and
> > use the orm for inserts it will correctly assign it.
>
> That's the behavior I expected, but that's not what I get.  See the
> code I posted.  My Form Model complains that my BooleanField type is
> missing when I do not supply it explicitly.
>
>
Perhaps if you posted more of your code someone could help. In this thread
at any rate all I see is a single line of code that presumably defines the
field you are talking about in your model? A model with a field as you have
defined it does behave the way you seem to be requesting. Specifically, this
model:

class BField(models.Model):
x = models.BooleanField(default=False)

def __unicode__(self):
return '%s' % self.x

and a bare-bones model form created for it:

>>> from ttt.models import BField
>>> from django import forms
>>> class BForm(forms.ModelForm):
... class Meta:
... model = BField
...

when created with an empty data dictionary:

>>> bf = BForm({})

...is reported as valid and has no errors:

>>> bf.is_valid()
True
>>> bf.errors
{}

...and successfully saves, creating a model instance with the specified
default:

>>> BField.objects.all()
[]
>>> bf.save()

>>> BField.objects.all()
[]
>>>

Karen
-- 
http://tracey.org/kmt/

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



Error when try to do ManyToMany relation with User class...

2011-05-17 Thread Chris Seberino
I have 3 classes that have a ManyToMany relation with the User class.

When I try to do syncdb I get this error

Error: One or more models did not validate:
mvc.course: 'users' has an m2m relation with model User, which has
either not been installed or is abstract.
mvc.homework: 'users' has an m2m relation with model User, which has
either not been installed or is abstract.
mvc.quiz: 'users' has an m2m relation with model User, which has
either not been installed or is abstract.

Not sure how to fix this or what means.

Chris

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



TemplateView and dynamic template_name in urlconf

2011-05-17 Thread Brian Morton
I have a generic view that accepts its template_name attribute from
the urlconf dynamic variable:

(r'^(?P[^/]+)$', TemplateView.as_view()),

But I get an exception:
TemplateResponseMixin requires either a definition of 'template_name'
or an implementation of 'get_template_names()'

I've read the code and understand the difference between class
attributes and the kwargs attribute.  I also understand how to fix
this problem by overriding get_template_names in this case.

Does anyone else share my feeling that this is unclear to some users
and should be better documented (the difference between initkwargs and
kwargs added from the request)?

-- 
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: Error when try to do ManyToMany relation with User class...

2011-05-17 Thread Kenneth Gonsalves
On Tue, 2011-05-17 at 18:26 -0700, Chris Seberino wrote:
> Error: One or more models did not validate:
> mvc.course: 'users' has an m2m relation with model User, which has
> either not been installed or is abstract.
> mvc.homework: 'users' has an m2m relation with model User, which has
> either not been installed or is abstract.
> mvc.quiz: 'users' has an m2m relation with model User, which has
> either not been installed or is abstract.
> 
> Not sure how to fix this or what means.
> 
> 

difficult to say without seeing your models
-- 
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 use this snippet

2011-05-17 Thread Gabriel Gunderson
On Tue, May 17, 2011 at 10:33 AM, Tom Evans  wrote:
> I don't mean to sound glib, but (almost) everything is detailed in the
> very fine manual. Read, re-read and re-re-read the manual - even the
> boring bits!

I think it's important to remember that one of the strengths of Django
is its docs.  They're some of the best out there.  I find myself
wishing other projects were documented so well.

So, yeah, read them and re-read them :)

Gabe

-- 
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: Problem in Part2 of the tutorial "DoesNotExist at /admin/"

2011-05-17 Thread Gabriel Gunderson
On Tue, May 17, 2011 at 11:53 AM, igalic  wrote:
> I went through the first part of the tutorial without problems, but
> when trying to turn on the admin app in tutorial 2, I got this error
> page with the message stated in subject line.
>
> Here's more info:
>
> Django: latest version from the trunk
> Python: 2.6.1
> OS: OSX 10.6.7
>
> Here's the info it gives me:
>
> DoesNotExist at /admin/
> Site matching query does not exist.


It looks like it's related to the sites framework:
http://docs.djangoproject.com/en/dev/ref/contrib/sites/

I'd have a look at what's in my settings file for SITE_ID and take it
from there.
http://docs.djangoproject.com/en/dev/ref/settings/#std:setting-SITE_ID

Let us know if you don't figure it out.


Best,
Gabe

-- 
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: Error when try to do ManyToMany relation with User class...

2011-05-17 Thread Gabriel Gunderson
On Tue, May 17, 2011 at 7:26 PM, Chris Seberino  wrote:
> I have 3 classes that have a ManyToMany relation with the User class.
>
> When I try to do syncdb I get this error
>
> Error: One or more models did not validate:
> mvc.course: 'users' has an m2m relation with model User, which has
> either not been installed or is abstract.

Just a quick guess, but could it be this?

http://docs.djangoproject.com/en/dev/ref/models/fields/#module-django.db.models.fields.related

If you need to create a relationship on a model that has not yet been
defined, you can use the name of the model, rather than the model
object itself:

"""
class Car(models.Model):
manufacturer = models.ForeignKey('Manufacturer')
# ...

class Manufacturer(models.Model):
# ...
"""

Best,
Gabe

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