lazy error

2014-06-20 Thread hinnack


class test(models.Model):

version = models.CharField(max_length=255, choices=lazy(getGibthubTags, 
list)())

and a function getGibthubTags returning en amply array or an array of 
sets...


Using:
manage.py runserver

I sometimes get:

raise TypeError("Lazy object returned unexpected type.")
TypeError: Lazy object returned unexpected type.

why?

regards

Hinnack

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7c752f7f-87b5-4145-86e6-697949a89c3f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Stack Overflow Open Source Advertising, 2H 2014

2014-06-20 Thread Jorge Cardoso Leitão
Hi Russell,

Thanks for the input.

My intention with my original mail wasn't to wave you off contributing; it
> was to make sure that you are aware that if you're representing the
> project, you need to use our trademarks correctly. If you don't, you weaken
> our claim on the *actual* trademarks. I also wanted to make sure that the
> final product meets the high graphical standards that the Django community
> tries to maintain.


I understood, don't worry. We will have to work on both aspects.

For those interested in following, this discussion was migrated to
django-dev
.

Regards,
Jorge





On Thu, Jun 19, 2014 at 1:49 AM, Russell Keith-Magee <
russ...@keith-magee.com> wrote:

> Hi Jorge,
>
> On Wed, Jun 18, 2014 at 3:21 PM, Jorge Cardoso Leitão <
> jorgecarlei...@gmail.com> wrote:
>
>> Hi Russell,
>>
>> Thank you for raising these concerns here.
>>
>> It would be a pleasure to me to represent the Django project but I'm not
>> sure that this is the case here, and surely was not my intention!
>>
>> That post was added as a SO member who is thrilled about a project and
>> wanted to promote it to other SO members to contribute, not as the project
>> representative.
>>
>> I see two questions here:
>>
>> 1. Does Django foundation has trademark concerns about it being
>> publicised by SO members to promote contributing to Django in SO?
>>
>> Since you raised some concerns and I'm no legal expert, I retracted the
>> post. Maybe this should be clarified at some point.
>>
>
> The legal standing of the Django trademark is well documented, and there's
> a FAQ for how you can use it; see:
>
> http://djangoproject.com/trademarks/
>
> The intention of this license is *not* to prevent people from using the
> Django trademark to represent the community. We *want* people to use the
> Django trademark. However, we have to make sure the trademark isn't left
> vulnerable to exploitation.
>
>
>> 2. Does Django project wants to participate in this program? (in the
>> representative sense)
>>
>> It interpret your reply as that at least you don't oppose, so I try to
>> bring this to django-dev after 1.7 is out.
>>
>
> It certainly looks like an interesting opportunity. What we really need is
> a volunteer to drive the effort. You look like you've volunteered for the
> job :-)
>
> I also wouldn't wait for 1.7 - it looks like this is a time sensitive, and
> it's difficult to give a firm deadline for the release of 1.7 final.
>
> My intention with my original mail wasn't to wave you off contributing; it
> was to make sure that you are aware that if you're representing the
> project, you need to use our trademarks correctly. If you don't, you weaken
> our claim on the *actual* trademarks. I also wanted to make sure that the
> final product meets the high graphical standards that the Django community
> tries to maintain.
>
> So - please - feel free to contribute an ad to this program; just keep in
> mind the two points that I mentioned in my original email.
>
> Yours,
> Russ Magee %-)
>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/OOGMtm9KMcM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAJxq84-KFbM%3D%2B_f6Om20SkwTNYGtoeropw%3DuY58Dd6X_rcv56A%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAOYPqDDTZf93NMiu0AHsb1eioE3r6ejS4PuZtWNTS%3DVK-4_PLw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Dying upon loop

2014-06-20 Thread Tom Evans
On Fri, Jun 20, 2014 at 12:16 AM, G Z  wrote:
> my django server dies whenever i login and access the following function:
>
> what is a better way to do what im doing. I need to loop through all of the
> vm_groups by customer id, and then loop through all of the vms and associate
> them with each other.
> The code below is what i have but its not working. django just kills its
> self.
>
> def portal(request):
>
> query_results = Customer.objects.all()
>
> for result in query_results:
>customer_id = Customer.objects.values('customer_id')
>
>vm_group = Vm_group.objects.filter(customer=customer_id)
>
>for result in vm_group:
>   vm_group_ids = Vm_group.objects.values('vm_group_id')
>
>   for result in vm_group_ids:
>  vms = Vm.objects.filter(vm_group_id=vm_group_ids)
>
>
> context = Context({'customer': query_results, 'vm_group': vm_group,
> 'vms': vms,
> })
>
> return render(request, 'portal.html', context)
>

What is this code supposed to do?

You generate a "vm_group" for each customer, but then discard all but
the last one generated, which you put in your context.

Similarly, you generate a "vms" object for each vm group id in each vm
group in each customer, but then discard all but the last one.

Running queries inside loops inside loops inside loops is an extremely
inefficient way of querying the database, and this is ultimately why
it kills itself - it takes too long.

The purpose of the view is to efficiently generate data that you then
output in your template, but your view generates data inefficiently
that you discard. What do you want output in your template?

Cheers

Tom

PS:

I don't mean to discourage you, but looking back at your past posts,
they all seem to be variants of this exact question for the past
several months.

