Django create userprofile

2014-05-12 Thread hito koto


Hi,

i have this error , why ?


(1062, "Duplicate entry '1' for key 'start_work_id'")

Exception Type: IntegrityError  Exception Value: 

(1062, "Duplicate entry '1' for key 'start_work_id'"


-- 
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/be84b4ce-bedd-468e-aeae-3b3ea798d8f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django create userprofile

2014-05-12 Thread Erik Cederstrand
Den 12/05/2014 kl. 10.53 skrev hito koto :

> Hi,
> 
> i have this error , why ?
> 
> 
> (1062, "Duplicate entry '1' for key 'start_work_id'")
> Exception Type:   IntegrityError
> Exception Value:  
> (1062, "Duplicate entry '1' for key 'start_work_id'"

Please post your code for the model containing the "start_work" field. Must 
likely, you have defined the field with unique values and are now trying to 
create an model instance with a "start_work" foreign key reference that already 
exists.

Erik

-- 
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/C6114620-AB3E-46EF-BB7D-2A201249A297%40cederstrand.dk.
For more options, visit https://groups.google.com/d/optout.


Re: Django create userprofile

2014-05-12 Thread hito koto
Ok, Thank you!

So, this is my the full codes;


class Staff(models.Model):
user = models.OneToOneField(User)
user_name = models.CharField(max_length=255,)
first_kana = models.CharField(max_length=255,)
last_kana  = models.CharField(max_length=255, )
employee_number = models.CharField(blank=True, max_length=22)
gender = models.CharField(max_length=6, choices=(('male', 
'男性'),('female', '女性')), verbose_name="性別" )
created_at = models.DateTimeField(auto_now_add=True,)
updated_at = models.DateTimeField(auto_now=True, )
birthday = models.DateField(null=True, blank=True, )


def __unicode__(self):
return self.user_name


class Myattendance(models.Model):
start_work = models.ForeignKey(Staff, verbose_name = "名前")
get_work_data = models.DateTimeField(default=datetime.now, verbose_name 
= "出勤時間")

class Meta:
ordering = ['-get_work_data']

def __unicode__(self):
return unicode(self.start_work)

class Myleavework(models.Model):
user = models.ForeignKey(Staff, verbose_name = "名前")
get_off_work_data = models.DateTimeField(default=datetime.now, 
verbose_name = "退勤時間")

class Meta:
ordering = ["-get_off_work_data"]

def __unicode__(self):
  return unicode(self.user)

This is my the views.py:

@login_required
def myattendance(request):
if request.POST:
   # attendance = get_object_or_404(Attendence, pk=user_id)
form = MyattendanceForm(request.POST)
if form.is_valid():
form.save()
return HttpResponse('Ok')
else:
form = MyattendanceForm()
args = {}
args.update(csrf(request))
args['form'] = form
return render_to_response('myattendance.html', args)

@login_required
def myleavework(request):
if request.POST:
#leavework = Leavework.objects.get(pk = request.user.id )
form = MyleaveworkForm(request.POST)
if form.is_valid():
form.save()
return HttpResponse('Ok')
else:
form = MyleaveworkForm()
args = {}
args.update(csrf(request))
args['form'] = form
return render_to_response('myleave.html', args)

This is my the forms.py:

class MyattendanceForm(forms.ModelForm):

class Meta:
model = Myattendance


class MyleaveworkForm(forms.ModelForm):

class Meta:
model = Myleavework





2014年5月12日月曜日 18時21分45秒 UTC+9 Erik Cederstrand:
>
> Den 12/05/2014 kl. 10.53 skrev hito koto >: 
>
>
> > Hi, 
> > 
> > i have this error , why ? 
> > 
> > 
> > (1062, "Duplicate entry '1' for key 'start_work_id'") 
> > Exception Type:IntegrityError 
> > Exception Value: 
> > (1062, "Duplicate entry '1' for key 'start_work_id'" 
>
> Please post your code for the model containing the "start_work" field. 
> Must likely, you have defined the field with unique values and are now 
> trying to create an model instance with a "start_work" foreign key 
> reference that already exists. 
>
> Erik

-- 
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/d9e68fe7-878c-4d23-9347-4d315830e5a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django create userprofile

2014-05-12 Thread hito koto

This the error is  came out when edited and saved

2014年5月12日月曜日 18時21分45秒 UTC+9 Erik Cederstrand:
>
> Den 12/05/2014 kl. 10.53 skrev hito koto >: 
>
>
> > Hi, 
> > 
> > i have this error , why ? 
> > 
> > 
> > (1062, "Duplicate entry '1' for key 'start_work_id'") 
> > Exception Type:IntegrityError 
> > Exception Value: 
> > (1062, "Duplicate entry '1' for key 'start_work_id'" 
>
> Please post your code for the model containing the "start_work" field. 
> Must likely, you have defined the field with unique values and are now 
> trying to create an model instance with a "start_work" foreign key 
> reference that already exists. 
>
> Erik

-- 
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/0e554bd2-f907-4de4-8576-7ed96ba46ccd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django create userprofile

2014-05-12 Thread Erik Cederstrand
Den 12/05/2014 kl. 11.38 skrev hito koto :

> Ok, Thank you!
> 
> So, this is my the full codes;

Are you sure your database is in sync with your model? The error message 
implies that the field is defined with unique=True, but your model doesn't 
define it so:

  start_work = models.ForeignKey(Staff, verbose_name = "名前")


Erik

-- 
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/26954CFC-061C-4E77-80FD-EA462D2E1704%40cederstrand.dk.
For more options, visit https://groups.google.com/d/optout.


Re: html email function to a large recipient list problem

2014-05-12 Thread MikeKJ
Anyone have an insight into this please?

-- 
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/1bbb2ae1-1964-4ee0-9872-d59391dcd33e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django create userprofile

2014-05-12 Thread Helton Alves
Reset your database and test again.


2014-05-12 10:46 GMT+01:00 Erik Cederstrand :

> Den 12/05/2014 kl. 11.38 skrev hito koto :
>
> > Ok, Thank you!
> >
> > So, this is my the full codes;
>
> Are you sure your database is in sync with your model? The error message
> implies that the field is defined with unique=True, but your model doesn't
> define it so:
>
>   start_work = models.ForeignKey(Staff, verbose_name = "名前")
>
>
> Erik
>
> --
> 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/26954CFC-061C-4E77-80FD-EA462D2E1704%40cederstrand.dk
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Helton Alves 
Desenvolvedor web
Graduado em Sistemas de Informação - FACIMP
Cursando Metodologia do Ensino Superior - INESPO

-- 
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/CABcoSmB5wtm1V%3Da0_Z9jSYM88ibXwL2ywH4%3D5GhrytK-LUqT8w%40mail.gmail.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-12 Thread David Malcolm
Hi Timothy

thanks for your suggestions. I'm still on the path. I'll put more details in my 
reply to WongoBongo below.

cheers
Dave

-- 
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/f10d728f-b690-4681-8807-0c66d7ddd8b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


PyDev 3.4.1 & Django 1.7: undefined variable from Import

2014-05-12 Thread Florian Auer
Hi folks

I'am new to django and try to follow the tutorial to digg into the code.

I am using eclipse 4.3.SR2 with PyDev 3.4.1 and Django 1.7.b2 (because of 
the new features)
In Tutorial Part 3 
(https://docs.djangoproject.com/en/1.7/intro/tutorial03/) the database API 
is used to get the latest 5 objects

latest_question_list = Question.objects.order_by('-pub_date')[:5]


But my eclipse/PyDev does not resolve the objects correctly. "Question.
objects" will e resolved bot not further on. This leads to the problem that 
PyDev is claiming about a "undefined variable from import: order_by"
I know that I can turn off this in the settings, but I would like to know 
if there is a way to bring this auto-completion feature to work.

The application is running correctly an on the python shell the 
auto-completion is also working.
So therefor I would think it is a PyDev problem or did I just missed to add 
something to the config?

-- 
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/13b3436a-402e-47ef-acfd-23fdbaf5166a%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-12 Thread David Malcolm
thanks for your reply WB. 

I was hoping to avoid virtualenv. My webapp is a frontend to a vulnerability 
scanner in a large corporation.
They are very picky about what I can use and what I can't. Is virtualenv 
suitable for such a production system?
They insist that I cannot use mod_wsgi (it annoys me intensely, but hey that's 
life) and HAVE to use mod_python.
Is there any other way to get this working without virtualenv?

I also have no choice about OS. rhel6 is undergoing an approval process as an 
SOE but it won't happen any time soon :(

I am so close to getting this working now but it does indeed look like django 
(httpd) is using python2.4.
Note that "which python" gives me 2.7 - what is causing django to use python & 
mod_python 2.4? mod_python is installed for 2.7.

Mod_python error: "PythonHandler django.core.handlers.modpython"
Traceback (most recent call last):
  File "/usr/lib64/python2.4/site-packages/mod_python/apache.py", line 287, in 
HandlerDispatch
log=debug)
  File "/usr/lib64/python2.4/site-packages/mod_python/apache.py", line 461, in 
import_module
f, p, d = imp.find_module(parts[i], path)
ImportError: No module named django

thanks for your help.
cheers Dave

-- 
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/85c41d50-e41e-4c2f-9951-59c020038cd9%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-12 Thread Timothy W. Cook
I can't imagine virtualenv being a vulnerability risk.  AFAIK; All it does
is create a set of scripts to isolate the executing Python environment.
http://virtualenv.readthedocs.org/en/latest/virtualenv.html

In fact, I would almost say that it improves your ability to know EXACTLY
what is in your environment irregardless of the rest of the machine.

Frankly, I do not create any Python code outside of a specified virtualenv.
 Web apps or any other scripts or apps.




On Mon, May 12, 2014 at 7:50 AM, David Malcolm  wrote:

> Hi Timothy
>
> thanks for your suggestions. I'm still on the path. I'll put more details
> in my reply to WongoBongo below.
>
> cheers
> Dave
>
> --
> 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/f10d728f-b690-4681-8807-0c66d7ddd8b9%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%3DOU3Ui-QV2TRKq3PgOxy4pPBgpRzDS_0S5ZK%2BwzpmgJEHjMg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: PyDev 3.4.1 & Django 1.7: undefined variable from Import

2014-05-12 Thread Bill Freeman
But the code works, right?

This is a PyDev issue, not a Django issue.

(If you can only use code that your IDE understands, that leaves out a lot
of interesting programs.)


On Mon, May 12, 2014 at 4:04 AM, Florian Auer  wrote:

> Hi folks
>
> I'am new to django and try to follow the tutorial to digg into the code.
>
> I am using eclipse 4.3.SR2 with PyDev 3.4.1 and Django 1.7.b2 (because of
> the new features)
> In Tutorial Part 3 (
> https://docs.djangoproject.com/en/1.7/intro/tutorial03/) the database API
> is used to get the latest 5 objects
>
> latest_question_list = Question.objects.order_by('-pub_date')[:5]
>
>
> But my eclipse/PyDev does not resolve the objects correctly. "Question.
> objects" will e resolved bot not further on. This leads to the problem
> that PyDev is claiming about a "undefined variable from import: order_by"
> I know that I can turn off this in the settings, but I would like to know
> if there is a way to bring this auto-completion feature to work.
>
> The application is running correctly an on the python shell the
> auto-completion is also working.
> So therefor I would think it is a PyDev problem or did I just missed to
> add something to the config?
>
>  --
> 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/13b3436a-402e-47ef-acfd-23fdbaf5166a%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/CAB%2BAj0s%3Dv2sqYj94FczL_3yrJ9HK-LYpn%3DZHGvqwqhw%2B4QKseA%40mail.gmail.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-12 Thread Tom Evans
On Mon, May 12, 2014 at 12:09 PM, David Malcolm  wrote:
> thanks for your reply WB.
>
> I was hoping to avoid virtualenv. My webapp is a frontend to a vulnerability 
> scanner in a large corporation.
> They are very picky about what I can use and what I can't. Is virtualenv 
> suitable for such a production system?

If I ever come across a production system where a python app is not
installed in a virtualenv, I consider that a bug. virtualenv is the
basis of all of our python production systems (our dev systems too).

> They insist that I cannot use mod_wsgi (it annoys me intensely, but hey 
> that's life) and HAVE to use mod_python.

mod_python is old, insecure, unmaintained, unmanaged - and most
importantly - not supported for django.

> Is there any other way to get this working without virtualenv?

Find the right person to talk to your in your org, tell them that
mod_python is dangerous, and that virtualenv is the industry standard
way of deploying a python application, and that wsgi is the industry
standard way of connecting a python web application to a web server.

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/CAFHbX1KKVS_ULyJi%3DEOG8n10yn5AO775U3-5qF-sq6zavADgeA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


What does "+=" mean, or do?

2014-05-12 Thread Malik Rumi
I saw it 
here http://www.slideshare.net/jacobian/the-best-and-worst-of-django on 
slide 41. That's a lot to go through, I know, sorry about that. But I 
googled it and of course got nothing because Google ignores things like + 
and = now. And I know in this particular example he says 'don't do this", I 
just want to know what += means or does? Thx. 

-- 
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/f364291f-ae62-4b0b-a2d9-23e3f81a64e4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: What does "+=" mean, or do?

2014-05-12 Thread Tom Evans
On Mon, May 12, 2014 at 2:22 PM, Malik Rumi  wrote:
> I saw it here
> http://www.slideshare.net/jacobian/the-best-and-worst-of-django on slide 41.
> That's a lot to go through, I know, sorry about that. But I googled it and
> of course got nothing because Google ignores things like + and = now. And I
> know in this particular example he says 'don't do this", I just want to know
> what += means or does? Thx.

+ means addition
= means assignment
+= means addition and assignment

Eg, a += 5 means a = a + 5

Cheers

Tom

PS - the "don't do this" is not about "+="!

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


Re: What does "+=" mean, or do?

2014-05-12 Thread Bill Freeman
a += b

is nominally the same as

a = a + b

To make class instances support this behavior the class can implement the
__iadd__ special method.  See docs.python.org and read about special
methods.

This notation originated, so far as I know, in the C language.  It at least
goes back that far.


On Mon, May 12, 2014 at 9:22 AM, Malik Rumi  wrote:

> I saw it here
> http://www.slideshare.net/jacobian/the-best-and-worst-of-django on slide
> 41. That's a lot to go through, I know, sorry about that. But I googled it
> and of course got nothing because Google ignores things like + and = now.
> And I know in this particular example he says 'don't do this", I just want
> to know what += means or does? Thx.
>
> --
> 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/f364291f-ae62-4b0b-a2d9-23e3f81a64e4%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/CAB%2BAj0te4P1ce9AX%3DA9_xxiYFYC2v8dwJU9OhzUQQ%2BmepyPgCQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: What does "+=" mean, or do?

2014-05-12 Thread Malik Rumi
Wow, really quick replies! thanks to both of you!

On Monday, May 12, 2014 8:26:57 AM UTC-5, Tom Evans wrote:
>
> On Mon, May 12, 2014 at 2:22 PM, Malik Rumi 
> > 
> wrote: 
> > I saw it here 
> > http://www.slideshare.net/jacobian/the-best-and-worst-of-django on 
> slide 41. 
> > That's a lot to go through, I know, sorry about that. But I googled it 
> and 
> > of course got nothing because Google ignores things like + and = now. 
> And I 
> > know in this particular example he says 'don't do this", I just want to 
> know 
> > what += means or does? Thx. 
>
> + means addition 
> = means assignment 
> += means addition and assignment 
>
> Eg, a += 5 means a = a + 5 
>
> Cheers 
>
> Tom 
>
> PS - the "don't do this" is not about "+="! 
>

-- 
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/e9a173df-ce25-44ee-9fc9-f3d0f9daa62c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to display the database table in administration tool??

2014-05-12 Thread dev tc
Hi,
I am really new to django (and python as well). 
I now try to create an app from the django. 
I want to view the database table on something like phpmyadmin, does django 
come with administration tool?
I installed the django on virtualenv on my local computer (Arch Linux), and 
it already have mariadb installed. How can I use it for my app on my local 
machine and finally use phpmyadmin to display the db and table? 
 

Thanks 

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


Re: PyDev 3.4.1 & Django 1.7: undefined variable from Import

2014-05-12 Thread Bill Freeman
Also, I don't think that it's the += that he's worried about.  What he's
saying is that you shouldn't expect every sub-directory of BASE to always
be an app, and/or that the order of INSTALLED_APPS can be important, and/or
that your settings.py file should document what you are using.


On Mon, May 12, 2014 at 9:04 AM, Bill Freeman  wrote:

> But the code works, right?
>
> This is a PyDev issue, not a Django issue.
>
> (If you can only use code that your IDE understands, that leaves out a lot
> of interesting programs.)
>
>
> On Mon, May 12, 2014 at 4:04 AM, Florian Auer  wrote:
>
>> Hi folks
>>
>> I'am new to django and try to follow the tutorial to digg into the code.
>>
>> I am using eclipse 4.3.SR2 with PyDev 3.4.1 and Django 1.7.b2 (because of
>> the new features)
>> In Tutorial Part 3 (
>> https://docs.djangoproject.com/en/1.7/intro/tutorial03/) the database
>> API is used to get the latest 5 objects
>>
>> latest_question_list = Question.objects.order_by('-pub_date')[:5]
>>
>>
>> But my eclipse/PyDev does not resolve the objects correctly. "Question.
>> objects" will e resolved bot not further on. This leads to the problem
>> that PyDev is claiming about a "undefined variable from import: order_by"
>> I know that I can turn off this in the settings, but I would like to know
>> if there is a way to bring this auto-completion feature to work.
>>
>> The application is running correctly an on the python shell the
>> auto-completion is also working.
>> So therefor I would think it is a PyDev problem or did I just missed to
>> add something to the config?
>>
>>  --
>> 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/13b3436a-402e-47ef-acfd-23fdbaf5166a%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/CAB%2BAj0tM79-6TcEtnCnbfgoBpwXSvsSAty5CMKw0_xeG7EKTtQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: FormWizard confirmation step logic and Allow dynamic form classes with WizardView

2014-05-12 Thread Fabio Caritas Barrionuevo da Luz
Apparently nobody is interested in WizardView and related features, much 
less with the proposed[1][3] improvements.


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


Em quarta-feira, 7 de maio de 2014 17h43min57s UTC-3, Fabio Caritas 
Barrionuevo da Luz escreveu:
>
> 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/19369e7b-cddf-470d-b1c3-ee5a95273ae3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django create userprofile

2014-05-12 Thread hito koto
Thank you !
I was should be set up unique=True 

2014年5月12日月曜日 18時46分22秒 UTC+9 Erik Cederstrand:
>
> Den 12/05/2014 kl. 11.38 skrev hito koto >: 
>
>
> > Ok, Thank you! 
> > 
> > So, this is my the full codes; 
>
> Are you sure your database is in sync with your model? The error message 
> implies that the field is defined with unique=True, but your model doesn't 
> define it so: 
>
>   start_work = models.ForeignKey(Staff, verbose_name = "名前") 
>
>
> Erik 
>
>

-- 
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/c02c0795-d4b5-4909-8ed9-cd072ebbca9e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Opinion needed for a BookMarker project - Regarding CSRF token

2014-05-12 Thread Aseem Bansal
I am new to Django and am learning it baically because I wanted to create a 
BookMarker project. A project for managing bookmarks. For this I am going 
to create a UI through Django and a JavaScript for sending the URLs to the 
app. There is a problem of CSRF token in Django. I was able to do a dummy 
POST request  by sending the CSRF token hard-coded as a parameter. But I do 
not understand how the CSRF tokens are generated. Can I just hard-code 
them? I don't think that it should be possible otherwise there is no point 
of having it in the first place. Should I consider turning off the CSRF 
middleware as this is just local machine or should I keep it as a best 
practice and find a way to generate the CSRF token in my JavaScript? That 
would suck but I am out of opinions. 

Also when you are doing Django projects and need to deal with JS then what 
do you do? I mean is there an alternative for JS in Django? 

If any of these questions doesn't make any sense please tell and I will try 
to improve these. Just tell what doesn't make sense.

-- 
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/8f166450-195f-45fb-98e5-c67448ed92b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Opinion needed for a BookMarker project - Regarding CSRF token

2014-05-12 Thread Sanjay Bhangar
Hi Aseem,

On Mon, May 12, 2014 at 11:25 PM, Aseem Bansal  wrote:
> I am new to Django and am learning it baically because I wanted to create a
> BookMarker project. A project for managing bookmarks. For this I am going to
> create a UI through Django and a JavaScript for sending the URLs to the app.
> There is a problem of CSRF token in Django. I was able to do a dummy POST
> request  by sending the CSRF token hard-coded as a parameter. But I do not
> understand how the CSRF tokens are generated. Can I just hard-code them? I
> don't think that it should be possible otherwise there is no point of having
> it in the first place. Should I consider turning off the CSRF middleware as
> this is just local machine or should I keep it as a best practice and find a
> way to generate the CSRF token in my JavaScript? That would suck but I am
> out of opinions.
>

To use the csrf token and send it along with AJAX requests made in
javascript, refer
https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax .

It should be fairly straightforward following steps there. Let know if
anything is unclear or does not work.

> Also when you are doing Django projects and need to deal with JS then what
> do you do? I mean is there an alternative for JS in Django?
>
> If any of these questions doesn't make any sense please tell and I will try
> to improve these. Just tell what doesn't make sense.
>

Hope the documentation makes sense, otherwise just search for "django
ajax csrf token" or so and you should find quite a lot of examples
online :)

All the best.
-Sanjay

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


Re: Opinion needed for a BookMarker project - Regarding CSRF token

2014-05-12 Thread Aseem Bansal
Hi Sanjay

I think you misunderstood a bit. The JS that I am talking about will not be 
inside the web pages of the project. The JS is supposed to be used as a 
Bookmarklet in the web browser. I intend to use the bookmarklet for sending 
the current webpage's url to the app via a POST request. The app will then 
store the URL.

Here a problem due to CSRF token would occur becuase I can hard-code the 
CSRF token in the JS for one environment but as I am not aware how the 
token is generated it would be difficult to dynamically generate the token 
in the JS for a different environment. For example if I tried to run the 
app on a different computer than I will have to manually check the CSRF 
token for that and change the hard-coding.

On Tuesday, May 13, 2014 12:57:40 AM UTC+5:30, Sanjay Bhangar wrote:
>
> Hi Aseem, 
>
> On Mon, May 12, 2014 at 11:25 PM, Aseem Bansal 
> > 
> wrote: 
> > I am new to Django and am learning it baically because I wanted to 
> create a 
> > BookMarker project. A project for managing bookmarks. For this I am 
> going to 
> > create a UI through Django and a JavaScript for sending the URLs to the 
> app. 
> > There is a problem of CSRF token in Django. I was able to do a dummy 
> POST 
> > request  by sending the CSRF token hard-coded as a parameter. But I do 
> not 
> > understand how the CSRF tokens are generated. Can I just hard-code them? 
> I 
> > don't think that it should be possible otherwise there is no point of 
> having 
> > it in the first place. Should I consider turning off the CSRF middleware 
> as 
> > this is just local machine or should I keep it as a best practice and 
> find a 
> > way to generate the CSRF token in my JavaScript? That would suck but I 
> am 
> > out of opinions. 
> > 
>
> To use the csrf token and send it along with AJAX requests made in 
> javascript, refer 
> https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax . 
>
> It should be fairly straightforward following steps there. Let know if 
> anything is unclear or does not work. 
>
> > Also when you are doing Django projects and need to deal with JS then 
> what 
> > do you do? I mean is there an alternative for JS in Django? 
> > 
> > If any of these questions doesn't make any sense please tell and I will 
> try 
> > to improve these. Just tell what doesn't make sense. 
> > 
>
> Hope the documentation makes sense, otherwise just search for "django 
> ajax csrf token" or so and you should find quite a lot of examples 
> online :) 
>
> All the best. 
> -Sanjay 
>

-- 
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/971c8426-16a7-4fb3-8d5c-36b8d8d9b1a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Opinion needed for a BookMarker project - Regarding CSRF token

2014-05-12 Thread Tom Evans
On Mon, May 12, 2014 at 9:01 PM, Aseem Bansal  wrote:
> Hi Sanjay
>
> I think you misunderstood a bit. The JS that I am talking about will not be
> inside the web pages of the project. The JS is supposed to be used as a
> Bookmarklet in the web browser. I intend to use the bookmarklet for sending
> the current webpage's url to the app via a POST request. The app will then
> store the URL.

The entire purpose of CSRF is to stop things like that from being
possible. The bookmark makes a cross site request from the site you
are currently on to your django site.

In light of that, disable CSRF for that view.

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


Re: Opinion needed for a BookMarker project - Regarding CSRF token

2014-05-12 Thread carlos
Hi you read this part of the exempt, if you not need csrf
https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#django.views.decorators.csrf.csrf_exempt

cheers


On Mon, May 12, 2014 at 2:01 PM, Aseem Bansal  wrote:

> Hi Sanjay
>
> I think you misunderstood a bit. The JS that I am talking about will not
> be inside the web pages of the project. The JS is supposed to be used as a
> Bookmarklet in the web browser. I intend to use the bookmarklet for sending
> the current webpage's url to the app via a POST request. The app will then
> store the URL.
>
> Here a problem due to CSRF token would occur becuase I can hard-code the
> CSRF token in the JS for one environment but as I am not aware how the
> token is generated it would be difficult to dynamically generate the token
> in the JS for a different environment. For example if I tried to run the
> app on a different computer than I will have to manually check the CSRF
> token for that and change the hard-coding.
>
>
> On Tuesday, May 13, 2014 12:57:40 AM UTC+5:30, Sanjay Bhangar wrote:
>
>> Hi Aseem,
>>
>> On Mon, May 12, 2014 at 11:25 PM, Aseem Bansal 
>> wrote:
>> > I am new to Django and am learning it baically because I wanted to
>> create a
>> > BookMarker project. A project for managing bookmarks. For this I am
>> going to
>> > create a UI through Django and a JavaScript for sending the URLs to the
>> app.
>> > There is a problem of CSRF token in Django. I was able to do a dummy
>> POST
>> > request  by sending the CSRF token hard-coded as a parameter. But I do
>> not
>> > understand how the CSRF tokens are generated. Can I just hard-code
>> them? I
>> > don't think that it should be possible otherwise there is no point of
>> having
>> > it in the first place. Should I consider turning off the CSRF
>> middleware as
>> > this is just local machine or should I keep it as a best practice and
>> find a
>> > way to generate the CSRF token in my JavaScript? That would suck but I
>> am
>> > out of opinions.
>> >
>>
>> To use the csrf token and send it along with AJAX requests made in
>> javascript, refer
>> https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax .
>>
>> It should be fairly straightforward following steps there. Let know if
>> anything is unclear or does not work.
>>
>> > Also when you are doing Django projects and need to deal with JS then
>> what
>> > do you do? I mean is there an alternative for JS in Django?
>> >
>> > If any of these questions doesn't make any sense please tell and I will
>> try
>> > to improve these. Just tell what doesn't make sense.
>> >
>>
>> Hope the documentation makes sense, otherwise just search for "django
>> ajax csrf token" or so and you should find quite a lot of examples
>> online :)
>>
>> All the best.
>> -Sanjay
>>
>  --
> 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/971c8426-16a7-4fb3-8d5c-36b8d8d9b1a2%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/CAM-7rO0axQxvpjt4%2B9R23k_kB7-hb4zy2y_-jfJPtLma%2BaTvkQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Opinion needed for a BookMarker project - Regarding CSRF token

2014-05-12 Thread Tom Evans
On Mon, May 12, 2014 at 9:08 PM, Tom Evans  wrote:
> On Mon, May 12, 2014 at 9:01 PM, Aseem Bansal  wrote:
>> Hi Sanjay
>>
>> I think you misunderstood a bit. The JS that I am talking about will not be
>> inside the web pages of the project. The JS is supposed to be used as a
>> Bookmarklet in the web browser. I intend to use the bookmarklet for sending
>> the current webpage's url to the app via a POST request. The app will then
>> store the URL.
>
> The entire purpose of CSRF is to stop things like that from being
> possible. The bookmark makes a cross site request from the site you
> are currently on to your django site.
>
> In light of that, disable CSRF for that view.
>

I should also mention that this would also leave that view wide open
to a CSRF attack. A malicious user who can make you execute javascript
- if you view a webpage they either control, or have injected
javascript in to (like a forum) - could then make your browser make
forged requests to your view, submitting whatever content or url that
they wanted to it, using your credentials.

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


Django Template Based If Statement Issue

2014-05-12 Thread G Z


Views.py


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)


index.html


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

{% endif %}



Test Data 
e.name - {{ e.NAME }}

d.customerid - {{ d.CUSTOMERID }}


{% endfor %}
{% endfor %}


The section for test data will display but the section under the iff statement 
wont and there are values that match exactly.

-- 
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/f7c8ca19-e66d-4a70-bbac-426d66b25c2f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Template Based If Statement Issue

2014-05-12 Thread Tom Evans
On Mon, May 12, 2014 at 10:02 PM, G Z  wrote:
> Views.py
>
>
> 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)
>
>
> index.html
>
>
> {% for e in customers %}
> {% for d in vms %}
> {% if e.NAME == d.CUSTOMERID %}
>  {{ e.id }} - {{ e.NAME }} - {{ d.VMNAME }}
> 
> {% endif %}
>
>
> 
> Test Data 
> e.name - {{ e.NAME }}
>
> d.customerid - {{ d.CUSTOMERID }}
>
>
> {% endfor %}
> {% endfor %}
>
>
> The section for test data will display but the section under the iff
> statement wont and there are values that match exactly.
>

Generally people do their table joins in the database rather than the
template...

Could we start with what are you trying to achieve with this page,
rather than what is going wrong. What HTML should that section
generate?

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


Re: Django Template Based If Statement Issue

2014-05-12 Thread G Z
I'm just trying to associate each vm tied to the customers id and display 
the vms under the customer that are associated with his id.

On Monday, May 12, 2014 3:02:34 PM UTC-6, G Z wrote:
>
> Views.py
>
>
> 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)
>
>
> index.html
>
>
> {% for e in customers %}
> {% for d in vms %}
> {% if e.NAME == d.CUSTOMERID %}
>  {{ e.id }} - {{ e.NAME }} - {{ d.VMNAME }} 
> 
> {% endif %}
>
>
> 
> Test Data 
> e.name - {{ e.NAME }}
>
> d.customerid - {{ d.CUSTOMERID }}
>
>
> {% endfor %}
> {% endfor %}
>
>
> The section for test data will display but the section under the iff 
> statement wont and there are values that match exactly.
>
>

-- 
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/0b78b42e-dc8c-46f4-adbc-60e116dfe2cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Template Based If Statement Issue

2014-05-12 Thread G Z
so as you can see when ever the vm field customer id matches the customers 
name i want to display the vm with the customer. To create a table of vms 
that each customer has. I also will be associating a third database with 
vmspecs to each vm.

I know there is an easier way to do this with django but i didn't quite 
understand waht the documentation was sayign






On Monday, May 12, 2014 3:02:34 PM UTC-6, G Z wrote:
>
> Views.py
>
>
> 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)
>
>
> index.html
>
>
> {% for e in customers %}
> {% for d in vms %}
> {% if e.NAME == d.CUSTOMERID %}
>  {{ e.id }} - {{ e.NAME }} - {{ d.VMNAME }} 
> 
> {% endif %}
>
>
> 
> Test Data 
> e.name - {{ e.NAME }}
>
> d.customerid - {{ d.CUSTOMERID }}
>
>
> {% endfor %}
> {% endfor %}
>
>
> The section for test data will display but the section under the iff 
> statement wont and there are values that match exactly.
>
>

