Re: What is the best server for Django

2011-03-10 Thread Tom Christie
And again, +1 webfaction, they really do rock.

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



AttributeError at / polls / in Django Tutorial

2011-03-10 Thread Alberto Morales Fernández
Hi guys, I'm a rookie in django, I am doing the tutorial intro of the 
official URL Django, in chapter 3 but I get the following error when I 
access the url of my application



{
AttributeError at / polls /

type object 'Poll' has no attribute 'objetcs'

Request Method: GET
Request URL: http://localhost:8000/polls/
Django Version: 1.2.5
Exception Type: AttributeError
Exception Value:

type object 'Poll' has no attribute 'objetcs'

Exception Location: / home / kodenix / Workspace / programming / django 
/ example / MyFirst / polls / views.py in index, line 7

Python Executable: / usr / bin / python
Python Version: 2.6.5

}

What does this error?, I followed the tutorial correctly
I am use Django 1.2



Best regards

Alberto Morales

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



join when it is not needed

2011-03-10 Thread aiko
Can anyone me explain why django here uses join.

Let say I have:

class List(models.Model):
property = models.ForeignKey(Property, related_name="List")

class Property(models.Model):
name = models.CharField(...)

property = Property.objects.get(pk=100)
list = List.objects.get(property=property, value='value')


Django generates:

SELECT ...
FROM list
INNER JOIN property ON (list.property_id = property.id)
WHERE list.property_id = 100  AND list.value = "value"

Why not ?:

SELECT ... FROM list WHERE property_id = 100  AND value = "value"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: AttributeError at / polls / in Django Tutorial

2011-03-10 Thread delegbede
The spelling is what the problem is. 
You have typed 'objetcs' instead of 'objects'. 

Always study the error trace very well. 

Best regards. 
Sent from my BlackBerry wireless device from MTN

-Original Message-
From: Alberto Morales Fernández 
Sender: django-users@googlegroups.com
Date: Wed, 09 Mar 2011 15:53:17 
To: 
Reply-To: django-users@googlegroups.com
Subject: AttributeError at / polls / in Django Tutorial

Hi guys, I'm a rookie in django, I am doing the tutorial intro of the 
official URL Django, in chapter 3 but I get the following error when I 
access the url of my application


{
AttributeError at / polls /

type object 'Poll' has no attribute 'objetcs'

Request Method: GET
Request URL: http://localhost:8000/polls/
Django Version: 1.2.5
Exception Type: AttributeError
Exception Value:

type object 'Poll' has no attribute 'objetcs'

Exception Location: / home / kodenix / Workspace / programming / django 
/ example / MyFirst / polls / views.py in index, line 7
Python Executable: / usr / bin / python
Python Version: 2.6.5

}

What does this error?, I followed the tutorial correctly
I am use Django 1.2



Best regards

Alberto Morales

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: AttributeError at / polls / in Django Tutorial

2011-03-10 Thread Kenneth Gonsalves
On Wed, 2011-03-09 at 15:53 -0500, Alberto Morales Fernández wrote:
> 'objetcs'

objects
-- 
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: Error 503 Service Unavailable from 127.0.0.1

2011-03-10 Thread pjstunna
Thanks for your response.

Yes I have DEBUG = True in settings.py

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



Failed to build documentation (solved)

2011-03-10 Thread Thomas Guettler
Hi,

the problem is solved, this is just for other people who have the same error.

When you try to build the documentation and get the following error:


  File "/home/user/_django-trunk/docs/_ext/djangodocs.py", line 86, in run
xrefs = roles.XRefRole()('doc', linktext, linktext, self.lineno, self.state)
AttributeError: 'module' object has no attribute 'XRefRole'

You might be running an old version of Sphinx. Version 0.6 is not supported.

You need to use the "-U" Option (update), to get the latest version:

Example: easy_install -U --prefix=$HOME Sphinx

Without -U easy_install copied the old version from /usr/lib into my home
directory.

 HTH,
Thomas Güttler

-- 
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: Satchmo Error - Invalid block tag: 'thumbnail', expected 'else' or 'endif'

2011-03-10 Thread pols
Check in settings.py installed apps for the entry
'satchmo_utils.thumbnail', If not istalled add this.If you are using
new version you may need to add {% endthumbnail %} in the templates
before closing endif

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Tracking Model's History

2011-03-10 Thread Tomasz Zieliński


On 7 Mar, 05:06, Venkatraman S  wrote:
> Hi,
>
> Similar to the way, the admin tracks the changes, i was looking for
> something which can be used in my app and stumbled on
> this
> .
> Q is : How efficient is this? I mean, do you see performance problems in
> your app when you implement this feature?Anything else that needs to be
> taken care of?
> Also, is it possible to know what were the old and new values of the field
> that are getting updated?
>
> -V-http://blizzardzblogs.blogspot.com/

One of the answers there was to use django-reversion - you can try if
it fits your needs.
It stores previous states of the model instance using XML notation,
which makes it possible to migrate models without loosing history.

--
Tomasz Zielinski
pyconsultant.eu

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 delete ONLY m2m relation?

2011-03-10 Thread Tomasz Zieliński
On 9 Mar, 16:12, Casey Greene  wrote:
> In that case, I believe you can remove it with
>
> user.province_set.remove(province)
> user.save()
>

User.save() is unnecessary here because remove() changes m2m
intermediate table
and save() changes only User table.

>
> I am going from memory here.  I tried to find this in the docs to make
> sure but couldn't.
>

Here you are: 
http://docs.djangoproject.com/en/1.2/ref/models/relations/#django.db.models.fields.related.RelatedManager.remove

--
Tomasz Zielinski
pyconsultant.eu

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Tracking Model's History

2011-03-10 Thread Venkatraman S
2011/3/10 Tomasz Zieliński 

>
> One of the answers there was to use django-reversion - you can try if
> it fits your needs.
> It stores previous states of the model instance using XML notation,
> which makes it possible to migrate models without loosing history.
>

Actually, i ended up cloning contrib.admin.LogEntry and it worked pretty
fine.
Though i would have liked a feature by which i can store the old and new
values
when a model is updated -but i wasnt sure how much of an overhead that would
be.

-V

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 503 Service Unavailable from 127.0.0.1

2011-03-10 Thread Jirka Vejrazka
Most likely, you have a proxy defined in your browser and "bypass
proxy for local machines" is not checked.

  Cheers

 Jirka


On 09/03/2011, pjstunna  wrote:
> Hi,
>
> I just recently discovered Django and I'm following the Django
> tutorial as it is written on the website (
> http://docs.djangoproject.com/en/dev//intro/tutorial01/
> ) but when i start the development server and view http://127.0.0.1:8000
> from my browser I get this error
>
> Error 503 Service Unavailable from 127.0.0.1
>
> I just installed Django 1.2.5 and I'm using the SQlite3 backend on a
> Windows 7 laptop
>
> Please help!!!
>
> 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.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 with FileField (file upload) and generic views

2011-03-10 Thread Simon
I'm writing an app to allow users in a school to upload newsletters to our 
website, but I'm having problems using models.FileField in a generic view. 
I've set 

MEDIA_ROOT = '/data/school/media/'

and MEDIA_URL is also set to a valid location. I've checked and re-checked 
permissions on the directories: www-data (apache user) has full RWX 
permissions. The model:

class Newsletter(models.Model):
issue_date= models.DateField()
issue_number  = models.IntegerField()
table_of_contents = models.TextField(null=True, blank=True)
pdf_file  = models.FileField(upload_to='newsletters', null=True, 
blank=True)

In urls.py:

# Create newsletter detail
(r'^new/$',
CreateView.as_view(
model=Newsletter,
template_name='newsletter/edit.html',
)),

If I set the pdf_file field so that a file is required, it fails every time 
with the error "This field is required", even though a file has been 
selected. If I set it to "null=True, blank=True" (as above) it takes no 
notice of the file I have selected in the "pdf_file" upload field.

I'm not sure if I've missed something obvious. Searching around turns up an 
old bug which gives the same problem but was fixed years ago.

Any suggestions would be appreciated, TIA.

--
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 with FileField (file upload) and generic views

2011-03-10 Thread Matthias Kestenholz
Hey Simon

On Thu, Mar 10, 2011 at 11:49 AM, Simon  wrote:
> I'm writing an app to allow users in a school to upload newsletters to our
> website, but I'm having problems using models.FileField in a generic view.
> I've set
> MEDIA_ROOT = '/data/school/media/'
> and MEDIA_URL is also set to a valid location. I've checked and re-checked
> permissions on the directories: www-data (apache user) has full RWX
> permissions. The model:
> class Newsletter(models.Model):
>     issue_date        = models.DateField()
>     issue_number      = models.IntegerField()
>     table_of_contents = models.TextField(null=True, blank=True)
>     pdf_file          = models.FileField(upload_to='newsletters', null=True,
> blank=True)
> In urls.py:
>     # Create newsletter detail
>     (r'^new/$',
>         CreateView.as_view(
>             model=Newsletter,
>             template_name='newsletter/edit.html',
>         )),
> If I set the pdf_file field so that a file is required, it fails every time
> with the error "This field is required", even though a file has been
> selected. If I set it to "null=True, blank=True" (as above) it takes no
> notice of the file I have selected in the "pdf_file" upload field.
> I'm not sure if I've missed something obvious. Searching around turns up an
> old bug which gives the same problem but was fixed years ago.
> Any suggestions would be appreciated, TIA.

Which enctype do you use when submitting the form? It does not work
with the default POST enctype, you have to use the following:




Matthias



-- 
Matthias Kestenholz - Dipl. Umwelt-Natw. ETH - Konzept & Programmierung
FEINHEIT GmbH - Molkenstrasse 21 - CH-8004 Zürich - www.feinheit.ch

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 with FileField (file upload) and generic views

2011-03-10 Thread Simon
Spot on. Thanks.

--
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 log model inserts,updates and deletes

2011-03-10 Thread sushanth Reddy
hi,

how to log model inserts,updates and deletes?
I am not using django admin,in my app there are multiple tables
i just want to records only which  model or table name, field name,previous 
value,who edited,and what time
to one log table?

Who edited (my app uses SSO,it should pick up remote user automatically) 

can you please suggest any built in function or module in django to records 
this kind of logs ,if possible can you plz add few lines of django code or 
any ref links?

Thanks in advance

Thanks 
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: Satchmo Error - Invalid block tag: 'thumbnail', expected 'else' or 'endif'

2011-03-10 Thread chris hendrix

both of these are done and we're still getting the error.

On 03/10/2011 04:32 AM, pols wrote:

Check in settings.py installed apps for the entry
'satchmo_utils.thumbnail', If not istalled add this.If you are using
new version you may need to add {% endthumbnail %} in the templates
before closing endif