It might be worth doing some more straightforward exercises in python
so that you understand basic concepts like looping and variable
scoping, and when you get help on the mailing list, make sure you
understand why you are changing what you have been told to change -
ask questions of the people helping you if you don't know - otherwise
you are learning how to be a cargo cult programmer.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFHbX1L4pNhKa4qYs3qd8NH%3DSz9%3DHQGN%2BQEeg%3Deb2hHxOvgg9Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Language code issue - Django thinks default is en-us?

2014-06-20 Thread Vernon D. Cole
(*cough*)
Excuse me, everyone, but many of the locale names mentioned in this 
discussion have been invalid.

https://docs.djangoproject.com/en/1.6/topics/i18n/#term-locale-name says:

> locale nameA locale name, either a language specification of the form ll 
> or a combined language and country specification of the form ll_CC. 
> Examples: it, de_AT, es, pt_BR. The language part is always in lower case 
> and the country part in upper case. The separator is an underscore.


so 'en-gb' should not be recognized.
'en_GB' ought to be.


On Thursday, June 19, 2014 3:18:32 PM UTC+1, Stodge wrote:
>
> My problem seems to be this:
>
>  * run custom management command
>  * activate language from settings, which is "en-gb"
>  * dynamically import module for a Django app and invoke custom bootstrap 
> function
>  * calling get_language() in bootstrap function returns "en-gb"
>  * bootstrap function calls loaddata management command (using 
> management.call_command)
>  * data created in DB, which triggers a post_save signal
>  * get_language() in post_save signal always returns "en-us"
>
>
>
>
> On Wednesday, 18 June 2014 12:48:47 UTC-4, Stodge wrote:
>>
>> My settings for languages are:
>>
>> LANGUAGE_CODE = 'en'
>>
>> USE_I18N = True
>> LANGUAGE_COOKIE_NAME='django_language'
>> ugettext = lambda s: s
>> LANGUAGES = (
>> ('en', ugettext('English')),
>> ('de', ugettext('German')),
>> ('fr', ugettext('French'))
>> )
>>
>>
>> I have a post-save signal that creates instances of a model and gets the 
>> current Django language. The language returned is for some reason "en-us", 
>> but I have no idea where this is coming from. My default as shown above is 
>> "en". get_language() is called from within a signal so the language isn't 
>> being taken from a cookie or request header. Any ideas why Django thinks 
>> the current (default) language is "en-us"? Thanks
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0a65bbc0-453a-4cb4-9be3-1fe71ba00b36%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Using forms/template to enter recurring events - how to avoid duplicate and redundant forms?

2014-06-20 Thread Stodge
I'm trying to make a template and form to let a user define a recurring 
event. I want to present different fields depending on whether they want 
daily, weekly, monthly or yearly recurrence. I'm not sure how to define the 
forms to do this so that the submitted data isn't duplicated or redundant.

Are there any examples of the best practice for this? I'm Googling for 
examples Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9bb5e587-3f4c-4ecb-83be-2dfd1ea57e81%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Language code issue - Django thinks default is en-us?

2014-06-20 Thread Stodge
This always confuses me - the language code is always lower case according 
to the docs. Which is specified in the settings - language codes or 
locales? I've always assumed the former.

locale nameA locale name, either a language specification of the form ll or 
a combined language and country specification of the form ll_CC. Examples: 
it, de_AT, es, pt_BR. The language part is always in lower case and the 
country part in upper case. The separator is an underscore.language 
codeRepresents 
the name of a language. Browsers send the names of the languages they 
accept in the Accept-Language HTTP header using this format. Examples: it, 
de-at, es, pt-br. Both the language and the country parts are in lower 
case. The separator is a dash.
On Friday, 20 June 2014 08:47:13 UTC-4, Vernon D. Cole wrote:
>
> (*cough*)
> Excuse me, everyone, but many of the locale names mentioned in this 
> discussion have been invalid.
>
> https://docs.djangoproject.com/en/1.6/topics/i18n/#term-locale-name says:
>
>> locale nameA locale name, either a language specification of the form ll 
>> or a combined language and country specification of the form ll_CC. 
>> Examples: it, de_AT, es, pt_BR. The language part is always in lower 
>> case and the country part in upper case. The separator is an underscore.
>
>
> so 'en-gb' should not be recognized.
> 'en_GB' ought to be.
>
>
> On Thursday, June 19, 2014 3:18:32 PM UTC+1, Stodge wrote:
>>
>> My problem seems to be this:
>>
>>  * run custom management command
>>  * activate language from settings, which is "en-gb"
>>  * dynamically import module for a Django app and invoke custom bootstrap 
>> function
>>  * calling get_language() in bootstrap function returns "en-gb"
>>  * bootstrap function calls loaddata management command (using 
>> management.call_command)
>>  * data created in DB, which triggers a post_save signal
>>  * get_language() in post_save signal always returns "en-us"
>>
>>
>>
>>
>> On Wednesday, 18 June 2014 12:48:47 UTC-4, Stodge wrote:
>>>
>>> My settings for languages are:
>>>
>>> LANGUAGE_CODE = 'en'
>>>
>>> USE_I18N = True
>>> LANGUAGE_COOKIE_NAME='django_language'
>>> ugettext = lambda s: s
>>> LANGUAGES = (
>>> ('en', ugettext('English')),
>>> ('de', ugettext('German')),
>>> ('fr', ugettext('French'))
>>> )
>>>
>>>
>>> I have a post-save signal that creates instances of a model and gets the 
>>> current Django language. The language returned is for some reason "en-us", 
>>> but I have no idea where this is coming from. My default as shown above is 
>>> "en". get_language() is called from within a signal so the language isn't 
>>> being taken from a cookie or request header. Any ideas why Django thinks 
>>> the current (default) language is "en-us"? Thanks
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/68c48096-2929-49e4-afe8-af5f172f61b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Language code issue - Django thinks default is en-us?

