Re: Local variable dump on exception in production environment (DEBUG=False)

2019-02-03 Thread Web Architect
Hi Simon,

Thanks for your response. 

include_html was what I needed and the stack trace in mail contained the 
variable dump.

Thanks a lot. 

On Friday, February 1, 2019 at 10:15:53 PM UTC+5:30, Simon Charette wrote:
>
> Hello there,
>
> I haven't tried it myself but you could try subclassing 
> django.utils.log.AdminEmailHandler
> to rely on the better-exceptions[0] package to _better_ format exceptions 
> sent in text
> emails or simply set the include_html option[1] to True in your LOGGING 
> configuration to
> get report similar to when DEBUG=True is enabled in development 
> environment.
>
> Cheers,
> Simon
>
> [0] https://github.com/Qix-/better-exceptions
> [1] 
> https://docs.djangoproject.com/en/2.1/topics/logging/#django.utils.log.AdminEmailHandler
>
> Le vendredi 1 février 2019 05:11:47 UTC-5, Web Architect a écrit :
>>
>> Hi,
>>
>> In our production environment, we receive mail whenever an exception 
>> happens in our django application. But it contains only the function 
>> traces. The log will be helpful it also contains data dump or the local 
>> variable dump for each function trace. 
>> The exception trace on the browser in our development environment 
>> (DEBUG=True) contains the local variable dump. 
>>
>> Hence, could anyone let me know if it's possible to get the local 
>> variable dump during exceptions in our django application? 
>>
>> Thanks.
>>
>

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


Re: PLEASE HELP! Django documentation, Writing Your First App, Part 4

2019-02-03 Thread Atsunori Kaneshige
Hi Carsten,

Thank you!
I finally understood what's happening.
I should have added choices into each question.
Now, choice_set.all thing is working!

Thank you for your advice!

Nori

