Re: google app engine suggestion

2012-11-12 Thread Stefano Tranquillini
Jumping in the thread. 
is GAE supporting django? i knew that something is supported but 
not completely (like db is non rel in GAE). 
is there a tutorial on how to set it up? what did you follow?
my 2 cents on the server, right now i'm using AWS free tier, it's for 
12months  and it's good. after that i'll switch to something else, which i 
didn't found yet. so suggestions are welcome (need to manage a 3 pages 
website with few queries and 2 celery scheduled tasks)

ciao

On Saturday, November 10, 2012 5:59:51 PM UTC+1, Aswani Kumar wrote:
>
> wow thank you, can any one of you write a blog post about how to setup 
> this environment or share a post which you have written earlier.
>
>
> With Best
> -Ashwin.
> +91-9959166266
>
>
>
> On Sat, Nov 10, 2012 at 10:19 PM, Javier Guerra Giraldez <
> jav...@guerrag.com > wrote:
>
>> On Sat, Nov 10, 2012 at 3:51 AM, Kurtis Mullins
>> > wrote:
>> > I, personally, prefer Nginx and uWSGI but something else may be better 
>> for
>> > your particular use case.
>>
>> same here.  it's a little different from other solutions, but rock
>> solid, and includes its own process management, so it's really close
>> to 'setup and forget about it'.
>>
>> of course, if/when your traffic outgrows your initial setup you have
>> to tune up and/or add more resources, but it has a lot of grow space.
>> you won't find it constraining until you become bigger than twitter.
>>
>> --
>> Javier
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@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/-/JBNTv5wQstoJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Exception Type: TypeError Exception Value: individual() takes exactly 2 arguments (1 given)

2012-11-12 Thread muhammed riyas
thanks it works fine, but the if statement is not working,,, why?  it
always gives the first result?.

On Mon, Nov 12, 2012 at 1:28 PM, Jonathan D. Baker <
jonathandavidba...@gmail.com> wrote:

> You need to capture the id parameter in your URL by wrapping it in
> parentheses: ([0-9])
>
> Sent from my iPhone
>
> On Nov 12, 2012, at 12:49 AM, muhammed riyas 
> wrote:
>
> Request Method:GET
> Request URL:http://localhost:9744/employee/1/
> Exception Type:TypeError
> Exception Value:individual() takes exactly 2 arguments (1 given)
> Exception
> Location:/home/user/google_appengine/lib/django_0_96/django/core/handlers/base.py
> in get_response, line 77
>
>
>
> url is  (r'^employee/[0-9]+/$','qburstemployeeapp.main.views.individual'),
>
> in this the [0-9]+ denotes id number for the user ...
>
> in my view...
>
>
>
> def individual(request,id):
> employees = Employeeprofile.all()
> for employee in employees:
> if(employee.key().id() == id):
> return render_to_response('main/individual1.html', { 'employee' : employee
> })
>
> What is the mistake?...
>
>
> 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/-/PJcdrn57HooJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Exception Type: TypeError Exception Value: individual() takes exactly 2 arguments (1 given)

2012-11-12 Thread Daniel Roseman
On Monday, 12 November 2012 08:37:44 UTC, muhammed riyas wrote:

> thanks it works fine, but the if statement is not working,,, why?  it 
> always gives the first result?.
>


This is a question about AppEngine, not Django. Please post it to the 
appropriate list.

(Hint: you absolutely certainly do *not* want to be iterating over every 
entity in the datastore until you find a match.)
--
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/-/JlGYEtib8PQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Exception Type: TypeError Exception Value: individual() takes exactly 2 arguments (1 given)

2012-11-12 Thread muhammed riyas
sorry:)


On Monday, 12 November 2012 15:09:09 UTC+5:30, Daniel Roseman wrote:
>
> On Monday, 12 November 2012 08:37:44 UTC, muhammed riyas wrote:
>
>> thanks it works fine, but the if statement is not working,,, why?  it 
>> always gives the first result?.
>>
>
>
> This is a question about AppEngine, not Django. Please post it to the 
> appropriate list.
>
> (Hint: you absolutely certainly do *not* want to be iterating over every 
> entity in the datastore until you find a match.)
> --
> 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/-/-8D8USc8heMJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Exporting tuple/dictionary within django html template

2012-11-12 Thread Daniel Roseman
On Sunday, 11 November 2012 23:51:44 UTC, HA wrote:

> Hi Folks,
>
> I want to export data from my named tuple within my django html template.
> Can someone please point me to an example or let me know how to accomplish 
> this?
> I know how to get this done within my python script but this time I want 
> to get this done inside of my html template page. Basically I want to have 
> a button which says "Export to CSV" on html page and clicking on it exports 
> data (from a named tuple) to a csv
>
> Thanks,
> Hemanshu
>

This question makes no sense. Exporting data isn't something you do in a 
template, you do it in a view. Your template should just have a link to the 
view that does this.
And what could it mean to have data in a "named tuple"? Assuming you mean 
collections.namedtuple, that's just a tuple with named fields, and is 
really only suitable for a small amount of data. How can you have enough 
data in a namedtuple to make it worth exporting to a CSV?
--
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/-/1_GqDAllMCAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 many developers have moved to class-based views?

2012-11-12 Thread Tom Christie
If you're working with the generic CBVs, I would strongly recommend taking 
a look at the documentation provided by the Classy CBV project - 
http://ccbv.co.uk/.  Because of the way it's auto-generated it allows you 
to see at a glance exactly what set of methods and attributes are 
implemented by an given class or mixin, and makes it frictionless to skip 
between the documentation and the source implementation.  It makes it much 
easier to get an idea of how everything fits together.

  - Tom

On Monday, 12 November 2012 04:16:51 UTC, Kurtis wrote:
>
> I use them!
>
>
> On Sun, Nov 11, 2012 at 2:05 PM, Kevin >wrote:
>
>> Wow, the dev docs are much more informative and actually explains the 
>> best way to alter a form before saving it.  I was using a different method, 
>> but the method mentioned in the dev docs are much more cleaner than what I 
>> was doing.  Many thanks for this.
>>
>>
>> On Sunday, 11 November 2012 12:54:45 UTC-6, Lee Hinde wrote:
>>
>>> The dev docs are much more informative.
>>>
>>>
>>> On Sun, Nov 11, 2012 at 10:45 AM, Arnold Krille wrote:
>>>

 Docs on CBV in django1.4 are a bit sparse to say the least.

>>>  
>>>

 Have fun,

 Arnold

>>>
>>>  -- 
>> 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/-/jZ8_sGjQpkoJ.
>>
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@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/-/AEQsS3r-ZuoJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Exporting tuple/dictionary within django html template

2012-11-12 Thread Lachlan Musicman
On Monday, November 12, 2012, Daniel Roseman wrote:

> On Sunday, 11 November 2012 23:51:44 UTC, HA wrote:
>
>> Hi Folks,
>>
>> I want to export data from my named tuple within my django html template.
>> Can someone please point me to an example or let me know how to
>> accomplish this?
>> I know how to get this done within my python script but this time I want
>> to get this done inside of my html template page. Basically I want to have
>> a button which says "Export to CSV" on html page and clicking on it exports
>> data (from a named tuple) to a csv
>>
>
While I might agree with DR below, it should be pointed out, and is more
friendly to note, that the front page of the documentation has a link that
is called "Generating CSV", points to
/path/django-docs/howto/outputting-csv.html
and
shows two techniques for outputting html, one using a view function (as per
below) and one using the template, as requested. Note that the template
solution is provided "for completeness" which I take to mean "the
developers cannot think of any use case, but admit that it is possible and
therefore give an example".

Also, a quick search will turn up a number of Django snippets that show how
to output a queryset; and I believe there's an "export anything to
anything" app as well.

cheers
L.


