variable to a template

2016-03-02 Thread 'luca72' via Django users
Hello i have write this in a template:
{% for a in lista %}
 
 {% endfor %}
But i get no image

if i add just a  {{a}}  i see that the file name is righ, 
also if i direct write the file i get it
 {% for a in lista %}
 
 {% endfor %}

can you tell me what is wrong

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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9a12167f-e919-4632-b77a-6d5acc80fd3e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: variable to a template

2016-03-02 Thread Sergiy Khohlov
original path  og your image please.
 Also setting for STATIC_ROOT  from setting.py send please

Many thanks,

Serge


+380 636150445
skype: skhohlov

On Wed, Mar 2, 2016 at 12:41 PM, 'luca72' via Django users <
django-users@googlegroups.com> wrote:

> Hello i have write this in a template:
> {% for a in lista %}
>  height="100" 
>  {% endfor %}
> But i get no image
>
> if i add just a  {{a}}  i see that the file name is righ,
> also if i direct write the file i get it
>  {% for a in lista %}
>  height="100" 
>  {% endfor %}
>
> can you tell me what is wrong
>
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/9a12167f-e919-4632-b77a-6d5acc80fd3e%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADTRxJOVdo5oM38qBOgAVYD7cSVMDip%3DB4FW5TAHK85bWgG8dA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How force DJANGo choice MEDIA_URL or STATIC_URL in template?

2016-03-02 Thread setivolkylany
I am solved problem next variant:

in model
--

@property
def account_user_picture(self):
if self.picture:
return self.picture.url
else:
return settings.STATIC_URL + 
'project_static/images/default-picture.png'

in templates
--



And all worked

Thanks

среда, 2 марта 2016 г., 1:41:28 UTC+2 пользователь James Schneider написал:
>
>
>> I need choice base url MEDIA_URL (/media/) - for uploaded user picture, 
>> or STATIC_URL (/static/) - picture by default
>>
>> I am try next:
>>
>> p>> alt="picture_for_{{ account.name }}" id="account_picture">
>>
>> , but result is MEDIA_URL(STATIC_URL) and path to file.
>>  
>>
>
> You should work your {% if %} statement this way:
>
> {% if account.accountuserinfo.picture %}
> 
> {% else %}
> 
> {% endif %}
>
> Trying to cram all of that together within the template is awful to read, 
> and doesn't work as you've seen.
>
> It would also make more sense to have the URL path of the default image 
> set somewhere other than inside of a property. Either as a global variable 
> for the model class, or even within your settings.py file and brought in as 
> part of the template context if it can be used by other areas of the 
> system. Querying an object instance for a static value like that is not 
> good style.
>
> -James
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5ea7fc64-b031-4b54-acde-6e745aeb787c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: variable to a template

2016-03-02 Thread 'luca72' via Django users
Hello Thanks for your reply

STATIC_URL = '/static/'

I have no static root configured

But why if i write i get the image

and if i write   where a is the file name i can't get?

The path is 
F:\Sito_01_03_16\test\nuovo\myproject\mysite\static\mysite\scorr

Thanks for your help  

Il giorno mercoledì 2 marzo 2016 11:52:05 UTC+1, Sergiy Khohlov ha scritto:
>
> original path  og your image please. 
>  Also setting for STATIC_ROOT  from setting.py send please 
>
> Many thanks,
>
> Serge
>
>
> +380 636150445
> skype: skhohlov
>
> On Wed, Mar 2, 2016 at 12:41 PM, 'luca72' via Django users <
> django...@googlegroups.com > wrote:
>
>> Hello i have write this in a template:
>> {% for a in lista %}
>> > height="100"  
>>  {% endfor %}
>> But i get no image
>>
>> if i add just a  {{a}}  i see that the file name is righ, 
>> also if i direct write the file i get it
>>  {% for a in lista %}
>> > height="100"  
>>  {% endfor %}
>>
>> can you tell me what is wrong
>>
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/9a12167f-e919-4632-b77a-6d5acc80fd3e%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e23e424c-0105-4b11-878c-86bb9dbe5613%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django 1.9 Apps aren't loaded yet

2016-03-02 Thread Larry Martell
I am developing a django app. I had the basic site running, but I had
not yet created any models. I created a model, and now the server
fails to start with "Apps aren't loaded yet"

traceback below. Anyone know what I am doing wrong?

Traceback (most recent call last):
  File "./manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File 
"/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py",
line 353, in execute_from_command_line
utility.execute()
  File 
"/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py",
line 327, in execute
django.setup()
  File "/usr/local/lib/python2.7/site-packages/django/__init__.py",
line 18, in setup
apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python2.7/site-packages/django/apps/registry.py",
line 85, in populate
app_config = AppConfig.create(entry)
  File "/usr/local/lib/python2.7/site-packages/django/apps/config.py",
line 90, in create
module = import_module(entry)
  File "/usr/local/lib/python2.7/importlib/__init__.py", line 37, in
import_module
__import__(name)
  File "/projects/foo/foo/app/scripts/__init__.py", line 3, in 
from tasks import *
  File "/projects/foo/foo/app/scripts/tasks/__init__.py", line 1, in 
from makeworkitemlist import MakeWorkItemList
  File "/projects/foo/foo/app/scripts/tasks/makeworkitemlist.py", line
2, in 
from foo.app.scripts.models import Reports
  File "/projects/foo/foo/app/scripts/models.py", line 3, in 
class Reports(models.Model):
  File "/usr/local/lib/python2.7/site-packages/django/db/models/base.py",
line 94, in __new__
app_config = apps.get_containing_app_config(module)
  File "/usr/local/lib/python2.7/site-packages/django/apps/registry.py",
line 239, in get_containing_app_config
self.check_apps_ready()
  File "/usr/local/lib/python2.7/site-packages/django/apps/registry.py",