2014-06-20 Thread Tom Evans
On Fri, Jun 20, 2014 at 1:47 PM, Vernon D. Cole  wrote:
> (*cough*)
> Excuse me, everyone, but many of the locale names mentioned in this
> discussion have been invalid.
>
> https://docs.djangoproject.com/en/1.6/topics/i18n/#term-locale-name says:
>>
>> locale nameA locale name, either a language specification of the form ll
>> or a combined language and country specification of the form ll_CC.
>> Examples: it, de_AT, es, pt_BR. The language part is always in lower case
>> and the country part in upper case. The separator is an underscore.
>
>
> so 'en-gb' should not be recognized.
> 'en_GB' ought to be.
>

What is and what is not a locale name has little bearing on what is
accepted and returned by django.utils.translation.{set,get}_language,
which is self-evidently a language name.

Language names map to locales.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFHbX1K5Ow%3D25wKEBsYrot_JqmFbbccrDJjiGv5-9GSt4ceccg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django Rest Framework create api-root ???

2014-06-20 Thread Carlos Perche
Using DjangoRestFramework, how can I create api-root with all urls for my 
apps

Like this e.g.

I have following apps

core_api
  views
  models
  serializers
  urls
equipments
  views
  models
  serializers
  urls
companies
  views
  models
  serializers
  urls
contacts
  views
  models
  serializers
  urls

When acess foo.teste.com, I want see all urls availables of my applications 
in api-root

thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/277cc83b-ac45-40de-8305-c927e0df3ab0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Dying upon loop

2014-06-20 Thread G Z
Sad part is I can do it in python well, I just can't seem to grasp the way 
django works i keep reading the damn documentation but I cant see any good 
examples relating to what I have to do.

On Friday, June 20, 2014 5:10:10 AM UTC-6, Tom Evans wrote:
>
> On Fri, Jun 20, 2014 at 12:16 AM, G Z > 
> wrote: 
> > my django server dies whenever i login and access the following 
> function: 
> > 
> > what is a better way to do what im doing. I need to loop through all of 
> the 
> > vm_groups by customer id, and then loop through all of the vms and 
> associate 
> > them with each other. 
> > The code below is what i have but its not working. django just kills its 
> > self. 
> > 
> > def portal(request): 
> > 
> > query_results = Customer.objects.all() 
> > 
> > for result in query_results: 
> >customer_id = Customer.objects.values('customer_id') 
> > 
> >vm_group = Vm_group.objects.filter(customer=customer_id) 
> > 
> >for result in vm_group: 
> >   vm_group_ids = Vm_group.objects.values('vm_group_id') 
> > 
> >   for result in vm_group_ids: 
> >  vms = Vm.objects.filter(vm_group_id=vm_group_ids) 
> > 
> > 
> > context = Context({'customer': query_results, 'vm_group': vm_group, 
> > 'vms': vms, 
> > }) 
> > 
> > return render(request, 'portal.html', context) 
> > 
>
> What is this code supposed to do? 
>
> You generate a "vm_group" for each customer, but then discard all but 
> the last one generated, which you put in your context. 
>
> Similarly, you generate a "vms" object for each vm group id in each vm 
> group in each customer, but then discard all but the last one. 
>
> Running queries inside loops inside loops inside loops is an extremely 
> inefficient way of querying the database, and this is ultimately why 
> it kills itself - it takes too long. 
>
> The purpose of the view is to efficiently generate data that you then 
> output in your template, but your view generates data inefficiently 
> that you discard. What do you want output in your template? 
>
> Cheers 
>
> Tom 
>
> PS: 
>
> I don't mean to discourage you, but looking back at your past posts, 
> they all seem to be variants of this exact question for the past 
> several months. 
>
> It might be worth doing some more straightforward exercises in python 
> so that you understand basic concepts like looping and variable 
> scoping, and when you get help on the mailing list, make sure you 
> understand why you are changing what you have been told to change - 
> ask questions of the people helping you if you don't know - otherwise 
> you are learning how to be a cargo cult programmer. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/959ab937-8c9e-44a6-bef4-31472c8322d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Upgrade Mysql

2014-06-20 Thread Dariusz Mysior
I use pythonanywhere.com Django 1.6 and Python 2.7 I 

and when I write p.save() I had error like below. 

It says something about updating mysql to fix it, but I don't know what 
code or shell commands I need to write.

Can you help me? One person post that he upgrade MySQL to 5.0.27 but I 
don't know what is a commend for do this :/.

Traceback (most recent call last):
  File "", line 1, in 
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/base.py",
 line 545, in save
force_update=force_update, update_fields=update_fields)
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/base.py",
 line 570, in save_base
with transaction.commit_on_success_unless_managed(using=using, 
savepoint=False):
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/transaction.py",
 line 280, in __enter__
connection.set_autocommit(False)
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/__init__.py",
 line 340, in set_autocommit
self._set_autocommit(autocommit)
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py",
 line 461, in _set_autocommit
self.connection.autocommit(autocommit)
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/utils.py",
 line 99, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py",
 line 461, in _set_autocommit
self.connection.autocommit(autocommit)
  File 
"/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/MySQLdb/connections.py",
 line 243, in autocommit
_mysql.connection.autocommit(self, on)
OperationalError: (2006, 'MySQL server has gone away')


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0dc3a793-2fd0-4884-87f3-b14724bdd1ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Upgrade Mysql