On Sunday, February 3, 2019 at 3:20:39 PM UTC-5, Carsten Fuchs wrote:
>
> Well, you're adding choices to q = Question.objects.get(pk=1). 
> But is this also the question you call the view with? 
>
> I suggest you add a few more print statements below your existing 
>
> print(question) 
>
> For example: 
>
> print(question.pk) 
> print(question.choice_set.all()) 
>
> # Or, a bit more verbose, for example: 
> for c in question.choice_set.all(): 
> print(c.pk, c) 
>
> # Is the following a valid PK among the choices printed above? 
> print(request.POST['choice']) 
>
> Best regards, 
> Carsten 
>
>
> Am 2019-02-03 um 16:58 schrieb Atsunori Kaneshige: 
> > *_Here is the codes about choice_* 
> > 
> > 
> > In [27]: q = Question.objects.get(pk=1) 
> > 
> > 
> > In [28]: q.choice_set.all() 
> > 
> > Out[28]:  
> > 
> > 
> > In [29]: q.choice_set.create(choice_text='Not much',votes=0) 
> > 
> > Out[29]:  
> > 
> > 
> > In [30]: q.choice_set.create(choice_text='The sky',votes=0) 
> > 
> > Out[30]:  
> > 
> > 
> > In [31]: c = q.choice_set.create(choice_text='Just hacking 
> again',votes=0) 
> > 
> > 
> > In [32]: c.question 
> > 
> > Out[32]:  
> > 
> > 
> > In [33]: q.choice_set.all() 
> > 
> > Out[33]: , , 
> ]> 
> > 
> > 
> > In [34]: q.choice_set.count() 
> > 
> > Out[34]: 3 
> > 
> > 
> > 
> > choice exits, or correctly working? 
> > 
> > Nori 
> > 
> > On Sunday, February 3, 2019 at 10:55:48 AM UTC-5, Atsunori Kaneshige 
> wrote: 
> > 
> > Hi Carsten, 
> > 
> > Sorry, are you talking about Writing Your First App, Part2? The page 
> below? 
> > https://docs.djangoproject.com/en/2.1/intro/tutorial02/ <
> https://docs.djangoproject.com/en/2.1/intro/tutorial02/> 
> > 
> > Yeah, when I tried this, there was something wrong. 
> > 
> > *_I did that again. I copied and pasted my terminal below._* 
> > *_seems like migration was successful when I did before._* 
> > *_I am not sure what 'python sqlmigrate polls 001' is doing._* 
> > 
> > 
> > MacBook-Pro-3:mysite Koitaro$ python manage.py migrate 
> > 
> > 
> /Applications/anaconda3/lib/python3.6/site-packages/psycopg2/__init__.py:144: 
> UserWarning: The psycopg2 wheel package will be renamed from release 2.8; 
> in order to keep installing from binary please use "pip install 
> psycopg2-binary" instead. For details see: <
> http://initd.org/psycopg/docs/install.html#binary-install-from-pypi <
> http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>>. 
> > 
> >   """) 
> > 
> > Operations to perform: 
> > 
> >   Apply all migrations: admin, auth, contenttypes, polls, sessions 
> > 
> > Running migrations: 
> > 
> >   No migrations to apply. 
> > 
> > MacBook-Pro-3:mysite Koitaro$ python manage.py makemigrations polls 
> > 
> > 
> /Applications/anaconda3/lib/python3.6/site-packages/psycopg2/__init__.py:144: 
> UserWarning: The psycopg2 wheel package will be renamed from release 2.8; 
> in order to keep installing from binary please use "pip install 
> psycopg2-binary" instead. For details see: <
> http://initd.org/psycopg/docs/install.html#binary-install-from-pypi <
> http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>>. 
> > 
> >   """) 
> > 
> > No changes detected in app 'polls' 
> > 
> > MacBook-Pro-3:mysite Koitaro$ python manage.py sqlmigrate polls 0001 
> > 
> > 
> /Applications/anaconda3/lib/python3.6/site-packages/psycopg2/__init__.py:144: 
> UserWarning: The psycopg2 wheel package will be renamed from release 2.8; 
> in order to keep installing from binary please use "pip install 
> psycopg2-binary" instead. For details see: <
> http://initd.org/psycopg/docs/install.html#binary-install-from-pypi <
> http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>>. 
> > 
> >   """) 
> > 
> > BEGIN; 
> > 
> > -- 
> > 
> > -- Create model Choice 
> > 
> > -- 
> > 
> > CREATE TABLE "polls_choice" ("id" serial NOT NULL PRIMARY KEY, 
> "choice_text" varchar(200) NOT NULL, "votes" integer NOT NULL); 
> > 
> > -- 
> > 
> > -- Create model Question 
> > 
> > -- 
> > 
> > CREATE TABLE "polls_question" ("id" serial NOT NULL PRIMARY KEY, 
> "question_text" varchar(200) NOT NULL, "pub_date" timestamp with time zone 
> NOT NULL); 
> > 
> > -- 
> > 
> > -- Add field question to choice 
> > 
> > -- 
> > 
> > ALTER TABLE "polls_choice" ADD COLUMN "question_id" integer NOT 
> NULL; 
> > 
> > CREATE INDEX "polls_choice_question_id_c5b4b260" ON "polls_choice" 
> ("question_id"); 
> > 
> > ALTER TABLE "polls_choice" ADD CONSTRAINT 
> "polls_choice_question_id_c5b4b260_fk_polls_question_id" FOREIGN KEY 
> ("question_id") REFERENCES "polls_question" ("id") DEFERRABLE INITIALLY 
> DEFERRED; 

Re: PLEASE HELP! Django documentation, Writing Your First App, Part 4

2019-02-03 Thread Atsunori Kaneshige
Hi Nitin,

Thank you!
I finally understood what you said.
Now working fine. Actually it was working, but I did not understand.

Thank you!

Nori

On Sunday, February 3, 2019 at 11:08:34 AM UTC-5, Nitin Kalmaste wrote:
>
> You have to add Choices for each questions you have created in database 
> like the process is same as you used for the questions.
> On Sun, Feb 3, 2019, 8:53 PM Atsunori Kaneshige   wrote:
>
>> Hi Nitin,
>>
>> Thank you for your comment.
>>
>> I did  
>>
>> jango-admin startproject mysite
>>
>> and cd mysite, then
>>
>> python manage.py runserver
>>
>> and server is working, so I did
>>
>> opython manage.py startapp polls
>>
>> polls app was successfully created, and stopped the server because I 
>> wanted to user postgresql instead of the default SQLite3(?).
>> I did below
>>
>> pg_ctl -D /user/local/var/posgres start
>>
>> postgres successfully started running, then stopped
>>
>> *By the way, I registered polls app in settings.py (I just copied and 
>> pasted part of codes from the file below)*
>> INSTALLED_APPS = [
>> 'polls.apps.PollsConfig',
>>
>> *Also, I followed the way to add postgres as database, I looked as Django 
>> docs*
>> DATABASES = {
>> 'default': {
>> 'ENGINE': 'django.db.backends.postgresql',
>> 'NAME': 'Koitaro',
>> 'USER': '',
>> 'PASSWORD': '',
>> 'HOST': '',
>> 'PORT': '',
>> }
>> }
>>
>> *I did migration too, like migrate, makemigration etc, just copied and 
>> pasted from Django Docs*
>> *This is my models.py*
>>
>> import datetime
>> from django.db import models
>> from django.utils import timezone
>>
>> # Create your models here.
>>
>>
>> class Question(models.Model):
>> question_text = models.CharField(max_length=200)
>> pub_date = models.DateTimeField('date published')
>>
>> def __str__(self):
>> return self.question_text
>>
>> def was_published_recently(self):
>> return self.pub_date >= timezone.now() - 
>> datetime.timedelta(days=1)
>>
>>
>> class Choice(models.Model):
>> question = models.ForeignKey(Question, on_delete=models.CASCADE)
>> choice_text = models.CharField(max_length=200)
>> votes = models.IntegerField(default=0)
>>
>> def __str__(self):
>> return self.choice_text
>>
>> *mygration was successfully generated*
>> from django.db import migrations, models
>> import django.db.models.deletion
>>
>>
>> class Migration(migrations.Migration):
>>
>> initial = True
>>
>> dependencies = [
>> ]
>>
>> operations = [
>> migrations.CreateModel(
>> name='Choice',
>> fields=[
>> ('id', models.AutoField(auto_created=True, 
>> primary_key=True, serialize=False, verbose_name='ID')),
>> ('choice_text', models.CharField(max_length=200)),
>> ('votes', models.IntegerField(default=0)),
>> ],
>> ),
>> migrations.CreateModel(
>> name='Question',
>> fields=[
>> ('id', models.AutoField(auto_created=True, 
>> primary_key=True, serialize=False, verbose_name='ID')),
>> ('question_text', models.CharField(max_length=200)),
>> ('pub_date', models.DateTimeField(verbose_name='date 
>> published')),
>> ],
>> ),
>> migrations.AddField(
>> model_name='choice',
>> name='question',
>> 
>> field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, 
>> to='polls.Question'),
>> ),
>> ]
>>
>> *When I go to admin, I added 5 or 6 questions, and successfully added in 
>> database.*
>> *the database name I made is 'Koitaro'.*
>> *I registered in settings.py and I have this database named as Koitaro in 
>> my posgresql*
>>
>>
>> question has data, but choice thing doesn't seem having any data...
>>
>> I really appreciate your thoughts.
>>
>> Nori
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Sunday, February 3, 2019 at 1:56:18 AM UTC-5, Nitin Kalmaste wrote:
>>>
>>> Have you migrated database and added any question there?
>>>
>>> On Sun, Feb 3, 2019, 8:39 AM Atsunori Kaneshige >> wrote:
>>>
 Oh, one note is that I am using postgresql.
 everything else except vote function in views.py seems working.

 Sorry, any help would be really appreciated!

 Nori

 On Saturday, February 2, 2019 at 10:02:14 PM UTC-5, Atsunori Kaneshige 
 wrote:
>
> Hi Django users,
>
> I started using Django recently.
> I am following the official Django tutorial.
> I am just at Writing Your First Django App, Part4, and I have been 
> just copying and pasting all codes.
>
> But I have a problem in vote.
> I inserted print(question) and this is printed in detail.html
> also, question.id is also printed.
>
> BUT, choice part doesn't seem working.
>
> **
> def vote(request, question_id):
> question = get_object_or_404(Question, 

Re: PLEASE HELP! Django documentation, Writing Your First App, Part 4

2019-02-03 Thread Carsten Fuchs
Well, you're adding choices to q = Question.objects.get(pk=1).
But is this also the question you call the view with?

I suggest you add a few more print statements below your existing

print(question)

For example:

print(question.pk)
print(question.choice_set.all())

# Or, a bit more verbose, for example:
for c in question.choice_set.all():
print(c.pk, c)

# Is the following a valid PK among the choices printed above?
print(request.POST['choice'])

Best regards,
Carsten


Am 2019-02-03 um 16:58 schrieb Atsunori Kaneshige:
> *_Here is the codes about choice_*
> 
> 
> In [27]: q = Question.objects.get(pk=1)
> 
> 
> In [28]: q.choice_set.all()
> 
> Out[28]: 
> 
> 
> In [29]: q.choice_set.create(choice_text='Not much',votes=0)
> 
> Out[29]: 
> 
> 
> In [30]: q.choice_set.create(choice_text='The sky',votes=0)
> 
> Out[30]: 
> 
> 
> In [31]: c = q.choice_set.create(choice_text='Just hacking again',votes=0)
> 
> 
> In [32]: c.question
> 
> Out[32]: 
> 
> 
> In [33]: q.choice_set.all()
> 
> Out[33]: , ,  Not much>]>
> 
> 
> In [34]: q.choice_set.count()
> 
> Out[34]: 3
> 
> 
> 
> choice exits, or correctly working?
> 
> Nori
> 
> On Sunday, February 3, 2019 at 10:55:48 AM UTC-5, Atsunori Kaneshige wrote:
> 
> Hi Carsten,
> 
> Sorry, are you talking about Writing Your First App, Part2? The page 
> below?
> https://docs.djangoproject.com/en/2.1/intro/tutorial02/ 
> 
> 
> Yeah, when I tried this, there was something wrong.
> 
> *_I did that again. I copied and pasted my terminal below._*
> *_seems like migration was successful when I did before._*
> *_I am not sure what 'python sqlmigrate polls 001' is doing._*
> 
> 
> MacBook-Pro-3:mysite Koitaro$ python manage.py migrate
> 
> 
> /Applications/anaconda3/lib/python3.6/site-packages/psycopg2/__init__.py:144: 
> UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in 
> order to keep installing from binary please use "pip install psycopg2-binary" 
> instead. For details see: 
>  >.
> 
>   """)
> 
> Operations to perform:
> 
>   Apply all migrations: admin, auth, contenttypes, polls, sessions
> 
> Running migrations:
> 
>   No migrations to apply.
> 
> MacBook-Pro-3:mysite Koitaro$ python manage.py makemigrations polls
> 
> 
> /Applications/anaconda3/lib/python3.6/site-packages/psycopg2/__init__.py:144: 
> UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in 
> order to keep installing from binary please use "pip install psycopg2-binary" 
> instead. For details see: 
>  >.
> 
>   """)
> 
> No changes detected in app 'polls'
> 
> MacBook-Pro-3:mysite Koitaro$ python manage.py sqlmigrate polls 0001
> 
> 
> /Applications/anaconda3/lib/python3.6/site-packages/psycopg2/__init__.py:144: 
> UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in 
> order to keep installing from binary please use "pip install psycopg2-binary" 
> instead. For details see: 
>  >.
> 
>   """)
> 
> BEGIN;
> 
> --
> 
> -- Create model Choice
> 
> --
> 
> CREATE TABLE "polls_choice" ("id" serial NOT NULL PRIMARY KEY, 
> "choice_text" varchar(200) NOT NULL, "votes" integer NOT NULL);
> 
> --
> 
> -- Create model Question
> 
> --
> 
> CREATE TABLE "polls_question" ("id" serial NOT NULL PRIMARY KEY, 
> "question_text" varchar(200) NOT NULL, "pub_date" timestamp with time zone 
> NOT NULL);
> 
> --
> 
> -- Add field question to choice
> 
> --
> 
> ALTER TABLE "polls_choice" ADD COLUMN "question_id" integer NOT NULL;
> 
> CREATE INDEX "polls_choice_question_id_c5b4b260" ON "polls_choice" 
> ("question_id");
> 
> ALTER TABLE "polls_choice" ADD CONSTRAINT 
> "polls_choice_question_id_c5b4b260_fk_polls_question_id" FOREIGN KEY 
> ("question_id") REFERENCES "polls_question" ("id") DEFERRABLE INITIALLY 
> DEFERRED;
> 
> COMMIT;
> 
> MacBook-Pro-3:mysite Koitaro$ 
> 
> 
> 
> 
> *_After this, when I typed 'python manage.py shell',_*
> *_By the way, I am not doing this in virtual environment, is it fine?_*
> *_Django docs doesn't say anything about it._*
> 
> *_Here is the result of shell_*
> 
> MacBook-Pro-3:mysite Koitaro$ python manage.py shell
> 
> 
> /Applications/anaconda3/lib/python3.6/site-packages/psycopg2/__init__.py:144: 
> UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in 
> order to keep installing from binary please use "pip 