--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 503 Service Unavailable from 127.0.0.1

2011-03-10 Thread pjstunna
I just checked. I am using Firefox and my proxy settings is set to "No
Proxy"

On Mar 10, 11:41 am, Jirka Vejrazka  wrote:
> Most likely, you have a proxy defined in your browser and "bypass
> proxy for local machines" is not checked.
>
>   Cheers
>
>      Jirka
>
> On 09/03/2011, pjstunna  wrote:
>
> > Hi,
>
> > I just recently discovered Django and I'm following the Django
> > tutorial as it is written on the website (
> >http://docs.djangoproject.com/en/dev//intro/tutorial01/
> > ) but when i start the development server and viewhttp://127.0.0.1:8000
> > from my browser I get this error
>
> > Error 503 Service Unavailable from 127.0.0.1
>
> > I just installed Django 1.2.5 and I'm using the SQlite3 backend on a
> > Windows 7 laptop
>
> > Please help!!!
>
> > 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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: join when it is not needed

2011-03-10 Thread Karen Tracey
On Thu, Mar 10, 2011 at 1:26 AM, aiko  wrote:

> Can anyone me explain why django here uses join.
>
> Let say I have:
>
> class List(models.Model):
>property = models.ForeignKey(Property, related_name="List")
>
> class Property(models.Model):
>name = models.CharField(...)
>
> property = Property.objects.get(pk=100)
> list = List.objects.get(property=property, value='value')
>
>
> Django generates:
>
> SELECT ...
> FROM list
> INNER JOIN property ON (list.property_id = property.id)
> WHERE list.property_id = 100  AND list.value = "value"
>
>
I can't get it to generate that query. I get:

Python 2.5.2 (r252:60911, Jan 20 2010, 23:16:55)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from ttt.models import Property, List
>>> p = Property.objects.get(pk=1)
>>> List.objects.get(property=p, value='v1')

>>> from django.db import connection
>>> connection.queries[-1]['sql']
u'SELECT `ttt_list`.`id`, `ttt_list`.`property_id`, `ttt_list`.`value` FROM
`ttt_list` WHERE (`ttt_list`.`property_id` = 1  AND `ttt_list`.`value` = v1
)'



> Why not ?:
>
> SELECT ... FROM list WHERE property_id = 100  AND value = "value"
>
>
That's the query I get. I thought maybe it was a recent optimization but I
get that query going as far back as Django 1.1. Have you simplified your
models/queries here?

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.



Probable bug - not importing force_unicode silently fails

2011-03-10 Thread Venkatraman S
I stumbled on this 'probable' bug and thought would share it with the group
to ensure that it indeed is a bug and not something that i have been
hallucinating :)
When you try using force_unicode without importing it, the django console
does not report an error; for eg, when i was playing around with LogEntry,
using like :
..
..
somecode_here_1
LogUserAction.objects.log_action(
user_id = request.user.pk,
content_type_id = ContentType.objects.get_for_model(object).pk,
object_id   = object.pk,
object_repr = force_unicode(object),
action_flag = CHANGE
  )
somecode_here_2
..
render_to-response...

The code just silently failed - i.e control never came to somecode_here_2 ,
but somehow the template got rendered without any errors. Thoughts?

-V-

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Probable bug - not importing force_unicode silently fails

2011-03-10 Thread Karen Tracey
On Thu, Mar 10, 2011 at 7:10 AM, Venkatraman S  wrote:

> I stumbled on this 'probable' bug and thought would share it with the group
> to ensure that it indeed is a bug and not something that i have been
> hallucinating :)
> When you try using force_unicode without importing it, the django console
> does not report an error; for eg, when i was playing around with LogEntry,
> using like :
> ..
> ..
> somecode_here_1
> LogUserAction.objects.log_action(
> user_id = request.user.pk,
> content_type_id = ContentType.objects.get_for_model(object).pk,
> object_id   = object.pk,
> object_repr = force_unicode(object),
> action_flag = CHANGE
>   )
> somecode_here_2
> ..
> render_to-response...
>
> The code just silently failed - i.e control never came to somecode_here_2 ,
> but somehow the template got rendered without any errors. Thoughts?
>

There's nothing magic about force_unicode, Python is going to raise an
exception if you try to use it without importing it. My initial guess is
this code you have shown is in a try/except that is swallowing the
exception, somewhere in those dots representing other code not shown.

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.



Re: Probable bug - not importing force_unicode silently fails

2011-03-10 Thread Tom Evans
On Thu, Mar 10, 2011 at 12:10 PM, Venkatraman S  wrote:
> I stumbled on this 'probable' bug and thought would share it with the group
> to ensure that it indeed is a bug and not something that i have been
> hallucinating :)
> When you try using force_unicode without importing it, the django console
> does not report an error; for eg, when i was playing around with LogEntry,
> using like :
> ..
> ..
> somecode_here_1
> LogUserAction.objects.log_action(
>     user_id = request.user.pk,
>     content_type_id = ContentType.objects.get_for_model(object).pk,
>     object_id   = object.pk,
>     object_repr = force_unicode(object),
>     action_flag = CHANGE
>   )
> somecode_here_2
> ..
> render_to-response...
>
> The code just silently failed - i.e control never came to somecode_here_2 ,
> but somehow the template got rendered without any errors. Thoughts?
>
> -V-
>

If you didn't get to somecode_here_2, you certainly didn't get to
render_to_response. More likely, your browser returned a cached
version of the page.

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: Probable bug - not importing force_unicode silently fails

2011-03-10 Thread Gennadiy Zlobin
CTRL + F5 on Firefox and Chrome to force reload page with no caching


- Gennadiy 


On Thu, Mar 10, 2011 at 6:22 PM, Tom Evans  wrote:

> On Thu, Mar 10, 2011 at 12:10 PM, Venkatraman S 
> wrote:
> > I stumbled on this 'probable' bug and thought would share it with the
> group
> > to ensure that it indeed is a bug and not something that i have been
> > hallucinating :)
> > When you try using force_unicode without importing it, the django console
> > does not report an error; for eg, when i was playing around with
> LogEntry,
> > using like :
> > ..
> > ..
> > somecode_here_1
> > LogUserAction.objects.log_action(
> > user_id = request.user.pk,
> > content_type_id = ContentType.objects.get_for_model(object).pk,
> > object_id   = object.pk,
> > object_repr = force_unicode(object),
> > action_flag = CHANGE
> >   )
> > somecode_here_2
> > ..
> > render_to-response...
> >
> > The code just silently failed - i.e control never came to somecode_here_2
> ,
> > but somehow the template got rendered without any errors. Thoughts?
> >
> > -V-
> >
>
> If you didn't get to somecode_here_2, you certainly didn't get to
> render_to_response. More likely, your browser returned a cached
> version of the page.
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Satchmo Error - Invalid block tag: 'thumbnail', expected 'else' or 'endif'

2011-03-10 Thread pols
try re-installing thumbnail
easy_install  sorl-thumbnail==3.2.5

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



Re: Probable bug - not importing force_unicode silently fails

2011-03-10 Thread Venkatraman S
I did not have the code inside try-catch block. I had a hyperlink (lets say
from page A) to another page(B) which was to displayed using 'thickbox';
during the display of this page B, the variables sent to Page B were not
being used and i was getting a blank page inside the div(i.e,  thickbox ) -
so in effect, page B wasnt getting rendered, but again there was no error
either!

Had a tough time debugging this issue :)

-V

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Satchmo Error - Invalid block tag: 'thumbnail', expected 'else' or 'endif'

2011-03-10 Thread chris hendrix

yeah we've followed all the instructions


On 03/10/2011 08:00 AM, pols wrote:

try re-installing thumbnail
easy_install  sorl-thumbnail==3.2.5



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



acces to dict

2011-03-10 Thread Szabo, Patrick (LNG-VIE)
Hi, 

 

I'm passing a dict of lists on to a template like this:

 

return render_to_response('reports.html', {'produkte': prod_pool}
,context_instance=RequestContext(request))

 

prod_pool looks like this:

 

defaultdict(, {'Dumme G\xc3\xa4nge revisited':
['Absatzkontrolle'], 'Das Sparschwein im Wandel der Zeiten':
['Konvertierungsanleitung', 'Sonstiges'], 'Schlager 1':
['Konvertierungsanleitung'], 'RWZ 1': ['Absatzkontrolle',
'Konvertierungsanleitung'], 'RWZ 3': ['Absatzkontrolle',
'Konvertierungsanleitung']})

 

In my template i do this:

 

{% for produkt, akt in produkte.items %}

{{ produkt }}

 

   

   Aktivitaet

   Zeit

   

   

   {% for x in akt%}

   {{ x }}

   {% endfor %}

   

   

   Gesamt: 



   



{% endfor %}

 

Unfortunately i don't get a single table...

Can anyone help me ?!

 

Kind regards


. . . . . . . . . . . . . . . . . . . . . . . . . .
Patrick Szabo
 XSLT Developer 
LexisNexis
Marxergasse 25, 1030 Wien

mailto:patrick.sz...@lexisnexis.at
Tel.: +43 (1) 534 52 - 1573 
Fax: +43 (1) 534 52 - 146 





-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: acces to dict

2011-03-10 Thread Matias Aguirre
Hi

The problem is that django template system tries __getkey__ first and as you
are using a defaultdict get key call is creating a new entry with key "items"
and empty list as value.

Try passing dict(prod_pool) to your template.

Regards,
Matías

Excerpts from Szabo, Patrick \(LNG-VIE\)'s message of Thu Mar 10 11:28:00 -0200 
2011:
> Hi, 
> 
>  
> 
> I'm passing a dict of lists on to a template like this:
> 
>  
> 
> return render_to_response('reports.html', {'produkte': prod_pool}
> ,context_instance=RequestContext(request))
> 
>  
> 
> prod_pool looks like this:
> 
>  
> 
> defaultdict(, {'Dumme G\xc3\xa4nge revisited':
> ['Absatzkontrolle'], 'Das Sparschwein im Wandel der Zeiten':
> ['Konvertierungsanleitung', 'Sonstiges'], 'Schlager 1':
> ['Konvertierungsanleitung'], 'RWZ 1': ['Absatzkontrolle',
> 'Konvertierungsanleitung'], 'RWZ 3': ['Absatzkontrolle',
> 'Konvertierungsanleitung']})
> 
>  
> 
> In my template i do this:
> 
>  
> 
> {% for produkt, akt in produkte.items %}
> 
> {{ produkt }}
> 
>  
> 
>
> 
>Aktivitaet
> 
>Zeit
> 
>
> 
>
> 
>{% for x in akt%}
> 
>{{ x }}
> 
>{% endfor %}
> 
>
> 
>
> 
>Gesamt: 
> 
> 
> 
>
> 
> 
> 
> {% endfor %}
> 
>  
> 
> Unfortunately i don't get a single table...
> 
> Can anyone help me ?!
> 
>  
> 
> Kind regards
-- 
Matías Aguirre 

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