2014-06-20 Thread François Schiettecatte
Dariusz 

Not sure about upgrading mysql, what the error is telling you is that mysql is 
dropping the connection before django is done with it.

I would look at CONN_MAX_AGE in DATABASES (in settings.py) and wait_timeout in 
my.cnf, the first should be lower than the second.

For example I have these settings for a project:

'CONN_MAX_AGE': 3500,   # 3500 seconds because 
wait_timeout = 3600 in my.cnf


Cheers

François

On Jun 20, 2014, at 11:31 AM, Dariusz Mysior  wrote:

> I use pythonanywhere.com Django 1.6 and Python 2.7 I 
> 
> and when I write p.save() I had error like below.
> It says something about updating mysql to fix it, but I don't know what code 
> or shell commands I need to write.
> 
> Can you help me? One person post that he upgrade MySQL to 5.0.27 but I don't 
> know what is a commend for do this :/.
> 
> Traceback (most recent call last):
> 
>   
> File "", line 1, in 
> 
>   
> File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/base.py",
>  line 545, in save
> 
> force_update
> =force_update, update_fields=update_fields)
> 
>   
> File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/base.py",
>  line 570, in
>  save_base
> 
> with transaction.commit_on_success_unless_managed(using=using, 
> savepoint=False):
> 
>   
> File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/transaction.py",
>  line 280, in
>  __enter__
> connection
> .set_autocommit(False)
> 
>   
> File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/__init__.py",
>  line 340, in
>  set_autocommit
> self
> ._set_autocommit(autocommit)
> 
>   
> File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py",
>  line 461, in
>  _set_autocommit
> self
> .connection.autocommit(autocommit)
> 
>   
> File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/utils.py",
>  line 99, in
>  __exit__
> six
> .reraise(dj_exc_type, dj_exc_value, traceback)
> 
>   
> File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py",
>  line 461, in
>  _set_autocommit
> self
> .connection.autocommit(autocommit)
> 
>   
> File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/MySQLdb/connections.py",
>  line 243, in
>  autocommit
> _mysql
> .connection.autocommit(self, on)
> 
> OperationalError
> : (2006, 'MySQL server has gone away')
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/0dc3a793-2fd0-4884-87f3-b14724bdd1ab%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9ED0A86A-0299-49CE-B959-929EE13EB761%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Dying upon loop

2014-06-20 Thread G Z
There instead of looping through the queries i do it all in one loop but 
its still taking forever, how does django do the query, it seems like its 
doing a Cartesian product ? My server dies when ever I hit this page.

query_results = Customer.objects.all()
customers = {}
data = {}
customer_names = {}
vm_group_id = {}
vm_groups = {}
vm_names = {}

for result in query_results:
   #get data
   customer_id = Customer.objects.values('customer_id')
   customer_name = Customer.objects.values('customer_name') 
   vm_group = Vm_group.objects.filter(customer=customer_id)
   vm_group_ids = Vm_group.objects.values('vm_group_id')
   vm_name = Vm.objects.values('vm_name')
   vms = Vm.objects.filter(vm_group_id=vm_group_ids)  
   
   
   #build dictonary

   vm_group_id['vm_group_id'] = vm_group_ids
   customer_names['customer_name'] = customer_name
   vm_names['vm_name'] = vm_name
   vm_groups['vm_group'] = vm_group
   data['info'] = (vm_group_id, customer_names, vm_name, vm_group)

   customers[customer_id] = data 

context = Context({'customer': query_results, 'vm_group': vm_group, 
'vms': vms, 'customers':customers,
})

return render(request, 'portal.html', context)



On Friday, June 20, 2014 9:09:55 AM UTC-6, G Z wrote:
>
> Sad part is I can do it in python well, I just can't seem to grasp the way 
> django works i keep reading the damn documentation but I cant see any good 
> examples relating to what I have to do.
>
> On Friday, June 20, 2014 5:10:10 AM UTC-6, Tom Evans wrote:
>>
>> On Fri, Jun 20, 2014 at 12:16 AM, G Z  wrote: 
>> > my django server dies whenever i login and access the following 
>> function: 
>> > 
>> > what is a better way to do what im doing. I need to loop through all of 
>> the 
>> > vm_groups by customer id, and then loop through all of the vms and 
>> associate 
>> > them with each other. 
>> > The code below is what i have but its not working. django just kills 
>> its 
>> > self. 
>> > 
>> > def portal(request): 
>> > 
>> > query_results = Customer.objects.all() 
>> > 
>> > for result in query_results: 
>> >customer_id = Customer.objects.values('customer_id') 
>> > 
>> >vm_group = Vm_group.objects.filter(customer=customer_id) 
>> > 
>> >for result in vm_group: 
>> >   vm_group_ids = Vm_group.objects.values('vm_group_id') 
>> > 
>> >   for result in vm_group_ids: 
>> >  vms = Vm.objects.filter(vm_group_id=vm_group_ids) 
>> > 
>> > 
>> > context = Context({'customer': query_results, 'vm_group': vm_group, 
>> > 'vms': vms, 
>> > }) 
>> > 
>> > return render(request, 'portal.html', context) 
>> > 
>>
>> What is this code supposed to do? 
>>
>> You generate a "vm_group" for each customer, but then discard all but 
>> the last one generated, which you put in your context. 
>>
>> Similarly, you generate a "vms" object for each vm group id in each vm 
>> group in each customer, but then discard all but the last one. 
>>
>> Running queries inside loops inside loops inside loops is an extremely 
>> inefficient way of querying the database, and this is ultimately why 
>> it kills itself - it takes too long. 
>>
>> The purpose of the view is to efficiently generate data that you then 
>> output in your template, but your view generates data inefficiently 
>> that you discard. What do you want output in your template? 
>>
>> Cheers 
>>
>> Tom 
>>
>> PS: 
>>
>> I don't mean to discourage you, but looking back at your past posts, 
>> they all seem to be variants of this exact question for the past 
>> several months. 
>>
>> It might be worth doing some more straightforward exercises in python 
>> so that you understand basic concepts like looping and variable 
>> scoping, and when you get help on the mailing list, make sure you 
>> understand why you are changing what you have been told to change - 
>> ask questions of the people helping you if you don't know - otherwise 
>> you are learning how to be a cargo cult programmer. 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f71cbe94-f7a0-4375-8d62-3468997a2aec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Upgrade Mysql