line 124, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY6Qw%2BPzCw7%2B1zcmZROUQo%2B79dXTpXPjvwa6gr6s0vZikg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Provide way to add an item during "Selecting a ForeignKey"

2016-03-02 Thread guettli
I found that django-autocomplete-light supports "Add another popup outside 
the admin":

http://django-autocomplete-light.readthedocs.org/en/latest/addanother.html

This is exactly what I was looking for :-)


Am Samstag, 27. Februar 2016 14:28:27 UTC+1 schrieb guettli:
>
> I use django-select2  for 
> easy ForeignKey picking. Works nice.
>
>
> But how can I add a new item in the ForeignKey table?
>
>
> I would like to have a big [+] button and then a dialog should open.
>
>
> AFAIK django-select2 does not help here. Is there a different library 
> which can help here?
>
>
> The result should look like this "create user" example: 
> https://jqueryui.com/dialog/#modal-form
>
>
> I don't care how the pop-up works. 
>
>
> Via ajax, browser pop-up, or like in django admin, ... 
>
>
> It should work and be re-usable. I don't want to invent this common 
> pattern again and again.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/353df277-1093-4247-91d8-2536678d1516%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Provide way to add an item during "Selecting a ForeignKey"

2016-03-02 Thread guettli
Just for the records: "add another" is one compared feature in this 
comparison grid: https://www.djangopackages.com/grids/g/auto-complete/

Am Mittwoch, 2. März 2016 13:12:02 UTC+1 schrieb guettli:
>
> I found that django-autocomplete-light supports "Add another popup outside 
> the admin":
>
> http://django-autocomplete-light.readthedocs.org/en/latest/addanother.html
>
> This is exactly what I was looking for :-)
>
>
> Am Samstag, 27. Februar 2016 14:28:27 UTC+1 schrieb guettli:
>>
>> I use django-select2  for 
>> easy ForeignKey picking. Works nice.
>>
>>
>> But how can I add a new item in the ForeignKey table?
>>
>>
>> I would like to have a big [+] button and then a dialog should open.
>>
>>
>> AFAIK django-select2 does not help here. Is there a different library 
>> which can help here?
>>
>>
>> The result should look like this "create user" example: 
>> https://jqueryui.com/dialog/#modal-form
>>
>>
>> I don't care how the pop-up works. 
>>
>>
>> Via ajax, browser pop-up, or like in django admin, ... 
>>
>>
>> It should work and be re-usable. I don't want to invent this common 
>> pattern again and again.
>>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5fc48950-89ea-41db-ab06-a54b8381a0e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.9 Apps aren't loaded yet

2016-03-02 Thread Michal Petrucha
On Wed, Mar 02, 2016 at 07:05:53AM -0500, Larry Martell wrote:
> I am developing a django app. I had the basic site running, but I had
> not yet created any models. I created a model, and now the server
> fails to start with "Apps aren't loaded yet"
> 
> traceback below. Anyone know what I am doing wrong?

The problem is that one of your applications (foo.app.scripts) imports
models in its top-level __init__.py. This is not supported; for an
explanation, you can read
https://docs.djangoproject.com/en/1.9/ref/applications/#how-applications-are-loaded

Good luck,

Michal

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20160302123712.GA960%40konk.org.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


Re: variable to a template

2016-03-02 Thread Sergiy Khohlov
 try to use :
"{% static "mysite/scorr{{a}}" %}"



Many thanks,

Serge


+380 636150445
skype: skhohlov

On Wed, Mar 2, 2016 at 1:00 PM, 'luca72' via Django users <
django-users@googlegroups.com> wrote:

> Hello Thanks for your reply
>
> STATIC_URL = '/static/'
>
> I have no static root configured
>
> But why if i writewidth="100" height="100"   i get the image
>
> and if i write   height="100"  where a is the file name i can't get?
>
> The path is
> F:\Sito_01_03_16\test\nuovo\myproject\mysite\static\mysite\scorr
>
> Thanks for your help
>
> Il giorno mercoledì 2 marzo 2016 11:52:05 UTC+1, Sergiy Khohlov ha scritto:
>>
>> original path  og your image please.
>>  Also setting for STATIC_ROOT  from setting.py send please
>>
>> Many thanks,
>>
>> Serge
>>
>>
>> +380 636150445
>> skype: skhohlov
>>
>> On Wed, Mar 2, 2016 at 12:41 PM, 'luca72' via Django users <
>> django...@googlegroups.com> wrote:
>>
>>> Hello i have write this in a template:
>>> {% for a in lista %}
>>> >> height="100" 
>>>  {% endfor %}
>>> But i get no image
>>>
>>> if i add just a  {{a}}  i see that the file name is righ,
>>> also if i direct write the file i get it
>>>  {% for a in lista %}
>>> >> width="100" height="100" 
>>>  {% endfor %}
>>>
>>> can you tell me what is wrong
>>>
>>> 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...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/9a12167f-e919-4632-b77a-6d5acc80fd3e%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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e23e424c-0105-4b11-878c-86bb9dbe5613%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADTRxJNYVrCFyqcnnZhbQqF-Kd-AnB0K3hYWtBj9BtibtELpyQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: variable to a template

2016-03-02 Thread Andreas Schosser
Hi Luca,

>  height="100"  

Try {% static "mysite/scorr/"|add:a %}

Andreas

-- 
Kurs 10 IT-Consulting   www.kurs-10.de
Andreas Schosser  a...@kurs-10.de

Baldestraße. 14  Telefon +49 89 41615842-0
80469 MünchenTelefax +49 89 41615842-3

0x6EDECCF1 - 2AA0 939B 5585 819B FCE8 E43B 0B8E 0DF2 6EDE CCF1

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/56D6E4F5.8010702%40kurs-10.de.
For more options, visit https://groups.google.com/d/optout.


smime.p7s
Description: S/MIME Cryptographic Signature


Django Shell image upload _io.BufferedReader no attribute size

