Re: Looking for a round trip example of adding/editing/saving a record using class-based views

2012-03-19 Thread Lee Hinde
On Sun, Mar 18, 2012 at 4:11 PM, Lee Hinde  wrote:
> I'm looking for something like the vote function in step 4 of the tutorial,
> but using class-based views.py. Any pointers would be appreciated.
>
> Thanks.

Specifically, what's the equivalent of this block:



def vote(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id)
try:
selected_choice = p.choice_set.get(pk=request.POST['choice'])
except (KeyError, Choice.DoesNotExist):
# Redisplay the poll voting form.
return render_to_response('polls/detail.html', {
'poll': p,
'error_message': "You didn't select a choice.",
}, context_instance=RequestContext(request))
else:
selected_choice.votes += 1
selected_choice.save()
# Always return an HttpResponseRedirect after successfully dealing
# with POST data. This prevents data from being posted twice if a
# user hits the Back button.
return HttpResponseRedirect(reverse('polls.views.results',
args=(p.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: Question about threading a view[REPOSTED]

2012-03-19 Thread Jani Tiainen
Hi,

Basic idea is to send a message to message broker from your view to tell "I
want to run this long running task X".

After that your view can return (with task id). After that your client can
start asking from second view for long running response.

In the background you have to have some means to query message broker for
requested tasks and execute them. For example
using a cron job.

That's where django-celery comes in. It can create tasks and it can run
tasks within Django framework using various message
brokers - rabbitmq being probably most popular.

So first you define task with django-celery. Then in your view you send
message to message broker that "execute that task".
And then you must have some background running process to read messages
from broker and execute them.

What comes to testing usually you mock responses in these kind of tests. Of
course you can still test your long running process but
in unit tests you don't test that communication between broker and running
system.

HTH,

Jani Tiainen

On Mon, Mar 19, 2012 at 11:17 PM, Arruda wrote:

> Some one also gave me that tip.
> I was reading it, but I couldn't see much clear how to use this in this
> case.
> I saw that to execute a task I should run it by using ./manage.py ... and
> how can I do that in a view?
> Another thing is that it seems to me a bit overkill isn't it, and a little
> to complicated to setup.
> To test it in development I need to prepare a huge scenario so that it can
> work out, and also I can't imagine how to use this in tests.
>
> Did I understood it wrong? Ins't it a lot complicated to use?
>
> Thanks
>
> Em segunda-feira, 19 de março de 2012 16h43min03s UTC-3, Kurtis escreveu:
>
>> Did you check out django-celery yet?
>>
>> On Mon, Mar 19, 2012 at 2:18 PM, Arruda 
>> 
>> > wrote:
>>
>>> *(I've created a topic like this a few minutes ago, but was using the
>>> old google groups, and now it's broken. So I created a new one using the
>>> new google groups).*
>>> Hi, I'll try to explain the best I can my problem, and I don't know if
>>> what I'm trying to archive is the best way to get where I want, but
>>> here is it:
>>> I want that a specific view to run in a new thread, ex:
>>> * def foo(request):
>>>do_something_slow()
>>>   return httpResponse*
>>>
>>> But I DON'T want that a new thread is run inside the view, the view it
>>> self should be runned in another thread, ex:
>>> *
>>>  def foo(request):
>>>t = thread(target=do_something_slow())
>>>t.daemon = True
>>>t.start()
>>>
>>>   return httpResponse
>>> *
>>> This way when a user A access any page the site will load, even if a
>>> user B is accessing the 'foo' view.
>>> But the B user when access the view 'foo' will load it just a if if
>>> was a normal view( will be slow and will render the response just
>>> after do_something_slow() finished running).
>>>
>>> I don't know if this is what I want, but I believe that there is
>>> another way around:
>>> when user B calls foo view, it will render to him a page with a JS(I
>>> don't know JS either, so correct me if I'm talking nonsense) that say
>>> its "Loading..."
>>> And after the do_someting_slow() finished running if will change the
>>> content of the page to whatever the result of "do_something_slow" was.
>>>
>>> Thanks for the attention.
>>>
>>> --
>>> 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/-/**jc20eqhcl8oJ
>>> .
>>> 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/-/9Xk3RQ-y6pgJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: Question about threading a view[REPOSTED]

2012-03-19 Thread Arruda
Some one also gave me that tip. 
I was reading it, but I couldn't see much clear how to use this in this 
case.
I saw that to execute a task I should run it by using ./manage.py ... and 
how can I do that in a view?
Another thing is that it seems to me a bit overkill isn't it, and a little 
to complicated to setup.
To test it in development I need to prepare a huge scenario so that it can 
work out, and also I can't imagine how to use this in tests. 

Did I understood it wrong? Ins't it a lot complicated to use?

Thanks

Em segunda-feira, 19 de março de 2012 16h43min03s UTC-3, Kurtis escreveu:
>
> Did you check out django-celery yet?
>
> On Mon, Mar 19, 2012 at 2:18 PM, Arruda wrote:
>
>> *(I've created a topic like this a few minutes ago, but was using the 
>> old google groups, and now it's broken. So I created a new one using the 
>> new google groups).*
>> Hi, I'll try to explain the best I can my problem, and I don't know if
>> what I'm trying to archive is the best way to get where I want, but
>> here is it:
>> I want that a specific view to run in a new thread, ex:
>> * def foo(request):
>>do_something_slow()
>>   return httpResponse*
>>
>> But I DON'T want that a new thread is run inside the view, the view it
>> self should be runned in another thread, ex:
>> *
>>  def foo(request):
>>t = thread(target=do_something_slow())
>>t.daemon = True
>>t.start()
>>
>>   return httpResponse
>> *
>> This way when a user A access any page the site will load, even if a
>> user B is accessing the 'foo' view.
>> But the B user when access the view 'foo' will load it just a if if
>> was a normal view( will be slow and will render the response just
>> after do_something_slow() finished running).
>>
>> I don't know if this is what I want, but I believe that there is
>> another way around:
>> when user B calls foo view, it will render to him a page with a JS(I
>> don't know JS either, so correct me if I'm talking nonsense) that say
>> its "Loading..."
>> And after the do_someting_slow() finished running if will change the
>> content of the page to whatever the result of "do_something_slow" was.
>>
>> Thanks for the attention.
>>
>> -- 
>> 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/-/jc20eqhcl8oJ.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, 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/-/9Xk3RQ-y6pgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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/Python version compatibility

2012-03-19 Thread Simone Federici
On Mon, Mar 19, 2012 at 21:52, Chiproller  wrote:

> So will 1.4 be compatible with Python 3.X?  I am wondering how best to
> learn Python for Django if I'm learning from Python books that cover
> (like most new books) 3.X.  Any suggestions?
>

Django 1.4 => [ Python2.5, Python2.6, Python2.7 ]
Django 1.5 maybe=>  [Python2.5+,  Python3.3]

Actually python2.7 is the best solution to begin, if you like the syntax of
python 3x you can use import __future__

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

2012-03-19 Thread Chiproller
So will 1.4 be compatible with Python 3.X?  I am wondering how best to
learn Python for Django if I'm learning from Python books that cover
(like most new books) 3.X.  Any suggestions?

On Mar 19, 12:50 pm, Joel Goldstick  wrote:
> On Mon, Mar 19, 2012 at 11:41 AM, Shawn Milochik  wrote:
> > Django won't support 3.x for a while. You can't go wrong with 2.7 for now.
>
> >https://www.djangoproject.com/weblog/2012/mar/13/py3k/
>
> > Shawn
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> So your other choice is whether to go with django 1.3 or the new 1.4
> being released some time in the coming days.  Probably best to go with
> 1.4 since they keep making it better, but there are differences
> between the new version and the old version's way of setting up
> directories, so beware that third party tutorials will have to be
> tweeked with to get going in 1.4
>
> --
> 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: Question about threading a view[REPOSTED]

2012-03-19 Thread Kurtis Mullins
Did you check out django-celery yet?

On Mon, Mar 19, 2012 at 2:18 PM, Arruda wrote:

> *(I've created a topic like this a few minutes ago, but was using the old
> google groups, and now it's broken. So I created a new one using the new
> google groups).*
> Hi, I'll try to explain the best I can my problem, and I don't know if
> what I'm trying to archive is the best way to get where I want, but
> here is it:
> I want that a specific view to run in a new thread, ex:
> * def foo(request):
>do_something_slow()
>   return httpResponse*
>
> But I DON'T want that a new thread is run inside the view, the view it
> self should be runned in another thread, ex:
> *
>  def foo(request):
>t = thread(target=do_something_slow())
>t.daemon = True
>t.start()
>
>   return httpResponse
> *
> This way when a user A access any page the site will load, even if a
> user B is accessing the 'foo' view.
> But the B user when access the view 'foo' will load it just a if if
> was a normal view( will be slow and will render the response just
> after do_something_slow() finished running).
>
> I don't know if this is what I want, but I believe that there is
> another way around:
> when user B calls foo view, it will render to him a page with a JS(I
> don't know JS either, so correct me if I'm talking nonsense) that say
> its "Loading..."
> And after the do_someting_slow() finished running if will change the
> content of the page to whatever the result of "do_something_slow" was.
>
> Thanks for the attention.
>
> --
> 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/-/jc20eqhcl8oJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: calculated form field

2012-03-19 Thread Tim Ney
Rajeesh,

Following your advice, Im think I've about solved the problem.
I've got one last exception, I hope.

Here is the new iteration of views.py, all other files remain the same.
In short the page renders to the screen, the problem arises when values are
submitted
to the view.

I get an exception  "can't multiply sequence by non-int of type 'tuple".
I've created a new
function that describes the multiplication operation, that is used within
the render function, this
is where the error occcrs. I'm not referencing the variables properly, I
guess.

def calculation(request):
 """function that computes submission"""
if request.method == 'POST':
 form = FinanceTable(request.POST)
 if form.is_valid():
   cd =form.cleaned_data
   capital = cd['capital'],
   tax_rate = cd['tax_rate'],
   useage = projfin(request, capital, tax_rate)
   response_dict = {'capital' : capital, 'tax_rate' : tax_rate,
'useage' : useage}
   return render_to_response('textplusnumbers.html' , response_dict)
   else:
 form = FinanceTable(
  initial={'capital' : 1000, 'tax_rate' : .07}
  )

   return render_to_response('textplusnumbers.html' , {'form' : form})

def projfin(request, capital, tax_rate):
 useage = capital * tax_rate
 return useage









On Mon, Mar 19, 2012 at 1:10 PM, Rajeesh Nair wrote:

>
> Your FormClass expects all 3 fields to be optional (*required=False*).
> But your code in view always expects them to have integer values. And you
> end up multiplying values from two blank fields! Either you provide some
> default value to the fields or rewrite view to use 
> *form.cleaned_data.get*with a default value as 2nd argument to it.
>
>
> On Monday, March 19, 2012 9:11:27 PM UTC+5:30, bolivar4 wrote:
>
>>
>>
>> "unsupported operand type(s) for *: 'NoneType' and 'NoneType'"
>>
>>
>> class FinanceTable(forms.Form):
>>capital = forms.IntegerField(required=**False)
>>tax_rate = forms.DecimalField(required=**False)
>>useage = forms.IntegerField(required=**False)
>>
>  --
> 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/-/CFfpFTLoPSMJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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.



Need advice on admin models

2012-03-19 Thread django_noob
Hello all, 

I am just starting learning Django and managed to get a basic website 
working with a nice admin section. I am now facing a problem which I am not 
sure how to resolve. 

So I basically have 2 tables in my database: 
- Flat 
- PendingFlat 

The PendingFlat would be a subset of the Flat table. 

The website will offer the ability to a user to sell his flat. The website 
will ask only a few questions to the user such as the price and the 
location and store this information within the PendingFlat table. The admin 
can then go the admin section of the website, view all pending flats from 
the PendingFlat table and approve them as he wish. So I'd like to have an 
approve button next to each line of the records of the PendingFlat table. 
This button should then get the admin to the add view page of the Flat 
table with some prepopulated fields such as the location and the price. 

My first attempt was to do the following in the admin.py file: 
class PendingFlatAdmin(admin.ModelAdmin): 
def button(self, obj): 
return mark_safe('Approve'.format(obj=obj)) 
button.short_description = 'Approve' 
button.allow_tags = True 
list_display = ('id', 'button') 
admin.site.register(PendingFlat, PendingFlatAdmin) 

This will successfully get the admin to the add flat page with the rent 
being prepopulated. Unfortunately, this won't delete the PendingFlat entry 
once the admin has successfully added this flat to the database and it also 
makes it difficult to maintain when new attributes are being added to the 
table. Is there a nice way to achieve this? 

I understand that my choice of database structure might be wrong. It might 
be better to have a single table Flat which has a pending boolean field. 
But if I do this how can I mark certain felds as being optional (blank = 
True) when the pending field is set to True? 

Thanks, 
a noob who hopes to lose his noob status as soon as possible [image: :)]  

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



Question about threading a view[REPOSTED]

2012-03-19 Thread Arruda
*(I've created a topic like this a few minutes ago, but was using the old 
google groups, and now it's broken. So I created a new one using the new 
google groups).*
Hi, I'll try to explain the best I can my problem, and I don't know if
what I'm trying to archive is the best way to get where I want, but
here is it:
I want that a specific view to run in a new thread, ex:
* def foo(request):
   do_something_slow()
  return httpResponse*

But I DON'T want that a new thread is run inside the view, the view it
self should be runned in another thread, ex:
*
 def foo(request):
   t = thread(target=do_something_slow())
   t.daemon = True
   t.start()

  return httpResponse
*
This way when a user A access any page the site will load, even if a
user B is accessing the 'foo' view.
But the B user when access the view 'foo' will load it just a if if
was a normal view( will be slow and will render the response just
after do_something_slow() finished running).

I don't know if this is what I want, but I believe that there is
another way around:
when user B calls foo view, it will render to him a page with a JS(I
don't know JS either, so correct me if I'm talking nonsense) that say
its "Loading..."
And after the do_someting_slow() finished running if will change the
content of the page to whatever the result of "do_something_slow" was.

Thanks for the attention.

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



Custom template tag - share data

2012-03-19 Thread mikegolf
Hi,
lets say I want my templatetag to collect menu items from all the
rendered template pieces.

I thought of writing custom templatetag which would work as following:

this would be called in "sub-template"
{% register_menu_item "some item" "/someItem/view" %}

and finally the "main" template would call {% render_menu %}

the first command would simply add the (label, url) to the collection,
the second one would render all the collected items.

The problem is - where to keep the collected data? the RequestContext
passed is not always the same, even during processing the same request.

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



Re: Question about threading a view

2012-03-19 Thread Kurtis Mullins
Check out django-celery.

On Mon, Mar 19, 2012 at 1:52 PM, Felipe Arruda <
felipe.arruda.pon...@gmail.com> wrote:

> Hi, I'll try to explain the best I can my problem, and I don't know if
> what I'm trying to archive is the best way to get where I want, but
> here is it:
> I want that a specific view to run in a new thread, ex:
>  def foo(request):
>do_something_slow()
>   return httpResponse
>
> But I DON'T want that a new thread is run inside the view, the view it
> self should be runned in another thread, ex:
>
>  def foo(request):
>t = thread(target=do_something_slow())
>t.daemon = True
>t.start()
>
>   return httpResponse
>
> This way when a user A access any page the site will load, even if a
> user B is accessing the 'foo' view.
> But the B user when access the view 'foo' will load it just a if if
> was a normal view( will be slow and will render the response just
> after do_something_slow() finished running).
>
> I don't know if this is what I want, but I believe that there is
> another way around:
> when user B calls foo view, it will render to him a page with a JS(I
> don't know JS either, so correct me if I'm talking nonsense) that say
> its "Loading..."
> And after the do_someting_slow() finished running if will change the
> content of the page to whatever the result of "do_something_slow" was.
>
> Thanks for the attention.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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.



Question about threading a view

2012-03-19 Thread Felipe Arruda
Hi, I'll try to explain the best I can my problem, and I don't know if
what I'm trying to archive is the best way to get where I want, but
here is it:
I want that a specific view to run in a new thread, ex:
  def foo(request):
do_something_slow()
   return httpResponse

But I DON'T want that a new thread is run inside the view, the view it
self should be runned in another thread, ex:

  def foo(request):
t = thread(target=do_something_slow())
t.daemon = True
t.start()

   return httpResponse

This way when a user A access any page the site will load, even if a
user B is accessing the 'foo' view.
But the B user when access the view 'foo' will load it just a if if
was a normal view( will be slow and will render the response just
after do_something_slow() finished running).

I don't know if this is what I want, but I believe that there is
another way around:
when user B calls foo view, it will render to him a page with a JS(I
don't know JS either, so correct me if I'm talking nonsense) that say
its "Loading..."
And after the do_someting_slow() finished running if will change the
content of the page to whatever the result of "do_something_slow" was.

Thanks for the attention.

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



Re: problem with admin settings

2012-03-19 Thread Sophia
Of course I attach it, Thanks for helping Swaroop.

On Sunday, March 18, 2012 9:25:12 PM UTC-7, Swaroop Shankar wrote:
>
> Sophia,
> Could you please provide me with your settings.py file?
> On Mar 19, 2012 4:04 AM, "Sophia"  wrote:
>
>> Swaroop,
>>
>> I run sync.db this is what it shows after running sync.db :
>>
>> Creating tables ...
>> Installing custom SQL ...
>> Installing indexes ...
>> No fixtures found.
>>
>> Process finished with exit code 0
>>
>> without any error, but it still doesn't work, would you please help me 
>> with it, I really stuck :(
>>
>>
>> On Saturday, March 17, 2012 2:46:25 PM UTC-7, Swaroop Shankar wrote:
>>>
>>> Did you run the syncdb after enabling it? While doing a syncdb did you 
>>> encounter any errors? From the error it looks like django_session table 
>>> is not created.
>>>
>>> Thanks and Regards,
>>> Swaroop Shankar V
>>>
>>>
>>>
>>> On Sun, Mar 18, 2012 at 3:07 AM, Sophia wrote:
>>>
 Thank you for helping, I had enabled it. But I don't know what's wrong 
 with it!


 On Saturday, March 17, 2012 2:23:10 PM UTC-7, Swaroop Shankar wrote:
>
> Sophia,
> Please check if you have enabled the app 'django.contrib.sessions' in 
> your INSTALLED_APPS, if not do that and then do a syncdb, this issue 
> should 
> be resolved.
>
> Thanks and Regards,
> Swaroop Shankar V
>
>
>
> On Sun, Mar 18, 2012 at 2:41 AM, Sophia wrote:
>
>> Hi all,
>>
>> I'm trying to set my admin settings so I will get the web page asking 
>> for user name and password, I did all the settings that is needed and 
>> mentioned in the online django book(chapter6), but the page keep giving 
>> me 
>> this error :
>>
>> Exception Type: DatabaseError  Exception Value: 
>>
>> no such table: django_session
>>
>>
>> this my settings.py what could be wrong with my code?
>>
>> DATABASES = {
>> 'default': {
>> 'ENGINE': 'django.db.backends.sqlite3',
>> 'NAME': 'test.db',  
>> 'USER': '',  
>> 'PASSWORD': '',  
>> 'HOST': '',  
>> 'PORT': '',  
>> }
>> } 
>>
>> Thanks in advance
>> Sophia
>>
>> -- 
>> 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/
>> **ms**g/django-users/-/**huWdNc8xUycJ
>> .
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscribe@**googl**egroups.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/-/DkRv66Jz-**lYJ
 .

 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
 .

>>>
>>>
>> On Saturday, March 17, 2012 2:46:25 PM UTC-7, Swaroop Shankar wrote:
>>>
>>> Did you run the syncdb after enabling it? While doing a syncdb did you 
>>> encounter any errors? From the error it looks like django_session table 
>>> is not created.
>>>
>>> Thanks and Regards,
>>> Swaroop Shankar V
>>>
>>>
>>>
>>> On Sun, Mar 18, 2012 at 3:07 AM, Sophia wrote:
>>>
 Thank you for helping, I had enabled it. But I don't know what's wrong 
 with it!


 On Saturday, March 17, 2012 2:23:10 PM UTC-7, Swaroop Shankar wrote:
>
> Sophia,
> Please check if you have enabled the app 'django.contrib.sessions' in 
> your INSTALLED_APPS, if not do that and then do a syncdb, this issue 
> should 
> be resolved.
>
> Thanks and Regards,
> Swaroop Shankar V
>
>
>
> On Sun, Mar 18, 2012 at 2:41 AM, Sophia wrote:
>
>> Hi all,
>>
>> I'm trying to set my admin settings so I will get the web page asking 
>> for user name and password, I did all the settings that is needed and 
>> mentioned in the online django book(chapter6), but the page keep giving 
>> me 
>> this error :
>>
>> Exception Type: DatabaseError  Exception Value: 
>>
>> no such table: django_session
>>
>>
>> th

Re: filtered admin change-list

2012-03-19 Thread Rajeesh Nair

Add a field on your model to identify the user who created each instance & 
then extend your model_admin's queryset method to filter queryset by the 
user.

On Sunday, March 18, 2012 4:37:43 AM UTC+5:30, omerd wrote:
>
> every user will see only the instances that he'd created. Of 
> course, this user doesn't have permissions to view or edit instances 
> of other users. 
>

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



Re: Problem with tuncated Admin pages in apache + mod_fcgid

2012-03-19 Thread Jani Tiainen
Hi,

Since we use same setup except one part: we use mod_wsgi instead of
mod_fcgi.

(Since wsgi is considered to be defacto protocol). Could you try to use it?


On Mon, Mar 19, 2012 at 7:04 PM, Another Django Newbie <
another.xxx.u...@gmail.com> wrote:

>
>
> On Thursday, March 15, 2012 1:05:53 PM UTC, Another Django Newbie wrote:
>>
>> Hi,
>>
>> I've just started playing with django this week and was following the
>> example in the Django Book.
>>
>> I created an example of my own, based on the models.py in the book and
>> tested it with manage.py runserver. All worked OK, but when I try it
>> in apache one of my admin pages is truncated - a number of fields are
>> left off and there is no Save button. The exact number of fields
>> truncated depends on whether I use Add from the main page or from the
>> Add page of another field (so that the affected page is a pop-up)
>>
>> Apache 2.4.1
>> mod_fcgid 2.3.6
>> django 1.3.1
>> Python 2.7.2
>> cx-Oracle 5.1.1
>>
>> Has anyone seen this behaviour? I've looked in apache and django logs
>> but don't see anything recorded when the page loads. Any ideas greatly
>> appreciated.
>>
>> Thanks.
>
>
> Bump  I've had no luck with this and would still appreciate some
> pointers! I've tried re-arranging the order of statements in my model code
> without any improvement.
>
>
>
>
>
>
> --
> 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/-/asZ5sigBBuQJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: starting django

2012-03-19 Thread Willy
If you're learning Django and Python I think you're missing some
prerequisite knowledge. I would really suggest you learn how to
install both Python and Django on your own as well as working through
this tutorial on Python so that you have at least a basic
understanding of the language. http://docs.python.org/tutorial/index.html

That way you're better prepared to learn Django as Django is just
Python code.

On Mar 19, 2:00 am, Kikozzza  wrote:
> I'm starting learning django? that's why I ask my friend to install me
> python and all distrib for my projects.
> I have very silly question- how can I discover what version of python
> and  Django i get?
> he installs me ubuntu 10

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Running manage.py commands in Windows Power Shell

2012-03-19 Thread Jani Tiainen
Hi,

I (and all my other teammates) are have been developing in windows with
standard Python (+ Django + lot of other interesting stuff) in WinXP,
Vista, Win7.

To keep everyone on same line, we use TCC/LE (Take Command Console/LE)
which is augmented CMD. Has lot of nice features. And it's free.

On Sun, Mar 18, 2012 at 6:32 PM, Dennis Lee Bieber wrote:

> On Sun, 18 Mar 2012 02:14:15 -0700 (PDT), orschiro
>  declaimed the following in
> gmane.comp.python.django.user:
>
> > Is this the case for the ActivePython package?
>
> Since I don't have a non-ActiveState install anywhere to compare
> against...
>
> -=-=-=-=-=-
> Windows PowerShell
> Copyright (C) 2009 Microsoft Corporation. All rights reserved.
>
> PS E:\UserData\Wulfraed\My Documents> ./test.py
> test
>
> PS E:\UserData\Wulfraed\My Documents> python test.py
> test
>
> PS E:\UserData\Wulfraed\My Documents> .\test.py
> test
>
> PS E:\UserData\Wulfraed\My Documents>
>
> PS E:\UserData\Wulfraed\My Documents> get-host
>
>
> Name : ConsoleHost
> Version  : 2.0
> InstanceId   : 253c9466-5541-4737-b974-5b376fd39caa
> UI   :
> System.Management.Automation.Internal.Host.InternalHostUserInterface
> CurrentCulture   : en-US
> CurrentUICulture : en-US
> PrivateData  : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
> IsRunspacePushed : False
> Runspace : System.Management.Automation.Runspaces.LocalRunspace
>
>
>
> PS E:\UserData\Wulfraed\My Documents>
> -=-=-=-=-=-
>
> WinXP (on which I had to download PowerShell as it isn't standard),
> running from a semi-privileged (so-called "power user") account.
> --
>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.



Re: New way to run your Django projects

2012-03-19 Thread Alexander
On Mar 19, 11:00 am, Roberto De Ioris  wrote:
> Your project is really funny, but you will need to fight with two factors:
>
> few users/developers understand non-blocking/async programming (albeit a lot 
> of them use, and blindly suggest, such technologies)
>
> webservers support for multipexing fastcgi requests is practically 
> non-existent or buggy, on which webserver you have tested your project ?

Roberto,

Thank you for cheering me up : ) Like I said gevent-fastcgi is not
suitable for every project and I don't expect people switching to it
en masse but those who needs what it provides should benefit from
using it. I know that mainstream Web-servers do not support FastCGI
multiplexing or support for it is buggy. That is sad since it doesn't
cost much to implement and it could be a big deal in fight against
C10K problem. I saw something like "there are not many FastCGI servers
that support multiplexing so why bother to implement that in our Web
server" while I was looking for Web-servers that do multiplexing.
Hopefully, Web-server developers will have little less excuses to not
implement it.

I haven't tested FastCGI multiplexing feature because I couldn't find
Web-server that supports it out-of-the-box. However, I found reference
to alternative Nginx FastCGI module that supposedly designed to
support multiplexing (https://github.com/rsms/afcgi). Also Cherokee
Web-server had another version of FastCGI module with connection
multiplexing (http://code.google.com/p/cherokee/issues/detail?id=714).
Rumors have it Zeus Web-server has FastCGI multiplexing feature but
it's not available for free.

Alex

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



Caching and module import question

2012-03-19 Thread Jeff Heard
Question 1: Would this work with views, or for that matter, anything else
in Django, assuming you're using a WSGI server like gunicorn?
http://code.activestate.com/recipes/578078/  Specifically, will it cache
across HTTP requests, or not?

I guess the one thing I don't understand well in Django is when modules are
re-loaded.  I know it's different in a "full-fledged" setup vs. the test
server, but is there a rule one can follow? Is it different on WSGI vs.
FastCGI? And finally, if I delete a module from sys.modules, does that
effectively delete it from the cache or is there something else I need to
do to make sure it's reloaded the next time someone makes a request?  I
would assume that deleting the module from sys.modules would only delete it
from one worker process.

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

2012-03-19 Thread Rajeesh Nair

Your FormClass expects all 3 fields to be optional (*required=False*). But 
your code in view always expects them to have integer values. And you end 
up multiplying values from two blank fields! Either you provide some 
default value to the fields or rewrite view to use *form.cleaned_data.get*with 
a default value as 2nd argument to it.

On Monday, March 19, 2012 9:11:27 PM UTC+5:30, bolivar4 wrote:

>  
>
> "unsupported operand type(s) for *: 'NoneType' and 'NoneType'"
>
>  
> class FinanceTable(forms.Form):
>capital = forms.IntegerField(required=False)
>tax_rate = forms.DecimalField(required=False)
>useage = forms.IntegerField(required=False)
>

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

2012-03-19 Thread Tim Ney
Thank you for responding, this is a vexing problem.
I know the urs.py is fine, as the the form html code I posted
is part of an .html, largely static html, which renders to the screen fine.
The form fields are also showing up in the rendered page, and numbers can be
entered, when the submit button is clicked I get the exception

Did I not understand your question, I am new at this.



On Mon, Mar 19, 2012 at 12:54 PM, Joel Goldstick
wrote:

> On Mon, Mar 19, 2012 at 11:41 AM, bolivar4  wrote:
> > Want to present users a form in which numbers are entered, then
> manipulated
> > in a view and a calculated value is returned to the screen.
> > After looking in the the Django book around the net this is what I have
> > come, (it doesn't work) shows below.  So far, the three fields setup in
> > forms.py render to the secreen, that is all I'm getting.
> >
> >
> >
> > I am getting this error in the django 404 exception page: "unsupported
> > operand type(s) for *: 'NoneType' and 'NoneType'"
> >
> >
> > It is purposely a  simple exercise, more interested  in technique of
> doing
> > this so, I know this can be done in javascript, but I want to do this
> with
> > python/django.
> > Thank you to anyone who can help me out, this has been a problem all
> > weekend.
> >
> > forms.py:
> >
> > from django import forms
> >
> > class FinanceTable(forms.Form):
> >capital = forms.IntegerField(required=False)
> >tax_rate = forms.DecimalField(required=False)
> >useage = forms.IntegerField(required=False)
> >
> > views.py:
> >
> > from django.shortcuts import render_to_response
> >
> > def  calculation(request):
> >"""view that sets up form calculation"""
> >if request.method == 'POST':
> > form  = FinanceTable(request.POST)
> > if form.is_valid():
> >  capital = form.cleaned_data['capital']
> >   tax_rate = form.cleaned_data['tax_rate']
> >   useage = form.cleaned_data['capital'] *
> > form.cleaned_data['tax_rate']
> >   response_dict = {'capital' : capital, 'tax_rate'  :
> > tax_rate, 'useage' : useage}
> >   return render_to_response('focus_areas.html',
> > response_dict)
> > else:
> >   form = FinanceTable(
> >  initial={'capital' : 1000, tax_rate : .07}
> >)
> > return render_to_response('focus_areas.html', {'form' : form})
> >
> >
> > html in template:
> >   
> >   
> >   {{ form.as_table }}
> >   
> >   
> >   
> >
> >
> > Any help ios much appreciated.
>
> What does your urls.py file look like.  If you are getting 404 then it
> may not be finding your view.
> --
> 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.
>
>

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



Re: Problem with tuncated Admin pages in apache + mod_fcgid

2012-03-19 Thread Another Django Newbie


On Thursday, March 15, 2012 1:05:53 PM UTC, Another Django Newbie wrote:
>
> Hi, 
>
> I've just started playing with django this week and was following the 
> example in the Django Book. 
>
> I created an example of my own, based on the models.py in the book and 
> tested it with manage.py runserver. All worked OK, but when I try it 
> in apache one of my admin pages is truncated - a number of fields are 
> left off and there is no Save button. The exact number of fields 
> truncated depends on whether I use Add from the main page or from the 
> Add page of another field (so that the affected page is a pop-up) 
>
> Apache 2.4.1 
> mod_fcgid 2.3.6 
> django 1.3.1 
> Python 2.7.2 
> cx-Oracle 5.1.1 
>
> Has anyone seen this behaviour? I've looked in apache and django logs 
> but don't see anything recorded when the page loads. Any ideas greatly 
> appreciated. 
>
> Thanks.


Bump  I've had no luck with this and would still appreciate some 
pointers! I've tried re-arranging the order of statements in my model code 
without any improvement.




 

-- 
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/-/asZ5sigBBuQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Models, field like a list

2012-03-19 Thread Jani Tiainen
Hi,

All depends on a few factors will simple foreign key or many to many be
correct solution.

If single model B can be assigned only on a single model A then foreign key
from B to A is right choice. But if
requirement is that model B can be assigned multiple times to model A then
it's definitely many to many.

And that's pretty much how far you can get with traditional RDBMS. You can
easily write convenience
methods/properties on a model class to cut out few corners if needed.

Of course you can go in many other ways, for example storing primary key
values as a string list, and then parsing it.
It's just not good thing to do. You can easily end up with data integrity
problems like what should happen if you delete
entity from model B? or your list in model A doesn't find all entities in
model B.

On Mon, Mar 19, 2012 at 5:19 PM, Dmitry Zimnukhov wrote:

> Hi,
> If you want to retrieve list of related models with one to many
> relation, you can do it with related manager, without adding a field
> to model A.
> So, if you have model B like this:
>
> class B(models.Model):
>  a = models.ForeignKey(A)
>
> you can get related B objects like this: a_instance.b_set.all()
>
> But if you want to have an array field in your model (so that array
> data will be stored in the same table that stores model data), your db
> backend must support it and you must extend Django to support this
> functionality. That's probably not what you want.
>
> 2012/3/19 Xavier Pegenaute :
> > Hi,
> >
> > I was thinking to use a field like a list [] of another object. But I
> have
> > no a clear idea which field type should I use. Any idea?
> >
> > Ex:
> > class A:
> >bClasses = models.() # list of Foreign keys from B
> >
> >
> > I am not looking for a ManyToMany Field.
> >
> > Thanks,
> > Xavi
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, 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: calculated form field

2012-03-19 Thread Joel Goldstick
On Mon, Mar 19, 2012 at 11:41 AM, bolivar4  wrote:
> Want to present users a form in which numbers are entered, then manipulated
> in a view and a calculated value is returned to the screen.
> After looking in the the Django book around the net this is what I have
> come, (it doesn't work) shows below.  So far, the three fields setup in
> forms.py render to the secreen, that is all I'm getting.
>
>
>
> I am getting this error in the django 404 exception page: "unsupported
> operand type(s) for *: 'NoneType' and 'NoneType'"
>
>
> It is purposely a  simple exercise, more interested  in technique of doing
> this so, I know this can be done in javascript, but I want to do this with
> python/django.
> Thank you to anyone who can help me out, this has been a problem all
> weekend.
>
> forms.py:
>
> from django import forms
>
> class FinanceTable(forms.Form):
>    capital = forms.IntegerField(required=False)
>    tax_rate = forms.DecimalField(required=False)
>    useage = forms.IntegerField(required=False)
>
> views.py:
>
> from django.shortcuts import render_to_response
>
> def  calculation(request):
>    """view that sets up form calculation"""
>    if request.method == 'POST':
>     form  = FinanceTable(request.POST)
>     if form.is_valid():
>  capital = form.cleaned_data['capital']
>   tax_rate = form.cleaned_data['tax_rate']
>   useage = form.cleaned_data['capital'] *
> form.cleaned_data['tax_rate']
>   response_dict = {'capital' : capital, 'tax_rate'  :
> tax_rate, 'useage' : useage}
>   return render_to_response('focus_areas.html',
> response_dict)
> else:
>   form = FinanceTable(
>  initial={'capital' : 1000, tax_rate : .07}
>    )
> return render_to_response('focus_areas.html', {'form' : form})
>
>
> html in template:
>   
>   
>   {{ form.as_table }}
>   
>   
>   
>
>
> Any help ios much appreciated.

What does your urls.py file look like.  If you are getting 404 then it
may not be finding your view.
-- 
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: Django/Python version compatibility

2012-03-19 Thread Joel Goldstick
On Mon, Mar 19, 2012 at 11:41 AM, Shawn Milochik  wrote:
> Django won't support 3.x for a while. You can't go wrong with 2.7 for now.
>
> https://www.djangoproject.com/weblog/2012/mar/13/py3k/
>
> Shawn
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

So your other choice is whether to go with django 1.3 or the new 1.4
being released some time in the coming days.  Probably best to go with
1.4 since they keep making it better, but there are differences
between the new version and the old version's way of setting up
directories, so beware that third party tutorials will have to be
tweeked with to get going in 1.4

-- 
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: New way to run your Django projects

2012-03-19 Thread Kurtis Mullins
Sorry, I didn't mean to sound like I was putting down your application. I
think it's a great thing to develop more applications. I can't wait to see
the progress you make :)

I was just trying to clarify that these days, stock Nginx does provide WSGI
in its default configuration. Of course, I didn't think about specific
distributions offering alternative or older configurations of Nginx.
Running 'sudo apt-get install nginx' is a bit easier than './configure;
make; sudo make install' -- especially with the distribution's
initialization scripts -- but I'm a bit old school when it comes to that.

One thing I can say about FastCGI (the reason I don't develop with it) is
that it's licensed under the OpenMarket License which is, to my knowledge,
not compatible with GPL. However, that's the libraries and not the raw
protocol itself.

Good luck and happy hacking!

On Mon, Mar 19, 2012 at 10:46 AM, Alexander wrote:

> Kurtis,
>
> There is nothing wrong with using uwsgi protocol instead of FastCGI
> but you still have to run uWSGI server and it doesn't fit "simply
> using nginx" description. And I wouldn't call it "out of the box"
> either if I'd have to rebuild Nginx instead of using one shipped with
> my Linux distro (Debian Squeeze has Nginx with uwsgi module in
> backports and uWSGI is only available in unstable branch).
>
> I didn't say gevent-fastcgi is best way to run WSGI application.
>
> Alex
>
> On Mar 19, 10:08 am, Kurtis Mullins  wrote:
> > > I'm not sure what you meant by "simply using nginx" since as far as I
> > > know it doesn't have standard WSGI module.
> >
> > I use Nginx w/ WSGI (Django running under uWSGI, communicating w/ WSGI
> > Protocol) out of the box. No special modules or anything were installed
> --
> > just a quick download and compile of the source package.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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.



calculated form field

2012-03-19 Thread bolivar4
Want to present users a form in which numbers are entered, then manipulated 
in a view and a calculated value is returned to the screen.
After looking in the the Django book around the net this is what I have 
come, (it doesn't work) shows below.  So far, the three fields setup in 
forms.py render to the secreen, that is all I'm getting. 

 

I am getting this error in the django 404 exception page: "unsupported operand 
type(s) for *: 'NoneType' and 'NoneType'"

 
It is purposely a  simple exercise, more interested  in technique of doing 
this so, I know this can be done in javascript, but I want to do this with 
python/django.
Thank you to anyone who can help me out, this has been a problem all 
weekend.
 
forms.py:
 
from django import forms
 
class FinanceTable(forms.Form):
   capital = forms.IntegerField(required=False)
   tax_rate = forms.DecimalField(required=False)
   useage = forms.IntegerField(required=False)
 
views.py:
 
from django.shortcuts import render_to_response
 
def  calculation(request):
   """view that sets up form calculation"""
   if request.method == 'POST':
form  = FinanceTable(request.POST)
if form.is_valid():
 capital = form.cleaned_data['capital']
  tax_rate = form.cleaned_data['tax_rate']
  useage = form.cleaned_data['capital'] * 
form.cleaned_data['tax_rate']  
  response_dict = {'capital' : capital, 'tax_rate'  : 
tax_rate, 'useage' : useage}
  return render_to_response('focus_areas.html', 
response_dict)
else:
  form = FinanceTable(
 initial={'capital' : 1000, tax_rate : .07}
   )
return render_to_response('focus_areas.html', {'form' : form}) 
 
 
html in template:
  
  
  {{ form.as_table }}
  
  
  
 
 
Any help ios much 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/-/3yrkavizpWQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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/Python version compatibility

2012-03-19 Thread Shawn Milochik

Django won't support 3.x for a while. You can't go wrong with 2.7 for now.

https://www.djangoproject.com/weblog/2012/mar/13/py3k/

Shawn

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



Django/Python version compatibility

2012-03-19 Thread Chiproller
I am just learning Python and plan to use it for web development so I
will be using Django.  Python version 2.7 was pre-installed on my
macbook and I'm wondering if I installed the latest 3.* version would
Django not work at all when I get to the point of learning Django?

Reason I ask, is that I'm using a number of resources to learn Python
(Learning Python, Programming Python, Learn Python the Hard Way) and
some of these books use 3.0 code.

Jim

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

2012-03-19 Thread Bolang

On 03/19/2012 08:28 PM, Alexander wrote:

Hi Bolang,

I'm not sure what you meant by "simply using nginx" since as far as I
know it doesn't have standard WSGI module. I hope you're not talking
about running WSGI application as CGI script, do you?


Hi Alexander,
Thanks for your long response, really apreciate it.
Actually, i'm just django & python beginner, although already have a few 
simple sites in production.


And actually i'm not really understand wsgi, uwsgi, etc.
I use nginx because AFAIK it great on serving static files and as a proxy.
I use gunicorn when i need multiple process.

When will i need your gevent-fastcgi? Or which types of applications 
that really need your gevent-fastcgi. From your answer, one of them is 
long-polling webapp and webapp with thousand of simultaneous connections.

As a newbie, i think i will not build that kind of advanced apps now.

Thanks



As to comparing Gunicorn to gevent-fastcgi Gunocorn is HTTP server and
gevent-fastcg is FastCGI one. FastCGI can run over UNIX domain
sockets, it can multiplex requests using single connection. That could
be deal-breaker when application is using long-polling requests and
there are thousands of clients that can be accessing it
simultaneously. Beside HTTP is not well suited for communication
between frontend and backend (just recall famous need to fix
hostname:port in backend server responses because backend server has
no way to get access to original HTTP-request and it might not even
know that there is something that makes request on behalf of client
browser). There is no such problems in FastCGI protocol because it was
specifically designed for frontend/backend communication.

Gevent-fastcgi is not well suited for any type of applications. The
application should not block since everything is run in the same
thread (there are greenlets that are used in place of thread to avoid
GIL). Not all databases and other external resources can be used in
non-blocking mode. Luckily PostgreSQL, MySQL, Memcache are those that
have adapters/hooks for making them work well in non-blocking manner.

Alex

Bolang wrote:

Hi Alexander,
What is the advantage of using gevent-fastcgi instead of simply using
nginx and maybe with gunicorn?




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

2012-03-19 Thread Carlos Daniel Ruvalcaba Valenzuela
I think it is an interesting project, many may say its pointless given
the "wealth" of wsgi servers, but I think there is always space to
explore more, who says this project can't be faster than many of
today's servers?, or who says there wont be anything useful out of
this project even if is not really popular as gunicorn or uwsgi? I
imagine uwsgi started this way against the "mainstream" apache
mod_wsgi, but now uwsgi has more features, its fast and it has been
adopted as a sort of defacto wsgi module by nginx, who says a new
project can't be done?

Keep it up, I will personally give it a try!

Regards,
Carlos Daniel Ruvalcaba Valenzuela

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

2012-03-19 Thread Dmitry Zimnukhov
Hi,
If you want to retrieve list of related models with one to many
relation, you can do it with related manager, without adding a field
to model A.
So, if you have model B like this:

class B(models.Model):
 a = models.ForeignKey(A)

you can get related B objects like this: a_instance.b_set.all()

But if you want to have an array field in your model (so that array
data will be stored in the same table that stores model data), your db
backend must support it and you must extend Django to support this
functionality. That's probably not what you want.

2012/3/19 Xavier Pegenaute :
> Hi,
>
> I was thinking to use a field like a list [] of another object. But I have
> no a clear idea which field type should I use. Any idea?
>
> Ex:
> class A:
>    bClasses = models.() # list of Foreign keys from B
>
>
> I am not looking for a ManyToMany Field.
>
> Thanks,
> Xavi
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: New way to run your Django projects

2012-03-19 Thread Roberto De Ioris

Il giorno 19/mar/2012, alle ore 15:46, Alexander ha scritto:

> Kurtis,
> 
> There is nothing wrong with using uwsgi protocol instead of FastCGI
> but you still have to run uWSGI server and it doesn't fit "simply
> using nginx" description. And I wouldn't call it "out of the box"
> either if I'd have to rebuild Nginx instead of using one shipped with
> my Linux distro (Debian Squeeze has Nginx with uwsgi module in
> backports and uWSGI is only available in unstable branch).
> 
> I didn't say gevent-fastcgi is best way to run WSGI application.
> 

Yes, but when you release a software, be prepared to answer the most useless, 
provocative
and rageous questions :) Expecially if your project is pretty 'unique'.

You are lucky (for now), the questions you got are all 'gentle' :)

Your project is really funny, but you will need to fight with two factors:

few users/developers understand non-blocking/async programming (albeit a lot of 
them use, and blindly suggest, such technologies)

webservers support for multipexing fastcgi requests is practically non-existent 
or buggy, on which webserver you have tested your project ?

In addition to this, Django is not the kind of framework/platform you can - 
easily - adapt to non-blocking/async paradigm :(

--
Roberto De Ioris
http://unbit.it
JID: robe...@jabber.unbit.it

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



Models, field like a list

2012-03-19 Thread Xavier Pegenaute

Hi,

I was thinking to use a field like a list [] of another object. But I 
have no a clear idea which field type should I use. Any idea?


Ex:
class A:
bClasses = models.() # list of Foreign keys from B


I am not looking for a ManyToMany Field.

Thanks,
Xavi

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

2012-03-19 Thread Alexander
Kurtis,

There is nothing wrong with using uwsgi protocol instead of FastCGI
but you still have to run uWSGI server and it doesn't fit "simply
using nginx" description. And I wouldn't call it "out of the box"
either if I'd have to rebuild Nginx instead of using one shipped with
my Linux distro (Debian Squeeze has Nginx with uwsgi module in
backports and uWSGI is only available in unstable branch).

I didn't say gevent-fastcgi is best way to run WSGI application.

Alex

On Mar 19, 10:08 am, Kurtis Mullins  wrote:
> > I'm not sure what you meant by "simply using nginx" since as far as I
> > know it doesn't have standard WSGI module.
>
> I use Nginx w/ WSGI (Django running under uWSGI, communicating w/ WSGI
> Protocol) out of the box. No special modules or anything were installed --
> just a quick download and compile of the source package.

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

2012-03-19 Thread Kurtis Mullins
People will probably need more information to help you. For example, what
are the errors you are seeing?

On Mon, Mar 19, 2012 at 9:44 AM, Enrique Juan de Dios
wrote:

> Hello Everyone.
> I tried to send email with the email settings shown below, but doesn't
> work.
>
> EMAIL_HOST = 'smtpout.secureserver.net'
> EMAIL_HOST_USER = 'staff@**.com'
> EMAIL_HOST_PASSWORD = ''
> DEFAULT_FROM_EMAIL = 'staff@*.com'
> SERVER_EMAIL = 'staff@*.com'
> EMAIL_PORT = 465
> EMAIL_USE_TLS = True
>
> Can anyone help me.
> Thanks.
> JD
>
> --
> 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/-/Kk3nzHbMTQgJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: New way to run your Django projects

2012-03-19 Thread Kurtis Mullins
>
> I'm not sure what you meant by "simply using nginx" since as far as I
> know it doesn't have standard WSGI module.


I use Nginx w/ WSGI (Django running under uWSGI, communicating w/ WSGI
Protocol) out of the box. No special modules or anything were installed --
just a quick download and compile of the source package.

On Mon, Mar 19, 2012 at 9:28 AM, Alexander wrote:

> Hi Bolang,
>
> I'm not sure what you meant by "simply using nginx" since as far as I
> know it doesn't have standard WSGI module. I hope you're not talking
> about running WSGI application as CGI script, do you?
>
> As to comparing Gunicorn to gevent-fastcgi Gunocorn is HTTP server and
> gevent-fastcg is FastCGI one. FastCGI can run over UNIX domain
> sockets, it can multiplex requests using single connection. That could
> be deal-breaker when application is using long-polling requests and
> there are thousands of clients that can be accessing it
> simultaneously. Beside HTTP is not well suited for communication
> between frontend and backend (just recall famous need to fix
> hostname:port in backend server responses because backend server has
> no way to get access to original HTTP-request and it might not even
> know that there is something that makes request on behalf of client
> browser). There is no such problems in FastCGI protocol because it was
> specifically designed for frontend/backend communication.
>
> Gevent-fastcgi is not well suited for any type of applications. The
> application should not block since everything is run in the same
> thread (there are greenlets that are used in place of thread to avoid
> GIL). Not all databases and other external resources can be used in
> non-blocking mode. Luckily PostgreSQL, MySQL, Memcache are those that
> have adapters/hooks for making them work well in non-blocking manner.
>
> Alex
>
> Bolang wrote:
> > Hi Alexander,
> > What is the advantage of using gevent-fastcgi instead of simply using
> > nginx and maybe with gunicorn?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: Combining two model fields into one

2012-03-19 Thread Kurtis Mullins
Sorry, I kind of left you some misleading information.

The LocalFlavor stuff are *Form* fields (not Model Fields). And, they are
specific to certain countries so it may not work for you if your
application supports multiple countries. It could be a good starting point
for your own custom form field, though. They do include telephone numbers.
Judging by the django developer's choice to put that logic in Form Fields
instead of Model Fields, it may be a good idea (or at least easier) to
follow their lead on doing it that way.

On Mon, Mar 19, 2012 at 9:49 AM, Kurtis Mullins wrote:

> Personally, I would just create a custom Form for that validation logic
> then store the number in some generic Model Field (like IntegerField). You
> can write a method in your model to format that integer as a telephone
> number for display purposes using __string__ or other similar methods. Just
> convert to a unicode object and go right-to-left, adding
> hyphenation, parenthesis, etc... as needed. Also, check out the Model
> Fields LocalFlavor stuff, there *may* be a telephone number field already?
> I know there are address fields. I'd look for you, but I got to get back to
> work :/ Good luck!
>
> https://docs.djangoproject.com/en/1.3/ref/contrib/localflavor/
>
>
> On Mon, Mar 19, 2012 at 9:41 AM, BGMaster  wrote:
>
>> That looks like it could work. The problem I'm having is tying into a
>> ModelForm. I want to create something basically to the effect of:
>>
>> phoneNumber = phoneNumber1+phoneNumber2
>>
>> Here, phoneNumber1 and phoneNumber2 are the first 3 and last 4 digits
>> of a user's phone number. I want them input as separate fields for
>> sake of readability and then want to combine them into one model for
>> searchability in the database. Do you have an example of
>> MultiValueField? The django documentation isn't very clear on it.
>> Here's what I've been trying:
>>
>>  class launchForm(ModelForm):
>>  phoneNumber = forms.MultiValueField(fields=[phoneNumber1(),
>> phoneNumber2()])
>>
>>  class Meta:
>>model = potentialUser
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, 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: Combining two model fields into one

2012-03-19 Thread Kurtis Mullins
Personally, I would just create a custom Form for that validation logic
then store the number in some generic Model Field (like IntegerField). You
can write a method in your model to format that integer as a telephone
number for display purposes using __string__ or other similar methods. Just
convert to a unicode object and go right-to-left, adding
hyphenation, parenthesis, etc... as needed. Also, check out the Model
Fields LocalFlavor stuff, there *may* be a telephone number field already?
I know there are address fields. I'd look for you, but I got to get back to
work :/ Good luck!

https://docs.djangoproject.com/en/1.3/ref/contrib/localflavor/

On Mon, Mar 19, 2012 at 9:41 AM, BGMaster  wrote:

> That looks like it could work. The problem I'm having is tying into a
> ModelForm. I want to create something basically to the effect of:
>
> phoneNumber = phoneNumber1+phoneNumber2
>
> Here, phoneNumber1 and phoneNumber2 are the first 3 and last 4 digits
> of a user's phone number. I want them input as separate fields for
> sake of readability and then want to combine them into one model for
> searchability in the database. Do you have an example of
> MultiValueField? The django documentation isn't very clear on it.
> Here's what I've been trying:
>
>  class launchForm(ModelForm):
>  phoneNumber = forms.MultiValueField(fields=[phoneNumber1(),
> phoneNumber2()])
>
>  class Meta:
>model = potentialUser
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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.



Send SMTP Email Through GoDaddy

2012-03-19 Thread Enrique Juan de Dios
Hello Everyone.
I tried to send email with the email settings shown below, but doesn't work.

EMAIL_HOST = 'smtpout.secureserver.net'
EMAIL_HOST_USER = 'staff@**.com'
EMAIL_HOST_PASSWORD = ''
DEFAULT_FROM_EMAIL = 'staff@*.com'
SERVER_EMAIL = 'staff@*.com'
EMAIL_PORT = 465 
EMAIL_USE_TLS = True

Can anyone help me.
Thanks.
JD

-- 
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/-/Kk3nzHbMTQgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: Combining two model fields into one

2012-03-19 Thread BGMaster
That looks like it could work. The problem I'm having is tying into a
ModelForm. I want to create something basically to the effect of:

 phoneNumber = phoneNumber1+phoneNumber2

Here, phoneNumber1 and phoneNumber2 are the first 3 and last 4 digits
of a user's phone number. I want them input as separate fields for
sake of readability and then want to combine them into one model for
searchability in the database. Do you have an example of
MultiValueField? The django documentation isn't very clear on it.
Here's what I've been trying:

  class launchForm(ModelForm):
  phoneNumber = forms.MultiValueField(fields=[phoneNumber1(),
phoneNumber2()])

  class Meta:
model = potentialUser

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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 setting up website with mysql as backend

2012-03-19 Thread Swaroop Shankar V
Hello Clifford,
It was really nice of you to provide an insight into the non strict mode. I
agree to what you said regarding the length of the field. I was developing
the project using sqlite and since it was ready to go live i wanted to test
it using mysql in my local system. When i ran syncdb i was getting the
above said error and just for the sake of testing i changed the mode to non
strict. Am not planning the same for my production server. Once again
thanks a lot for your input. Cheers.

Thanks and Regards,

Swaroop Shankar V



On Mon, Mar 19, 2012 at 2:22 AM, CLIFFORD ILKAY
wrote:

> On 03/17/2012 04:49 PM, Swaroop Shankar V wrote:
>
>> Hello All,
>> I was developing a website and the development was all done using sqlite
>> database. Now the development is almost complete so i need to test the
>> site using mysql. When i did a syncdb on a fresh database i got the
>> following error:
>>
> [snip]
>
>  _mysql_exceptions.Warning: Data truncated for column 'name' at row 1
>>
>> As you can see its a mysql warning since i had changed mysql mode to non
>> strict.
>>
>
> Hello,
>
> Others have already explained why this happened. Let me add that you
> should not run MySQL in non-strict mode. Django is actually saving you from
> creating junk data in this case but that would not necessarily be the case
> if you were to do insert or update operations on that same database with
> something other than Django.
>
> MySQL used to have a "feature", which I considered a bug, whereby it would
> happily accept a string longer than the width of the column in which that
> data was to be stored and not even mention that it had truncated your
> string to fit into that particular column.
>
> Recent versions of MySQL allow you to set the database to non-strict mode
> whereby it will still allow you to insert a string longer than the width of
> a column but at least, it will generate a warning message. Older versions
> would just silently truncate. Either scenario is unacceptable in a
> database. Why would you want the database to tell you after-the-fact, "Oh,
> by the way, I just screwed up your data." after-the-fact? The first job of
> a database should be to protect data integrity so if you're attempting to
> insert 51 characters into a varchar(50) column, it should not accept it
> under any circumstances and throw an exception.
>
> The MySQL docs  *html >,
> which I've quoted below, explains this.
>
> ###
>TRADITIONAL
>
>Make MySQL behave like a “traditional” SQL database system. A simple
> description of this mode is “give an error instead of a warning” when
> inserting an incorrect value into a column.
>Note
>
>The INSERT/UPDATE aborts as soon as the error is noticed. This may not
> be what you want if you are using a nontransactional storage engine,
> because data changes made prior to the error may not be rolled back,
> resulting in a “partially done” update. (Added in MySQL 5.0.2)
>
> When this manual refers to “strict mode,” it means a mode where at least
> one of STRICT_TRANS_TABLES or STRICT_ALL_TABLES is enabled.
> ###
> --
> Regards,
>
> Clifford Ilkay
> Dinamis
> 1419-3266 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+unsubscribe@**
> googlegroups.com .
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en
> .
>
>

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



Re: New way to run your Django projects

2012-03-19 Thread Alexander
Hi Bolang,

I'm not sure what you meant by "simply using nginx" since as far as I
know it doesn't have standard WSGI module. I hope you're not talking
about running WSGI application as CGI script, do you?

As to comparing Gunicorn to gevent-fastcgi Gunocorn is HTTP server and
gevent-fastcg is FastCGI one. FastCGI can run over UNIX domain
sockets, it can multiplex requests using single connection. That could
be deal-breaker when application is using long-polling requests and
there are thousands of clients that can be accessing it
simultaneously. Beside HTTP is not well suited for communication
between frontend and backend (just recall famous need to fix
hostname:port in backend server responses because backend server has
no way to get access to original HTTP-request and it might not even
know that there is something that makes request on behalf of client
browser). There is no such problems in FastCGI protocol because it was
specifically designed for frontend/backend communication.

Gevent-fastcgi is not well suited for any type of applications. The
application should not block since everything is run in the same
thread (there are greenlets that are used in place of thread to avoid
GIL). Not all databases and other external resources can be used in
non-blocking mode. Luckily PostgreSQL, MySQL, Memcache are those that
have adapters/hooks for making them work well in non-blocking manner.

Alex

Bolang wrote:
> Hi Alexander,
> What is the advantage of using gevent-fastcgi instead of simply using
> nginx and maybe with gunicorn?

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

2012-03-19 Thread Kurtis Mullins
What are you using for your session engine? Maybe try another one? (
https://docs.djangoproject.com/en/1.3/topics/http/sessions/#configuring-the-session-engine
)

On Sun, Mar 18, 2012 at 9:51 AM, pyramid...@gmail.com
wrote:

> If i clear my cookies and run this view, i get a new session key each
> page load.
>
> If I comment out the print, and output the session key in the
> template, new session key each load.
>
> If I print session key in both view and template, the session key is
> 'saved' and remains the same each page load.
>
> def view_session(request):
>print request.session.session_key
>return render(request, "view_session.html", {})
>
> So how to explain this behavior? at no point do i modify the session.
> I can print twice in the view and still get new keys.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: starting django

2012-03-19 Thread Raphael Reumayr
hello Kikozzza,

if you say ubuntu 10 I give a shot into the dark and tip on ubuntu
version 10_04 LTS (long term support).
After installation you can open a terminal an type:
python

the python console will open and responding with version Python 2.6.5 as
this is the default version on ubuntu 10.04

After your friend has installed django on your system - the version is
system independent, do the following:
again run the command "python" in terminal:
python
and then type
import django 
print django.VERSION

this could look similar to this approach:
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> print django.VERSION
(1, 2, 3, 'final', 0)
>>> 

so you see on this machine I am running Django version 1.2.3 final

Good luck on improving your skills!

-- Raphael
http://develissimo.com




On Sun, 2012-03-18 at 23:00 -0700, Kikozzza wrote:

> I'm starting learning django? that's why I ask my friend to install me
> python and all distrib for my projects.
> I have very silly question- how can I discover what version of python
> and  Django i get?
> he installs me ubuntu 10
> 

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

2012-03-19 Thread Marc Patermann

Kikozzza,

Kikozzza schrieb (19.03.2012 07:00 Uhr):

I'm starting learning django? that's why I ask my friend to install me
python and all distrib for my projects.
I have very silly question- how can I discover what version of python

# python -V
# man python
"-V Prints the Python version number of the executable and exits."

(or look it up in the package managing software)



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: starting django

2012-03-19 Thread Joel Goldstick
On Mon, Mar 19, 2012 at 2:00 AM, Kikozzza  wrote:
> I'm starting learning django? that's why I ask my friend to install me
> python and all distrib for my projects.
> I have very silly question- how can I discover what version of python
> and  Django i get?
> he installs me ubuntu 10
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
from the shell just type python and you will enter they interactive
python shell.  The first thing it shows is the version of python

then type import django

then type help(django0) and look down through the information it
shows.  the version is near the bottom


-- 
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: Combining two model fields into one

2012-03-19 Thread Russell Keith-Magee

On 19/03/2012, at 11:31 AM, BGMaster wrote:

> Hi,
> 
> I'm trying to combine the values from two separate fields into one
> field for my database model. I've tried this both in the view function
> with the values passed back through POST as well as trying to write a
> method for my model. Any suggestions on the best way to do this?
> Basically, I just want to add a field to my model that combines a
> phone number and area code field into one field for the database.

It sounds to me like you might be looking for a django.forms.MultiValueField. 

The SplitDateTimeField is one example of a MultiValueField in action -- it uses 
two CharField inputs to capture the date and the time, then combines them into 
a single datetime object for the database. 

Yours,
Russ Magee %-)

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



starting django

2012-03-19 Thread Kikozzza
I'm starting learning django? that's why I ask my friend to install me
python and all distrib for my projects.
I have very silly question- how can I discover what version of python
and  Django i get?
he installs me ubuntu 10

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



Combining two model fields into one

2012-03-19 Thread BGMaster
Hi,

I'm trying to combine the values from two separate fields into one
field for my database model. I've tried this both in the view function
with the values passed back through POST as well as trying to write a
method for my model. Any suggestions on the best way to do this?
Basically, I just want to add a field to my model that combines a
phone number and area code field into one field for the database.

Thanks

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



Re: Running manage.py commands in Windows Power Shell

2012-03-19 Thread orschiro
After testing the Python distribution of ActiveState I have to confirm
that with that version I smoothly can run .\test.py in PowerShell
without having the cmd window to pop up.

Overall I can only recommend all Windows users to prefer this one over
the default one.

Regards

On Mar 18, 10:14 am, orschiro  wrote:
> Hello Sam,
>
> Let's assume we're having the following script test.py containing
> nothing more than a print statement and a raw_input.
>
> 
> print "Test"
> raw_input()
> 
>
> When I launch test.py in PowerShell like that:
>
> PS C:\Users\Robert> .\test.py
>
> Then C:\Python27\python.exe is launched in a new cmd window that runs
> test.py.
>
> When I launch test.py in PowerShell like that:
>
> PS C:\Users\Robert> python test.py
>
> Then the script is launched inside PowerShell. Exactly this should
> happen also when I only type .\test.py.
>
> Is this the case for the ActivePython package?
>
> Regards,
>
> Robert
>
> On Mar 15, 10:54 am, Sam Lai  wrote:
>
>
>
>
>
>
>
> > On 15 March 2012 04:35, orschiro  wrote:
>
> > > Hello,
>
> > > I have a question which is based on the discussion here:
>
> > >http://groups.google.com/group/django-users/browse_thread/thread/2333...
>
> > > I'm working on Windows 7 with the PowerShell. Python 2.7 and the path
> > > to django-admin.py is stored in my PATH variable.
>
> > > After creating a project I can make use of the various manage.py
> > > commands in my PowerShell. However, only in the following way:
>
> > > 'python manage.py runserver'
>
> > > If I only type '.\manage.py runserver' then a new CMD window is opened
> > > running again 'python manage.py runserver'. That is, the command is
> > > forwarded to the CMD shell which opens it with the Python
> > > interpreter.
>
> > > Is there any way to tell the PowerShell to interpret the command given
> > > within the shell instead of launching a CMD window?
>
> > For me, both ways execute within PowerShell's shell. I do have
> > ActiveState ActivePython installed instead of the Python distribution
> > from python.org though; I find the ActiveState distribution integrates
> > much better with Windows than python.org's.
>
> > That said, I can't really explain why you're seeing what you're seeing
> > though. Does it happen if you just do '.\test.py' where test.py just
> > contains simple Python commands like a couple of print statements?
>
> > > Regards,
>
> > > Robert
>
> > > --
> > > You received this message because you are subscribed to the Google Groups 
> > > "Django users" group.
> > > To post to this group, send email to django-users@googlegroups.com.
> > > To unsubscribe from this group, send email to 
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group 
> > > athttp://groups.google.com/group/django-users?hl=en.

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



Re: VERY strange unicode encode error on internet connection

2012-03-19 Thread ionic drive
hello django friends,

issue found and solved.
The code which was causing the trouble:
log.debug('Using "%s" as title for "%s"' % (title, url))

as url is having a '/u' in the link this was causing the following error
message:
Caught UnicodeDecodeError while rendering: 'ascii' codec can't decode
byte 0xe2 in position 31: ordinal not in range(128)

I fixed this by doing a force to string conversion on url:
log.debug('Using "%s" as title for "%s"' % (title, str(url)))

I am not sure if this is a clean solution to the problem.

Kind regards,
ionic


On Sun, 2012-03-18 at 13:37 +0100, ionic drive wrote:

> hello django friends,
> 
> I am facing a VERY strange unicode encode error on internet
> connection.
> No Error when network(LAN/internet) is disabled.
> 
> Situation:
> 
> In a template I do have a link to a site(google) in this a URL a '/u'
> is included.
> 
> I am testing this in my virtual-machine so I can turn on and off
> internet connection.
> the server is in my virtual-machine and the browser is in this
> virtual-machine too.
> So I am able to test the site with "internet connection" and without
> "internet connection".
> 
> Now the VERY strange behavior: 
>   * When my internet connection is activated I do get the
> following Template Error:
> Caught UnicodeDecodeError while rendering: 'ascii' codec can't
> decode byte 0xe2 in position 31: ordinal not in range(128)
> 
>   * When my internet connection is disabled everything works fine.
> 
> I did not know that my django - interpreter is internet connection
> related!?
> 
> Please give me some insights on that problem.
> 
> Thank you very much!!!
> Ionic
> 
> 
> 
> 
> 

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