-- 
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/63db923d-905d-4cf9-ba8b-41efdacf9dc5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Template Based If Statement Issue

2014-05-12 Thread Tom Evans
On Mon, May 12, 2014 at 10:47 PM, G Z  wrote:
> I'm just trying to associate each vm tied to the customers id and display
> the vms under the customer that are associated with his id.
>

Normally, you would have some sort of relationship between those
models, and the template code would look something like this:


{% for customer in customers %}
{% for vms in customer.vms_set.all %}
{{ vms.id }} - {{ vms.NAME }} - {{ d.VMNAME }}

{% endfor %}
{% endfor %}

Please note, even if you are using a legacy database, there is no need
for the model's fields to have the same name as the table column. All
caps normally denotes a constant, these are not constants, and
"VMNAME" is less pleasant to look at than "virtual_machine_name" or
even "vm_name".

One other thing, your view, you should be actually calling the
function "all()", not passing the function object "all":

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

Note the brackets, and you no longer need to pass in 'vms' either, as
it should come from the relation.

If this doesn't work, please show your models.

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


Re: Django Template Based If Statement Issue

2014-05-12 Thread G Z
this is my models 

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
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 unicode(self.VMID)

if im not wrong the foreignkey is the association

On Monday, May 12, 2014 4:00:27 PM UTC-6, Tom Evans wrote:
>
> On Mon, May 12, 2014 at 10:47 PM, G Z > 
> wrote: 
> > I'm just trying to associate each vm tied to the customers id and 
> display 
> > the vms under the customer that are associated with his id. 
> > 
>
> Normally, you would have some sort of relationship between those 
> models, and the template code would look something like this: 
>
>
> {% for customer in customers %} 
> {% for vms in customer.vms_set.all %} 
> {{ vms.id }} - {{ vms.NAME }} - {{ d.VMNAME }} 
>  
> {% endfor %} 
> {% endfor %} 
>
> Please note, even if you are using a legacy database, there is no need 
> for the model's fields to have the same name as the table column. All 
> caps normally denotes a constant, these are not constants, and 
> "VMNAME" is less pleasant to look at than "virtual_machine_name" or 
> even "vm_name". 
>
> One other thing, your view, you should be actually calling the 
> function "all()", not passing the function object "all": 
>
> def index(request): 
>customers = Customer.objects.all() 
>ctx = { 'customers':customers } 
>return render_to_response('index.html', ctx) 
>
> Note the brackets, and you no longer need to pass in 'vms' either, as 
> it should come from the relation. 
>
> If this doesn't work, please show your models. 
>
> 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/9bd4411a-d0d3-4da7-a6cb-ed233a684bc7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Template Based If Statement Issue