2016-03-02 Thread Povilas Kudriavcevas


down votefavorite 


My problem is that when I try to save image to my model using Django shell 
I get this error that I can't find solution anywere.

models.py

class AdImage(models.Model):
   ad = models.ForeignKey(Ad)
   full_photo = models.ImageField(upload_to='uploads/', blank=True)

I import models create AdImage instance add 'ad' and try to

imagead.full_photo.save("NowHiring.jpg",open("C:\\NowHiring.jpg", "rb"))

but i get an error

Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Users\hp\Envs\platform\lib\site-packages\django\db\models\fields\file
s.py", line 106, in save
self._size = content.sizeAttributeError: '_io.BufferedReader' object has no 
attribute 'size'

Using: *Python 3.5, Django 1.9*


-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f91211d1-1461-4cfb-beda-b37b0bb46d9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Problem uploading image Django 1.9 Python 3.5

2016-03-02 Thread Povilas Kudriavcevas
My problem is that when I try to save image to my model using Django shell 
I get this error that I can't find solution anywere.

models.py

class AdImage(models.Model):
   ad = models.ForeignKey(Ad)
   full_photo = models.ImageField(upload_to='uploads/', blank=True)

I import models create AdImage instance add 'ad' and try to

imagead.full_photo.save("NowHiring.jpg",open("C:\\NowHiring.jpg", "rb"))

but i get an error

Traceback (most recent call last):
  File "", line 1, in 
  File 
"C:\Users\hp\Envs\platform\lib\site-packages\django\db\models\fields\file
s.py", line 106, in save
self._size = content.size
AttributeError: '_io.BufferedReader' object has no attribute 'size'

Using:* Python 3.5, Django 1.9*

What could I do ?

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d89d4906-0494-4d01-bd6a-428f29466f4d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: variable to a template

2016-03-02 Thread 'luca72' via Django users
Thanks now it works

Luca

Il giorno mercoledì 2 marzo 2016 14:05:24 UTC+1, Andreas Schosser ha 
scritto:
>
> Hi Luca, 
>
> >  > height="100"  
>
> Try {% static "mysite/scorr/"|add:a %} 
>
> Andreas 
>
> -- 
> Kurs 10 IT-Consulting   www.kurs-10.de 
> Andreas Schosser  a...@kurs-10.de 
>  
>
> Baldestraße. 14  Telefon +49 89 41615842-0 
> 80469 MünchenTelefax +49 89 41615842-3 
>
> 0x6EDECCF1 - 2AA0 939B 5585 819B FCE8 E43B 0B8E 0DF2 6EDE CCF1 
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/abdc20d6-943e-4466-899b-e682dd0e5d31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.9 Apps aren't loaded yet

2016-03-02 Thread Larry Martell
On Wed, Mar 2, 2016 at 7:37 AM, Michal Petrucha
 wrote:
> On Wed, Mar 02, 2016 at 07:05:53AM -0500, Larry Martell wrote:
>> I am developing a django app. I had the basic site running, but I had
>> not yet created any models. I created a model, and now the server
>> fails to start with "Apps aren't loaded yet"
>>
>> traceback below. Anyone know what I am doing wrong?
>
> The problem is that one of your applications (foo.app.scripts) imports
> models in its top-level __init__.py. This is not supported; for an
> explanation, you can read
> https://docs.djangoproject.com/en/1.9/ref/applications/#how-applications-are-loaded

Thanks you very much for the quick reply. Is there some workaround for
this? What version was this issued introduced in? This code works in
1.5.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY7Y86anuYEKs9X%2Bw%2B27NBFixySwyN--drqVf%2B14%3DEwQ4Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: problem deploying two apps

2016-03-02 Thread frocco
That is correct, sorry for my wording. This is two separate projects that 
need to run on the same server.

On Tuesday, March 1, 2016 at 6:17:33 PM UTC-5, James Schneider wrote:
>
> On Tue, Mar 1, 2016 at 8:56 AM, frocco > 
> wrote:
>
>> Hi,
>>
>> I followed this
>> https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/modwsgi/
>>
>> First app works fine, if I deploy the second app, the settings conflict 
>> and images are not rendered.
>>
>>
> I'm assuming that you have two separate projects that need to run 
> concurrently, not two separate apps within a single Django project (as the 
> Django nomenclature would define). Your Apache config would need to be 
> modified per the answer in this SO: 
> http://stackoverflow.com/questions/6590587/multiple-mod-wsgi-apps-on-one-virtual-host-directing-to-wrong-app
>
> -James
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4221c351-47ee-43a1-a337-3f7625c4f6d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: problem deploying two apps

2016-03-02 Thread frocco
>From your link, it looks like I am using the WSGIDaemonProcess and 
WSGIScriptAlias
The app runs fine, but images do not render unless I remove one project.
As soon as I add the second project, images do not render in static.
Each project has there own static directory under project name

On Wednesday, March 2, 2016 at 8:59:05 AM UTC-5, frocco wrote:
>
> That is correct, sorry for my wording. This is two separate projects that 
> need to run on the same server.
>
> On Tuesday, March 1, 2016 at 6:17:33 PM UTC-5, James Schneider wrote:
>>
>> On Tue, Mar 1, 2016 at 8:56 AM, frocco  wrote:
>>
>>> Hi,
>>>
>>> I followed this
>>> https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/modwsgi/
>>>
>>> First app works fine, if I deploy the second app, the settings conflict 
>>> and images are not rendered.
>>>
>>>
>> I'm assuming that you have two separate projects that need to run 
>> concurrently, not two separate apps within a single Django project (as the 
>> Django nomenclature would define). Your Apache config would need to be 
>> modified per the answer in this SO: 
>> http://stackoverflow.com/questions/6590587/multiple-mod-wsgi-apps-on-one-virtual-host-directing-to-wrong-app
>>
>> -James
>>
>>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fa704544-9bbb-48ce-b917-8b6b88a0800c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: a question about django admin and language

