Re: modelform selection options

2018-02-17 Thread sum abiut
Ok now i have written my view,py

def payhistory(request):
paynum=selection.objects.all()
num=request.POST.get('dropdown')
if request.method=='GET':
form=paynumberform()
else:
select=selection.objects.get(num=num)
#do someting
return render(request,'displaypayhistory.html',locals())

return render(request,'payhistory.html',{'form':form,'paynum':paynum})


and my template 'payhistory.html

{%csrf_token%}
  
Pay Number:
  

  {%for paynum in paynum%}

  {{paynum.num}}
  {%endfor%}







  



i manage to load the form, but the drop down list elements are not showing.


cheers,



On Fri, Feb 16, 2018 at 11:00 AM, sum abiut  wrote:

> I have a model.py
> class selection(models.Model):
> select=(
> (A','A'),
> ('B','B'),
> ('C','C'),
>
>
> )
>
> options=models.CharField(max_length=7,choices=select)
>
>
> and form.py
>
> class order(forms.ModelForm):
> class Meta:
> model=selection
> fields=('Pay_options,)
>
>
> I want to write a view.py that check the form for the choice that is
> selected but i don't know how to get started. for example if a user select
> option A, i want to perform some query. I want to know how to check for the
> options that are selected before i can performing a query. Appreciate any
> assistances.
>
> cheers,
>



--

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


Re: When to use get_user_model()

2018-02-17 Thread tango ward
I also checked the documentation of it but I am confuse. It says "Instead
of referring to User

directly, you should reference the user model using
django.contrib.auth.get_user_model(). This method will return the currently
active user model – the custom user model if one is specified, or User

otherwise." When it says "currently active user mode" is it the model that
I created in models.py or the one that is currently logged in to the
website? what does "or User otherwise" mean?

My apologies for asking too many questions.

On Sun, Feb 18, 2018 at 6:39 AM, tango ward  wrote:

>
> Hi,
>
> I am playing around with user registration. I came across a code where the
> get_user_model() was assigned to a model in Meta class inside a form. I was
> just wondering, what is the benefit of using the get_user_model() as Model
> in a form instead of importing a class from models.py then use that class
> as model of the form and when should I use it?
>
> models.py
> class RegUser(User):
>
> def __str__(self):
> return self.username
>
> forms.py
>
> class UserCreateForm(UserCreationForm):
>
> class Meta:
> fields = ('username', 'password1', 'password2')
> model = get_user_model()
>
>
> Thanks,
> Jarvis
>

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


When to use get_user_model()

2018-02-17 Thread tango ward
Hi,

I am playing around with user registration. I came across a code where the
get_user_model() was assigned to a model in Meta class inside a form. I was
just wondering, what is the benefit of using the get_user_model() as Model
in a form instead of importing a class from models.py then use that class
as model of the form and when should I use it?

models.py
class RegUser(User):

def __str__(self):
return self.username

forms.py

class UserCreateForm(UserCreationForm):

class Meta:
fields = ('username', 'password1', 'password2')
model = get_user_model()


Thanks,
Jarvis

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


Re: Error with django-admin.py

2018-02-17 Thread Tet Yeap
Hi Dylan,

 Thank you for the pointers. As you have suggested, after re-installing 
Python, I am able to continue my work. I must have screw up the path.

Regards,

Tet Yeap


On Saturday, February 17, 2018 at 12:48:58 PM UTC-5, Tet Yeap wrote:
>
> Hi,
>
> I was trying to crate a django project using "django-admin.py 
> startproject mysite". The a message showed up in notepad 
>
> "#!C:\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\python.exe
> from django.core import management
>
> if __name__ == "__main__":
> management.execute_from_command_line()
>
> I am using Django 2.0, Python 3.6. Both programs run on Windows 8.
>
> Do anyone know what is wrong? Tx.
>
>
>

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


Re: Error with django-admin.py

2018-02-17 Thread Dylan Reinhold
This means your windows system has python files (.py) associated with
notepad not python.
It's okay, but anything you are going to run a python script like
django-admin.py or manage.py you need to run pythin first.

>  python django-admin.py startproject myapp
>  python manage.py

If you get an error about python comand not found you will need to fix the
path, the easy way might be to re run the python3 installer and make sure
add python to the path and associdate .py files to python is checked.

Dylan

On Sat, Feb 17, 2018 at 8:59 AM, Tet Yeap  wrote:

> Hi,
>
> I was trying to crate a django project using "django-admin.py
> startproject mysite". The a message showed up in notepad
>
> "#!C:\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\python.exe
> from django.core import management
>
> if __name__ == "__main__":
> management.execute_from_command_line()
>
> I am using Django 2.0, Python 3.6. Both programs run on Windows 8.
>
> Do anyone know what is wrong? Tx.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/7eef68cc-5480-4a3a-b0b8-11a97044ca0d%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Error with django-admin.py

2018-02-17 Thread Etienne Robillard

Please send the actual traceback and error message.

Etienne

Le 2018-02-17 à 11:59, Tet Yeap a écrit :

Hi,

    I was trying to crate a django project using "django-admin.py 
startproject mysite". The a message showed up in notepad


"#!C:\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\python.exe
from django.core import management

if __name__ == "__main__":
    management.execute_from_command_line()

    I am using Django 2.0, Python 3.6. Both programs run on Windows 8.

    Do anyone know what is wrong? Tx.


--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to django-users+unsubscr...@googlegroups.com 
.
To post to this group, send email to django-users@googlegroups.com 
.

Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7eef68cc-5480-4a3a-b0b8-11a97044ca0d%40googlegroups.com 
.

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


--
Etienne Robillard
tkad...@yandex.com
https://www.isotopesoftware.ca/

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


Strange problem with Django

2018-02-17 Thread Tet Yeap
Hi,

I was trying to learn Django. I have installed Python 3.6 and Django. 
The installation was successful. When I ran "django-admin startproject 
mysite" to create a new project, the attached file showed up and the 
program stop. What is wrong?

Thank you.

Tet Yeap
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/eb395e57-5633-4b00-87de-459729e085f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
#!C:\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\python.exe
from django.core import management

if __name__ == "__main__":
management.execute_from_command_line()



Error with django-admin.py

2018-02-17 Thread Tet Yeap
Hi,

I was trying to crate a django project using "django-admin.py 
startproject mysite". The a message showed up in notepad 

"#!C:\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\python.exe
from django.core import management

if __name__ == "__main__":
management.execute_from_command_line()

I am using Django 2.0, Python 3.6. Both programs run on Windows 8.

Do anyone know what is wrong? Tx.


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


Re: Syntax Error when trying to migrate to Postgresql

2018-02-17 Thread PASCUAL Eric
Office oriented editors tend to take initiatives for making the text prettier 
(at least, according to their "standards" 😊).


For programming tasks, you'd better use real programming editors. There are a 
lot of very good ones which are free, and even full IDEs. I'd strongly suggest 
PyCharm Community Edition in this category (I'm not endorsed by JetBrain and 
have no connection at all with them, apart from being a very happy user of 
their products).


Best


Eric

From: django-users@googlegroups.com  on behalf 
of Joe 
Sent: Thursday, February 15, 2018 4:12:54 AM
To: Django users
Subject: Re: Syntax Error when trying to migrate to Postgresql

The problem was with the quotes being weird format, had to copy and paste the 
correct quotes in for it.  Thanks for the help!!

On Wednesday, February 14, 2018 at 9:59:06 PM UTC-5, Joe wrote:
I used TextEdit on Mac to edit the files, maybe using a different editor would 
work better.

On Wednesday, February 14, 2018 at 5:41:24 PM UTC-5, larry@gmail.com wrote:
On Wed, Feb 14, 2018 at 5:32 PM, Joe  wrote:
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.postgresql',
> 'NAME': ‘postgres’,
> 'USER': ‘postgres’,
> 'PASSWORD': ‘*’,
> 'HOST': ‘localhost’,
> 'PORT': ‘8000’,
> }
> }

Looks like the quotes around the values are some non ascii character.
On my screen I see this:

‘

Change it to ' or "

Did you copy/paste that from Word perhaps?

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

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