Re: django on rhel5 with both python2.4 and python2.7 confusion

2014-05-07 Thread Kelvin Wong
Question one...

The gist is:

1. Set up Virtualenv and Virtualenvwrapper (lots of howtos on the web for 
this - find one written in the last year)
2. Set correct environment keys to point to the right Python (similar to 
the following, you paths may be different)

# ~/.bashrc
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python2.7
export VIRTUALENVWRAPPER_VIRTUALENV=$HOME/.local/bin/virtualenv-2.7
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Projects
source $HOME/.local/bin/virtualenvwrapper.sh

3. Make a virtualenv: like this $ mkvirtualenv myappenv
4. Install Django into the virtualenv (you should have been dumped into it 
after you made it): (myappenv) $ pip install Django
5. Check which django-admin.py you are using

$ which django-admin.py
/home/myuser/.virtualenvs/myappenv/bin/django-admin.py

Hint: Webfaction uses CentOS with many different types of Pythons. 
Searching their support website may be helpful.

---

Question two: Use mod_wsgi rather than mod_python. See warning at the top 
of the Dj1.4 docs

https://docs.djangoproject.com/en/1.4/howto/deployment/modpython/

Setting up a Django app is more complex than setting up a PHP app (one 
persons opinion). The benefit is that at the end of the ordeal you will be 
running Python and not PHP (one persons opinion).

:)

K

-- 
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/a5356de2-3b61-45d6-a9de-8c76472d2a4e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: What is different of handling character code between pure Python and Django?

2014-05-07 Thread Sugita Shinsuke
Hello Tom Evans


> plain single and double quotes - " and ', not “ and ‘. 
My e-mail client is Gmail web client.

>What version of Python? 2.x or 3.x? 
Python version is 2.7.5
And, Django version is 1.3.7

>There was an old case to force Django to use UTF-8: 
I added 
sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
But, I couldn't resolve...

>language that user requests (if supported and USE_i18N=True) or 
LANGUAGE_CODE otherwise. 

Both of them are True.
USE_I18N = True
USE_L10N = True


2014年5月8日木曜日 1時23分01秒 UTC+9 Tom Evans:
>
> On Sun, Apr 27, 2014 at 7:13 AM, Sugita Shinsuke 
>  
> wrote: 
> > Hi there 
> > 
> > I’d like to run Java code via Django. 
> > 
> > The Java code, javaprogram use like below. 
> > 
> > — 
> > java javaprogram [text] [file_name] 
> > — 
> > 
> > text is parameter. multi-byte character is also okey. 
> > file_name is generate file name. 
> > 
> > So, I run the stand-alone Python program like below could run fine. 
> > — 
> > java_file = ‘javaprogram’ 
> > file_name = ‘filename’ 
> > text = ‘あいうえお’ #Japanese character 
> > java_file_path = ‘/path/to/‘ 
> > class_path = ‘-cp ' + java_file_path 
> > 
> > cmd = “java {0} {1} {2} {3}".format(class_path, java_file, text, 
> file_name) 
>
> What version of Python? 2.x or 3.x? 
>
> Presumably your email client is converting plain single and double 
> quotes to smart quotes and backticks, and in your source code they are 
> plain single and double quotes - " and ', not “ and ‘. 
>
> Django does something explicitly to force management commands to be 
> ascii, see here: 
>
>
> https://docs.djangoproject.com/en/1.6/howto/custom-management-commands/#management-commands-and-locales
>  
>
> There was an old case to force Django to use UTF-8: 
> https://code.djangoproject.com/ticket/5877 
>
> It was closed wontfix on the basis that Django respects your locale, 
> which it no longer does by default. There are several workarounds 
> listed on the first link that will restore that behaviour. Within a 
> view code, the rules are different, it will activate either the 
> language that user requests (if supported and USE_i18N=True) or 
> LANGUAGE_CODE otherwise. 
>
> 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/fdc7f7e6-fd48-445b-be60-6f16b41e8dc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Install Django debug toolbar - Error Path

2014-05-07 Thread Venkatraman S
On Wed, May 7, 2014 at 10:48 PM, Rafael Santos wrote:

> Python Version: 2.7.6
> Django Version: 1.6.4
>
>
> Traceback:
> File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in
> get_response
>   201. response = middleware_method(request, response)
> File "C:\Python27\lib\site-packages\debug_toolbar\middleware.py" in
> process_response
>   86. new_response = panel.process_response(request, response)
> File "C:\Python27\lib\site-packages\debug_toolbar\panels\staticfiles.py"
> in process_response
>   129. 'staticfiles_finders': self.get_staticfiles_finders(),
> File "C:\Python27\lib\site-packages\debug_toolbar\panels\staticfiles.py"
> in get_staticfiles_finders
>   140. for path, finder_storage in finder.list([]):
> File "C:\Python27\lib\site-packages\django\contrib\staticfiles\finders.py"
> in list
>   106. for path in utils.get_files(storage, ignore_patterns):
> File "C:\Python27\lib\site-packages\django\contrib\staticfiles\utils.py"
> in get_files
>   25. directories, files = storage.listdir(location)
> File "C:\Python27\lib\site-packages\django\core\files\storage.py" in
> listdir
>   250. for entry in os.listdir(path):
>
> Exception Type: WindowsError at /Aula10/
> Exception Value: 3 O sistema n�o pode encontrar o caminho especificado
>
>
Looks to be some for of a Language issue.  Unfortunately, am not much of an
UTF-8 expert, but can you check your templates once more.

-- 
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/CAN7tdFTA%2BVvgE-pkm%3DTiA%3DDZOE7ZM%3DURS7Gk6mnHSne_EzL3TQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Python Nested For Looping MultiTable Association Question

2014-05-07 Thread G Z
by the way if someone could help me understand what the docs are saying 
about doing this in views that would be awesome.

On Wednesday, May 7, 2014 11:35:21 AM UTC-6, G Z wrote:
>
> I'm new to django so im assuming there is an easier way to do this but in 
> my html template im trying to do the following
>
> I have a customer that has vmids associated with that and i want to match 
> up every vm in the table vms by id to the vmids tag associated with the 
> customer and display each one for each customer and eventually vmspecs are 
> going to be tied to the vmid. I have my models.py and my index.html can 
> anyone help me understand wahts wrong
>
>
> 
>> 
>> Customres
>> 
>> 
>> Index Page
>> {% for e in customers %}
>> {% for v in vms %}
>> {% if e.VMIDS = v.id %}
>>  {{ e.id }} - {{ e.NAME }} - {{ 
>> v.VMNAME }} 
>> {% endif %}
>> {% endfor %}
>> {% endfor %}
>> 
>> 
>
>
>
>
>
> class Customer(models.Model):
>> NAME = models.CharField(max_length=200)
>> WEBSITE = models.CharField(max_length=200)
>> PHONE = models.CharField(max_length=200)
>> EMAIL = models.CharField(max_length=200)
>> ADDRESS = models.CharField(max_length=200)
>> VMIDS = models.CharField(max_length=200)
>> def __unicode__(self):
>> return self.NAME
>> class Vms(models.Model):
>> VMNAME = models.CharField(max_length=200)
>> VMSTATUS = models.CharField(max_length=200)
>> CUSTOMERID = models.ForeignKey(Customer)
>> def __unicode__(self):
>> return self.VMNAME
>> class Vmspecs(models.Model):
>> CPUS =  models.CharField(max_length=200)
>> CORES =  models.CharField(max_length=200)
>> MEMORY =  models.CharField(max_length=200)
>> HDSPACE =  models.CharField(max_length=200)
>> OS =  models.CharField(max_length=200)
>> UPTIME = models.CharField(max_length=200)
>> VMID  = models.ForeignKey(Vms)
>> CUSTOMERID = models.ForeignKey(Customer)
>> def __unicode__(self):
>>return self.VMID
>
>

-- 
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/900ab03a-b0ff-44a5-837c-f67dd1d222c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Python Nested For Looping MultiTable Association Question

2014-05-07 Thread G Z
ok so I added == to my if statement and independently verified that the 
values were displaying and are correct. So I was wrong though .id is not 
.CUSTOMERID because I returned self.name for the customer model it needs to 
match the strings

so i have 