Re: Django timezone problem

2019-02-03 Thread Waqas Ali
Plz can you share the all data about this site and source code

On Mon., 4 Feb. 2019, 12:00 am Mikko Meronen  Hi,
>
> Is there any easy way in Django to catch end user's local time when end
> user access the webpage?
>
> I have read django documentation and tried to google solutions, but I get
> quite confused. Below you will find my code. In short the code should show
> a story on my webpage what happened in the past on the current day. However
> it doesn't take into account the endusers local time, and thus doesn't work
> properly.
>
>
> *Views.py*
> from django.utils import timezone
>
> t = timezone.now() *[This should somehow react to endusers local
> time]*
> dm = t.strftime('%m-%d')
> history = history.objects.filter(monthday__exact=dm)
> historystory = random.sample(list(history), 1)
> args = {'historystory':historystory}
> return render(request, "news/home.html", args)
>
> *home.html*
> [in html I have just the basic things to show the content]
>
> 
> 
> {% for x in historystory %}
>  {{ x.title }} 
>  {{ x.subtitle }} 
>  {{ x.content }} 
> {% endfor %}
> 
> 
>
>
> *Settings.py*
> LANGUAGE_CODE = 'en-us'
> TIME_ZONE = 'UTC'
> USE_I18N = True
> USE_L10N = True
> USE_TZ = True
>
> You can check my webpage (http://www.topithenewsdoggy.com/) to get better
> understanding what I'm doing. The part is under Additional info.
>
> -Mikko
>
> --
> 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/CAGD0jj%2Bh_1Pd50eE0e0zXt8P-yozqCnZeYYXTe6bj6Tt6UopxA%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAF2yDDEsdmmHSgwhfQZDdUWGmv75ktnxhAdNh%3Dmu3AkgOCam2g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django timezone problem

2019-02-03 Thread Mikko Meronen
Hi,

Is there any easy way in Django to catch end user's local time when end
user access the webpage?

I have read django documentation and tried to google solutions, but I get
quite confused. Below you will find my code. In short the code should show
a story on my webpage what happened in the past on the current day. However
it doesn't take into account the endusers local time, and thus doesn't work
properly.


*Views.py*
from django.utils import timezone

t = timezone.now() *[This should somehow react to endusers local time]*
dm = t.strftime('%m-%d')
history = history.objects.filter(monthday__exact=dm)
historystory = random.sample(list(history), 1)
args = {'historystory':historystory}
return render(request, "news/home.html", args)

*home.html*
[in html I have just the basic things to show the content]



{% for x in historystory %}
 {{ x.title }} 
 {{ x.subtitle }} 
 {{ x.content }} 
{% endfor %}




*Settings.py*
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True

You can check my webpage (http://www.topithenewsdoggy.com/) to get better
understanding what I'm doing. The part is under Additional info.

-Mikko

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


Re: PLEASE HELP! Django documentation, Writing Your First App, Part 4

2019-02-03 Thread Nitin Kalmaste
You have to add Choices for each questions you have created in database
like the process is same as you used for the questions.
On Sun, Feb 3, 2019, 8:53 PM Atsunori Kaneshige  Hi Nitin,
>
> Thank you for your comment.
>
> I did
>
> jango-admin startproject mysite
>
> and cd mysite, then
>
> python manage.py runserver
>
> and server is working, so I did
>
> opython manage.py startapp polls
>
> polls app was successfully created, and stopped the server because I
> wanted to user postgresql instead of the default SQLite3(?).
> I did below
>
> pg_ctl -D /user/local/var/posgres start
>
> postgres successfully started running, then stopped
>
> *By the way, I registered polls app in settings.py (I just copied and
> pasted part of codes from the file below)*
> INSTALLED_APPS = [
> 'polls.apps.PollsConfig',
>
> *Also, I followed the way to add postgres as database, I looked as Django
> docs*
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.postgresql',
> 'NAME': 'Koitaro',
> 'USER': '',
> 'PASSWORD': '',
> 'HOST': '',
> 'PORT': '',
> }
> }
>
> *I did migration too, like migrate, makemigration etc, just copied and
> pasted from Django Docs*
> *This is my models.py*
>
> import datetime
> from django.db import models
> from django.utils import timezone
>
> # Create your models here.
>
>
> class Question(models.Model):
> question_text = models.CharField(max_length=200)
> pub_date = models.DateTimeField('date published')
>
> def __str__(self):
> return self.question_text
>
> def was_published_recently(self):
> return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
>
>
> class Choice(models.Model):
> question = models.ForeignKey(Question, on_delete=models.CASCADE)
> choice_text = models.CharField(max_length=200)
> votes = models.IntegerField(default=0)
>
> def __str__(self):
> return self.choice_text
>
> *mygration was successfully generated*
> from django.db import migrations, models
> import django.db.models.deletion
>
>
> class Migration(migrations.Migration):
>
> initial = True
>
> dependencies = [
> ]
>
> operations = [
> migrations.CreateModel(
> name='Choice',
> fields=[
> ('id', models.AutoField(auto_created=True,
> primary_key=True, serialize=False, verbose_name='ID')),
> ('choice_text', models.CharField(max_length=200)),
> ('votes', models.IntegerField(default=0)),
> ],
> ),
> migrations.CreateModel(
> name='Question',
> fields=[
> ('id', models.AutoField(auto_created=True,
> primary_key=True, serialize=False, verbose_name='ID')),
> ('question_text', models.CharField(max_length=200)),
> ('pub_date', models.DateTimeField(verbose_name='date
> published')),
> ],
> ),
> migrations.AddField(
> model_name='choice',
> name='question',
>
> field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
> to='polls.Question'),
> ),
> ]
>
> *When I go to admin, I added 5 or 6 questions, and successfully added in
> database.*
> *the database name I made is 'Koitaro'.*
> *I registered in settings.py and I have this database named as Koitaro in
> my posgresql*
>
>
> question has data, but choice thing doesn't seem having any data...
>
> I really appreciate your thoughts.
>
> Nori
>
>
>
>
>
>
>
>
>
>
> On Sunday, February 3, 2019 at 1:56:18 AM UTC-5, Nitin Kalmaste wrote:
>>
>> Have you migrated database and added any question there?
>>
>> On Sun, Feb 3, 2019, 8:39 AM Atsunori Kaneshige >
>>> Oh, one note is that I am using postgresql.
>>> everything else except vote function in views.py seems working.
>>>
>>> Sorry, any help would be really appreciated!
>>>
>>> Nori
>>>
>>> On Saturday, February 2, 2019 at 10:02:14 PM UTC-5, Atsunori Kaneshige
>>> wrote:

 Hi Django users,

 I started using Django recently.
 I am following the official Django tutorial.
 I am just at Writing Your First Django App, Part4, and I have been just
 copying and pasting all codes.

 But I have a problem in vote.
 I inserted print(question) and this is printed in detail.html
 also, question.id is also printed.

 BUT, choice part doesn't seem working.

 **
 def vote(request, question_id):
 question = get_object_or_404(Question, pk=question_id)
 print(question)
 try:
 selected_choice =
 question.choice_set.get(pk=request.POST['choice'])
 except (KeyError, Choice.DoesNotExist) as e:
 # Redisplay the question voting form.
 print(e)
 return render(request, 'polls/detail.html', {
 'question': question,
 'error_message': "You didn't select a choice.",
 })
 

Re: Time tracker sytem

2019-02-03 Thread Joakim Hove
A space sneaked in in the github address:

https://github.com/joakim-hove/ptime

Den søn. 3. feb. 2019, 15:50 skrev Joakim Hove  I have created such a system - it is extremely basic, but it covers my
> needs. Feel free to take a look:
>
> https://github.com/joakim-hove/ptime
>
> Den søn. 3. feb. 2019, 15:26 skrev Rupam Hazra 
>> I want to create a time tracker system to track the employee work time
>> and data save to mysql database.please tell me how to start.
>>
>> --
>> 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/6e4c36c8-10ea-403d-9afa-8c9b40c1f1e6%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/CALKD1M-2ZtbJiT3d7mb3gVgAocZTt6jOavZxNZrkumQVjpZAPw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: PLEASE HELP! Django documentation, Writing Your First App, Part 4

2019-02-03 Thread Atsunori Kaneshige
*Here is the codes about choice*


In [27]: q = Question.objects.get(pk=1)


In [28]: q.choice_set.all()

Out[28]: 


In [29]: q.choice_set.create(choice_text='Not much',votes=0)

Out[29]: 


In [30]: q.choice_set.create(choice_text='The sky',votes=0)

Out[30]: 


In [31]: c = q.choice_set.create(choice_text='Just hacking again',votes=0)


In [32]: c.question

Out[32]: 


In [33]: q.choice_set.all()

Out[33]: , , 
]>


In [34]: q.choice_set.count()

Out[34]: 3


choice exits, or correctly working?

Nori

On Sunday, February 3, 2019 at 10:55:48 AM UTC-5, Atsunori Kaneshige wrote:
>
> Hi Carsten,
>
> Sorry, are you talking about Writing Your First App, Part2? The page below?
> https://docs.djangoproject.com/en/2.1/intro/tutorial02/
>
> Yeah, when I tried this, there was something wrong.
>
> *I did that again. I copied and pasted my terminal below.*
> *seems like migration was successful when I did before.*
> *I am not sure what 'python sqlmigrate polls 001' is doing.*
>
>
> MacBook-Pro-3:mysite Koitaro$ python manage.py migrate
>
> /Applications/anaconda3/lib/python3.6/site-packages/psycopg2/__init__.py:144: 
> UserWarning: The psycopg2 wheel package will be renamed from release 2.8; 
> in order to keep installing from binary please use "pip install 
> psycopg2-binary" instead. For details see: <
> http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
>
>   """)
>
> Operations to perform:
>
>   Apply all migrations: admin, auth, contenttypes, polls, sessions
>
> Running migrations:
>
>   No migrations to apply.
>
> MacBook-Pro-3:mysite Koitaro$ python manage.py makemigrations polls
>
> /Applications/anaconda3/lib/python3.6/site-packages/psycopg2/__init__.py:144: 
> UserWarning: The psycopg2 wheel package will be renamed from release 2.8; 
> in order to keep installing from binary please use "pip install 
> psycopg2-binary" instead. For details see: <
> http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
>
>   """)
>
> No changes detected in app 'polls'
>
> MacBook-Pro-3:mysite Koitaro$ python manage.py sqlmigrate polls 0001
>
> /Applications/anaconda3/lib/python3.6/site-packages/psycopg2/__init__.py:144: 
> UserWarning: The psycopg2 wheel package will be renamed from release 2.8; 
> in order to keep installing from binary please use "pip install 
> psycopg2-binary" instead. For details see: <
> http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
>
>   """)
>
> BEGIN;
>
> --
>
> -- Create model Choice
>
> --
>
> CREATE TABLE "polls_choice" ("id" serial NOT NULL PRIMARY KEY, 
> "choice_text" varchar(200) NOT NULL, "votes" integer NOT NULL);
>
> --
>
> -- Create model Question
>
> --
>
> CREATE TABLE "polls_question" ("id" serial NOT NULL PRIMARY KEY, 
> "question_text" varchar(200) NOT NULL, "pub_date" timestamp with time zone 
> NOT NULL);
>
> --
>
> -- Add field question to choice
>
> --
>
> ALTER TABLE "polls_choice" ADD COLUMN "question_id" integer NOT NULL;
>
> CREATE INDEX "polls_choice_question_id_c5b4b260" ON "polls_choice" 
> ("question_id");
>
> ALTER TABLE "polls_choice" ADD CONSTRAINT 
> "polls_choice_question_id_c5b4b260_fk_polls_question_id" FOREIGN KEY 
> ("question_id") REFERENCES "polls_question" ("id") DEFERRABLE INITIALLY 
> DEFERRED;
>
> COMMIT;
>
> MacBook-Pro-3:mysite Koitaro$ 
>
>
>
> *After this, when I typed 'python manage.py shell',*
> *By the way, I am not doing this in virtual environment, is it fine?*
> *Django docs doesn't say anything about it.*
>
> *Here is the result of shell*
>
> MacBook-Pro-3:mysite Koitaro$ python manage.py shell
>
> /Applications/anaconda3/lib/python3.6/site-packages/psycopg2/__init__.py:144: 
> UserWarning: The psycopg2 wheel package will be renamed from release 2.8; 
> in order to keep installing from binary please use "pip install 
> psycopg2-binary" instead. For details see: <
> http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
>
>   """)
>
> Python 3.6.5 |Anaconda, Inc.| (default, Apr 26 2018, 08:42:37) 
>
> Type 'copyright', 'credits' or 'license' for more information
>
> IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help.
>
>
> In [1]: from polls.models import Choice, Question
>
>
> In [2]: Question.objects.all()
>
> Out[2]: , , 
> , ]>
>
>
> In [3]: from django.utils import timezone
>
>
> In [4]: q = Question(question_text='What's up?,pub_data=timezone.now())
>
>   File "", line 1
>
> q = Question(question_text='What's up?,pub_data=timezone.now())
>
>  ^
>
> SyntaxError: invalid syntax
>
>
>
> In [5]: q = Question(question_text="What's up?",pub_data=timezone.now())
>
> ---
>
> TypeError Traceback (most recent call 
> last)
>
>  in ()
>
> > 1 q = Question(question_text="What's up?",pub_data=timezone.now())
>
>
>
> /Applications/anaconda3/lib/python3.6/site-packages/django/db/models/base.py 
> in __init__(self, *args, 

Re: Where is the data set of the Django documents demo models

2019-02-03 Thread Jason
I'm not sure what you mean?  if you're referring to the way querysets and 
the ORM operate, there's a thorough section in the docs.  but if you're 
asking how to model data and use a db, that's out of the scope of django as 
a whole.

-- 
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/dcd779b4-6ad9-4b46-8cd9-ea4eef3931e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: PLEASE HELP! Django documentation, Writing Your First App, Part 4

2019-02-03 Thread Atsunori Kaneshige
Hi Carsten,

Sorry, are you talking about Writing Your First App, Part2? The page below?
https://docs.djangoproject.com/en/2.1/intro/tutorial02/

Yeah, when I tried this, there was something wrong.

*I did that again. I copied and pasted my terminal below.*
*seems like migration was successful when I did before.*
*I am not sure what 'python sqlmigrate polls 001' is doing.*


MacBook-Pro-3:mysite Koitaro$ python manage.py migrate

/Applications/anaconda3/lib/python3.6/site-packages/psycopg2/__init__.py:144: 
UserWarning: The psycopg2 wheel package will be renamed from release 2.8; 
in order to keep installing from binary please use "pip install 
psycopg2-binary" instead. For details see: 
.

  """)

Operations to perform:

  Apply all migrations: admin, auth, contenttypes, polls, sessions

Running migrations:

  No migrations to apply.

MacBook-Pro-3:mysite Koitaro$ python manage.py makemigrations polls

/Applications/anaconda3/lib/python3.6/site-packages/psycopg2/__init__.py:144: 
UserWarning: The psycopg2 wheel package will be renamed from release 2.8; 
in order to keep installing from binary please use "pip install 
psycopg2-binary" instead. For details see: 
.

  """)