2014-06-20 Thread Dariusz Mysior
But in mysite-mysite-settings.py in DATABASES I dont't have CONN_MAX_AGE 
and in don't have in my general directory file my.cnf :/ 

W dniu piątek, 20 czerwca 2014 17:31:10 UTC+2 użytkownik Dariusz Mysior 
napisał:
>
> I use pythonanywhere.com Django 1.6 and Python 2.7 I 
>
> and when I write p.save() I had error like below. 
>
> It says something about updating mysql to fix it, but I don't know what 
> code or shell commands I need to write.
>
> Can you help me? One person post that he upgrade MySQL to 5.0.27 but I 
> don't know what is a commend for do this :/.
>
> Traceback (most recent call last):
>   File "", line 1, in 
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/base.py",
>  line 545, in save
> force_update=force_update, update_fields=update_fields)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/models/base.py",
>  line 570, in save_base
> with transaction.commit_on_success_unless_managed(using=using, 
> savepoint=False):
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/transaction.py",
>  line 280, in __enter__
> connection.set_autocommit(False)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/__init__.py",
>  line 340, in set_autocommit
> self._set_autocommit(autocommit)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py",
>  line 461, in _set_autocommit
> self.connection.autocommit(autocommit)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/utils.py",
>  line 99, in __exit__
> six.reraise(dj_exc_type, dj_exc_value, traceback)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py",
>  line 461, in _set_autocommit
> self.connection.autocommit(autocommit)
>   File 
> "/home/daro822/.virtualenvs/django16/local/lib/python2.7/site-packages/MySQLdb/connections.py",
>  line 243, in autocommit
> _mysql.connection.autocommit(self, on)
> OperationalError: (2006, 'MySQL server has gone away')
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ac07e598-aa07-4319-b12a-b354b118e61c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Dying upon loop

2014-06-20 Thread G Z
shouldn't this work? After doing some more research into making django 
queries faster and more efficient I came 
across, http://tech.yipit.com/2013/01/20/making-django-orm-queries-faster/
I'm using thier method from what I understand you can selec_related to a 
primary key field and query like such, and it is the same as doing a join 
building a query set based on your parameters.


my html is 

{% for item in customer %}
 
{{ item.customer_id }}

{{ item.customer_name }}
{{ vm_groups.customer_id.vm_group_name }}
{{ vms.vm_group_id.vm_name }}




{% endfor %}


my view code:

def portal(request):

query_results = Customer.objects.all()
vm_groups = Vm_group.objects.all().select_related('customer_id') 
vms =  Vm.objects.all().select_related('vm_group_id')   


context = Context({'customer': query_results, 'vm_groups':vm_groups, 
'vms':vms,
})

return render(request, 'portal.html', context)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e61cb11e-0461-4e24-83b6-e6dd77d8ad93%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Dying upon loop

2014-06-20 Thread George Silva
You can use the raw() function to create a adhoc query to the database.
Check the documentation and write proper sql code. It will be much more
efficient.


On Fri, Jun 20, 2014 at 12:44 PM, G Z  wrote:

> There instead of looping through the queries i do it all in one loop but
> its still taking forever, how does django do the query, it seems like its
> doing a Cartesian product ? My server dies when ever I hit this page.
>
> query_results = Customer.objects.all()
> customers = {}
> data = {}
> customer_names = {}
> vm_group_id = {}
> vm_groups = {}
> vm_names = {}
>
> for result in query_results:
>#get data
>customer_id = Customer.objects.values('customer_id')
>customer_name = Customer.objects.values('customer_name')
>vm_group = Vm_group.objects.filter(customer=customer_id)
>vm_group_ids = Vm_group.objects.values('vm_group_id')
>vm_name = Vm.objects.values('vm_name')
>vms = Vm.objects.filter(vm_group_id=vm_group_ids)
>
>
>#build dictonary
>
>vm_group_id['vm_group_id'] = vm_group_ids
>customer_names['customer_name'] = customer_name
>vm_names['vm_name'] = vm_name
>vm_groups['vm_group'] = vm_group
>data['info'] = (vm_group_id, customer_names, vm_name, vm_group)
>
>customers[customer_id] = data
>
> context = Context({'customer': query_results, 'vm_group': vm_group,
> 'vms': vms, 'customers':customers,
> })
>
> return render(request, 'portal.html', context)
>
>
>
> On Friday, June 20, 2014 9:09:55 AM UTC-6, G Z wrote:
>>
>> Sad part is I can do it in python well, I just can't seem to grasp the
>> way django works i keep reading the damn documentation but I cant see any
>> good examples relating to what I have to do.
>>
>> On Friday, June 20, 2014 5:10:10 AM UTC-6, Tom Evans wrote:
>>>
>>> On Fri, Jun 20, 2014 at 12:16 AM, G Z  wrote:
>>> > my django server dies whenever i login and access the following
>>> function:
>>> >
>>> > what is a better way to do what im doing. I need to loop through all
>>> of the
>>> > vm_groups by customer id, and then loop through all of the vms and
>>> associate
>>> > them with each other.
>>> > The code below is what i have but its not working. django just kills
>>> its
>>> > self.
>>> >
>>> > def portal(request):
>>> >
>>> > query_results = Customer.objects.all()
>>> >
>>> > for result in query_results:
>>> >customer_id = Customer.objects.values('customer_id')
>>> >
>>> >vm_group = Vm_group.objects.filter(customer=customer_id)
>>> >
>>> >for result in vm_group:
>>> >   vm_group_ids = Vm_group.objects.values('vm_group_id')
>>> >
>>> >   for result in vm_group_ids:
>>> >  vms = Vm.objects.filter(vm_group_id=vm_group_ids)
>>> >
>>> >
>>> > context = Context({'customer': query_results, 'vm_group':
>>> vm_group,
>>> > 'vms': vms,
>>> > })
>>> >
>>> > return render(request, 'portal.html', context)
>>> >
>>>
>>> What is this code supposed to do?
>>>
>>> You generate a "vm_group" for each customer, but then discard all but
>>> the last one generated, which you put in your context.
>>>
>>> Similarly, you generate a "vms" object for each vm group id in each vm
>>> group in each customer, but then discard all but the last one.
>>>
>>> Running queries inside loops inside loops inside loops is an extremely
>>> inefficient way of querying the database, and this is ultimately why
>>> it kills itself - it takes too long.
>>>
>>> The purpose of the view is to efficiently generate data that you then
>>> output in your template, but your view generates data inefficiently
>>> that you discard. What do you want output in your template?
>>>
>>> Cheers
>>>
>>> Tom
>>>
>>> PS:
>>>
>>> I don't mean to discourage you, but looking back at your past posts,
>>> they all seem to be variants of this exact question for the past
>>> several months.
>>>
>>> It might be worth doing some more straightforward exercises in python
>>> so that you understand basic concepts like looping and variable
>>> scoping, and when you get help on the mailing list, make sure you
>>> understand why you are changing what you have been told to change -
>>> ask questions of the people helping you if you don't know - otherwise
>>> you are learning how to be a cargo cult programmer.
>>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f71cbe94-f7a0-4375-8d62-3468997a2aec%40googlegroups.com
> 

Recurring question. Automate manage.py syncdb

2014-06-20 Thread Rubén Ortiz
Hi

I have to automate a kind of django setup in linux ubuntu box. The project 
runs under virtualenv. Then my main problem is when I have to execute the 
famous:

$ python $VIRTUAL_ENV/opt/graphite/webapp/graphite/manage.py syncdb 
--pythonpath=$VIRTUAL_ENV/opt/graphite/webapp -v 2


I am very noob with python but I don't want to maintain dumps or 
workarounds with expect. I have found some info in stackoverflow but I 
don't know how to apply it.

http://stackoverflow.com/questions/10326277/django-automate-syncdb

Does anybody knows what I have to do? Goal is run manage.py syncb and in 
some way automate the send of user,password and email to python script. 

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ac7cdcba-52cc-4e1d-842a-cd440bc0167a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Recurring question. Automate manage.py syncdb

2014-06-20 Thread Ariel Calzada
I hope this helps you

http://pastebin.com/umGv3br9

Greetings from Colombia
ARIEL


2014-06-20 11:31 GMT-05:00 Rubén Ortiz :

> Hi
>
> I have to automate a kind of django setup in linux ubuntu box. The project
> runs under virtualenv. Then my main problem is when I have to execute the
> famous:
>
> $ python $VIRTUAL_ENV/opt/graphite/webapp/graphite/manage.py syncdb 
> --pythonpath=$VIRTUAL_ENV/opt/graphite/webapp -v 2
>
>
> I am very noob with python but I don't want to maintain dumps or
> workarounds with expect. I have found some info in stackoverflow but I
> don't know how to apply it.
>
> http://stackoverflow.com/questions/10326277/django-automate-syncdb
>
> Does anybody knows what I have to do? Goal is run manage.py syncb and in
> some way automate the send of user,password and email to python script.
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ac7cdcba-52cc-4e1d-842a-cd440bc0167a%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Ariel Calzada
Homepage: http://www.000paradox000.co
Blog: http://blog.000paradox000.co

No sabré desatarme los zapatos y dejar que la ciudad me muerda los pies
no me emborracharé bajo los puentes, no cometeré faltas de estilo.
Acepto este destino de camisas planchadas,
llego a tiempo a los cines, cedo mi asiento a las señoras.
El largo desarreglo de los sentidos me va mal. Opto
por el dentífrico y las toallas. Me vacuno.
Mira qué pobre amante, incapaz de meterse en una fuente
para traerte un pescadito rojo
bajo la rabia de gendarmes y niñeras.

-- EL NIÑO BUENO / Julio Cortazar --

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACVFg4sX0GD5HCYqLSrpd77JBBK7iCWW_7WMzPfGUEPZxp0KRA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django Post Issue