> This question makes no sense. Exporting data isn't something you do in a
> template, you do it in a view. Your template should just have a link to the
> view that does this.
> And what could it mean to have data in a "named tuple"? Assuming you mean
> collections.namedtuple, that's just a tuple with named fields, and is
> really only suitable for a small amount of data. How can you have enough
> data in a namedtuple to make it worth exporting to a CSV?
>


-- 
...we look at the present day through a rear-view mirror. This is something
Marshall McLuhan said back in the Sixties, when the world was in the grip
of authentic-seeming future narratives. He said, “We look at the present
through a rear-view mirror. We march backwards into the future.”

http://www.warrenellis.com/?p=14314

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 many developers have moved to class-based views?

2012-11-12 Thread Lachlan Musicman
On Monday, November 12, 2012, Tom Christie wrote:

> If you're working with the generic CBVs, I would strongly recommend taking
> a look at the documentation provided by the Classy CBV project -
> http://ccbv.co.uk/.  Because of the way it's auto-generated it allows you
> to see at a glance exactly what set of methods and attributes are
> implemented by an given class or mixin, and makes it frictionless to skip
> between the documentation and the source implementation.  It makes it much
> easier to get an idea of how everything fits together.


Ooooh. That's nice. Really nice.

Big high five to CCBV!


-- 
...we look at the present day through a rear-view mirror. This is something
Marshall McLuhan said back in the Sixties, when the world was in the grip
of authentic-seeming future narratives. He said, “We look at the present
through a rear-view mirror. We march backwards into the future.”

http://www.warrenellis.com/?p=14314

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



contrib group memberships

2012-11-12 Thread Mark Vijftigschild
Hia Folks,

I recently made a web app with Django where I present a list of Jobs a user 
can execute. I make a list of Jobs based on user and group memberships. I 
use contrib.auth for the memberships. 
I make the list with this:
-- snip --
class JobManager(models.Manager):
def jobsByUser(self, username):
lookup = models.Q(user__username__icontains=username) | \
models.Q(group__user__username__icontains=username)
return Job.objects.filter(lookup).distinct('name')
-- snip --
This works like a charm. 

I added a search box and I am able to search on any of the properties of a 
Job. Since I recently added the group memberships part I used to search 
only in the Jobs a user had permissions to. I now want to expand the search 
to include the group memberships. 

This is the part I use to create the list:

--snip--
@login_required
def joblist(request):
""" haalt de jobs voor de user uit de database en laat ze zien"""

query = request.GET.get('q','')
if query:

# filter op: Job.name, Job.description, Job.host, Job.type, Job.user
qset = (
Q(name__icontains=query) |
Q(description__icontains=query) |
Q(host__icontains=query) |
Q(type__name__icontains=query))
joblist = 
Job.objects.filter(qset,user__username__icontains=request.user.username) 
#joblist = 
Job.objects.filter(qset,user__username__icontains=request.user.username, 
group__user__username__icontains=request.user.username)
else:
joblist = Job.objects.jobsByUser(request.user.username)

jobtable = JobTable( joblist,)

return render_to_response('joblist.html', 
{'username':request.user.username, 'table':jobtable} )

--snip--
The commented line is my last attempt to include the group memberships, but 
this doesn't work. 
I think I'm missing a very simple solution here. In the Django Admin part I 
can select users and groups that have access to a Job. I want to be able to 
search not just in the Jobs that a user has access to, but also with group 
memberships.

I would greatly appreciate any help any of you can offer.

Regards,
Mark

P.S. If turns out to be a double post, I'm sorry

-- 
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/-/Chxou0nSBN8J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Filtering on group membership (contrib.auth)

2012-11-12 Thread Mark Vijftigschild
Hia Folks,

I've cooked up a 'simple' webapp where based on user and group memberships, 
a user gets a list of Jobs he can execute. Listing jobs by group membership 
is not a problem. 
I select the Jobs a user sees like this:

class JobManager(models.Manager):
def jobsByUser(self, username):
lookup = models.Q(user__username__icontains=username) | \
models.Q(group__user__username__icontains=username)
return Job.objects.filter(lookup).distinct('name')


My problem is that I haven't found a way to also search (searchbox on a web 
form) for Jobs based on group membership.
The following snippet allows me to make a list based on the query a user 
does and on the Jobs his user is allowed to see. Now I want to add the Jobs 
that the user's group is allowed to see. The commented line was my last 
attempt. This gives a SyntaxError, but I'm not sure why.

@login_required
def joblist(request):
""" retrieves jobs from dbase and show"""

query = request.GET.get('q','')
if query:

# filter on: Job.name, Job.description, Job.host, Job.type, Job.user
qset = (
Q(name__icontains=query) |
Q(description__icontains=query) |
Q(host__icontains=query) |
Q(type__name__icontains=query))
joblist = 
Job.objects.filter(qset,user__username__icontains=request.user.username)
#joblist = 
Job.objects.filter(qset,user__username__icontains=request.user.username, 
group__user__username__icontains=request.user.username)
else:
joblist = Job.objects.jobsByUser(request.user.username)

jobtable = JobTable( joblist,)

return render_to_response('joblist.html', 
{'username':request.user.username, 'table':jobtable} )


The group and user stuff is contrib.auth without modifications. I think i'm 
missing something very simple so if anyone can help me here I would greatly 
appreciate it.

Regards,
Mark

-- 
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/-/Vyn819j_QIwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Design patterns with users / groups

2012-11-12 Thread Guy Bowden
Bit of a design question:

I have a site where there are a few different views depending on each 
user's status - i will explain:

   1. A user can create an object, so should be able to view it and update 
   it.
   2. A user can 'follow' another users object, so should be able to view 
   it and it's children
   3. A user could be granted permission to administer another users 
   object, so should have the same permissions as the original owner.
   
So, the question is...

When an object is created, should I also create two additional user groups 
and assign the permissions to those groups? Then all I'd have to do is add 
a follower to the followers group.

"followers_[modelname]_[pk]", "administrators_[modelname]_[pk]"

Or, do I assign administer / follow / view / update permissions per user?

This has just really occurred to me as an option because I've only really 
seen Groups as a much larger way to organise users - i.e. "members", 
"administrators" etc. But this seems like a good way to go in this instance 
rather than assigning permissions to individual users.

Pros / Cons? Is this a normal way to handle permissions?

I can see that there would obviously be a lot more groups created, but 
permissions would only be assigned to groups, not users, so easier to 
manage..?

Cheers
Guy

-- 
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/-/rceCVy_eH14J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



sqlsync help

2012-11-12 Thread hardik juneja
i am trying to sync mysql to django using command python mange.py syncdb 
and it is giving me long list of errors 
first error pointing out error in manage.py
other in __init__.py,  base.py,validation.py
what to do???


-- 
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/-/f7hyzsQeXGcJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Encoding error

2012-11-12 Thread Ariz-maN@
Hi,
i'm coding a system using Django Pyodbc and SQL Server 2005.
But i've a problem of encoding when i try to save some complex string like 
"éei«éíπ≤Æ∫" in sql server through pyodbc.
The error was always "'not enough arguments for format string'"

i've identified the line in the file base.py in pyodbc folder : 

if isinstance(p, unicode):
> if self.driver_needs_utf8:
> # FreeTDS (and other ODBC drivers?) doesn't support 
> Unicode
> # yet, so we need to encode parameters in utf-8
> fp.append(p.encode('utf-8'))
> else:
> fp.append(p)
> elif isinstance(p, str):
> if self.driver_needs_utf8:
> # TODO: use system encoding when calling decode()?
> *fp.append(p.decode('utf-8').encode('utf-8'))*
> else:
> fp.append(p)
> elif isinstance(p, type(True)):
> if p:
> fp.append(1)
> else:
> fp.append(0)
> else:
> fp.append(p)
>

Can anyone help me ?

-- 
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/-/XyjqLX9YR28J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Exception Type: TypeError Exception Value: individual() takes exactly 2 arguments (1 given)

2012-11-12 Thread Dominik Przybysz

You have to convert id to int