No changes detected in app 'polls'

MacBook-Pro-3:mysite Koitaro$ python manage.py sqlmigrate polls 0001

/Applications/anaconda3/lib/python3.6/site-packages/psycopg2/__init__.py:144: 
UserWarning: The psycopg2 wheel package will be renamed from release 2.8; 
in order to keep installing from binary please use "pip install 
psycopg2-binary" instead. For details see: 
.

  """)

BEGIN;

--

-- Create model Choice

--

CREATE TABLE "polls_choice" ("id" serial NOT NULL PRIMARY KEY, 
"choice_text" varchar(200) NOT NULL, "votes" integer NOT NULL);

--

-- Create model Question

--

CREATE TABLE "polls_question" ("id" serial NOT NULL PRIMARY KEY, 
"question_text" varchar(200) NOT NULL, "pub_date" timestamp with time zone 
NOT NULL);

--

-- Add field question to choice

--

ALTER TABLE "polls_choice" ADD COLUMN "question_id" integer NOT NULL;

CREATE INDEX "polls_choice_question_id_c5b4b260" ON "polls_choice" 
("question_id");

ALTER TABLE "polls_choice" ADD CONSTRAINT 
"polls_choice_question_id_c5b4b260_fk_polls_question_id" FOREIGN KEY 
("question_id") REFERENCES "polls_question" ("id") DEFERRABLE INITIALLY 
DEFERRED;

COMMIT;

MacBook-Pro-3:mysite Koitaro$ 



*After this, when I typed 'python manage.py shell',*
*By the way, I am not doing this in virtual environment, is it fine?*
*Django docs doesn't say anything about it.*

*Here is the result of shell*

MacBook-Pro-3:mysite Koitaro$ python manage.py shell

/Applications/anaconda3/lib/python3.6/site-packages/psycopg2/__init__.py:144: 
UserWarning: The psycopg2 wheel package will be renamed from release 2.8; 
in order to keep installing from binary please use "pip install 
psycopg2-binary" instead. For details see: 
.

  """)