2016-03-02 Thread Luis Zárate
You could write a middleware after language middleware than check if it is
a admin URL and change the language to English.

https://docs.djangoproject.com/en/1.9/topics/http/middleware/

https://docs.djangoproject.com/es/1.9/topics/i18n/translation/


El viernes, 26 de febrero de 2016, Will Harris 
escribió:
> Hi Paul,
> If you want the admin site to behave differently than the main site, you
could consider running two instances, one with the i18n activated for the
main site, and one for admin users with it disabled. In production, from a
security standpoint, it's a good idea to have the admin site running with
different settings/access in any case.
> Will
>
> On Thursday, February 25, 2016 at 2:37:54 PM UTC+1, Paul Z wrote:
>>
>>  Hi,
>>
>> I'm new to django, I try to set up a site that can select language
automatically.
>> So, I set as below:
>>
>> LANGUAGE_CODE = 'en'
>>
>> TIME_ZONE = 'UTC'
>>
>> USE_I18N = True
>>
>> USE_L10N = False
>>
>> USE_TZ = False
>>
>> For now, It can select language automatically, But, The question is:
>>
>> I don't want to it select language in Django Admin Interface, I want to
it always display in English.
>>
>> So, How to?
>>
>> Thanks
>> Paul Z
>>
>>



>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/b612e437-c093-4c06-b7ec-e53244402b2d%40googlegroups.com
.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAG%2B5VyNpEXRET5xHsabr_56RMH%3DL%2BaqtzLuh4zfn2whFf_5oYQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.9 Apps aren't loaded yet

2016-03-02 Thread Michal Petrucha
On Wed, Mar 02, 2016 at 08:20:44AM -0500, Larry Martell wrote:
> On Wed, Mar 2, 2016 at 7:37 AM, Michal Petrucha
>  wrote:
> > On Wed, Mar 02, 2016 at 07:05:53AM -0500, Larry Martell wrote:
> >> I am developing a django app. I had the basic site running, but I had
> >> not yet created any models. I created a model, and now the server
> >> fails to start with "Apps aren't loaded yet"
> >>
> >> traceback below. Anyone know what I am doing wrong?
> >
> > The problem is that one of your applications (foo.app.scripts) imports
> > models in its top-level __init__.py. This is not supported; for an
> > explanation, you can read
> > https://docs.djangoproject.com/en/1.9/ref/applications/#how-applications-are-loaded
> 
> Thanks you very much for the quick reply. Is there some workaround for
> this? What version was this issued introduced in? This code works in
> 1.5.

This is a result of making the initialization process of Django
explicit in 1.7. The correct way of fixing errors like this is to
untangle your imports, and remove anything that depends on models from
top-level __init__.py in your all your application packages. You want
to draw a boundary around all code that uses models, and make sure
that none of it is imported before django.setup() has finished.

For a quick and dirty workaround, you can always move the model import
statements into the definitions of functions that require it; that
way, the import is not executed until the function itself is called.

Good luck,

Michal

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20160302143450.GB960%40konk.org.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


django-smart-selects: ChainedManyToManyField value not selected after saving data via django admin

2016-03-02 Thread Bernardo Garcia


I am working with django-smart-selects 
 via django admin form. 
The idea that I have is try a model chaining or deployment of value fields 
accord to previous value in a previous separate field.


Accord to the first option value selected in the first field, I want that 
in the second field some values be deployed and which be of selection 
multiple. In fact, this idea I got it accomplished.


I have the following small level design approach for this:






The code that is related to the above design is this:

class AffectedSegment(models.Model):
SEGMENTO_ESCAPULA = 'ESCAPULA'
SEGMENTO_HOMBRO = 'HOMBRO'
SEGMENTO_CODO = 'CODO'
SEGMENTO_ANTEBRAZO = 'ANTEBRAZO'
SEGMENTO_CARPO_MUNECA = 'CARPO_MUNECA'
SEGMENTO_MANO = 'MANO'
SEGMENTO_CHOICES = (
(SEGMENTO_ESCAPULA, u'Escápula'),
(SEGMENTO_HOMBRO, u'Hombro'),
(SEGMENTO_CODO, u'Codo'),
(SEGMENTO_ANTEBRAZO, u'Antebrazo'),
(SEGMENTO_CARPO_MUNECA, u'Carpo/Muñeca'),
(SEGMENTO_MANO, u'Mano'),
)
affected_segment = models.CharField(
   max_length=12, 
   choices=SEGMENTO_CHOICES, 
   blank=False, verbose_name='Segmento afectado'
   )

class Meta:
verbose_name = 'Segmentos corporale'

def __str__(self):
return "%s" % self.affected_segment
class Movement(models.Model):
type = models.CharField(
  max_length=255,
  verbose_name='Tipo de movimiento'
  )
corporal_segment_associated = models.ManyToManyField(
  AffectedSegment, blank=False, 
  verbose_name='Segmento corporal asociado'
  )

class Meta:
verbose_name = 'Movimiento'

def __str__(self):
return "%s" % self.type
class RehabilitationSession(models.Model):
affected_segment = models.ManyToManyField(
  AffectedSegment,
  verbose_name='Segmento afectado'
  )
movement = ChainedManyToManyField(
  Movement, #chaining model
  chained_field = 'affected_segment',
  chained_model_field = 'corporal_segment_associated',
  verbose_name='Movimiento')



Until this section all this O.K.

*MY CHALLENGES*


*1. *When I save one movement (model Movement chained) which are related to 
affected segment (affected_segment in AffectedSegment model and 
ManyToManyField in RehabilitationSession model) , after I going to this row 
or rehabilitation sessions instance via admin and the movement that I 
select before is not selected, despite of that this is saved and I can 
explore via transitivity relationship the value inside my postgresql 
database.



In this video , I've been exploring the 
database records and showing the behavior of my form in which is denoted my 
inconvenient