W dniu 12.11.2012 09:37, muhammed riyas pisze:
thanks it works fine, but the if statement is not working,,, why?  it 
always gives the first result?.


On Mon, Nov 12, 2012 at 1:28 PM, Jonathan D. Baker 
mailto:jonathandavidba...@gmail.com>> 
wrote:


You need to capture the id parameter in your URL by wrapping it in
parentheses: ([0-9])

Sent from my iPhone

On Nov 12, 2012, at 12:49 AM, muhammed riyas
mailto:muhammedriyas.2...@gmail.com>> wrote:


Request Method:GET
Request URL:http://localhost:9744/employee/1/
Exception Type:TypeError
Exception Value:individual() takes exactly 2 arguments (1 given)
Exception

Location:/home/user/google_appengine/lib/django_0_96/django/core/handlers/base.py
in get_response, line 77



url
is  (r'^employee/[0-9]+/$','qburstemployeeapp.main.views.individual'),

in this the [0-9]+ denotes id number for the user ...

in my view...



def individual(request,id):
employees = Employeeprofile.all()
for employee in employees:
if(employee.key().id() == id):
return render_to_response('main/individual1.html', { 'employee' :
employee })

What is the mistake?...


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/-/PJcdrn57HooJ.
To post to this group, send email to
django-users@googlegroups.com .
To unsubscribe from this group, 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.


--
Pozdrawiam,
Dominik Przybysz

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

2012-11-12 Thread Babatunde Akinyanmi
It'll be nice if u gave specifics.

On 11/12/12, hardik juneja  wrote:
> i am trying to sync mysql to django using command python mange.py syncdb
> and it is giving me long list of errors
> first error pointing out error in manage.py
> other in __init__.py,  base.py,validation.py
> what to do???
>
>
> --
> 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/-/f7hyzsQeXGcJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
Sent from my mobile device

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



Forbidden (403)

2012-11-12 Thread Nebros
I know this is an old problem with many answers... but no one helps me. ^^
what i have:
 