AW: acces to dict

2011-03-10 Thread Szabo, Patrick (LNG-VIE)
Hi, 

Thx for the hint...works like a charme :-)

Kind regards


. . . . . . . . . . . . . . . . . . . . . . . . . .
Patrick Szabo
 XSLT Developer 
LexisNexis
Marxergasse 25, 1030 Wien

mailto:patrick.sz...@lexisnexis.at
Tel.: +43 (1) 534 52 - 1573 
Fax: +43 (1) 534 52 - 146 


-Ursprüngliche Nachricht-

Von: django-users@googlegroups.com [mailto:django-users@googlegroups.com] Im 
Auftrag von Matias Aguirre
Gesendet: Donnerstag, 10. März 2011 14:42
An: django-users
Betreff: Re: acces to dict

Hi

The problem is that django template system tries __getkey__ first and as you
are using a defaultdict get key call is creating a new entry with key "items"
and empty list as value.

Try passing dict(prod_pool) to your template.

Regards,
Matías

Excerpts from Szabo, Patrick \(LNG-VIE\)'s message of Thu Mar 10 11:28:00 -0200 
2011:
> Hi, 
> 
>  
> 
> I'm passing a dict of lists on to a template like this:
> 
>  
> 
> return render_to_response('reports.html', {'produkte': prod_pool}
> ,context_instance=RequestContext(request))
> 
>  
> 
> prod_pool looks like this:
> 
>  
> 
> defaultdict(, {'Dumme G\xc3\xa4nge revisited':
> ['Absatzkontrolle'], 'Das Sparschwein im Wandel der Zeiten':
> ['Konvertierungsanleitung', 'Sonstiges'], 'Schlager 1':
> ['Konvertierungsanleitung'], 'RWZ 1': ['Absatzkontrolle',
> 'Konvertierungsanleitung'], 'RWZ 3': ['Absatzkontrolle',
> 'Konvertierungsanleitung']})
> 
>  
> 
> In my template i do this:
> 
>  
> 
> {% for produkt, akt in produkte.items %}
> 
> {{ produkt }}
> 
>  
> 
>
> 
>Aktivitaet
> 
>Zeit
> 
>
> 
>
> 
>{% for x in akt%}
> 
>{{ x }}
> 
>{% endfor %}
> 
>
> 
>
> 
>Gesamt: 
> 
> 
> 
>
> 
> 
> 
> {% endfor %}
> 
>  
> 
> Unfortunately i don't get a single table...
> 
> Can anyone help me ?!
> 
>  
> 
> Kind regards
-- 
Matías Aguirre 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: What is the best server for Django

2011-03-10 Thread Eugene MechanisM
I've server (4x 2.66+ GHz, 8GB RAM, 2TB HDD, Debian 6) at http://ovh.co.uk
they're offers really great up-time/performance/service/broadband
speed.
I'm serving radio stations streams, several django sites(of coz nginx-
varnish-uwsgi)..

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



Re: Template Referencing Dictionary By Name

2011-03-10 Thread octopusgrabbus
Thanks. As you pointed out, I had to remove the '-' in the dictionary
key.

On Mar 9, 9:31 pm, Karen Tracey  wrote:
>  On Wed, Mar 9, 2011 at 1:30 PM, octopusgrabbus
> wrote:
>
> > This is for Django 1.2 and MySQL 5.x
>
> > How does a template know a dictionary's name, if a dictionary is
> > supplied in render_to_response?
>
> It doesn't.
>
> >   totals_dict['TotalActiveAccounts'] = ret_list[0]
> >    totals_dict['TotalBillableAccounts'] = ret_list[1]
> >    totals_dict['TotalNon-BillableAccounts'] = int(ret_list[0]) -
> > int(ret_list[1])
>
> > context_instance=RequestContext(request))
> >    return render_to_response('main_page.html', totals_dict,
> > context_instance=RequestContext(request))
>
> Given that code, the template can access TotalActiveAccounts and
> TotalBillableAccounts:
>
> {{ TotalActiveAccounts }} {{ TotalBillableAccounts }}
>
> That last key of 'TotalNon-BillableAccounts' is going to be a problem
> because the dash isn't allowed in a template variable name (though I can't
> find where allowed chars in template variable name are listed...but trying
> to access {{ TotalNon-BillableAccounts }} will generate a template syntax
> error relating to not being able to parse the content after the dash. So
> you're going to want to avoid putting dashes in your dictionary key names.
>
> If for some reason you wanted that dictionary, directly, accessible in the
> context for the template, you'd pass it inside a different dictionary passed
> to render_to_response:
>
> render_to_response('main_page.html', {'totals_dict': totals_dict }, ...
>
> Since I gave the key the same name as the variable with the value, that's
> the name it will have in the template context, and you can get to the
> individual items using the . operator, e.g.:
>
> {{ totals_dict.TotalActiveAccounts }}
>
> If I instead passed the dict under a different name:
>
> render_to_response('main_page.html', {'foo': totals_dict }, ...
>
> that's the name I'd use in the template:
>
> {{ foo.TotalActiveAccounts }}
>
> So the variable name for the dictionary in the view makes no difference,
> it's the key names in the dictionary passed to render_to_response that
> matter to the template.
>
> 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.



Admin Action - getting the 'entire' query set

2011-03-10 Thread tom
Hi,
I want to be able to perform an Action on the full query set I have
after filtering.

Assume I have 100,000 objects on my DB. After filtering- 1,000 remain,
and are divided into 10 pages of display. Now I want to delete all of
them, I check the appropriate checkbox but the action 'delete selected
objects' recieves as the queryset parameter only the objects that
appeared on the first page of the website after filtering.

Is there an easy way to be able to pass to the Action methods the
entire query set?

Thanks a lot,
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.



Django sitemap framework

2011-03-10 Thread Sithembewena Lloyd Dube
Hi everyone,

Does Django Sitemap Framework handle paginated content? I have a Django
sitemap generating URLs for articles, and the articles are paginated on the
site.

Thanks.

-- 
Regards,
Sithembewena Lloyd Dube

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Why does Django Fail on Date Field?

2011-03-10 Thread octopusgrabbus
Could my problem be related to the fact that my views.py module first
performs a get (sql select) on the table in question, and if the
record is
not there, then inserts it?

  try:
temp_ept_id =
CsRemove.objects.get(endpointid=requested_serial_number)
errors.append('Endpoint and channel
already queued for removal.')


except ObjectDoesNotExist:
# element was not found - it is OK to add
to cs_remove

gd = createGlobalData(getMySQLDateTime())
base_date = gd.get_xfer_date_base()

load_date = "'" + base_date + "'"

try:
inv_obj = \
CsRemove(action='R', \
 
endpointid=request.POST.get('inv_id'), \
 
devicetype=request.POST.get('ept_type'), \
 
channelnumber=request.POST.get('ept_ch'), \
   actiondate=load_date)

inv_obj.save(force_insert=True)
errors.append('Endpoint ID queued for
customer synch removal')

except MySQLdb.Error, e:
info_str = 'Error: ' + e  + '
load_date = ' + load_date
errors.append(info_str)

On Mar 9, 8:37 am, octopusgrabbus  wrote:
> This is a MySQL 5.0+ database. I can manually insert using Query
> Browser.
>
> On Mar 8, 12:34 pm, octopusgrabbus  wrote:
>
> > Sorry. The error is Exception Type:
> > ValidationError
> > Exception Value:
> > [u'Enter a valid date in -MM-DD format.']
>
> > I have printed out for myself to prove that my date is in this format.
>
> > On Mar 8, 8:24 am, Jirka Vejrazka  wrote:> Well, 
> > we're missing the bit where you tell us what error are you
> > > getting. I don't know about others, but my crystal ball is a bit dusty
> > > these days.
>
> > > The models.py snippet you posted is obvious result of inspectdb
> > > output, which *may* need some manual tweaking. But it's difficult for
> > > us to guess as we don't know your database and we don't know what
> > > exactly is wrong (except for "Django fails").
>
> > > If you add more details, someone might be able to help you
>
> > > My 2 cents
>
> > >    Jirka
>
> > > On Tue, Mar 8, 2011 at 14:08, octopusgrabbus  
> > > wrote:
> > > > Here is the table:
>
> > > > class CsRemove(models.Model):
> > > >    action = models.CharField(max_length=3, db_column='Action') #
> > > > Field name made lowercase.
> > > >    endpointid = models.IntegerField(primary_key=True,
> > > > db_column='EndpointId') # Field name made lowercase.
> > > >    devicetype = models.IntegerField(primary_key=True,
> > > > db_column='DeviceType') # Field name made lowercase.
> > > >    channelnumber = models.IntegerField(primary_key=True,
> > > > db_column='ChannelNumber') # Field name made lowercase.
> > > >    actiondate = models.DateField(primary_key=True,
> > > > db_column='ActionDate') # Field name made lowercase.
> > > >    class Meta:
> > > >        db_table = u'cs_remove'
>
> > > > I can use MySQL Query browser and insert successfully. Django cannot.
> > > > I can easily roll some MySQL code to do this, but would prefer to do
> > > > it the Django way.
>
> > > > What am I missing?
>
> > > > 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 
> > > > athttp://groups.google.com/group/django-users?hl=en.

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



Re: What is the best server for Django

2011-03-10 Thread octopusgrabbus
Server or Hosted Service? I was confused by the question.

We host our own applications (at least for now).

For server hardware, we use IBM e-server, non-virtual at the moment.

For OS software, Red Hat Enterprise EL WS 5 in production. Eventually,
will be rebuilt using CentOS.

For development Ubuntu desktop 10.04 with server components
installed.

I would recommend 32-bit OS for now. I've suffered through a lot of
cockpit error with 64-bit. The mod_wsgi list was quite helpful
regarding that.

cmn

On Mar 10, 9:00 am, Eugene MechanisM 
wrote:
> I've server (4x 2.66+ GHz, 8GB RAM, 2TB HDD, Debian 6) athttp://ovh.co.uk
> they're offers really great up-time/performance/service/broadband
> speed.
> I'm serving radio stations streams, several django sites(of coz nginx-
> varnish-uwsgi)..

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



acces lists by index

2011-03-10 Thread Szabo, Patrick (LNG-VIE)
Hi, 

 

I'm trying to acces the last index of a list in my template but list[-1]
throws  the following error:

 

Could not parse the remainder: '[-1]' from 'list[-1]'

 

How can i do it right !?

 

Kind regards

 


. . . . . . . . . . . . . . . . . . . . . . . . . .
Patrick Szabo
 XSLT Developer 
LexisNexis
Marxergasse 25, 1030 Wien

mailto:patrick.sz...@lexisnexis.at
Tel.: +43 (1) 534 52 - 1573 
Fax: +43 (1) 534 52 - 146 





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



AW: acces lists by index

2011-03-10 Thread Szabo, Patrick (LNG-VIE)
Nevermind:

 

This did it:

 

{% for x in akt %}

  {% if forloop.last %}

{{ x }}

  {% endif %}

{% endfor %}

 

Von: django-users@googlegroups.com [mailto:django-users@googlegroups.com] Im 
Auftrag von Szabo, Patrick (LNG-VIE)
Gesendet: Donnerstag, 10. März 2011 16:25
An: django-users@googlegroups.com
Betreff: acces lists by index

 

Hi, 

 

I'm trying to acces the last index of a list in my template but list[-1] throws 
 the following error:

 

Could not parse the remainder: '[-1]' from 'list[-1]'

 

How can i do it right !?

 

Kind regards

 

. . . . . . . . . . . . . . . . . . . . . . . . . .

Patrick Szabo
XSLT Developer 

LexisNexis
Marxergasse 25, 1030 Wien

patrick.sz...@lexisnexis.at

Tel.: +43 (1) 534 52 - 1573 

Fax: +43 (1) 534 52 - 146 

 

 

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


. . . . . . . . . . . . . . . . . . . . . . . . . .
Patrick Szabo
 XSLT Developer 
LexisNexis
Marxergasse 25, 1030 Wien

mailto:patrick.sz...@lexisnexis.at
Tel.: +43 (1) 534 52 - 1573 
Fax: +43 (1) 534 52 - 146 





-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: acces lists by index

2011-03-10 Thread Amao Zhao
django do not sport list[-n] index!

On Thu, Mar 10, 2011 at 11:24 PM, Szabo, Patrick (LNG-VIE) <
patrick.sz...@lexisnexis.at> wrote:

>  Hi,
>
>
>
> I’m trying to acces the last index of a list in my template but list[-1]
> throws  the following error:
>
>
>
> *Could not parse the remainder: '[-1]' from 'list[-1]'*
>
>
>
> How can i do it right !?
>
>
>
> Kind regards
>
>
>
>  . . . . . . . . . . . . . . . . . . . . . . . . . .
>
>  **
>
> Patrick Szabo
> XSLT Developer
>
> LexisNexis
> Marxergasse 25, 1030 Wien
>
> patrick.sz...@lexisnexis.at
>
> Tel.: +43 (1) 534 52 - 1573
>
> Fax: +43 (1) 534 52 - 146
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: Why does Django Fail on Date Field?

2011-03-10 Thread Tom Evans
On Thu, Mar 10, 2011 at 3:18 PM, octopusgrabbus
 wrote:
> Could my problem be related to the fact that my views.py module first
> performs a get (sql select) on the table in question, and if the
> record is
> not there, then inserts it?

No, it's probably because you are trying to set a datetime to a
string, and the string is in a format that django cannot grok. You
have failed to show any of the data or code, so all I can say about
the date format you are using is that it is wrong.

You should be using a datetime.datetime object anyway, rather than
generating a string representation (badly). The entire purpose of
using an ORM is to avoid these issues, but you seem intent on working
around the ORM rather than through it.

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: What is the best server for Django

2011-03-10 Thread Tiago Almeida
I've been using a shared hosting at djangohosting.ch and I am happy.
Lowest plans start at 4€/month, you only have to pay 3 months in
advance. Servers physically in europe (might be important due to
response times) and very simple web based installer for django apps.

Good luck.

On 9 Mar, 09:53, Chen Xu  wrote:
> I am thinking to buy a server, and integrated with Django environment. So
> could anyone please give me some suggestions, which server is the best for
> this, amazon ec2 or?
>
> Thanks very much
> Best regards
>
> --
> ⚡ Chen Xu ⚡

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



django random template tag

2011-03-10 Thread Jonas Geiregat
Hello,

I've ran into a situation where I might need a random generator in my templates.
I'm aware that the default template tag set doesn't support any random 
generator.
Previous attempts in adding one to the default set where ignored because off 
out of scope issues with the standard set.

Anyway here's my case.

I've got some queryset which I want to display. Each item has 3 possible visual 
presentation modes or way's it's might be displayed.
I could simply append some random data in my views.py file to the result set. 

gigs = Gig.objects.filter(date__gt = date.today()).order_by('date')[:17]

for gig in gigs:
#append the random item to each result
   # This doesn't seem like a sensible solution and it I'm not even sure if 
it's even possible appending some data to a querset


Next I would check the random data in my template and act upon it.





My other idea is a random generator in my template tags.

something like

{% random %}
{{gig.data}}
{% or %}
{{gig.data}}
etc ...
{% endrandom %}

This behavior is mimicked after: 
http://code.djangoproject.com/attachment/ticket/919/random_tag.patch

Is this a sensible solution ? 

Or are there other better way's of solving random issues in the template layer ?

Regards,

Jonas.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: acces lists by index

2011-03-10 Thread Brett Parker
{% for x in akt|slice:"-1" %}
{{ x }}
{% endfor %}

Maybe quicker.
-- 
Brett Parker

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: AttributeError at / polls / in Django Tutorial-Solved

2011-03-10 Thread Alberto Morales Fernández

On 03/10/2011 03:28 AM, delegb...@dudupay.com wrote:

The spelling is what the problem is.
You have typed 'objetcs' instead of 'objects'.

Always study the error trace very well.

Best regards.
Sent from my BlackBerry wireless device from MTN



Ups!!, sorry, I did not see "objects" when I wrote it wrong, the error 
was clear


Thank you very much

Best regards.

Alberto Morales

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



render_to_response a HTML msg

2011-03-10 Thread Thiago Carvalho D' Ávila
I'm having some problem while trying to render some HTML code as a template
variable.

What I am doing is:

*view.py*
def view(request, id):
   thing = get_object_or_404(Object, pk=id)
   if blablabla:
  return render_to_response('template.html'),
{'html_message': ' We recommend that you click here'},
}, RequestContext(request))

*template.html*

   {% if html_message %}{{ html_message }}{% endif %}


But I get the HTML tags written in the text, not the link.
What am I doing wrong?

Tks ;)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: render_to_response a HTML msg