I can see that this bug/error/issue or inconvenient was happen to 
others https://github.com/digi604/django-smart-selects/issues/112


*2.* Other inconvenient is that when I select more of than one affected 
segment, in the movements field. just are deployed the values related with 
the first affected segment selected and the movements associated to the 
second selected are not deployed ...

The explanation is the following accord to this picture:




When I select one second affected segment (segmento afectado field, *CODO* 
option 
in the red square number one), I want that the movements/exercises 
associated to these second affected segment that it's *CODO*


Currently, just are deployed the movements of Descenso,Elevación, 
Protracción y Retracción (options shown in the green square number two) and 
these are only or correspond to the first option of affected segment 
selected which is ESCÁPULA in the red square number one


In this video  I show you this in detail.


How I can do this I want?


In some sense, in the AffectedSegment model .. should be able to know the 
option (something seem to get_element_by_id in html?) is selected for know 
when one second option is selected and shown the movements of together 
options (affected segments selected)?


I hope that post a videos don't be a problem or inconvenient


Any support or orientation would be appreciated



-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0da

how to implement lazy settings as django setting

2016-03-02 Thread Luis Zárate
I need to implement a lazy setting like django setting that could be call
globally in several apps but get his values from a model in database.

I have some settings that need to be change by the admin user, so my apps
expect that settings but can not loaded on django setup because needs
populate with fields in db or something that user can change without
touching code.  So I thing I can implement a lazy setting that use database
in request process time and cached the result.

So do you have some idea how to implement that.

-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAG%2B5VyN8axAnC_jQuDdZ%2BLXTMe4hkVcYuityWc0t8sqE9WEyEQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: problem deploying two apps