Settings
MIDDLEWARE_CLASSES = (
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
---
 
urls--
from django.conf.urls import patterns
from klasse.views import portal, kundendaten
urlpatterns = patterns('',
(r'^portal/$', portal),
(r'^kundendaten/$', kundendaten),
)
---
 
views---
from django.shortcuts import render_to_response
from django.core.context_processors import csrf
from django.views.decorators.csrf import csrf_protect
import datetime
import pyodbc
@csrf_protect
def portal(request):
now = datetime.datetime.now()
return render_to_response('portal.html', {'current_date': now})

 
portal.html--

{% csrf_token %}

Anfrage
Bitte Kundennamen eingeben









 
I tryed a lot of variants to fix my "post" problem, but without success. 
can anybody help me? ^^
thx
*pls ignore my englisch fails

-- 
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/-/iMXtpFVaRp8J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



A problem about get_absolute_url()

2012-11-12 Thread ozgur yilmaz
Hi all,

I have 4 classes and i want to build a get_absolute_url() for a class,
querying other 3 classes. But i get "list index out of range" error
for the FILTER row. Any ideas?

class Aaa( models.Model ):
   ...
   ...

class City( models.Model ):
   ...
   ...

class Bbb( models.Model ):
   aaa = models.ForeignKey( Aaa )
   city = models.ForeignKey( City )
   ...
   ...

class Ccc( models.Model ):
   aaa = models.ForeignKey( Aaa )
   ...
   ...

   def get_absolute_url(self):  

  bbbs = Bbb.objects.filter( aaa = self.aaa )

  city = City.objects.get( id = bbbs[0].city.id )

  return "/" + city.name + "/"  + str(self.id)

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

2012-11-12 Thread Vibhu Rishi
When is it that you are getting the 403 ?


On Mon, Nov 12, 2012 at 7:30 PM, Nebros  wrote:

> I know this is an old problem with many answers... but no one helps me. ^^
> what i have:
>
> Settings
> MIDDLEWARE_CLASSES = (
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> # Uncomment the next line for simple clickjacking protection:
> # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
> )
> ---
>
> urls--
> from django.conf.urls import patterns
> from klasse.views import portal, kundendaten
> urlpatterns = patterns('',
> (r'^portal/$', portal),
> (r'^kundendaten/$', kundendaten),
> )
> ---
>
> views---
> from django.shortcuts import render_to_response
> from django.core.context_processors import csrf
> from django.views.decorators.csrf import csrf_protect
> import datetime
> import pyodbc
> @csrf_protect
> def portal(request):
> now = datetime.datetime.now()
> return render_to_response('portal.html', {'current_date': now})
> 
>
> portal.html--
> 
> {% csrf_token %}
> 
> Anfrage
> Bitte Kundennamen eingeben
> 
> 
> 
> 
> 
>  href="kundendaten">
> 
> 
> 
>
> I tryed a lot of variants to fix my "post" problem, but without success.
> can anybody help me? ^^
> thx
> *pls ignore my englisch fails
>
> --
> 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/-/iMXtpFVaRp8J.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Simplicity is the ultimate sophistication. - Leonardo da Vinci
Life is really simple, but we insist on making it complicated. - Confucius

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

2012-11-12 Thread Nebros
When i put in a variable in my type="text" and push type="submit" (by the 
step to next page)...
 

Am Montag, 12. November 2012 16:52:20 UTC+1 schrieb Vibhu Rishi:

> When is it that you are getting the 403 ? 
>
>
> On Mon, Nov 12, 2012 at 7:30 PM, Nebros 
> > wrote:
>
>> I know this is an old problem with many answers... but no one helps me. ^^
>> what i have:
>>  
>> Settings
>> MIDDLEWARE_CLASSES = (
>> 'django.middleware.csrf.CsrfViewMiddleware',
>> 'django.middleware.common.CommonMiddleware',
>> 'django.contrib.sessions.middleware.SessionMiddleware',
>> 'django.contrib.auth.middleware.AuthenticationMiddleware',
>> 'django.contrib.messages.middleware.MessageMiddleware',
>> # Uncomment the next line for simple clickjacking protection:
>> # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
>> )
>> ---
>>  
>> urls--
>> from django.conf.urls import patterns
>> from klasse.views import portal, kundendaten
>> urlpatterns = patterns('',
>> (r'^portal/$', portal),
>> (r'^kundendaten/$', kundendaten),
>> )
>> ---
>>  
>> views---
>> from django.shortcuts import render_to_response
>> from django.core.context_processors import csrf
>> from django.views.decorators.csrf import csrf_protect
>> import datetime
>> import pyodbc
>> @csrf_protect
>> def portal(request):
>> now = datetime.datetime.now()
>> return render_to_response('portal.html', {'current_date': now})
>> 
>>  
>> portal.html--
>> 
>> {% csrf_token %}
>> 
>> Anfrage
>> Bitte Kundennamen eingeben
>> 
>> 
>> 
>> 
>> 
>> > href="kundendaten">
>> 
>> 
>> 
>>  
>> I tryed a lot of variants to fix my "post" problem, but without success. 
>> can anybody help me? ^^
>> thx
>> *pls ignore my englisch fails
>>  
>> -- 
>> 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/-/iMXtpFVaRp8J.
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com .
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> -- 
> Simplicity is the ultimate sophistication. - Leonardo da Vinci
> Life is really simple, but we insist on making it complicated. - Confucius
>  

-- 
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/-/XtkJC5PnvpQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 many developers have moved to class-based views?

2012-11-12 Thread John DeRosa
On Nov 11, 2012, at 9:57 AM, Kevin  wrote:

> Hello!
> 
>   I am curious of how many existing Django developers have moved over to 
> class-based views or are still using the function-based ones.  I tend to use 
> a mix depending on what I am trying to do.  I try to stick with 

I use only function-based views. I've yet to read a compelling argument for 
switching.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 many developers have moved to class-based views?

2012-11-12 Thread Kurtis Mullins
John,

My argument (or reason for switching) is it's DRY. Saves a lot of time and
repetition in the long run ... at least in my experience. On the other
hand, there are still perfectly good purposes for "function based views".


On Mon, Nov 12, 2012 at 11:07 AM, John DeRosa  wrote:

> On Nov 11, 2012, at 9:57 AM, Kevin  wrote:
>
> > Hello!
> >
> >   I am curious of how many existing Django developers have moved over to
> class-based views or are still using the function-based ones.  I tend to
> use a mix depending on what I am trying to do.  I try to stick with
>
> I use only function-based views. I've yet to read a compelling argument
> for switching.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: Forbidden (403)

2012-11-12 Thread Tom Christie
Could you include your 'kundendaten' view too, please.
Any error text on the 403 page would also be useful.

On Monday, 12 November 2012 15:54:50 UTC, Nebros wrote:
>
> When i put in a variable in my type="text" and push type="submit" (by the 
> step to next page)...
>  
>
> Am Montag, 12. November 2012 16:52:20 UTC+1 schrieb Vibhu Rishi:
>
>> When is it that you are getting the 403 ? 
>>
>>
>> On Mon, Nov 12, 2012 at 7:30 PM, Nebros  wrote:
>>
>>> I know this is an old problem with many answers... but no one helps me. 
>>> ^^
>>> what i have:
>>>  
>>> Settings
>>> MIDDLEWARE_CLASSES = (
>>> 'django.middleware.csrf.CsrfViewMiddleware',
>>> 'django.middleware.common.CommonMiddleware',
>>> 'django.contrib.sessions.middleware.SessionMiddleware',
>>> 'django.contrib.auth.middleware.AuthenticationMiddleware',
>>> 'django.contrib.messages.middleware.MessageMiddleware',
>>> # Uncomment the next line for simple clickjacking protection:
>>> # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
>>> )
>>> ---
>>>  
>>> urls--
>>> from django.conf.urls import patterns
>>> from klasse.views import portal, kundendaten
>>> urlpatterns = patterns('',
>>> (r'^portal/$', portal),
>>> (r'^kundendaten/$', kundendaten),
>>> )
>>> ---
>>>  
>>> views---
>>> from django.shortcuts import render_to_response
>>> from django.core.context_processors import csrf
>>> from django.views.decorators.csrf import csrf_protect
>>> import datetime
>>> import pyodbc
>>> @csrf_protect
>>> def portal(request):
>>> now = datetime.datetime.now()
>>> return render_to_response('portal.html', {'current_date': now})
>>> 
>>>  
>>> portal.html--
>>> 
>>> {% csrf_token %}
>>> 
>>> Anfrage
>>> Bitte Kundennamen eingeben
>>> 
>>> >> required="required">
>>> 
>>> 
>>> 
>>> >> href="kundendaten">
>>> 
>>> 
>>> 
>>>  
>>> I tryed a lot of variants to fix my "post" problem, but without success. 
>>> can anybody help me? ^^
>>> thx
>>> *pls ignore my englisch fails
>>>  
>>> -- 
>>> 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/-/iMXtpFVaRp8J.
>>> To post to this group, send email to django...@googlegroups.com.
>>> To unsubscribe from this group, send email to 
>>> django-users...@googlegroups.com.
>>> For more options, visit this group at 
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>
>>
>>
>> -- 
>> Simplicity is the ultimate sophistication. - Leonardo da Vinci
>> Life is really simple, but we insist on making it complicated. - Confucius
>>  
>

-- 
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/-/GTvp3a-tJ58J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: A problem about get_absolute_url()

2012-11-12 Thread Bill Freeman
On Mon, Nov 12, 2012 at 10:06 AM, ozgur yilmaz  wrote:

> Hi all,
>
> I have 4 classes and i want to build a get_absolute_url() for a class,
> querying other 3 classes. But i get "list index out of range" error
> for the FILTER row. Any ideas?
>
> class Aaa( models.Model ):
>...
>...
>
> class City( models.Model ):
>...
>...
>
> class Bbb( models.Model ):
>aaa = models.ForeignKey( Aaa )
>city = models.ForeignKey( City )
>...
>...
>
> class Ccc( models.Model ):
>aaa = models.ForeignKey( Aaa )
>...
>...
>
>def get_absolute_url(self):
>
>   bbbs = Bbb.objects.filter( aaa = self.aaa )
>
>   city = City.objects.get( id = bbbs[0].city.id )
>
>   return "/" + city.name + "/"  + str(self.id)
>

There may be something else too, but I think that you want get "bbbs" as
follows:

bbbs = self.aaa.bbb_set.all()

And you will need to check that bbbs is not empty before applying "[0]" to
it.

Also, once you have a bbb for sure, then get city by using

city = bbbs[0].city

In summary, something like:

def get_absolute_url(self):
if self.aaa.bbb_set.count() < 1:
return 'some_fixed_url_for_when_a_Ccc_has_no_bbbs' # Or raise a
404 or whatever
return '/%s/%d' % (self.aaa.bbb_set.all()[0].city.name, self.id)

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: Display Model.id in fieldsets used in Admin Site

2012-11-12 Thread Orit Kislev
i know this was asked long time ago but i guess others are looking for the 
answer as well (as i did), so im publishing my answer here.
To view the id all you have to do is add it to the read only fields:
readonly_fields = ['id']

בתאריך יום שישי, 27 במאי 2011 23:19:56 UTC+3, מאת Frisbie:
>
> Hello, 
>
> Is there any way to display a display a Model's id field using the 
> fieldsets field in the Admin model? For example: 
>
> class CodeJobAdmin(admin.ModelAdmin): 
> fieldsets = [ 
> #('JobID', {'fields': ['id']}), 
> ('Status', {'fields': ['status', 'owners']}), 
> # more fields... 
> ] 
> # more entries... 
>
> admin.site.register(CodeJob, CodeJobAdmin) 
>
> This works fine, UNLESS I un-comment the line "#('JobID', {'fields': 
> ['id']}),". If I do, I get an error such as: 
>
> "ImproperlyConfigured at /admin/general/codejob/37/ 
> 'CodeJobAdmin.fieldsets[0][1]['fields']' refers to field 'id' that is 
> missing from the form." 
>
> Anybody know if it's possible to access CodeJob.id (or CodeJob.pk) 
> through fieldsets? 
>
> Thanks, 
> -Brian Frisbie 
>
> -- 
>
> P.S. I know the Model id can be displayed using list_display, e.g.: 
>
> list_display = ('id', getFileName, 'status', 'toolNum', 'date') 
>
> but I want the id to be viewable on the Model object webpage.

-- 
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/-/WU3EJ1JCwiAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 mod-wsgi multiple instances of One Class object

2012-11-12 Thread Diederik van der Boor
In pre 1.4 projects, it was common for projects to have multiple ways to import 
stuff;
because the project path, and the path 1 level up were both in the python path.

This way, you can actually have 2 versions of the module imported,
and hence your singleton breaks (depending on the route taken to access the 
object).

Please make sure your imports are consistent, and your `sys.path` is clean.

Greetings,
Diederik


Op 5 nov. 2012, om 19:07 heeft drunksaint het volgende geschreven:

> I am currently using a DJango - apache installation (on mod_wsgi) to run a 
> website (project) which hosts an intranet cards game, whose rules are 
> complicated enogh that it requires only 1 master list+dict data structure of 
> scores for each user. Individual user's score can be impacted by other users 
> actions also. I am using a Score class which I instantiate in urls.py and all 
> players / users access this class' object [scObj = Scorer('Spades') ]. 
> internally in this obj there are Dicts of players actions, score updates etc 
> etc.
> 
> class Scorer:
> def __init__(self, suitname):
> self.__suitname = suitname
> The scorer class is separately stored in Scorer.py
> 
> scObjs = (Scorer('Spades'), Scorer('Hearts'), Scorer('Clubs'), 
> Scorer('Diamonds'),)
> The objects are created in urls.py
> 
> This model was running perfectly in the DEV deployement. When I moved to PROD 
> in apache, this broke (as in there are multiple instances of scObj being 
> created, so a score update from player-1's move on player-2 is not reflected 
> in a different move by player-3 on player-2) . I need to simulate a singleton 
> class behaviour / global scObj behaviour, which I am not able to do. I am 
> running apache in worker - mpm - multithreaded mode, so I assume that the 
> problem of multiple copies of scObj being there due to multi-process is not 
> there.
> 
> Is the problem related to mod_wsgi?
> 
> 
> -- 
> 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/-/omNsLiRhcpkJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: Postgres versus mysql? Or, is RDS worth migrating for?