2014-06-20 Thread G Z
I'm trying to post
customer_id
while generating a combo box with a loop from a database query.
I have the combo box generating and such, but the posted data does not 
return the customer id. It returns something weird.


> {% csrf_token %}
> 
> {% for item in customer %}
> {{ 
> item.customer_name }}
> {% endfor %}
> 
> 
> {{ post }}



this is what it returns



def portal(request):
> 
> customers = Customer.objects.all()
> 
> 
> 
> if request.method == 'POST':
>vm_groups = Vm_group.objects.all()
>vms = Vm.objects.all()
>selected_customer = request.POST.copy()
>#selected_customer_id = selected_customer['customer_id']
>  
>post = selected_customer
>context = Context({'customer': customers, 'vm_groups':vm_groups, 
> 'vms':vms, 'post':post, 
>})
>
>return render(request, 'portal.html', context)
> 
> else:
>context = Context({'customer': customers,})
>return render(request, 'portal.html', context)




-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e75fd019-a74e-415f-b681-8617a781cf38%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Upgrade Mysql

2014-06-20 Thread Tom Evans
On Fri, Jun 20, 2014 at 5:04 PM, Dariusz Mysior  wrote:
> But in mysite-mysite-settings.py in DATABASES I dont't have CONN_MAX_AGE and
> in don't have in my general directory file my.cnf :/ 

Helpfully, mysql uses my.cnf to refer to a whole raft of different
config files (or rather, multiple config files all called my.cnf get
read, combined in a specific order, and specific sections read
depending on what program is being run). You are saying your app - the
mysql client - does not have a my.cnf. Francois is saying that the
mysql server's my.cnf has that setting.

Even if it doesn't, it will have a default value. If the servers
"default" value differs from your client's "default" value then you
would have the same issue.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFHbX1LgnvK54CMBqjqy88toPkMcJgyVp3bySwuZBSBxgpq58Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Post Issue

2014-06-20 Thread Nikolas Stevenson-Molnar
The "name" attribute should be on the select tag. E.g:


  Foo


_Nik
On 6/20/2014 10:33 AM, G Z wrote:
> I'm trying to post
> customer_id
> while generating a combo box with a loop from a database query.
> I have the combo box generating and such, but the posted data does not
> return the customer id. It returns something weird.
>
> 
> {% csrf_token %}
> 
> {% for item in customer %}
> {{
> item.customer_name }}
> {% endfor %}
> 
> 
> {{ post }}
>
>
>
> this is what it returns
>  [u'CpzKrwmZsmfiiNHngNWDFSNxqUoBykYO']}>
>
>
> def portal(request):
> 
> customers = Customer.objects.all()
> 
> 
> 
> if request.method == 'POST':
>vm_groups = Vm_group.objects.all()
>vms = Vm.objects.all()
>selected_customer = request.POST.copy()
>#selected_customer_id = selected_customer['customer_id']
>  
>post = selected_customer
>context = Context({'customer': customers,
> 'vm_groups':vm_groups, 'vms':vms, 'post':post, 
>})
>
>return render(request, 'portal.html', context)
> 
> else:
>context = Context({'customer': customers,})
>return render(request, 'portal.html', context)
>
>
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com
> .
> To post to this group, send email to django-users@googlegroups.com
> .
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e75fd019-a74e-415f-b681-8617a781cf38%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/53A47679.4050309%40consbio.org.
For more options, visit https://groups.google.com/d/optout.


Re: Django Post Issue

2014-06-20 Thread Tom Evans
On Fri, Jun 20, 2014 at 6:33 PM, G Z  wrote:
> I'm trying to post
> customer_id
> while generating a combo box with a loop from a database query.
> I have the combo box generating and such, but the posted data does not
> return the customer id. It returns something weird.
>
>> 
>> {% csrf_token %}
>> 

Only form elements with names are submitted.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFHbX1LxLD--fepw0YNyzxHuziH2mpeGDYVOvzMT-HBd%3D%2B4y6w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Post Issue

2014-06-20 Thread G Z
Thanks lol its one of those days, I notice i was calling the options the 
name instead of the select.


this might be a django ism but after i post the number and try to check it 
with an if statement it doesnt do anythign but if i print both out they are 
the same here is the code


> {% if user.is_authenticated %}
> Enki-Corp says... hello {{ user.username }}!
> {% else %}
> Enki-Corp says... hello world!
> {% endif %}
>
> {% if user.is_authenticated %}
>
> 
> {% csrf_token %}
> 
> {% for item in customer %}
> {{ item.customer_name }}
> {% endfor %}
> 
> 
>
>
> 
> 
> ID
>  
> NAME
> 
> 
> {% for item in customer %}
> {{post}} -  {{item.customer_id}}  //where I print them out to check if 
> they match when infact there is a matching number it does nothing. but all 
> my if statements below work.
>
 

> {% if post == item.customer_id %}
> test
> 
> {{ item.customer_id }}  {{ item.customer_name }}
> Customer Inactive: {{item.inactive}}
> 
> 
>  {% for group in vm_groups %}
>  {% if item.customer_id == group.customer_id %}
>  {% for vm in vms %}
>  {% if group.vm_group_id == vm.vm_group_id %}
>  
>VM Name: {{vm.vm_name}}
>
>VM ID: {{vm.vm_id}}
>VM Display Name: {{vm.vm_display_name}}
>VM Group: {{group.vm_group_name}}
>Vm Mor:  {{vm.vm_mor}} 
>Vm Datacenter:  {{vm.datacenter_id}} 
>VCD Managed:  {{vm.vcd_managed}} 
>
>
>
> {%endif%}
> {%endfor%}
>  {%endif%}
> {% endfor %} 
>  
>  
> 
>
>  {%endif%}
> {% endfor %}
>  
> 
> 
> Logout
> {% else %}
> You are not authenticated.
> Login
> {% endif %}