2011-03-10 Thread Tom Evans
2011/3/10 Thiago Carvalho D' Ávila :
> I'm having some problem while trying to render some HTML code as a template
> variable.
>
> What I am doing is:
>
> view.py
> def view(request, id):
>    thing = get_object_or_404(Object, pk=id)
>    if blablabla:
>       return render_to_response('template.html'),
> {'html_message': ' We recommend that you click  href="thing.get_update_url">here'},
> }, RequestContext(request))
>
> template.html
> 
>    {% if html_message %}{{ html_message }}{% endif %}
> 
>
> But I get the HTML tags written in the text, not the link.
> What am I doing wrong?
>
> Tks ;)
>

http://docs.djangoproject.com/en/1.2/topics/templates/#automatic-html-escaping

http://docs.djangoproject.com/en/1.2/ref/templates/builtins/#autoescape

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: render_to_response a HTML msg

2011-03-10 Thread Gennadiy Zlobin
try

   {% if html_message %}{{ html_message|safe }}{% endif %}



but I would do:
   {% if html_message %}
  We recommend that you click here
  {% endif %}



- Gennadiy 


2011/3/10 Thiago Carvalho D' Ávila 

> I'm having some problem while trying to render some HTML code as a template
> variable.
>
> What I am doing is:
>
> *view.py*
> def view(request, id):
>thing = get_object_or_404(Object, pk=id)
>if blablabla:
>   return render_to_response('template.html'),
> {'html_message': ' We recommend that you click  href="thing.get_update_url">here'},
> }, RequestContext(request))
>
> *template.html*
> 
>{% if html_message %}{{ html_message }}{% endif %}
> 
>
> But I get the HTML tags written in the text, not the link.
> What am I doing wrong?
>
> Tks ;)
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: render_to_response a HTML msg

2011-03-10 Thread Bill Freeman
Use:

  {% if html_message %}{{ html_message|safe }}{% endif %}

Presuming that you believe that the variable's content is, indeed, safe.

Bill

2011/3/10 Thiago Carvalho D' Ávila :
> I'm having some problem while trying to render some HTML code as a template
> variable.
>
> What I am doing is:
>
> view.py
> def view(request, id):
>    thing = get_object_or_404(Object, pk=id)
>    if blablabla:
>       return render_to_response('template.html'),
> {'html_message': ' We recommend that you click  href="thing.get_update_url">here'},
> }, RequestContext(request))
>
> template.html
> 
>    {% if html_message %}{{ html_message }}{% endif %}
> 
>
> But I get the HTML tags written in the text, not the link.
> What am I doing wrong?
>
> Tks ;)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: Error when trying to deploy Django.

2011-03-10 Thread Tom Evans
On Thu, Mar 10, 2011 at 4:21 PM, balu  wrote:
> Hi all
>
> I'm trying to deploy django for the first time. During this process
> I'm getting the following error. Please help me to correct this.
>
> balu@balu-varanasi:/etc/apache2/sites-available$ /etc/init.d/apache2
> reloadSyntax error on line 10 of /etc/apache2/sites-enabled/mysite:
> Invalid command 'WSGIScriptAlias', perhaps misspelled or defined by a
> module not included in the server configuration
> Action 'configtest' failed.
> The Apache error log may have more information.
>   ...fail!
>

You haven't installed mod_wsgi, or you have installed it but have not
enabled it in Apache.

http://code.google.com/p/modwsgi/wiki/QuickInstallationGuide#Loading_Module_Into_Apache

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.



Error when trying to deploy Django.

2011-03-10 Thread balu
Hi all

I'm trying to deploy django for the first time. During this process
I'm getting the following error. Please help me to correct this.

balu@balu-varanasi:/etc/apache2/sites-available$ /etc/init.d/apache2
reloadSyntax error on line 10 of /etc/apache2/sites-enabled/mysite:
Invalid command 'WSGIScriptAlias', perhaps misspelled or defined by a
module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
   ...fail!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: render_to_response a HTML msg

2011-03-10 Thread Thiago Carvalho D' Ávila
Oh, thanks a lot. That worked, but now I have one more doubt...

What are the security issues related to the use of safe variable? When can I
consider it safe? Is it possible to make some kind of injection using it
this way? Is autoescape a better option?

2011/3/10 Bill Freeman 