2012-11-12 Thread Diederik van der Boor
Second that. If you consider moving back to MySQL,
at least make they've seen the following video at:

http://wekeroad.com/2012/07/19/postgresql-rising

;-)

Secondly, timezones of 1.4 are painful in MySQL to convert to,
and south migrations won't be able to rollback failed schema changes.

Greetings,
Diederik

Op 5 nov. 2012, om 16:44 heeft Faraz Masood Khan het volgende geschreven:

> I recommend if you do transactions a lot, stick to Postgresql by all means. 
> MySQL isn't transactional database, to test what I mean, create a InnoDB 
> database with a very simple InnoDB table (two columns would be fine), than do 
> 1000 inserts in transactions; note the time and you will find that InnoDB is 
> very very slow on insert, plus transactions death locks are very frequent.
> 
> On Monday, November 5, 2012 7:50:56 AM UTC+5, martharotter wrote:
> I was advised recently to port my startup's Django databases from postgres to 
> mysql for two reasons: 
> 
> 1) RDS on Amazon makes it your life much easier
> 2) When I need to scale my web app and have to hire people to help me, it 
> will be much easier to find solid mysql people than postgres people. 
> 
> Any thoughts on these? Are they legitimate concerns? It's always a pain to 
> migrate, but I guess if it's worth doing I'd rather do that now when it makes 
> less of an impact. 
> 
> Thanks in advance for your help!
> --Martha 
> http://woop.ie 
> 
> 
> -- 
> 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/-/dJ8jP6DRylgJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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.



How to configure nginx to serve mail for django

2012-11-12 Thread Chris Pagnutti
Hi.  I'm using nginx+uwsgi to serve a django app.  I'd like to configure it 
to be able to send mail with django's send_mail() and send_mass_mail() 
functions.  I've played with the nginx configuration files using the 
examples here
http://wiki.nginx.org/Configuration#Mail_examples

I have a very simple view that just does 

from django.core.mail import send_mail
send_mail('Subject here', 'Here is the message.', 'f...@example.com',
['t...@example.com'], fail_silently=False)


but with my email addresses in there of course.  The view doesn't throw any 
exceptions, but it also doesn't send the email (or do anything else for 
that matter).  Can someone help me with getting nginx to serve email for 
django, or at least point me in the right direction?  Thanks to all.

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



ModelForm displays invalid cohice error.

2012-11-12 Thread Josue Balandrano
Hi, I am trying to create a very basic ratings and comments app. I have 
this model:

class Ratings(models.Model):
user = models.ForeignKey(UserProfile)
product = models.ForeignKey(Product)
rate = models.PositiveIntegerField(default=0, null=False, 
choices=((1,'1'),(2,'2'),(3,'3'),(4,'4'),(5,'5')))
comment = models.TextField(default='', blank=True)
date_added = models.DateField(default=datetime.now)
objects = RatingsManager()

def __unicode__(self):
return self.rating

class Meta:   
unique_together = ("user", "restaurant")  

class RatingsManager(models.Manager):
def get_average(self, **kwargs):
prod = kwargs['prod']
return self.filter(product = prod).aggregate(Avg('rate'))

And I have this modelform Class:

class RatingsForm(forms.ModelForm):
comment = 
forms.CharField(widget=forms.Textarea(attrs={'name':'comentario', 
'label':'', 'rows':'5', 'cols':'50'}))
class Meta:
model = Ratings
widgets = {
'user' : forms.HiddenInput(),
'product' : forms.HiddenInput(),
'rate' : forms.RadioSelect(),
}
exclude = ('date_added', )

First, this is how I initiate the form and pass it to the context variable. 
This form will only ve bisivle in a detail view of the product.

rating_form = RatingsForm(initial={'product':prod.id, 
'user':self.request.user.id})
context['rating_form'] = rating_form

And this is what I gets executed once the view recieves a post request. 

product_id = request.POST.get('product')
user_id = request.user.id
try:
instance = Ratings.objects.get(user = int(user_id), product = 
int(product_id)) #IF USER SUBMITED RATING FOR THIS PRODUCT UPDATE EXISTING 
RECORD INSTEAD OF CREATING A NEW ONE
except Ratings.DoesNotExist:
instance = None
if instance is None:
formset = RatingsForm(request.POST)
formset.restaurant = int(restaurant_id)
formset.user = int(user_id) 
if formset.is_valid():
formset.save()

else:
formset = RatingsForm(request.POST, instance=instance)
if formset.is_valid():
formset.save()

context.update({ 'rating_form':formset,})
return self.render_to_response(context)

So when ever I submit the form I get this error:


   - Select a valid choice. That choice is not one of the available choices.

But I can't figure out what does it means? Because the only choice field I 
have is the "rate" field and it could never be anything else than an int 
between 1 - 5.

Any ideas how to fix this?

Thank you.

-- 
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/-/u6heU1dlyDsJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 configure nginx to serve mail for django

2012-11-12 Thread Nikolas Stevenson-Molnar
The nginx configuration examples you link to are all POP3 or IMAP.
Sending mail is SMTP. But even then, you need an SMTP server to proxy
/to/. In these examples, nginx is simply acting as a proxy, not as an
actual mail server. I would recommend using a bona fide SMTP server. Or
use one already available to you from your mail provider (e.g., if you
use GMail, you can configure Django to use GMail's mail servers to send
email).

_Nik

On 11/12/2012 10:22 AM, Chris Pagnutti wrote:
> Hi.  I'm using nginx+uwsgi to serve a django app.  I'd like to
> configure it to be able to send mail with django's send_mail() and
> send_mass_mail() functions.  I've played with the nginx configuration
> files using the examples here
> http://wiki.nginx.org/Configuration#Mail_examples
>
> I have a very simple view that just does 
> from django.core.mail import send_mail
>
> send_mail('Subject here', 'Here is the message.', 'f...@example.com',
> ['t...@example.com'], fail_silently=False)
>
> but with my email addresses in there of course.  The view doesn't
> throw any exceptions, but it also doesn't send the email (or do
> anything else for that matter).  Can someone help me with getting
> nginx to serve email for django, or at least point me in the right
> direction?  Thanks to all.
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/yfrTK_xhMpUJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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 many developers have moved to class-based views?

2012-11-12 Thread Lachlan Musicman
On Tue, Nov 13, 2012 at 4:07 AM, John DeRosa  wrote:
>
> I use only function-based views. I've yet to read a compelling argument for 
> switching.

I think the best argument goes something like:

 - if you have previously developed sites that are now stable or only
require minor changes, and wont have any further or much development
there's no need to change
 - if you have previously developed sites that are expecting to
grow/change (and have the budget :) ) then you would probably change
 - if you are developing a new site, then use CBV

Just like a stable OS, there's no need to update every 6 months just
because you can, unless you enjoy the work it takes.

Cheers
L.

--
...we look at the present day through a rear-view mirror. This is
something Marshall McLuhan said back in the Sixties, when the world
was in the grip of authentic-seeming future narratives. He said, “We
look at the present through a rear-view mirror. We march backwards
into the future.”

http://www.warrenellis.com/?p=14314

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 many developers have moved to class-based views?

