Re: Trouble with query syntax in Django view

2012-04-30 Thread Alexandr Aibulatov
First of all. Student.objects.filter(pk=id) returns QuerySet not
instance of Student.
If you want get current student use
get_object_or_404()(https://docs.djangoproject.com/en/1.4/topics/http/shortcuts/#get-object-or-404)
or Student.objects.get(pk=id).

Teacher and parents can bee retrived via Student instance:
teacher = student.teacher
parents = student.parents.all()

2012/5/1 LJ :
> I have a Student model that stores information about a student,
> including the student's teacher.
> The teacher's information is stored in the Employee model that
> inherits from the Person Model.
> I am having trouble figuring out how to query the teacher, when a
> student id is passed as an ajax argument to the view function.
> I have no trouble returning the data about the parents and the
> student, but my filter for querying the teacher info is incorrect.
> Does anyone have any ideas how I can query for the teacher information
> based on the models below?
>
> #models.py
> class Student(Person):
>    grade = models.ForeignKey('schools.Grade')
>    school = models.ManyToManyField('schools.School', blank=True,
> null=True, related_name="school")
>    parents = models.ManyToManyField('parents.Parent', blank=True,
> null=True)
>    teacher = models.ForeignKey(Employee, blank=True, null=True,
> related_name='teacher')
>
> class Employee(Person):
>    ''' Employee model inherit Person Model'''
>    role=models.ForeignKey(EmployeeType, blank=True, null=True)
>    user=models.ForeignKey(User)
>    schools =
> models.ManyToManyField(School,blank=True,null=True)
>
> # views.py
> def get_required_meeting_participants(request, template):
>    try:
>        id=request.GET['id']
>    except:
>        id=None
>
>    parents = Parent.objects.filter(student=id)
>    student = Student.objects.filter(pk=id)
>    teacher = Employee.objects.filter(pk=student.teacher_id)  #this
> line is incorrect...help, please?
>
>    data = {
>        'parents': parents,
>        'student': student,
>        'teacher': teacher,
>    }
>
>    return
> render_to_response(template,data,
>                            context_instance=RequestContext(request))
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>

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

2012-04-30 Thread Alexandr Aibulatov
You can get teacher and parents objects from student instance.
student.teacher and student.teachers.all()
01.05.2012 11:46 пользователь "LJ"  написал:

> I have a Student model that stores information about a student,
> including the student's teacher.
> The teacher's information is stored in the Employee model that
> inherits from the Person Model.
> I am having trouble figuring out how to query the teacher, when a
> student id is passed as an ajax argument to the view function.
> I have no trouble returning the data about the parents and the
> student, but my filter for querying the teacher info is incorrect.
> Does anyone have any ideas how I can query for the teacher information
> based on the models below?
>
> #models.py
> class Student(Person):
>grade = models.ForeignKey('schools.Grade')
>school = models.ManyToManyField('schools.School', blank=True,
> null=True, related_name="school")
>parents = models.ManyToManyField('parents.Parent', blank=True,
> null=True)
>teacher = models.ForeignKey(Employee, blank=True, null=True,
> related_name='teacher')
>
> class Employee(Person):
>''' Employee model inherit Person Model'''
>role=models.ForeignKey(EmployeeType, blank=True, null=True)
>user=models.ForeignKey(User)
>schools =
> models.ManyToManyField(School,blank=True,null=True)
>
> # views.py
> def get_required_meeting_participants(request, template):
>try:
>id=request.GET['id']
>except:
>id=None
>
>parents = Parent.objects.filter(student=id)
>student = Student.objects.filter(pk=id)
>teacher = Employee.objects.filter(pk=student.teacher_id)  #this
> line is incorrect...help, please?
>
>data = {
>'parents': parents,
>'student': student,
>'teacher': teacher,
>}
>
>return
> render_to_response(template,data,
>context_instance=RequestContext(request))
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Trouble with query syntax in Django view

2012-04-30 Thread LJ
I have a Student model that stores information about a student,
including the student's teacher.
The teacher's information is stored in the Employee model that
inherits from the Person Model.
I am having trouble figuring out how to query the teacher, when a
student id is passed as an ajax argument to the view function.
I have no trouble returning the data about the parents and the
student, but my filter for querying the teacher info is incorrect.
Does anyone have any ideas how I can query for the teacher information
based on the models below?

#models.py
class Student(Person):
grade = models.ForeignKey('schools.Grade')
school = models.ManyToManyField('schools.School', blank=True,
null=True, related_name="school")
parents = models.ManyToManyField('parents.Parent', blank=True,
null=True)
teacher = models.ForeignKey(Employee, blank=True, null=True,
related_name='teacher')

class Employee(Person):
''' Employee model inherit Person Model'''
role=models.ForeignKey(EmployeeType, blank=True, null=True)
user=models.ForeignKey(User)
schools =
models.ManyToManyField(School,blank=True,null=True)

# views.py
def get_required_meeting_participants(request, template):
try:
id=request.GET['id']
except:
id=None

parents = Parent.objects.filter(student=id)
student = Student.objects.filter(pk=id)
teacher = Employee.objects.filter(pk=student.teacher_id)  #this
line is incorrect...help, please?

data = {
'parents': parents,
'student': student,
'teacher': teacher,
}

return
render_to_response(template,data,
context_instance=RequestContext(request))

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



Dojo Rich Editor Implementation in Admin.py

2012-04-30 Thread Gchorn
Hi All,

I'm building a blog, with models "Post" and "Image" (each blog post can 
have multiple images; they're related by ForeignKey) and I'm trying to 
implement the Dojo rich editor in my admin site by following the example 
here: 

https://gist.github.com/868595

However, the rich editor is not showing up.  I have a feeling I don't have 
something set up correctly in my admin.py file; could anyone tell me what 
it is?  Here are the contents of admin.py:

from blogs.models import Post,Image
from django.contrib import admin
from django.contrib.admin import site, ModelAdmin
import models


class CommonMedia:
  js = (
'https://ajax.googleapis.com/ajax/libs/dojo/1.6.0/dojo/dojo.xd.js',
'/home/guillaume/mysite/blogs/static/editor.js',
  )
  css = {
'all': ('/home/guillaume/mysite/blogs/static/editor.css',),
  }

class PostImageInline(admin.TabularInline):
model = Image
extra = 5

class PostAdmin(admin.ModelAdmin):
inlines = [PostImageInline]

site.register(models.Post,
list_display = ('text',),
search_fields = ['text',],
Media = CommonMedia,
)

admin.site.unregister(Post)

admin.site.register(Post, PostAdmin)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/IPDPAY_Z5skJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 admin site display (None) even when values are non-null/empty

2012-04-30 Thread Aditya Sriram M

 
I have been trying a lot but could not make out why it happens,

class FortressUserAdmin(admin.ModelAdmin):
list_display(. . . , get_my_schema)
def get_my_schema(self, obj):
sql_query = "select prop_val from customer_property where customer_id = %d 
and property_value like 'SCHEMA'" % obj.customer_id.customer_id
property_value = connection.cursor().execute(sql_query).fetch_one()
print sql_query
return 1
# return "aditya"
get_my_schema.short_description = 'Schema Instance'


   - why the column values are always (None) 
   - why the print 1 or print 'aditya' won't print anything to the console 

Screen shot of the column admin site: [image: enter image description here]

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



Re: The template tag {% load tz %}

2012-04-30 Thread CLIFFORD ILKAY

On 04/30/2012 09:21 PM, Rajat Jain wrote:

Hi,

I am shifting to Django 1.4 and want to use the timezone support (for
which I want to use {% load tz %} in my templates). The problem is that
I have aroudn 30-40 templates, and manually adding these tags to each
template is a pain. Is there a way by which I can do this loading by
default in all the templates?


Hi Rajat,

You can use sed. See: .
--
Regards,

Clifford Ilkay
Dinamis
1419-3230 Yonge St.
Toronto, ON
Canada  M4N 3P6


+1 416-410-3326

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



The template tag {% load tz %}

2012-04-30 Thread Rajat Jain
Hi,

I am shifting to Django 1.4 and want to use the timezone support (for which
I want to use {% load tz %} in my templates). The problem is that I have
aroudn 30-40 templates, and manually adding these tags to each template is
a pain. Is there a way by which I can do this loading by default in all the
templates?

Thanks,
Rajat

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

2012-04-30 Thread Larry Martell
On Mon, Apr 30, 2012 at 6:26 PM, Dennis Lee Bieber
 wrote:
> On Mon, 30 Apr 2012 15:29:08 -0600, Larry Martell
>  declaimed the following in
> gmane.comp.python.django.user:
>
>>
>> But in django I am doing this:
>>
>> from django.db import connection
>> cursor = connection.cursor()
>> cursor.execute(sql)
>>
>> and it's getting the error, so that would mean that the sql isn't
>> getting executed for some reason. I'll have to investigate that
>> avenue.
>
>        You still haven't show us what "sql" contains... Given your three
> statements I'd expect to get an error message since "sql" itself is
> undefined.

I figured out the problem. I had %s in my sql, and they was getting
treated as a format specifier. When I built the sql I did put in '%%',
but I had to put in 4 '' for it to work.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: [help] Server Config: django + uwsgi + nginx

2012-04-30 Thread Karl Sutt
I am not entirely sure what you mean by that. If you mean the nginx
equivalent of Apache VirtualHosts then the nginx wiki explains it quite
nicely http://wiki.nginx.org/ServerBlockExample. Is that what you meant?

Karl Sutt


On Mon, Apr 30, 2012 at 7:04 PM, easypie  wrote:

> does your configuration allow for running multiple sites?
>
>
> On Sunday, April 29, 2012 12:01:27 PM UTC-7, Karl Sutt wrote:
>>
>> Here is my uWSGI command and nginx.conf contents:
>>
>> uwsgi -- http://www.dpaste.org/**aiJuq/ 
>> nginx -- http://www.dpaste.org/**bAG0o/ 
>>
>> I've used it for a Flask application, but I've just tested it and it
>> works for a Django project as well. Note that wsgi.py file in the uwsgi
>> command is the Python file that Django generates when you first create a
>> project, there is no need to change it.
>>
>> Good luck!
>>
>> Karl Sutt
>>
>>
>> On Sun, Apr 29, 2012 at 6:49 PM, easypie  wrote:
>>
>>> I have this file that was created for me by one of the users in django's
>>> irc channel. I edited to have the right information inserted but I"m not
>>> sure what I'm doing wrong to not make it work. I've spent some time trying
>>> to understand each line by searching the web. There's still a thing or two
>>> that's missing from the puzzle. Maybe it's the server config that has a
>>> flaw or the way I went about it. I haven't done a fresh install of uwsgi
>>> and nginx yet. However, please take a look to see if there's an error or
>>> solution that could work. Thanks.
>>>
>>> Link to code: http://www.dpaste.org/**wWVd3/
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To view this discussion on the web visit https://groups.google.com/d/**
>>> msg/django-users/-/**2rekHP0I6V0J
>>> .
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to django-users+unsubscribe@*
>>> *googlegroups.com .
>>> For more options, visit this group at http://groups.google.com/**
>>> group/django-users?hl=en
>>> .
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/sMsRN5iG9NQJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: executing raw sql

2012-04-30 Thread Larry Martell
On Mon, Apr 30, 2012 at 2:32 PM, Larry Martell  wrote:
> On Mon, Apr 30, 2012 at 12:46 PM, Larry Martell  
> wrote:
>> I'm trying to execute some raw sql. I found some code that did this:
>>
>> from django.db import connection
>> cursor = connection.cursor()
>> cursor.execute(sql)
>> data = cursor.fetchall()
>>
>> But the cursor.execute(sql) is blowing up with:
>>
>> 'Cursor' object has no attribute '_last_executed'
>>
>> What is the best or proper way for me to execute my raw sql?
>
> I traced this with the debugger,  and it's blowing up in
> django/db/backends/mysql/base.py in this:
>
>    def last_executed_query(self, cursor, sql, params):
>        # With MySQLdb, cursor objects have an (undocumented) "_last_executed"
>        # attribute where the exact query sent to the database is saved.
>        # See MySQLdb/cursors.py in the source distribution.
>        return cursor._last_executed
>
> Could this have something to do with the version of django and/or mysql?
>
> I'm running django 1.5 and MySQL 5.5.19, and MySQLdb 1.2.3. I just
> tried this and that does not exist on my system:
>
> $ python
> Python 2.6.7 (r267:88850, Jan 11 2012, 06:42:34)
> [GCC 4.0.1 (Apple Inc. build 5490)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
 import MySQLdb
 conn = MySQLdb.connect(host, user, passwd, db)
 cursor = conn.cursor()
 print cursor._last_executed
> Traceback (most recent call last):
>  File "", line 1, in 
> AttributeError: 'Cursor' object has no attribute '_last_executed'
 print cursor.__dict__
> {'_result': None, 'description': None, 'rownumber': None, 'messages':
> [], '_executed': None, 'errorhandler':  Connection.defaulterrorhandler of <_mysql.connection open to
> 'localhost' at 889810>>, 'rowcount': -1, 'connection':  0x62f630 to Connection at 0x889810>, 'description_flags': None,
> 'arraysize': 1, '_info': None, 'lastrowid': None, '_warnings': 0}

I've found that cursor._last_executed doesn't exist until a query has
been executed (it's not initialized to None)

But in django I am doing this:

from django.db import connection
cursor = connection.cursor()
cursor.execute(sql)

and it's getting the error, so that would mean that the sql isn't
getting executed for some reason. I'll have to investigate that
avenue.

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

2012-04-30 Thread Gerald Klein
No problem eveyone has one of those moments

On Mon, Apr 30, 2012 at 4:07 PM, Zaerion  wrote:

> Yup, I caught it just after I posted it and spent about 30 minutes trying
> to figure out what I did wrong. Thanks for the help! :)
>
> On Monday, April 30, 2012 2:05:37 PM UTC-7, Gerald Klein wrote:
>>
>> Hi, the delimiters use are using are wrong it should be {% not (%
>>
>> On Mon, Apr 30, 2012 at 3:41 PM, Zaerion  wrote:
>>
>>> I'm new to using Django and was working my way through the tutorial to
>>> get a better feel of it. I'm stuck on part 3 of the tutorial and the
>>> section where they show you how to use templates. When I hard-code the
>>> HttpResponse object everything works fine, but when I try to use a template
>>> it appears that none of the python code is being interpreted and it
>>> displays in the web browser. I am using Debian 6, Python 2.6, and Django
>>> 1.4 and things have been going smoothly up until this point. I'm sure I
>>> missed a setting somewhere or have something configured incorrectly, but I
>>> can't seem to find it. Any help is appreciated.
>>>
>>> -- You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To view this discussion on the web visit https://groups.google.com/d/**
>>> msg/django-users/-/IErgzK-**V4BYJ
>>> .
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to django-users+unsubscribe@*
>>> *googlegroups.com .
>>> For more options, visit this group at http://groups.google.com/**
>>> group/django-users?hl=en
>>> .
>>>
>>
>>
>>
>> --
>>
>> Gerald Klein DBA
>>
>> contac...@geraldklein.com
>>
>> www.geraldklein.com 
>>
>> j...@zognet.com
>>
>> 708-599-0352
>>
>>
>> Linux registered user #548580
>>
>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/XS7TMWWSqNYJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 

Gerald Klein DBA

contac...@geraldklein.com

www.geraldklein.com 

j...@zognet.com

708-599-0352


Linux registered user #548580

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

2012-04-30 Thread Zaerion
Yup, I caught it just after I posted it and spent about 30 minutes trying 
to figure out what I did wrong. Thanks for the help! :)

On Monday, April 30, 2012 2:05:37 PM UTC-7, Gerald Klein wrote:
>
> Hi, the delimiters use are using are wrong it should be {% not (%
>
> On Mon, Apr 30, 2012 at 3:41 PM, Zaerion  wrote:
>
>> I'm new to using Django and was working my way through the tutorial to 
>> get a better feel of it. I'm stuck on part 3 of the tutorial and the 
>> section where they show you how to use templates. When I hard-code the 
>> HttpResponse object everything works fine, but when I try to use a template 
>> it appears that none of the python code is being interpreted and it 
>> displays in the web browser. I am using Debian 6, Python 2.6, and Django 
>> 1.4 and things have been going smoothly up until this point. I'm sure I 
>> missed a setting somewhere or have something configured incorrectly, but I 
>> can't seem to find it. Any help is appreciated.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/IErgzK-V4BYJ.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> -- 
>
> Gerald Klein DBA
>
> contac...@geraldklein.com
>
> www.geraldklein.com 
>
> j...@zognet.com
>
> 708-599-0352
>
>
> Linux registered user #548580 
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/XS7TMWWSqNYJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Templates not working properly

2012-04-30 Thread Zaerion
Nevermind. I'm just an idiot. I had used parenthesis instead of curly 
braces. Sorry!

On Monday, April 30, 2012 1:41:25 PM UTC-7, Zaerion wrote:
>
> I'm new to using Django and was working my way through the tutorial to get 
> a better feel of it. I'm stuck on part 3 of the tutorial and the section 
> where they show you how to use templates. When I hard-code the HttpResponse 
> object everything works fine, but when I try to use a template it appears 
> that none of the python code is being interpreted and it displays in the 
> web browser. I am using Debian 6, Python 2.6, and Django 1.4 and things 
> have been going smoothly up until this point. I'm sure I missed a setting 
> somewhere or have something configured incorrectly, but I can't seem to 
> find it. Any help is appreciated.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/PJwPbj7qm10J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Templates not working properly

2012-04-30 Thread Gerald Klein
Hi, the delimiters use are using are wrong it should be {% not (%

On Mon, Apr 30, 2012 at 3:41 PM, Zaerion  wrote:

> I'm new to using Django and was working my way through the tutorial to get
> a better feel of it. I'm stuck on part 3 of the tutorial and the section
> where they show you how to use templates. When I hard-code the HttpResponse
> object everything works fine, but when I try to use a template it appears
> that none of the python code is being interpreted and it displays in the
> web browser. I am using Debian 6, Python 2.6, and Django 1.4 and things
> have been going smoothly up until this point. I'm sure I missed a setting
> somewhere or have something configured incorrectly, but I can't seem to
> find it. Any help is appreciated.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/IErgzK-V4BYJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 

Gerald Klein DBA

contac...@geraldklein.com

www.geraldklein.com 

j...@zognet.com

708-599-0352


Linux registered user #548580

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



Templates not working properly

2012-04-30 Thread Zaerion
I'm new to using Django and was working my way through the tutorial to get 
a better feel of it. I'm stuck on part 3 of the tutorial and the section 
where they show you how to use templates. When I hard-code the HttpResponse 
object everything works fine, but when I try to use a template it appears 
that none of the python code is being interpreted and it displays in the 
web browser. I am using Debian 6, Python 2.6, and Django 1.4 and things 
have been going smoothly up until this point. I'm sure I missed a setting 
somewhere or have something configured incorrectly, but I can't seem to 
find it. Any help is appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/IErgzK-V4BYJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 timezone doesn't show the right time?

2012-04-30 Thread Dan Santos
Hi I'm a total programming newbie!

### INTRO ###
I have been following this tutorial and the timezone outputs confuses
me.
https://docs.djangoproject.com/en/1.4/intro/tutorial01/#playing-with-the-api

And I'm still confused after reading these explanations, I basically
need some really dumbed down answers to understand this timezone
business:

TIME_ZONE setting: How does it work?
http://groups.google.com/group/django-users/browse_thread/thread/bebbc1310f24e945/100d0fc3e8620684?lnk=gst&q=timezone+problems#



### QUESTION ###
* Europe/Brussels has UTC+2 during summer time.

When I run this as I follow the Django tutorial, then the time (20:34)
is behind by 2 hours to my local time and UTC displays +00:00.
Shouldn't it display 22:34 +02:00 instead for a server located at
Europe/Brussels?

>>> Poll.objects.all()
]

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



Re: executing raw sql

2012-04-30 Thread Larry Martell
On Mon, Apr 30, 2012 at 12:46 PM, Larry Martell  wrote:
> I'm trying to execute some raw sql. I found some code that did this:
>
> from django.db import connection
> cursor = connection.cursor()
> cursor.execute(sql)
> data = cursor.fetchall()
>
> But the cursor.execute(sql) is blowing up with:
>
> 'Cursor' object has no attribute '_last_executed'
>
> What is the best or proper way for me to execute my raw sql?

I traced this with the debugger,  and it's blowing up in
django/db/backends/mysql/base.py in this:

def last_executed_query(self, cursor, sql, params):
# With MySQLdb, cursor objects have an (undocumented) "_last_executed"
# attribute where the exact query sent to the database is saved.
# See MySQLdb/cursors.py in the source distribution.
return cursor._last_executed

Could this have something to do with the version of django and/or mysql?

I'm running django 1.5 and MySQL 5.5.19, and MySQLdb 1.2.3. I just
tried this and that does not exist on my system:

$ python
Python 2.6.7 (r267:88850, Jan 11 2012, 06:42:34)
[GCC 4.0.1 (Apple Inc. build 5490)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>> conn = MySQLdb.connect(host, user, passwd, db)
>>> cursor = conn.cursor()
>>> print cursor._last_executed
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'Cursor' object has no attribute '_last_executed'
>>> print cursor.__dict__
{'_result': None, 'description': None, 'rownumber': None, 'messages':
[], '_executed': None, 'errorhandler': >, 'rowcount': -1, 'connection': , 'description_flags': None,
'arraysize': 1, '_info': None, 'lastrowid': None, '_warnings': 0}

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



Re: Django - Worldwide Developer Rates - Hourly Income - location and project duration specific

2012-04-30 Thread Raphael
Dear djangos,

if you want to hand-in your data anonymously - just send us an email to
django[at]develissimo.com
we really need more data to achieve some meaningful results.

http://develissimo.com/forum/topic/107887/

Cheers,
Raphael


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Storing Sorl-thumbnail created images in separate folder

2012-04-30 Thread Swaroop Shankar V
Okay in the latest version every images generated is getting saved to
cache. My issue is resolved. Thanks all for your kind help :)

Thanks and Regards,
Swaroop Shankar V



On Tue, May 1, 2012 at 1:24 AM, Swaroop Shankar V wrote:

> It looks like i was using an old version which came with satchmo. Am
> currently testing my project with new version.
>
> Thanks and Regards,
> Swaroop Shankar V
>
>
>
> On Tue, May 1, 2012 at 12:59 AM, Swaroop Shankar V wrote:
>
>> It looks like the latest version of solr-thumnails or the version that i
>> have currently installed supports THUMBNAIL_STORAGE. When i checked i
>> could see a file under the path solr/thumbnail called defaults.py. In this
>> file there are following options
>>
>> DEBUG = False
>> BASEDIR = ''
>> SUBDIR = ''
>> PREFIX = ''
>> QUALITY = 85
>> CONVERT = '/usr/bin/convert'
>> WVPS = '/usr/bin/wvPS'
>> EXTENSION = 'jpg'
>> PROCESSORS = (
>> 'sorl.thumbnail.processors.colorspace',
>> 'sorl.thumbnail.processors.autocrop',
>> 'sorl.thumbnail.processors.scale_and_crop',
>> 'sorl.thumbnail.processors.filters',
>> )
>> IMAGEMAGICK_FILE_TYPES = ('eps', 'pdf', 'psd')
>>
>> which i guess can be overridden from the django settings file. Here there
>> is BASEDIR and SUBDIR and i guess those are the settings to be used but not
>> sure. When i tried to override the default i could see no change. So anyone
>> having experience in setting the same please let me know.
>>
>> Thanks and Regards,
>>
>> Swaroop Shankar V
>>
>>
>>
>>
>> On Mon, Apr 30, 2012 at 7:27 PM, Tiago Almeida > > wrote:
>>
>>> Have you tried changing the THUMBNAIL_STORAGE setting? I haven't done
>>> what you ask for but you should give it a try.
>>>
>>> http://thumbnail.sorl.net/reference/settings.html#thumbnail-storage
>>>
>>>
>>> Domingo, 29 de Abril de 2012 17:27:56 UTC+1, Swaroop Shankar escreveu:
>>>
 Thanks Kelly, could you tell me what all settings you had provided for
 it to cache into a separate directory?

 Thanks and Regards,
 Swaroop Shankar V



 On Sun, Apr 29, 2012 at 8:09 PM, Kelly Nicholes >>> > wrote:

> It always just caches the files for me in a completely different
> directory.
>
> On Saturday, April 28, 2012 1:06:12 PM UTC-6, Swaroop Shankar wrote:
>>
>> Hello All,
>> I am using sorl-thumbnail extensively in my project. It works
>> perfectly fine except for one issue which is regarding the storage. The
>> default behaviour of sorl-thumbnail is to create the images in the same
>> folder where the original image is stored. Is it possible to provide
>> a separate location for storage of generated file rather than the source
>> folder? I could find a setting called THUMBNAIL_STORAGE, is it the one to
>> be used? I am not able to figure it out from the documentation. If yes 
>> then
>> should i provide the absolute or relative path?
>>
>> Thanks and Regards,
>>
>> Swaroop Shankar V
>>
>>   --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To view this discussion on the web visit https://groups.google.com/d/*
> *msg/django-users/-/Tfl7B7Xir_**gJ
> .
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscribe@**googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en
> .
>

  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msg/django-users/-/bh_2yiDPjF0J.
>>>
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, 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: Storing Sorl-thumbnail created images in separate folder

2012-04-30 Thread Swaroop Shankar V
It looks like i was using an old version which came with satchmo. Am
currently testing my project with new version.

Thanks and Regards,
Swaroop Shankar V



On Tue, May 1, 2012 at 12:59 AM, Swaroop Shankar V wrote:

> It looks like the latest version of solr-thumnails or the version that i
> have currently installed supports THUMBNAIL_STORAGE. When i checked i
> could see a file under the path solr/thumbnail called defaults.py. In this
> file there are following options
>
> DEBUG = False
> BASEDIR = ''
> SUBDIR = ''
> PREFIX = ''
> QUALITY = 85
> CONVERT = '/usr/bin/convert'
> WVPS = '/usr/bin/wvPS'
> EXTENSION = 'jpg'
> PROCESSORS = (
> 'sorl.thumbnail.processors.colorspace',
> 'sorl.thumbnail.processors.autocrop',
> 'sorl.thumbnail.processors.scale_and_crop',
> 'sorl.thumbnail.processors.filters',
> )
> IMAGEMAGICK_FILE_TYPES = ('eps', 'pdf', 'psd')
>
> which i guess can be overridden from the django settings file. Here there
> is BASEDIR and SUBDIR and i guess those are the settings to be used but not
> sure. When i tried to override the default i could see no change. So anyone
> having experience in setting the same please let me know.
>
> Thanks and Regards,
>
> Swaroop Shankar V
>
>
>
>
> On Mon, Apr 30, 2012 at 7:27 PM, Tiago Almeida 
> wrote:
>
>> Have you tried changing the THUMBNAIL_STORAGE setting? I haven't done
>> what you ask for but you should give it a try.
>>
>> http://thumbnail.sorl.net/reference/settings.html#thumbnail-storage
>>
>>
>> Domingo, 29 de Abril de 2012 17:27:56 UTC+1, Swaroop Shankar escreveu:
>>
>>> Thanks Kelly, could you tell me what all settings you had provided for
>>> it to cache into a separate directory?
>>>
>>> Thanks and Regards,
>>> Swaroop Shankar V
>>>
>>>
>>>
>>> On Sun, Apr 29, 2012 at 8:09 PM, Kelly Nicholes 
>>> wrote:
>>>
 It always just caches the files for me in a completely different
 directory.

 On Saturday, April 28, 2012 1:06:12 PM UTC-6, Swaroop Shankar wrote:
>
> Hello All,
> I am using sorl-thumbnail extensively in my project. It works
> perfectly fine except for one issue which is regarding the storage. The
> default behaviour of sorl-thumbnail is to create the images in the same
> folder where the original image is stored. Is it possible to provide
> a separate location for storage of generated file rather than the source
> folder? I could find a setting called THUMBNAIL_STORAGE, is it the one to
> be used? I am not able to figure it out from the documentation. If yes 
> then
> should i provide the absolute or relative path?
>
> Thanks and Regards,
>
> Swaroop Shankar V
>
>   --
 You received this message because you are subscribed to the Google
 Groups "Django users" group.
 To view this discussion on the web visit https://groups.google.com/d/**
 msg/django-users/-/Tfl7B7Xir_**gJ
 .
 To post to this group, send email to django-users@googlegroups.com.
 To unsubscribe from this group, send email to django-users+unsubscribe@
 **googlegroups.com .
 For more options, visit this group at http://groups.google.com/**
 group/django-users?hl=en
 .

>>>
>>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/django-users/-/bh_2yiDPjF0J.
>>
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, 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: html5 + Django

2012-04-30 Thread yati sagade
I suggest Nginx to serve your static files, and possibly also as a reverse
proxy to point to your Django with Gunicorn/Apache setup (If you haven't
considered Gunicorn as a production server yet, please do. It is fantastic).

On Mon, Apr 30, 2012 at 11:21 PM, HarpB  wrote:

> It is much better to use Apache for static files than Django. You can
> still run DJango for data validation, but all static content is typically
> served via Apache. In your  virtualhost, you should proxy the /static/
> endpoint to the /static/ folder in Django app.
>
>
> On Sunday, April 29, 2012 5:39:15 AM UTC-7, collectiveSQL wrote:
>>
>> Hi Everyone,
>>
>> I'm working on a heavily animated web site using the html5 canvas tag.
>> Its mainly made of html, javascript and css static files and I'd like
>> to integrate the Google Identity Toolkit for an Oauth 2.0 account
>> chooser for signup and registration.
>>
>> The first question is Django a good candidate for serving up mainly
>> static files and using a small Django app for authentication?
>>
>> And secondly what performance impact would this have over straight
>> apache?
>>
>> More info:
>>
>> 1. Static web files such as html, javascript and css are stored on
>> Amazon AWS S3
>> 2. Data is loaded via oData using jsdata for animations
>> 3. Amazon AWS EC2 is used to scale apache web servers
>>
>> Thanks in advance.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/p30N-x76AEgJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Yati Sagade 

Twitter: @yati_itay 

Organizing member of TEDx EasternMetropolitanBypass
http://www.ted.com/tedx/events/4933
https://www.facebook.com/pages/TEDx-EasternMetropolitanBypass/337763226244869

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Storing Sorl-thumbnail created images in separate folder

2012-04-30 Thread Swaroop Shankar V
It looks like the latest version of solr-thumnails or the version that i
have currently installed supports THUMBNAIL_STORAGE. When i checked i could
see a file under the path solr/thumbnail called defaults.py. In this file
there are following options

DEBUG = False
BASEDIR = ''
SUBDIR = ''
PREFIX = ''
QUALITY = 85
CONVERT = '/usr/bin/convert'
WVPS = '/usr/bin/wvPS'
EXTENSION = 'jpg'
PROCESSORS = (
'sorl.thumbnail.processors.colorspace',
'sorl.thumbnail.processors.autocrop',
'sorl.thumbnail.processors.scale_and_crop',
'sorl.thumbnail.processors.filters',
)
IMAGEMAGICK_FILE_TYPES = ('eps', 'pdf', 'psd')

which i guess can be overridden from the django settings file. Here there
is BASEDIR and SUBDIR and i guess those are the settings to be used but not
sure. When i tried to override the default i could see no change. So anyone
having experience in setting the same please let me know.

Thanks and Regards,

Swaroop Shankar V



On Mon, Apr 30, 2012 at 7:27 PM, Tiago Almeida wrote:

> Have you tried changing the THUMBNAIL_STORAGE setting? I haven't done what
> you ask for but you should give it a try.
>
> http://thumbnail.sorl.net/reference/settings.html#thumbnail-storage
>
>
> Domingo, 29 de Abril de 2012 17:27:56 UTC+1, Swaroop Shankar escreveu:
>
>> Thanks Kelly, could you tell me what all settings you had provided for it
>> to cache into a separate directory?
>>
>> Thanks and Regards,
>> Swaroop Shankar V
>>
>>
>>
>> On Sun, Apr 29, 2012 at 8:09 PM, Kelly Nicholes 
>> wrote:
>>
>>> It always just caches the files for me in a completely different
>>> directory.
>>>
>>> On Saturday, April 28, 2012 1:06:12 PM UTC-6, Swaroop Shankar wrote:

 Hello All,
 I am using sorl-thumbnail extensively in my project. It works perfectly
 fine except for one issue which is regarding the storage. The default
 behaviour of sorl-thumbnail is to create the images in the same folder
 where the original image is stored. Is it possible to provide
 a separate location for storage of generated file rather than the source
 folder? I could find a setting called THUMBNAIL_STORAGE, is it the one to
 be used? I am not able to figure it out from the documentation. If yes then
 should i provide the absolute or relative path?

 Thanks and Regards,

 Swaroop Shankar V

   --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To view this discussion on the web visit https://groups.google.com/d/**
>>> msg/django-users/-/Tfl7B7Xir_**gJ
>>> .
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to django-users+unsubscribe@*
>>> *googlegroups.com .
>>> For more options, visit this group at http://groups.google.com/**
>>> group/django-users?hl=en
>>> .
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/bh_2yiDPjF0J.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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 a clean in inline formset

2012-04-30 Thread Guevara
Hello!

The (if display.max_windows() >= display.windows) works fine to
prevent insert. Behaves as expected.
But is raised even when the row is REMOVED from the edit formset. =/

## Models

class Display(models.Model):
windows = models.IntegerField()

def max_windows(self):
total = self.window_set.all().count() #window is a
intermediary class to campaign
if total:
return total

## Clean method in CampaignInlineFormSet

def clean(self):
if any(self.errors):
# Don't bother validating the formset unless each form is
valid on its own
return
for i in range(0, self.total_form_count()):
form = self.forms[i]
cleaned_data = form.clean()
display = cleaned_data.get('display', None)
if display.max_windows() >= display.windows:
raise forms.ValidationError("The display have all
windows occupied.")

This "if" can not stop me remove a row in inline formset. How can I
fix this?
Regards.

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



executing raw sql

2012-04-30 Thread Larry Martell
I'm trying to execute some raw sql. I found some code that did this:

from django.db import connection
cursor = connection.cursor()
cursor.execute(sql)
data = cursor.fetchall()

But the cursor.execute(sql) is blowing up with:

'Cursor' object has no attribute '_last_executed'

What is the best or proper way for me to execute my raw sql?

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



cPanel Python/Django support

2012-04-30 Thread Scot Hacker
For the past couple of years, cPanel (the most widely deployed hosting control 
panel system) has been taking pulse on user demand for native Django support 
(similar to their Rails installer). Just saw this note from cPanel devs  and 
thought some folks here might be interested. This is a great opportunity to 
help shape the future of what could become one of the most widely available 
routes to Django deployment on commodity hosting.

./s

Begin forwarded message:
> 
> Dear shacker23,
> 
> cPanelDavidG has just replied to a thread you have subscribed to entitled - 
> After EA3 Django support [Case 33011] - in the Feature Requests for 
> cPanel/WHM forum of cPanel Forums.
> 
> This thread is located at:
> http://forums.cpanel.net/f145/django-support-case-33011-a-146541-new-post.html
> 
> Here is the message that has just been posted:
> ***
> For those who are not aware, we are soliciting feedback regarding a preferred 
> Python implementation via a new mailing list devoted specifically for this 
> subject.  If you want to participate, you can visit: cPanel 
> (http://go.cpanel.net/python)
> ***
> 


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: [help] Server Config: django + uwsgi + nginx

2012-04-30 Thread easypie
does your configuration allow for running multiple sites?

On Sunday, April 29, 2012 12:01:27 PM UTC-7, Karl Sutt wrote:
>
> Here is my uWSGI command and nginx.conf contents:
>
> uwsgi -- http://www.dpaste.org/aiJuq/
> nginx -- http://www.dpaste.org/bAG0o/
>
> I've used it for a Flask application, but I've just tested it and it works 
> for a Django project as well. Note that wsgi.py file in the uwsgi command 
> is the Python file that Django generates when you first create a project, 
> there is no need to change it.
>
> Good luck!
>
> Karl Sutt
>
>
> On Sun, Apr 29, 2012 at 6:49 PM, easypie  wrote:
>
>> I have this file that was created for me by one of the users in django's 
>> irc channel. I edited to have the right information inserted but I"m not 
>> sure what I'm doing wrong to not make it work. I've spent some time trying 
>> to understand each line by searching the web. There's still a thing or two 
>> that's missing from the puzzle. Maybe it's the server config that has a 
>> flaw or the way I went about it. I haven't done a fresh install of uwsgi 
>> and nginx yet. However, please take a look to see if there's an error or 
>> solution that could work. Thanks.
>>
>> Link to code: http://www.dpaste.org/wWVd3/
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/2rekHP0I6V0J.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, 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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/sMsRN5iG9NQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: html5 + Django

2012-04-30 Thread HarpB
It is much better to use Apache for static files than Django. You can still 
run DJango for data validation, but all static content is typically served 
via Apache. In your  virtualhost, you should proxy the /static/ endpoint to 
the /static/ folder in Django app.

On Sunday, April 29, 2012 5:39:15 AM UTC-7, collectiveSQL wrote:
>
> Hi Everyone, 
>
> I'm working on a heavily animated web site using the html5 canvas tag. 
> Its mainly made of html, javascript and css static files and I'd like 
> to integrate the Google Identity Toolkit for an Oauth 2.0 account 
> chooser for signup and registration. 
>
> The first question is Django a good candidate for serving up mainly 
> static files and using a small Django app for authentication? 
>
> And secondly what performance impact would this have over straight 
> apache? 
>
> More info: 
>
> 1. Static web files such as html, javascript and css are stored on 
> Amazon AWS S3 
> 2. Data is loaded via oData using jsdata for animations 
> 3. Amazon AWS EC2 is used to scale apache web servers 
>
> Thanks in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/p30N-x76AEgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Import from local ftp server

2012-04-30 Thread Joel Goldstick
On Mon, Apr 30, 2012 at 11:53 AM, orsomannaro  wrote:
> On 30/04/2012 17:44, Thomas Weholt wrote:
>>
>> Might not be exactly what you need, but want to mention it anyway:
>
>
> Thank you very much, but I nedd a ftp client, not a server.
>
> I must build with Django something like this:
>
> http://www.net2ftp.com/
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
There is a python library called subprocess :
http://docs.python.org/library/subprocess.html#using-the-subprocess-module
You can just enter your ftp command as arguments
subprocess.call(["ftp://username:password@hostname/path/to/files/*";])

I haven't tried it before, but give it a try

-- 
Joel Goldstick

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

2012-04-30 Thread orsomannaro

On 30/04/2012 17:44, Thomas Weholt wrote:

Might not be exactly what you need, but want to mention it anyway:


Thank you very much, but I nedd a ftp client, not a server.

I must build with Django something like this:

http://www.net2ftp.com/

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



Re: Import from local ftp server

2012-04-30 Thread Thomas Weholt
Might not be exactly what you need, but want to mention it anyway:

https://bitbucket.org/weholt/djftpd

Regards,
Thomas

On Mon, Apr 30, 2012 at 5:33 PM, orsomannaro  wrote:
> Hi all.
>
> In my LAN I have some files stored in a ftp server, to which I can access
> from my computer with:
>
> ftp://username:password@hostname/path/to/files/*
>
>
> How can I import this files in a Django web-app uploading them directly from
> the ftp server?
>
>
> Thank you.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



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

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



Import from local ftp server

2012-04-30 Thread orsomannaro

Hi all.

In my LAN I have some files stored in a ftp server, to which I can 
access from my computer with:


ftp://username:password@hostname/path/to/files/*


How can I import this files in a Django web-app uploading them directly 
from the ftp server?



Thank you.

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



Re: @login_required do nothing

2012-04-30 Thread marcelo nicolet

  
  
Hi 
My apologies: I was running my app from apache, so none of my
changes were reflected! 
I'm now running into the development server and trying again all the
login stuff! 
Thank you all!

On 04/29/2012 01:59 AM, yati sagade wrote:
Hi
  Have you set the LOGIN_URL setting in settings.py? That setting
  should be assigned a location(e.g., "/login/") to redirect to when
  your view is called without the user logged in. Also, you can do
  this if for some reason you don't want to have that setting.
  
      @login_required(login_url="/login/")
      def index(request):
   
  
  
  On Sun, Apr 29, 2012 at 10:15 AM,
Jonathan Baker 
wrote:
Apologies,
  as I shouldn't have assumed that the import had not taken
  place. Would you mind posting the views.py to pastebin or
  codepad?
  

  
  On Sat, Apr 28, 2012 at 2:24 PM,
marcelo nicolet 
wrote:
Thanks,
  but of course the views module does the import.
  I'm a python newbie. Just to test it, I commented the
  import line, and the page loads without trouble. I
  suppose that referencing a symbol not imported would
  raise an exception!
  

  
  On 04/28/2012 04:18 PM, Jonathan D. Baker wrote:
  
You have to be sure and import the module at the
top of your script: from
django.contrib.auth.decorators import
login_required. Otherwise, it's never in scope
and thus not available.

Sent from my iPhone

On Apr 28, 2012, at 1:00 PM, marcelo nicolet
 wrote:


  Hi
  Following the on-line docs ( https://docs.djangoproject.com/en/1.4/topics/auth/
  ) I decorated my "index" view with
  @login_required, but nothing happens. In other
  words, it'supossed I would be redirected to a
  login page, else an exception migth raise. But
  the whole thing keeps doing as always.
  What am I doing the wrong way?
  
  TIA
  
  -- 
  You received this message because you are
  subscribed to the Google Groups "Django users"
  group.
  To post to this group, send email to django-users@googlegroups.com.
  To unsubscribe from this group, 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.
  

  

  
  
  
  
  

  
  -- 
  Jonathan D. Baker
  Developer
  http://jonathandbaker.com
  

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

  

  
  
  
  
  -- 
  Yati Sagade 

Twitter: @yati_itay

Organizing member of TEDx EasternMetropolitanBypass
  http://www.ted.com/tedx/events/4933
  https://www.facebook.co

Re: Parse Custom html in custom template tags, django 1.4

2012-04-30 Thread 95felipe
Hi! But then the rendering wouldn't include the loaded templatetags.
And I guess it would be expensive to go through this process a couple times 
for each call of the renderer.

On Monday, 30 April 2012 09:24:54 UTC-3, Daniel Roseman wrote:
>
>
>
> On Monday, 30 April 2012 09:03:56 UTC+1, 95felipe wrote:
>>
>> Hi. I've been struggling with this problem the whole night and just 
>> couldn't find any solution. I've tried reverse engineering the 
>> template/base.py file, but things are getting ugly. :S
>>
>> How can I, inside a custom tag class (template.Node), make the parser 
>> render a snippet of html with tags in it? For example:
>>
>> @register.tag(name='addspam')
>> class AddSpam(template.Node):
>> def __init__(self, parser, token): ...
>> def render(self, context):
>> spam_html = "SPAM { any_tag_here } SPAM"
>> return spam_html
>>
>> Here, AddSpam, when 'called', returns 'SPAM { any_tag_here } SPAM', 
>> without rendering the any_tag_here.That's obviously the predictable, but 
>> how can I change the return value so that any_tag_here is rendered as if it 
>> was 'native'? Are there any methods using the context and the parser that I 
>> could use? Thanks!
>>
>
> You could simply instantiate and render a template.Template object with 
> the content of `spam_html` and the existing context:
>
> spam_tpl = template.Template(spam_html)
> return spam_tpl.render(context)
> --
> DR.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/VtTZD_lUFrQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: kind of template introspection question.

2012-04-30 Thread Marc Aymerich
On Mon, Apr 30, 2012 at 4:22 PM, Marc Aymerich  wrote:
> Dear all,
>
> Each model of my application has an associated template. This template
> should be rendered each time that their context changes. So this is an
> example to clarify this cryptic explanation:
>
> class ModelA(models.Model):
>   
>
> class ModelB(models.Model):
>   a = models.ForeignKey(ModelA)
>
> class ModelC(models.Model):
>   ...
>   def get_a(self):
>         return ModelA.objects.get(whatever_field=self.whatever_other_field)
>
>
> Each of these models has a "related template", and specifically:
> 1) ModelB related template contains this tag: {{ modelb_object.a.some_field }}
> 2) and ModelC template has: {{ modelc_object.get_a() }}
>
> This means that ModelC related template should be rendered when saves
> (changes) are performed on ModelA and ModelB (because ModelC context
> depends on them)
>

Sorry I mess things up on this paragraph, I wanted to say:

This means that when changes are performed on ModelA: ModelB and
ModelC related templates should be rendered since their context
depends on ModelA.


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



kind of template introspection question.

2012-04-30 Thread Marc Aymerich
Dear all,

Each model of my application has an associated template. This template
should be rendered each time that their context changes. So this is an
example to clarify this cryptic explanation:

class ModelA(models.Model):
   

class ModelB(models.Model):
   a = models.ForeignKey(ModelA)

class ModelC(models.Model):
   ...
   def get_a(self):
 return ModelA.objects.get(whatever_field=self.whatever_other_field)


Each of these models has a "related template", and specifically:
1) ModelB related template contains this tag: {{ modelb_object.a.some_field }}
2) and ModelC template has: {{ modelc_object.get_a() }}

This means that ModelC related template should be rendered when saves
(changes) are performed on ModelA and ModelB (because ModelC context
depends on them)

So for each template I can provide a list of "dependent models" but
I'll be very happy if this behaviour can be provided "automatically".
Unfortunatly I do not have any clue on how to do that.

Someone has an idea?

Thanks so much!!

-- 
Marc

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



Re: buildout development vs. deployment

2012-04-30 Thread Reinout van Rees

On 30-04-12 13:08, Reikje wrote:

Are you using a setup.py file with buildout? Currently I am not using
one. My buildout.cfg lists all the dependencies


Yes, I use a setup.py. For me, a setup.py is for listing hard 
dependencies of the code, especially for packages you include in your 
buildout. That way you can also reuse them and be sure that everything 
you need is included.


The core point is that setup.py's are "recursive" where buildouts are not.


Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Storing Sorl-thumbnail created images in separate folder

2012-04-30 Thread Tiago Almeida
Have you tried changing the THUMBNAIL_STORAGE setting? I haven't done what 
you ask for but you should give it a try.

http://thumbnail.sorl.net/reference/settings.html#thumbnail-storage 


Domingo, 29 de Abril de 2012 17:27:56 UTC+1, Swaroop Shankar escreveu:
>
> Thanks Kelly, could you tell me what all settings you had provided for it 
> to cache into a separate directory?
>
> Thanks and Regards,
> Swaroop Shankar V
>
>
>
> On Sun, Apr 29, 2012 at 8:09 PM, Kelly Nicholes wrote:
>
>> It always just caches the files for me in a completely different 
>> directory.
>>
>> On Saturday, April 28, 2012 1:06:12 PM UTC-6, Swaroop Shankar wrote:
>>>
>>> Hello All,
>>> I am using sorl-thumbnail extensively in my project. It works perfectly 
>>> fine except for one issue which is regarding the storage. The default 
>>> behaviour of sorl-thumbnail is to create the images in the same folder 
>>> where the original image is stored. Is it possible to provide 
>>> a separate location for storage of generated file rather than the source 
>>> folder? I could find a setting called THUMBNAIL_STORAGE, is it the one to 
>>> be used? I am not able to figure it out from the documentation. If yes then 
>>> should i provide the absolute or relative path?
>>>
>>> Thanks and Regards,
>>>
>>> Swaroop Shankar V
>>>
>>>   -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/Tfl7B7Xir_gJ.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, 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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/bh_2yiDPjF0J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 create form from odd model

2012-04-30 Thread Adam S
Hi,
I am working with an existing database where I am unable to change the
schema and having some trouble trying to deal with presenting forms.
The structure in question is as follows and all models are unmanaged.

class Persons(models.Model):
personid = models.BigIntegerField(primary_key=True,
db_column='PersonID')


class Phones(models.Model):
phoneid = models.BigIntegerField(primary_key=True,
db_column='PhoneID')
number = models.CharField(max_length=60, db_column='Number',
blank=True)
type = models.CharField(max_length=15, db_column='Type',
blank=True)
...

class Personsphones(models.Model):
personphoneid = models.BigIntegerField(primary_key=True,
db_column='PersonPhoneID')
personid = models.ForeignKey(Persons, db_column='PersonID')
phoneid = models.ForeignKey(Phones, db_column='PhoneID')
...

I want to create a form to display all of the 'Phones' associated with
a particular 'Persons' and in addition be able to modify/add/remove
'Phones' belonging to a 'Persons'. Right now the only thing I can
think of is to display the 'Phones' in a modelformset and then if one
is added or removed manually set the 'Personsphones' relation. Any
ideas on how to best deal with this model setup? If I manually need to
update the relationships should I just create a custom save() for my
'Phones' form?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Parse Custom html in custom template tags, django 1.4

2012-04-30 Thread Daniel Roseman


On Monday, 30 April 2012 09:03:56 UTC+1, 95felipe wrote:
>
> Hi. I've been struggling with this problem the whole night and just 
> couldn't find any solution. I've tried reverse engineering the 
> template/base.py file, but things are getting ugly. :S
>
> How can I, inside a custom tag class (template.Node), make the parser 
> render a snippet of html with tags in it? For example:
>
> @register.tag(name='addspam')
> class AddSpam(template.Node):
> def __init__(self, parser, token): ...
> def render(self, context):
> spam_html = "SPAM { any_tag_here } SPAM"
> return spam_html
>
> Here, AddSpam, when 'called', returns 'SPAM { any_tag_here } SPAM', 
> without rendering the any_tag_here.That's obviously the predictable, but 
> how can I change the return value so that any_tag_here is rendered as if it 
> was 'native'? Are there any methods using the context and the parser that I 
> could use? Thanks!
>

You could simply instantiate and render a template.Template object with the 
content of `spam_html` and the existing context:

spam_tpl = template.Template(spam_html)
return spam_tpl.render(context)
--
DR.

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



Parse Custom html in custom template tags, django 1.4

2012-04-30 Thread 95felipe


Hi. I've been struggling with this problem the whole night and just 
couldn't find any solution. I've tried reverse engineering the 
template/base.py file, but things are getting ugly. :S

How can I, inside a custom tag class (template.Node), make the parser 
render a snippet of html with tags in it? For example:

@register.tag(name='addspam')
class AddSpam(template.Node):
def __init__(self, parser, token): ...
def render(self, context):
spam_html = "SPAM { any_tag_here } SPAM"
return spam_html

Here, AddSpam, when 'called', returns 'SPAM { any_tag_here } SPAM', without 
rendering the any_tag_here.That's obviously the predictable, but how can I 
change the return value so that any_tag_here is rendered as if it was 
'native'? Are there any methods using the context and the parser that I 
could use? Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/7MfK_zBy_mgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: buildout development vs. deployment

2012-04-30 Thread Reikje
Excellent, thanks for sharing that blog post.

Are you using a setup.py file with buildout? Currently I am not using one. 
My buildout.cfg lists all the dependencies and I checkout my source code 
from a specific git revision. Afterwards I go into the source code folder 
and add local files (i.e. production ready Django settings file). 

Am I right that using setup.py and running bin/buildout.py setup would 
create an egg of my source folder and the egg is created in the 
develop-eggs folder? Using this approach I wouldn't be able to do local 
modifications correct, as everything is bundled within a egg file. (Let me 
add that I am new to Django/Python deployment :)

/Reik


On Wednesday, April 25, 2012 12:21:25 PM UTC+2, Reikje wrote:
>
> Hi, I am looking into buildout to deploy a django webapp and all it's 
> dependencies. I find it quite useful even during development because it 
> forces you to keep track of your dependencies. A question regarding some 
> best practices. Lets say I have buildout.cfg and setup.py in my project 
> root and checked in into SCM. My webapp is listed under develop in 
> buildout.cfg. While this is great, during deployment this is probably not 
> what you want because you wanna lock the version of your source code. I 
> want to do a git revision checkout to archive this. So i guess I need to 
> maintain two different buildout.cfg files, one for development and one for 
> deployment. How can this be organized to avoid DRY?
>
> On a side note, what are the alternatives to buildout. Maybe there is 
> something even better :)
>

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



Europython 2012 - Early Bird will end in 3 days!

2012-04-30 Thread Palla
Hi all,
the end of Early bird is on May 2nd, 23:59:59 CEST. We'd like to ask
to you to forward this post to anyone that you feel may be interested.

We have an amazing lineup of tutorials and talks. We have some
excellent keynote speakers and Guido will be with us!
[https://ep2012.europython.eu/p3/whos-coming?speaker=on#guido-van-
rossum]

If you plan to attend, you could save quite a bit on registration
fees ... but remember that early bird registration ends in 3 days!

Things to Remember:
- House your server: We will be running an Intranet at EuroPython, to
let sponsors, startups, open-source projects and speakers showcase
their products directly within our network.
- Training: You can book the trainings you want to attend, directly
from the schedule (click on the training, and then click on the "Book"
button).
- Sprints: Wonderful hacking sessions during the weekend, learn from
expert Python developers and contribute to the Python ecosystem!
- Probably we've already discussed about the fact that Guido Van
Rossum will be at Europython in Florence :)

---> Register Now! - https://ep2012.europython.eu/p3/cart/

Best,

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