> Use:
>
>  {% if html_message %}{{ html_message|safe }}{% endif %}
>
> Presuming that you believe that the variable's content is, indeed, safe.
>
> Bill
>
> 2011/3/10 Thiago Carvalho D' Ávila :
> > I'm having some problem while trying to render some HTML code as a
> template
> > variable.
> >
> > What I am doing is:
> >
> > view.py
> > def view(request, id):
> >thing = get_object_or_404(Object, pk=id)
> >if blablabla:
> >   return render_to_response('template.html'),
> > {'html_message': ' We recommend that you click  > href="thing.get_update_url">here'},
> > }, RequestContext(request))
> >
> > template.html
> > 
> >{% if html_message %}{{ html_message }}{% endif %}
> > 
> >
> > But I get the HTML tags written in the text, not the link.
> > What am I doing wrong?
> >
> > Tks ;)
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



AttributeError on _strptime_time

2011-03-10 Thread Massimiliano della Rovere
The error  was trapped by django-sentry and does *not* occur in python
interpreter, thus I can't understand it!
Please can anybody enlighten me?

Here the details:

Exception Type: AttributeError
Exception Value: _strptime_time

The error is raised by line #698 in
/usr/local/lib/python2.6/dist-packages/Django-1.2.5-py2.6.egg/django/db/models/fields/__init__.py
in to_python using django 1.2.5:

 698. return datetime.datetime(*time.strptime(value, '%Y-%m-%d
%H:%M:%S')[:6],
 699. **kwargs)

With local variables:

kwargs = {'microsecond': 0}
self = u''
usecs = 0
value = u'2011-02-24 00:00:00'

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: render_to_response a HTML msg

2011-03-10 Thread Tom Evans
2011/3/10 Thiago Carvalho D' Ávila :
> Oh, thanks a lot. That worked, but now I have one more doubt...
>
> What are the security issues related to the use of safe variable? When can I
> consider it safe? Is it possible to make some kind of injection using it
> this way? Is autoescape a better option?
>

They are all variants of the same thing. These are all equivalent:

{{ foo|safe }}

{% autoescape off %}
{{ foo }}
{% endautoescape %}

from django.utils.safestring import mark_safe
return render_to_response('...', { 'foo': mark_safe(foo) })

They are all equally vulnerable to injection. If you mark a string as
safe, it disables automatic output escaping, and if the string or a
portion of the string is user controlled, then that is an injection
vector, which is why Gennadiy suggested not building the HTML in the
view.

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.



django remove unicode from query result ?

2011-03-10 Thread sushanth Reddy
Hi,

Django query gives me below output  format,but i want below format

date=`[{'total': 1744, 'name: u'x'}, {'total': 13, 'name': u'm'}, 
{'total': 126, 'role': name'n'}]`
m=[]
for i in m:
   m.append(i.values())

   
print m
it give me output

[[1744,u'x'], [13,u'm'], [126,u'n']]

but i need output in
how to remove unicode symbol from output 

[['x',1744], ['m',13], ['n',126]]

how to do this ?

Thanks in advance

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: render_to_response a HTML msg

2011-03-10 Thread Bill Freeman
On Thu, Mar 10, 2011 at 12:14 PM, Tom Evans  wrote:
> 2011/3/10 Thiago Carvalho D' Ávila :
>> Oh, thanks a lot. That worked, but now I have one more doubt...
>>
>> What are the security issues related to the use of safe variable? When can I
>> consider it safe? Is it possible to make some kind of injection using it
>> this way? Is autoescape a better option?
>>
>
> They are all variants of the same thing. These are all equivalent:
>
> {{ foo|safe }}
>
> {% autoescape off %}
> {{ foo }}
> {% endautoescape %}
>
> from django.utils.safestring import mark_safe
> return render_to_response('...', { 'foo': mark_safe(foo) })
>
> They are all equally vulnerable to injection. If you mark a string as
> safe, it disables automatic output escaping, and if the string or a
> portion of the string is user controlled, then that is an injection
> vector, which is why Gennadiy suggested not building the HTML in the
> view.
>
> Cheers
>
> Tom

If this is a field whose content you are allowing users to enter, it's
pretty vulnerable.  There are products that allow you to restrict html
content, but, as far as I know, they are not part of Django, at least
by default.  Perhaps someone knows something that plugs in.
Assuming that this is a model field value, you would want to qualify
it on save, which, presumably happens much less often than views.

But allowing users to enter HTML is something I try to avoid.  (I'm
stuck with it on many of our plone sites, but plone has "safe html"
controls built in.)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: What is the best server for Django

2011-03-10 Thread Venkatraman S
On Thu, Mar 10, 2011 at 8:51 PM, Tiago Almeida wrote:

> I've been using a shared hosting at djangohosting.ch and I am happy.
> Lowest plans start at 4€/month, you only have to pay 3 months in
> advance. Servers physically in europe (might be important due to
> response times) and very simple web based installer for django apps.
>

How are these guys w.r.t webfaction - can someone who has used webfaction
comment on these guys?
Webfaction's support simple rocks!
But, djangohosting.ch is almost 50% cheaper than webfaction! so was
wondering whether i should make a move!

-V

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 remove unicode from query result ?

2011-03-10 Thread Bill Freeman
If you know your content only has characters that exist in your
default, you can say:

m.append([str(s) for s in i.values()])

Or, read up on the encode method of unicode objects to see about how to ignore
characters that don't translate, or for encoding into other than your
default characer
set.  Encoding into UTF-8 might be what you want.

On Thu, Mar 10, 2011 at 12:29 PM, sushanth Reddy  wrote:
> Hi,
>
> Django query gives me below output  format,but i want below format
>
>     date=`[{'total': 1744, 'name: u'x'}, {'total': 13, 'name': u'm'},
> {'total': 126, 'role': name'n'}]`
>     m=[]
>     for i in m:
>    m.append(i.values())
>
>
> print m
> it give me output
>
>     [[1744,u'x'], [13,u'm'], [126,u'n']]
>
> but i need output in
> how to remove unicode symbol from output
>
>     [['x',1744], ['m',13], ['n',126]]
>
> how to do this ?
>
> Thanks in advance
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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 Django from cron

2011-03-10 Thread Sells, Fred
I'm sure the solution is out there somewhere, but my google search is
giving me too many false positives.

I have a stand along python program that will be run as a cron job and I
don't know how to launch it so it picks up the django settings, etc.

I can run it like this

>python manage.py shell
>>>import mymodule
>>>mymodule.execute()

But I would like to run it like 

>python mymodule.py

I really don't want to set the DJANGO_SETTINGS_MODULE as a system
environment variable since I have other django webapps I debug on this
box, but perhaps I just don't grasp the concept here.  I apologize for
asking something that I'm sure has been covered, I just could not find
it.

I'm currently using django 1.2.4 and Python 2.4 but could upgrade both
if that's the correct 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: Why does Django Fail on Date Field?

2011-03-10 Thread Tom Evans
On Thu, Mar 10, 2011 at 5:31 PM, octopusgrabbus
 wrote:
> The code's in the last post. What other code would you like to see?
>

If you'd like help, please reply to the list, not to me directly. Thanks.

*Some* code is in the post. Your problem is that you are formatting a
date as a string, and trying to update a DateTime field with it. The
string does not conform to a format that django can understand, and
you get a validation error.

You haven't shown:
  A sample of the date that gets generated as a string
  The code that generates the date as a string

IE, anything that could help determine why it fails. All the code
you've shown so far is uninteresting to this problem.

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: Why does Django Fail on Date Field?

2011-03-10 Thread octopusgrabbus
I'm confused as to how this code isn't using the model?

Here's the model I'm using. The table is in a MySQL database.
class CsRemove(models.Model):
action = models.CharField(max_length=3, db_column='Action') #
Field name made lowercase.
endpointid = models.IntegerField(primary_key=True,
db_column='EndpointId') # Field name made lowercase.
devicetype = models.IntegerField(primary_key=True,
db_column='DeviceType') # Field name made lowercase.
channelnumber = models.IntegerField(primary_key=True,
db_column='ChannelNumber') # Field name made lowercase.
actiondate = models.DateField(primary_key=True,
db_column='ActionDate') # Field name made lowercase.
class Meta:
db_table = u'cs_remove'

Here's the code extract.

This date, not a datetime, format works fine in other python code, and
it is a string in the form 2011-03-08 format.

   try:
temp_ept_id =
CsRemove.objects.get(endpointid=requested_serial_number)
errors.append('Endpoint and channel
already queued for removal.')


except ObjectDoesNotExist:
# element was not found - it is OK to add
to cs_remove

load_date = '-00-00'

inv_obj = \
CsRemove(action='R', \
 
endpointid=request.POST.get('inv_id'), \
 
devicetype=request.POST.get('ept_type'), \
 
channelnumber=request.POST.get('ept_ch'), \
   actiondate=load_date)

inv_obj.save(force_insert=True)
errors.append('Endpoint ID queued for
customer synch removal')




On Mar 10, 10:30 am, Tom Evans  wrote:
> On Thu, Mar 10, 2011 at 3:18 PM, octopusgrabbus
>
>  wrote:
> > Could my problem be related to the fact that my views.py module first
> > performs a get (sql select) on the table in question, and if the
> > record is
> > not there, then inserts it?
>
> No, it's probably because you are trying to set a datetime to a
> string, and the string is in a format that django cannot grok. You
> have failed to show any of the data or code, so all I can say about
> the date format you are using is that it is wrong.
>
> You should be using a datetime.datetime object anyway, rather than
> generating a string representation (badly). The entire purpose of
> using an ORM is to avoid these issues, but you seem intent on working
> around the ORM rather than through it.
>
> 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: using Django from cron

2011-03-10 Thread Shawn Milochik
import os

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'


>From the docs:
http://docs.djangoproject.com/en/dev/topics/settings/

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: using Django from cron

2011-03-10 Thread Tom Evans
On Thu, Mar 10, 2011 at 5:42 PM, Sells, Fred
 wrote:
> I'm sure the solution is out there somewhere, but my google search is
> giving me too many false positives.
>
> I have a stand along python program that will be run as a cron job and I
> don't know how to launch it so it picks up the django settings, etc.
>
> I can run it like this
>
>>python manage.py shell
import mymodule
mymodule.execute()
>
> But I would like to run it like
>
>>python mymodule.py
>
> I really don't want to set the DJANGO_SETTINGS_MODULE as a system
> environment variable since I have other django webapps I debug on this
> box, but perhaps I just don't grasp the concept here.  I apologize for
> asking something that I'm sure has been covered, I just could not find
> it.
>
> I'm currently using django 1.2.4 and Python 2.4 but could upgrade both
> if that's the correct solution.
>

The easiest way is to wrap your python script in a shell script. This
would be necessary* if using virtualenv. Mine look like this (from
rote, so may be wrong):

  #!/bin/sh
  . /path/to/django/install/my-venv-name/bin/activate
  DJANGO_SETTINGS_MODULE=myproj.settings
  export DJANGO_SETTINGS_MODULE
  # virtualenv activate ensures we get right python
  python /path/to/django/install/myproj/manage.py foobar "$*"


You can then put this directly into cron:

@daily /path/to/wrapper.sh "bar" "quuz wibble"

Cheers

Tom

* well, easier. Maybe not necessary

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Why does Django Fail on Date Field?

2011-03-10 Thread Jirka Vejrazka
Will this answer your question?

>>> import datetime
>>> datetime.datetime(year=, month=00, day=00)
Traceback (most recent call last):
  File "", line 1, in 
ValueError: year is out of range


  Jirka

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Why does Django Fail on Date Field?

2011-03-10 Thread Tom Evans
On Thu, Mar 10, 2011 at 5:46 PM, octopusgrabbus
 wrote:
> I'm confused as to how this code isn't using the model?
>
> Here's the model I'm using. The table is in a MySQL database.
> class CsRemove(models.Model):
>    action = models.CharField(max_length=3, db_column='Action') #
> Field name made lowercase.
>    endpointid = models.IntegerField(primary_key=True,
> db_column='EndpointId') # Field name made lowercase.
>    devicetype = models.IntegerField(primary_key=True,
> db_column='DeviceType') # Field name made lowercase.
>    channelnumber = models.IntegerField(primary_key=True,
> db_column='ChannelNumber') # Field name made lowercase.
>    actiondate = models.DateField(primary_key=True,
> db_column='ActionDate') # Field name made lowercase.
>    class Meta:
>        db_table = u'cs_remove'
>
> Here's the code extract.
>
> This date, not a datetime, format works fine in other python code, and
> it is a string in the form 2011-03-08 format.

It 'works in other code' - talking directly to mysql though, right,
using mysqldb and not using django's ORM? You are no longer using
mysqldb, you are using django's ORM, and you must obey it's rules, not
mysql's.

Truthfully, if you are using django's ORM, you should be using the
objects it expects, eg date or datetime. Your date format, I can't
tell whether it is 'Y-m-d' or 'Y-d-m'. Using the proper python objects
would resolve ambiguity.

>
>   try:
>                            temp_ept_id =
> CsRemove.objects.get(endpointid=requested_serial_number)
>                            errors.append('Endpoint and channel
> already queued for removal.')
>
>
>                        except ObjectDoesNotExist:
>                            # element was not found - it is OK to add
> to cs_remove
>
>                            load_date = '-00-00'

This isn't a valid date. MySQL will accept it just fine, but it isn't
valid in many other databases, and its not valid in django.

>
>                            inv_obj = \
>                                    CsRemove(action='R', \
>
> endpointid=request.POST.get('inv_id'), \
>
> devicetype=request.POST.get('ept_type'), \
>
> channelnumber=request.POST.get('ept_ch'), \
>                                           actiondate=load_date)
>
>                            inv_obj.save(force_insert=True)
>                            errors.append('Endpoint ID queued for
> customer synch removal')
>
>
>

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



Packaging and development workflow for decoupled apps.

2011-03-10 Thread DaleB
Hi all,

i could use some advice for a good packaging workflow.

So far i used to put an "apps"-folder in my project root and i stored
all individual apps in a sub-folder.
This works, but i thought: "Okay, try to decouple things a bit more
and try to create some 'real' reusable apps."

So i followed Jacob's guide on buildout (http://jacobian.org/writing/
django-apps-with-buildout) and thanks to the clear and detailed
instructions i managed to build a nice package for one of my apps.
Okay, so i removed the according sub-folder from my app-dir, installed
my new package to the virtualenv containing my project and everything
worked ... Nice!

BUT ...

I see that this is really great for the distribution of an app.
But what about development and "continuous packaging"?
I mean, my project consists of more than five apps. One side of me
would rather turn them all into installable packages so i get a nice
decoupled environment.

But how do i work on my projects once things are separated?
I mean, in reality, though functional distinct, the apps work together
and interact to form a site as whole.
So, to get a complete feeling and an overview for what my app does (or
breaks) i need to see it embedded in a working site.
I got this, when all different apps where folders under the same root-
dir. I could easily edit things in one app and see the results
immediately on my site. Due to version control it was easy to rollback
changes that were problematic.

Do i simply miss an important point? Am i just spilled by the
monolithic workflow?
How do you implement new features? Do you just concentrate on a single
app (in a separated buildout dir), test everything, package it and
finally install the new version and
then check if everything fits still together? (And if not, go back to
your app, package it again, install it etc.)

I'd really love to hear some strategies how you cope with this.

Thanks,
Andreas

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



Re: using Django from cron

2011-03-10 Thread Bill Freeman
On Thu, Mar 10, 2011 at 12:49 PM, Tom Evans  wrote:
> On Thu, Mar 10, 2011 at 5:42 PM, Sells, Fred
>  wrote:
>> I'm sure the solution is out there somewhere, but my google search is
>> giving me too many false positives.
>>
>> I have a stand along python program that will be run as a cron job and I
>> don't know how to launch it so it picks up the django settings, etc.
>>
>> I can run it like this
>>
>>>python manage.py shell
>import mymodule
>mymodule.execute()
>>
>> But I would like to run it like
>>
>>>python mymodule.py
>>
>> I really don't want to set the DJANGO_SETTINGS_MODULE as a system
>> environment variable since I have other django webapps I debug on this
>> box, but perhaps I just don't grasp the concept here.  I apologize for
>> asking something that I'm sure has been covered, I just could not find
>> it.
>>
>> I'm currently using django 1.2.4 and Python 2.4 but could upgrade both
>> if that's the correct solution.
>>
>
> The easiest way is to wrap your python script in a shell script. This
> would be necessary* if using virtualenv. Mine look like this (from
> rote, so may be wrong):
>
>  #!/bin/sh
>  . /path/to/django/install/my-venv-name/bin/activate
>  DJANGO_SETTINGS_MODULE=myproj.settings
>  export DJANGO_SETTINGS_MODULE
>  # virtualenv activate ensures we get right python
>  python /path/to/django/install/myproj/manage.py foobar "$*"
>
>
> You can then put this directly into cron:
>
> @daily /path/to/wrapper.sh "bar" "quuz wibble"
>
> Cheers
>
> Tom
>
> * well, easier. Maybe not necessary

Another approach is to write your script as a django manage.py
command.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Packaging and development workflow for decoupled apps.

2011-03-10 Thread Bill Freeman
On Thu, Mar 10, 2011 at 12:57 PM, DaleB  wrote:
> Hi all,
>
> i could use some advice for a good packaging workflow.
>
> So far i used to put an "apps"-folder in my project root and i stored
> all individual apps in a sub-folder.
> This works, but i thought: "Okay, try to decouple things a bit more
> and try to create some 'real' reusable apps."
>
> So i followed Jacob's guide on buildout (http://jacobian.org/writing/
> django-apps-with-buildout) and thanks to the clear and detailed
> instructions i managed to build a nice package for one of my apps.
> Okay, so i removed the according sub-folder from my app-dir, installed
> my new package to the virtualenv containing my project and everything
> worked ... Nice!
>
> BUT ...
>
> I see that this is really great for the distribution of an app.
> But what about development and "continuous packaging"?
> I mean, my project consists of more than five apps. One side of me
> would rather turn them all into installable packages so i get a nice
> decoupled environment.
>
> But how do i work on my projects once things are separated?
> I mean, in reality, though functional distinct, the apps work together
> and interact to form a site as whole.
> So, to get a complete feeling and an overview for what my app does (or
> breaks) i need to see it embedded in a working site.
> I got this, when all different apps where folders under the same root-
> dir. I could easily edit things in one app and see the results
> immediately on my site. Due to version control it was easy to rollback
> changes that were problematic.
>
> Do i simply miss an important point? Am i just spilled by the
> monolithic workflow?
> How do you implement new features? Do you just concentrate on a single
> app (in a separated buildout dir), test everything, package it and
> finally install the new version and
> then check if everything fits still together? (And if not, go back to
> your app, package it again, install it etc.)
>
> I'd really love to hear some strategies how you cope with this.
>
> Thanks,
> Andreas

buildout offers a feature called development eggs.  In addition to listing
your eggs in the "eggs" variable of the [buildout] section, you list the
path to the egg source (containing setup.py, etc.) in the "develop"
variable.  This keeps buildout from trying to down load the egg and,
I believe, make a directory "develop-eggs" (a sibling of buildout.cfg)
containing ".link" files, each containing the path to where you can import
the package (typically the folder containing setup.py).

zope's recipe, I think, uses these to figure out what all to add to sys.path
in the various python based executable scripts that it makes in the bin
subdirectory, so that other code can just import the package by name.
I'm not sure whether the django deployment instructions you have will
use these, but if not you could certainly make a module for inclusion
by settings.py that figured out what to add to sys.path (if it's not already
there) by inspecting the files in the develop-eggs directory.

Bill

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Packaging and development workflow for decoupled apps.

2011-03-10 Thread Mike Ramirez
On Thursday, March 10, 2011 09:57:29 am DaleB wrote:

> I see that this is really great for the distribution of an app.
> But what about development and "continuous packaging"?
> I mean, my project consists of more than five apps. One side of me
> would rather turn them all into installable packages so i get a nice
> decoupled environment.
> 
> But how do i work on my projects once things are separated?
> I mean, in reality, though functional distinct, the apps work together
> and interact to form a site as whole.
> So, to get a complete feeling and an overview for what my app does (or
> breaks) i need to see it embedded in a working site.
> I got this, when all different apps where folders under the same root-
> dir. I could easily edit things in one app and see the results
> immediately on my site. Due to version control it was easy to rollback
> changes that were problematic.
> 
> Do i simply miss an important point? Am i just spilled by the
> monolithic workflow?
> How do you implement new features? Do you just concentrate on a single
> app (in a separated buildout dir), test everything, package it and
> finally install the new version and
> then check if everything fits still together? (And if not, go back to
> your app, package it again, install it etc.)
> 

Apps should do one thing and do it well. The trick in your situation is to 
avoid circular dependcies. If you have circular dependancies, refactor. 

You want to build the apps like a pyramid, each block/app adds something, but 
only the upper levels should (if they need to) depend on an app at a lower 
level. but never the lower level depend on the upper level. 

Test Driven Development really shines here. Write your tests firsts then write 
the code to pass those tests, not the other way around. With proper tests you 
shouldn't have to worry about how the code will break your projects. You'll 
know it won't, once they all pass. Tests also give good example code on how to 
use your app.

I think you are stuck in the monolithic point of view.  I'm also not sure if 
you understand that django apps are python modules and the same rules apply.  

The apps location within the PYTHONPATH is immaterial to a project, as long as 
the project can find the app. With this in mind, I tend to have a lib 
directory, that contains apps that are in development or checkouted out from 
other developers versioning system. This lib directory is added to the python 
path for each project that needs an app from this location. Please note this 
is a directory seperate from python${VERSION}/site-packages. 

In the end how you do it is what fits your needs, but it's best to have one 
location for each app that is accessible to every project that needs it.

To get a sense of what I mean you should read this[1]. 


Mike



> I'd really love to hear some strategies how you cope with this.
> 
> Thanks,
> Andreas


[1] http://docs.python.org/tutorial/modules.html#packages

-- 
QOTD:
"If I'm what I eat, I'm a chocolate chip cookie."

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Packaging and development workflow for decoupled apps.

2011-03-10 Thread Tom Evans
On Thu, Mar 10, 2011 at 5:57 PM, DaleB  wrote:
> Hi all,
>
> i could use some advice for a good packaging workflow.
>
> So far i used to put an "apps"-folder in my project root and i stored
> all individual apps in a sub-folder.
> This works, but i thought: "Okay, try to decouple things a bit more
> and try to create some 'real' reusable apps."
>
> So i followed Jacob's guide on buildout (http://jacobian.org/writing/
> django-apps-with-buildout) and thanks to the clear and detailed
> instructions i managed to build a nice package for one of my apps.
> Okay, so i removed the according sub-folder from my app-dir, installed
> my new package to the virtualenv containing my project and everything
> worked ... Nice!
>
> BUT ...
>
> I see that this is really great for the distribution of an app.
> But what about development and "continuous packaging"?
> I mean, my project consists of more than five apps. One side of me
> would rather turn them all into installable packages so i get a nice
> decoupled environment.
>
> But how do i work on my projects once things are separated?
> I mean, in reality, though functional distinct, the apps work together
> and interact to form a site as whole.
> So, to get a complete feeling and an overview for what my app does (or
> breaks) i need to see it embedded in a working site.
> I got this, when all different apps where folders under the same root-
> dir. I could easily edit things in one app and see the results
> immediately on my site. Due to version control it was easy to rollback
> changes that were problematic.
>
> Do i simply miss an important point? Am i just spilled by the
> monolithic workflow?
> How do you implement new features? Do you just concentrate on a single
> app (in a separated buildout dir), test everything, package it and
> finally install the new version and
> then check if everything fits still together? (And if not, go back to
> your app, package it again, install it etc.)
>
> I'd really love to hear some strategies how you cope with this.
>
> Thanks,
> Andreas
>

It's all about packages really IMO. If two apps are coupled, then they
probably deserve to be in the same package, but still as separate
apps. An app that is only consumed by other apps, on the other hand,
would be in a package by itself.

Eg, one of my 'for fun' projects at the minute is a django/amqp
PVR/media player that records and plays back TV and organizes,
manages, collects my other media (photos, video clips, etc), and makes
all the media available either to control on the big screen, or
consume via the browser.
Some apps are tightly coupled together, eg the app that provides the
interactive remote and the app that provides transcoding support, so
they are both apps within the pvr package. The app that collects,
parses and displays TV listings data doesn't depend on anything else,
so it lives in its own package.

Eg, my INSTALLED_APPS looks like this:

INSTALLED_APPS = (
  'pvr.transcoding',
  'pvr.iremote',
  'xmltvutils',
  ...
)

The apps in the pvr package are actually in my project source code,
since they are highly coupled, eg this structure:

project/
`- pvr/
 `- transcoding/

whilst the xmltvutils is completely standalone and so is installed by
pip into the appropriate place in my virtualenv.

Some ideas to chew on :)

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: Why does Django Fail on Date Field?

2011-03-10 Thread octopusgrabbus
I converted my date, and it all works fine. Thanks for your help.

On Mar 10, 12:54 pm, Tom Evans  wrote:
> On Thu, Mar 10, 2011 at 5:46 PM, octopusgrabbus
>
>
>
>  wrote:
> > I'm confused as to how this code isn't using the model?
>
> > Here's the model I'm using. The table is in a MySQL database.
> > class CsRemove(models.Model):
> >    action = models.CharField(max_length=3, db_column='Action') #
> > Field name made lowercase.
> >    endpointid = models.IntegerField(primary_key=True,
> > db_column='EndpointId') # Field name made lowercase.
> >    devicetype = models.IntegerField(primary_key=True,
> > db_column='DeviceType') # Field name made lowercase.
> >    channelnumber = models.IntegerField(primary_key=True,
> > db_column='ChannelNumber') # Field name made lowercase.
> >    actiondate = models.DateField(primary_key=True,
> > db_column='ActionDate') # Field name made lowercase.
> >    class Meta:
> >        db_table = u'cs_remove'
>
> > Here's the code extract.
>
> > This date, not a datetime, format works fine in other python code, and
> > it is a string in the form 2011-03-08 format.
>
> It 'works in other code' - talking directly to mysql though, right,
> using mysqldb and not using django's ORM? You are no longer using
> mysqldb, you are using django's ORM, and you must obey it's rules, not
> mysql's.
>
> Truthfully, if you are using django's ORM, you should be using the
> objects it expects, eg date or datetime. Your date format, I can't
> tell whether it is 'Y-m-d' or 'Y-d-m'. Using the proper python objects
> would resolve ambiguity.
>
>
>
> >   try:
> >                            temp_ept_id =
> > CsRemove.objects.get(endpointid=requested_serial_number)
> >                            errors.append('Endpoint and channel
> > already queued for removal.')
>
> >                        except ObjectDoesNotExist:
> >                            # element was not found - it is OK to add
> > to cs_remove
>
> >                            load_date = '-00-00'
>
> This isn't a valid date. MySQL will accept it just fine, but it isn't
> valid in many other databases, and its not valid in django.
>
>
>
> >                            inv_obj = \
> >                                    CsRemove(action='R', \
>
> > endpointid=request.POST.get('inv_id'), \
>
> > devicetype=request.POST.get('ept_type'), \
>
> > channelnumber=request.POST.get('ept_ch'), \
> >                                           actiondate=load_date)
>
> >                            inv_obj.save(force_insert=True)
> >                            errors.append('Endpoint ID queued for
> > customer synch removal')

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



Insert an "editable" extra field on admin change list.

2011-03-10 Thread Marc Aymerich
Hi,
I spend all day trying to figure out how to insert an "editable" extra
field (not a model field) in admin change list. Is there an easy way
to do that?
Thanks!
-- 
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.



mysql OperationalError

2011-03-10 Thread Brian Craft
When a long-running script loses the db connection, I get this exception:

_mysql_exceptions.OperationalError


Is there any way to trap this in a database-agnostic way? Or must I
hard-code it to 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: Admin Action - getting the 'entire' query set

2011-03-10 Thread Karen Tracey
On Thu, Mar 10, 2011 at 9:15 AM, tom  wrote:

> I want to be able to perform an Action on the full query set I have
> after filtering.
>
> Assume I have 100,000 objects on my DB. After filtering- 1,000 remain,
> and are divided into 10 pages of display. Now I want to delete all of
> them, I check the appropriate checkbox but the action 'delete selected
> objects' recieves as the queryset parameter only the objects that
> appeared on the first page of the website after filtering.
>
>
What level of Django are you using? With Django 1..2 (I think that is when
it was added), there is javascript that, when you check the "select all"
checkbox at the very top of the column (in the header), adds a "link" to the
right of the action dropdown and selection text that is something like:

"Select all nnn whatevers"

If you select that link the note about how many items are selected should
update to match the number you had filtered on, and that larger set will get
passed in to any chosen action.

If you are not seeing that link and are indeed using Django 1.2 or higher
then you may be using customized admin templates from before that support
was added -- I remember at least one person not seeing the option for that
reason.

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.



Use admin interface in public facing pages?

2011-03-10 Thread gbl
The admin interface is perfect for the site I'm working on. Automatic
pagination, customizable search fields, filter via boolean or date
fields in a sidebar, clickable sorting on column headings. Easy to
modify

Is there really no way to use all this code in a read-only situation?

Do I have to rewrite all that code or is there some way to use what is
already built in?

Pointers to relevant docs would be great. It seems a variant of this
question is asked frequently so I'm guessing there is no easy way to
do this...but I ask anyway with fingers crossed.

databrowse is cool as well but not customizable, nor as full featured
as the admin interface

The admin interface is nearly exactly what I need to view and search a
databasebut I don't want people editing what they're browsing and
I need to customize the detail view a bit.

I'm new to django so if this is truly basic and I've missed something
my apologies.

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



What is it with Django and 2008?

2011-03-10 Thread Benjamin Roberts
So I don't mean to be confrontational at all.  I am learning Django
and really like it.  I'm forming a startup and we've already decided
to go with it to build our applications.  I look forward to getting
involved in the community, too.  Something has me a bit weirded out
though, it seems 75% of what I see on the web about django (whether it
is blog posts, tutorials, stack questions, etc.) came out in 2008.
Can anyone explain this?  I would assume that if Django hit its
"Critical mass" in 2008 that there would be even more stuff from 2009,
2010, and 2011 as the community gets bigger and bigger.  Does this
just strangely coincide with when Hovolaty got really busy with
EveryBlock and he couldn't keep writing mass blog posts under a bunch
of pseudonyms and aliases?  (just kidding on that last question, of
course).  Just wanted to check if anyone else has noticed the same
thing and post something for friendly conversation.

Thanks,

Ben

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



Skinning/extending the admin for sub-admin interfaces?

2011-03-10 Thread br
So I'm taking over a project (which already has a strong start in
Django) from a few guys. I'm new to the framework (but experienced as
a programmer) and excited for everything about it (the project,
Python, and Django).

I have one general design question. But first, some background

The site is something we will be providing as SaaS to various
customers (lets call them units) for interfacing with their own
customers.  Each unit will have various sub-units. So we are dealing
with a product having several web interfaces, with varying levels of r/
w access to data:

The interfaces:

- sys admin (Default Django Admin: my co.)

- unit dashboard (i.e. unit admin): (can edit data related to their
specific unit)

- sub-unit dashboard: (can edit a little bit of data, specific to
their subunit)

- authenticated public interface (subunit's customers)
- unauthenticated public interface

We're working on pretty designs for everything but the sysadmin, for
which we're stoked to be using Django admin.

So the question is, for each of the "dashboards"--which are
essentially limited admin interfaces--would it make sense to extend or
inherit from Django Admin in some way? Or should I just design these
like I would client-side pages, with specific forms to edit the
pertinent data that a user has permission to edit.

I realize this may be a total noob question, but I wanted to get a
general idea of which tree to start barking up from an architecture
standpoint

Thanks,

bdr

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 remove unicode from query result ?

2011-03-10 Thread Kenneth Gonsalves
On Thu, 2011-03-10 at 09:29 -0800, sushanth Reddy wrote:
> print m
> it give me output
> 
> [[1744,u'x'], [13,u'm'], [126,u'n']]
> 
> but i need output in
> how to remove unicode symbol from output 
> 
> 

why do you want to remove it? unicode is a great advance - why are you
going backward in time?
-- 
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: Why does Django Fail on Date Field?

2011-03-10 Thread Kenneth Gonsalves
On Thu, 2011-03-10 at 09:46 -0800, octopusgrabbus wrote:
> load_date = '-00-00'

what on earth is this?
-- 
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: Skinning/extending the admin for sub-admin interfaces?

2011-03-10 Thread Kenneth Gonsalves
On Thu, 2011-03-10 at 16:55 -0800, br wrote:
> So the question is, for each of the "dashboards"--which are
> essentially limited admin interfaces--would it make sense to extend or
> inherit from Django Admin in some way? Or should I just design these
> like I would client-side pages, with specific forms to edit the
> pertinent data that a user has permission to edit. 

design as client side. With things like ModelForm this is a breeze.
Would be faster than inheriting/extending admin. You have unlimited
flexibility outside admin.
-- 
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.



Simple Django Report Generator

2011-03-10 Thread Patrick McDonnell
Hello -

I'm wondering if anyone has any suggestions/recommendations for a flexible
Django report generator.  Basically, I'd like to give user's the ability to
query a given model based on user-defined filters.  For example, for an
application that tracks information about a company's employees, often a
manager will want to run a report saying "show me all the employees in the
accounting department who have been employeed for X or more years," or
something to that effect.  Clearly, these kind of reports are trivial for me
to hard code using Django's ORM, but a much more ideal solution would be to
provide users with a (dare I say it) MS Access-like query builder, that
would allow them to choose the columns they want, define basic filters, and
a sorting order, and then review the results in a tabular format.

I've looked around and haven't quite found anything that meets my needs, so
I'd appreciate any suggestions anyone might have.  If nothing exists, I'll
probably try to write something myself, and make it my contribution to the
OSS community if its any good, but obviously I'd rather not reinvent the
wheel.

Thanks in advance!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 remove unicode from query result ?

2011-03-10 Thread sushanth Reddy
I using jplot in my app .if list is in unicode(u) ,it not displaying the 
charts,thats the reason i want 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: django remove unicode from query result ?

2011-03-10 Thread Kenneth Gonsalves
On Thu, 2011-03-10 at 17:26 -0800, sushanth Reddy wrote:
> I using jplot in my app .if list is in unicode(u) ,it not displaying
> the 
> charts,thats the reason i want to remove it ... 

I do not think that is a good reason. Why not use a python or js
library?

http://wiki.python.org/moin/NumericAndScientific/Plotting
-- 
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: django remove unicode from query result ?

2011-03-10 Thread Jason Culverhouse

On Mar 10, 2011, at 5:26 PM, sushanth Reddy wrote:

> I using jplot in my app .if list is in unicode(u) ,it not displaying the 
> charts,thats the reason i want to remove it ...
> 

Pass a json string then have the Java(?) side convert it back into "objects"

In [1]: import json
In [2]: json.dumps([[1744,u'x'], [13,u'm'], [126,u'n']])
Out[2]: '[[1744, "x"], [13, "m"], [126, "n"]]'



> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: Simple Django Report Generator

2011-03-10 Thread Venkatraman S
On Fri, Mar 11, 2011 at 6:54 AM, Patrick McDonnell  wrote:

> Clearly, these kind of reports are trivial for me to hard code using
> Django's ORM, but a much more ideal solution would be to provide users with
> a (dare I say it) MS Access-like query builder, that would allow them to
> choose the columns they want, define basic filters, and a sorting order, and
> then review the results in a tabular format.
>

I have done earlier, wherein i had to design a custom dashboard for
reporting.
Instead of the ORM, think in terms of building a SQL - things would be much
much easier and also faster to develop.

-V

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Logging raw sql

2011-03-10 Thread Marwan Al-Sabbagh
Hi,
  There are three different possible solutions you could investigate to do
this logging on the django/python level:

1) use django's new logging feature that as per the docs will log "every SQL
statement executed by a request". The beauty of this approach is that you
can use python's excellent logging module an just add your own filter and
handler to grab exactly what you want and log it the way you want. you can
read more about it at
http://docs.djangoproject.com/en/dev/topics/loggingKeep in mind though
this is a django 1.3 feature which looks to be released
within a week.
2) check out django-debug-toolbar (
http://robhudson.github.com/django-debug-toolbar/) which displays all SQL
queries executed in a request, you could read through their code and see how
they hook in and get that information
3) you could take the mysql database backend django.db.backends.mysql which
seems to be a collection of classes and try and make your own custom backend
that only extends certain classes that you need to be logged. It could be
like a thin wrapper around django.db.backends.mysql