2012-11-12 Thread Dan Gentry
It took me a few months to warm up to using class based views, and it was 
the pending decommissioning of the generic function based views that first 
caused me to take a look.  Now, I have converted all but the most 
complicated views to the class format (why change what works?).  Any new 
work I do is in CBV unless there is a compelling reason not to.

I agree with the remark from Kurtis that DRY is a great motivator to use 
CBVs.  Inspired by braces, I have begun to write my own mixins to minimize 
code copying.

-- 
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/-/GqUJkhF50HQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: ModelForm displays invalid cohice error.

2012-11-12 Thread Lachlan Musicman
On Tue, Nov 13, 2012 at 6:37 AM, Josue Balandrano  wrote:
> Hi, I am trying to create a very basic ratings and comments app. I have this
> model:
>
> class Ratings(models.Model):
> user = models.ForeignKey(UserProfile)
> product = models.ForeignKey(Product)
> rate = models.PositiveIntegerField(default=0, null=False,
> choices=((1,'1'),(2,'2'),(3,'3'),(4,'4'),(5,'5')))

Can a choices kwarg be used with a PositiveIntegerField? Is the
problem solved by changing this to a CharField?



> comment = models.TextField(default='', blank=True)
> date_added = models.DateField(default=datetime.now)
> objects = RatingsManager()
>
> def __unicode__(self):
> return self.rating
>
> class Meta:
> unique_together = ("user", "restaurant")
>
> class RatingsManager(models.Manager):
> def get_average(self, **kwargs):
> prod = kwargs['prod']
> return self.filter(product = prod).aggregate(Avg('rate'))
>
> And I have this modelform Class:
>
> class RatingsForm(forms.ModelForm):
> comment =
> forms.CharField(widget=forms.Textarea(attrs={'name':'comentario',
> 'label':'', 'rows':'5', 'cols':'50'}))
> class Meta:
> model = Ratings
> widgets = {
> 'user' : forms.HiddenInput(),
> 'product' : forms.HiddenInput(),
> 'rate' : forms.RadioSelect(),
> }
> exclude = ('date_added', )
>
> First, this is how I initiate the form and pass it to the context variable.
> This form will only ve bisivle in a detail view of the product.
>
> rating_form = RatingsForm(initial={'product':prod.id,
> 'user':self.request.user.id})
> context['rating_form'] = rating_form
>
> And this is what I gets executed once the view recieves a post request.
>
> product_id = request.POST.get('product')
> user_id = request.user.id
> try:
> instance = Ratings.objects.get(user = int(user_id), product =
> int(product_id)) #IF USER SUBMITED RATING FOR THIS PRODUCT UPDATE EXISTING
> RECORD INSTEAD OF CREATING A NEW ONE
> except Ratings.DoesNotExist:
> instance = None
> if instance is None:
> formset = RatingsForm(request.POST)
> formset.restaurant = int(restaurant_id)
> formset.user = int(user_id)
> if formset.is_valid():
> formset.save()
>
> else:
> formset = RatingsForm(request.POST, instance=instance)
> if formset.is_valid():
> formset.save()
>
> context.update({ 'rating_form':formset,})
> return self.render_to_response(context)
>
> So when ever I submit the form I get this error:
>
> Select a valid choice. That choice is not one of the available choices.
>
> But I can't figure out what does it means? Because the only choice field I
> have is the "rate" field and it could never be anything else than an int
> between 1 - 5.
>
> Any ideas how to fix this?
>
> Thank you.
>
>
> --
> 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/-/u6heU1dlyDsJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.



--
...we look at the present day through a rear-view mirror. This is
something Marshall McLuhan said back in the Sixties, when the world
was in the grip of authentic-seeming future narratives. He said, “We
look at the present through a rear-view mirror. We march backwards
into the future.”

http://www.warrenellis.com/?p=14314

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

2012-11-12 Thread Jill Green
Doesn't the default need to be one of the choices?

> models.PositiveIntegerField(default=1, null=False, 
> choices=((1,'1'),(2,'2'),(3,'3'),(4,'4'),(5,'5')))

Sent from my iPhone

On Nov 12, 2012, at 11:37 AM, Josue Balandrano  wrote:

> Hi, I am trying to create a very basic ratings and comments app. I have this 
> model:
> 
> class Ratings(models.Model):
> user = models.ForeignKey(UserProfile)
> product = models.ForeignKey(Product)
> rate = models.PositiveIntegerField(default=0, null=False, 
> choices=((1,'1'),(2,'2'),(3,'3'),(4,'4'),(5,'5')))
> comment = models.TextField(default='', blank=True)
> date_added = models.DateField(default=datetime.now)
> objects = RatingsManager()
> 
> def __unicode__(self):
> return self.rating
> 
> class Meta:   
> unique_together = ("user", "restaurant")  
> 
> class RatingsManager(models.Manager):
> def get_average(self, **kwargs):
> prod = kwargs['prod']
> return self.filter(product = prod).aggregate(Avg('rate'))
> 
> And I have this modelform Class:
> 
> class RatingsForm(forms.ModelForm):
> comment = 
> forms.CharField(widget=forms.Textarea(attrs={'name':'comentario', 'label':'', 
> 'rows':'5', 'cols':'50'}))
> class Meta:
> model = Ratings
> widgets = {
> 'user' : forms.HiddenInput(),
> 'product' : forms.HiddenInput(),
> 'rate' : forms.RadioSelect(),
> }
> exclude = ('date_added', )
> 
> First, this is how I initiate the form and pass it to the context variable. 
> This form will only ve bisivle in a detail view of the product.
> 
> rating_form = RatingsForm(initial={'product':prod.id, 
> 'user':self.request.user.id})
> context['rating_form'] = rating_form
> 
> And this is what I gets executed once the view recieves a post request. 
> 
> product_id = request.POST.get('product')
> user_id = request.user.id
> try:
> instance = Ratings.objects.get(user = int(user_id), product = 
> int(product_id)) #IF USER SUBMITED RATING FOR THIS PRODUCT UPDATE EXISTING 
> RECORD INSTEAD OF CREATING A NEW ONE
> except Ratings.DoesNotExist:
> instance = None
> if instance is None:
> formset = RatingsForm(request.POST)
> formset.restaurant = int(restaurant_id)
> formset.user = int(user_id) 
> if formset.is_valid():
> formset.save()
> 
> else:
> formset = RatingsForm(request.POST, instance=instance)
> if formset.is_valid():
> formset.save()
> 
> context.update({ 'rating_form':formset,})
> return self.render_to_response(context)
> 
> So when ever I submit the form I get this error:
> 
> Select a valid choice. That choice is not one of the available choices.
> But I can't figure out what does it means? Because the only choice field I 
> have is the "rate" field and it could never be anything else than an int 
> between 1 - 5.
> 
> Any ideas how to fix this?
> 
> Thank you.
> 
> 
> -- 
> 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/-/u6heU1dlyDsJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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 configure nginx to serve mail for django

2012-11-12 Thread Chris Pagnutti
Yeah.  Makes good sense.  I guess that Postfix is one of the more popular 
options.  Is there any reason why I should NOT use postfix.

On Monday, November 12, 2012 1:47:03 PM UTC-5, Nikolas Stevenson-Molnar 
wrote:
>
>  The nginx configuration examples you link to are all POP3 or IMAP. 
> Sending mail is SMTP. But even then, you need an SMTP server to proxy *to*. 
> In these examples, nginx is simply acting as a proxy, not as an actual mail 
> server. I would recommend using a bona fide SMTP server. Or use one already 
> available to you from your mail provider (e.g., if you use GMail, you can 
> configure Django to use GMail's mail servers to send email).
>
> _Nik
>
> On 11/12/2012 10:22 AM, Chris Pagnutti wrote:
>  
> Hi.  I'm using nginx+uwsgi to serve a django app.  I'd like to configure 
> it to be able to send mail with django's send_mail() and send_mass_mail() 
> functions.  I've played with the nginx configuration files using the 
> examples here 
> http://wiki.nginx.org/Configuration#Mail_examples
>  
>  I have a very simple view that just does 
>  
> from django.core.mail import send_mail
> send_mail('Subject here', 'Here is the message.', 'fr...@example.com 
> ',
> ['t...@example.com '], fail_silently=False)
>
>  
>  but with my email addresses in there of course.  The view doesn't throw 
> any exceptions, but it also doesn't send the email (or do anything else for 
> that matter).  Can someone help me with getting nginx to serve email for 
> django, or at least point me in the right direction?  Thanks to all.
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/django-users/-/yfrTK_xhMpUJ.
> To post to this group, send email to django...@googlegroups.com
> .
> To unsubscribe from this group, send email to 
> django-users...@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/-/N3CVAVAyHcwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: ModelForm displays invalid cohice error.