2016-03-02 Thread frocco
I changed the second project to use STATIC_URL = *'/static1/' and the 
apache conf to **ALIAS /static1/* 

*and the images now show*
On Wednesday, March 2, 2016 at 9:02:40 AM UTC-5, frocco wrote:
>
> From your link, it looks like I am using the WSGIDaemonProcess and 
> WSGIScriptAlias
> The app runs fine, but images do not render unless I remove one project.
> As soon as I add the second project, images do not render in static.
> Each project has there own static directory under project name
>
> On Wednesday, March 2, 2016 at 8:59:05 AM UTC-5, frocco wrote:
>>
>> That is correct, sorry for my wording. This is two separate projects that 
>> need to run on the same server.
>>
>> On Tuesday, March 1, 2016 at 6:17:33 PM UTC-5, James Schneider wrote:
>>>
>>> On Tue, Mar 1, 2016 at 8:56 AM, frocco  wrote:
>>>
 Hi,

 I followed this
 https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/modwsgi/

 First app works fine, if I deploy the second app, the settings conflict 
 and images are not rendered.


>>> I'm assuming that you have two separate projects that need to run 
>>> concurrently, not two separate apps within a single Django project (as the 
>>> Django nomenclature would define). Your Apache config would need to be 
>>> modified per the answer in this SO: 
>>> http://stackoverflow.com/questions/6590587/multiple-mod-wsgi-apps-on-one-virtual-host-directing-to-wrong-app
>>>
>>> -James
>>>
>>>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3c3105e8-ccaa-468a-907c-6a066aab7655%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Absolute beginner question -- recipes

2016-03-02 Thread Simon Gunacker
Thank you James. Taking your suggestion, I solved it!

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7c7494ec-8ee5-4d14-bfae-a52297696e59%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Absolute beginner question -- recipes

2016-03-02 Thread Simon Gunacker
Inspired by Mike Dewhirsts suggestion on building hierachical structures, 
I've made up another model:
class Part(models.Model):
parts = models.ForeignKey('Part', null=True, blank=True, default=None, 
related_name='pieces')
name = models.CharField(max_length=200)

Then I made my view:
class PartsView(generic.ListView):
context_object_name='parts'
model=Part

But how should I design my template now?
Parts


{% for part in parts %}
  
{% endfor %}


I already found different answers on the net reaching from 'impossible' to 
'with-tag' or 'install some add-ons'. According to Mikes former suggestion, 
I expected something easy and elegant here ...

regards, Simon


-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/abcfeada-4bd6-496f-a3f8-4678b08d8440%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


GROUP BY without using aggregate function

2016-03-02 Thread marcin . j . nowak
Hello,

I would like to query database with Django ORM and add GROUP BY clause 
without including unnecessary counting, avg, etc.
I can force/hack queryset by settting qs.query.group_by=['my_column'], but 
this is unclean and risky.

Is possible something like:

MyModel.objects.filter(...).group_by('my_column')

?

Kind Regards,
Marcin

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/64f4b422-7704-413d-a9c5-837c53eaefc9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: variable to a template

2016-03-02 Thread raoul
Hi Luca,

Did {{ a }} solve the problem?

Cheers,
Raoul

On Wednesday, March 2, 2016 at 2:12:46 PM UTC+1, luca72 wrote:
>
> Thanks now it works
>
> Luca
>
> Il giorno mercoledì 2 marzo 2016 14:05:24 UTC+1, Andreas Schosser ha 
> scritto:
>>
>> Hi Luca, 
>>
>> > > > height="100"  
>>
>> Try {% static "mysite/scorr/"|add:a %} 
>>
>> Andreas 
>>
>> -- 
>> Kurs 10 IT-Consulting   www.kurs-10.de 
>> Andreas Schosser  a...@kurs-10.de 
>>
>> Baldestraße. 14  Telefon +49 89 41615842-0 
>> 80469 MünchenTelefax +49 89 41615842-3 
>>
>> 0x6EDECCF1 - 2AA0 939B 5585 819B FCE8 E43B 0B8E 0DF2 6EDE CCF1 
>>
>>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2778f470-dc15-4d2e-9ada-d6146f6909b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: GROUP BY without using aggregate function

2016-03-02 Thread Dan Tagg
if your aren't counting or averaging then why are you grouping?

D

On 2 March 2016 at 17:06,  wrote:

> Hello,
>
> I would like to query database with Django ORM and add GROUP BY clause
> without including unnecessary counting, avg, etc.
> I can force/hack queryset by settting qs.query.group_by=['my_column'],
> but this is unclean and risky.
>
> Is possible something like:
>
> MyModel.objects.filter(...).group_by('my_column')
>
> ?
>
> Kind Regards,
> Marcin
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/64f4b422-7704-413d-a9c5-837c53eaefc9%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Wildman and Herring Limited, Registered Office: 52 Great Eastern Street,
London, EC2A 3EP, Company no: 05766374

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY7tKM%2BBFPGf0o%3DXwJBOAhiyt8Avu0Xbe%2BqpfeiFQoRafA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: GROUP BY without using aggregate function

2016-03-02 Thread marcin . j . nowak


On Wednesday, March 2, 2016 at 6:11:32 PM UTC+1, Dan Tagg wrote:
>
> if your aren't counting or averaging then why are you grouping?
>
>
>
To fast find distinct values within big dataset - some queries on some 
engines may be faster when using grouping. 
It was known technique years ago and I'm still using it.

Marcin

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9aa22036-4537-4734-b2d5-93cc625b09f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: variable to a template

2016-03-02 Thread Fred Stluka

Luca,

You can't nest a variable evaluation (via {{}}) inside a tag
execution {%%}.  But you can put them side by side to achieve
the effect you want:

'{% static "mysite/scorr" %}'/{{a}}'

--Fred

Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.

On 3/2/16 8:04 AM, Andreas Schosser wrote:

Hi Luca,


 

Try {% static "mysite/scorr/"|add:a %}

Andreas



--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/56D722C1.1080103%40bristle.com.
For more options, visit https://groups.google.com/d/optout.


Re: problem deploying two apps

2016-03-02 Thread Bernardo Garcia
Hi frocco

May be this post can ve useful for you, althought instead of uwsgi use 
gunicorn 
http://michal.karzynski.pl/blog/2013/10/29/serving-multiple-django-applications-with-nginx-gunicorn-supervisor/

On Tuesday, March 1, 2016 at 11:56:57 AM UTC-5, frocco wrote:
>
> Hi,
>
> I followed this
> https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/modwsgi/
>
> First app works fine, if I deploy the second app, the settings conflict 
> and images are not rendered.
>
> [code]
> Alias /static /var/www/django/track/static
>
> 
> Require all granted
> 
>
> 
> 
> Require all granted
> 
> 
>
>
> 
> Require all granted
> 
>
> WSGIDaemonProcess track 
> python-path=/var/www/django/track:/usr/lib/python2.7/site-packages
> WSGIProcessGroup track
> WSGIScriptAlias /track /var/www/django/track/track/wsgi.py 
> process-group=track
> [/code]
>
> [code]
> Alias /static /var/www/django/coffee/static
>
> 
> Require all granted
> 
>
> 
> 
> Require all granted
> 
> 
>
>
> 
> Require all granted
> 
>
> WSGIDaemonProcess coffee 
> python-path=/var/www/django/coffee:/usr/lib/python2.7/site-packages
> WSGIProcessGroup coffee
> WSGIScriptAlias /coffee /var/www/django/coffee/coffee/wsgi.py 
> process-group=coffee
>
>
> [/code]
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bcb39068-2d4c-490f-bdcc-5eceb1e0ac5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Handling fields with values that depend on a value from previous file

2016-03-02 Thread Bernardo Garcia


I want handling fields' values which depend on a value from another field


Currently I am working with django-smart-selects 
 but I have this problems 



Reading, in the issues and the web is possible that django-smart-selects have 
some problems related or similar to the mine. 



Do you know some application in Django whcih I can work for handling 
fields' values which depend on a value from another field ?


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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/60ecf184-ab34-4537-acdf-2f1f40a1325b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error running Django tutorial

2016-03-02 Thread jorrit787
Glad you got it solved!!


On Monday, February 29, 2016 at 10:10:58 PM UTC+1, Mike Kipling wrote:
>
> I found the problem.
>
> When the mysite\urls.py file is created, it has this line already in it.
>
> from django.conf.urls import url
>
> The tutorial asks you to add the following lines to the file.
>
> from django.conf.urls import include, url
> from django.contrib import admin
>
> urlpatterns = [
> url(r'^polls/', include('polls.urls')),
> url(r'^admin/', admin.site.urls),
> ]
>
> I must did not notice that the 'include' was different, and so I had not 
> placed it into the file.  I changed the file to add the 'include' and 
> everything worked.
>
> Thank you for the help.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4ce4dd13-aa8b-4981-8a0a-727a16ac19ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


What are the things similar TabularInline and StackedInline?

2016-03-02 Thread setivolkylany
Just wondering, how in django so few similar things.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/78dc0f8a-5574-4b2b-9cc8-e137b129d2ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How will make OneToOne relationship in admin for my User model?

2016-03-02 Thread setivolkylany
I need create link in my admin part of site, for models AccountUser and 
AccountUserInfo

--
My models.py
--

import imghdr
import string
import datetime

from django_countries.fields import CountryField

from django.db import models
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager, 
PermissionsMixin
from django.core.urlresolvers import reverse
from django.core.exceptions import ValidationError
from django.core.validators import MinLengthValidator
from django.conf import settings

from libs.validators import OnlyLowercaseAndDigits


ALLOWED_CHARS = string.ascii_lowercase + string.digits
MAX_LENGTH = 8


class AccountUserManager(*BaseUserManager*):
"""
Manager for my user model
"""

def create_user(self, email, name, password=None):
"""
Creates and saves a user with the given email, name of account and 
password.
"""
if not email:
raise ValueError('User must have an email address')
if not name:
raise ValueError('User must have a name of account')
user = self.model(email=self.normalize_email(email), name=name)
user.set_password(password)
user.save()
return user

def create_superuser(self, email, name, password):
"""
Creates and saves a superuser with the given email, name of account 
and password.
"""
if not password:
raise ValueError('Superuser must be have a password')
user = self.create_user(email=self.normalize_email(email), 
name=name, password=password)
user.is_superuser = True
user.save()
return user

def make_random_password(self, length=10, allowed_chars=ALLOWED_CHARS):
return super().make_random_password(length, allowed_chars)


class AccountUser(*AbstractBaseUser*, *PermissionsMixin*):
"""
Model for users, registering by email and unique name of account
"""

email = models.EmailField('Email of account', max_length=50, 
unique=True)
name = models.CharField('Account of name', max_length=50, validators=[
OnlyLowercaseAndDigits,
MinLengthValidator(MAX_LENGTH, 'Field must be at least {0} 
chars'.format(MAX_LENGTH)),
])
is_active = models.BooleanField(default=True)
date_joined = models.DateTimeField('Date joined', auto_now_add=True)

objects = AccountUserManager()

USERNAME_FIELD = 'email'
REQUIRED_FIELDS = ['name']

class Meta:
db_table = 'account_user'
verbose_name = "AccountUser"
verbose_name_plural = "AccountUsers"
get_latest_by = 'date_joined'
ordering = ['-date_joined']

def __str__(self):
return '{0.email}'.format(self)

def save(self, *args, **kwargs):
try:
self.full_clean()
except ValidationError as errors_message:
print('Was happened next 
errors:\n-')
for error in errors_message:
print(error)
else:
super().save(*args, **kwargs)
account = AccountUser.objects.get(email=self.email)
if not hasattr(account, 'accountuserinfo'):
AccountUserInfo.objects.create(account=account)

def get_absolute_url(self):
return reverse('app_accounts:account_profile')

def get_full_name(self):
return '{0.name} ({0.email})'.format(self)

def clean(self):
if len(self.password) < MAX_LENGTH:
raise ValidationError({
'password': 'Length of password must be at least 
{0}'.format(MAX_LENGTH)
})
if all(i in string.digits for i in self.password):
raise ValidationError({
'password': 'Your password can\'t be entirely numeric'
})

def get_short_name(self):
return '{0.email}'.format(self)

@property
def is_staff(self):
return self.is_superuser


class AccountUserInfo(models.Model):

MAN = 'man'
WOMAN = 'woman'
VAGUE = 'vague'

GENDER_CHOICES = [
(VAGUE, 'Vague'),
(MAN, 'Male'),
(WOMAN, 'Female'),
]

def dispatch_account_media_files(instance, filename):
return '{0}/app_accounts/{1}'.format(instance.account.__str__(), 
filename)

account = models.OneToOneField(AccountUser, on_delete=models.CASCADE)
first_name = models.CharField('First name', max_length=50, blank=True, 
null=True)
last_name = models.CharField('Last name', max_length=50, blank=True, 
null=True)
picture = models.ImageField('Picture', 
upload_to=dispatch_account_media_files, blank=True, null=True)
gender = models.CharField('Gender', max_length=10, 
choices=GENDER_CHOICES, default=GENDER_CHOICES[0][0])
country = CountryField('Country', blank_label='(select country)', 
blank=True, null=True)
birthday = models.DateField('Birthday', blank=True, null=True)
# theme
# language

class Meta:
 

how to implement lazy settings as django setting

2016-03-02 Thread Luis Zárate
I need to implement a lazy setting like django setting that could be call
globally in several apps but get his values from a model in database.

I have some settings that need to be change by the admin user, so my apps
expect that settings but can not loaded on django setup because needs
populate with fields in db or something that user can change without
touching code.  So I thing I can implement a lazy setting that use database
in request process time and cached the result.

So do you have some idea how to implement that.

-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAG%2B5VyN8A34Jme701Oz%2BzprfbQyxfu8K7d%3D9kUw8BSMYyCq20g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANNOUNCE] Django security releases issued: 1.9.3 and 1.8.10

2016-03-02 Thread José David Ordoñez
After upgrading django 1.8.9 to 1.8.10 my i18n/setlang/ went crazy 
"TypeError: must be unicode not str" when using {% url 'set_language' %} by 
going back to 1.8.9 solved the issue.

El martes, 1 de marzo de 2016, 12:50:27 (UTC-4:30), Tim Graham escribió:
>
> Today the Django team issued 1.9.3 and 1.8.10 as part of our security 
> process. This releases address two security issues, and we encourage all 
> users to upgrade as soon as possible.
>
> Details are available on the Django project weblog:
>
> https://www.djangoproject.com/weblog/2016/mar/01/security-releases/
>
> As a reminder, we ask that potential security issues be reported via 
> private email to secu...@djangoproject.com  and not via 
> Django's Trac instance or the django-developers list. Please see 
> https://www.djangoproject.com/security for further information.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fbb581a2-005a-4efe-b2be-e219ef486ecf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANNOUNCE] Django security releases issued: 1.9.3 and 1.8.10

2016-03-02 Thread Tim Graham
Please create a separate thread with some details such as a sample project 
with steps to reproduce the issue so we can determine if it's a problem in 
Django or in your application. Thanks!

On Wednesday, March 2, 2016 at 8:49:03 PM UTC-5, José David Ordoñez wrote:
>
> After upgrading django 1.8.9 to 1.8.10 my i18n/setlang/ went crazy 
> "TypeError: must be unicode not str" when using {% url 'set_language' %} by 
> going back to 1.8.9 solved the issue.
>
> El martes, 1 de marzo de 2016, 12:50:27 (UTC-4:30), Tim Graham escribió:
>>
>> Today the Django team issued 1.9.3 and 1.8.10 as part of our security 
>> process. This releases address two security issues, and we encourage all 
>> users to upgrade as soon as possible.
>>
>> Details are available on the Django project weblog:
>>
>> https://www.djangoproject.com/weblog/2016/mar/01/security-releases/
>>
>> As a reminder, we ask that potential security issues be reported via 
>> private email to secu...@djangoproject.com and not via Django's Trac 
>> instance or the django-developers list. Please see 
>> https://www.djangoproject.com/security for further information.
>>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d55193d8-0cbc-48a6-9267-e1e8bf931eba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Debugging DJango app on production for High CPU Usage

2016-03-02 Thread Web Architect
Hi James,

Thanks for the detailed explanation. Certainly helps and I would embed 
logging to debug the CPU usage. 

Please find my comments inline:

On Monday, February 29, 2016 at 2:45:41 PM UTC+5:30, James Schneider wrote:
>
>
> On Tue, Feb 23, 2016 at 8:59 PM, Web Architect  > wrote:
>
>> Hi,
>>
>> We have an ecommerce platform based on Django. We are using uwsgi to run 
>> the app. The issue the CPU usage is hitting the roof (sometimes going 
>> beyond 100%) for some scenarios. I would like to debug the platform on 
>> Production to see where the CPU consumption is happening. We have used 
>> Cache all over the place (including templates) as well - hence, the DB 
>> queries would be quite limited. 
>>
>
> Have you validated that your cache is actually being used, and not just 
> populated? I've seen that before.
>

Cache is being and has been validated. But one thing I have observed is - 
while I was storing ORM objects (DB results) in cache to avoid DB queries, 
it proved to be expensive due to the object related operations 
(manipulating and copying the objects in cache). We are using Redis and 
Redis only handles strings I think. Hence, I reverted back to DB. 

I am personally in favour of async based frameworks like Tornado - in fact 
have used it for a high capacity Pinterest like platform where the 
performance has been excellent. But Tornado is quite lightweight and lot of 
services need to be built by us - hence, chose Django for ecommerce. This 
was the first experience with a complex service (ecommerce) on a platform 
like Django. Since Django is Sync, I was wondering if the threads getting 
stuck waiting for DB responses. 

>
>  
>
>> I would refrain from using Django-debug toolbar as it slows down the 
>> platform further, increases the CPU usage and also need to turn the DEBUG 
>> on. Is there any other tool or way to debug the platform? Would appreciate 
>> any recommendations/suggestions. 
>>
>
>
> Have you looked into profiling the code or adding logging statements 
> throughout your code to determine when/where particular segments are being 
> run? I would definitely start with logging. I'm assuming you have 
> suspicions on where your pain points might be:
>
> https://docs.djangoproject.com/en/1.9/topics/logging/
>
> I would put them in places that may be part of large loops (in terms of 
> number of objects queried or depth of relationships traversed), or 
> sprinkled within complex views. You have to start narrowing down which 
> page/pages are causing your angst. 
>
>
> Also, does the Django ORM increase the CPU usage? Does it block the CPU? 
>> Would appreciate if anyone could throw some light on this.
>>
>
> I'm not sure about blocking, but if deployed correctly, the ORM should 
> have a negligible (and acceptable) hit to the CPU in most cases, if you 
> notice one at all. I've seen spikes from bad M2M relationships where 
> prefetch_related() was needed (>200 queries down to 3 with 
> prefetch_related, and ~1-2s total response down to <80ms if I recall 
> correctly). The most common case I run into is as part of nested {% for %} 
> loops within a template that dig down through relationships.
>

We have 'for loops' in templates where DB queries are being made.  Would 
look into those. 

>
> I would also consider increasing the logging levels of your cache and DB 
> to see if you are getting repetitive queries. The ORM does cause those from 
> time to time since it has non-intuitive behavior in some edge cases. You 
> can try that during low activity periods to keep the extra logging from 
> overwhelming the system. Sometimes you can still catch the issue with a 
> single end-user for something like repetitive/multiple queries, and are 
> actually much easier to diagnose on a low usage server.
>
> Do you have any other jobs that run against the system (session cleanup, 
> expired inventory removal, mass mailing, etc.)? Would it be possible for 
> those to be the culprit?
>
We do not have any other bulk tasks right now. If possible, we try to do 
those separately with crons.  

>
> Have you figured out any reproducible trigger?
>

I have done some load testing with locust.io and know there are few views 
which are the culprits - specifically the ones where we show bunch of 
products. But  wanted to make sure if Django is not a bottleneck. 

 

>
> -James
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/dd47a604-26ab-46ed-83f7-3328f6d4fc8f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Debugging DJango app on production for High CPU Usage

2016-03-02 Thread Web Architect
Integrated new Relic and seems to be good. Thanks for the suggestion. 

On Monday, February 29, 2016 at 3:20:43 PM UTC+5:30, Lloyd Dube wrote:
>
> New Relic.
>
> On Wed, Feb 24, 2016 at 6:59 AM, Web Architect  > wrote:
>
>> Hi,
>>
>> We have an ecommerce platform based on Django. We are using uwsgi to run 
>> the app. The issue the CPU usage is hitting the roof (sometimes going 
>> beyond 100%) for some scenarios. I would like to debug the platform on 
>> Production to see where the CPU consumption is happening. We have used 
>> Cache all over the place (including templates) as well - hence, the DB 
>> queries would be quite limited. 
>>
>> I would refrain from using Django-debug toolbar as it slows down the 
>> platform further, increases the CPU usage and also need to turn the DEBUG 
>> on. Is there any other tool or way to debug the platform? Would appreciate 
>> any recommendations/suggestions. 
>>
>> Also, does the Django ORM increase the CPU usage? Does it block the CPU? 
>> Would appreciate if anyone could throw some light on this.
>>
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/c2699791-6de9-4b94-975b-fd1d4f8bbd3c%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Regards,
> Sithembewena
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c7e7f373-902f-4cc9-9e93-9063fa138a27%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.