hope one of these solutions works for you.

cheers,
Marwan

On Wed, Mar 9, 2011 at 8:57 PM, Dave Sluder  wrote:

> Thanks krzysiekpl, I actually have to use mysql. Having browsed
> through the django source, I don't think there is anyway to intercept
> the query unless it were done for example in mysqldb, since the
> library actually generates the raw sql. I've discovered the
> general_log to table feature of mysql 5.1 and am just executing a
> query against that to filter the results.
>
> On Mar 9, 4:35 am, krzysiekpl  wrote:
> > Hi, if you are using postgresql you can use logger_collector. Try
> > this:
> http://www.postgresql.org/docs/8.3/static/runtime-config-logging.html.
> >
> > On 9 Mar, 05:04, Dave Sluder  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > I need to log all insert/update/delete queries such that the database
> > > could be rebuilt from the log. I know I can do this at the database
> > > level, but I need to log selectively for certain models.
> > > The statements captured from db.connection.queries still contain
> > > parameters so they won't work.
> >
> > > Does anyone have any insight as to where I can intercept the raw query
> > > if at 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.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 get next and previous element in a forloop in the template

2011-03-10 Thread Derek
On Mar 7, 10:43 pm, Ariel  wrote:
> Could you give some idea ???
> I am sorry about the previous message I had not finished.
>
> Any help is appreciated.
> Regards.
>
>
>
>
>
>
>
> On Mon, Mar 7, 2011 at 3:39 PM, Ariel  wrote:
> > Hi everybody:
>
> > I would want to know in the django template tags how to get the next and
> > the previous element when I am iterating in the forloop, I haven't found
> > something similar, for instance I would want something like this:
>
> > {% for element in list_elements %}
> > {{forloop.get_prev_element.title}}
> > {{forloop.get_next_element.title}}