2012-11-12 Thread Josue Balandrano
Judging by the docs it really doesn't matter the kind of field it is. As 
long as it has de choices tuple list. Giving that this tuple gives you the 
value it should take and the human readable form. So I am guessing django 
framework just mapps the labels with the values you give in the choices 
tuples. So as long as you use Positive Integers in the choice tuple it 
should be fine. 
HAving said this I am going to try to change it into a charfield to see 
what happens.

El lunes, 12 de noviembre de 2012 13:41:01 UTC-6, Lachlan Musicman escribió:
>
> On Tue, Nov 13, 2012 at 6:37 AM, Josue Balandrano 
> > 
> wrote: 
> > Hi, I am trying to create a very basic ratings and comments app. I have 
> this 
> > model: 
> > 
> > class Ratings(models.Model): 
> > user = models.ForeignKey(UserProfile) 
> > product = models.ForeignKey(Product) 
> > rate = models.PositiveIntegerField(default=0, null=False, 
> > choices=((1,'1'),(2,'2'),(3,'3'),(4,'4'),(5,'5'))) 
>
> Can a choices kwarg be used with a PositiveIntegerField? Is the 
> problem solved by changing this to a CharField? 
>
>
>
> > comment = models.TextField(default='', blank=True) 
> > date_added = models.DateField(default=datetime.now) 
> > objects = RatingsManager() 
> > 
> > def __unicode__(self): 
> > return self.rating 
> > 
> > class Meta: 
> > unique_together = ("user", "restaurant") 
> > 
> > class RatingsManager(models.Manager): 
> > def get_average(self, **kwargs): 
> > prod = kwargs['prod'] 
> > return self.filter(product = prod).aggregate(Avg('rate')) 
> > 
> > And I have this modelform Class: 
> > 
> > class RatingsForm(forms.ModelForm): 
> > comment = 
> > forms.CharField(widget=forms.Textarea(attrs={'name':'comentario', 
> > 'label':'', 'rows':'5', 'cols':'50'})) 
> > class Meta: 
> > model = Ratings 
> > widgets = { 
> > 'user' : forms.HiddenInput(), 
> > 'product' : forms.HiddenInput(), 
> > 'rate' : forms.RadioSelect(), 
> > } 
> > exclude = ('date_added', ) 
> > 
> > First, this is how I initiate the form and pass it to the context 
> variable. 
> > This form will only ve bisivle in a detail view of the product. 
> > 
> > rating_form = RatingsForm(initial={'product':prod.id, 
> > 'user':self.request.user.id}) 
> > context['rating_form'] = rating_form 
> > 
> > And this is what I gets executed once the view recieves a post request. 
> > 
> > product_id = request.POST.get('product') 
> > user_id = request.user.id 
> > try: 
> > instance = Ratings.objects.get(user = int(user_id), product 
> = 
> > int(product_id)) #IF USER SUBMITED RATING FOR THIS PRODUCT UPDATE 
> EXISTING 
> > RECORD INSTEAD OF CREATING A NEW ONE 
> > except Ratings.DoesNotExist: 
> > instance = None 
> > if instance is None: 
> > formset = RatingsForm(request.POST) 
> > formset.restaurant = int(restaurant_id) 
> > formset.user = int(user_id) 
> > if formset.is_valid(): 
> > formset.save() 
> > 
> > else: 
> > formset = RatingsForm(request.POST, instance=instance) 
> > if formset.is_valid(): 
> > formset.save() 
> > 
> > context.update({ 'rating_form':formset,}) 
> > return self.render_to_response(context) 
> > 
> > So when ever I submit the form I get this error: 
> > 
> > Select a valid choice. That choice is not one of the available choices. 
> > 
> > But I can't figure out what does it means? Because the only choice field 
> I 
> > have is the "rate" field and it could never be anything else than an int 
> > between 1 - 5. 
> > 
> > Any ideas how to fix this? 
> > 
> > Thank you. 
> > 
> > 
> > -- 
> > 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/-/u6heU1dlyDsJ. 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > To unsubscribe from this group, send email to 
> > django-users...@googlegroups.com . 
> > For more options, visit this group at 
> > http://groups.google.com/group/django-users?hl=en. 
>
>
>
> -- 
> ...we look at the present day through a rear-view mirror. This is 
> something Marshall McLuhan said back in the Sixties, when the world 
> was in the grip of authentic-seeming future narratives. He said, “We 
> look at the present through a rear-view mirror. We march backwards 
> into the future.” 
>
> http://www.warrenellis.com/?p=14314 
>

-- 
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/-/pjjgxDzWwgIJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send emai

Re: ModelForm displays invalid cohice error.

2012-11-12 Thread Josue Balandrano
Iam really not shure. Will try to chane this.

El lunes, 12 de noviembre de 2012 13:56:08 UTC-6, Jill Green escribió:
>
> Doesn't the default need to be one of the choices?
>
> models.PositiveIntegerField(default=1, null=False, 
> choices=((1,'1'),(2,'2'),(3,'3'),(4,'4'),(5,'5')))
>
>
> Sent from my iPhone
>
> On Nov 12, 2012, at 11:37 AM, Josue Balandrano 
> > 
> wrote:
>
> Hi, I am trying to create a very basic ratings and comments app. I have 
> this model:
>
> class Ratings(models.Model):
> user = models.ForeignKey(UserProfile)
> product = models.ForeignKey(Product)
> rate = models.PositiveIntegerField(default=0, null=False, 
> choices=((1,'1'),(2,'2'),(3,'3'),(4,'4'),(5,'5')))
> comment = models.TextField(default='', blank=True)
> date_added = models.DateField(default=datetime.now)
> objects = RatingsManager()
>
> def __unicode__(self):
> return self.rating
>
> class Meta:   
> unique_together = ("user", "restaurant")  
>
> class RatingsManager(models.Manager):
> def get_average(self, **kwargs):
> prod = kwargs['prod']
> return self.filter(product = prod).aggregate(Avg('rate'))
>
> And I have this modelform Class:
>
> class RatingsForm(forms.ModelForm):
> comment = 
> forms.CharField(widget=forms.Textarea(attrs={'name':'comentario', 
> 'label':'', 'rows':'5', 'cols':'50'}))
> class Meta:
> model = Ratings
> widgets = {
> 'user' : forms.HiddenInput(),
> 'product' : forms.HiddenInput(),
> 'rate' : forms.RadioSelect(),
> }
> exclude = ('date_added', )
>
> First, this is how I initiate the form and pass it to the context 
> variable. This form will only ve bisivle in a detail view of the product.
>
> rating_form = RatingsForm(initial={'product':prod.id, 'user':
> self.request.user.id})
> context['rating_form'] = rating_form
>
> And this is what I gets executed once the view recieves a post request. 
>
> product_id = request.POST.get('product')
> user_id = request.user.id
> try:
> instance = Ratings.objects.get(user = int(user_id), product = 
> int(product_id)) #IF USER SUBMITED RATING FOR THIS PRODUCT UPDATE EXISTING 
> RECORD INSTEAD OF CREATING A NEW ONE
> except Ratings.DoesNotExist:
> instance = None
> if instance is None:
> formset = RatingsForm(request.POST)
> formset.restaurant = int(restaurant_id)
> formset.user = int(user_id) 
> if formset.is_valid():
> formset.save()
>
> else:
> formset = RatingsForm(request.POST, instance=instance)
> if formset.is_valid():
> formset.save()
>
> context.update({ 'rating_form':formset,})
> return self.render_to_response(context)
>
> So when ever I submit the form I get this error:
>
>
>- Select a valid choice. That choice is not one of the available 
>choices.
>
> But I can't figure out what does it means? Because the only choice field I 
> have is the "rate" field and it could never be anything else than an int 
> between 1 - 5.
>
> Any ideas how to fix this?
>
> Thank you.
>
>  -- 
> 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/-/u6heU1dlyDsJ.
> To post to this group, send email to django...@googlegroups.com
> .
> To unsubscribe from this group, send email to 
> django-users...@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/-/nrjwEGQ46ioJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: ModelForm displays invalid cohice error.