On Friday, June 20, 2014 12:00:37 PM UTC-6, Tom Evans wrote:
>
> On Fri, Jun 20, 2014 at 6:33 PM, G Z > 
> wrote: 
> > I'm trying to post 
> > customer_id 
> > while generating a combo box with a loop from a database query. 
> > I have the combo box generating and such, but the posted data does not 
> > return the customer id. It returns something weird. 
> > 
> >>  
> >> {% csrf_token %} 
> >>  
>
> Only form elements with names are submitted. 
>
> Cheers 
>
> Tom 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/40b761ff-841a-4fa8-8a1d-83fcbc2c02fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Post Issue

2014-06-20 Thread G Z
solved it item.customer_id was a int post needed to be passed as an int..

On Friday, June 20, 2014 12:14:18 PM UTC-6, G Z wrote:
>
> Thanks lol its one of those days, I notice i was calling the options the 
> name instead of the select.
>
>
> this might be a django ism but after i post the number and try to check it 
> with an if statement it doesnt do anythign but if i print both out they are 
> the same here is the code
>
>
>> {% if user.is_authenticated %}
>> Enki-Corp says... hello {{ user.username }}!
>> {% else %}
>> Enki-Corp says... hello world!
>> {% endif %}
>>
>> {% if user.is_authenticated %}
>>
>> 
>> {% csrf_token %}
>> 
>> {% for item in customer %}
>> {{ item.customer_name }}
>> {% endfor %}
>> 
>> 
>>
>>
>> 
>> 
>> ID
>>  
>> NAME
>> 
>> 
>> {% for item in customer %}
>> {{post}} -  {{item.customer_id}}  //where I print them out to check 
>> if they match when infact there is a matching number it does nothing. but 
>> all my if statements below work.
>>
>  
>
>> {% if post == item.customer_id %}
>> test
>> 
>> {{ item.customer_id }}  {{ item.customer_name }}
>> Customer Inactive: {{item.inactive}}
>> 
>> 
>>  {% for group in vm_groups %}
>>  {% if item.customer_id == group.customer_id %}
>>  {% for vm in vms %}
>>  {% if group.vm_group_id == vm.vm_group_id %}
>>  
>>VM Name: {{vm.vm_name}}
>>
>>VM ID: {{vm.vm_id}}
>>VM Display Name: {{vm.vm_display_name}}
>>VM Group: {{group.vm_group_name}}
>>Vm Mor:  {{vm.vm_mor}} 
>>Vm Datacenter:  {{vm.datacenter_id}} 
>>VCD Managed:  {{vm.vcd_managed}} 
>>
>>
>>
>> {%endif%}
>> {%endfor%}
>>  {%endif%}
>> {% endfor %} 
>>  
>>  
>> 
>>
>>  {%endif%}
>> {% endfor %}
>>  
>> 
>> 
>> Logout
>> {% else %}
>> You are not authenticated.
>> Login
>> {% endif %}
>
>
>
>
>
> On Friday, June 20, 2014 12:00:37 PM UTC-6, Tom Evans wrote:
>>
>> On Fri, Jun 20, 2014 at 6:33 PM, G Z  wrote: 
>> > I'm trying to post 
>> > customer_id 
>> > while generating a combo box with a loop from a database query. 
>> > I have the combo box generating and such, but the posted data does not 
>> > return the customer id. It returns something weird. 
>> > 
>> >>  
>> >> {% csrf_token %} 
>> >>  
>>
>> Only form elements with names are submitted. 
>>
>> Cheers 
>>
>> Tom 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bd30d1a8-0b23-4219-9fa4-a7ccc4b9c84f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Rest Framework create api-root ???

2014-06-20 Thread Glyn Jackson
The documentation explains this very well: 
http://www.django-rest-framework.org/tutorial/5-relationships-and-hyperlinked-apis

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/22fe0551-9e82-4fe6-9df4-e2ef99936129%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


unit test: AssertionError: 302 != 200

2014-06-20 Thread Kim
Hi everyone, 
I'm new to Django and am running a test. 

For my admintest in tests.py, I have the following:
--
class AdminTest(LiveServerTestCase):
def test_login(self):
c = Client()

response = c.get('/admin/')
self.assertEquals(response.status_code,200)
self.assertTrue('Log in' in response.content)
c.login(username = 'username',password='password')
response = c.get('/admin/')
self.assertEquals(response.status_code,200)
self.assertTrue('Log out' in response.content)

-
And I get this error. 

-
$ python manage.py test
Creating test database for alias 'default'...
.F
==
FAIL: test_login (blogengine.tests.AdminTest)
--
Traceback (most recent call last):
  File "/Users/Desktop/Python/1.7/src/blogengine/tests.py", line 35, in 
test_login
self.assertEquals(response.status_code,200)
AssertionError: 302 != 200

--
Ran 2 tests in 0.510s

FAILED (failures=1)
Destroying test database for alias 'default'...
-

Since I checked the admin is actually working(status 200) in my localhost, 
I thought I should give 200 status instead of 302. 

Please give me some advice to fix this.

Many thanks,
Kim

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/03da1883-8291-41b9-a707-a122f289f0b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.