Python 3.6.5 |Anaconda, Inc.| (default, Apr 26 2018, 08:42:37) 

Type 'copyright', 'credits' or 'license' for more information

IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help.


In [1]: from polls.models import Choice, Question


In [2]: Question.objects.all()

Out[2]: , , 
, ]>


In [3]: from django.utils import timezone


In [4]: q = Question(question_text='What's up?,pub_data=timezone.now())

  File "", line 1

q = Question(question_text='What's up?,pub_data=timezone.now())

 ^

SyntaxError: invalid syntax



In [5]: q = Question(question_text="What's up?",pub_data=timezone.now())

---

TypeError Traceback (most recent call last)

 in ()

> 1 q = Question(question_text="What's up?",pub_data=timezone.now())


/Applications/anaconda3/lib/python3.6/site-packages/django/db/models/base.py 
in __init__(self, *args, **kwargs)

483 pass

484 for kwarg in kwargs:

--> 485 raise TypeError("'%s' is an invalid keyword 
argument for this function" % kwarg)

486 super().__init__()

487 post_init.send(sender=cls, instance=self)


TypeError: 'pub_data' is an invalid keyword argument for this function


In [6]: q = Question(question_text="What's up?",pub_date=timezone.now())


In [7]: q.save()


In [8]: q.id

Out[8]: 5


In [9]: q.question_text

Out[9]: "What's up?"


In [10]: q.pub_date

Out[10]: datetime.datetime(2019, 2, 3, 15, 43, 10, 354354, tzinfo=)


In [11]: q.question_text = "What's up?"


In [12]: q.save()


In [13]: Question.objects.all()

Out[13]: , , 
, , ]>


In [14]: from polls.models import Choice, Question


In [15]: Question.objects.all()

Out[15]: , 

Re: Where is the data set of the Django documents demo models

2019-02-03 Thread Fogmoon
Sorry for I just list the section but did not emphasize the relative topic: 
DB relative operation.


在 2019年2月3日星期日 UTC+8下午9:50:18,Jason写道:
>
> I feel I have to disagree, and the reason is the point of the tutorial is 
> to show you the basics with the various parts of django, and you're 
> creating a data set as you go along.
>
>
> https://docs.djangoproject.com/en/2.1/intro/tutorial02/#playing-with-the-api  
> shows you how to use the ORM to create a new question
>
> https://docs.djangoproject.com/en/2.1/intro/tutorial02/#explore-the-free-admin-functionality
>  shows 
> you how to use the admin to create and edit questions
>
> https://docs.djangoproject.com/en/2.1/intro/tutorial03/#writing-your-first-django-app-part-3
>  shows 
> you how to make templates to list questions and show a specific question
>
> That's all from data you're creating in the second step.
>
> What do you feel you would get from having a data set provided as an 
> example over the process above?
>

-- 
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/0ad96877-7bfc-45c8-9750-bd872401748b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Webinterface for python script

2019-02-03 Thread Asad
Hi All ,

  I have created certain python scripts to analyze log files and
suggest solution based on logic which I invoke on the command line . I need
some information on how to execute these through browser . I am using :

python test.py file1 file2

How do I use the browser to upload the files file1 and file2 and it process
the files .

Please advice ,

Thanks,

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


Re: PLEASE HELP! Django documentation, Writing Your First App, Part 4

2019-02-03 Thread Atsunori Kaneshige