2012-11-12 Thread Lachlan Musicman
On Tue, Nov 13, 2012 at 8:52 AM, Josue Balandrano  wrote:
> Judging by the docs it really doesn't matter the kind of field it is. As
> long as it has de choices tuple list. Giving that this tuple gives you the
> value it should take and the human readable form. So I am guessing django
> framework just mapps the labels with the values you give in the choices
> tuples. So as long as you use Positive Integers in the choice tuple it
> should be fine.
> HAving said this I am going to try to change it into a charfield to see what
> happens.

I actually think you will have more luck with Jill's suggestion :)

cheers
L.

>
> El lunes, 12 de noviembre de 2012 13:41:01 UTC-6, Lachlan Musicman escribió:
>>
>> On Tue, Nov 13, 2012 at 6:37 AM, Josue Balandrano 
>> wrote:
>> > Hi, I am trying to create a very basic ratings and comments app. I have
>> > this
>> > model:
>> >
>> > class Ratings(models.Model):
>> > user = models.ForeignKey(UserProfile)
>> > product = models.ForeignKey(Product)
>> > rate = models.PositiveIntegerField(default=0, null=False,
>> > choices=((1,'1'),(2,'2'),(3,'3'),(4,'4'),(5,'5')))
>>
>> Can a choices kwarg be used with a PositiveIntegerField? Is the
>> problem solved by changing this to a CharField?
>>
>>
>>
>> > comment = models.TextField(default='', blank=True)
>> > date_added = models.DateField(default=datetime.now)
>> > objects = RatingsManager()
>> >
>> > def __unicode__(self):
>> > return self.rating
>> >
>> > class Meta:
>> > unique_together = ("user", "restaurant")
>> >
>> > class RatingsManager(models.Manager):
>> > def get_average(self, **kwargs):
>> > prod = kwargs['prod']
>> > return self.filter(product = prod).aggregate(Avg('rate'))
>> >
>> > And I have this modelform Class:
>> >
>> > class RatingsForm(forms.ModelForm):
>> > comment =
>> > forms.CharField(widget=forms.Textarea(attrs={'name':'comentario',
>> > 'label':'', 'rows':'5', 'cols':'50'}))
>> > class Meta:
>> > model = Ratings
>> > widgets = {
>> > 'user' : forms.HiddenInput(),
>> > 'product' : forms.HiddenInput(),
>> > 'rate' : forms.RadioSelect(),
>> > }
>> > exclude = ('date_added', )
>> >
>> > First, this is how I initiate the form and pass it to the context
>> > variable.
>> > This form will only ve bisivle in a detail view of the product.
>> >
>> > rating_form = RatingsForm(initial={'product':prod.id,
>> > 'user':self.request.user.id})
>> > context['rating_form'] = rating_form
>> >
>> > And this is what I gets executed once the view recieves a post request.
>> >
>> > product_id = request.POST.get('product')
>> > user_id = request.user.id
>> > try:
>> > instance = Ratings.objects.get(user = int(user_id), product
>> > =
>> > int(product_id)) #IF USER SUBMITED RATING FOR THIS PRODUCT UPDATE
>> > EXISTING
>> > RECORD INSTEAD OF CREATING A NEW ONE
>> > except Ratings.DoesNotExist:
>> > instance = None
>> > if instance is None:
>> > formset = RatingsForm(request.POST)
>> > formset.restaurant = int(restaurant_id)
>> > formset.user = int(user_id)
>> > if formset.is_valid():
>> > formset.save()
>> >
>> > else:
>> > formset = RatingsForm(request.POST, instance=instance)
>> > if formset.is_valid():
>> > formset.save()
>> >
>> > context.update({ 'rating_form':formset,})
>> > return self.render_to_response(context)
>> >
>> > So when ever I submit the form I get this error:
>> >
>> > Select a valid choice. That choice is not one of the available choices.
>> >
>> > But I can't figure out what does it means? Because the only choice field
>> > I
>> > have is the "rate" field and it could never be anything else than an int
>> > between 1 - 5.
>> >
>> > Any ideas how to fix this?
>> >
>> > Thank you.
>> >
>> >
>> > --
>> > 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/-/u6heU1dlyDsJ.
>> > To post to this group, send email to django...@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > django-users...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/django-users?hl=en.
>>
>>
>>
>> --
>> ...we look at the present day through a rear-view mirror. This is
>> something Marshall McLuhan said back in the Sixties, when the world
>> was in the grip of authentic-seeming future narratives. He said, “We
>> look at the present through a rear-view mirror. We march backwards
>> into the future.”
>>
>> http://www.warrenellis.com/?p=14314
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https

Obtaining field name in template

2012-11-12 Thread Axel Rau
1st trial with generic views:

url.py:
url(r'^account/(?P\d+)/$', AccountDetailView.as_view(), 
name='account-detail'),

views.py:
class AccountDetailView(DetailView):
model = Account

In the template, I get the data so:
object.field
But how do I get the field name (model.field.verbose_name)?

Axel
---
PGP-Key:29E99DD6  ☀ +49 151 2300 9283  ☀ computing @ chaos claudius

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

2012-11-12 Thread Lachlan Musicman
On Tue, Nov 13, 2012 at 9:51 AM, Axel Rau  wrote:
> 1st trial with generic views:
>
> url.py:
> url(r'^account/(?P\d+)/$', AccountDetailView.as_view(), 
> name='account-detail'),
>
> views.py:
> class AccountDetailView(DetailView):
> model = Account
>
> In the template, I get the data so:
> object.field
> But how do I get the field name (model.field.verbose_name)?

I think the easiest way I've seen is to use _meta like thus:

http://stackoverflow.com/questions/3647805/get-models-fields-in-django

cheers
L.

--
...we look at the present day through a rear-view mirror. This is
something Marshall McLuhan said back in the Sixties, when the world
was in the grip of authentic-seeming future narratives. He said, “We
look at the present through a rear-view mirror. We march backwards
into the future.”

http://www.warrenellis.com/?p=14314

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

2012-11-12 Thread Chris Pagnutti
Not sure.  It's VPS and I was handed a Debian install with practically
nothing on it.  I even had to install make to be able to compile nginx.
 I'm looking into setting up Postfix+Dovecot+Roundcube (or SquirrelMail)

On Mon, Nov 12, 2012 at 8:37 PM, Dennis Lee Bieber wrote:

> On Mon, 12 Nov 2012 12:51:57 -0800 (PST), Chris Pagnutti
>  declaimed the following in
> gmane.comp.python.django.user:
>
> > Yeah.  Makes good sense.  I guess that Postfix is one of the more popular
> > options.  Is there any reason why I should NOT use postfix.
> >
> Well, do you already have access to a running SMTP daemon? (Does
> your server machine respond to local connection attempts on port 25? Is
> the server machine part of a network that may have an SMTPd located on
> another machine?
> ).
> --
> Wulfraed Dennis Lee Bieber AF6VN
> wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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