You could try using the Paginator ( 
http://docs.djangoproject.com/en/1.2/topics/pagination/
) for this - giving it a limit of 1 object - and making use of its
functionality for your own purposes.

(You should also probably try to understand more about how iteration
works in Python; for example, have a look at this discussion -
http://stackoverflow.com/questions/2777188/making-a-python-iterator-go-backwards
)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: When do we stop using Django admin?

2011-03-10 Thread Derek
On Mar 8, 8:16 am, ajaishankar  wrote:
> Thanks Viklap
>
> We have been doing a lot of ModelAdmin & ModelForm tweaking as
> mentioned in those slides.
>
> But still kind of skeptical we should be opening up the admin to other
> companies; and go through the gymnastics of restricting say a foreign
> key lookup to just the data they are allowed to access etc.
>
> Ajai
>
> On Mar 7, 11:57 pm, vikalp sahni  wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > Django Admin is nicely structured to give you lot of flixibility.
>
> > We have tweaked around admin using all possible features and with good
> > mingling of MIDDLEWARE, AUTH_BACKENDS  and STORAGE one can
> > achive a lot of integrations and customizations.
>
> > have a look at these slides, it brings more amount of confidence to going
> > forward
> > with 
> > Django-Adminhttp://www.slideshare.net/lincolnloop/customizing-the-django-admin
>
> > Regards,//Vikalp
>
> > On Tue, Mar 8, 2011 at 11:19 AM, ajaishankar  wrote:
> > > Hi
>
> > > We have a app built on Django, and have been using the admin to good
> > > effect.
>
> > > Right now we want to open up the app to other companies:
>
> > > 1. They can log in, create *their* own users
> > > 2. They can only see data that belongs to their company etc.
> > > 3. Also in one part of the app, we expect a highly customized UI where
> > > there is a lot of ajaxy image upload etc going on.
>
> > > I do know we can tweak the admin to restrict querysets etc. and also
> > > override admin templates - but is admin preferable in this situation?
>
> > > Or is it better to treat all this as a front end web app, and start
> > > work on fresh pages.
>
> > > Any pointers would be much appreciated.