2014-05-12 Thread G Z
also thank you so much for your help.

On Monday, May 12, 2014 4:00:27 PM UTC-6, Tom Evans wrote:
>
> On Mon, May 12, 2014 at 10:47 PM, G Z > 
> wrote: 
> > I'm just trying to associate each vm tied to the customers id and 
> display 
> > the vms under the customer that are associated with his id. 
> > 
>
> Normally, you would have some sort of relationship between those 
> models, and the template code would look something like this: 
>
>
> {% for customer in customers %} 
> {% for vms in customer.vms_set.all %} 
> {{ vms.id }} - {{ vms.NAME }} - {{ d.VMNAME }} 
>  
> {% endfor %} 
> {% endfor %} 
>
> Please note, even if you are using a legacy database, there is no need 
> for the model's fields to have the same name as the table column. All 
> caps normally denotes a constant, these are not constants, and 
> "VMNAME" is less pleasant to look at than "virtual_machine_name" or 
> even "vm_name". 
>
> One other thing, your view, you should be actually calling the 
> function "all()", not passing the function object "all": 
>
> def index(request): 
>customers = Customer.objects.all() 
>ctx = { 'customers':customers } 
>return render_to_response('index.html', ctx) 
>
> Note the brackets, and you no longer need to pass in 'vms' either, as 
> it should come from the relation. 
>
> If this doesn't work, please show your models. 
>
> 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/746d62be-3162-44ab-94f4-6b99d726fd37%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Template Based If Statement Issue