On Sunday, February 3, 2019 at 10:22:56 AM UTC-5, Atsunori Kaneshige wrote:
>
> Hi Nitin,
>
> Thank you for your comment.
>
> I did  
>
> jango-admin startproject mysite
>
> and cd mysite, then
>
> python manage.py runserver
>
> and server is working, so I did
>
> opython manage.py startapp polls
>
> polls app was successfully created, and stopped the server because I 
> wanted to user postgresql instead of the default SQLite3(?).
> I did below
>
> pg_ctl -D /user/local/var/posgres start
>
> postgres successfully started running, then stopped
>
> *By the way, I registered polls app in settings.py (I just copied and 
> pasted part of codes from the file below)*
> INSTALLED_APPS = [
> 'polls.apps.PollsConfig',
>
> *Also, I followed the way to add postgres as database, I looked as Django 
> docs*
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.postgresql',
> 'NAME': 'Koitaro',
> 'USER': '',
> 'PASSWORD': '',
> 'HOST': '',
> 'PORT': '',
> }
> }
>
> *I did migration too, like migrate, makemigration etc, just copied and 
> pasted from Django Docs*
> *This is my models.py*
>
> import datetime
> from django.db import models
> from django.utils import timezone
>
> # Create your models here.
>
>
> class Question(models.Model):
> question_text = models.CharField(max_length=200)
> pub_date = models.DateTimeField('date published')
>
> def __str__(self):
> return self.question_text
>
> def was_published_recently(self):
> return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
>
>
> class Choice(models.Model):
> question = models.ForeignKey(Question, on_delete=models.CASCADE)
> choice_text = models.CharField(max_length=200)
> votes = models.IntegerField(default=0)
>
> def __str__(self):
> return self.choice_text
>
> *mygration was successfully generated*
> from django.db import migrations, models
> import django.db.models.deletion
>
>
> class Migration(migrations.Migration):
>
> initial = True
>
> dependencies = [
> ]
>
> operations = [
> migrations.CreateModel(
> name='Choice',
> fields=[
> ('id', models.AutoField(auto_created=True, 
> primary_key=True, serialize=False, verbose_name='ID')),
> ('choice_text', models.CharField(max_length=200)),
> ('votes', models.IntegerField(default=0)),
> ],
> ),
> migrations.CreateModel(
> name='Question',
> fields=[
> ('id', models.AutoField(auto_created=True, 
> primary_key=True, serialize=False, verbose_name='ID')),
> ('question_text', models.CharField(max_length=200)),
> ('pub_date', models.DateTimeField(verbose_name='date 
> published')),
> ],
> ),
> migrations.AddField(
> model_name='choice',
> name='question',
> 
> field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, 
> to='polls.Question'),
> ),
> ]
>
> *When I go to admin, I added 5 or 6 questions, and successfully added in 
> database.*
> *the database name I made is 'Koitaro'.*
> *I registered in settings.py and I have this database named as Koitaro in 
> my posgresql*
>
>
> question has data, but choice thing doesn't seem having any data...
>
> I really appreciate your thoughts.
>
> Nori
>
>
>
>
>
>
>
>
>
>
> On Sunday, February 3, 2019 at 1:56:18 AM UTC-5, Nitin Kalmaste wrote:
>>
>> Have you migrated database and added any question there?
>>
>> On Sun, Feb 3, 2019, 8:39 AM Atsunori Kaneshige >
>>> Oh, one note is that I am using postgresql.
>>> everything else except vote function in views.py seems working.
>>>
>>> Sorry, any help would be really appreciated!
>>>
>>> Nori
>>>
>>> On Saturday, February 2, 2019 at 10:02:14 PM UTC-5, Atsunori Kaneshige 
>>> wrote:

 Hi Django users,

 I started using Django recently.
 I am following the official Django tutorial.
 I am just at Writing Your First Django App, Part4, and I have been just 
 copying and pasting all codes.

 But I have a problem in vote.
 I inserted print(question) and this is printed in detail.html
 also, question.id is also printed.

 BUT, choice part doesn't seem working.

 **
 def vote(request, question_id):
 question = get_object_or_404(Question, pk=question_id)
 print(question)
 try:
 selected_choice = 
 question.choice_set.get(pk=request.POST['choice'])
 except (KeyError, Choice.DoesNotExist) as e:
 # Redisplay the question voting form.
 print(e)
 return render(request, 'polls/detail.html', {
 'question': question,
 'error_message': "You didn't select a choice.",
 })
 else:
 selected_choice.votes += 1
 

Re: PLEASE HELP! Django documentation, Writing Your First App, Part 4

2019-02-03 Thread Atsunori Kaneshige
Hi Nitin,

Thank you for your comment.

I did  

jango-admin startproject mysite

and cd mysite, then

python manage.py runserver

and server is working, so I did

opython manage.py startapp polls

polls app was successfully created, and stopped the server because I wanted 
to user postgresql instead of the default SQLite3(?).
I did below

pg_ctl -D /user/local/var/posgres start

postgres successfully started running, then stopped

*By the way, I registered polls app in settings.py (I just copied and 
pasted part of codes from the file below)*
INSTALLED_APPS = [
'polls.apps.PollsConfig',

*Also, I followed the way to add postgres as database, I looked as Django 
docs*
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'Koitaro',
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': '',
}
}

*I did migration too, like migrate, makemigration etc, just copied and 
pasted from Django Docs*
*This is my models.py*

import datetime
from django.db import models
from django.utils import timezone

# Create your models here.


class Question(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')

def __str__(self):
return self.question_text

def was_published_recently(self):
return self.pub_date >= timezone.now() - datetime.timedelta(days=1)


class Choice(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)

def __str__(self):
return self.choice_text

*mygration was successfully generated*
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Choice',
fields=[
('id', models.AutoField(auto_created=True, 
primary_key=True, serialize=False, verbose_name='ID')),
('choice_text', models.CharField(max_length=200)),
('votes', models.IntegerField(default=0)),
],
),
migrations.CreateModel(
name='Question',
fields=[
('id', models.AutoField(auto_created=True, 
primary_key=True, serialize=False, verbose_name='ID')),
('question_text', models.CharField(max_length=200)),
('pub_date', models.DateTimeField(verbose_name='date 
published')),
],
),
migrations.AddField(
model_name='choice',
name='question',

field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, 
to='polls.Question'),
),
]

*When I go to admin, I added 5 or 6 questions, and successfully added in 
database.*
*the database name I made is 'Koitaro'.*
*I registered in settings.py and I have this database named as Koitaro in 
my posgresql*


question has data, but choice thing doesn't seem having any data...

I really appreciate your thoughts.

Nori