Our approach has been to use the Admin - there is not *that* much
tweaking required in Django to filter data, and the approach of
writing a completely new interface is a lot more work.  But we had
that approach "built-in" from the start; you need to consider your
situation and see how many extra changes are needed.  In our situation
there is also a lot of shared data/tables, and so it makes to have a
common interface to access that.

HTH
Derek

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Multiple modelforms in single POST

2011-03-10 Thread Anoop Thomas Mathew
Hi all,

I have a Profile model, which has a ForiegnKey to User model. I want to edit
both of it at same form.

this is what I tried, http://dpaste.de/ODOJ/
Still, no success. Please help.

regards,
atm

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Simple Django Report Generator

2011-03-10 Thread Bruno Tikami
On Thu, Mar 10, 2011 at 11:44 PM, Venkatraman S  wrote:

>
> On Fri, Mar 11, 2011 at 6:54 AM, Patrick McDonnell wrote:
>
>> Clearly, these kind of reports are trivial for me to hard code using
>> Django's ORM, but a much more ideal solution would be to provide users with
>> a (dare I say it) MS Access-like query builder, that would allow them to
>> choose the columns they want, define basic filters, and a sorting order, and
>> then review the results in a tabular format.
>>
>
> I have done earlier, wherein i had to design a custom dashboard for
> reporting.
> Instead of the ORM, think in terms of building a SQL - things would be much
> much easier and also faster to develop.
>
> -V
>
>
Hi Patrick,

have you tried Geraldo Reports [0] ? It's flexible, easy to use and worth a
look ;-)

Cheers,

Tkm

[0] http://geraldoreports.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.