2014-05-12 Thread G Z

>
> ok its still not putting out the vm data i get 


Grant - google.com - 7029855378 - zuk...@gmail.com - 2332 oakland st
- -


{% for customer in customers %}
{{ customer.NAME }} - {{ customer.WEBSITE }} - 
 {{customer.PHONE}} - {{ customer.EMAIL }} - {{ customer.ADDRESS }}   
 
{% for Vms in customer.vms_set.all %}
{{ vms.id }} - {{ vms.NAME }} - {{ 
vms.VMSTATUS }}
{% endfor %}
{% endfor %}


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




its still not working 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/ca712dba-3b05-43c0-a2ea-064799017bd4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Template Based If Statement Issue

2014-05-12 Thread donarb


On Monday, May 12, 2014 3:37:47 PM UTC-7, G Z wrote:
>
> ok its still not putting out the vm data i get 
>
>
> Grant - google.com - 7029855378 - zuk...@gmail.com  - 2332 
> oakland st
> - -
>
>
> {% for customer in customers %}
> {{ customer.NAME }} - {{ customer.WEBSITE }} 
> -  {{customer.PHONE}} - {{ customer.EMAIL }} - {{ customer.ADDRESS }}   
>  
> {% for Vms in customer.vms_set.all %}
> {{ vms.id }} - {{ vms.NAME }} - {{ 
> vms.VMSTATUS }}
> {% endfor %}
> {% endfor %}
>
>
> def index(request):
>customers = Customer.objects.all()
>ctx = { 'customers':customers }
>return render_to_response('index.html', ctx)
>
>
>
>
> its still not working correctly.
>
>
>
You have