{% for e in customers %}
{% for d in vms %}
{% if e.NAME == d.CUSTOMERID %}
 {{ e.id }} - {{ e.NAME }} - {{ 
d.VMNAME }$
{% endif %}

e.name - {{ e.NAME }}
d.customerid - {{ d.CUSTOMERID }} 

//I did this to validate I was getting data and the names match when they 
are displayed but the if statement doesn't display anything.

{% endfor %}
{% endfor %}


-- 
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/3c42e133-b325-4694-b3c3-406ae50fd56b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Python Nested For Looping MultiTable Association Question

2014-05-07 Thread Sylvain GROS-DESORMEAUX
use == instead of = in your if statement.




On Wed, May 7, 2014 at 4:18 PM, G Z  wrote:

> out of my stupidity i refined it a bit
>
> {% for e in customers %}
> {% for d in vms %}
> {% if e.id = d.CUSTOMERID %}
>  {{ e.id }} - {{ e.NAME }} - {{
> d.VMNAME }} 
> {% endif %}
> {% endfor %}
> {% endfor %}
>
> why doesn't this work.?
>
> --
> 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/92670fc0-31f0-4d26-91a0-f84560a6991c%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/CAOSN4BWRFoJhR2x8w0awcHNWAyBDyeuCsNTbnAU7tdKFcMmwfQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Linking Multiple Mysql tables with unique identifiers

2014-05-07 Thread G Z
Thanks that worked.

On Tuesday, May 6, 2014 11:34:51 AM UTC-6, G Z wrote:
>
> So I'm trying to set up my django app and I want to link multiple tables 
> each with a unique key identifier. To test this i have the following 
> models. py
> 
> from django.db import models
>
> # Create your models here.
> class Customer(models.Model):
> NAME = models.CharField(max_length=200)
> WEBSITE = models.CharField(max_length=200)
> PHONE = models.CharField(max_length=200)
> EMAIL = models.CharField(max_length=200)
> ADDRESS = models.CharField(max_length=200)
> VMIDS = models.CharField(max_length=200)
>
> def __unicode__(self):
> return self.NAME
> #   return self.NAME
>
> class Vms(models.Model):
> VMID  = models.CharField(max_length=200)
> VMNAME = models.CharField(max_length=200)
> VMSTATUS = models.CharField(max_length=200)
> CUSTOMERID = models.ForeignKey(Customer)
>
> def __unicode__(self):
> return self.VMNAME
> class Vmspecs(models.Model):
> CPUS =  models.CharField(max_length=200)
> CORES =  models.CharField(max_length=200)
> MEMORY =  models.CharField(max_length=200)
> HDSPACE =  models.CharField(max_length=200)
> OS =  models.CharField(max_length=200)
> UPTIME = models.CharField(max_length=200)
> VMID = models.ForeignKey(Vms)
>
> def __unicode__(self):
> return self.VMID
> 
>
> If works fantastic until I try to add a vmspecs in the admin panel and 
> link it to a VM it gives the following error
>
>
>
>
>
> 
>
> Environment:
>
>
> Request Method: POST
> Request URL: http://pythondev.enki.co:8001/admin/vmware/vmspecs/add/
>
> Django Version: 1.6.4
> Python Version: 2.7.3
> Installed Applications:
> ('django.contrib.admin',
>  'django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.messages',
>  'django.contrib.staticfiles',
>  'vmware')
> Installed Middleware:
> ('django.contrib.sessions.middleware.SessionMiddleware',
>  'django.middleware.common.CommonMiddleware',
>  'django.middleware.csrf.CsrfViewMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.contrib.messages.middleware.MessageMiddleware',
>  'django.middleware.clickjacking.XFrameOptionsMiddleware')
>
>
> Traceback:
> File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" 
> in get_response
>   114. response = wrapped_callback(request, 
> *callback_args, **callback_kwargs)
> File 
> "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in 
> wrapper
>   432. return self.admin_site.admin_view(view)(*args, 
> **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" 
> in _wrapped_view
>   99. response = view_func(request, *args, **kwargs)
> File 
> "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" 
> in _wrapped_view_func
>   52. response = view_func(request, *args, **kwargs)
> File 
> "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in 
> inner
>   198. return view(request, *args, **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" 
> in _wrapper
>   29. return bound_func(*args, **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" 
> in _wrapped_view
>   99. response = view_func(request, *args, **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" 
> in bound_func
>   25. return func(self, *args2, **kwargs2)
> File "/usr/local/lib/python2.7/dist-packages/django/db/transaction.py" in 
> inner
>   371. return func(*args, **kwargs)
> File 
> "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in 
> add_view
>   1133. self.log_addition(request, new_object)
> File 
> "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in 
> log_addition
>   600. action_flag=ADDITION
> File 
> "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/models.py" in 
> log_action
>   19. e = self.model(None, None, user_id, content_type_id, 
> smart_text(object_id), object_repr[:200], action_flag, change_message)
>
> Exception Type: TypeError at /admin/vmware/vmspecs/add/
> Exception Value: 'Vms' object has no attribute '__getitem__'
> 
>

-- 
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/3851616c-b474-4170-80c9-1c2b9cc41e61%40googlegroups.com.
For more options, visit 

Re: Python Nested For Looping MultiTable Association Question

2014-05-07 Thread G Z
I read that but didn't quite get how to return the values the way I want.. 

On Wednesday, May 7, 2014 11:35:21 AM UTC-6, G Z wrote:
>
> I'm new to django so im assuming there is an easier way to do this but in 
> my html template im trying to do the following
>
> I have a customer that has vmids associated with that and i want to match 
> up every vm in the table vms by id to the vmids tag associated with the 
> customer and display each one for each customer and eventually vmspecs are 
> going to be tied to the vmid. I have my models.py and my index.html can 
> anyone help me understand wahts wrong
>
>
> 
>> 
>> Customres
>> 
>> 
>> Index Page
>> {% for e in customers %}
>> {% for v in vms %}
>> {% if e.VMIDS = v.id %}
>>  {{ e.id }} - {{ e.NAME }} - {{ 
>> v.VMNAME }} 
>> {% endif %}
>> {% endfor %}
>> {% endfor %}
>> 
>> 
>
>
>
>
>
> class Customer(models.Model):
>> NAME = models.CharField(max_length=200)
>> WEBSITE = models.CharField(max_length=200)
>> PHONE = models.CharField(max_length=200)
>> EMAIL = models.CharField(max_length=200)
>> ADDRESS = models.CharField(max_length=200)
>> VMIDS = models.CharField(max_length=200)
>> def __unicode__(self):
>> return self.NAME
>> class Vms(models.Model):
>> VMNAME = models.CharField(max_length=200)
>> VMSTATUS = models.CharField(max_length=200)
>> CUSTOMERID = models.ForeignKey(Customer)
>> def __unicode__(self):
>> return self.VMNAME
>> class Vmspecs(models.Model):
>> CPUS =  models.CharField(max_length=200)
>> CORES =  models.CharField(max_length=200)
>> MEMORY =  models.CharField(max_length=200)
>> HDSPACE =  models.CharField(max_length=200)
>> OS =  models.CharField(max_length=200)
>> UPTIME = models.CharField(max_length=200)
>> VMID  = models.ForeignKey(Vms)
>> CUSTOMERID = models.ForeignKey(Customer)
>> def __unicode__(self):
>>return self.VMID
>
>

-- 
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/310b2795-0ef9-4846-bc57-a26dc57fa6bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


FormWizard confirmation step logic and Allow dynamic form classes with WizardView

2014-05-07 Thread Fabio Caritas Barrionuevo da Luz
Hello django users.

About the ticket 21644[1] - "FormWizard needs confirmation step logic" 
and ticket 21667[2] - "Allow dynamic form classes with WizardView"

I would like your opinions about the proposed implementation by user 
nickname123[3].

Remember that an implementation is in very early stage.

I added two more classes to at least to me, are useful

see: https://github.com/thenewguy/django_formwizard_mixins/pull/2


[1] https://code.djangoproject.com/ticket/21644
[2] https://code.djangoproject.com/ticket/21667
[3] https://github.com/thenewguy/django_formwizard_mixins

-- 
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/72955561-b8a1-4e3e-b78d-a7f5975123cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Python Nested For Looping MultiTable Association Question

2014-05-07 Thread Rafael E. Ferrero
https://docs.djangoproject.com/en/dev/topics/db/queries/#retrieving-all-objects

--
Rafael E. Ferrero


2014-05-07 16:54 GMT-03:00 G Z :

> I don't know why this isn't working..
>
>
> from django.shortcuts import render
> from django.http import HttpResponse
> from vmware.models import Customer
> from django.shortcuts import render_to_response
> from vmware.models import Vms
>
> def index(request):
> customers = Customer.objects.*all()*
> vms = Vms.objects.all
> ctx = { 'customers':customers, 'vms':vms}
> return render_to_response('index.html', ctx)
>
> my views.py
>
> the loop now reads
>
> {% for e in customers %}
> {% for e in vms %}
> {% if e.VMIDS = e.id %}
>  {{ e.id }} - {{ e.NAME }} - {{
> e.VMNAME }} 
> {% endif %}
> {% endfor %}
> {% endfor %}
>
>
>
>  --
> 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/0e8117da-c6b0-4930-aebd-534124e025a5%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/CAJJc_8Vo29_hW%2BWxPEoaOje-4Hjft-EpZVcjb8DcvzqufhimTw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Python Nested For Looping MultiTable Association Question

2014-05-07 Thread G Z
out of my stupidity i refined it a bit

{% for e in customers %}
{% for d in vms %}
{% if e.id = d.CUSTOMERID %}
 {{ e.id }} - {{ e.NAME }} - {{ 
d.VMNAME }} 
{% endif %}
{% endfor %}
{% endfor %}

why doesn't this work.?

-- 
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/92670fc0-31f0-4d26-91a0-f84560a6991c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Python Nested For Looping MultiTable Association Question

2014-05-07 Thread G Z
I don't know why this isn't working..


from django.shortcuts import render
from django.http import HttpResponse
from vmware.models import Customer
from django.shortcuts import render_to_response
from vmware.models import Vms

def index(request):
customers = Customer.objects.all
vms = Vms.objects.all
ctx = { 'customers':customers, 'vms':vms}
return render_to_response('index.html', ctx)

my views.py

the loop now reads

{% for e in customers %}
{% for e in vms %}
{% if e.VMIDS = e.id %}
 {{ e.id }} - {{ e.NAME }} - {{ 
e.VMNAME }} 
{% endif %}
{% endfor %}
{% endfor %}



-- 
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/0e8117da-c6b0-4930-aebd-534124e025a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Linking Multiple Mysql tables with unique identifiers

2014-05-07 Thread Daniel Roseman
On Tuesday, 6 May 2014 23:06:16 UTC+1, G Z wrote:
>
> Easier to be red
>
> Ok so I have three tables in my database Customer Vms and Vmspecs
>
> Vms is tied through customer by customer id through database id field and 
> vmspecs is tied to vms through the id field for Vms. However when I go into 
> admin panel and try to add vmspecs to vms after connecting the vm to a 
> customer i get the and error here is my model contorller.
>
> class Customer(models.Model):
> NAME = models.CharField(max_length=200)
> WEBSITE = models.CharField(max_length=200)
> PHONE = models.CharField(max_length=200)
> EMAIL = models.CharField(max_length=200)
> ADDRESS = models.CharField(max_length=200)
> VMIDS = models.CharField(max_length=200)
>
> def __unicode__(self):
> return self.NAME
> #   return self.NAME
>
> class Vms(models.Model):
> VMID  = models.CharField(max_length=200)
> VMNAME = models.CharField(max_length=200)
> VMSTATUS = models.CharField(max_length=200)
> CUSTOMERID = models.ForeignKey(Customer)
>
> def __unicode__(self):
> return self.VMNAME
> class Vmspecs(models.Model):
> CPUS =  models.CharField(max_length=200)
> CORES =  models.CharField(max_length=200)
> MEMORY =  models.CharField(max_length=200)
> HDSPACE =  models.CharField(max_length=200)
> OS =  models.CharField(max_length=200)
> UPTIME = models.CharField(max_length=200)
> VMID = models.ForeignKey(Vms)
>
> def __unicode__(self):
> return self.VMID
>
> Here is there error
>
> Environment:
>
> Request Method: POST
> Request URL: http://pythondev.enki.co:8001/admin/vmware/vmspecs/add/
>
> Django Version: 1.6.4
> Python Version: 2.7.3
> Installed Applications:
> ('django.contrib.admin',
>  'django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.messages',
>  'django.contrib.staticfiles',
>  'vmware')
> Installed Middleware:
> ('django.contrib.sessions.middleware.SessionMiddleware',
>  'django.middleware.common.CommonMiddleware',
>  'django.middleware.csrf.CsrfViewMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.contrib.messages.middleware.MessageMiddleware',
>  'django.middleware.clickjacking.XFrameOptionsMiddleware')
>
> Traceback:
> File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in 
> get_response
>   114. response = wrapped_callback(request, 
> *callback_args, **callback_kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" 
> in wrapper
>   432. return self.admin_site.admin_view(view)(*args, 
> **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in 
> _wrapped_view
>   99. response = view_func(request, *args, **kwargs)
> File 
> "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" in 
> _wrapped_view_func
>   52. response = view_func(request, *args, **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py" 
> in inner
>   198. return view(request, *args, **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in 
> _wrapper
>   29. return bound_func(*args, **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in 
> _wrapped_view
>   99. response = view_func(request, *args, **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in 
> bound_func
>   25. return func(self, *args2, **kwargs2)
> File "/usr/local/lib/python2.7/dist-packages/django/db/transaction.py" in 
> inner
>   371. return func(*args, **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" 
> in add_view
>   1133. self.log_addition(request, new_object)
> File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" 
> in log_addition
>   600. action_flag=ADDITION
> File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/models.py" 
> in log_action
>   19. e = self.model(None, None, user_id, content_type_id, 
> smart_text(object_id), object_repr[:200], action_flag, change_message)
>
> Exception Type: TypeError at /admin/vmware/vmspecs/add/
> Exception Value: 'Vms' object has no attribute '__getitem__'
>
>
The trouble is in your VMSpec model's `__unicode__` method. That actually 
needs to return unicode, but you are returning the value of the VMID 
ForeignKey field, which is a VMS object. You should either return 
`unicode(self.VMID)`, or choose another field to be the unicode 
representation.
--
DR.

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

Error in Django debug toolbar

2014-05-07 Thread Rafael Santos
INSTALLED_APPS += (
'debug_toolbar',
)

MIDDLEWARE_CLASSES += (
'debug_toolbar.middleware.DebugToolbarMiddleware',
)

INTERNAL_IPS = ('127.0.0.1',)



Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/Aula10/

Django Version: 1.6.4
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'Aula3',
 'Aula4',
 'Aula5',
 'Aula6',
 'Aula7',
 'Aula8',
 'Aula9',
 'Aula10',
 'Aula11',
 'debug_toolbar')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'debug_toolbar.middleware.DebugToolbarMiddleware')


Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in 
get_response
  201. response = middleware_method(request, response)
File "C:\Python27\lib\site-packages\debug_toolbar\middleware.py" in 
process_response
  86. new_response = panel.process_response(request, response)
File "C:\Python27\lib\site-packages\debug_toolbar\panels\staticfiles.py" in 
process_response
  129. 'staticfiles_finders': self.get_staticfiles_finders(),
File "C:\Python27\lib\site-packages\debug_toolbar\panels\staticfiles.py" in 
get_staticfiles_finders
  140. for path, finder_storage in finder.list([]):
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\finders.py" 
in list
  106. for path in utils.get_files(storage, ignore_patterns):
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\utils.py" in 
get_files
  25. directories, files = storage.listdir(location)
File "C:\Python27\lib\site-packages\django\core\files\storage.py" in listdir
  250. for entry in os.listdir(path):

Exception Type: WindowsError at /Aula10/
Exception Value: 3 O sistema n�o pode encontrar o caminho especificado

-- 
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/7713c305-3e48-4a5c-a461-610da29d9022%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Install Django debug toolbar - Error Path

2014-05-07 Thread Rafael Santos
Python Version: 2.7.6
Django Version: 1.6.4

I installed the debug toolbar = pip install django-debug-toolbar, that's ok.

Add:

INSTALLED_APPS += (
'debug_toolbar',
)

MIDDLEWARE_CLASSES += (
'debug_toolbar.middleware.DebugToolbarMiddleware',
)

INTERNAL_IPS = ('127.0.0.1',)



In execution time happens this error:

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/Aula10/

Django Version: 1.6.4
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'Aula3',
 'Aula4',
 'Aula5',
 'Aula6',
 'Aula7',
 'Aula8',
 'Aula9',
 'Aula10',
 'Aula11',
 'debug_toolbar')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'debug_toolbar.middleware.DebugToolbarMiddleware')


Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in 
get_response
  201. response = middleware_method(request, response)
File "C:\Python27\lib\site-packages\debug_toolbar\middleware.py" in 
process_response
  86. new_response = panel.process_response(request, response)
File "C:\Python27\lib\site-packages\debug_toolbar\panels\staticfiles.py" in 
process_response
  129. 'staticfiles_finders': self.get_staticfiles_finders(),
File "C:\Python27\lib\site-packages\debug_toolbar\panels\staticfiles.py" in 
get_staticfiles_finders
  140. for path, finder_storage in finder.list([]):
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\finders.py" 
in list
  106. for path in utils.get_files(storage, ignore_patterns):
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\utils.py" in 
get_files
  25. directories, files = storage.listdir(location)
File "C:\Python27\lib\site-packages\django\core\files\storage.py" in listdir
  250. for entry in os.listdir(path):

Exception Type: WindowsError at /Aula10/
Exception Value: 3 O sistema n�o pode encontrar o caminho especificado




-- 
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/a2803a6f-110a-486c-8874-5f1dacc4d48f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Python Nested For Looping MultiTable Association Question

2014-05-07 Thread G Z
I'm new to django so im assuming there is an easier way to do this but in 
my html template im trying to do the following

I have a customer that has vmids associated with that and i want to match 
up every vm in the table vms by id to the vmids tag associated with the 
customer and display each one for each customer and eventually vmspecs are 
going to be tied to the vmid. I have my models.py and my index.html can 
anyone help me understand wahts wrong



> 
> Customres
> 
> 
> Index Page
> {% for e in customers %}
> {% for v in vms %}
> {% if e.VMIDS = v.id %}
>  {{ e.id }} - {{ e.NAME }} - {{ 
> v.VMNAME }} 
> {% endif %}
> {% endfor %}
> {% endfor %}
> 
> 





class Customer(models.Model):
> NAME = models.CharField(max_length=200)
> WEBSITE = models.CharField(max_length=200)
> PHONE = models.CharField(max_length=200)
> EMAIL = models.CharField(max_length=200)
> ADDRESS = models.CharField(max_length=200)
> VMIDS = models.CharField(max_length=200)
> def __unicode__(self):
> return self.NAME
> class Vms(models.Model):
> VMNAME = models.CharField(max_length=200)
> VMSTATUS = models.CharField(max_length=200)
> CUSTOMERID = models.ForeignKey(Customer)
> def __unicode__(self):
> return self.VMNAME
> class Vmspecs(models.Model):
> CPUS =  models.CharField(max_length=200)
> CORES =  models.CharField(max_length=200)
> MEMORY =  models.CharField(max_length=200)
> HDSPACE =  models.CharField(max_length=200)
> OS =  models.CharField(max_length=200)
> UPTIME = models.CharField(max_length=200)
> VMID  = models.ForeignKey(Vms)
> CUSTOMERID = models.ForeignKey(Customer)
> def __unicode__(self):
>return self.VMID

-- 
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/0670a022-e963-4c6e-8089-4e4ba85cab12%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django rest framework api versioning

2014-05-07 Thread Стас Медведев


I'm new to the DRF. I tried to write an example by description on links:

http://james.lin.net.nz/2014/02/18/django-rest-framework-api-versioning/

django-rest-framework: api 
versioning

and share it: https://github.com/van2048/DRF_versioning

, but I get the error "NoReverseMatch at / app_drf/v1 /". Please tell me, 
that was not written correctly?

-- 
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/0082684b-7430-45bd-9596-d90adc2f3ba7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django URLS help app not defined

2014-05-07 Thread Tom Evans
On Tue, May 6, 2014 at 9:40 PM, G Z  wrote:

> Thanks so much one last thing
>>
>
> Page not found (404)Request Method:GETRequest URL:
> http://pythondev.enki.co:8001/customers
>
> Using the URLconf defined in provisioning.urls, Django tried these URL
> patterns, in this order:
>
>1. ^admin/
>2. ^customers/
>
> The current URL, customers, didn't match any of these.
> You're seeing this error because you have DEBUG = True in your Django
> settings file. Change that to False, and Django will display a standard
> 404 page.
>
> I got it to work but its still not seeing the customers url is my regex
> wrong?
>
>
Check closely what you are being told here.

Django tried these patterns:

"^admins/"
"^customers/"

and neither matched the current URL "customers".

Computers are precise machines - "customers" is not the same as
"customers/". You must be precise.

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/CAFHbX1JPBZ%3DXM5ORwHG9JON%3DX3fk7LiFgbazak6dvTs9zdsyDg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: What is different of handling character code between pure Python and Django?

2014-05-07 Thread Tom Evans
On Sun, Apr 27, 2014 at 7:13 AM, Sugita Shinsuke  wrote:
> Hi there
>
> I’d like to run Java code via Django.
>
> The Java code, javaprogram use like below.
>
> —
> java javaprogram [text] [file_name]
> —
>
> text is parameter. multi-byte character is also okey.
> file_name is generate file name.
>
> So, I run the stand-alone Python program like below could run fine.
> —
> java_file = ‘javaprogram’
> file_name = ‘filename’
> text = ‘あいうえお’ #Japanese character
> java_file_path = ‘/path/to/‘
> class_path = ‘-cp ' + java_file_path
>
> cmd = “java {0} {1} {2} {3}".format(class_path, java_file, text, file_name)

What version of Python? 2.x or 3.x?

Presumably your email client is converting plain single and double
quotes to smart quotes and backticks, and in your source code they are
plain single and double quotes - " and ', not “ and ‘.

Django does something explicitly to force management commands to be
ascii, see here:

https://docs.djangoproject.com/en/1.6/howto/custom-management-commands/#management-commands-and-locales

There was an old case to force Django to use UTF-8:
https://code.djangoproject.com/ticket/5877

It was closed wontfix on the basis that Django respects your locale,
which it no longer does by default. There are several workarounds
listed on the first link that will restore that behaviour. Within a
view code, the rules are different, it will activate either the
language that user requests (if supported and USE_i18N=True) or
LANGUAGE_CODE otherwise.

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/CAFHbX1%2Bx%2BQ2CS4Hc9ifbddCGygZzhF3pK-Z0EMp%3DHtAHvTH_jQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: What is different of handling character code between pure Python and Django?

2014-05-07 Thread Sugita Shinsuke
Hello Lloyd Dube

I fix 'utf8' to 'utf-8'.
But, same error happned.

ascii' codec can't decode byte 0xe3 in position 0: ordinal not in range(128)

"locale.getpreferredencoding() is ANSI_X3.4-1968"
is not the cause?

2014年5月7日水曜日 0時20分03秒 UTC+9 Lloyd Dube:
>
> That should be ".encode('utf-8') - it is separated by a dash.
>
>
> On Tue, May 6, 2014 at 4:31 PM, 杉田臣輔 wrote:
>
>> Hello
>>
>> Thank you for replying.
>> I tried to use the ".encode('utf8')" method before.
>>
>> I also tried your suggestion. But error happened like below.
>>
>> 'ascii' codec can't decode byte 0xe3 in position 0: ordinal not in 
>> range(128)
>>
>>
>>
>>
>> 2014-05-06 17:10 GMT+09:00 Hannu Krosing > >:
>>
>>>  On 05/06/2014 08:28 AM, Sugita Shinsuke wrote:
>>>
>>> ...
>>>  
>>>  
 If it is the cause. Can I change encode type of locale.
 getpreferredencoding?
  
>>>  ...
>>>
>>>> 
> > So, I run the stand-alone Python program like below could run fine. 
> > — 
> > java_file = ‘javaprogram’ 
> > file_name = ‘filename’ 
> > text = ‘あいうえお’ #Japanese character 
> > java_file_path = ‘/path/to/‘ 
> > class_path = ‘-cp ' + java_file_path 
> > 
> > cmd = “java {0} {1} {2} {3}".format(class_path, java_file, text, 
> file_name) 
>
You can check if encoding the arguments manually works:
>>>
>>> cmd = "java {0} {1} {2} {3}".format(*[s.encode('utf8') for s in 
>>> (class_path, java_file, text, file_name)])
>>>
>>>
>>> Cheers
>>>
>>> -- 
>>> Hannu Krosing
>>> PostgreSQL Consultant
>>> Performance, Scalability and High Availability
>>> 2ndQuadrant Nordic OÜ
>>>
>>>  
>>  -- 
>> 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 http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CAJ5zBj6H-HE60KJpB4-KbQkE9sY5Hri_vnQApeSPGSbkzLMV9g%40mail.gmail.com
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Regards,
> Sithu Lloyd Dube 
>

-- 
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/b3db679e-ce93-4508-b0ed-0127544b9b27%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Linking Multiple Mysql tables with unique identifiers

2014-05-07 Thread G Z
Anyone?

On Tuesday, May 6, 2014 11:34:51 AM UTC-6, G Z wrote:
>
> So I'm trying to set up my django app and I want to link multiple tables 
> each with a unique key identifier. To test this i have the following 
> models. py
> 
> from django.db import models
>
> # Create your models here.
> class Customer(models.Model):
> NAME = models.CharField(max_length=200)
> WEBSITE = models.CharField(max_length=200)
> PHONE = models.CharField(max_length=200)
> EMAIL = models.CharField(max_length=200)
> ADDRESS = models.CharField(max_length=200)
> VMIDS = models.CharField(max_length=200)
>
> def __unicode__(self):
> return self.NAME
> #   return self.NAME
>
> class Vms(models.Model):
> VMID  = models.CharField(max_length=200)
> VMNAME = models.CharField(max_length=200)
> VMSTATUS = models.CharField(max_length=200)
> CUSTOMERID = models.ForeignKey(Customer)
>
> def __unicode__(self):
> return self.VMNAME
> class Vmspecs(models.Model):
> CPUS =  models.CharField(max_length=200)
> CORES =  models.CharField(max_length=200)
> MEMORY =  models.CharField(max_length=200)
> HDSPACE =  models.CharField(max_length=200)
> OS =  models.CharField(max_length=200)
> UPTIME = models.CharField(max_length=200)
> VMID = models.ForeignKey(Vms)
>
> def __unicode__(self):
> return self.VMID
> 
>
> If works fantastic until I try to add a vmspecs in the admin panel and 
> link it to a VM it gives the following error
>
>
>
>
>
> 
>
> Environment:
>
>
> Request Method: POST
> Request URL: http://pythondev.enki.co:8001/admin/vmware/vmspecs/add/
>
> Django Version: 1.6.4
> Python Version: 2.7.3
> Installed Applications:
> ('django.contrib.admin',
>  'django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.messages',
>  'django.contrib.staticfiles',
>  'vmware')
> Installed Middleware:
> ('django.contrib.sessions.middleware.SessionMiddleware',
>  'django.middleware.common.CommonMiddleware',
>  'django.middleware.csrf.CsrfViewMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.contrib.messages.middleware.MessageMiddleware',
>  'django.middleware.clickjacking.XFrameOptionsMiddleware')
>
>
> Traceback:
> File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" 
> in get_response
>   114. response = wrapped_callback(request, 
> *callback_args, **callback_kwargs)
> File 
> "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in 
> wrapper
>   432. return self.admin_site.admin_view(view)(*args, 
> **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" 
> in _wrapped_view
>   99. response = view_func(request, *args, **kwargs)
> File 
> "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" 
> in _wrapped_view_func
>   52. response = view_func(request, *args, **kwargs)
> File 
> "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in 
> inner
>   198. return view(request, *args, **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" 
> in _wrapper
>   29. return bound_func(*args, **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" 
> in _wrapped_view
>   99. response = view_func(request, *args, **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" 
> in bound_func
>   25. return func(self, *args2, **kwargs2)
> File "/usr/local/lib/python2.7/dist-packages/django/db/transaction.py" in 
> inner
>   371. return func(*args, **kwargs)
> File 
> "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in 
> add_view
>   1133. self.log_addition(request, new_object)
> File 
> "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in 
> log_addition
>   600. action_flag=ADDITION
> File 
> "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/models.py" in 
> log_action
>   19. e = self.model(None, None, user_id, content_type_id, 
> smart_text(object_id), object_repr[:200], action_flag, change_message)
>
> Exception Type: TypeError at /admin/vmware/vmspecs/add/
> Exception Value: 'Vms' object has no attribute '__getitem__'
> 
>

-- 
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/e7aaf400-d6d9-4cfb-ae9e-fcbcd1f96567%40googlegroups.com.
For more options, visit 

Re: Detail View Question

2014-05-07 Thread G Z
Thanks so much that worked.

On Tuesday, May 6, 2014 5:21:35 PM UTC-6, G Z wrote:
>
> So I'm using DetailView to associate a Customer ID with customer 
> information but due to my lack of knowledge im not entirely sure what the 
> issue is. It will go to the page but it won't load the unique customer 
> data. The data exist at domain/customers/ however when you click the link 
> which takes you to domain/customers/id it wont show the data its just a 
> blank page with a title.
>
> Here is my urls.py
> 
> from django.conf.urls import patterns, include, url
> from django.views.generic.list import ListView
> from django.views.generic.detail import DetailView
> from vmware.models import Customer
>
> urlpatterns = patterns('',
> url(r'^$', ListView.as_view(
> queryset=Customer.objects.all().order_by("-id")[:100],
> template_name="vms.html")),
>
> url(r'^(?P\d+)$', DetailView.as_view(
> model = Customer,
> template_name="customer.html")),
>
> )
> 
>
> Here is the html output for it 
>
>
> 
> {% extends "base.html" %}
> {% block content %}
>  {{ post.NAME }}  
> 
>  {{ post.id }}
> 
> 
>  {{ post.NAME }}
> 
> 
>  {{ post.WEBSITE }}
> 
> 
>  {{ post.PHONE }}
> 
> 
>  {{ post.EMAIL }}
> 
> 
>  {{ post.ADDRESS }}
> 
> 
>  {{ post.VMIDS }}
> 
> {% endblock %}
> 
>

-- 
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/d4da275c-40f3-4d01-8e97-19791e2ded44%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: query on models

2014-05-07 Thread Rafael E. Ferrero
I'll recommend you to read
https://docs.djangoproject.com/en/dev/ref/models/querysets/

Cheers!

--
Rafael E. Ferrero


2014-05-07 12:03 GMT-03:00 Anushree Jangid :

> no no you are not missing anything. You got it right and I did that in
> view and it worked. Actually I am new to Django. Thanks a lot.
>
>
>
>
> On Wed, May 7, 2014 at 8:28 PM, Rafael E. Ferrero <
> rafael.ferr...@gmail.com> wrote:
>
>> You are using Ques for related Subject and QuestionBank... just make a
>> method in Ques class who filter the Ques model with some subject parameter
>> or do it in your view like:
>>qs = Ques.objects.select_related().filter(subject='some_name')
>>
>>
>> I'm missing something really big? or i miss understud your question?
>>
>>
>>
>> 2014-05-07 11:19 GMT-03:00 Anushree Jangid :
>>
>>> No* I start with subject model. *There I have created subjects like
>>> General knowledge, English etc. ​Then I create question banks Like for
>>> General knowledge I have created GK1, GK2 and GK3 . Then when I enter a
>>> ques in the Ques model there I specify that the question is related to
>>> which subject and which question bank.
>>> For e.g In Ques model I enter
>>> content=what is friction
>>> subject=General knowledge
>>> ques_bank=GK1
>>>
>>>
>>> ​Now for eg I want to know the question banks associated with subject​
>>> General knowledge, then it should tell GK1 GK2 and GK3
>>> Assume all the questions related to the subjects along with their
>>> question banks have been stored in Ques model.
>>>
>>>
>>> On Wed, May 7, 2014 at 7:38 PM, Davide Scatto wrote:
>>>
 Do you start from Ques model? What are your starting data?

 Il giorno mercoledì 7 maggio 2014 15:24:38 UTC+2, Anushree ha scritto:

> I have the following models. I want to retrieve list of question banks
> related to a particular subject. Is it possible to do without modifying 
> the
> existing data models?Thank you
> class Subject(models.Model):
>  name = models.CharField(max_length = 255)
> desc = models.TextField(blank=True)
> def __unicode__(self):
>  return self.name
>
> class QuestionBank(models.Model):
> name = models.CharField(max_length=255)
>  desc = models.TextField()
> def __unicode__(self):
> return self.name
>
> class Ques(models.Model):
> content = models.TextField()
> ques_type = models.CharField(max_length = 1 , default= 'A')
>  score = models.PositiveSmallIntegerField(max_length = 1 , default= 1)
> ques_bank = models.ForeignKey(QuestionBank)
>  subject = models.ForeignKey(Subject)
>
  --
 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/f98ca810-27a1-45a2-a177-cef5ba365456%40googlegroups.com
 .

 For more options, visit https://groups.google.com/d/optout.

>>>
>>>
>>>
>>> --
>>>
>>> *Anushree Jangid *
>>> *BIT Mesra, Jaipur Campus*
>>>
>>> --
>>> 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/CAP%3D_V50C-VV_zCJK_8%3DgeKb-JeBsZiDgrmLDWu0F6Wmbw_aYFQ%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
>> 

Re: query on models

2014-05-07 Thread Anushree Jangid
no no you are not missing anything. You got it right and I did that in view
and it worked. Actually I am new to Django. Thanks a lot.




On Wed, May 7, 2014 at 8:28 PM, Rafael E. Ferrero
wrote:

> You are using Ques for related Subject and QuestionBank... just make a
> method in Ques class who filter the Ques model with some subject parameter
> or do it in your view like:
>qs = Ques.objects.select_related().filter(subject='some_name')
>
>
> I'm missing something really big? or i miss understud your question?
>
>
>
> 2014-05-07 11:19 GMT-03:00 Anushree Jangid :
>
>> No* I start with subject model. *There I have created subjects like
>> General knowledge, English etc. ​Then I create question banks Like for
>> General knowledge I have created GK1, GK2 and GK3 . Then when I enter a
>> ques in the Ques model there I specify that the question is related to
>> which subject and which question bank.
>> For e.g In Ques model I enter
>> content=what is friction
>> subject=General knowledge
>> ques_bank=GK1
>>
>>
>> ​Now for eg I want to know the question banks associated with subject​
>> General knowledge, then it should tell GK1 GK2 and GK3
>> Assume all the questions related to the subjects along with their
>> question banks have been stored in Ques model.
>>
>>
>> On Wed, May 7, 2014 at 7:38 PM, Davide Scatto wrote:
>>
>>> Do you start from Ques model? What are your starting data?
>>>
>>> Il giorno mercoledì 7 maggio 2014 15:24:38 UTC+2, Anushree ha scritto:
>>>
 I have the following models. I want to retrieve list of question banks
 related to a particular subject. Is it possible to do without modifying the
 existing data models?Thank you
 class Subject(models.Model):
  name = models.CharField(max_length = 255)
 desc = models.TextField(blank=True)
 def __unicode__(self):
  return self.name

 class QuestionBank(models.Model):
 name = models.CharField(max_length=255)
  desc = models.TextField()
 def __unicode__(self):
 return self.name

 class Ques(models.Model):
 content = models.TextField()
 ques_type = models.CharField(max_length = 1 , default= 'A')
  score = models.PositiveSmallIntegerField(max_length = 1 , default= 1)
 ques_bank = models.ForeignKey(QuestionBank)
  subject = models.ForeignKey(Subject)

>>>  --
>>> 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/f98ca810-27a1-45a2-a177-cef5ba365456%40googlegroups.com
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>>
>> *Anushree Jangid *
>> *BIT Mesra, Jaipur Campus*
>>
>> --
>> 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/CAP%3D_V50C-VV_zCJK_8%3DgeKb-JeBsZiDgrmLDWu0F6Wmbw_aYFQ%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/CAJJc_8W9iog17Rtgqp_ywpNkwEovs0jq5g%2B5cx290jVjXvKsWQ%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 

*Anushree Jangid*
*BIT Mesra, Jaipur Campus*

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

Re: query on models

2014-05-07 Thread Rafael E. Ferrero
You are using Ques for related Subject and QuestionBank... just make a
method in Ques class who filter the Ques model with some subject parameter
or do it in your view like:
   qs = Ques.objects.select_related().filter(subject='some_name')


I'm missing something really big? or i miss understud your question?



2014-05-07 11:19 GMT-03:00 Anushree Jangid :

> No* I start with subject model. *There I have created subjects like
> General knowledge, English etc. ​Then I create question banks Like for
> General knowledge I have created GK1, GK2 and GK3 . Then when I enter a
> ques in the Ques model there I specify that the question is related to
> which subject and which question bank.
> For e.g In Ques model I enter
> content=what is friction
> subject=General knowledge
> ques_bank=GK1
>
>
> ​Now for eg I want to know the question banks associated with subject​
> General knowledge, then it should tell GK1 GK2 and GK3
> Assume all the questions related to the subjects along with their question
> banks have been stored in Ques model.
>
>
> On Wed, May 7, 2014 at 7:38 PM, Davide Scatto wrote:
>
>> Do you start from Ques model? What are your starting data?
>>
>> Il giorno mercoledì 7 maggio 2014 15:24:38 UTC+2, Anushree ha scritto:
>>
>>> I have the following models. I want to retrieve list of question banks
>>> related to a particular subject. Is it possible to do without modifying the
>>> existing data models?Thank you
>>> class Subject(models.Model):
>>>  name = models.CharField(max_length = 255)
>>> desc = models.TextField(blank=True)
>>> def __unicode__(self):
>>>  return self.name
>>>
>>> class QuestionBank(models.Model):
>>> name = models.CharField(max_length=255)
>>>  desc = models.TextField()
>>> def __unicode__(self):
>>> return self.name
>>>
>>> class Ques(models.Model):
>>> content = models.TextField()
>>> ques_type = models.CharField(max_length = 1 , default= 'A')
>>>  score = models.PositiveSmallIntegerField(max_length = 1 , default= 1)
>>> ques_bank = models.ForeignKey(QuestionBank)
>>>  subject = models.ForeignKey(Subject)
>>>
>>  --
>> 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/f98ca810-27a1-45a2-a177-cef5ba365456%40googlegroups.com
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
>
> *Anushree Jangid*
> *BIT Mesra, Jaipur Campus*
>
> --
> 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/CAP%3D_V50C-VV_zCJK_8%3DgeKb-JeBsZiDgrmLDWu0F6Wmbw_aYFQ%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/CAJJc_8W9iog17Rtgqp_ywpNkwEovs0jq5g%2B5cx290jVjXvKsWQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: regex error?

2014-05-07 Thread Sergiy Khohlov
try this one
 url(r'/(?P\d+)$', DetailView.as_view(
model = Customer,
template_name="customer.html")),


Many thanks,

Serge


+380 636150445
skype: skhohlov

-- 
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/CADTRxJMX0sF6AUbtbtOAzaJcdjJ6WJGgL_RvoxdJnrufMKn3MA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Centos 6.5 Python 3.3.x Django 1.6 Apache 2.2

2014-05-07 Thread Guillem Liarte
Timothy,

Thanks you, but SELinux here does not seem to be the issue. I tried with 
enforcing/permissive/disabled and the effect is the same.

I belive the problem to be in the os path in the seetings:

---

import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
...
...







 
--

in wsgi.py :



import os, sys
sys.path.append('/data/app/guillem-py3-dj17-test/guillem_test/guillem_test')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "guillem_test.settings")


---

python -c "import sys; print(sys.path)" 
['', '/data/app/guillem-py3-dj17-test/lib64/python33.zip', 
'/data/app/guillem-py3-dj17-test/lib64/python3.3', 
'/data/app/guillem-py3-dj17-test/lib64/python3.3/plat-linux', 
'/data/app/guillem
-py3-dj17-test/lib64/python3.3/lib-dynload', 
'/opt/rh/python33/root/usr/lib64/python3.3', 
'/opt/rh/python33/root/usr/lib/python3.3', 
'/data/app/guillem-py3-dj17-test/lib/python3.3/site-packa
ges']




I am reading about the differnces for mod_wsgi from python2.x to python3.x 
but I fail to find clear documentation about how the wsgi.py and  
settings.py should look like in python3.

On Wednesday, 7 May 2014 00:20:00 UTC+2, Timothy W. Cook wrote:
>
>
> On Tue, May 6, 2014 at 7:01 PM, Guillem Liarte 
>  > wrote:
>
>>
>>
>> But I still get the locale encoding problem.  Do you guys have any 
>> suggestions?
>>
>> I do not recall the exact error I had with this config (once you 
> corrected those you mentioned) but eventually I had to set:
>
> $setenforce 0
>
> to disable SELinux security.  I am sure that there is a way around this 
> but I haven't had a need to fix it yet. 
>
> HTH,
> Tim
>  
>
>
> 
> Timothy Cook
> LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
> MLHIM http://www.mlhim.org
>
>  

-- 
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/574819c6-624c-4071-9222-3a7f74be9429%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: query on models

2014-05-07 Thread Anushree Jangid
No I start with subject model. There I have created subjects like General
knowledge, English etc. ​Then I create question banks Like for General
knowledge I have created GK1, GK2 and GK3 . Then when I enter a ques in the
Ques model there I specify that the question is related to which subject
and which question bank.
For e.g In Ques model I enter
content=what is friction
subject=General knowledge
ques_bank=GK1


​Now for eg I want to know the question banks associated with subject​
General knowledge, then it should tell GK1 GK2 and GK3
Assume all the questions related to the subjects along with their question
banks have been stored in Ques model.


On Wed, May 7, 2014 at 7:38 PM, Davide Scatto wrote:

> Do you start from Ques model? What are your starting data?
>
> Il giorno mercoledì 7 maggio 2014 15:24:38 UTC+2, Anushree ha scritto:
>
>> I have the following models. I want to retrieve list of question banks
>> related to a particular subject. Is it possible to do without modifying the
>> existing data models?Thank you
>> class Subject(models.Model):
>>  name = models.CharField(max_length = 255)
>> desc = models.TextField(blank=True)
>> def __unicode__(self):
>>  return self.name
>>
>> class QuestionBank(models.Model):
>> name = models.CharField(max_length=255)
>>  desc = models.TextField()
>> def __unicode__(self):
>> return self.name
>>
>> class Ques(models.Model):
>> content = models.TextField()
>> ques_type = models.CharField(max_length = 1 , default= 'A')
>>  score = models.PositiveSmallIntegerField(max_length = 1 , default= 1)
>> ques_bank = models.ForeignKey(QuestionBank)
>>  subject = models.ForeignKey(Subject)
>>
>  --
> 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/f98ca810-27a1-45a2-a177-cef5ba365456%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 

*Anushree Jangid*
*BIT Mesra, Jaipur Campus*

-- 
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/CAP%3D_V50C-VV_zCJK_8%3DgeKb-JeBsZiDgrmLDWu0F6Wmbw_aYFQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: query on models

2014-05-07 Thread Davide Scatto
Do you start from Ques model? What are your starting data?

Il giorno mercoledì 7 maggio 2014 15:24:38 UTC+2, Anushree ha scritto:
>
> I have the following models. I want to retrieve list of question banks 
> related to a particular subject. Is it possible to do without modifying the 
> existing data models?Thank you
> class Subject(models.Model):
> name = models.CharField(max_length = 255)
> desc = models.TextField(blank=True)
> def __unicode__(self):
> return self.name
>
> class QuestionBank(models.Model):
> name = models.CharField(max_length=255)
> desc = models.TextField()
> def __unicode__(self):
> return self.name
>
> class Ques(models.Model):
> content = models.TextField()
> ques_type = models.CharField(max_length = 1 , default= 'A')
> score = models.PositiveSmallIntegerField(max_length = 1 , default= 1)
> ques_bank = models.ForeignKey(QuestionBank)
> subject = models.ForeignKey(Subject)
>

-- 
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/f98ca810-27a1-45a2-a177-cef5ba365456%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: About django round-up display function of time

2014-05-07 Thread Mario Gudelj
I assume you're using datetime object in which case you have a look at this
SO answer
http://stackoverflow.com/questions/3463930/how-to-round-the-minute-of-a-datetime-object-python


On 7 May 2014 17:55, hito koto  wrote:

> Hi , good afternoon!
>
> I want to the round-up display function of time, how do i can do it ,
> please help me!!
> (Django/Python)
>
> For example:
>
> 2, 09:30 minute = 09:40
> 09:15minute= 09:45
> 09:30minute= 10:00
> 09:31minute = 09:31
>
>
>  --
> 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/11430740-d840-4143-8c3a-67f0054bc92e%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/CAHqTbjmE157YrhYJy3nURbp2vviM0VjL9nfAc16VuV8KDUDeYw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: query on models

2014-05-07 Thread Rafael E. Ferrero
Just filtering Ques model (imho)

--
Rafael E. Ferrero


2014-05-07 10:24 GMT-03:00 Anushree :

> I have the following models. I want to retrieve list of question banks
> related to a particular subject. Is it possible to do without modifying the
> existing data models?Thank you
> class Subject(models.Model):
> name = models.CharField(max_length = 255)
> desc = models.TextField(blank=True)
> def __unicode__(self):
> return self.name
>
> class QuestionBank(models.Model):
> name = models.CharField(max_length=255)
> desc = models.TextField()
> def __unicode__(self):
> return self.name
>
> class Ques(models.Model):
> content = models.TextField()
> ques_type = models.CharField(max_length = 1 , default= 'A')
> score = models.PositiveSmallIntegerField(max_length = 1 , default= 1)
> ques_bank = models.ForeignKey(QuestionBank)
> subject = models.ForeignKey(Subject)
>
> --
> 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/66442114-cda1-45c4-9320-1059c045e48a%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/CAJJc_8WPAZcJnfXND1VAdfASK31VuQ1HR1So%3DYykgxcSXEMSxw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


query on models

2014-05-07 Thread Anushree
I have the following models. I want to retrieve list of question banks 
related to a particular subject. Is it possible to do without modifying the 
existing data models?Thank you
class Subject(models.Model):
name = models.CharField(max_length = 255)
desc = models.TextField(blank=True)
def __unicode__(self):
return self.name

class QuestionBank(models.Model):
name = models.CharField(max_length=255)
desc = models.TextField()
def __unicode__(self):
return self.name

class Ques(models.Model):
content = models.TextField()
ques_type = models.CharField(max_length = 1 , default= 'A')
score = models.PositiveSmallIntegerField(max_length = 1 , default= 1)
ques_bank = models.ForeignKey(QuestionBank)
subject = models.ForeignKey(Subject)

-- 
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/66442114-cda1-45c4-9320-1059c045e48a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django on rhel5 with both python2.4 and python2.7 confusion

2014-05-07 Thread Timothy W. Cook
A good place to start is with this thread:
https://groups.google.com/forum/?utm_medium=email_source=footer#!msg/django-users/_0RTNcYyCSI/24QinBTEnX8J


Be sure to include CentOS in your searches for clues about this setup since
many people use CentOS instead of RHEL.

HTH,
Tim



On Wed, May 7, 2014 at 6:08 AM, David Malcolm  wrote:

> I have been tasked with finishing a build for production that was
> interrupted due to another staff member leaving at short notice. It's
> RedHat Enterprise Linux 5 and there are two versions of python on the box.
> If I type python I get version 2.7. However if I try and use
> django-admin.py I find that it is trying to use python version 2.4. How do
> I specify to Django that I want to use python 2.7? I've seen multiple
> supposed answers on the net but nothing actually seems to answer my
> specific question. I'm fairly experienced on linux but have never had to
> setup django and python before. My Apache, php, phpMyAdmin setup is all
> working properly (after I sorted out some other issues),  but my second
> question is how do I wire up python/django to apache (or httpd as rhel5
> calls it). I've tried using mod_wsgi but have been told I must use
> mod_python. Advice or pointers to relevant urls are much appreciated.
> Thanks Dave, Melbourne
>
> --
> 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/74af440c-b42d-4fcd-abfa-74da94958b73%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 


Timothy Cook
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
MLHIM http://www.mlhim.org

-- 
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/CA%2B%3DOU3UYTe0r6gqiCQj3%3DcQh6EqMrRzQDk5-R-9cxd9CCQPR0w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django calendar error

2014-05-07 Thread hito koto
I hava also have some error , 
Why ? i did import calendar!


ViewDoesNotExist at /admin/auth/user/ 

Could not import tcsarticle.views.calendar. View is not callable.

 Request Method: GET  Request URL: http://admin/auth/user/  Django Version: 
1.6.2  Exception Type: ViewDoesNotExist  Exception Value: 

Could not importrticle.views.calendar. View is not callable.

 Exception Location: 
/usr/lib/python2.6/site-packages/django/core/urlresolvers.py 
in get_callable, line 112  Python Executable: /usr/bin/python
TypeError at /articles/month 

month() takes at least 3 arguments (1 given)

 Request Method: GET  Request URL: http://articles/month  Django Version: 
1.6.2  Exception Type: TypeError  Exception Value: 

month() takes at least 3 arguments (1 given)

 Exception Location: 
/usr/lib/python2.6/site-packages/django/core/handlers/base.py 
in get_response, line 114  Python Executable: /usr/bin/python  Python 
Version: 2.6.

This is my Views.py:

from datetime import date, datetime, timedelta
import calendar

def month(request, year, month, change=None):
year, month = int(year), int(month)
if change in ("next", "prev"):
now, mdelta = date(year, month, 15), timedelta(days=31)
if change == "next":   mod = mdelta
elif change == "prev": mod = -mdelta

year, month = (now+mod).timetuple()[:2]

cal = calendar.Calendar()
month_days = cal.itermonthdays(year, month)
nyear, nmonth, nday = time.localtime()[:3]
lst = [[]]
week = 0

for day in month_days:
entries = current = False   # are there entries for this day; 
current day?
if day:
entries = User.objects.filter(date__year=year, 
date__month=month, date__day=day)
if day == nday and year == nyear and month == nmonth:
current = True

lst[week].append((day, entries, current))
if len(lst[week]) == 7:
lst.append([])
week += 1

return render_to_response("month.html", dict(year=year, month=month, 
user=request.user,
month_days=lst, mname=mnames[month-1]))

-- 
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/8d7e2f77-048f-4431-9c6d-18be5399ccba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


html email function to a large recipient list problem

2014-05-07 Thread MikeKJ
I have these functions to send update emails to a subscriber list 
(recipients) but for some reason I cannot seem to fathom it does:

Connect
Send Email A
Connect 
Connect
Send Email B
Send Email B
Connect 
Connect
Connect
Send Email C
Send Email C
Send Email C

etc etc

Can anyone see where the incrementing is happening because I can't.
Interestingly it seems that even though the logger says each email is sent 
multiple (by increment, like the 1000th address on the list theoretically 
should get the same email 1000 times) it doesnt, just the one email or so 
it appears, if anyone has an explanation for that as well I would be 
interested


def send( self ):
c = Context({ "content": self.introductory_text, "user":None, 
"request":None, "updates": [] })
t = loader.get_template('emailer/html/updates.html')
subject = self.subject
recipients = []
if self.to_all_principal_contacts:
for gs in GroupSubscription.objects.all():
if not gs in self.recipients.all():
self.recipients.add( gs.principal_contact.id )
for i in self.recipients.all():
i.save()
super( UpdateEmail, self ).save()

if self.to_all_subscribers:
for subscriber in 
UserProfile.objects.select_related().order_by('name'):
if subscriber.subscription_set.count() > 0:
if not subscriber in self.recipients.all():
self.recipients.add(subscriber)
for i in self.recipients.all():
i.save()
super( UpdateEmail, self ).save()

for i in self.recipients.all():
recipients.append( i.email )
#  raise NameError(recipients) #This produces a list of singlular email 
addresses not incremented
self.save()
html = t.render(c)
#  raise NameError(html) #as expected this si just the html of the 
content
#  x = []
for i in recipients:
#x.append(i)
send_html_email( subject, html, "upda...@domain.co.uk", i, 
image_root=settings.PROJECT_DIR )
from datetime import datetime
self.sent_on = datetime.now()
self.sent = True
self.save()
#  raise NameError(x) #This produces a list of singlular email 
addresses not incremented




def send_html_email(subject_line, html_content, from_address, to_address, 
text_content=None, image_root=None, attachments=[]):
"""
Send an html email, which can have embedded images.
from_address can look like 'some...@somewhere.net',
or 'Some dude '.
to_addresses needs to be a list of such addresses.
Image hrefs need to be like /media/image1.gif. image_root needs to be 
the
prefix to allow us to find those images on the filesystem
attachments should be a list of dicts with 'mimetype', 'filename' and 
'payload' keys
"""
parser = EmailConverter()
parser.feed(html_content.encode('utf-8'))
text_content = text_content or 
strip_html_for_email(html_content.encode("utf-8"))

msgRoot = MIMEMultipart('related')
msgRoot['Subject'] = subject_line
msgRoot['From'] = from_address
msgRoot['To'] = to_address
msgRoot.preamble = 'This is a multi-part message in MIME format.'

msgAlternative = MIMEMultipart('alternative')
msgRoot.attach(msgAlternative)

msgAlternative.attach(MIMEText(text_content))
msgAlternative.attach(MIMEText(parser.body, 'html'))

for img in parser.imagelist:
fp = open(image_root+img[1], 'rb')
msgImg = MIMEImage(fp.read())
fp.close()
msgImg.add_header('Content-ID', '' % img[0])
msgRoot.attach(msgImg)

for attachment in attachments:
mimetype_bits = attachment['mimetype'].split('/')
a = MIMEBase(mimetype_bits[0], mimetype_bits[1])
a.set_payload(attachment['payload'])
Encoders.encode_base64(a)
a.add_header('Content-Disposition', 'attachment; filename="%s"' % 
attachment['filename'])
msgRoot.attach(a)

smtp = smtplib.SMTP()
from django.conf import settings
smtp.connect(settings.EMAIL_HOST, settings.EMAIL_PORT )
smtp.login( settings.EMAIL_HOST_USER, settings.EMAIL_HOST_PASSWORD )
logger = getlogger()
logger.info("Connected to %s on port %s as %s" % (settings.EMAIL_HOST, 
settings.EMAIL_PORT, settings.EMAIL_HOST_USER) )
import sys

try:
smtp.sendmail(from_address, to_address, msgRoot.as_string())
logger.info("Successfully sent %s -> %s" % ( from_address, 
to_address ))
except:
logger.info("Unexpected error (%s)\nWhen sending %s -> %s" % ( 
sys.exc_info()[0], from_address, to_address ))#, msgRoot.as_string())
smtp.quit()



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

Re: Detail View Question

2014-05-07 Thread visionary800
I am not sure my first reply worked, but here it goes again.
Your template is using {{ post.NAME }} when I believe it should be using {{ 
customer.NAME }}.  The context name that is used in the template is 
obtained by default from the model and in your case, you are using model= 
Customer.  If you want to rename so that you can use {{ post.Name }}, you 
will have to use 'context_object_name = post'.  But I suggest you edit your 
template. 

url(r'^(?P\d+)$', DetailView.as_view(
model = Customer,
template_name="customer.html",

context_object_name='post')),# Do this only if you want 
to use {{ post.NAME }}


get_context_object_name(*obj*)

Return the context variable name that will be used to contain the data that 
this view is manipulating. If 
context_object_nameis
 
not set, the context name will be constructed from themodel_name of the 
model that the queryset is composed from. For example, the model Article would 
have context object named 'article'.
Ref: 
https://docs.djangoproject.com/en/1.6/ref/class-based-views/mixins-single-object/#django.views.generic.detail.SingleObjectMixin.get_context_object_name

hope that works.



On Tuesday, May 6, 2014 4:24:07 PM UTC-7, G Z wrote:
>
> repost easier to read
>
> So I'm using DetailView to associate a Customer ID with customer 
> information but due to my lack of knowledge im not entirely sure what the 
> issue is. It will go to the page but it won't load the unique customer 
> data. The data exist at domain/customers/ however when you click the link 
> which takes you to domain/customers/id it wont show the data its just a 
> blank page with a title.
>
> Here is my urls.py
>
> from django.conf.urls import patterns, include, url
> from django.views.generic.list import ListView
> from django.views.generic.detail import DetailView
> from vmware.models import Customer
>
> urlpatterns = patterns('',
> url(r'^$', ListView.as_view(
> queryset=Customer.objects.all().order_by("-id")[:100],
> template_name="vms.html")),
>
> url(r'^(?P\d+)$', DetailView.as_view(
> model = Customer,
> template_name="customer.html")),
>
> )
>
> Here is the html output for it
>
> {% extends "base.html" %}
> {% block content %}
>  {{ post.NAME }}  
> 
>  {{ post.id }}
> 
> 
>  {{ post.NAME }}
> 
> 
>  {{ post.WEBSITE }}
> 
> 
>  {{ post.PHONE }}
> 
> 
>  {{ post.EMAIL }}
> 
> 
>  {{ post.ADDRESS }}
> 
> 
>  {{ post.VMIDS }}
> 
> {% endblock %}
>
>

-- 
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/31ef4781-37b7-4d03-980c-3bc63aa4d382%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django on rhel5 with both python2.4 and python2.7 confusion

2014-05-07 Thread David Malcolm
I have been tasked with finishing a build for production that was 
interrupted due to another staff member leaving at short notice. It's 
RedHat Enterprise Linux 5 and there are two versions of python on the box. 
If I type python I get version 2.7. However if I try and use 
django-admin.py I find that it is trying to use python version 2.4. How do 
I specify to Django that I want to use python 2.7? I've seen multiple 
supposed answers on the net but nothing actually seems to answer my 
specific question. I'm fairly experienced on linux but have never had to 
setup django and python before. My Apache, php, phpMyAdmin setup is all 
working properly (after I sorted out some other issues),  but my second 
question is how do I wire up python/django to apache (or httpd as rhel5 
calls it). I've tried using mod_wsgi but have been told I must use 
mod_python. Advice or pointers to relevant urls are much appreciated. 
Thanks Dave, Melbourne

-- 
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/74af440c-b42d-4fcd-abfa-74da94958b73%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


About django round-up display function of time

2014-05-07 Thread hito koto
Hi , good afternoon!

I want to the round-up display function of time, how do i can do it , 
please help me!!
(Django/Python)

For example:

2, 09:30 minute = 09:40
09:15minute= 09:45
09:30minute= 10:00
09:31minute = 09:31


-- 
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/11430740-d840-4143-8c3a-67f0054bc92e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django-smart-selects ModelForm Issue

2014-05-07 Thread Venkatraman S
Hi,

In the context of using
django-smart-selects:
as anyone stumbled on an issue with a Model using ChainedFK and if the
queryset of chained_field in the ModelForm is changed before  rendering?

ie., if person is the chained_field in my form and I changed its queryset
before rendering as follows, then the dependent dropdowns do not get
populated while the form is rendered.

form.fields['person'].queryset = this_dept.get_persons()

regards,
Venkat

-- 
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/CAN7tdFQnk-OWyy5jakaSZEEprNrZG7dRHaKCkuWT00Z5B5KHQg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.