On Sunday, February 3, 2019 at 1:56:18 AM UTC-5, Nitin Kalmaste wrote:
>
> Have you migrated database and added any question there?
>
> On Sun, Feb 3, 2019, 8:39 AM Atsunori Kaneshige   wrote:
>
>> Oh, one note is that I am using postgresql.
>> everything else except vote function in views.py seems working.
>>
>> Sorry, any help would be really appreciated!
>>
>> Nori
>>
>> On Saturday, February 2, 2019 at 10:02:14 PM UTC-5, Atsunori Kaneshige 
>> wrote:
>>>
>>> Hi Django users,
>>>
>>> I started using Django recently.
>>> I am following the official Django tutorial.
>>> I am just at Writing Your First Django App, Part4, and I have been just 
>>> copying and pasting all codes.
>>>
>>> But I have a problem in vote.
>>> I inserted print(question) and this is printed in detail.html
>>> also, question.id is also printed.
>>>
>>> BUT, choice part doesn't seem working.
>>>
>>> **
>>> def vote(request, question_id):
>>> question = get_object_or_404(Question, pk=question_id)
>>> print(question)
>>> try:
>>> selected_choice = 
>>> question.choice_set.get(pk=request.POST['choice'])
>>> except (KeyError, Choice.DoesNotExist) as e:
>>> # Redisplay the question voting form.
>>> print(e)
>>> return render(request, 'polls/detail.html', {
>>> 'question': question,
>>> 'error_message': "You didn't select a choice.",
>>> })
>>> else:
>>> selected_choice.votes += 1
>>> selected_choice.save()
>>> # Always return an HttpResponseRedirect after successfully 
>>> dealing
>>> # with POST data. This prevents data from being posted twice if a
>>> # user hits the Back button.
>>> return HttpResponseRedirect(reverse('polls:results', args=(
>>> question.id,)))
>>>
>>> **
>>> {{ 

Re: Time tracker sytem

2019-02-03 Thread Joakim Hove
I have created such a system - it is extremely basic, but it covers my
needs. Feel free to take a look:

https://github.com/joakim-hove/ptime

Den søn. 3. feb. 2019, 15:26 skrev Rupam Hazra  I want to create a time tracker system to track the employee work time and
> data save to mysql database.please tell me how to start.
>
> --
> 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/6e4c36c8-10ea-403d-9afa-8c9b40c1f1e6%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/CALKD1M8PxoOW0BmL851RvLnL12BEuF8W2movQknf2KCi8La5Sg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Where is the data set of the Django documents demo models

2019-02-03 Thread Joel Mathew
Yes, it is not supposed to be a copy paste demo. You're supposed to work
along the tutorial, use the shell, and not throw in a bunch of files and
opening the browser to see if it works

On Sun, 3 Feb, 2019, 7:20 PM Jason  I feel I have to disagree, and the reason is the point of the tutorial is
> to show you the basics with the various parts of django, and you're
> creating a data set as you go along.
>
>
> https://docs.djangoproject.com/en/2.1/intro/tutorial02/#playing-with-the-api
> shows you how to use the ORM to create a new question
>
> https://docs.djangoproject.com/en/2.1/intro/tutorial02/#explore-the-free-admin-functionality
>  shows
> you how to use the admin to create and edit questions
>
> https://docs.djangoproject.com/en/2.1/intro/tutorial03/#writing-your-first-django-app-part-3
>  shows
> you how to make templates to list questions and show a specific question
>
> That's all from data you're creating in the second step.
>
> What do you feel you would get from having a data set provided as an
> example over the process above?
>
> --
> 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/b749246d-1ce0-40ba-9b8f-31ce222c8ef7%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/CAA%3Diw_8gr%2Brom14SojLJT4_cUDXg3%3DfdE3QNy%3DPBYZNfh0heyQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Time tracker sytem

2019-02-03 Thread Joel Mathew
Go through the django tutorials, and kindly start a thread when you have a
problem.

On Sun, 3 Feb, 2019, 7:56 PM Rupam Hazra  I want to create a time tracker system to track the employee work time and
> data save to mysql database.please tell me how to start.
>
> --
> 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/6e4c36c8-10ea-403d-9afa-8c9b40c1f1e6%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/CAA%3Diw_9X7ypVtXCAQXLjrT0iGwXnk%3D4zb6-p%2Bj1t5R6LwR%3DGTA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: filtering and searching help - regarding

2019-02-03 Thread Shashank Singh
Can you give an example.

On Sun, 3 Feb, 2019, 7:49 PM Mohan Goud  here the problem is, i can't give sectionname, dept and year directly. It
> has to do it for all sections in the database. can u help me how to do this.
>
>
>
> On Sun, Feb 3, 2019 at 7:41 PM Shashank Singh <
> shashank.singh10...@gmail.com> wrote:
>
>> Student.objects.filter(section__iexact="a",
>> department=1,year=2019).order_by("name")
>>
>> On Sun, 3 Feb, 2019, 7:32 PM Mohan Goud >
>>> django
>>>
>>>
>>>
>>> On Sun, Feb 3, 2019 at 7:30 PM Birol Demirtaş 
>>> wrote:
>>>
 Django ? Or ?

 3 Şub 2019 Paz, saat 16:59 tarihinde Mohan Goud <
 kathi.mohang...@gmail.com> şunu yazdı:

>
>
> students list is in database. I have to search based on section,
> department and year and sort them in ascending order. can any one help me
> on this through any video links or any other.
>
> --
> 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/CAB29Dk%3D9sLASp9Gr4q73qzh8ozw-ecYukUZZ62WkC8XKXtMDZA%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 https://groups.google.com/group/django-users.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/CAN908so%3DSjsqv%2B%2BhA5Kw3W7tctGX%3D5WbtC4t9ZuwnsnZg92Xww%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 https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAB29DkneL1r4QeznCQG-4%2Bg7cSEnU5kcpsE_mowj0Y0pzN3Sgg%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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAD-d1sYc53o2itdGW_Ohrv2Rb2HXKutLHtrFkSGrbBrJCEQ%2B5w%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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAB29DknduCzh%2BTLq2yHaPwHtj3deYKaKwYstrCBZvx6Eu12p%3Dg%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 

Time tracker sytem

2019-02-03 Thread Rupam Hazra
I want to create a time tracker system to track the employee work time and 
data save to mysql database.please tell me how to start.

-- 
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/6e4c36c8-10ea-403d-9afa-8c9b40c1f1e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: filtering and searching help - regarding

2019-02-03 Thread Mohan Goud
yes render response but i have to store the sorted version in some other
model by creating it dynamically.

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


Re: filtering and searching help - regarding

2019-02-03 Thread Mohan Goud
here the problem is, i can't give sectionname, dept and year directly. It
has to do it for all sections in the database. can u help me how to do this.



On Sun, Feb 3, 2019 at 7:41 PM Shashank Singh 
wrote:

> Student.objects.filter(section__iexact="a",
> department=1,year=2019).order_by("name")
>
> On Sun, 3 Feb, 2019, 7:32 PM Mohan Goud 
>> django
>>
>>
>>
>> On Sun, Feb 3, 2019 at 7:30 PM Birol Demirtaş 
>> wrote:
>>
>>> Django ? Or ?
>>>
>>> 3 Şub 2019 Paz, saat 16:59 tarihinde Mohan Goud <
>>> kathi.mohang...@gmail.com> şunu yazdı:
>>>


 students list is in database. I have to search based on section,
 department and year and sort them in ascending order. can any one help me
 on this through any video links or any other.

 --
 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/CAB29Dk%3D9sLASp9Gr4q73qzh8ozw-ecYukUZZ62WkC8XKXtMDZA%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 https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAN908so%3DSjsqv%2B%2BhA5Kw3W7tctGX%3D5WbtC4t9ZuwnsnZg92Xww%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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAB29DkneL1r4QeznCQG-4%2Bg7cSEnU5kcpsE_mowj0Y0pzN3Sgg%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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAD-d1sYc53o2itdGW_Ohrv2Rb2HXKutLHtrFkSGrbBrJCEQ%2B5w%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB29DknduCzh%2BTLq2yHaPwHtj3deYKaKwYstrCBZvx6Eu12p%3Dg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: filtering and searching help - regarding

2019-02-03 Thread Shashank Singh
Student.objects.filter(section__iexact="a",
department=1,year=2019).order_by("name")

On Sun, 3 Feb, 2019, 7:32 PM Mohan Goud  django
>
>
>
> On Sun, Feb 3, 2019 at 7:30 PM Birol Demirtaş 
> wrote:
>
>> Django ? Or ?
>>
>> 3 Şub 2019 Paz, saat 16:59 tarihinde Mohan Goud <
>> kathi.mohang...@gmail.com> şunu yazdı:
>>
>>>
>>>
>>> students list is in database. I have to search based on section,
>>> department and year and sort them in ascending order. can any one help me
>>> on this through any video links or any other.
>>>
>>> --
>>> 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/CAB29Dk%3D9sLASp9Gr4q73qzh8ozw-ecYukUZZ62WkC8XKXtMDZA%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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAN908so%3DSjsqv%2B%2BhA5Kw3W7tctGX%3D5WbtC4t9ZuwnsnZg92Xww%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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAB29DkneL1r4QeznCQG-4%2Bg7cSEnU5kcpsE_mowj0Y0pzN3Sgg%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAD-d1sYc53o2itdGW_Ohrv2Rb2HXKutLHtrFkSGrbBrJCEQ%2B5w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Passing pk arguments from a URL into another view

2019-02-03 Thread poOya mOsaddegh
Hi
You may use include in urls.py

urlpatterns = [
path('', views.club_home, name='club_home'),
path('/', include(club_home_urls, namespace='club_home')),
]



On Sat, Feb 2, 2019 at 8:20 PM GavinB841  wrote:

> *Hi all,*
>
> *I am having issues using arguments from a URL in another view, I have
> reached out on stackover flow with no success, i believe i am wording this
> question poorly.*
>
> *To quickly explain *
>
>- *I have a main site which shows a list of sports clubs. When the
>user selects on one it renders that specific club home page using the PK
>passed in the template.*
>- *Once I get to this home page
>e.g. http://127.0.0.1:8000/club_home/2/
>  .  I have many sub-pages which a user
>can select but I have no idea how I can use that same PK to filter data in
>the other pages to only show details based on that club.*
>- *I would also like to include that PK in the rest of the URLs.
>e.g. http://127.0.0.1:8000/club_home/2/teams/
>*
>
>
> *Code:*
>
> *index.html:*
>
> Our Clubs
> {% for club in all_clubs %}
> 
> {{ club.club_name }}
> 
>   {% endfor %}
>
>
> *urls.py*
>
> I understand I must include the / before teams in the URL but
> I am unsure how to pass in that argument
>
> urlpatterns = [
> path('', views.club_home, name='club_home'),
> path('/', views.club_home, name='club_home_with_pk'),
> path('teams/', views.TeamInfo.as_view(), name='teams'),
> ]
>
>
>
>
>
> *views.py *
>
>
>
> def club_home(request, pk=None):
> if pk:
> club = ClubInfo.objects.filter(pk=pk)
> club_posts = ClubPosts.objects.filter(club_id=club[0])
> elif request.user.is_authenticated:
> club = ClubInfo.objects.filter(user=request.user)
> club_posts = ClubPosts.objects.filter(club_id=club[0])
> # photo = model.club_logo.ImageField(storage=profile_pics)
> args = {'club': club,
> 'club_posts': club_posts
> }
> return render(request, 'club_home_page.html', args)
>
>
>
> class TeamInfo(APIView):
> renderer_classes = [TemplateHTMLRenderer]
> template_name = 'teams.html'
>
> def get(self, request):
> serializer = TeamSerializer()
> user = ClubInfo.objects.filter(user=request.user).first()
> teams = Team.objects.filter(club_id=user.pk)
> return Response({'serializer': serializer,
>  'teams': teams,
>  })
>
>
>
> *club_main_page.html*
>
>
> navbar on club home page to get to other pages, I know I need to include 
>  into the **URL and** I need to pass this argument into the href of this 
> URL but as need to figure out the view before adding this 
>
>
>
> Team
>
>
>
> *Any idea what I need to add into the view to allow for this. I would really 
> appreciate any help as I've been stuck on this for weeks now. *
>
>
> *Thanks *
>
>
> *Gavin*
>
>
>
> *Séanadh Ríomhphoist/Email DisclaimerTá an ríomhphost seo agus aon chomhad
> a sheoltar leis faoi rún agus is lena úsáid ag an seolaí agus sin amháin
> é. Is féidir tuilleadh a léamh anseo.
> 
> This e-mail and any
> files transmitted with it are confidential and are intended solely for use
> by the addressee. Read more here.
>  *
>
> --
> 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/3465a2fc-347a-4096-b037-83be9b57d8a2%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/CANuyGV1Dr6NUtk%3DNm3Bh9Ev%2Bvov%2B35_i0Q%2BfL6-2xP%3D0-DsuAg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: PLEASE HELP! Django documentation, Writing Your First App, Part 4

2019-02-03 Thread Malick Cisse
Hi, copy and paste wouldn't actually make you understand Django. Try to 
write the code yourself and you see how quickly your understanding grow. 

On Saturday, February 2, 2019 at 10:02:14 PM UTC-5, Atsunori Kaneshige 
wrote:
>
> Hi Django users,
>
> I started using Django recently.
> I am following the official Django tutorial.
> I am just at Writing Your First Django App, Part4, and I have been just 
> copying and pasting all codes.
>
> But I have a problem in vote.
> I inserted print(question) and this is printed in detail.html
> also, question.id is also printed.
>
> BUT, choice part doesn't seem working.
>
> **
> def vote(request, question_id):
> question = get_object_or_404(Question, pk=question_id)
> print(question)
> try:
> selected_choice = 
> question.choice_set.get(pk=request.POST['choice'])
> except (KeyError, Choice.DoesNotExist) as e:
> # Redisplay the question voting form.
> print(e)
> return render(request, 'polls/detail.html', {
> 'question': question,
> 'error_message': "You didn't select a choice.",
> })
> else:
> selected_choice.votes += 1
> selected_choice.save()
> # Always return an HttpResponseRedirect after successfully dealing
> # with POST data. This prevents data from being posted twice if a
> # user hits the Back button.
> return HttpResponseRedirect(reverse('polls:results', args=(
> question.id,)))
>
> **
> {{ question.question_text }}
>
> {% if error_message %}{{ error_message }}{% endif 
> %}
>
> 
> {% csrf_token %}
> {% for choice in question.choice_set.all %}
>  value="{{ choice.id }}">
> {{ choice.choice_text 
> }}
> {% endfor %}
> 
> 
>
> 
> {{ question }}
> #printed 
>  
> {{ question.id }}
> #printed
> 
> *{{ question.choice_set.all }}*
> *# #what is this? empty? why?*
> 
> {{ question.question_text }}
> #printed
> 
> {{ question.question_text }}
> #printed
> 
> *{% for choice in question.choice_set.all %}*
> *{{ choice.choice_text }}*
> *{% endfor %}*
> *#nothing printed!*
> 
>
> Also when I click button 'vote', I only get error.
> *You didn't select a choice.*
>
> I am just copying and pasting so that I can understand Django, but I am 
> having hard time in this Part 4.
>
> I really appreciate advice from anybody!
>
> Nori
>
>

-- 
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/0ee9f1c3-3ab0-4c26-8417-920a642a1469%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: filtering and searching help - regarding

2019-02-03 Thread Birol Demirtaş
Wnat u want ask to database ?

Example

X = yourmodel.objects.all()
Context = {‘x’:x}
Return render (request,your.html,context)



3 Şub 2019 Paz, saat 17:02 tarihinde Mohan Goud 
şunu yazdı:

> django
>
>
>
> On Sun, Feb 3, 2019 at 7:30 PM Birol Demirtaş 
> wrote:
>
>> Django ? Or ?
>>
>> 3 Şub 2019 Paz, saat 16:59 tarihinde Mohan Goud <
>> kathi.mohang...@gmail.com> şunu yazdı:
>>
>>>
>>>
>>> students list is in database. I have to search based on section,
>>> department and year and sort them in ascending order. can any one help me
>>> on this through any video links or any other.   --
>>> 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/CAB29Dk%3D9sLASp9Gr4q73qzh8ozw-ecYukUZZ62WkC8XKXtMDZA%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 https://groups.google.com/group/django-users.
>>
> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAN908so%3DSjsqv%2B%2BhA5Kw3W7tctGX%3D5WbtC4t9ZuwnsnZg92Xww%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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAB29DkneL1r4QeznCQG-4%2Bg7cSEnU5kcpsE_mowj0Y0pzN3Sgg%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN908soXT5KTN4eB7vhqX4GOdjdxK6nRPOsUT1m3Zh3L2Kv3Mg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: filtering and searching help - regarding

2019-02-03 Thread Mohan Goud
django



On Sun, Feb 3, 2019 at 7:30 PM Birol Demirtaş 
wrote:

> Django ? Or ?
>
> 3 Şub 2019 Paz, saat 16:59 tarihinde Mohan Goud 
> şunu yazdı:
>
>>
>>
>> students list is in database. I have to search based on section,
>> department and year and sort them in ascending order. can any one help me
>> on this through any video links or any other.
>>
>> --
>> 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/CAB29Dk%3D9sLASp9Gr4q73qzh8ozw-ecYukUZZ62WkC8XKXtMDZA%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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAN908so%3DSjsqv%2B%2BhA5Kw3W7tctGX%3D5WbtC4t9ZuwnsnZg92Xww%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB29DkneL1r4QeznCQG-4%2Bg7cSEnU5kcpsE_mowj0Y0pzN3Sgg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: filtering and searching help - regarding

2019-02-03 Thread Birol Demirtaş
Django ? Or ?

3 Şub 2019 Paz, saat 16:59 tarihinde Mohan Goud 
şunu yazdı:

>
>
> students list is in database. I have to search based on section,
> department and year and sort them in ascending order. can any one help me
> on this through any video links or any other.
>
> --
> 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/CAB29Dk%3D9sLASp9Gr4q73qzh8ozw-ecYukUZZ62WkC8XKXtMDZA%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN908so%3DSjsqv%2B%2BhA5Kw3W7tctGX%3D5WbtC4t9ZuwnsnZg92Xww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


filtering and searching help - regarding

2019-02-03 Thread Mohan Goud
students list is in database. I have to search based on section, department
and year and sort them in ascending order. can any one help me on this
through any video links or any other.

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


Re: Where is the data set of the Django documents demo models

2019-02-03 Thread Jason
I feel I have to disagree, and the reason is the point of the tutorial is 
to show you the basics with the various parts of django, and you're 
creating a data set as you go along.

https://docs.djangoproject.com/en/2.1/intro/tutorial02/#playing-with-the-api  
shows you how to use the ORM to create a new question
https://docs.djangoproject.com/en/2.1/intro/tutorial02/#explore-the-free-admin-functionality
 shows 
you how to use the admin to create and edit questions
https://docs.djangoproject.com/en/2.1/intro/tutorial03/#writing-your-first-django-app-part-3
 shows 
you how to make templates to list questions and show a specific question

That's all from data you're creating in the second step.

What do you feel you would get from having a data set provided as an 
example over the process above?

-- 
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/b749246d-1ce0-40ba-9b8f-31ce222c8ef7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Where is the data set of the Django documents demo models

2019-02-03 Thread Fogmoon
Thanks for your answer and advice. 

BTW, I think the data set should be somewhere because the demo is based on 
the data set. Maybe on the document author's computer. I just think 
provided the data set with the document will be more helpful for Django new 
users.  So hope the author or others can attach the data set with the demo. 


在 2019年2月2日星期六 UTC+8下午9:34:12,Jason写道:
>
> you would have to make your own data set for that, or try googling 
> around.  the demo is just to show how to make a django project, and doesn't 
> contain any data.
>
> one option for making your own is using factory boy or model mommy 
> projects to generate realistic randomized data.
>
>

-- 
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/3c69d050-ed39-47c1-a107-bde5f5cf27d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.