{% for Vms in customer.vms_set_all %} 

And then 

{{ vms.id }}...

Vms is not the same variable as vms.


-- 
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/15927d9c-e921-4e37-9549-90bc532b6b4c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django case, when, then on querysets

2014-05-12 Thread Anthony Hawkes
Hi Guys,

I need to replace results in a queryset and then perform counts and further 
queries on the set and have been trying to find a way of doing it.

Basically in some but not all cases I get a set of results eg select * from 
table and then I want to do a: case when column = 'some value' then 'some 
other value'.

Is there any way using django's queries or at least preserving the ability 
to continue using the queries using raw sql? (I've had a look at extra() 
but can't see a way to make it 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/af24856c-5d0a-45aa-932d-faa56c097bcb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: GET parameters in admin "add" model page

2014-05-12 Thread Russell Keith-Magee
Hi,

On Sun, May 11, 2014 at 11:42 PM, ?manu*  wrote:

> I noticed that django admin "add" page reads GET parameters and uses them
> as initial values in the form. However I was not able to pass DateTime
> values in this way. In particular if I try to pass a DateTime value I get a
> "server error".
>
> See
> http://stackoverflow.com/questions/23559771/django-admin-add-page-initial-datetime-from-get-parametersfor
>  more details.
>
> 1. is it possible to pass DateTime values this way?
>

Yes, but not "out of the box". I've responded on the SO thread; but the
short answer is that you need to override get_changeform_initial_data() in
your ModelAdmin class.

2. isn't it a bug if a user is able to generate a server error by messing
> with GET parameters?
>
>
Not necessarily. It's only a bug if, when *using the APIs as documented*, a
user is able to generate a server error by providing faulty GET arguments.
Taking the extreme case of the argument - if you write a view that
knowingly does divide by zero, it's not a bug in Django that the user is
able to generate a 500 by visiting that view. In your case, the argument is
much more subtle, but you still have code that is "wrong", and as a result,
it's raising a 500.

Yours,
Russ Magee %-)

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


Django1.6 CentOS Apache static

2014-05-12 Thread hito koto
Hello,

I have 3 project,
CentOS
Apache
Django1.6
Mod_wsgi


I have  the following error:
[Tue May 13 14:43:47 2014] [warn] The Alias directive in 
/etc/httpd/conf.d/wsgi.conf at line 17 will probably never match because it 
overlaps an earlier Alias.

This is my the : /etc/httpd/conf.d/wsgi.conf

WSGIScriptAlias /django_test  
/var/www/html/django_test/skillshare/skillshare/wsgi.py

Alias /static/  "/django_test/skillshare/skillshare/static/"

WSGIScriptAlias /mysite   /var/www/html/mysite/test/test/wsgi.py

Alias /static/  "/mysite/test/test/static/"

WSGIScriptAlias /mysite/abc /var/www/html/mysite/abc/article/article/wsgi.py

Alias /static/  "/mysite/abc/test/test/static/"

-- 
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/b43363cc-b4ef-4f8a-96b1-c03fd4375314%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.