Re: SPAM sent via this list?

2019-01-10 Thread Joel Mathew
I've got multiple emails of similiar sort from aphiso...@gmail.com and
blocked this account. Didnt find any other option.
Sincerely yours,

 Joel G Mathew



On Thu, 10 Jan 2019 at 13:56, Markus Holtermann 
wrote:

> Hi, if the response you got is related to https://bitbounce.com/ , we're
> in touch with them so that they can fix their system. Unfortunately, Google
> Groups makes it really hard to find individual members and kick them, for
> lists of the size of django-developers and django-users.
>
> Cheers,
>
> Markus
>
> On Thursday, January 10, 2019 at 5:22:07 AM UTC+1, Lachlan Musicman wrote:
>>
>> I just got a spam email from the account
>>
>> aphi...@gmail.com
>>
>> That is threaded to my previous response to Alejandro Reyes's email
>>
>> Here's the raw header
>>
>>
>> Delivered-To: dat...@gmail.com
>> Received: by 2002:ab0:59f2:0:0:0:0:0 with SMTP id k47csp1496731uad;
>> Wed, 9 Jan 2019 20:15:11 -0800 (PST)
>> X-Received: by 2002:a17:906:e2c9:: with SMTP id 
>> gr9-v6mr7444893ejb.108.1547093711410;
>> Wed, 09 Jan 2019 20:15:11 -0800 (PST)
>> ARC-Seal: i=1; a=rsa-sha256; t=1547093711; cv=none;
>> d=google.com; s=arc-20160816;
>> b=Uk1KEWZpXj57NrLSw/NrkYofbu7/WAxFBbuzEY7jMIpScKUGzLMh6hxFd89RhPMo7/
>>  7eMRsfWxvPeVAknN7Ghc+A+jK+ZidGjRsv/DsKiCJYWLE4m/B2w2i5PpL0jPCTD/cJ7Q
>>  /A3FbBDkoaegCbDZzBHwy1RF2lejE8joiT7VaIUKxINQ1Tq4Z0IGyCPdPjI/ThKWU+FU
>>  xn+laGAltdoUG3WbvIueNXA8jChxUagFoMlns0yDr1FETv1ymUgcLefeqi7F5F65r9vo
>>  9Rz6kyp33FSo5tqGRf1ZBmcSd4cXiIUwcEPTFMisEPxBLUTpspNcedop625YpWljG8sb
>>  PRvw==
>> ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; 
>> s=arc-20160816;
>> h=to:subject:message-id:date:references:in-reply-to:mime-version:from
>>  :dkim-signature;
>> bh=Azuv04E2o8dshX5o1BJ8WGQr6D9cswM1D1HqW5tXEoo=;
>> b=UCngM/tm+Rg242qMf/EbLYW8Cw+DpPvskZ1KVvBfqS7xDOqGg6vNHwKh+eJ/BZAjvS
>>  gaLZFT2Z4uCt5BSeuQTclwi5Uw0NkZ3OrEwXSbm9dAe7k5dJ5vGv9XQFNncxd3BAx5AS
>>  SE26fuct4nn3chaXCKmzZlaIYIlO0jfZ5uBgnpQFEGWAyAVYo6sUnhswLw5dPpKuckh/
>>  dCGq1TIvd0hRrcqNw4jAIh4L6qyB96TlKbJSO/7nTbb7dN5/a5VxKXM/tT4/qkqfNW/D
>>  bnmXoa7nHxKFFe9/WlY4ktFRo1ovndNqE2D/xZtptOEEneY46CaFvzI6ODFYbjMR5io/
>>  SS8w==
>> ARC-Authentication-Results: i=1; mx.google.com;
>>dkim=pass header.i=@gmail.com header.s=20161025 header.b=dd8veXeU;
>>spf=pass (google.com: domain of aphi...@gmail.com designates 
>> 209.85.220.41 as permitted sender) smtp.mailfrom=aphi...@gmail.com;
>>dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
>> Return-Path: 
>> Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. 
>> [209.85.220.41])
>> by mx.google.com with SMTPS id 
>> e44sor3343283ede.13.2019.01.09.20.15.11
>> for 
>> (Google Transport Security);
>> Wed, 09 Jan 2019 20:15:11 -0800 (PST)
>> Received-SPF: pass (google.com: domain of aphi...@gmail.com designates 
>> 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
>> Authentication-Results: mx.google.com;
>>dkim=pass header.i=@gmail.com header.s=20161025 header.b=dd8veXeU;
>>spf=pass (google.com: domain of aphi...@gmail.com designates 
>> 209.85.220.41 as permitted sender) smtp.mailfrom=aphi...@gmail.com;
>>dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
>> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
>> d=gmail.com; s=20161025;
>> 
>> h=from:mime-version:in-reply-to:references:date:message-id:subject:to;
>> bh=Azuv04E2o8dshX5o1BJ8WGQr6D9cswM1D1HqW5tXEoo=;
>> b=dd8veXeUlee7ACSL3xnZk1RzWT44ZXlifjzUuqnUVlxZu5S0dkUgoVSsT8MaevKOGe
>>  WorIqWc4/K6XFuz6caxwn+U+sWrYiESrusvkXsNAZAXzQ1G0e4tAc8uvh77AnoYUPstk
>>  K2ZQyTRB42EuREJN94GArD6E0D+3cYk86eYF2BdXD1s59r7z97+LHNUJLE/EErHTiQ9B
>>  TE3+AzAKpSgJF5a49sSIeFDGzF5O64qFqIr2wHL3ZuYYk0+LDP3mLIOtCEU1kmcpfRxS
>>  mxyFqQ5t1XjkcZRuMVc0jvxsMTBeTSMs73i5PVmmWkmeXykc9YOPNFSXEg9+QeCduOEC
>>  /yIA==
>> X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
>> d=1e100.net; s=20161025;
>> h=x-gm-message-state:from:mime-version:in-reply-to:references:date
>>  :message-id:subject:to;
>> bh=Azuv04E2o8dshX5o1BJ8WGQr6D9cswM1D1HqW5tXEoo=;
>> b=cFU5b8+MRXUtvTznVlGZLohfDDKdWCWXLdsPcP8TSYKGINSy+80JnJI5GL9Ogh6vQk
>>  VDJyuuXsarPxBhew98u5kpThsAAQ6L92S2vA6b5I08S9KR4xIL6W+CsTa4bS3RZo17Ev
>>  C4fP8wHwpCmylgqOVO2Kwp39HXgXg3mySVv9HyZ2JzzwgXF9bhqFeOWVXdWzHK4WdF1v
>>  5S0/1Cr/8vIkjpOkD4NVtBp3frWUgDFIJN7wpukYdhcpc2FNpRJY15RKtBCv8MXOBGlA
>>  FF/4uQXnGeyAiLd0yaGTROuR9cSzBzMlW+YWtXn4Xc3b8fYLZ9u4OwK2ty58NfAGMlPH
>>  yJCQ==
>> X-Gm-Message-State: AJcUukfvXzy9WecRe6/K4iC0iWtIxysbNXeBqUtF2Kd2ps8N/L8fOOHe 
>> 40EtFgLtrpivvrGCWt4YnGRlV/Rdh2ioyee6AZX45w==
>> X-Google-Smtp-Source: 
>> ALg8bN40FdsN8UjLFM7ESJPXEvdSS/UpieqzzaYvx8rwlAn8+JpAg1Nnt5kHhcXV47odMIri/

Installing pdftotext library on heroku

2019-01-23 Thread Joel Mathew
pdftotext library is a requirement in requirements.txt. While trying to
push to heroku, I get the following error:

remote:  Running setup.py install for pdftotext: started
remote:Running setup.py install for pdftotext: finished
with status 'error'
remote:Complete output from command
/app/.heroku/python/bin/python -u -c "import setuptools,
tokenize;__file__='/tmp/pip-build-rnbekz45/pdftotext/setup.py';f=getattr(tokenize,
'open', open)(__file__);code=f.read().replace('\r\n',
'\n');f.close();exec(compile(code, __file__, 'exec'))" install
--record /tmp/pip-o0if2tl3-record/install-record.txt
--single-version-externally-managed --compile:
remote:
/app/.heroku/python/lib/python3.6/distutils/dist.py:261: UserWarning:
Unknown distribution option: 'long_description_content_type'
remote:  warnings.warn(msg)
remote:running install
remote:running build
remote:running build_ext
remote:building 'pdftotext' extension
remote:creating build
remote:creating build/temp.linux-x86_64-3.6
remote:gcc -pthread -Wno-unused-result -Wsign-compare
-DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPOPPLER_CPP_AT_LEAST_0_30_0=0
-I/app/.heroku/python/include/python3.6m -c pdftotext.cpp -o
build/temp.linux-x86_64-3.6/pdftotext.o -Wall
remote:pdftotext.cpp:3:10: fatal error:
poppler/cpp/poppler-document.h: No such file or directory
remote: #include 
remote:  ^~~~
remote:compilation terminated.
remote:error: command 'gcc' failed with exit status 1
remote:
remote:
remote:Command "/app/.heroku/python/bin/python -u -c "import
setuptools, 
tokenize;__file__='/tmp/pip-build-rnbekz45/pdftotext/setup.py';f=getattr(tokenize,
'open', open)(__file__);code=f.read().replace('\r\n',
'\n');f.close();exec(compile(code, __file__, 'exec'))" install
--record /tmp/pip-o0if2tl3-record/install-record.txt
--single-version-externally-managed --compile" failed with error code
1 in /tmp/pip-build-rnbekz45/pdftotext/
remote:  ! Push rejected, failed to compile Python app.
remote:
remote:  ! Push failed

Normally I'd solve this by installing libpoppler-cpp-dev with apt. But on
heroku, I don't have root access to do that. Is there a solution for this?
Sincerely yours,

 Joel G Mathew

-- 
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__jf69Dcd4QZAGQrSjbL51biA3kZq_LuV%3D6Vu6kHkYj1g%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: 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: Webinterface for python script

2019-02-05 Thread Joel Mathew
Exactly. I to use file upload and rendering in a medical report.

@OP Did your research and post your code. Can help with any errors you're
getting.

Research about request.POST, request.FILES. Read this.
https://docs.djangoproject.com/en/2.1/topics/files/

On Tue, 5 Feb, 2019, 1:25 PM Scot Hacker  Make a basic Django view. Place your script in a python module that lives
> inside your app. Call that module/ function from the Django view. See
> Django docs and tutorials on how to handle uploaded files. Pass the
> uploaded file to your module, and handle the return value(s) however you
> want. Hard to get more specific than that without seeing your code, but
> this should come together pretty quickly with some experimentation.
>
> I never know what people mean by "Django is overkill for...". Django is
> lightweight and starts up very quickly, even with large/complex projects.
> Django saves you mountains of time compared to Flask, which makes you go
> shopping for every little piece of framework you need. Every time I've
> experimented with Flask, I've come running back to Django after realizing
> my time is too valuable to waste it on creating my own framework when a
> perfectly great one already exists.
>
> ./s
>
>
> On Sunday, February 3, 2019 at 7:53:20 AM UTC-8, Asad Hasan wrote:
>>
>> 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/88c2337b-7e8a-4e11-968f-30299b6229d4%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_-a-x4dOWwvqckq1E%2B8Bv%2B5n1DHxikEsEBVxDq9pHKV1A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Installing pdftotext library on heroku

2019-03-05 Thread Joel Mathew
This was solved after a user helped me out on StackOverflow. The solution
is to use build packs.

https://help.heroku.com/IYRYW6VB/how-do-i-install-additional-software-packages-that-my-application-requires

Sincerely yours,

 Joel G Mathew



On Tue, 5 Mar 2019 at 21:02, joelryan2k  wrote:

> I'm curious about this, too. I've been using docker containers on heroku
> to avoid potential issues like this.
>
> On Wednesday, January 23, 2019 at 7:20:03 AM UTC-5, Joel Mathew wrote:
>>
>> pdftotext library is a requirement in requirements.txt. While trying to
>> push to heroku, I get the following error:
>>
>> remote:  Running setup.py install for pdftotext: started
>> remote:Running setup.py install for pdftotext: finished with 
>> status 'error'
>> remote:Complete output from command 
>> /app/.heroku/python/bin/python -u -c "import setuptools, 
>> tokenize;__file__='/tmp/pip-build-rnbekz45/pdftotext/setup.py';f=getattr(tokenize,
>>  'open', open)(__file__);code=f.read().replace('\r\n', 
>> '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record 
>> /tmp/pip-o0if2tl3-record/install-record.txt 
>> --single-version-externally-managed --compile:
>> remote:/app/.heroku/python/lib/python3.6/distutils/dist.py:261: 
>> UserWarning: Unknown distribution option: 'long_description_content_type'
>> remote:  warnings.warn(msg)
>> remote:running install
>> remote:running build
>> remote:running build_ext
>> remote:building 'pdftotext' extension
>> remote:creating build
>> remote:creating build/temp.linux-x86_64-3.6
>> remote:gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG 
>> -g -fwrapv -O3 -Wall -fPIC -DPOPPLER_CPP_AT_LEAST_0_30_0=0 
>> -I/app/.heroku/python/include/python3.6m -c pdftotext.cpp -o 
>> build/temp.linux-x86_64-3.6/pdftotext.o -Wall
>> remote:pdftotext.cpp:3:10: fatal error: 
>> poppler/cpp/poppler-document.h: No such file or directory
>> remote: #include 
>> remote:  ^~~~
>> remote:compilation terminated.
>> remote:error: command 'gcc' failed with exit status 1
>> remote:
>> remote:
>> remote:Command "/app/.heroku/python/bin/python -u -c "import 
>> setuptools, 
>> tokenize;__file__='/tmp/pip-build-rnbekz45/pdftotext/setup.py';f=getattr(tokenize,
>>  'open', open)(__file__);code=f.read().replace('\r\n', 
>> '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record 
>> /tmp/pip-o0if2tl3-record/install-record.txt 
>> --single-version-externally-managed --compile" failed with error code 1 in 
>> /tmp/pip-build-rnbekz45/pdftotext/
>> remote:  ! Push rejected, failed to compile Python app.
>> remote:
>> remote:  ! Push failed
>>
>> Normally I'd solve this by installing libpoppler-cpp-dev with apt. But
>> on heroku, I don't have root access to do that. Is there a solution for
>> this?
>> Sincerely yours,
>>
>>  Joel G Mathew
>>
>> --
> 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/a6177122-63d0-4162-8be4-ab05d9d094d4%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/a6177122-63d0-4162-8be4-ab05d9d094d4%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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_-rro5%2B%3DeY%2B9avCqVyPjCvQxmDPZFm5i1Khc4iGBmL8Qg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How does WSGI work?

2019-03-07 Thread Joel Mathew
There's a mod_wsgi_express thread that Graham monitors, so he's sure to get
feedback from there

Understanding this better could help me solve static file blues. Most of
the time I don't understand why my static files fine aren't served when I
move to production.

On Fri, 8 Mar, 2019, 5:29 AM Mike Dewhirst,  wrote:

> On 8/03/2019 10:11 am, Tal wrote:
> > The word "simple" appears 13 times in PEP, but no one knows how
> > this magical specification works?
> > Can anyone confirm I'm not crazy please?
>
> You could try writing to Grahame Dumpleton for confirmation. I'm
> reasonably sure he wrote mod_wsgi and ought to be able to correct you if
> you've misunderstood anything.He used to give presentations on wsgi at
> PyCons so you might be able to find something on YouTube from a few
> years ago.
>
> Last I heard of him he is fairly focused on Kubernetes so he probably
> doesn't monitor the Django list any more.
>
> >
> > On Tuesday, February 26, 2019 at 3:13:00 PM UTC-7, Tal wrote:
> >
> > Is it right though?
> >
> > On Tuesday, February 26, 2019 at 2:49:03 PM UTC-7, mike wrote:
> >
> > Great write up!
> >
> > On Tue, Feb 26, 2019 at 2:39 PM Tal  wrote:
> >
> > Did I get something wrong?
> > Do you mean the devs working on the Django project know
> > nothing about this, or the devs using Django to build web
> > apps?
> > From what I've read, devs using Django don't need to be
> > too familiar with WSGI, but it seems like it helps at
> > least having a conceptual understanding of what it is.
> >
> > On Tuesday, February 26, 2019 at 12:28:26 PM UTC-7, Motaz
> > Hejaze wrote:
> >
> > You are very close to what realy happens , most of
> > devs know nothing aboutbthis stuff
> >
> > On Tue, 26 Feb 2019, 20:26 Tal, 
> wrote:
> >
> > I've been developing web applications using Flask
> > and Django for about a year now, and although I've
> > come across the term WSGI a bunch of times in both
> > frameworks, I never really understood what it did.
> > I'm sure I'm not the only one. The quick
> > explanations I read never made sense to me. Even
> > PEP didn't really give me a clear picture of
> > how WSGI fits in with Nginx, and Django. There are
> > a bunch of articles online that quickly show how
> > to setup nginx, gunicorn/uwsgi and django to work
> > in production, and once I figured that out, I
> > never really had a reason to figure out WSGI
> > again. But it's been a year now, and I probably
> > should understand at least the basics.
> >
> > I did a bit more reading recently, and I think I
> > get it. Just looking for someone to confirm that
> > I'm on the right track.
> > This is how I think it works:
> >
> > My example uses the most common setup I use:
> > Nginx, Gunicorn and Django
> >
> >   * When an HTTP request comes in, it hits Nginx
> first
> >   o Nginx runs multiple processes, and makes
> > sure that browsers/clients that have a
> > slow connection don't effect other clients
> >   o If it's a request for a static file, like
> > a CSS file, JS, image, or anything like
> > that, Nginx returns it directly
> >   o If it's a request for anything else, it
> > uses *HTTP* to send the request over a
> > Unix socket to Gunicorn
> >   + Doesn't have to be a Unix socket, but
> > if both Nginx and Gunicorn are running
> > on the same host, it makes sense to
> > use Unix sockets
> >   + The main point is that Nginx uses HTTP
> > to communicate with Gunicorn
> >   * Gunicorn
> >   o Starts up x worker processes on startup
> > (as many as you tell it)
> >   o Each worker process imports your
> > application's code
> > (django.core.wsgi.get_wsgi_application()
> > in Django's case)
> >   + The application's code is a callable
> > function
> >  

Re: Font Awesome does not work locally

2019-03-11 Thread Joel Mathew
It's related to your static address. You're probably not setting the
correct relative path. Check the tutorials on how the settings for STATIC
files work
Sincerely yours,

 Joel G Mathew



On Mon, 11 Mar 2019 at 20:42, Mujab Nasraldeen 
wrote:

>  font awesome does not work locally .. without using: https://use.fontawesome.com/releases/v5.7.2/css/all.css";
> integrity="
> sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr"
> crossorigin="anonymous">
>
>  I replaced it with: 
>
> but when but when i type:  .. but
> the page displays as a square
>
> How to solve this problem???
>
> --
> 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/57773dd9-1a60-4c58-a706-a39959e9e28e%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_-_zEBrvdsfK79K-0dOQ2aPpc%3DnP-2uNQQF7mdX637UDg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is there any inline editing the data and delete data in table in Django?

2019-03-22 Thread Joel Mathew
This is simple to achieve with django formset plus jquery. You just need to
have a little imagination

On Fri, 22 Mar, 2019, 12:15 PM VeeraNagaRaja Sankar, 
wrote:

> hi Derek,
>
> Thank you but I saw this one not working for my methodology.
>
> Best Regards,
> Inti VeeraNagaRaja Sankar,M.Tech(IT)
> M: 9985864383
> intisank...@gmail.com 
> https://about.me/veeranagarajasankar
>
>
> On Thu, Mar 21, 2019 at 11:08 AM Derek  wrote:
>
>> If I had to do something like this right now I would probably look at:
>> *
>> https://bossanova.uk/jexcel/examples/tracking-changes-on-the-spreadsheet
>> ,
>> * plus the javascript needed to handle the front-end GET/POST requests
>> (MANY examples on the web) when data changes,
>> * along with Django DRF on the back-end to handle the server side data
>> generation and database updates.
>>
>> Please don't keep asking "how" and rather start with your own
>> development.
>>
>> On Wednesday, 20 March 2019 21:57:21 UTC+2, Chetan Ganji wrote:
>>>
>>> Hi Sankar,
>>>
>>> Derek is right, we can only give you suggestions as we are far away from
>>> you. How is really upto YOU.
>>> What you are trying to achieve is basically a front end task. You only
>>> have knowledge of django which is a backend technology.
>>>
>>> You have many options to make choice from -
>>> 1. You have to learn to use jquery to do it the way you want it.
>>> 2. Use the default UpdateView from django where EDIT/UPDATE view will be
>>> shown separately. i.e. let go of inline editing feature.
>>> 3. Find someone who will code it for you.
>>> 4. Any other that you can think of.
>>>
>>> Happy Coding :)
>>>
>>>
>>> Regards,
>>> Chetan Ganji
>>> +91-900-483-4183
>>> ganji@gmail.com
>>> http://ryucoder.in
>>>
>>>
>>> On Wed, Mar 20, 2019 at 11:58 AM VeeraNagaRaja Sankar <
>>> intis...@gmail.com> wrote:
>>>
 hi,

 means, i am only aware of Django so i need any code reference to do that
  thank you,

 Best Regards,
 Inti VeeraNagaRaja Sankar,M.Tech(IT)
 M: 9985864383
 intis...@gmail.com
 https://about.me/veeranagarajasankar


 On Wed, Mar 20, 2019 at 11:55 AM Derek  wrote:

> That is not an answerable question.  We have given you suggestions -
> the "how" is up to you.
>
> On Tuesday, 19 March 2019 09:36:27 UTC+2, veera nagaraja sankar Inti
> wrote:
>>
>>
>> how ?
>>
>> On Monday, March 4, 2019 at 12:40:03 PM UTC+5:30, Derek wrote:
>>>
>>> Grid / tabular editing outside of the admin is tricky; I have not
>>> been able to manage it and have not found a good app for it.
>>>
>>> Here are some suggested reading:
>>>
>>> * https://www.ibm.com/developerworks/library/wa-django/index.html
>>> * https://bossanova.uk/jexcel
>>> *
>>> https://medium.com/ag-grid/building-a-crud-application-with-ag-grid-part-4-3189034df922
>>>
>>> You'd also need an app like Django REST Framework to handle GET/POST
>>> of JSON data to populate your grid.
>>>
>>> On Wednesday, 27 February 2019 20:39:04 UTC+2, veera nagaraja sankar
>>> Inti wrote:

 need help friends ?..

 thq..

>>> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/562202e8-53a3-44d2-b0aa-ba710e180787%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...@googlegroups.com.
 To post to this group, send email to django...@googlegroups.com.
 Visit this group at https://groups.google.com/group/django-users.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/CAJFTHQa_6OGseZ8TwrniWrUNDM%2BkN8a%3DChBFrF7j4XRysARaLw%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.

Re: how can i get current username in model field ??

2019-04-01 Thread Joel Mathew
This does not make sense to me. A model is not a dynamic entity. It is
something that's created beforehand. Getting the current username into
model should be done in your logic (views), or the template
Sincerely yours,

 Joel G Mathew



On Mon, 1 Apr 2019 at 19:01, omar ahmed  wrote:

> i want to put value of logged in user.username in author field
> class Comment(models.Model):
> leaguenews = models.ForeignKey(LeagueNews, on_delete= models.CASCADE,
> related_name='comments')
> author = models.CharField(max_length=200)
> text = models.TextField()
>
> --
> 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/8a24a020-af3a-4a5f-ac25-5da3aa1fa8db%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_9E9szHxpGUwXB1UFgcEkJDOCaSK8-an%2BxFyV0jt4sR2g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: I need help please

2019-04-01 Thread Joel Mathew
It's supposed to be an example.
Sincerely yours,

 Joel G Mathew



On Mon, 1 Apr 2019 at 19:12, dvij parekh  wrote:

> link is not working
>
>
> On Mon, Apr 1, 2019 at 6:32 PM Nanjuki Saidat 
> wrote:
>
>> Hi all,
>> I am Saidat a new django developer, i need help on how to go about this
>> " Change admin portal URL to more obvious path and add link in side menu
>> to admin settings for admin users". In summary:
>>
>>
>>1.  i want to change URL string to more intuitive URL (i.e.
>>fhp.example.com/drunken-octo-lama/ to fhp.example.com/admin/)
>>2. If a user is an admin user, show a link in the side menu to access
>>admin settings page.
>>
>>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/CAHrBrjC-j-2Z%2Bkn-U2gKBaV24Mu3W4QFGgochC1s6906VE5Tuw%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/CAF-XeXapTQ5jdOUOtkV5USYhyje9sWtU8hvShEY1yC6pBQ51zw%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/CAA%3Diw_9pa3ZyW9%2Ba4VWSYMFSY-3wsZ%2BBFvppJvwZrR0kTdQrXA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Hosting recommendations please

2019-04-02 Thread Joel Mathew
I'm running mine off a Digitalocean 1GB droplet, and one hobby site off
Heroku. Heroku has some latency noticeable occasionally, but the
digitalocean droplet is perfect. I will scale to better specs once I go
into active production. It's working fine for upto 10 users now.
Sincerely yours,

 Joel G Mathew



On Tue, 2 Apr 2019 at 12:39, Mike Dewhirst  wrote:

> I have to move three Django websites away from my current VM service
> provider by the end of April because he is going out of the VM business.
>
> One is a plain Mezzanine CMS on one VM running Nginx/Gunicorn and the
> other two are on the second VM running Apache and mod_wsgi.
>
> I'm most familiar with Ubuntu 16.04 and hope to go to 18.04.
>
> I think the RAM requirements are around 4GB for the Apache sites and
> half that for Nginx. Haven't done any profiling.
>
> I'm in Australia. I'm after stability and reliability and if I'm lucky,
> scalability.
>
> If you have any negative comments about providers please send them
> off-list.
>
> Many thanks
>
> Mike
>
>
> --
> 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/b7e16385-0ea9-6d02-e175-ba4594208bcc%40dewhirst.com.au
> .
> 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_9My8quXSDKr4BBCSSSnPnuH%3DYp6mQezG4%3DBFrcgHHBjA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django module view has no attribute?

2019-04-02 Thread Joel Mathew
Is there a function named posts in views.py?

On Tue, 2 Apr, 2019, 7:29 AM drone4four,  wrote:

> I’m taking a Udemy course by Nick Walter and rather than copying line by
> line, I’m trying to branch out and experiment on my own.
>
> The purpose of the website I am creating is for a small blog, with the
> ability to redact string input (in an HTML form) from the user. There is
> also a word counter for the body content of the blog.
>
> I got Django running but as soon as I started adding the code I wrote,
> Django stopped running properly.
>
> Here is the traceback in full: https://pastebin.com/8HtdNwPP
>
> The main issue shows at the bottom:
>
> File
>> "/home//dev/projects/python/2018-and-2019/CC_Redact_Iter2/CC_Redact_Iter2/urls.py",
>> line 28, in 
>>* path('^james/', views.posts, name='james'),*
>> *AttributeError: module 'counters.views' has no attribute 'posts’*
>
>
>
> Based on this traceback, I gather I have probably misnamed a function or a
> file name or template but I can’t for the life of me figure which one or
> where.
>
> My entire source code repo can be found here:
> https://github.com/Angeles4four/CC_Redact_Iter2
>
> Here are some of the relevant files involved.
>
> urls.py:
>
> from django.contrib import admin
>> from django.urls import path
>> # from . import views
>> from posts import views
>> from redactors import views
>> from counters import views
>> urlpatterns = [
>>   path('admin/', admin.site.urls),
>>   path('^$', views.home, name='home'),
>>   path('^result/', views.result, name='result'),
>>   path('^seth/', views.counters, name='seth'),
>>   path('^james/', views.posts, name='james'),
>>   path('^james/', views.redactors, name='simon'),
>> ]
>
>
>
> counters/views.py:
>
> from django.http import HttpResponse
>> from django.shortcuts import render
>> def home(request):
>>   if 'ccEntry' in request.GET:
>>   number = request.GET['ccEntry']
>>   redacted_num = '   {}'.format(number[-4:])
>>   return render(request, 'result.html', {'number':number,
>> 'redacted_num':redacted_num})
>>   else:
>>   return render(request, 'home.html')
>> def result(request):
>>return render(request, 'result.html')
>> def counters(request):
>>   return render(request, 'counters/james.html')
>
>
> Here is my file tree: https://imgur.com/a/BUTKKEH
>
> Contents of requirements.txt:
>
>> Django==2.0.13
>> Pillow==5.4.1
>> psycopg2==2.7.7
>> psycopg2-binary==2.7.7
>> pytz==2018.9
>
>
>
> If there are other files in my project that you wish to view, you can
> click through the file tree as it appears on GitHub (linked to 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/353c83b5-1f37-4e23-b6c7-f488cb05805e%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__0D%2BEHdxgkCLOGFHJDza9Q5EmdGRS3vo9RrFKybRTKGw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: I need help on adding a search button to an input field

2019-04-10 Thread Joel Mathew
Use bootstrap's input-group-append
Sincerely yours,

 Joel G Mathew



On Wed, 10 Apr 2019 at 23:14, Nanjuki Saidat 
wrote:

> Please any one to help me out.thanks
>
> On Wed, 10 Apr 2019 at 20:40, Nanjuki Saidat 
> wrote:
>
>> this one still did the same thing which i didnt mean me i meant an search
>> button in an input field
>>
>> On Wed, 3 Apr 2019 at 22:04, Anirudh Jain 
>> wrote:
>>
>>> You can include the following code in the end
>>>
>>> ButtonHolder(
>>> Submit('submit', 'Update', css_class='btn btn-theme small')
>>> )
>>>
>>> Take care of proper indentation.
>>>
>>> On Wed, 3 Apr 2019, 23:48 Nanjuki Saidat, 
>>> wrote:
>>>
 Hi everyone,
 I want to add a search button to an input search field , if there is
 anyone who knows
 how to add a button to the field in crispy form's input field. Please
 help me out


 https://pagure.io/fedora-commops/fedora-happiness-packets/issue/raw/files/a8846b7d72aced5bdc0a2470dc97a495fb7558d6a0908a04b369260e862d-Screenshot_2019-03-20_Open-source_Happiness_Packets.png

 --
 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/CAHrBrjDW%2Bn-oHwdiYRpw%3DdS8HA%2BAH%2Bne3_kjmxz-UHYqPhX9ow%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/CAC3mK7fBWiFTXEqeDHPfiExZ39DexHK90OBQ6mmsrSpfD2CCVA%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/CAHrBrjAhx4wY-eouLXr3LWYR9hsD_18bULS-p_6qku1cfDPKHA%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/CAA%3Diw_-x-jotqifY8DdpA-xHxF9XFMCcbACVOhkEJDd_fmgRzg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need assistance! I want to create a list box that displays records that can be selected (single or multiple) from a PGSQL table.

2019-04-17 Thread Joel Mathew
Great to know

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


Advanced permissions and role creation

2019-04-20 Thread Joel Mathew
I have an application for a hospital. There, I should be able to assign
different roles like Doctor, Nurse, Attender, Auxillary Nurse, Pharmacist,
Store Manager etc, each of would be having specific access to seperate
areas (views), with some having restricted access. In addition, there are
other hospitals who would be having no access to another hospital's
records. All of these permissions should be customisable, and I should be
able to create additional roles and permission groups for specific areas
later (from within the application itself, in production). What would be
the best solution to use? Is there a middleware which works well. I don't
want to roll my own if I will be reinventing the wheel.

Currently my application has no use permissions. But access to specific
hospitals is being restricted by a model whoch stores hospital name, and
user name.
Sincerely yours,

 Joel G Mathew

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


Re: Advanced permissions and role creation

2019-04-21 Thread Joel Mathew
Thanks a lot, guys.

On Sun, 21 Apr, 2019, 3:58 PM Jani Tiainen,  wrote:

> Hi,
>
> We do in our applications pretty much same approach as Mike proposed in
> his post. It's relatively efficient and works for both, UI and application
> side pretty well and doesn't require building anything complex and pretty
> much everything you need is already built-in in Django.
>
>
>
> On Sun, Apr 21, 2019 at 5:12 AM Joel Mathew  wrote:
>
>> I have an application for a hospital. There, I should be able to assign
>> different roles like Doctor, Nurse, Attender, Auxillary Nurse, Pharmacist,
>> Store Manager etc, each of would be having specific access to seperate
>> areas (views), with some having restricted access. In addition, there are
>> other hospitals who would be having no access to another hospital's
>> records. All of these permissions should be customisable, and I should be
>> able to create additional roles and permission groups for specific areas
>> later (from within the application itself, in production). What would be
>> the best solution to use? Is there a middleware which works well. I don't
>> want to roll my own if I will be reinventing the wheel.
>>
>> Currently my application has no use permissions. But access to specific
>> hospitals is being restricted by a model whoch stores hospital name, and
>> user name.
>> Sincerely yours,
>>
>>  Joel G Mathew
>>
>> --
>> 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_9BrOEh4Ss3X0g_EnaFyp1XTXij5DoZvva_XxwKVzXsGQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAA%3Diw_9BrOEh4Ss3X0g_EnaFyp1XTXij5DoZvva_XxwKVzXsGQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> Jani Tiainen
> Software wizard
>
> https://blog.jani.tiainen.cc/
>
> Always open for short term jobs or contracts to work with Django.
>
> --
> 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/CAHn91od2vbV7F0WwAVp6Eppqmmd5-NgZciO_04Tm%3D9x9FSJyvQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAHn91od2vbV7F0WwAVp6Eppqmmd5-NgZciO_04Tm%3D9x9FSJyvQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> 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_-6cLiAfN1NHovdY4-Y_Wtz1KToMWW6zErNKAdXNOpm1w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Storing HTML in DB using DJANGO

2019-04-21 Thread Joel Mathew
I fail to see the purpose of that. Serialisation is sufficient. Big
projects like wordpress store even big blog posts, which is html like this.
Sincerely yours,

 Joel G Mathew



On Sun, 21 Apr 2019 at 20:20, Brian M  wrote:

> What if you convert the html to an array of bytes before storing?
>
> Then you’d convert from bytes array back to string when you retrieve. This
> way you’d store raw data.
>
>
> On Apr 21, 2019, at 8:41 AM, Jani Tiainen  wrote:
>
> Well after all, HTML is just plain text... Though you probably want to
> think to do some sanitization so you won't get nasty injections via html.
>
> On Sat, Apr 20, 2019 at 9:09 PM Sipum Mishra  wrote:
>
>> Hi friends,
>>
>> I want to store a html in database using python and need to retrieve that
>> html and convert that in to PDF.
>> can u plz suggest me how to store that HTML in DB ?
>>
>> --
>> 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/f301b675-6587-434e-b25d-87de9d9fef10%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> Jani Tiainen
> Software wizard
>
> https://blog.jani.tiainen.cc/
>
> Always open for short term jobs or contracts to work with Django.
>
> --
> 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/CAHn91oe6hUWZtEYCx%3D8uNe%3DFEphZ4C_VRPv74oK2E-x9gvJjGw%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/47B36FA2-099C-4AAB-B5DA-1D9662513398%40gmail.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_-pMCYKd4_7CHbcU7jz7YFZmNw3BXd6Grgwa99x6WGALg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Integrating Google calendar API in TODO list

2019-04-24 Thread Joel Mathew
Just do it. The API has python sample code.
Sincerely yours,

 Joel G Mathew



On Tue, 23 Apr 2019 at 09:58, Sipum  wrote:

> Hello friends.
>
> I am going to integrate google calendar API in to my TODO List.
> can anyone suggest how to integrate so that when I will add any event in
> my TODO List app it will directly show in my google calendar.
>
> 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/ebbfbf68-4445-4146-9e49-c18041796343%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_9UTM0izFDbwcGMDxGPZaUHSy9r9L90cEkYA0Vc0JDAmQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Integrating Google calendar API in TODO list

2019-04-24 Thread Joel Mathew
I fail to see what's your difficulty in integrating this. You just insert
the code in your views, and display your processed result in your template.
Try writing code and post your error. There's no specific code needed just
for django.

If it failed, post your code with the error stream.

On Wed, 24 Apr, 2019, 10:59 PM Sipum Mishra,  wrote:

> Joel, i know there is python code for yhat API but how to integrate it.. I
> want to know that.. I tried to do but failed.
>
> On Wed, 24 Apr, 2019, 6:55 PM Joel Mathew,  wrote:
>
>> Just do it. The API has python sample code.
>> Sincerely yours,
>>
>>  Joel G Mathew
>>
>>
>>
>> On Tue, 23 Apr 2019 at 09:58, Sipum  wrote:
>>
>>> Hello friends.
>>>
>>> I am going to integrate google calendar API in to my TODO List.
>>> can anyone suggest how to integrate so that when I will add any event in
>>> my TODO List app it will directly show in my google calendar.
>>>
>>> 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/ebbfbf68-4445-4146-9e49-c18041796343%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/ebbfbf68-4445-4146-9e49-c18041796343%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> 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_9UTM0izFDbwcGMDxGPZaUHSy9r9L90cEkYA0Vc0JDAmQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAA%3Diw_9UTM0izFDbwcGMDxGPZaUHSy9r9L90cEkYA0Vc0JDAmQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> 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/CAGHZBzxv28c%3Db8MQEnXiGVY9pM6rj-u%3DwEr1VOVYMNYcZSbCVw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAGHZBzxv28c%3Db8MQEnXiGVY9pM6rj-u%3DwEr1VOVYMNYcZSbCVw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> 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_8adPwu6_OoeCieERW9eNzcvzbP6D_2B7ntvghE7TxQLA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Like button for user pictures.

2019-04-25 Thread Joel Mathew
I tried and could not is not a valid developer question. We're left
imagining how you tried, and how it failed. Post code with any question and
explain in words.
Sincerely yours,

 Joel G Mathew



On Fri, 26 Apr 2019 at 00:13, Nitesh Saini 
wrote:

> Hello,
> I'm working on a project similar to Instagram and I want to create a like
> button for user pictures.
> I try it with BooleanField but unable to do it. So please help
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/413143b9-b11c-4315-ad10-3cf440ad341f%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_87ZPPnAWSa%2BNb-uiAxqcY6Jv5kqRqumoPxLbgaTEQRaw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Unable to create the django_migrations table (ORA-00907: missing right parenthesis)

2019-04-27 Thread Joel Mathew
What's the error?
Sincerely yours,

 Joel G Mathew



On Sun, 28 Apr 2019 at 01:26, tossouwisdom  wrote:

> Django 2.2.2
> Cx_oracle 7.2
> base Oracle 11g
>
> When I run the django migrate commande, i have error 
> django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the 
> django_migrations table (ORA-00907: missing right parenthesis)
>
>   Operations to perform:
>   Apply all migrations: admin, auth, contenttypes, sessions
> Running migrations:
> Traceback (most recent call last):
>   File "C:\Python37-32\lib\site-packages\django\db\backends\utils.py", line 
> 82, in _execute
> return self.cursor.execute(sql)
>   File "C:\Python37-32\lib\site-packages\django\db\backends\oracle\base.py", 
> line 510, in execute
> return self.cursor.execute(query, self._param_generator(params))
> cx_Oracle.DatabaseError: ORA-00907: missing right parenthesis
>
> The above exception was the direct cause of the following exception:
>
> Traceback (most recent call last):
>   File "C:\Python37-32\lib\site-packages\django\db\migrations\recorder.py", 
> line 67, in ensure_schema
> editor.create_model(self.Migration)
>   File "C:\Python37-32\lib\site-packages\django\db\backends\base\schema.py", 
> line 307, in create_model
> self.execute(sql, params or None)
>   File "C:\Python37-32\lib\site-packages\django\db\backends\base\schema.py", 
> line 137, in execute
> cursor.execute(sql, params)
>   File "C:\Python37-32\lib\site-packages\django\db\backends\utils.py", line 
> 99, in execute
> return super().execute(sql, params)
>   File "C:\Python37-32\lib\site-packages\django\db\backends\utils.py", line 
> 67, in execute
> return self._execute_with_wrappers(sql, params, many=False, 
> executor=self._execute)
>   File "C:\Python37-32\lib\site-packages\django\db\backends\utils.py", line 
> 76, in _execute_with_wrappers
> return executor(sql, params, many, context)
>   File "C:\Python37-32\lib\site-packages\django\db\backends\utils.py", line 
> 84, in _execute
> return self.cursor.execute(sql, params)
>   File "C:\Python37-32\lib\site-packages\django\db\utils.py", line 89, in 
> __exit__
> raise dj_exc_value.with_traceback(traceback) from exc_value
>   File "C:\Python37-32\lib\site-packages\django\db\backends\utils.py", line 
> 82, in _execute
> return self.cursor.execute(sql)
>   File "C:\Python37-32\lib\site-packages\django\db\backends\oracle\base.py", 
> line 510, in execute
> return self.cursor.execute(query, self._param_generator(params))
> django.db.utils.DatabaseError: ORA-00907: missing right parenthesis
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>   File "manage.py", line 21, in 
> main()
>   File "manage.py", line 17, in main
> execute_from_command_line(sys.argv)
>   File "C:\Python37-32\lib\site-packages\django\core\management\__init__.py", 
> line 381, in execute_from_command_line
> utility.execute()
>   File "C:\Python37-32\lib\site-packages\django\core\management\__init__.py", 
> line 375, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "C:\Python37-32\lib\site-packages\django\core\management\base.py", 
> line 323, in run_from_argv
> self.execute(*args, **cmd_options)
>   File "C:\Python37-32\lib\site-packages\django\core\management\base.py", 
> line 364, in execute
> output = self.handle(*args, **options)
>   File "C:\Python37-32\lib\site-packages\django\core\management\base.py", 
> line 83, in wrapped
> res = handle_func(*args, **kwargs)
>   File 
> "C:\Python37-32\lib\site-packages\django\core\management\commands\migrate.py",
>  line 234, in handle
> fake_initial=fake_initial,
>   File "C:\Python37-32\lib\site-packages\django\db\migrations\executor.py", 
> line 91, in migrate
> self.recorder.ensure_schema()
>   File "C:\Python37-32\lib\site-packages\django\db\migrations\recorder.py", 
> line 69, in ensure_schema
> raise MigrationSchemaMissing("Unable to create the django_migrations 
> table (%s)" % exc)
> django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the 
> django_migrations table (ORA-00907: missing right parenthesis)
>
> --
> 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/dac2cda6-2543-4664-aea5-025473ecc3e5%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed 

Simplifying code with multiple loops and logic, into queryset aggregates

2019-04-30 Thread Joel Mathew
My models:


class customer(models.Model):
cstid = models.AutoField(primary_key=True, unique=True)
insurance_number = models.CharField(max_length=100, blank=True, null=True)
name = models.CharField(max_length=35)
ageyrs = models.IntegerField(blank=True)

class Admission(models.Model):
id = models.AutoField(primary_key=True, unique=True)
clinic = models.ForeignKey(Clinic, on_delete=models.CASCADE)
customer = models.ForeignKey(customer, on_delete=models.CASCADE)
diagnosis = models.CharField(max_length=2000, default='', blank=True)
date_admission = models.DateTimeField(default=timezone.now)
ward = models.ForeignKey(Ward, on_delete=models.CASCADE)
bed = models.ForeignKey(Bed, on_delete=models.CASCADE)
discharged = models.BooleanField(default=False)
ip_number = models.IntegerField(blank=True)
ip_prefix = models.CharField(max_length=20, default='', blank=True)

My objective: Set a variable to a query filter, adding a property,
'is_admitted' to the queryset, so that I can pass this query set to the
template and use the property while displaying data.

Code:


def is_admitted(cust):
admission = Admission.objects.filter(customer=cust, discharged=False)
admission_results = len(admission)
if admission_results > 0:
return True
return False


my_q = or_q_if_truthfull(
cstid=HospitalID,
name__lower__contains=name.lower() if name else None,
ageyrs=ageyrs if ageyrs.isdigit() else None,
agemnths=agemnths if agemnths.isdigit() else None,
mobile__contains=mobile if mobile else None,
alternate__contains=alternate if alternate else None,
email__lower__contains=email.lower() if email else None,
address__lower__contains=address.lower() if address else None,
city__lower__contains=city.lower() if city else None
)
ORSearchResult = customer.objects.filter(my_q, linkedclinic=clinicobj)
cust_set = []
cust_admission_status = []
for cust in ORSearchResult:
cust_set.append(cust)
cust_admission_status.append(is_admitted(cust))
print(f"Customer name: {cust.name} Admission status: {is_admitted(cust)}")
cust_templ_set = zip(cust_set, cust_admission_status)

And in template, I will do:

{% for cust, status in cust_templ_set %}
{{ cust.name }} {{ status }}
{% endfor %}

I want to understand how I can convert my above code by generating an
aggregate over the queryset, so that I can use a property of the query, and
change the template code to the following, and avoid the loop in the view,
and the zip. So that the template code becomes:

{% for cust in customers %}
{{ cust.name }} {{ cust.status }}
{% endfor %}

I am not sure whether I am making complete sense, and can explain further.
Sincerely yours,

 Joel G Mathew

-- 
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_-8OUE5cd%3DZBahkLMTSTD%3DOXJbYenHjiB3ORGfkY9mSrQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Button Event

2019-04-30 Thread Joel Mathew
Templates expand into html. So you just write javascript like you normally
do. You call javascript from within your templates by using something like:



Here, I am using {% load static %}
Sincerely yours,

 Joel G Mathew



On Tue, 30 Apr 2019 at 12:05, Mayur Bagul  wrote:

> Thanks Ahmed,
>
> can you please provide me resource to learn  how to use java script and
> events in django Templates?
> Because im not getting proper resource how to use java script in django.
>
> Actually on one web page there will be one button after clicking on that
> button i want to merge another web page inside  current one.
> can you help me with that?
>
> Thanking you
>
>
>
>
>
>
> On Monday, April 29, 2019 at 11:03:35 PM UTC+5:30, Ahmed Ishtiaque wrote:
>>
>> Hi Mayur,
>>
>> I'm not sure what you mean by "there is no javascript in django" because
>> I use it all the time. JS is not tied to Django in any way since its
>> operations are usually client-side and so it can be used inside your Django
>> templates.
>>
>> In any case, you can have JS code in your template inside 

Re: More controls on createsuperuser

2019-04-30 Thread Joel Mathew
It's not the command that you should be worried about, but shell access to
your system. If your database server is secure, shell access is restricted,
and the server is also hardened reasonably, you should be relatively safe.
Sincerely yours,

 Joel G Mathew



On Tue, 30 Apr 2019 at 21:07, Mario R. Osorio  wrote:

> You'd only need editing the already existing management command and remove
> the possibility of using createsuperuser, but that is as useless as a
> ceiling fan on a motor bike.as anyone that already has access to the
> management code could just revert those changes. even continuing this
> thread is a waste of time.
>
> Dtb/Gby
> ===
> Mario R. Osorio
> B.A.S. of Information Technology
> Web page: *http;//mario.osorio.solutions
> *
> Email: *mario@osorio.solutions* 
> *Just Choose Python!* 
>
> *SQL programmers don't die, they just ROLLBACK the TRANSACTION.*
>
>
>
> On Tue, Apr 30, 2019 at 11:12 AM Chetan Ganji 
> wrote:
>
>> RE :"*someone could still run createsuperuser *"
>>
>> How do you suppose this is going to happen unless they have access to
>> your system?
>>
>> If you are really concerned about that?? django is basically a package.
>> Just find the source code for the creatsuperuser admin command and delete
>> that file if its the only command in that file ;-)
>> if not just delete that function only :) Its that simple.
>>
>> But How will you create a superuser after deleting the command from the
>> django package??
>>
>> One way to solve is write your own custom management command, create
>> superuser at the time of deployment and delete that custom command also.
>>
>> I hope this solves your problemo :)
>> Cheers!
>>
>>
>> Regards,
>> Chetan Ganji
>> +91-900-483-4183
>> ganji.che...@gmail.com
>> http://ryucoder.in
>>
>>
>> On Tue, Apr 30, 2019 at 6:09 PM Lipika Chandel 
>> wrote:
>>
>>> Hey,
>>> I am using Django 2.2 and I am stuck with the image upload functionality
>>> from admin site. I am not able to get the image on my template.
>>> Please help.
>>>
>>> Thanks & Regards
>>> LIPIKA CHANDEL
>>>
>>> On Tue, Apr 30, 2019 at 11:57 AM Jani Tiainen  wrote:
>>>
 I've have to agree that any attempt to limit superuser creation through
 manage.py is wrong solution to wrong problem.

 Even it's possible to attempt it it is as easy to circumvent.

 So do not give an access to manage.py to users that are not supposed
 to. Problem solved for good.

 ma 29. huhtik. 2019 klo 21.04  kirjoitti:

> Anyone capable of running the createsuperuser command on your project
> most probably has access to all and any of the project's files, specially
> your config file.
>
> Actually this user is either a valid su or you are in serious trouble
> because the security of your server sucks or you gave access to your
> project to the wrong person.
>
> So, no I don't think there is any point in doing so. Not because it
> can't be done but because it is both trivially useless.and uselessly
> trivial.
>
>
>
> On Sunday, April 28, 2019 at 11:24:57 PM UTC-4, JJ Zolper wrote:
>>
>> All,
>>
>> Curious what people think about more thought and control going into
>> who can run the createsuperuser method?
>>
>> For example say there's models that I don't want anyone to touch
>> except myself as a superuser. Is it not plausible that even if I make a
>> Django Group around that model that someone could still run 
>> createsuperuser
>> and give themselves the ability to have full control?
>>
>> Wouldn't it make sense if some random developer were to run
>> createsuperuser using django settings with any of the databases (as an
>> example) that it prevent them if say that email isn't on say an internal
>> list in the django admin of approved potential users?
>>
>> I see something like this being a good idea to prevent just anyone
>> from getting full control over the site without it being specifically
>> provided.
>>
>> Maybe there's something I'm missing something but been reading about
>> third party options and more about what's there and I just feel there's a
>> hole when it comes to who can create a super user account. Obviously you
>> could have a script that you run to initialize who is a super user, what
>> the groups are etc, but then you're basically recording personal
>> information somewhere when that should only be typed in.
>>
>> Open to ideas and thoughts, mostly just curious what could be a good
>> answer.
>>
>> Best,
>>
>> JJ
>>
> --
> 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.

Re: Simplifying code with multiple loops and logic, into queryset aggregates

2019-04-30 Thread Joel Mathew
Thank you Matthew. Excellent advise as always. When I started off with this
project 5 months ago, I was a beginner to both django and python. I've come
a bit along the journey. That customer model is the first model I created,
and I was unaware of these conventions. By the time I realized that, the
project has branched into several apps, and the code now runs into
thousands of lines of code. I didnt change the naming due to fear of
breaking other code. :)

Nowadays I do it more "pythonically". Still, it's great to have people like
you offer excellent general advise to help budding enthusiasts!

Sincerely yours,

 Joel G Mathew



On Tue, 30 Apr 2019 at 20:33, Matthew Pava  wrote:

> It was a little difficult to follow your message because the formatting is
> non-standard, but I think this might be what you’re looking for.
>
> Also, you should try to follow more Python coding conventions: models
> start with an upper case letter. Variables start with a lower case letter.
>
>
>
> And you probably want to use a QuerySet Manager on Customer. Maybe a query
> like this:
>
> Customer.objects.annotate(is_admitted=Case(When(admission_set__discharged=False,
> then=True), default=False).distinct()
>
>
>
>
>
> *From:* django-users@googlegroups.com [mailto:
> django-users@googlegroups.com] *On Behalf Of *Joel Mathew
> *Sent:* Tuesday, April 30, 2019 9:22 AM
> *To:* django-users@googlegroups.com
> *Subject:* Simplifying code with multiple loops and logic, into queryset
> aggregates
>
>
>
> My models:
>
>
>
> class customer(models.Model):
>
> cstid = models.AutoField(primary_key=True, unique=True)
>
> insurance_number = models.CharField(max_length=100, blank=True,
> null=True)
>
> name = models.CharField(max_length=35)
>
> ageyrs = models.IntegerField(blank=True)
>
>
>
> class Admission(models.Model):
>
> id = models.AutoField(primary_key=True, unique=True)
>
> clinic = models.ForeignKey(Clinic, on_delete=models.CASCADE)
>
> customer = models.ForeignKey(customer, on_delete=models.CASCADE)
>
> diagnosis = models.CharField(max_length=2000, default='', blank=
> True)
>
> date_admission = models.DateTimeField(default=timezone.now)
>
> ward = models.ForeignKey(Ward, on_delete=models.CASCADE)
>
> bed = models.ForeignKey(Bed, on_delete=models.CASCADE)
>
> discharged = models.BooleanField(default=False)
>
> ip_number = models.IntegerField(blank=True)
>
> ip_prefix = models.CharField(max_length=20, default='', blank=True
> )
>
>
>
> My objective: Set a variable to a query filter, adding a property,
> 'is_admitted' to the queryset, so that I can pass this query set to the
> template and use the property while displaying data.
>
>
>
> Code:
>
>
>
> def is_admitted(cust):
>
> admission = Admission.objects.filter(customer=cust, discharged=
> False)
>
> admission_results = len(admission)
>
> if admission_results > 0:
>
> return True
>
> return False
>
>
>
> my_q = or_q_if_truthfull(
>
> cstid=HospitalID,
>
> name__lower__contains=name.lower() if name else None,
>
> ageyrs=ageyrs if ageyrs.isdigit() else None,
>
> agemnths=agemnths if agemnths.isdigit() else None,
>
> mobile__contains=mobile if mobile else None,
>
> alternate__contains=alternate if alternate else None,
>
> email__lower__contains=email.lower() if email else None,
>
> address__lower__contains=address.lower() if address else None,
>
> city__lower__contains=city.lower() if city else None
>
> )
>
> ORSearchResult = customer.objects.filter(my_q, linkedclinic=clinicobj)
>
> cust_set = []
>
> cust_admission_status = []
>
> for cust in ORSearchResult:
>
> cust_set.append(cust)
>
> cust_admission_status.append(is_admitted(cust))
>
> print(f"Customer name: {cust.name} Admission status: {
> is_admitted(cust)}")
>
> cust_templ_set = zip(cust_set, cust_admission_status)
>
>
>
> And in template, I will do:
>
>
>
> {% for cust, status in cust_templ_set %}
>
> {{ cust.name }} {{ status }}
>
> {% endfor %}
>
>
>
> I want to understand how I can convert my above code by generating an
> aggregate over the queryset, so that I can use a property of the query,
> and change the template code to the following, and avoid the loop in the
> view, and the zip. So that the template code

Re: WYSIWYG/Rich Text Editor recommendations

2019-04-30 Thread Joel Mathew
Currently I'm using quill. It's easy to implement, and has all basic
features.
Sincerely yours,

 Joel G Mathew



On Wed, 1 May 2019 at 05:47, Tim Johnson  wrote:

> Using python 3.7.2 and django 2.1.5
>
> Production is in Ubuntu 16.04 and prospective deployment is likely
> to be CentOS with same python/django.
>
> I'm a retired python developer.
>
> I'd welcome recommendations and/or caveats regarding  a stable
> WYSIWIG "plugin".
>
> Much is available on google, but it is always edifying to hear
> individual comments.
>
> I currently publish on drupal using its ckeditor plugin. My common
> method is to compose articles in LibreOffice, then copy and paste
> into the editor. Works well, except that it IS drupal.
>
> I'd like to recreate the same functionality with django. I will need
> to be able to include embedded images.
>
> TIA
> --
> Tim
> http://www.tj49.com
>
> --
> 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/20190501001716.GD2404%40mail.akwebsoft.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_9GFDrj4DT%3DrZg8UMZeXLj7iG%2Bcz8moe_RNZNfNHkTE%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Anyone kind enough to help me understand these few concepts

2019-05-16 Thread Joel Mathew
I would suggest you go through the official tutorial. Your questions don't
have relation to django. It seems you're still at the concept/algorithm
level of your app.

In django, you put all your logic in your views, retrieve data from models
into views, and then pass the data from views to templates which display
the data.
Sincerely yours,

 Joel G Mathew



On Thu, 16 May 2019 at 22:02, DumbaClassics  wrote:

> I am still new on Django Web Framework and I want to understand the MVC
> concept based on this Project structure. Say I am trying to come up with an
> Online Gambling platform. Where exaclty do put the following;
>
> 1. say I want the player to randomly shuffle cards, is this whole business
> called on views.py or models or in models I just put a class related to
> creating my database?
> 2. say I want a player to have a ticket which is a receipt that can be
> picked randomly from those who have signed up for a draw. how exaclty do i
> have my clients get randomly generated receipts numbers using the
> random.randint module
> 3. Is there a possibility to generate a coin that is a local currency
> which enables players to buy them and then use the tokens for buying
> tickets into the game? If so how do i go about it in django python
>
> --
> 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/6658851f-f32c-42d4-bb04-7e00c0715a97%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_8P8wApcV57A5mkQNt0DADfdRMa-90vj%3DeYCwA2bjXXng%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: mod_wsgi problem

2019-06-06 Thread Joel Mathew
Always read installation README and github README before installing
anything. It seems you dont even have a basic compiler installed.

For Debian based systems, install:

`sudo apt install build-essential`
Sincerely yours,

 Joel G Mathew



On Thu, 6 Jun 2019 at 17:09, Davin Pore  wrote:

> how able to resolve this issue. I tried to install the mod_wsgi on manual
> procedure.
>
> [image: mod_wsgi.jpg]
>
> --
> 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/d56ff442-ac07-4328-a6b0-b4bee64095d5%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_9ngHcA-d1Me9uNfEiohxBcZLhWf6txj4%3Dm13QrOq8tKg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to create Different Graphs and PDF Reports

2019-06-24 Thread Joel Mathew
You can use reportlab for pdf generation

On Mon, 24 Jun, 2019, 9:18 PM Balaji Shetty,  wrote:

> HI
> can anyone suggest How to create Different Graphs and PDF Reports in
> Django Admin Panel itself which work on Models with relation.
> It there any library.
>
>
>
> --
>
>
> *Mr. Shetty Balaji S.Asst. ProfessorDepartment of Information Technology,*
> *SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.India*
> *Official: bsshe...@sggs.ac.in  *
> *  Mobile: +91-9270696267*
>
> --
> 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/CAECSbOvi0sAta%3Do%2BmBf%2BVTBbTcAU6ZmZZBvWKoaU1T4-TFf2jw%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/CAA%3Diw__%3DM6XKNwu40og2wtrUDtk87K4%3DdXFet8ytas4Sa1rybA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Unexpected behavior with icontains in query filter

2018-08-11 Thread Joel Mathew
This is what I got:

In [8]: doct = doctor.objects.filter(name__icontains = 'joel')
   ...: print(doct.query)

SELECT `appointments_doctor`.`docid`, `appointments_doctor`.`name`,
`appointments_doctor`.`username`, `appointments_doctor`.`regid`,
`appointments_doctor`.`photo`, `appointments_doctor`.`email`,
`appointments_doctor`.`phone`, `appointments_doctor`.`qualifications`,
`appointments_doctor`.`about`, `appointments_doctor`.`specialities`,
`appointments_doctor`.`department`, `appointments_doctor`.`fees`,
`appointments_doctor`.`displayfee`, `appointments_doctor`.`slotrange`,
`appointments_doctor`.`slotdurn`, `appointments_doctor`.`breakrange`,
`appointments_doctor`.`slotsleft` FROM `appointments_doctor` WHERE
`appointments_doctor`.`name` LIKE %joel%


Sincerely yours,

Dr Joel G Mathew



On 11 August 2018 at 11:25, Jason  wrote:
> Are you using sqlite for your db?  if so, there are some notes about case
> insensitive matching at
> https://docs.djangoproject.com/en/dev/ref/databases/#sqlite-string-matching
>
> otherwise, I'd be interested in seeing what your SQL is like
>
> in your django shell, do the following:
>
> doctors = Doctors.objects.filter(name__icontains = 'joel')
> print(doctors.query)
>
> It should have something like
>
> SELECT ... FROM ... WHERE name ILIKE  '%joel%';
>
> which should do the case insensitive search.
>
> Otherwise, this is a database issue, and not a django issue.  Django just
> converts the filter call to the appropriate SQL and has the db execute it.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/2b8dd9eb-b1ab-4eaf-ac17-4f03c1ed1c2c%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_8E0NcRCU142f6eRBTSrmuj9nrG2n8DSXV_-PaGAWwqyg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Unexpected behavior with icontains in query filter

2018-08-11 Thread Joel Mathew
This workaround works.

In [10]: from django.db.models.functions import Lower
In [11]: from django.db.models import CharField

In [12]: CharField.register_lookup(Lower, "lower")
Out[12]: django.db.models.functions.base.Lower

In [13]: doctor.objects.filter(name__lower__contains="joel")
Out[13]: , ]>

I'm eager to solve this strange behavior though.
Sincerely yours,

Dr Joel G Mathew



On 10 August 2018 at 17:17, Matthew Pava  wrote:
> I’m fascinated by this problem.
>
> Try this workaround.
>
> https://docs.djangoproject.com/en/2.0/ref/models/database-functions/#lower
>
>
>
> Register the lookup Lower like so:
>
> CharField.register_lookup(Lower, "lower")
>
>
>
> Then use the contains lookup.
>
> doctor.objects.filter(name__lower__contains="joel")
>
>
>
>
>
> From: django-users@googlegroups.com [mailto:django-users@googlegroups.com]
> On Behalf Of Joel
> Sent: Friday, August 10, 2018 10:56 AM
> To: Django users
> Subject: Unexpected behavior with icontains in query filter
>
>
>
> I'm trying to do a case insensitive search for a substring within a field in
> my model.
>
>
>
> My model:
>
>
>
>
>
> class doctor(models.Model):
> docid = models.AutoField(primary_key=True, unique=True) # Need
> autoincrement, unique and primary
> name = models.CharField(max_length=35)
> username = models.CharField(max_length=15)
> regid = models.CharField(max_length=15, default="", blank=True)
> photo = models.CharField(
> max_length=35, default="", blank=True)
> email = models.EmailField(default="", blank=True)
> phone = models.CharField(max_length=15)
> qualifications = models.CharField(
> max_length=50, default="", blank=True)
> about = models.CharField(
> max_length=35, default="", blank=True)
> specialities = models.CharField(
> max_length=50, default="", blank=True)
> department = models.CharField(max_length=50, default="ENT",
> blank=True)
> fees = models.FloatField(default=300.0)
> displayfee = models.IntegerField(default=0, blank=True)
> slotrange = models.CharField(max_length=50, blank=True)
> slotdurn = models.IntegerField(default=10)
> breakrange = models.CharField(
> max_length=50, default="", blank=True)
> slotsleft = models.CharField(
> max_length=50, default="", blank=True)
> def __str__(self):
> return self.name
> def Range(self):
> return self.slotrange
> def listslots(self):
> SlotRange = self.slotrange
> SlotDurn = self.slotdurn
> startime = SlotRange.split('-')[0]
> endtime = SlotRange.split('-')[1]
> sthr, stmin = SplitTimeString(startime)
> enhr, enmin = SplitTimeString(endtime)
> print(stamptoday(sthr, stmin))
> print(stamptoday(enhr, enmin))
> startstamp = stamptoday(sthr, stmin)
> endstamp = stamptoday(enhr, enmin)
> secdurn = SlotDurn*60
> slotlist = []
> for sec in range(startstamp, endstamp, secdurn):
> enttime = sec + secdurn
> myrange = ("%s - %s" % (HumanTime(sec),
> HumanTime(enttime)))
> slotlist.append(myrange)
> return slotlist
>
>
>
>
>
> Under the field 'name' in my mysql database, are two rows with values for
> name as 'Joel' and 'Jaffy Joel'.
>
>
>
> When I do the search like this:
>
>
>
>
>
> from appointments.models import customer, doctor, appointment
> doctor.objects.filter(name__icontains='joel')
>
>
>
>
>
> Output:
>
>
>
>
>
> 
>
>
>
>
>
> But when I do:
>
>
>
> doctor.objects.filter(name__icontains='Joel')
>
>
>
> Output:
>
>
>
>
>
>  , ]>
>
>
>
>
>
> Why isnt the case insensitive search working for a lowercase search?
>
>
>
> I'm on django 2.0.7
>
> --
> 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/46579c92-8a12-4977-814c-9c3fcaa14711%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/djan

Re: Convoluted setup information

2018-08-18 Thread Joel Mathew
You could perhaps provide more constructive advice by contributing to the
setup pages. I have written a small list of commands that I used for my
django setup, at
https://blog.droidzone.in/2018/08/17/create-virtualenv-with-python3/

I do this mostly to keep me from repeatedly reinventing the wheel.

Sincerely yours,

Dr Joel G Mathew


On 18 August 2018 at 23:35, akshay kanade  wrote:

> Mac OS
>
> Problems:
> So it’s pretty clear to me that one MUST install a virtual env before
> trying to run django.
> However the setup guide almost makes it sound like it’s optional.
>
> Why can’t the steps be mentioned clearly as also visually (and
> differentiate what’s essential and optional)?
>
> I figured out that I had two versions of python which was causing the
> issue. My guess is this is a common problem for everyone.
>
> I’m pretty sure if I hadn’t installed virtualenv there was no way I would
> be able to run django without first messing up the python version I already
> had installed
>
> Anyway, my point is that the setup guide assumes that people will
> understand that these problems will occur and somehow figure a way out. I
> just feel it can be simplified.
> As a first experience especially for beginners it’s not very encouraging.
>
> On Sat, 18 Aug 2018 at 11:28 PM, mottaz hejaze 
> wrote:
>
>> what is your operating system ?
>> what problems do you have
>>
>> On Sat, Aug 18, 2018 at 7:44 PM,  wrote:
>>
>>> Hi, I'm new to Django and I found the setup guide pretty useless. Had to
>>> refer to many articles on stackoverflow just to get basic django
>>> (+pip+python+virtualenv) installed.
>>> Why make it so complicated?
>>> Why not include screenshots?
>>>
>>> Also rather than pointing only to this group for help why not link to
>>> the best stackoverflow articles that cover the problems commonly faced by
>>> new users?
>>>
>>> --
>>> 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/025c7e3c-850f-439a-8b08-a3fdb5d44404%
>>> 40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Django users" group.
>> To unsubscribe from this topic, visit https://groups.google.com/d/
>> topic/django-users/9b3lT9PXjg8/unsubscribe.
>> To unsubscribe from this group and all its topics, 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/CAHV4E-fhnz1np4B4eEerok2x5WKDNABKRj2T
>> fPMNXbGXJbjqqQ%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/CAJ8hMtaCZHm4YdAXcSauwZwVAQVyb
> vd3Tg_kaZmThO-XWoA_Rg%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/CAA%3Diw_9Q-taV86EpQ7Lms2D8sJwC9eV3307O1i%3DSC4TOFmdNcA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Update data instead of creating a new row entry in django model

2018-08-26 Thread Joel Mathew
I have a page for editing existing data from a model.

The model:

class billitem(models.Model):
code = models.AutoField(primary_key=True, unique=True)
name = models.CharField(max_length=35)
description = models.CharField(max_length=60, null=True)
price = models.DecimalField(decimal_places=2, max_digits=8)

The form:

class BillItem(forms.Form):
code = forms.IntegerField(max_value=10, disabled=True)
name = forms.CharField(label='Item Name', max_length=32)
description = forms.CharField(
label='Description', max_length=57, required=False)
price = forms.DecimalField(decimal_places=2, max_digits=8)

The view is:

def edit_bill_item(request, itemcode):
if request.method == 'POST':
form = BillItem(request.POST)
code = request.POST.get('code')
name = request.POST.get('name').title()
description = request.POST.get('description')
price = request.POST.get('price')
billitem.objects.filter(code=code).update(
name=name, description=description, price=price)
msg = 'Successfully saved Billing item.'
# form = BillItem(request.POST)
return render(request, 'billing/edititem.html', {'form':
form, 'msg': msg})
else:
itemcode = int(itemcode)
item = get_object_or_404(billitem, code=itemcode)
form = BillItem(initial={
'code': item.code,
'name': item.name,
'description': item.description,
'price': item.price
})
return render(request, 'billing/edititem.html', {'form': form})

The problem is that every time POST is submitted, another entry gets
added in the table, with a new code, instead of updating existing row.

I also tried:

item = billitem(code=code, name=name, description=description, price=price)
item.save()

Which also had the same effect.
How can I handle updation of existing data only within my model and form.

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


Deploying with apache2 and modwsgi

2018-08-29 Thread Joel Mathew
After working with the development server for a month, I'm ready to
deploy to a VPS.
I've installed a debian9 environment and installed apache2 and
modwsgi. I'm having trouble editing the httpd.conf and apache wont
start with the added lines.

My project is at /home/joel/myappointments and the tree looks like this:
root@localhost:/home/joel/myappointments# tree -L 2
.
├── appointments
│   ├── admin.py
│   ├── apps.py
│   ├── forms.py
│   ├── migrations
│   ├── models.py
│   ├── __pycache__
│   ├── static
│   ├── templates
│   ├── tests.py
│   ├── urls.py
│   ├── using shell.txt
│   └── views.py
├── bugs.txt
├── db.sqlite3
├── django-todo.txt
├── manage.py
├── myappointments
│   ├── __init__.py
│   ├── middleware.py
│   ├── __pycache__
│   ├── settings.py
│   ├── settings.py~
│   ├── urls.py
│   └── wsgi.py
├── notebook.tex
├── propellor
│   ├── button.css
│   ├── floating-action-button.css
│   ├── materialicons.css
│   └── typography.css
├── README.md
├── requirements.txt
├── requirements.txt~
└── venv
├── bin
├── include
├── lib
└── pip-selfcheck.json

My apache conf is /home/joel/myappointments# cat
/etc/apache2/sites-enabled/000-default.conf:

# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf

WSGIScriptAlias / /home/joel/myappointments/myappointments/wsgi.py
WSGIPythonHome /home/joel/myappointments/venv
WSGIPythonPath /home/joel/myappointments



Require all granted





# vim: syntax=apache ts=4 sw=4 sts=4 sr noet


Can you tell me how to modify my apache conf file?

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


Re: new to django

2018-08-29 Thread Joel Mathew
There are two steps:
Install pip,
Use pip to install django

Follow the tutorial: https://docs.djangoproject.com/en/2.1/intro/install/

On Wed, 29 Aug 2018 at 16:46, sankar ardhas  wrote:
>
> Hi all,
>  I am a web developer in laravel and codeigniter php web frameworks. 
> I want to learn how to build web application  with django framework. I have 
> ubuntu platform in my comuputer. I want installation steps for django and 
> example also .. Can you help me?
>
> --
> 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/18094a65-7e19-4f8d-8376-69174ee4c4cb%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_-FGJGPxcEgQjoVvFpRVqAi1aJgun%3DJqw0bKr0b7cKw4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Deploying with apache2 and modwsgi

2018-08-29 Thread Joel Mathew
I get this:

Aug 29 12:24:52 localhost systemd[1]: Starting The Apache HTTP Server...
Aug 29 12:24:52 localhost apachectl[12718]: AH00526: Syntax error on
line 31 of /etc/apache2/sites-enabled/000-default.conf:
Aug 29 12:24:52 localhost apachectl[12718]: WSGIPythonHome cannot
occur within  section
Aug 29 12:24:52 localhost apachectl[12718]: Action 'start' failed.
Aug 29 12:24:52 localhost apachectl[12718]: The Apache error log may
have more information.
Aug 29 12:24:52 localhost systemd[1]: apache2.service: Control process
exited, code=exited status=1
Aug 29 12:24:52 localhost systemd[1]: Failed to start The Apache HTTP Server.
Aug 29 12:24:52 localhost systemd[1]: apache2.service: Unit entered
failed state.
Aug 29 12:24:52 localhost systemd[1]: apache2.service: Failed with
result 'exit-code'.

On Wed, 29 Aug 2018 at 17:12, Jason  wrote:
>
> just to cnfirm, are you using mod_wsgi3 for python3?
>
> and what do you get when you run apachectl configtest
>
> --
> 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/f290afe5-bd7c-467c-890b-e0faef16ad03%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_-CWV%3DpTUU%2B5FZ6LoUks1foHyfW43yF49FwO%2BZQvgiYPg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Deploying with apache2 and modwsgi

2018-08-29 Thread Joel Mathew
I surmised as much. But where does it go? Do you have a full working
configuration of the conf file?


On Wed, 29 Aug 2018 at 19:17, Jason  wrote:
>
> well, that's self-explainatory.  you have a bad config because that 
> WSGIPythonHome directive can't exist inside a VirtualHost section.
>
> On Wednesday, August 29, 2018 at 9:36:20 AM UTC-4, Joel wrote:
>>
>> I get this:
>>
>> Aug 29 12:24:52 localhost systemd[1]: Starting The Apache HTTP Server...
>> Aug 29 12:24:52 localhost apachectl[12718]: AH00526: Syntax error on
>> line 31 of /etc/apache2/sites-enabled/000-default.conf:
>> Aug 29 12:24:52 localhost apachectl[12718]: WSGIPythonHome cannot
>> occur within  section
>> Aug 29 12:24:52 localhost apachectl[12718]: Action 'start' failed.
>> Aug 29 12:24:52 localhost apachectl[12718]: The Apache error log may
>> have more information.
>> Aug 29 12:24:52 localhost systemd[1]: apache2.service: Control process
>> exited, code=exited status=1
>> Aug 29 12:24:52 localhost systemd[1]: Failed to start The Apache HTTP Server.
>> Aug 29 12:24:52 localhost systemd[1]: apache2.service: Unit entered
>> failed state.
>> Aug 29 12:24:52 localhost systemd[1]: apache2.service: Failed with
>> result 'exit-code'.
>>
>> On Wed, 29 Aug 2018 at 17:12, Jason  wrote:
>> >
>> > just to cnfirm, are you using mod_wsgi3 for python3?
>> >
>> > and what do you get when you run apachectl configtest
>> >
>> > --
>> > You received this message because you are subscribed to the Google Groups 
>> > "Django users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send an 
>> > email to django-users...@googlegroups.com.
>> > To post to this group, send email to django...@googlegroups.com.
>> > Visit this group at https://groups.google.com/group/django-users.
>> > To view this discussion on the web visit 
>> > https://groups.google.com/d/msgid/django-users/f290afe5-bd7c-467c-890b-e0faef16ad03%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/9f2d7bed-9eb4-4bfa-bdee-5e1e5c52f6a6%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__Ko31H3pr9_rqm3-S_1LzvdXQ5gR6BgtH5J4hxeazWYA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Deploying with apache2 and modwsgi

2018-08-30 Thread Joel Mathew
I finally got it working with mod_wsgi-express. I was able to get my
django project running on port 80.
However I have a new problem. The page starts loading, but takes a
very long time to load static files. If I hit refresh in the browser,
it gives a 503 error. There's nothing in apache logs. The
mod_wsgi-express page says there's a log file created in server root.
However I was unable to find it to trace the issue.
On another note, is this the right place to ask these doubts regarding
deploying django on the server? Or is there a better usergroup?

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


Cannot find static files when using mod_wsgi and apache

2018-08-31 Thread Joel Mathew
I'm having trouble getting serving static files.

My project is at /home/joel/myappointments
The app is at /home/joel/myappointments/appointments

An example template contains:


myappointments/myappointments/settings.py contains:
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static/")

]
STATIC_URL = '/static/'
STATIC_ROOT = '/home/joel/myappointments/static/'
#'/home/joel/myappointments/appointments/static/'

I've tried different options. The present option is after creating
/home/joel/myappointments/static/ and running
python3 manage.py collectstatic

While running the application with:
(venv) root@localhost:/home/joel/myappointments# mod_wsgi-express
start-server wsgi.py --host myopip.com --user www-data --group
www-data --port 80

I get links like:
http://mysite.com/static/appointments/propellor/typography.css
which are broken.
If I use the development server, it all works.

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


Error with file paths using mod_wsgi-express

2018-09-01 Thread Joel Mathew
If I run mod_wsgi-express from within the directory
/home/joel/myappointments, with the command:
mod_wsgi-express start-server --document-root ./htdocs wsgi.py --user
www-data --group www-data --port 80 --host myopip.com

It works fine. Everything loads. static files load correctly. But of
course this is terminated along with the shell.

However if I setup the script with:
mod_wsgi-express setup-server --document-root
/home/joel/myappointments/htdocs /home/joel/myappointments/wsgi.py
--user www-data --gro www-data --port 80 --host myopip.com

and then start it with:
/etc/mod_wsgi-express-80/apachectl start

Then, static files are not being loaded.
How can I fix this issue?

-- 
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_-kY%2B-3Lzwo%3DqL5Rp0B8E9-3Q7eUdp8rPDy7TAgwtK-4Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


mod_wsgi-express and letsencrypt

2018-09-05 Thread Joel Mathew
Has anyone used mod_wsgi-express with letsencrypt certificates on apache2?

On running mod_wsgi-express like this:

mod_wsgi-express start-server --log-to-terminal --startup-log
--https-port 443 --https-only --server-name mysite.com
--ssl-certificate-file ssl-certs/fullchain.pem
--ssl-certificate-key-file ssl-certs/privkey.pem
--ssl-ca-certificate-file ssl-certs/chain.pem --user www-data --group
www-data --port 80 --host mysite.com

Error:
[Thu Sep 06 00:54:01.900285 2018] [ssl:error] [pid 20491:tid
140457738499840] [client 111.92.31.10:18017] AH02261: Re-negotiation
handshake failed
[Thu Sep 06 00:54:02.182394 2018] [ssl:error] [pid 20491:tid
140457738233600] [client 111.92.31.10:9803] AH02261: Re-negotiation
handshake failed
[Thu Sep 06 00:54:02.182636 2018] [ssl:error] [pid 20491:tid
140457738233600] SSL Library Error: error:1417C0C7:SSL
routines:tls_process_client_certificate:peer did not return a
certificate -- No CAs known to server for verification?


Joel G Mathew

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


How do I make a field optional to enter, in a django ModelForm?

2018-09-12 Thread Joel Mathew
Scenario:
I instantiate a ModelForm and pass it to a template which displays the
form. When POST is submitted, code tries to search the database by any
of the given inputs. I dont require all inputs to be entered as in the
Model. I just need one (or more, if user desires to do an AND search)
to be entered.

Question: How can I make any of the ModelForm fields optional, where
in the Model, the field isnt optional. The field isnt optional in the
Model because I have another ModelForm based on the same Model, where
user is required to enter all his details.

My model:

class customer(models.Model):
# Need autoincrement, unique and primary
cstid = models.AutoField(primary_key=True, unique=True)
name = models.CharField(max_length=35)
age=models.IntegerField()
gender_choices = (('male', 'Male'),
('female', 'Female'))
gender = models.CharField(
choices=gender_choices, max_length=10, default='male')
maritalstatus_choices = ( ('married', 'Married'),
('unmarried', 'Unmarried'))
maritalstatus = models.CharField(
choices=maritalstatus_choices, max_length=10, default='Unmarried')
mobile = models.CharField(max_length=15, default='')
alternate = models.CharField(max_length=15, default='')
email = models.CharField(max_length=50, default='', blank=True)
address = models.CharField(max_length=80, default='', blank=True)
city = models.CharField(max_length=25, default='', blank=True)
occupation = models.CharField(max_length=25, default='', blank=True)
bloodgroup_choices = (('apos', 'A+'),
('aneg', 'A-'),
('bpos', 'B+'),
('bneg', 'B-'),
('opos', 'O+'),
('oneg', 'O-'),
('abpos', 'AB+'),
('abneg', 'AB-'),
('unspecified', '-')
)
bloodgroup = models.CharField(choices=bloodgroup_choices,
max_length=3, default='-', blank=True)
class Meta:
unique_together = ["name", "mobile", "age"]
def __str__(self):
return self.name

My form:

class CheckinPatientMetaForm(ModelForm):
class Meta:
model = customer
exclude = [
'gender',
'maritalstatus',
'occupation',
'bloodgroup'
]

views.py:

def checkin_patient(request):
results = ''
if request.method == 'POST':
form = CheckinPatientMetaForm(request.POST)
print("POST data",request.POST)
else:
form = CheckinPatientMetaForm()
return render(request, 'clinic/checkin.html', {'rnd_num':
randomnumber(), 'form': form, 'SearchResults': results})

Joel G Mathew

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


How can I display an AutoField in a ModelForm?

2018-09-12 Thread Joel Mathew
Question: How can I display an AutoField in a ModelForm. I have a need
where a Form is generated and displayed. Based on the input, I need to
read the AutoField's value and search for it in my database.

My form:

class CheckinPatientMetaForm(ModelForm):
class Meta:
model = customer
exclude = [
'gender',
'maritalstatus',
'occupation',
'bloodgroup'
]

My model:

class customer(models.Model):
# Need autoincrement, unique and primary
cstid = models.AutoField(primary_key=True, unique=True)
name = models.CharField(max_length=35)
age=models.IntegerField()
gender_choices = (('male', 'Male'),
('female', 'Female'))
gender = models.CharField(
choices=gender_choices, max_length=10, default='male')
maritalstatus_choices = ( ('married', 'Married'),
('unmarried', 'Unmarried'))
maritalstatus = models.CharField(
choices=maritalstatus_choices, max_length=10, default='Unmarried')
mobile = models.CharField(max_length=15, default='')
alternate = models.CharField(max_length=15, default='')
email = models.CharField(max_length=50, default='', blank=True)
address = models.CharField(max_length=80, default='', blank=True)
city = models.CharField(max_length=25, default='', blank=True)
occupation = models.CharField(max_length=25, default='', blank=True)
bloodgroup_choices = (('apos', 'A+'),
('aneg', 'A-'),
('bpos', 'B+'),
('bneg', 'B-'),
('opos', 'O+'),
('oneg', 'O-'),
('abpos', 'AB+'),
('abneg', 'AB-'),
('unspecified', '-')
)
bloodgroup = models.CharField(choices=bloodgroup_choices,
max_length=3, default='-', blank=True)
class Meta:
unique_together = ["name", "mobile", "age"]
def __str__(self):
return self.name

views.py:

def checkin_patient(request):
results = ''
if request.method == 'POST':
form = CheckinPatientMetaForm(request.POST)
print("POST data",request.POST)
else:
form = CheckinPatientMetaForm()
return render(request, 'clinic/checkin.html', {'rnd_num':
randomnumber(), 'form': form, 'SearchResults': results})

Relevant part of my template:


{% csrf_token %}


Hospital ID
{{ form.cstid|add_class:"form-control" }}




Name
{{ form.name|add_class:"form-control" }}




Age
{{ form.age|add_class:"form-control" }}


Email
{{ form.email|add_class:"form-control" }}




Mobile
{{ form.mobile|add_class:"form-control" }}

mobile

Alternate
{{ form.alternate|add_class:"form-control" }}




Address
{{ form.address|add_class:"form-control" }}

address



City
{{ form.city|add_class:"form-control" }}







The generated html:





Hospital ID




Name





Age



Email





Mobile


mobile

Alternate





Address


address



City








As you can see, there is not input field for cstid. In the actual
model, it's an automatic field. But in the ModelForm it needs to be a
form input so I can search for a patient's hospitalid (which is this
automatic field). How can I display this field in the form?

Joel G Mathew

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

Recreate all tables in mysql after dropping the database

2018-09-16 Thread Joel Mathew
I tried to fix mysql problems in my database by dropping tables. When that
didnt work, I dropped the database.
I then recreated the database, and tried to run makemigrations. But I am
getting errors about missing tables:

joel@hp:~/myappointments$ python3 manage.py makemigrations
Traceback (most recent call last):
  File
"/home/joel/.local/lib/python3.6/site-packages/django/db/backends/utils.py",
line 85, in _execute
return self.cursor.execute(sql, params)
  File
"/home/joel/.local/lib/python3.6/site-packages/django/db/backends/mysql/base.py",
line 71, in execute
return self.cursor.execute(query, args)
  File "/home/joel/.local/lib/python3.6/site-packages/MySQLdb/cursors.py",
line 250, in execute
self.errorhandler(self, exc, value)
  File
"/home/joel/.local/lib/python3.6/site-packages/MySQLdb/connections.py",
line 50, in defaulterrorhandler
raise errorvalue
  File "/home/joel/.local/lib/python3.6/site-packages/MySQLdb/cursors.py",
line 247, in execute
res = self._query(query)
  File "/home/joel/.local/lib/python3.6/site-packages/MySQLdb/cursors.py",
line 412, in _query
rowcount = self._do_query(q)
  File "/home/joel/.local/lib/python3.6/site-packages/MySQLdb/cursors.py",
line 375, in _do_query
db.query(q)
  File
"/home/joel/.local/lib/python3.6/site-packages/MySQLdb/connections.py",
line 276, in query
_mysql.connection.query(self, query)
_mysql_exceptions.ProgrammingError: (1146, "Table
'appointmentsdj.appointments_doctor' doesn't exist")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 15, in 
execute_from_command_line(sys.argv)
  File
"/home/joel/.local/lib/python3.6/site-packages/django/core/management/__init__.py",
line 381, in execute_from_command_line
utility.execute()
  File
"/home/joel/.local/lib/python3.6/site-packages/django/core/management/__init__.py",
line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File
"/home/joel/.local/lib/python3.6/site-packages/django/core/management/base.py",
line 316, in run_from_argv
self.execute(*args, **cmd_options)
  File
"/home/joel/.local/lib/python3.6/site-packages/django/core/management/base.py",
line 350, in execute
self.check()
  File
"/home/joel/.local/lib/python3.6/site-packages/django/core/management/base.py",
line 379, in check
include_deployment_checks=include_deployment_checks,
  File
"/home/joel/.local/lib/python3.6/site-packages/django/core/management/base.py",
line 366, in _run_checks
return checks.run_checks(**kwargs)
  File
"/home/joel/.local/lib/python3.6/site-packages/django/core/checks/registry.py",
line 71, in run_checks
new_errors = check(app_configs=app_configs)
  File
"/home/joel/.local/lib/python3.6/site-packages/django/core/checks/urls.py",
line 40, in check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
  File
"/home/joel/.local/lib/python3.6/site-packages/django/core/checks/urls.py",
line 57, in _load_all_namespaces
url_patterns = getattr(resolver, 'url_patterns', [])
  File
"/home/joel/.local/lib/python3.6/site-packages/django/utils/functional.py",
line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
  File
"/home/joel/.local/lib/python3.6/site-packages/django/urls/resolvers.py",
line 533, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns",
self.urlconf_module)
  File
"/home/joel/.local/lib/python3.6/site-packages/django/utils/functional.py",
line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
  File
"/home/joel/.local/lib/python3.6/site-packages/django/urls/resolvers.py",
line 526, in urlconf_module
return import_module(self.urlconf_name)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in
import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 994, in _gcd_import
  File "", line 971, in _find_and_load
  File "", line 955, in _find_and_load_unlocked
  File "", line 665, in _load_unlocked
  File "", line 678, in exec_module
  File "", line 219, in
_call_with_frames_removed
  File "/home/joel/myappointments/myappointments/urls.py", line 21, in

path('appointments/', include('appointments.urls')),
  File "/home/joel/.local/lib/python3.6/site-packages/django/urls/conf.py",
line 34, in include
urlconf_module = import_module(urlconf_module)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in
import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 994, in _gcd_import
  File "", line 971, in _find_and_load
  File "", line 955, in _find_and_load_unlocked
  File "", line 665, in _load_unlocked
  File "", line 678, in exec_module
  File "", line 219, in
_call_with_frames_removed
  File "/home/joel/myappointments/appointments/urls.py", line 3, in 
from . import views
  File "/home/joel/myappointments/appointments/views.py", line 6, in

from .forms 

Creating urls

2018-09-17 Thread Joel Mathew
I have a project named myappointments, which has two apps, clinic and
appointments. As of now, I am using the following urls in clinic.urls:

path('newclinic', views.newclinic, name="newclinic"),
path('/', views.clinic_home, name="clinic_home"),
path('/doctors', views.doctorlist, name="doctorlist"),
path('permissions', views.set_perms, name="set_perms"),

So I can access a url mysite.com/clinic/newclinic and
mysite.com/clinic/otherclinic/doctors
I want to call a view in clinic when a direct url is called.
Eg. When I visit mysite.com/newclinic and mysite.com/otherclinic/doctors, I
need the clinic.view to be called at the appropriate function.
I tried the following in myappointments.urls:

urlpatterns = [
path('admin/', admin.site.urls),
path('appointments/', include('appointments.urls')),
path('clinic/', include('clinic.urls')),
path('', include('appointments.urls')),
path('newclinic', clinic.views.newclinic, name="newclinic"),
path('/', clinic.views.clinic_home, name="clinic_home"),
path('/doctors', clinic.views.doctorlist, name="doctorlist"
),
path('permissions', clinic.views.set_perms, name="clinic_set_perms"),
]

But I get the error:
  File "/home/joel/myappointments/myappointments/urls.py", line 24, in

path('newclinic', clinic.views.newclinic, name="newclinic"),
NameError: name 'clinic' is not defined

I also tried within myappointments.urls:
urlpatterns = [
path('admin/', admin.site.urls),
path('appointments/', include('appointments.urls')),
path('clinic/', include('clinic.urls')),
path('', include('appointments.urls')),
path('newclinic', include('clinic.urls')),
path('/', include('clinic.urls')),
path('/doctors', include('clinic.urls')),
path('permissions', include('clinic.urls')),
]

But that caused some weird behavior.
What's the proper way to do this?
Sincerely yours,

Joel G Mathew

-- 
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_8_8CAA4J7T%2Bx%3DZRXgxeqG%2BbxM3AnJsGi6oU%3DicW8rygw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to get the name and url of an uploaded file when using models.FileField

2018-09-18 Thread Joel Mathew
How to get the name and url of an uploaded file?

I am using the following files:

settings.py:

MEDIA_URL = '/data/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'data')

urls.py:
urlpatterns = [
path("photo/upload", views.upload_pic, name="uploadpic ")
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

models.py:

class Pic(models.Model):
name = models.CharField(max_length=255)
photo = models.FileField(upload_to="data/media/%Y/%m/%d")
def __str__(self):
return self.url
def path(self):
return self.url

forms.py:

from django import forms
class DocumentForm(forms.Form):
docfile = forms.FileField(
label='Select a file',
help_text='any valid file'
)

views.py:

def upload_pic(request):
documents = Pic.objects.all()
import uuid
name = uuid.uuid4().hex[:6].upper()
if request.method == 'POST':
form = DocumentForm(request.POST, request.FILES)
if form.is_valid():
print(request.FILES)
newdoc = Pic(name=name, photo=request.FILES['docfile'])
newdoc.save()
return render(request, 'clinic/list.html', {'documents':
documents, 'form': form, 'msg': 'success'})
else:
form = DocumentForm()  # A empty, unbound form
return render(request, 'clinic/list.html', {'documents': documents,
'form': form})

template: clinic/list.html

{% extends 'clinic/newbase.html' %}
{% load static %}
{% block content %}

{% csrf_token %}

Upload

{% if uploaded_file_url %}
File uploaded at: {{
uploaded_file_url }}
{% endif %}
Return to home
{% endblock %}

However in the rendered html, the urls are blank:























Select a file: max. 42
megabytes







How can I get the media name and url in the rendered template?

Sincerely yours,

Joel G Mathew

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


Re: How to add form field dynamically?

2018-09-26 Thread Joel Mathew
You would use jquery to create the button using the $(selector).html(code).
Since this doesnt fall within the scope of this django group, I wont
elaborate. If you know basic javascript and jquery, it should be easy.



On Wed, 26 Sep 2018 at 19:25, Django Lover  wrote:

> Then What is the solution please let HELP ME?? I know that it will done by
> Jquery but how? I dont Know
>
>
>
> On Wednesday, September 26, 2018 at 6:14:07 PM UTC+5:30, Joel wrote:
>>
>> I don't think django alone can help you here. You need to do that with
>> JavaScript.
>>
>> On Wed 26 Sep, 2018, 6:01 PM Django Lover,  wrote:
>>
>>> Hi joel Thank for response.
>>>
>>> *I want something like this-*
>>>
>>> [image: form.png]
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> 1- when I click on *add row* button a new Row (*No-2)* will
>>> create dynamically.
>>> 2- In the select *product/service* its an options dropdown. the option
>>> should have related *model data*(from table product and service list)
>>> 3-  when i save all records in the dynamic field save to the database.
>>>
>>>
>>> I hope it clear to you. but if you need more information please let me
>>> know i am glad to discuss with you.
>>>
>>> :)
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/768d0fb2-4155-40c3-b0fc-fc4dbd2ad553%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/2140d58d-fc8b-4dcf-9acd-d965afa46cbc%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_8%3D6wQ7kg0TshMDHEBnD7hPfRq65nERkOMO%3D4XoDZ%2BjAg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: hi friends i want admin page like this. it is a application form in university

2018-09-27 Thread Joel Mathew
This is a standard django admin page. You can just enable admin and add the
relevant models. I suggest you follow the django standard tutorials.




On Thu, 27 Sep 2018 at 16:42, Sudha Mohan  wrote:

>
> --
> 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/9a0c31aa-d5f9-4aa8-b81b-810aa0660d09%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_9gyrr_gH1-QCoRd%2BiSfp3Myry1wcajS12EdURZ5s%2BF%2BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django/mysite/polls tutorial error

2018-10-02 Thread Joel Mathew
Well, what does /home/gino/djangoDEV/mysite/polls/urls.py contain?




On Tue, 2 Oct 2018 at 18:55, 'ginost7' via Django users <
django-users@googlegroups.com> wrote:

> Hello
>
> I am trying the django/mysite/polls tutorial.
>
> After typing, actually copying and pasting this:
>
> from django.contrib import adminfrom django.urls import include, path
> urlpatterns = [
> path('polls/', include('polls.urls')),
> path('admin/', admin.site.urls),]
>
> Running this command ( i am using python 3)
>
> $ python3  manage.py runserver
>  I get the following error:
>
> raise ImproperlyConfigured(msg.format(name=self.urlconf_name))
> django.core.exceptions.ImproperlyConfigured: The included URLconf ' 'polls.urls' from
>  '/home/gino/djangoDEV/mysite/polls/urls.py'>' does not appear to have any 
> patterns in it.
>  If you see valid patterns in the file then the issue is probably caused by a 
> circular import.
>
> CAN ANYBODY tell me what IS WRONG???
>
> --
> 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/0b0f1750-24dd-4dd1-8658-f68e9156a911%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_9zkBBGFv9Fax3%3DbKMs2i6FDbbGUr%3D%2BDYcnX5P93hBztw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to migrate old database into new database using python script

2018-10-11 Thread Joel Mathew
Just import the old ones from sql and then modify the tables.
Sincerely yours,

Dr Joel G Mathew



On Thu, 11 Oct 2018 at 22:12, Mohammad Aqib  wrote:

> I know CLI commands to backup db and restore into another but in this case
> CLI would not work because previous db tables is different from new db
> tables.
>
> So, I have backup.sql file and need to read this file and dump the values
> into new db
>
> Or another option I know, is to connect server db and execute queries one
> by one. Which is very lengthy and horrible process.
>
> Is any other way to do this?
>
> On Thu, 11 Oct 2018, 10:03 pm Ryan Gedwill,  wrote:
>
>> Depending on the SQL distribution you're using, there should be a couple
>> tools to do this without python using a CLI command or a basic SQL script.
>>
>> If you need to do it in python, use a basic python library (again,
>> depends on your sql distribution) to connect to your database and execute
>> the SQL command to execute the file.
>>
>> I only remember how to do this in postgres specifically, but you happen
>> to be using postgres as well, I can help further.
>>
>> On Thu, Oct 11, 2018 at 5:03 AM Mohammad Shareef M 
>> wrote:
>>
>>> Create new database and Restore the backup file
>>>
>>> Thanks & Regards,
>>> Mahammad Shareef M
>>>  +919741482617
>>>  +971501340618
>>>  +971581756035
>>>
>>>
>>> On Thu, Oct 11, 2018 at 4:01 PM Mohammad Aqib 
>>> wrote:
>>>
 Hi All,
 I have a task to migrate all data into a new database using
 "backup.sql" file.
 How to write a Python script to do this task.

 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/CAOh93ncV9awh9Y6GCC72FCY4XUO2eOSBWpB-TKH_RRmOk_4vZA%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/CAPUAdBH1-wZeR3J%2BKFpFxnwQYWu3CsZxacoiPOOsv7VzqY3%2Brg%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/CALG8KeAXP%3DF4fzbV1PVMr0CyELHYr2pASRqZerDEt1%3DVbkX%2BSQ%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/CAOh93nedBas9h_s-5GdGpqV8EG0sNatAFkcz5NxeEsdVv%2BvczQ%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@googlegro

Re: How to save multiple model form in one template?

2018-10-13 Thread Joel Mathew
Could you kindly stop spamming your course details over over this
discussion group. It's not useful to the majority of us English speaking
people.




On Sat, 13 Oct 2018 at 20:41, Daniel Bojorge (Foros) 
wrote:

> Take a look to my course (in spanish) and go to the last CRUD, there I do
> a Master-Detail form, the detail form are many models
>
>  DJANGO 2.1  https://goo.gl/oeT5Sx
>
> El viernes, 7 de septiembre de 2018, 4:43:11 (UTC-6), Django Lover
> escribió:
>>
>>
>> I have one page, which I have to show three model form and three
>> different submit button for each.
>>
>> My question is how I can save these three form individually?
>>
>> FOLLOWING IS CODE:-
>>
>> **form.py**
>>
>>
>> class UserTaxesMultiForm(MultiModelForm):
>>form_classes = {
>>'user_tax_form': MyForm,
>>'user_discount_form': DiscountForm,
>>'user_shiping_form': ShipmentForm,
>>}
>>
>> *Note- myForm, DiscountForm, ShipmentForm are model forms. like
>> following-*
>>
>> class MyForm(forms.ModelForm):
>>prefix = 'tax'
>>class Meta:
>>model = StUserTaxDetails
>>fields = ('tax_name', 'tax_rate')
>>
>>tax_name = forms.CharField(max_length=10,
>> widget=forms.TextInput(),
>> required=True, label="tax name")
>>
>> tax_rate = forms.FloatField(required=True,  label="tax rate")
>>
>>
>> error_messages  = {
>>'required': _('fields are required.'),
>>}
>>
>> def clean_title(self):
>>return self.cleaned_data['tax_name']
>>
>> def clean(self):
>>tax_name = self.cleaned_data.get('tax_name')
>>tax_rate = self.cleaned_data.get('tax_rate')
>>
>> if not tax_name and not tax_rate:
>>raise forms.ValidationError(
>>self.error_messages['required'],
>>code='required',
>>)
>>return self.cleaned_data
>>
>> **view.py**
>> class AddTaxView(LoginRequiredMixin, CreateView):
>>template_name = 'invoices/add_tax.html'
>>form_class = UserTaxesMultiForm
>>success_url = '/add/tax/'
>>
>>*{WHAT IS THE CODE HERE FOR THE POST METHOD TO SAVE DATA ACORDING
>> DIFFRENT FORM SUBMIT} *
>>
>>
>>
>>
>> **HTML**
>>
>>
>>
>> 
>> {% form.user_tax_form%}
>>
>> 
>> 
>>
>> 
>> {% form.user_discount_form%}
>>
>> 
>> 
>>
>> 
>> {% form.user_shiping_form%}
>>
>> 
>> 
>>
>> PLEASE HELP
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/6643b26e-d00d-438d-9d24-d383c857fada%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_-QFgL1DEZMmYMzpZRUcr5aY%2BGCBv_dJJB%3DdgyRyJJwQQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django tables with check box and delete button

2018-10-16 Thread Joel Mathew
There's not much difference in doing this than what is standard practise.
You just create the regular fields, loop over the ones creating multiple
rows, assign unique name fields to each of them (you can use
{{for.counter}} for this). You then capture the request with
request.POST.getlist.




On Tue, 16 Oct 2018 at 13:27, Praveen Kumar  wrote:

> Hello,
>
> Is there any django standard ways of creating a table with check boxes and
> let the user to select multiple rows using check box and the delete?
>
> Appreciate if anyone can help to provide an example to achieve this.
>
> Thanks,
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+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/CAB0oX7_URdpMiwqxkGrQq5tJaxeP5bqSDOspUukfs7d4gO_Mow%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/CAA%3Diw__Y80aCy7FwKsoaGhgb88gr%3DvzWHnWHE4FELW%3DwBF3r%2BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


django username and password error

2018-10-17 Thread Joel Mathew
After attempting to redirect http to https by setting SECURE_SSL_REDIRECT
to True and a few other changes, suddenly I found myself locked out of
django login. It didnt accept my password, so I tried resetting it via
manage.py passwd and manage.py changepassword. I even created a new
superuser account and tried to login.

I am unable to login to django admin site and to the custom login which
used to work until yesterday night. I'm at a loss to think of what next to
check. Any ideas?


Joel G Mathew

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


Creating seperate unique ids within the same table

2018-10-17 Thread Joel Mathew
I have an application which is a clinic management software which allows
login into different clinics, and needs to keep patient records of each
clinic seperately. The patient records are filed in one common model, with
a ForeignKey referring to the clinic to which a patient belongs.

Hitherto I had used the AutoField primary key of the customer model as a
hospital identification number for the patient. This number is unique and
used throughout the application to retrieve querysets related to the
customer. My problem is this. I want each patient to have a unique
automatically incrementing id which can be given to them. Obviously since
all patient records (irrespective of which clinic the patient belongs to)
are stored in one model, the ids are not seperated by clinic. cstid 1 may
be of clinic 1, cstid 5 may again be of clinic 1, but cstid 6 may be of
clinic 2.

I need patients  of one clinic to have continuous ids unique to each
clinic. What can I do to achieve this, within my defined models?

class Clinic(models.Model):
clinicid = models.AutoField(primary_key=True, unique=True)
name = models.CharField(max_length=60, unique=True)
label = models.SlugField(max_length=25, unique=True)
email = models.EmailField(max_length=50, default='')
mobile = models.CharField(max_length=15, default='')
alternate = models.CharField(max_length=15, default='', blank=True)
about = models.CharField(max_length=250, blank=True)
state = models.CharField(max_length=25)
city = models.CharField(max_length=35)
locality = models.CharField(max_length=35)
pincode = models.IntegerField(default=0)
address = models.TextField(max_length=80, default='', blank=True)
website = models.URLField(blank=True)
logo = models.ForeignKey(ProfilePic, blank=True, null=True,
on_delete=models.CASCADE)
latitude = models.FloatField(blank=True)
longitude = models.FloatField(blank=True)
placeurl = models.URLField(blank=True)
class Meta:
unique_together = ["name", "mobile", "email"]
def __str__(self):
return self.name

class customer(models.Model):
# Need autoincrement, unique and primary
cstid = models.AutoField(primary_key=True, unique=True)
name = models.CharField(max_length=35)
age=models.IntegerField()
gender_choices = (
('male', 'Male'),
('female', 'Female'),
('other', 'Something else'),
('decline', 'Decline to answer'))
gender = models.CharField(
choices=gender_choices, max_length=10, default='male')
maritalstatus_choices = (
('unmarried', 'Unmarried'),
('married', 'Married'))
maritalstatus = models.CharField(
choices=maritalstatus_choices, max_length=10,
default='Unmarried')
mobile = models.CharField(max_length=15, default='')
alternate = models.CharField(max_length=15, default='', blank=True)
email = models.CharField(max_length=50, default='', blank=True)
address = models.CharField(max_length=80, default='', blank=True)
city = models.CharField(max_length=25, default='', blank=True)
occupation = models.CharField(max_length=25, default='', blank=True)
bloodgroup_choices = (('apos', 'A+'),
('aneg', 'A-'),
('bpos', 'B+'),
('bneg', 'B-'),
('opos', 'O+'),
('oneg', 'O-'),
('abpos', 'AB+'),
('abneg', 'AB-')
)
bloodgroup = models.CharField(choices=bloodgroup_choices,
max_length=5, default='-', blank=True)
linkedclinic = models.ForeignKey(Clinic, on_delete=models.CASCADE)
class Meta:
unique_together = ["name", "mobile", "age", "linkedclinic"]
def __str__(self):
return self.name

My thoughts are on counting the number of customer objects with specific
ForeignKey of a clinic, and then updating hospital id field in the same
model. But probably there's a more logical less tedious way of doing this?
Or should I be creating seperate tables for each clinic?

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


Re: Creating seperate unique ids within the same table

2018-10-17 Thread Joel Mathew
A hospital id needs to be assigned to a patient and printed on their id
card. When they present their card or this number, their records can be
retrieved at any time. A checkin id is additionally generated each day
based on the date and time. A patient can have only one patient id but many
checkin ids.

What can be a good approach to solve this? Should I perhaps create another
table just to store the last patient id issued to each clinic?




On Wed, 17 Oct 2018 at 21:49, Matthew Pava  wrote:

> A number is a number, and we don’t need to attach meaning to it.
>
> Why do you need to have continuous ids unique to each clinic?  As a
> developer, I would object to anyone forcing such a requirement.  If they
> insisted, then I would add a property that is calculated each time based on
> the count of patients in the clinic.
>
>
>
> *From:* django-users@googlegroups.com [mailto:
> django-users@googlegroups.com] *On Behalf Of *Joel Mathew
> *Sent:* Wednesday, October 17, 2018 11:01 AM
> *To:* django-users@googlegroups.com
> *Subject:* Creating seperate unique ids within the same table
>
>
>
> I have an application which is a clinic management software which allows
> login into different clinics, and needs to keep patient records of each
> clinic seperately. The patient records are filed in one common model, with
> a ForeignKey referring to the clinic to which a patient belongs.
>
>
>
> Hitherto I had used the AutoField primary key of the customer model as a
> hospital identification number for the patient. This number is unique and
> used throughout the application to retrieve querysets related to the
> customer. My problem is this. I want each patient to have a unique
> automatically incrementing id which can be given to them. Obviously since
> all patient records (irrespective of which clinic the patient belongs to)
> are stored in one model, the ids are not seperated by clinic. cstid 1 may
> be of clinic 1, cstid 5 may again be of clinic 1, but cstid 6 may be of
> clinic 2.
>
>
>
> I need patients  of one clinic to have continuous ids unique to each
> clinic. What can I do to achieve this, within my defined models?
>
>
>
> class Clinic(models.Model):
>
> clinicid = models.AutoField(primary_key=True, unique=True)
>
> name = models.CharField(max_length=60, unique=True)
>
> label = models.SlugField(max_length=25, unique=True)
>
> email = models.EmailField(max_length=50, default='')
>
> mobile = models.CharField(max_length=15, default='')
>
> alternate = models.CharField(max_length=15, default='', blank=True)
>
> about = models.CharField(max_length=250, blank=True)
>
> state = models.CharField(max_length=25)
>
> city = models.CharField(max_length=35)
>
> locality = models.CharField(max_length=35)
>
> pincode = models.IntegerField(default=0)
>
> address = models.TextField(max_length=80, default='', blank=True)
>
> website = models.URLField(blank=True)
>
> logo = models.ForeignKey(ProfilePic, blank=True, null=True,
> on_delete=models.CASCADE)
>
> latitude = models.FloatField(blank=True)
>
> longitude = models.FloatField(blank=True)
>
> placeurl = models.URLField(blank=True)
>
> class Meta:
>
> unique_together = ["name", "mobile", "email"]
>
> def __str__(self):
>
> return self.name
>
>
>
> class customer(models.Model):
>
> # Need autoincrement, unique and primary
>
> cstid = models.AutoField(primary_key=True, unique=True)
>
> name = models.CharField(max_length=35)
>
> age=models.IntegerField()
>
> gender_choices = (
>
> ('male', 'Male'),
>
> ('female', 'Female'),
>
> ('other', 'Something else'),
>
> ('decline', 'Decline to answer'))
>
> gender = models.CharField(
>
> choices=gender_choices, max_length=10, default='male')
>
> maritalstatus_choices = (
>
> ('unmarried', 'Unmarried'),
>
> ('married', 'Married'))
>
> maritalstatus = models.CharField(
>
> choices=maritalstatus_choices, max_length=10,
> default='Unmarried')
>
> mobile = models.CharField(max_length=15, default='')
>
> alternate = models.CharField(max_length=15, default='', blank=True)
>
> ema

Re: Creating seperate unique ids within the same table

2018-10-17 Thread Joel Mathew
Hi Phako,
Thank you. I'm already following this practise. I have the following
additional Model:

class Checkins(models.Model):
checkinno = models.AutoField(primary_key=True, unique=True)
hospitalid = models.ForeignKey(
customer, on_delete=models.CASCADE, null=True)
date = models.DateField(default=timezone.now)
time = models.CharField(max_length=25)
consulted = models.IntegerField(default=0)
closed = models.IntegerField(default=0)
linkedclinic = models.ForeignKey(Clinic, on_delete=models.CASCADE)

Right now, the program's policy allows any doctor of that clinic to
see a patient who checked in to that clinic, so doctor is not a
ForeignKey for this. But later I may need to add this too.

What would you suggest for adding a unique number which gets
incremented for each new patient registration, and unique to each
clinic?
Sincerely yours,

Dr Joel G Mathew



On Thu, 18 Oct 2018 at 09:00, Phako Perez <13.phak...@gmail.com> wrote:
>
> I suggest to use another table for visit so you can add which doctor, 
> schedule time, and comments or so as a patient may have 1 visit or n...
>
> Sent from my iPhone
>
> On Oct 17, 2018, at 9:59 PM, Joel Mathew  wrote:
>
> A hospital id needs to be assigned to a patient and printed on their id card. 
> When they present their card or this number, their records can be retrieved 
> at any time. A checkin id is additionally generated each day based on the 
> date and time. A patient can have only one patient id but many checkin ids.
>
> What can be a good approach to solve this? Should I perhaps create another 
> table just to store the last patient id issued to each clinic?
>
>
>
>
> On Wed, 17 Oct 2018 at 21:49, Matthew Pava  wrote:
>>
>> A number is a number, and we don’t need to attach meaning to it.
>>
>> Why do you need to have continuous ids unique to each clinic?  As a 
>> developer, I would object to anyone forcing such a requirement.  If they 
>> insisted, then I would add a property that is calculated each time based on 
>> the count of patients in the clinic.
>>
>>
>>
>> From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] 
>> On Behalf Of Joel Mathew
>> Sent: Wednesday, October 17, 2018 11:01 AM
>> To: django-users@googlegroups.com
>> Subject: Creating seperate unique ids within the same table
>>
>>
>>
>> I have an application which is a clinic management software which allows 
>> login into different clinics, and needs to keep patient records of each 
>> clinic seperately. The patient records are filed in one common model, with a 
>> ForeignKey referring to the clinic to which a patient belongs.
>>
>>
>>
>> Hitherto I had used the AutoField primary key of the customer model as a 
>> hospital identification number for the patient. This number is unique and 
>> used throughout the application to retrieve querysets related to the 
>> customer. My problem is this. I want each patient to have a unique 
>> automatically incrementing id which can be given to them. Obviously since 
>> all patient records (irrespective of which clinic the patient belongs to) 
>> are stored in one model, the ids are not seperated by clinic. cstid 1 may be 
>> of clinic 1, cstid 5 may again be of clinic 1, but cstid 6 may be of clinic 
>> 2.
>>
>>
>>
>> I need patients  of one clinic to have continuous ids unique to each clinic. 
>> What can I do to achieve this, within my defined models?
>>
>>
>>
>> class Clinic(models.Model):
>>
>> clinicid = models.AutoField(primary_key=True, unique=True)
>>
>> name = models.CharField(max_length=60, unique=True)
>>
>> label = models.SlugField(max_length=25, unique=True)
>>
>> email = models.EmailField(max_length=50, default='')
>>
>> mobile = models.CharField(max_length=15, default='')
>>
>> alternate = models.CharField(max_length=15, default='', blank=True)
>>
>> about = models.CharField(max_length=250, blank=True)
>>
>> state = models.CharField(max_length=25)
>>
>> city = models.CharField(max_length=35)
>>
>> locality = models.CharField(max_length=35)
>>
>> pincode = models.IntegerField(default=0)
>>
>> address = models.TextField(max_length=80, default='', blank=True)
>>
>> website = models.URLField(blank=True)
>>
>> logo = models.ForeignKey(ProfilePic, blank=True, null=True, 
>> on_delete=models.CASCADE)
>>
>> latitude 

Re: Creating seperate unique ids within the same table

2018-10-18 Thread Joel Mathew
Hi Matthew,
Yes, and I am using the id field to query the database for many
operations. But I do not want to share this id to the patient. The
reason is that the data of one clinic is supposed to be seperate from
another. If a patient visits another clinic using the same software,
yes, the software should generate a different id for that clinic. In
short, different ids for the same person in different clinics. Data
will not be shared between the clinics.

And no, they dont get a new card at each visit. Checkid is just used
internally to reference the data between the tables.

So how can I get a unique id for each customer per clinic? I thought
of getting the last id from the database and then incrementing one,
but that wouldnt work if the last customer was deleted. So I'm
thinking a seperate table to store the last generated hospital id, and
use this while creating a new customer record. And then incrementing
the id in the table. Is this the right approach? Is there a better
way?

To help understand what I mean, just check the GG ID printed on this
hospital card. This id can be memorized by the patient and his records
fetched and checked in.

https://imgur.com/bU4Bz8W

Sincerely yours,

Joel G Mathew


On Thu, 18 Oct 2018 at 19:01, Matthew Pava  wrote:
>
> Hi Dr Joel,
> Each patient already has a unique number--the id or pk of the 
> model--regardless of what clinic the patient goes to.  I even recommend 
> maintaining this structure.  Any other numbers you add to the ID are just 
> noise.  Besides, a patient could go to more than one clinic.  Would you want 
> to add the ID of all the clinics that they are associated with?
>
> If you want to see all the patients at a specific clinic, you could do 
> something like this:
> Customer.objects.filter(linkedclinic=[provided_clinic])
>
> With your new Checkins model, I’m thinking that hospitalid and linkedclinic 
> should be a OneToOne relation.  You could also combine date and time into one 
> field: a DateTimeField.  You can always split that apart for your UI.
> And each checkin also has its own ID, so you may want to use that to put on 
> the patient's card.  Do they get a new card every time they checkin?
>
>
> -Original Message-
> From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
> Behalf Of Joel Mathew
> Sent: Wednesday, October 17, 2018 10:41 PM
> To: django-users@googlegroups.com
> Subject: Re: Creating seperate unique ids within the same table
>
> Hi Phako,
> Thank you. I'm already following this practise. I have the following 
> additional Model:
>
> class Checkins(models.Model):
> checkinno = models.AutoField(primary_key=True, unique=True)
> hospitalid = models.ForeignKey(
> customer, on_delete=models.CASCADE, null=True)
> date = models.DateField(default=timezone.now)
> time = models.CharField(max_length=25)
> consulted = models.IntegerField(default=0)
> closed = models.IntegerField(default=0)
> linkedclinic = models.ForeignKey(Clinic, on_delete=models.CASCADE)
>
> Right now, the program's policy allows any doctor of that clinic to see a 
> patient who checked in to that clinic, so doctor is not a ForeignKey for 
> this. But later I may need to add this too.
>
> What would you suggest for adding a unique number which gets incremented for 
> each new patient registration, and unique to each clinic?
> Sincerely yours,
>
> Dr Joel G Mathew
>
>
>
> On Thu, 18 Oct 2018 at 09:00, Phako Perez <13.phak...@gmail.com> wrote:
> >
> > I suggest to use another table for visit so you can add which doctor, 
> > schedule time, and comments or so as a patient may have 1 visit or n...
> >
> > Sent from my iPhone
> >
> > On Oct 17, 2018, at 9:59 PM, Joel Mathew  wrote:
> >
> > A hospital id needs to be assigned to a patient and printed on their id 
> > card. When they present their card or this number, their records can be 
> > retrieved at any time. A checkin id is additionally generated each day 
> > based on the date and time. A patient can have only one patient id but many 
> > checkin ids.
> >
> > What can be a good approach to solve this? Should I perhaps create another 
> > table just to store the last patient id issued to each clinic?
> >
> >
> >
> >
> > On Wed, 17 Oct 2018 at 21:49, Matthew Pava  wrote:
> >>
> >> A number is a number, and we don’t need to attach meaning to it.
> >>
> >> Why do you need to have continuous ids unique to each clinic?  As a 
> >> developer, I would object to anyone forcing such a requirement.  If they 
> >> insisted, then I would add a property that is calculated each time based 
> >> on

Re: Creating seperate unique ids within the same table

2018-10-18 Thread Joel Mathew
That's a great idea! Thank you.

Joel G Mathew


On Thu, 18 Oct 2018 at 19:57, Matthew Pava  wrote:
>
> Hi Dr. Joel,
> In that case, I would add a function on the customer model that simply 
> concatenates the customer ID with the clinic ID.  I would avoid generating a 
> whole new table for this.
>
> def get_card_id(self, clinic):
> return f"{self.id}-{clinic.id}"
>
>
> -Original Message-
> From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
> Behalf Of Joel Mathew
> Sent: Thursday, October 18, 2018 9:19 AM
> To: django-users@googlegroups.com
> Subject: Re: Creating seperate unique ids within the same table
>
> Hi Matthew,
> Yes, and I am using the id field to query the database for many operations. 
> But I do not want to share this id to the patient. The reason is that the 
> data of one clinic is supposed to be seperate from another. If a patient 
> visits another clinic using the same software, yes, the software should 
> generate a different id for that clinic. In short, different ids for the same 
> person in different clinics. Data will not be shared between the clinics.
>
> And no, they dont get a new card at each visit. Checkid is just used 
> internally to reference the data between the tables.
>
> So how can I get a unique id for each customer per clinic? I thought of 
> getting the last id from the database and then incrementing one, but that 
> wouldnt work if the last customer was deleted. So I'm thinking a seperate 
> table to store the last generated hospital id, and use this while creating a 
> new customer record. And then incrementing the id in the table. Is this the 
> right approach? Is there a better way?
>
> To help understand what I mean, just check the GG ID printed on this hospital 
> card. This id can be memorized by the patient and his records fetched and 
> checked in.
>
> https://imgur.com/bU4Bz8W
>
> Sincerely yours,
>
> Joel G Mathew
>
>
> On Thu, 18 Oct 2018 at 19:01, Matthew Pava  wrote:
> >
> > Hi Dr Joel,
> > Each patient already has a unique number--the id or pk of the 
> > model--regardless of what clinic the patient goes to.  I even recommend 
> > maintaining this structure.  Any other numbers you add to the ID are just 
> > noise.  Besides, a patient could go to more than one clinic.  Would you 
> > want to add the ID of all the clinics that they are associated with?
> >
> > If you want to see all the patients at a specific clinic, you could do 
> > something like this:
> > Customer.objects.filter(linkedclinic=[provided_clinic])
> >
> > With your new Checkins model, I’m thinking that hospitalid and linkedclinic 
> > should be a OneToOne relation.  You could also combine date and time into 
> > one field: a DateTimeField.  You can always split that apart for your UI.
> > And each checkin also has its own ID, so you may want to use that to put on 
> > the patient's card.  Do they get a new card every time they checkin?
> >
> >
> > -Original Message-
> > From: django-users@googlegroups.com
> > [mailto:django-users@googlegroups.com] On Behalf Of Joel Mathew
> > Sent: Wednesday, October 17, 2018 10:41 PM
> > To: django-users@googlegroups.com
> > Subject: Re: Creating seperate unique ids within the same table
> >
> > Hi Phako,
> > Thank you. I'm already following this practise. I have the following 
> > additional Model:
> >
> > class Checkins(models.Model):
> > checkinno = models.AutoField(primary_key=True, unique=True)
> > hospitalid = models.ForeignKey(
> > customer, on_delete=models.CASCADE, null=True)
> > date = models.DateField(default=timezone.now)
> > time = models.CharField(max_length=25)
> > consulted = models.IntegerField(default=0)
> > closed = models.IntegerField(default=0)
> > linkedclinic = models.ForeignKey(Clinic, on_delete=models.CASCADE)
> >
> > Right now, the program's policy allows any doctor of that clinic to see a 
> > patient who checked in to that clinic, so doctor is not a ForeignKey for 
> > this. But later I may need to add this too.
> >
> > What would you suggest for adding a unique number which gets incremented 
> > for each new patient registration, and unique to each clinic?
> > Sincerely yours,
> >
> > Dr Joel G Mathew
> >
> >
> >
> > On Thu, 18 Oct 2018 at 09:00, Phako Perez <13.phak...@gmail.com> wrote:
> > >
> > > I suggest to use another table for visit so you can add which doctor, 
> > > schedule time, and comments or so as a pati

Re: generate username and password

2018-10-18 Thread Joel Mathew
newpassword = RandomPassword()
user = User.objects.create_user(username, email, newpassword)

Joel G Mathew

On Fri, 19 Oct 2018 at 06:55,  wrote:
>
> Bonjour! Je voudrais lorsqu'un utilisateur s'inscrit avec ses informations 
> personnelles puis soumet le formulaire, je lui génère un nom d'utilisateur et 
> un mot de passe qu'on envoie dans son mail fourni.
>
> --
> 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/ba2ee416-84fa-4688-a461-a482a3890175%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_9vUuxccVPiQngQPDh04EoCgkqOfTJoZRt3KtqzsZvkPQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: new to django

2018-10-18 Thread Joel Mathew
just purge and reinstall django


On Fri, 19 Oct 2018 at 08:14, Shubham Bajaj  wrote:
>
> I tried this but it showing no module found django.core
> Pls help me..
>
> On Fri 19 Oct, 2018, 6:37 AM satyam mishra,  wrote:
>>
>> just install all the necessary module needed, just open the location of 
>> project where you want your project located to be..for example if you want 
>> your project to be located in desktop then use cmd in cmd prompt 'cd 
>> desktop' then create your project by using the command ;django-admin 
>> startproject projectname
>>
>> On Thursday, October 18, 2018 at 2:51:02 PM UTC+5:30, shubham...@gmail.com 
>> wrote:
>>>
>>> "django-admin startproject mysite" i tried to run this in cmd propmt but it 
>>> is not working showing "django-admin' is not recognized as an internal or 
>>> external command," what to do?
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/d5574242-bfa6-4d42-a74c-18cab55b296a%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/CAMT57gi8y61x_XXgdM95P0BkQEp5-sLBdAC4qBn8jkjDbYy4cA%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/CAA%3Diw__1eS_JFh_X82v27%3DiDbt7cq4cy_yqSh6UeEO7x6ZGR%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How can I implement built in signals, for my app?

2018-10-21 Thread Joel Mathew
How to implement built in signals, for my app?

I have a project myappointments, with two apps appointments and clinic in it.

Objective:
When a user logins, details should be entered in the database.

appointments/models.py:

class Event(models.Model):
id=models.AutoField(primary_key=True, unique=True)
type=models.CharField(max_length=60)
description = models.CharField(max_length=150)
time = models.DateTimeField(default=timezone.now)

appointments/__init__.py:

default_app_config = 'appointments.apps.AppointmentsConfig'

appointments/apps.py:

from django.apps import AppConfig
class AppointmentsConfig(AppConfig):
name = 'appointments'
def ready(self):
import appointments.signals  # noqa

appointments/signals.py:

from django.contrib.auth.signals import user_logged_in
from django.dispatch import receiver
def record_loggedin(sender, user, request, **kwargs):
  ev = Event(type="Login", description = 'User logged in:
{}'.format(request.user.id))
  ev.save()
  print("User has logged in. Saved event to DB.")
  user_logged_in.connect(record_loggedin)

What other modifications do I need to do this?

- Joel G Mathew

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


Re: Creating seperate unique ids within the same table

2018-10-22 Thread Joel Mathew
Thank you Bill. I had a look at UUIDs. One of the important criteria I
had was that these IDs should be easily memorable. Unfortunately UUIDs
are not memorable, being too long to remember. :(

Sincerely yours,

Joel G Mathew


On Mon, 22 Oct 2018 at 19:40,  wrote:
>
> Hello all,
>
> The previous discussion shows a method that will work.  but I think it has 
> disadvantages, and I want to suggest  another approach.
>
> The disadvantage of using a primary key from a table, any table, is that you 
> are committing to that table and that primary key for all eternity.   this 
> has consequences for migration to another system , for merging in data from 
> an external system, among others.
>
> Joel, if I understand your situation, you have a "thing", an individual human 
> being, and you need a permanent, unique identifier for that "thing".  The 
> identifier should not be an implementation detail of your current code, but 
> should be robust, sharable, and resilient in the face of evolving software.
>
> I faced a similar situation with digital assets that are photos and videos.  
> We share photos and videos across several related sites, but we don't want to 
> duplicate the asset for each site.
>
> My solution is to generate a UUID, a Universally Unique IDentifier,  when 
> creating the "thing" - see python 3 at 
> https://docs.python.org/3/library/uuid.html. or python 2 at 
> https://docs.python.org/2/library/uuid.html.
>
> A Universally Unique IDentifier is guaranteed not to collide with any other 
> UUID, and so independent systems can generate one at any time - no need to 
> coordinate with a central database or across separate servers.
>
> A UUID is robust in the face of name changes - such as a maiden name becoming 
> a married name.
>
> I would recommend a UUID over exposing a primary key, hands down, all the 
> time, no exceptions.
>
> --  Bill
>
> --
> 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/8bcbd562-5bb8-49f3-b1ad-1b73ff62d840%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__xSFHEcSUCDR-rzzkig3ZHZWKoCEO_z%2Bo%2BEOV_b4QByA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: test error

2018-10-22 Thread Joel Mathew
Why did you say that? I'm using django 2.2 and f strings are indeed supported.

Sincerely yours,

Joel G Mathew


On Sun, 21 Oct 2018 at 18:05, Motaz Hejaze  wrote:
>
> f'{}' is not supported
>
> On Sun, Oct 21, 2018 at 2:29 PM Joel  wrote:
>>
>> What is your version of python? f strings were introduced in 3.6
>>
>> On Sun, 21 Oct, 2018, 9:54 AM Tim Vogt (Tim Vogt),  
>> wrote:
>>>
>>> I try to make a test with has an error
>>> any suggestions?
>>> tim
>>>
>>>
>>> expected_author = f'{post.author}
>>> ^
>>> SyntaxError: EOL while scanning string literal
>>>
>>>
>>> --
>>> Ran 1 test in 0.000s
>>>
>>> FAILED (errors=1)
>>> Destroying test database for alias 'default'...
>>> MacBook-Pro-15-Officerebel:blogapi timvogt$
>>>
>>>
>>> from django.test import TestCase
>>> from django.contrib.auth.models import User
>>>
>>> from .models import Post
>>>
>>> class BlogTests(TestCase):
>>>
>>> @classmethod
>>> def setUpTestData(cls):
>>> #Create a user
>>> testuser1 = User.objects.create_user(
>>> username='testuser1', password='abc123')
>>> testuser1.save()
>>>
>>> # Create a blog post
>>> test_post = Post.objects.create(
>>> author=testuser1, title='Blog title', body='Body content...')
>>> test_post.save()
>>>
>>> def test_blog_content(self):
>>> post = Post.objects.get(id=1)
>>> expected_author = f'{post.author}'
>>> expected_title = f'{post.title}'
>>> expected_body = f'{post.body}'
>>> self.assertEquals(expected_author, 'testuser1')
>>> self.assertEquals(expected_title,'Blog title')
>>> self.assertEquals(expected_body, 'Body content ...')
>>>
>>> --
>>> 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/FCBEF0A0-EDB1-4842-BB4E-42249F3F48EB%40gmail.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_8VU9J9QGUz_LNGjBRCQSGo0rpJ1FTtY5H00U_Di_7oiw%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/CAHV4E-d4qHggazeGzrZJWdf1_Z766SoiJhqXDwizP5Vuox0nVQ%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/CAA%3Diw_98qeuc4MM4_HdUHJzjfJXGxpZGMmeauOMQXaaon-KSkA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Identify failed insert field

2018-10-27 Thread Joel Mathew
Is there anyway to identify which database field update failed,
instead of a generic message like "ValueError: invalid literal for
int() with base 10: ''?

For example, I have the following save():

tempcust = unconfirmedappointment(name=name, ageyrs=ageyrs,
agemnths=agemnths, gender=gender, mobile=phone,
docid=doc,clinicid=clinicobj, seldate=seldate, seltime=slot,
email=email, address=address, city=city, uniquestring=uniquestring,
otp=otp)
tempcust.save()

Apparently one of the values is wrong for the field. But all I get is
the following:

2018-10-28 08:29:48,842 django.request ERRORInternal Server Error:
/clinic/madhav/doctor/4/setappointment
Traceback (most recent call last):
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/core/handlers/exception.py",
line 34, in inner
response = get_response(request)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/core/handlers/base.py",
line 126, in _get_response
response = self.process_exception_by_middleware(e, request)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/core/handlers/base.py",
line 124, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/joel/myappointments/clinic/views.py", line 896, in setappointment
tempcust.save()
  File "/home/joel/.local/lib/python3.6/site-packages/django/db/models/base.py",
line 718, in save
force_update=force_update, update_fields=update_fields)
  File "/home/joel/.local/lib/python3.6/site-packages/django/db/models/base.py",
line 748, in save_base
updated = self._save_table(raw, cls, force_insert, force_update,
using, update_fields)
  File "/home/joel/.local/lib/python3.6/site-packages/django/db/models/base.py",
line 831, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
  File "/home/joel/.local/lib/python3.6/site-packages/django/db/models/base.py",
line 869, in _do_insert
using=using, raw=raw)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/db/models/manager.py",
line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/db/models/query.py",
line 1136, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/db/models/sql/compiler.py",
line 1288, in execute_sql
for sql, params in self.as_sql():
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/db/models/sql/compiler.py",
line 1241, in as_sql
for obj in self.query.objs
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/db/models/sql/compiler.py",
line 1241, in 
for obj in self.query.objs
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/db/models/sql/compiler.py",
line 1240, in 
[self.prepare_value(field, self.pre_save_val(field, obj)) for
field in fields]
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/db/models/sql/compiler.py",
line 1182, in prepare_value
value = field.get_db_prep_save(value, connection=self.connection)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/db/models/fields/__init__.py",
line 790, in get_db_prep_save
return self.get_db_prep_value(value, connection=connection, prepared=False)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/db/models/fields/__init__.py",
line 785, in get_db_prep_value
value = self.get_prep_value(value)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/db/models/fields/__init__.py",
line 1807, in get_prep_value
return int(value)
ValueError: invalid literal for int() with base 10: ''

How to trace which field is problematic, other than manually debugging
each variable and seeing if it is non integer? Can django tell me
which field is causing the  issue?

Sincerely yours,

Dr Joel G Mathew

-- 
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_-5bzYQfCw2BY38rDSS4aFkR48YC-zMDCWbiTDorRs%3DgQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django assignment

2018-10-27 Thread Joel Mathew
Isn't this cheating? Why dont you complete your own assignment?

Joel G Mathew


On Sun, 28 Oct 2018 at 10:40, RONAK JAIN  wrote:
>
> Hi
>
>
> Please help me out  this assignment urgent. How can I solve ?
>
>
>
>
> Thanks
> RJ
>
>
> --
> 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/CA%2BAqMUfHh77Op6OVRnwFLnpuOdLueXyzT9M4Sqbi8wu7g9Q9dA%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/CAA%3Diw_9pXPvEM%3DKYZmsoDp4vtRv8rNbHUijydKS1SfBv9Dw%3DFQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Identify failed insert field

2018-10-29 Thread Joel Mathew
Yes, usually I print request.POST to check.
On Mon, 29 Oct 2018 at 19:11, Manjunath  wrote:
>
> I think one of the numeric values you are passing is an empty string.
> Django is trying to cast it to int but failing to do so.
>
> Best solution would be to print each values before save() call & you will 
> know which is the error causing column..
>
> Hope it helps!!
>
>
> On Sunday, October 28, 2018 at 8:35:13 AM UTC+5:30, Joel wrote:
>>
>> Is there anyway to identify which database field update failed,
>> instead of a generic message like "ValueError: invalid literal for
>> int() with base 10: ''?
>>
>> For example, I have the following save():
>>
>> tempcust = unconfirmedappointment(name=name, ageyrs=ageyrs,
>> agemnths=agemnths, gender=gender, mobile=phone,
>> docid=doc,clinicid=clinicobj, seldate=seldate, seltime=slot,
>> email=email, address=address, city=city, uniquestring=uniquestring,
>> otp=otp)
>> tempcust.save()
>>
>> Apparently one of the values is wrong for the field. But all I get is
>> the following:
>>
>> 2018-10-28 08:29:48,842 django.request ERRORInternal Server Error:
>> /clinic/madhav/doctor/4/setappointment
>> Traceback (most recent call last):
>>   File 
>> "/home/joel/.local/lib/python3.6/site-packages/django/core/handlers/exception.py",
>> line 34, in inner
>> response = get_response(request)
>>   File 
>> "/home/joel/.local/lib/python3.6/site-packages/django/core/handlers/base.py",
>> line 126, in _get_response
>> response = self.process_exception_by_middleware(e, request)
>>   File 
>> "/home/joel/.local/lib/python3.6/site-packages/django/core/handlers/base.py",
>> line 124, in _get_response
>> response = wrapped_callback(request, *callback_args, **callback_kwargs)
>>   File "/home/joel/myappointments/clinic/views.py", line 896, in 
>> setappointment
>> tempcust.save()
>>   File 
>> "/home/joel/.local/lib/python3.6/site-packages/django/db/models/base.py",
>> line 718, in save
>> force_update=force_update, update_fields=update_fields)
>>   File 
>> "/home/joel/.local/lib/python3.6/site-packages/django/db/models/base.py",
>> line 748, in save_base
>> updated = self._save_table(raw, cls, force_insert, force_update,
>> using, update_fields)
>>   File 
>> "/home/joel/.local/lib/python3.6/site-packages/django/db/models/base.py",
>> line 831, in _save_table
>> result = self._do_insert(cls._base_manager, using, fields, update_pk, 
>> raw)
>>   File 
>> "/home/joel/.local/lib/python3.6/site-packages/django/db/models/base.py",
>> line 869, in _do_insert
>> using=using, raw=raw)
>>   File 
>> "/home/joel/.local/lib/python3.6/site-packages/django/db/models/manager.py",
>> line 82, in manager_method
>> return getattr(self.get_queryset(), name)(*args, **kwargs)
>>   File 
>> "/home/joel/.local/lib/python3.6/site-packages/django/db/models/query.py",
>> line 1136, in _insert
>> return query.get_compiler(using=using).execute_sql(return_id)
>>   File 
>> "/home/joel/.local/lib/python3.6/site-packages/django/db/models/sql/compiler.py",
>> line 1288, in execute_sql
>> for sql, params in self.as_sql():
>>   File 
>> "/home/joel/.local/lib/python3.6/site-packages/django/db/models/sql/compiler.py",
>> line 1241, in as_sql
>> for obj in self.query.objs
>>   File 
>> "/home/joel/.local/lib/python3.6/site-packages/django/db/models/sql/compiler.py",
>> line 1241, in 
>> for obj in self.query.objs
>>   File 
>> "/home/joel/.local/lib/python3.6/site-packages/django/db/models/sql/compiler.py",
>> line 1240, in 
>> [self.prepare_value(field, self.pre_save_val(field, obj)) for
>> field in fields]
>>   File 
>> "/home/joel/.local/lib/python3.6/site-packages/django/db/models/sql/compiler.py",
>> line 1182, in prepare_value
>> value = field.get_db_prep_save(value, connection=self.connection)
>>   File 
>> "/home/joel/.local/lib/python3.6/site-packages/django/db/models/fields/__init__.py",
>> line 790, in get_db_prep_save
>> return self.get_db_prep_value(value, connection=connection, 
>> prepared=False)
>>   File 
>> "/home/joel/.local/lib/python3.6/site-packages/django/db/models/fields/__init__.py",
>> line 785, in get_db_prep_value
>> value = self.get_prep_value(value)
>>   File 
>> "/home/joel/.local/lib/python3.6/site-packages/django/db/models/fields/__init__.py",
>> line 1807, in get_prep_value
>> return int(value)
>> ValueError: invalid literal for int() with base 10: ''
>>
>> How to trace which field is problematic, other than manually debugging
>> each variable and seeing if it is non integer? Can django tell me
>> which field is causing the  issue?
>>
>> Sincerely yours,
>>
>> Dr Joel G Mathew
>
> --
> 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.g

Error in function to return permissions

2018-10-31 Thread Joel Mathew
I have a custom function to check if a user is authorized to do
certain functions:

@login_required
def checkpermission(request, permiss):
username = request.user.username
print(f"username is {username}")
print(f"User.objects.filter() is {User.objects.filter()}")
userobj = User.objects.get(username=username)
print(dir(userobj))
print(userobj.user_permissions.all())
print(Permission.objects.filter(group__user=userobj))
perms = getpermissions(userobj)
for perm in perms:
p = perm.name.lower().replace(" ", "_")
if permiss == p:
print("Has permission: %s" % p)
return True
print("No")
return False

def getpermissions(userobj):
if userobj.is_superuser:
return Permission.objects.all()
return userobj.user_permissions.all() |
Permission.objects.filter(group__user=userobj)

The problem arises if I write the previous function with decorator:

@login_required
def getpermissions(userobj):
if userobj.is_superuser:
return Permission.objects.all()
return userobj.user_permissions.all() |
Permission.objects.filter(group__user=userobj)

In this case, I get the error:

2018-10-31 21:26:51,239 django.request ERRORInternal Server Error:
/clinic/joelent/doctors
Traceback (most recent call last):
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/core/handlers/exception.py",
line 34, in inner
response = get_response(request)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/core/handlers/base.py",
line 126, in _get_response
response = self.process_exception_by_middleware(e, request)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/core/handlers/base.py",
line 124, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/contrib/auth/decorators.py",
line 21, in _wrapped_view
return view_func(request, *args, **kwargs)
  File "/home/joel/myappointments/clinic/views.py", line 2797, in
clinicdoctorlist
if checkpermission(request, "can_change_doctor") and
HasMembership(request, cliniclabel):
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/contrib/auth/decorators.py",
line 21, in _wrapped_view
return view_func(request, *args, **kwargs)
  File "/home/joel/myappointments/clinic/views.py", line 2970, in
checkpermission
perms = getpermissions(userobj)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/contrib/auth/decorators.py",
line 20, in _wrapped_view
if test_func(request.user):
AttributeError: 'User' object has no attribute 'user'

Why would this be happening?

Sincerely yours,

Joel G Mathew

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


Re: Error in function to return permissions

2018-11-01 Thread Joel Mathew
Thank you!

Sincerely yours,

Joel G Mathew


On Wed, 31 Oct 2018 at 21:36, Stephen J. Butler
 wrote:
>
> @login_required needs "request" as the first parameter.
>
> On Wed, Oct 31, 2018 at 11:58 AM Joel Mathew  wrote:
>>
>> I have a custom function to check if a user is authorized to do
>> certain functions:
>>
>> @login_required
>> def checkpermission(request, permiss):
>> username = request.user.username
>> print(f"username is {username}")
>> print(f"User.objects.filter() is {User.objects.filter()}")
>> userobj = User.objects.get(username=username)
>> print(dir(userobj))
>> print(userobj.user_permissions.all())
>> print(Permission.objects.filter(group__user=userobj))
>> perms = getpermissions(userobj)
>> for perm in perms:
>> p = perm.name.lower().replace(" ", "_")
>> if permiss == p:
>> print("Has permission: %s" % p)
>> return True
>> print("No")
>> return False
>>
>> def getpermissions(userobj):
>> if userobj.is_superuser:
>> return Permission.objects.all()
>> return userobj.user_permissions.all() |
>> Permission.objects.filter(group__user=userobj)
>>
>> The problem arises if I write the previous function with decorator:
>>
>> @login_required
>> def getpermissions(userobj):
>> if userobj.is_superuser:
>> return Permission.objects.all()
>> return userobj.user_permissions.all() |
>> Permission.objects.filter(group__user=userobj)
>>
>> In this case, I get the error:
>>
>> 2018-10-31 21:26:51,239 django.request ERRORInternal Server Error:
>> /clinic/joelent/doctors
>> Traceback (most recent call last):
>>   File 
>> "/home/joel/.local/lib/python3.6/site-packages/django/core/handlers/exception.py",
>> line 34, in inner
>> response = get_response(request)
>>   File 
>> "/home/joel/.local/lib/python3.6/site-packages/django/core/handlers/base.py",
>> line 126, in _get_response
>> response = self.process_exception_by_middleware(e, request)
>>   File 
>> "/home/joel/.local/lib/python3.6/site-packages/django/core/handlers/base.py",
>> line 124, in _get_response
>> response = wrapped_callback(request, *callback_args, **callback_kwargs)
>>   File 
>> "/home/joel/.local/lib/python3.6/site-packages/django/contrib/auth/decorators.py",
>> line 21, in _wrapped_view
>> return view_func(request, *args, **kwargs)
>>   File "/home/joel/myappointments/clinic/views.py", line 2797, in
>> clinicdoctorlist
>> if checkpermission(request, "can_change_doctor") and
>> HasMembership(request, cliniclabel):
>>   File 
>> "/home/joel/.local/lib/python3.6/site-packages/django/contrib/auth/decorators.py",
>> line 21, in _wrapped_view
>> return view_func(request, *args, **kwargs)
>>   File "/home/joel/myappointments/clinic/views.py", line 2970, in
>> checkpermission
>> perms = getpermissions(userobj)
>>   File 
>> "/home/joel/.local/lib/python3.6/site-packages/django/contrib/auth/decorators.py",
>> line 20, in _wrapped_view
>> if test_func(request.user):
>> AttributeError: 'User' object has no attribute 'user'
>>
>> Why would this be happening?
>>
>> Sincerely yours,
>>
>> Joel G Mathew
>>
>> --
>> 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_94fELQWM873_y6w%2B0S8vCA2xtO44sG45dqMp4DSC8qeQ%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/CAD4ANxVoNhmE78-n0SQFn1QFFz1O9-wXBs9p5G8jfsiXa190Kw%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/CAA%3Diw_9diL9pWgww7-rsgUDsBXp07jOipi%3DouTqTFZ%2B4M-Cr0Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Turning DEBUG=True causes a tornado of Error 500s

2018-11-02 Thread Joel Mathew
When I turned DEBUG = False in my project/settings.py, I suddenly got
a whole bunch of HTTP Error 500. Most of the css reources showed the
error. I have two apps in this project, and I've been sharing static
resources between these apps. Would these be the cause of these
errors?

See the following with DEBUG=True:

joel@hp:~/myappointments$ python3 manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
November 03, 2018 - 00:46:23
Django version 2.1.2, using settings 'myappointments.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
In livelist for clinic: joelent
Checking for membership
In HasMembership function.
In IsMemberof function.. Got arguments: cliniclabel:joelent username:joel
permobj.viewperms: 1
Verified that ... is a member of joelent
Username is ...
Showhelp for Joel G Mathew  is False
[03/Nov/2018 00:46:27] "GET /clinic/joelent/live HTTP/1.1" 200 19802
[03/Nov/2018 00:46:27] "GET
/appointments/static/appointments/css/calcustomcolors.css?dev=82444302
HTTP/1.1" 200 246
[03/Nov/2018 00:46:27] "GET
/appointments/static/appointments/css/mytheme.css?dev=82444302
HTTP/1.1" 200 884
[03/Nov/2018 00:46:27] "GET
/appointments/static/clinic/css/colorbuttons.css?dev=82444302
HTTP/1.1" 200 3596
[03/Nov/2018 00:46:27] "GET
/appointments/static/appointments/js/search.js?dev=82444302 HTTP/1.1"
200 6554
[03/Nov/2018 00:46:27] "GET
/appointments/static/appointments/js/jquery-ui/jquery-ui.js?dev=82444302
HTTP/1.1" 200 520714
[03/Nov/2018 00:46:27] "GET
/appointments/static/appointments/js/appointment.js?dev=82444302
HTTP/1.1" 200 17716
[03/Nov/2018 00:46:27] "GET
/appointments/static/clinic/icons/favicon.ico HTTP/1.1" 200 311737




And now with DEBUG = False:

python3 manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
November 03, 2018 - 00:47:39
Django version 2.1.2, using settings 'myappointments.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
In livelist for clinic: joelent
Checking for membership
In HasMembership function.
In IsMemberof function.. Got arguments: cliniclabel:joelent username:joel
permobj.viewperms: 1
Verified that ... is a member of joelent
Username is 
Showhelp for Joel G Mathew  is False
[03/Nov/2018 00:47:44] "GET /clinic/joelent/live HTTP/1.1" 200 19802
2018-11-03 00:47:44,523 django.request ERRORInternal Server Error:
/appointments/static/clinic/css/colorbuttons.css
2018-11-03 00:47:44,525 django.request ERRORInternal Server Error:
/appointments/static/appointments/css/calcustomcolors.css
2018-11-03 00:47:44,532 django.request ERRORInternal Server Error:
/appointments/static/appointments/css/mytheme.css
2018-11-03 00:47:44,562 django.request ERRORInternal Server Error:
/appointments/static/appointments/js/jquery-ui/jquery-ui.js
2018-11-03 00:47:44,567 django.request ERRORInternal Server Error:
/appointments/static/appointments/js/search.js
[03/Nov/2018 00:47:44] "GET
/appointments/static/appointments/css/mytheme.css?dev=82846267
HTTP/1.1" 500 27
[03/Nov/2018 00:47:44] "GET
/appointments/static/appointments/css/calcustomcolors.css?dev=82846267
HTTP/1.1" 500 27
[03/Nov/2018 00:47:44] "GET
/appointments/static/clinic/css/colorbuttons.css?dev=82846267
HTTP/1.1" 500 27
[03/Nov/2018 00:47:44] "GET
/appointments/static/appointments/js/search.js?dev=82846267 HTTP/1.1"
500 27
[03/Nov/2018 00:47:44] "GET
/appointments/static/appointments/js/jquery-ui/jquery-ui.js?dev=82846267
HTTP/1.1" 500 27
2018-11-03 00:47:44,632 django.request ERRORInternal Server Error:
/appointments/static/appointments/js/appointment.js
[03/Nov/2018 00:47:44] "GET
/appointments/static/appointments/js/appointment.js?dev=82846267
HTTP/1.1" 500 27
2018-11-03 00:47:44,697 django.request ERRORInternal Server Error:
/appointments/static/appointments/js/jquery-ui/jquery-ui.js
[03/Nov/2018 00:47:44] "GET
/appointments/static/appointments/js/jquery-ui/jquery-ui.js?dev=82846267
HTTP/1.1" 500 27
2018-11-03 00:47:44,849 django.request ERRORInternal Server Error:
/appointments/static/appointments/js/search.js
[03/Nov/2018 00:47:44] "GET
/appointments/static/appointments/js/search.js?dev=82846267 HTTP/1.1"
500 27
2018-11-03 00:47:44,875 django.request ERRORInternal Server Error:
/appointments/static/appointments/js/appointment.js
[03/Nov/2018 00:47:44] "GET
/appointments/static/appointments/js/appointment.js?dev=82846267
HTTP/1.1" 500 27
2018-11-03 00:47:45,152 django.request ERRORInternal Server Error:
/appointments/static/clinic/icons/favicon.ico
[03/Nov/2018 00:47:45] "GET
/appointments/static/clinic/icons/favicon.ico HTTP/1.1" 500 27


Sincerely yours,

Joel G Mathew

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving e

Re: Turning DEBUG=True causes a tornado of Error 500s

2018-11-02 Thread Joel Mathew
Please forgive the typo in the subject line. It should read "Turning
DEBUG=False causes a tornado of Error 500s"


Joel G Mathew

On Sat, 3 Nov 2018 at 00:49, Joel Mathew  wrote:
>
> When I turned DEBUG = False in my project/settings.py, I suddenly got
> a whole bunch of HTTP Error 500. Most of the css reources showed the
> error. I have two apps in this project, and I've been sharing static
> resources between these apps. Would these be the cause of these
> errors?
>
> See the following with DEBUG=True:
> 
> joel@hp:~/myappointments$ python3 manage.py runserver
> Performing system checks...
>
> System check identified no issues (0 silenced).
> November 03, 2018 - 00:46:23
> Django version 2.1.2, using settings 'myappointments.settings'
> Starting development server at http://127.0.0.1:8000/
> Quit the server with CONTROL-C.
> In livelist for clinic: joelent
> Checking for membership
> In HasMembership function.
> In IsMemberof function.. Got arguments: cliniclabel:joelent username:joel
> permobj.viewperms: 1
> Verified that ... is a member of joelent
> Username is ...
> Showhelp for Joel G Mathew  is False
> [03/Nov/2018 00:46:27] "GET /clinic/joelent/live HTTP/1.1" 200 19802
> [03/Nov/2018 00:46:27] "GET
> /appointments/static/appointments/css/calcustomcolors.css?dev=82444302
> HTTP/1.1" 200 246
> [03/Nov/2018 00:46:27] "GET
> /appointments/static/appointments/css/mytheme.css?dev=82444302
> HTTP/1.1" 200 884
> [03/Nov/2018 00:46:27] "GET
> /appointments/static/clinic/css/colorbuttons.css?dev=82444302
> HTTP/1.1" 200 3596
> [03/Nov/2018 00:46:27] "GET
> /appointments/static/appointments/js/search.js?dev=82444302 HTTP/1.1"
> 200 6554
> [03/Nov/2018 00:46:27] "GET
> /appointments/static/appointments/js/jquery-ui/jquery-ui.js?dev=82444302
> HTTP/1.1" 200 520714
> [03/Nov/2018 00:46:27] "GET
> /appointments/static/appointments/js/appointment.js?dev=82444302
> HTTP/1.1" 200 17716
> [03/Nov/2018 00:46:27] "GET
> /appointments/static/clinic/icons/favicon.ico HTTP/1.1" 200 311737
>
>
> 
>
> And now with DEBUG = False:
>
> python3 manage.py runserver
> Performing system checks...
>
> System check identified no issues (0 silenced).
> November 03, 2018 - 00:47:39
> Django version 2.1.2, using settings 'myappointments.settings'
> Starting development server at http://127.0.0.1:8000/
> Quit the server with CONTROL-C.
> In livelist for clinic: joelent
> Checking for membership
> In HasMembership function.
> In IsMemberof function.. Got arguments: cliniclabel:joelent username:joel
> permobj.viewperms: 1
> Verified that ... is a member of joelent
> Username is 
> Showhelp for Joel G Mathew  is False
> [03/Nov/2018 00:47:44] "GET /clinic/joelent/live HTTP/1.1" 200 19802
> 2018-11-03 00:47:44,523 django.request ERRORInternal Server Error:
> /appointments/static/clinic/css/colorbuttons.css
> 2018-11-03 00:47:44,525 django.request ERRORInternal Server Error:
> /appointments/static/appointments/css/calcustomcolors.css
> 2018-11-03 00:47:44,532 django.request ERRORInternal Server Error:
> /appointments/static/appointments/css/mytheme.css
> 2018-11-03 00:47:44,562 django.request ERRORInternal Server Error:
> /appointments/static/appointments/js/jquery-ui/jquery-ui.js
> 2018-11-03 00:47:44,567 django.request ERRORInternal Server Error:
> /appointments/static/appointments/js/search.js
> [03/Nov/2018 00:47:44] "GET
> /appointments/static/appointments/css/mytheme.css?dev=82846267
> HTTP/1.1" 500 27
> [03/Nov/2018 00:47:44] "GET
> /appointments/static/appointments/css/calcustomcolors.css?dev=82846267
> HTTP/1.1" 500 27
> [03/Nov/2018 00:47:44] "GET
> /appointments/static/clinic/css/colorbuttons.css?dev=82846267
> HTTP/1.1" 500 27
> [03/Nov/2018 00:47:44] "GET
> /appointments/static/appointments/js/search.js?dev=82846267 HTTP/1.1"
> 500 27
> [03/Nov/2018 00:47:44] "GET
> /appointments/static/appointments/js/jquery-ui/jquery-ui.js?dev=82846267
> HTTP/1.1" 500 27
> 2018-11-03 00:47:44,632 django.request ERRORInternal Server Error:
> /appointments/static/appointments/js/appointment.js
> [03/Nov/2018 00:47:44] "GET
> /appointments/static/appointments/js/appointment.js?dev=82846267
> HTTP/1.1" 500 27
> 2018-11-03 00:47:44,697 django.request ERRORInternal Server Error:
> /appointments/static/appointments/js/jquery-ui/jquery-ui.js
> [03/Nov/2018 00:47:44] "GET
> /appointments/static/appointments/js/jquery-ui/jquery-ui.js?

Re: Turning DEBUG=True causes a tornado of Error 500s

2018-11-02 Thread Joel Mathew
No I hadnt. I did so now, and got a few errors:

joel@hp:~/myappointments$ python3 manage.py collectstatic

You have requested to collect static files at the destination
location as specified in your settings:

/home/joel/myappointments/appointments/static

This will overwrite existing files!
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: yes
Traceback (most recent call last):
  File "manage.py", line 15, in 
execute_from_command_line(sys.argv)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/core/management/__init__.py",
line 381, in execute_from_command_line
utility.execute()
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/core/management/__init__.py",
line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/core/management/base.py",
line 316, in run_from_argv
self.execute(*args, **cmd_options)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/core/management/base.py",
line 353, in execute
output = self.handle(*args, **options)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py",
line 188, in handle
collected = self.collect()
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py",
line 105, in collect
for path, storage in finder.list(self.ignore_patterns):
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/contrib/staticfiles/finders.py",
line 125, in list
for path in utils.get_files(storage, ignore_patterns):
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/contrib/staticfiles/utils.py",
line 23, in get_files
directories, files = storage.listdir(location)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/core/files/storage.py",
line 313, in listdir
for entry in os.listdir(path):
FileNotFoundError: [Errno 2] No such file or directory:
'/home/joel/myappointments/static'
Sentry is attempting to send 1 pending error messages
Waiting up to 2.0 seconds
Press Ctrl-C to quit
joel@hp:~/myappointments$ mkdir /home/joel/myappointments/static
joel@hp:~/myappointments$ python3 manage.py collectstatic

You have requested to collect static files at the destination
location as specified in your settings:

/home/joel/myappointments/appointments/static

This will overwrite existing files!
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: yes
Traceback (most recent call last):
  File "manage.py", line 15, in 
execute_from_command_line(sys.argv)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/core/management/__init__.py",
line 381, in execute_from_command_line
utility.execute()
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/core/management/__init__.py",
line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/core/management/base.py",
line 316, in run_from_argv
self.execute(*args, **cmd_options)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/core/management/base.py",
line 353, in execute
output = self.handle(*args, **options)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py",
line 188, in handle
collected = self.collect()
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py",
line 114, in collect
handler(path, prefixed_path, storage)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py",
line 352, in copy_file
with source_storage.open(path) as source_file:
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/core/files/storage.py",
line 33, in open
return self._open(name, mode)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/core/files/storage.py",
line 218, in _open
return File(open(self.path(name), mode))
FileNotFoundError: [Errno 2] No such file or directory:
'/home/joel/myappointments/METADATA'
Sentry is attempting to send 1 pending error messages
Waiting up to 2.0 seconds
Press Ctrl-C to quit
joel@hp:~/myappointments$

How should I choose location? My apps are appointments, and clinic
The project name is myappointments

Sincerely yours,

Joel G Mathew

On Sat, 3 Nov 2018 at 00:54, Matthew Pava  wrote:
>
> Did you run collectstatic?
>
>
> -Original Message-
> From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
> Behalf Of Joel Mathew
&

Reading serialized data without json

2018-11-05 Thread Joel Mathew
Is it possible to read serialized data from javascript without encoding to json?

The data received by request.POST is:



Sincerely yours,

Joel G Mathew

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


Sending PDF from javascript to django

2018-11-14 Thread Joel Mathew
I use jspdf to generate pdf for downloading by end users. I wish to
add a function to let them send an email to themselves through the
server.
Reading a little bit, I've seen a method to send the pdf to the server
as a base encoded string, and then have the server decode it, before
emailing the object. It seems to be bad practise and a convoluted way,
to me.

Anyway, the javascript is doing this:

var pdf = doc.output();
cliniclabel = $("#TopPatientBar").data("cliniclabel")
patient_id = $('body').find("#PatientIP").html();
$.ajax({
method: "POST",
url: 
`/clinic/${cliniclabel}/prescription/sendemail/patient/${patient_id}`,
data: {data: pdf},
}).done(function(data){
console.log(data);
});

And as a preliminary step, I'm trying to read the POST data:

def SendPrescriptionbyMail(request, cliniclabel, patient_id):
patient_id = int(patient_id)
if request.method == 'POST':
print("POST data", request.POST)
cus = customer.objects.get(cstid = patient_id)
recipient=cus.email

But I got this:
[14/Nov/2018 14:39:27] "GET
/appointments/static/appointments/js/popper.min.js.map HTTP/1.1" 404
1749
[14/Nov/2018 14:39:30] "GET /clinic/medicines HTTP/1.1" 200 8389
2018-11-14 14:39:36,360 django.security.RequestDataTooBig ERROR
Request body exceeded settings.DATA_UPLOAD_MAX_MEMORY_SIZE.
2018-11-14 14:39:36,441 django.request WARNING  Bad Request:
/clinic/madhav/prescription/sendemail/patient/18
[14/Nov/2018 14:39:36] "POST
/clinic/madhav/prescription/sendemail/patient/18 HTTP/1.1" 400 17930

But rather than create an XY problem, can anyone tell me whether I'm
approaching this in the right way? Isnt base encoding a pdf object
from javascript for sending to django the wrong way to do this?

What would be the right way? Just point me along what I need to be looking at.

Sincerely yours,

Joel G Mathew

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


Re: Sending PDF from javascript to django

2018-11-14 Thread Joel Mathew
I tried the following:

def myhandle_uploaded_file(f):
with open('some/file/name.txt', 'wb+') as destination:
for chunk in f.chunks():
destination.write(chunk)

def SendPrescriptionbyMail(request, cliniclabel, patient_id):
patient_id = int(patient_id)
if request.method == 'POST':
form = UploadFileForm(request.POST, request.FILES)
if form.is_valid():
myhandle_uploaded_file(request.FILES['file'])
return HttpResponseRedirect('/success/url/')

But I got the following error, which I cant make heads or tails of:

2018-11-14 15:16:49,585 django.request ERRORInternal Server Error:
/clinic/madhav/prescription/sendemail/patient/18
Traceback (most recent call last):
  File 
"/home/joel/myappointments/venv/lib/python3.6/site-packages/django/core/handlers/exception.py",
line 34, in inner
response = get_response(request)
  File 
"/home/joel/myappointments/venv/lib/python3.6/site-packages/django/utils/deprecation.py",
line 93, in __call__
response = self.process_response(request, response)
  File 
"/home/joel/myappointments/venv/lib/python3.6/site-packages/django/middleware/common.py",
line 105, in process_response
if response.status_code == 404:
AttributeError: 'str' object has no attribute 'status_code'

Sincerely yours,

Joel G Mathew
On Wed, 14 Nov 2018 at 14:45, Joel Mathew  wrote:
>
> I use jspdf to generate pdf for downloading by end users. I wish to
> add a function to let them send an email to themselves through the
> server.
> Reading a little bit, I've seen a method to send the pdf to the server
> as a base encoded string, and then have the server decode it, before
> emailing the object. It seems to be bad practise and a convoluted way,
> to me.
>
> Anyway, the javascript is doing this:
>
> var pdf = doc.output();
> cliniclabel = $("#TopPatientBar").data("cliniclabel")
> patient_id = $('body').find("#PatientIP").html();
> $.ajax({
> method: "POST",
> url: 
> `/clinic/${cliniclabel}/prescription/sendemail/patient/${patient_id}`,
> data: {data: pdf},
> }).done(function(data){
> console.log(data);
> });
>
> And as a preliminary step, I'm trying to read the POST data:
>
> def SendPrescriptionbyMail(request, cliniclabel, patient_id):
> patient_id = int(patient_id)
> if request.method == 'POST':
> print("POST data", request.POST)
> cus = customer.objects.get(cstid = patient_id)
> recipient=cus.email
>
> But I got this:
> [14/Nov/2018 14:39:27] "GET
> /appointments/static/appointments/js/popper.min.js.map HTTP/1.1" 404
> 1749
> [14/Nov/2018 14:39:30] "GET /clinic/medicines HTTP/1.1" 200 8389
> 2018-11-14 14:39:36,360 django.security.RequestDataTooBig ERROR
> Request body exceeded settings.DATA_UPLOAD_MAX_MEMORY_SIZE.
> 2018-11-14 14:39:36,441 django.request WARNING  Bad Request:
> /clinic/madhav/prescription/sendemail/patient/18
> [14/Nov/2018 14:39:36] "POST
> /clinic/madhav/prescription/sendemail/patient/18 HTTP/1.1" 400 17930
>
> But rather than create an XY problem, can anyone tell me whether I'm
> approaching this in the right way? Isnt base encoding a pdf object
> from javascript for sending to django the wrong way to do this?
>
> What would be the right way? Just point me along what I need to be looking at.
>
> Sincerely yours,
>
> Joel G Mathew

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


Re: Sending PDF from javascript to django

2018-11-14 Thread Joel Mathew
Thank you. I decided to go with reportlab since it seems to be really
powerful and doesnt require a headless browser. The options it has seem
similiar (at least superficially) to the way I'm coding js in pdfjs. Thank
you for your input. This was a XY problem after all. I should never have
thought about generating PDF on client and then uploading to server to
email the enduser.

Sincerely yours,

Joel G Mathew



On Wed, 14 Nov 2018 at 20:10, Matthew Pava  wrote:

> There is django-hardcopy.
>
>
>
> However, I’m in process of changing my PDF generation algorithm.  I
> originally used PhantomJS with gs-print and gs-view for Windows.
> Unfortunately, PhantomJS has been discontinued, and it wasn’t taking
> advantage of rendering changes to HTML (especially for printing or PDF
> generation) that had developed over the years, especially with Google
> Chrome’s Blink engine, which used to formerly be Webkit, the same engine
> that PhantomJS was using.  My current goal is to utilize headless Chrome
> with Puppeteer, which is a NodeJS package.  Since PhantomJS was a NodeJS
> package, too, it shouldn’t be to involved to get a script working for
> Puppeteer.  And then I am guaranteed to always have the latest version of
> Chrome.
>
>
>
> *From:* django-users@googlegroups.com [mailto:
> django-users@googlegroups.com] *On Behalf Of *Joel
> *Sent:* Wednesday, November 14, 2018 8:07 AM
> *To:* django-users@googlegroups.com
> *Subject:* Re: Sending PDF from javascript to django
>
>
>
> Ideally I would love to generate the pdf on the server. Hovered I am yet
> to discover an easy way to create a pdf easily with the ease of jspdf's
> table plugin.
>
>
>
> Perhaps someone can shed light on a good python library to do this without
> much ado.
>
>
>
> On Wed, 14 Nov, 2018, 7:12 PM Jason 
> your original error was due to exceding django's max upload size.  check
> out
> https://docs.djangoproject.com/en/2.1/ref/settings/#data-upload-max-memory-size
>
>
>
> also, you should check out https://djangopackages.org/grids/g/pdf/
>
>
>
> What I would do is generate the pdf in the view from a rendered template
> and then send from email.  No need to generate it on the client and upload
> for an email.
>
> --
> 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/506231af-2c44-4e8c-9c9d-36d8ea913b7b%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_9QAr_Y2deWgjsXmZcmM8HALA3Gg0jDz_dZVtnSt9Vtog%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/95f81d5cad9e4abb87af8d794ca745e6%40iss2.ISS.LOCAL
> 
> .
> 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_-0XNe%3DmRQwXFkneTzMUcjNr3NHEMoxXZtzhovcKDgvvw%40mail.gmail.com.
For more options, visit https://groups.google.com/d

Re: Django jobs

2018-11-14 Thread Joel Mathew
The last point is a bit of a sore for me. I'm well versed with some other
languages including perl, C, and javascript. Python seems to have
"pythonic" ways of doing stuff that's at loggerheads with all other
languages. Is there a single resource to learn the pythonic way of doing
things? Like, say for perl, there's Larry's books, which provide a solid
foundation for best practices.

Sincerely yours,

Joel G Mathew



On Thu, 15 Nov 2018 at 08:49, Ryan Gedwill  wrote:

> No problem!
>
> Also as a side note to the point that you heard django is slow...
>
> Django is extremely scalable, which of course requires speed.  It’s
> probably the most popular web framework among startups of any magnitude (at
> least from what I’ve seen) by a mile.
>
> Django certainly may require some extra optimization compared to something
> like ASP.NET, just like scaling any python software, but there are ways
> around a lot of it that are well understood.
>
> Instagram and Venmo are written in django, which is proof that it can be
> scaled with the rest of the big players in the industry.
>
> There are certainly problems with scaling python and Django, a perfect
> language/framework doesn’t exist, but there are benefits to both python and
> Django that can be worth the tradeoff.
>
> In addition to the fact that both Django and python are so flexible and
> stay up to date with modern trends as well as any of their competitors, I
> always suggest learning them compared to the other options out there. Just
> don’t let python get in the way of writing good code, because as a beginner
> it’s really easy to forget best practices with it.
>
> Sent from my iPhone
>
> On Nov 14, 2018, at 6:46 PM, Arturo Fernandez  wrote:
>
> Thanks :)
>
> On Wednesday, November 14, 2018 at 9:41:35 PM UTC-5, Ryan Gedwill wrote:
>>
>> I live in the SF Bay Area and there are no shortage of jobs in Django. It
>> is true there are also plenty of jobs in Node, but you can’t compare a
>> framework to a backend language. I see far more python jobs than node jobs.
>>
>> 2 things to keep in mind though (for reference I’m a python/Django dev
>> but have experience in node and c# as well):
>>
>> 1. Just because something is very popular doesn’t mean it’s the easiest
>> to get a job in. There may be more python/JS jobs out there, but there are
>> also way more people applying to them. There are plenty of .NET jobs out
>> there, and far less entry level developers who are looking for them. Nearly
>> every single entry level developer is looking for those python/JS jobs
>> 2. Often times the language and framework you’re experienced in doesn’t
>> matter. I recently had an interview for a Go position, and I was allowed to
>> pick which language I wanted to do the interview in. Most web development
>> jobs are looking for your understanding of general software and web
>> development principles. If you understand html/css/js, sql databases in
>> regards to MVC architecture, MVC architecture itself, and REST API’s and
>> requests, it probably won’t matter what language as long as you can prove
>> it. Knowing the language and framework of the company you’re applying to is
>> kind of just brownie points and improves your chances. If I’m amazing at
>> django and web development but don’t know the language being used, I’ll
>> generally be chosen over someone who’s shaky on web development who uses
>> the same language as the company
>>
>> Sent from my iPhone
>>
>> On Nov 14, 2018, at 6:18 PM, Arturo Fernandez  wrote:
>>
>> Hello community, today someone at work told me to bare in mind which tech
>> I use in terms of profitability. As a backend language, there is no doubt
>> that I'll use Python, however I'm doubting about the framework, whether I
>> should use Python or not for web.
>> I heard that Django is kind of slow, and also there amount of jobs are
>> decreasing. Is that true? I initiated my web experience with Node.js, but I
>> don't want to continue it due to the instability. A friend recommend me
>> .Net, so I have all this kind of doubts in my head. Can someone help me
>> clear my mind? This is probably the best/not the best place to ask it but I
>> need some advice :/
>>
>> Thank you
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users...@googlegroups.com.
>> To post to this group, send email to django...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/df1cf01f-a911-493c-aca4-e5a6ac3931d1%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>> --
> You received this message because you are subscribed 

Re: template

2018-11-15 Thread Joel Mathew
Huh?




On Thu, 15 Nov 2018 at 18:23, Scott Tresor  wrote:

> hello how to user template for django
>
> --
> 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/c5d8df21-fb8c-4073-b1b9-b74c4debefa5%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_9j-n671MnfaG7T9VEyGyrn3nrttzhyDorrUtWJ%3D2k5TA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to download a file when a django function is called by javascript instead of navigation to the url?

2018-11-16 Thread Joel Mathew
I have a page where several buttons process different functions like
sending a user sms (via API), sends an file by email, or downloads a PDF
file. Button actions dont use forms, but uses ajax requests via javascript.

I used to create a pdf file using javascript (jspdf), but have written code
which generates a pdf file by python on the server. Now I need to allow
download when the button is clicked.

Server code snippet:

with NamedTemporaryFile(mode='w+b') as temp:
from django.http import FileResponse
doc = SimpleDocTemplate(temp.name, pagesize=A4, rightMargin=20,
leftMargin=20, topMargin=20, bottomMargin=20, allowSplitting=1,
title="Prescription", author="MyOPIP.com")
doc.build(elements)
print(f'Generated {temp.name}')
return FileResponse(open(temp.name, 'rb'),
content_type='application/pdf')

The above code is supposed to download a pdf file, if called ny navigating
to the url.

On my javascript side, I tried to determine what I'm receiving:

$.ajax({
url:
`/clinic/${cliniclabel}/prescription/download/patient/${patient_id}`,
dataType: "html",
data: data,
type: 'POST',
success: function (data) {
console.log("Received data from server..type is ", typeof(data))
console.log(data)
}
});

And I get:

Received data from server..type is  string
userjs/main.js:2067 %PDF-1.4
% ReportLab Generated PDF document http://www.reportlab.com
1 0 obj
<<
/F1 2 0 R /F2 5 0 R
>>
endobj
2 0 obj

Apparently django sends this as a file stream. How can I get the file
downloaded to the user when the response is processed by javascript?
Sincerely yours,

Dr Joel G Mathew

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


Re: How to download a file when a django function is called by javascript instead of navigation to the url?

2018-11-17 Thread Joel Mathew
Hi Jason,
Thank you for responding.
I solved this by implementing a temporary link system in my model. This
would generate a unique key which points to a foreign key which references
the data I want. When the url with this foreign key is clicked, the pdf is
generated on the fly and presented as a FileResponse. On the javascript
side, what I do is generate the link when the button is clicked, and insert
a Download button in the DOM and the href is set to the link presented by
django.

Sincerely yours,

Dr Joel G Mathew



On Sat, 17 Nov 2018 at 19:16, Jason  wrote:

> check out
> https://stackoverflow.com/questions/4545311/download-a-file-by-jquery-ajax
>
> --
> 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/181a3c12-8b08-4220-b95d-b6fc02002c18%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__crkp1_SAt%2Bugm_jpQ2NfpwcBQ68dv6foN6rLPreMWNQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to download a file when a django function is called by javascript instead of navigation to the url?

2018-11-17 Thread Joel Mathew
Where?
Sincerely yours,

Joel G Mathew



On Sat, 17 Nov 2018 at 20:50, Yavin Aalto Arba  wrote:

> did you try to set "as_attachment=True" ?
>
> --
> 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/CA%2B%2Be-ZWVCysVfPG5iHS_Mr9XgASV_JCPnfj74Yu3edLQ96RNow%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/CAA%3Diw_9OKhi7xzZyd2sO3njck_gsmkWTCK0ECPOVXc2C-B7REA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


User permissions

2018-11-17 Thread Joel Mathew
How are you implementing user permission groups in your project? I'm using
a model to store user and other models as foreign key and permissions as
boolean? Is there a preferred module or standard way to do this?

Sincerely yours,

 Joel G Mathew

-- 
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_-q4HqkxoUnaO1ij%2BKanW-wJKV-xL6NufcuPboVfNMPRQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: file URL missing project name

2018-11-18 Thread Joel Mathew
It's anybody's guess unless you post your code.
Sincerely yours,

 Joel G Mathew



On Sun, 18 Nov 2018 at 20:47, Jeff Williams 
wrote:

> Hi All,
> I'm new to django, so sorry if this is a newbie issue.
>
> I've managed to upload an ImageFieldbut when I try to display it in my
> template using object.pic.url...the URL I'm getting back is missing my
> project name from the URL and the pic is not loading.
>
> Specifically I'm getting
> http://127.0.0.1:8000/media/media/56288852934__75FACD12-1711-4655-96D5-716198FE10B7.JPG
>  back.and
> I need
>
> http://127.0.0.1:8000/*oldgrub*
> /media/media/56288852934__75FACD12-1711-4655-96D5-716198FE10B7.JPG
>
> back to have it work.
>
> What am I missing?  I've poured over my configs.
> Jeff
>
> --
> 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/CAMgbqCe3UzvrWFg4fiRSPXp6HtLJoPJmGs8oPSZjAd%3Dxx4ygNQ%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/CAA%3Diw_-Siy3yQgn8O9Kj0NC6URxwhebR%3DqO7BvUwzyL9mi9NdQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to access Facebook graph api in django

2018-11-19 Thread Joel Mathew
What's the problem you're facing? Where's your code?
Sincerely yours,

 Joel G Mathew



On Mon, 19 Nov 2018 at 19:04, Tushar Nadkar 
wrote:

> i want to access my users email , address , phone number, pincode by face
> book graph api
>
> --
> 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/CAAHYEvMrSy9CJjQ4eAL_W6gSkkbk_4QN%2BEdHXD%3DT92rvRqEq9g%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/CAA%3Diw__BHyhCMqUQeHTv5wBdkN1Sc_0uS5C%2B_OySGsDoJChObA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Self hosted sentry server

2018-11-19 Thread Joel Mathew
I'm just wondering if any  of you are running a self hosted sentry server
for your django installation? Does it have all features of the commercial
non hosted subscription?
Sincerely yours,

 Joel G Mathew

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


Re: Unapplied Migration - how to apply

2018-11-20 Thread Joel Mathew
makemigrations should come before migrate. You cant migrate without
creating the migrations first.
Sincerely yours,

 Joel G Mathew



On Wed, 21 Nov 2018 at 00:47, Tim Johnson  wrote:

> * Shubham Rewale  [181120 08:44]:
> > python manage.py migrate
> > Then use
> > Python manage.py makemigrations
>
>   Thank you. That worked to apply the missing item.
>   Note: Had tried that in the past but reversed the sequence of the
>   two commands.
>
>   Have a great day Shubham
>
> > On Tue, 20 Nov 2018, 10:10 p.m. Tim Johnson  >
> > > using django on ubuntu 16.04
> > > python 3.5.2
> > > django.VERSION =
> > > (2, 0, 0, 'final', 0)
> > > Working from the Django Core book by Nigel George.
> > > When launching
> <...> For more options, visit https://groups.google.com/d/optout.
>
> --
> Tim Johnson
> http://www.tj49.com
>
> --
> 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/20181120191706.GJ30127%40mail.akwebsoft.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_-%3DZ%3DM3rX_w6N-HLHqj-LkdJxzAhg9v7V6wifrMMEY6wQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Unapplied Migration - how to apply

2018-11-20 Thread Joel Mathew
Yes, for your special case where you seem to have a pre-existing migration,
you dont need makemigrations before migrate. I was just commenting that
this is not the usual case.

Sincerely yours,

 Joel G Mathew



On Wed, 21 Nov 2018 at 01:43, Tim Johnson  wrote:

> * Joel Mathew  [181120 10:35]:
> > makemigrations should come before migrate. You cant migrate without
> > creating the migrations first.
>   Now I am being confused:
>
>   The sequence that Joel suggests did not work for me.
>   (I tried it before opening this thread)
>
>   The reverse sequence that was suggested by Shubham Rewale
>   did fully apply the migration.
>
>   Which is correct?
> --
> Tim Johnson
> http://www.tj49.com
>
> --
> 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/20181120201324.GK30127%40mail.akwebsoft.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_-_35s-zzkB77YUHttjuUU4mMjvkC7r3HDAfyCOFg_g2A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Unapplied Migration - how to apply

2018-11-20 Thread Joel Mathew
Anyway, there is no point running `makemigrations` after `migrate` is run.
That doesnt do anything, unless you have made a change in your models after
your migrate is done
Sincerely yours,

 Joel G Mathew



On Wed, 21 Nov 2018 at 01:45, Joel Mathew  wrote:

> Yes, for your special case where you seem to have a pre-existing
> migration, you dont need makemigrations before migrate. I was just
> commenting that this is not the usual case.
>
> Sincerely yours,
>
>  Joel G Mathew
>
>
>
> On Wed, 21 Nov 2018 at 01:43, Tim Johnson  wrote:
>
>> * Joel Mathew  [181120 10:35]:
>> > makemigrations should come before migrate. You cant migrate without
>> > creating the migrations first.
>>   Now I am being confused:
>>
>>   The sequence that Joel suggests did not work for me.
>>   (I tried it before opening this thread)
>>
>>   The reverse sequence that was suggested by Shubham Rewale
>>   did fully apply the migration.
>>
>>   Which is correct?
>> --
>> Tim Johnson
>> http://www.tj49.com
>>
>> --
>> 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/20181120201324.GK30127%40mail.akwebsoft.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_8%2Bxqoi12Gf2anpbe_O9A0njvHFn9GgHeeka3sqCZJP4g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Working with kronos

2018-11-21 Thread Joel Mathew
I was trying the basic django-kronos command to test:
I did pip3 install django-kronos,

myproject/myapp/cron.py:
import kronos
import random

@kronos.register('* * * * *')
def complain():
complaints = [
"I forgot to migrate our applications's cron jobs to our new server! Darn!",
"I'm out of complaints! Damnit!"
]

print random.choice(complaints)

In my myproject/myproject/settings.py:

INSTALLED_APPS = [
'appointments.apps.AppointmentsConfig',
'clinic.apps.ClinicConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_extensions',
'bootstrap4',
'widget_tweaks',
'parsley',
'session_security',
'kronos'
]

Ran:
./manage.py runserver
I expected the dev server to throw up a message every minute. Nothing seems
to be happening.

Sincerely yours,

 Joel G Mathew

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


Re: Working with kronos

2018-11-22 Thread Joel Mathew
I understood the documentation to mean that either we can create management
commands and register with cronos, or create cron.py.
Sincerely yours,

 Joel G Mathew



On Thu, 22 Nov 2018 at 18:42, Jason  wrote:

> https://github.com/jgorset/django-kronos/tree/v1.0#register-tasks-with-cron
>
> sounds like you need to run a register management command first.
>
> --
> 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/bc4a5948-8e8d-45c8-8a7c-522e482680bc%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_9XHEiRgkzG_16jz-CXB%2BE5fQ_PjYOMn6F1evbDEGEXaQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: problem on django contrib

2018-11-24 Thread Joel Mathew
Show the screenshot and complete code
Sincerely yours,

 Joel G Mathew



On Sun, 25 Nov 2018 at 08:07, Saeed Pooladzadeh  wrote:

> Hello
>
>
> I'm trying to use Django on the visual studio but for admin page when I
> uncomment the
>
>  from django.contrib import admin
>
> I get this message :
>
> unexpected token and it can't accept this line of code,
>
> please inform me why.
> Should I install a specific package or something?
>
> thanx
> Saeed
>
> --
> 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/24fc6b59-3342-4a9b-b3f5-075e64518c5c%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_-kxrzQdZEUAX6UY4OaFpGsSDj6w89xGNW9U73p6dnQ3w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: problem on django contrib

2018-11-24 Thread Joel Mathew
Use path for simple urls:

from django.contrib import admin
from django.urls import path, include
from django.conf.urls import url


urlpatterns = [
path('admin/', admin.site.urls),
path('appointments/', include('appointments.urls')),
path('clinic/', include('clinic.urls')),
path('', include('clinic.urls'))
]
Sincerely yours,

 Joel G Mathew



On Sun, 25 Nov 2018 at 08:33, Saeed Pooladzadeh  wrote:

>
> here comes the code for urls.py but i cant uncomment it because python
> doesnt accept it
>
> """
> Definition of urls for DjangoWebProject19.
> """
>
> from django.conf.urls import include, url
>
> # Uncomment the next two lines to enable the admin:
>  #from django.contrib import admin
>  #admin.autodiscover()
>
> urlpatterns = [
> # Examples:
> # url(r'^$', DjangoWebProject19.views.home, name='home'),
> # url(r'^DjangoWebProject19/',
> include('DjangoWebProject19.DjangoWebProject19.urls')),
>
> # Uncomment the admin/doc line below to enable admin documentation:
>  #url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
> # Uncomment the next line to enable the admin:
>  #url(r'^admin/', include(admin.site.urls)),
> ]
>
> در شنبه 24 نوامبر 2018، ساعت 18:54:47 (UTC-8)، Joel نوشته:
>>
>> Show the screenshot and complete code
>> Sincerely yours,
>>
>>  Joel G Mathew
>>
>>
>>
>> On Sun, 25 Nov 2018 at 08:07, Saeed Pooladzadeh 
>> wrote:
>>
>>> Hello
>>>
>>>
>>> I'm trying to use Django on the visual studio but for admin page when I
>>> uncomment the
>>>
>>>  from django.contrib import admin
>>>
>>> I get this message :
>>>
>>> unexpected token and it can't accept this line of code,
>>>
>>> please inform me why.
>>> Should I install a specific package or something?
>>>
>>> thanx
>>> Saeed
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/24fc6b59-3342-4a9b-b3f5-075e64518c5c%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/10d16b02-ea16-4550-b9a1-f098572c20e1%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_85x0Mv8UW-qjeJ8WwzCvF3KhDRAE1EA%2B8-OqmcNXKbuw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: problem on django contrib

2018-11-24 Thread Joel Mathew
You didnt show the admin page. You showed urls.py. path is an easier way to
use urls, without need for regex.
Your problem is not clear to me. If it's something on the admin page. What
exactly are you trying to do? Post everything relevant.
Sincerely yours,

 Joel G Mathew



On Sun, 25 Nov 2018 at 09:16, Saeed Pooladzadeh  wrote:

> Can you please explain what should I do exactly?
>
> should I place these code in admin page? and delete the previous code?
>
> در شنبه 24 نوامبر 2018، ساعت 19:32:52 (UTC-8)، Joel نوشته:
>>
>> Use path for simple urls:
>>
>> from django.contrib import admin
>> from django.urls import path, include
>> from django.conf.urls import url
>>
>>
>> urlpatterns = [
>> path('admin/', admin.site.urls),
>> path('appointments/', include('appointments.urls')),
>> path('clinic/', include('clinic.urls')),
>> path('', include('clinic.urls'))
>> ]
>> Sincerely yours,
>>
>>  Joel G Mathew
>>
>>
>>
>> On Sun, 25 Nov 2018 at 08:33, Saeed Pooladzadeh 
>> wrote:
>>
>>>
>>> here comes the code for urls.py but i cant uncomment it because python
>>> doesnt accept it
>>>
>>> """
>>> Definition of urls for DjangoWebProject19.
>>> """
>>>
>>> from django.conf.urls import include, url
>>>
>>> # Uncomment the next two lines to enable the admin:
>>>  #from django.contrib import admin
>>>  #admin.autodiscover()
>>>
>>> urlpatterns = [
>>> # Examples:
>>> # url(r'^$', DjangoWebProject19.views.home, name='home'),
>>> # url(r'^DjangoWebProject19/',
>>> include('DjangoWebProject19.DjangoWebProject19.urls')),
>>>
>>> # Uncomment the admin/doc line below to enable admin documentation:
>>>  #url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
>>>
>>> # Uncomment the next line to enable the admin:
>>>  #url(r'^admin/', include(admin.site.urls)),
>>> ]
>>>
>>> در شنبه 24 نوامبر 2018، ساعت 18:54:47 (UTC-8)، Joel نوشته:

 Show the screenshot and complete code
 Sincerely yours,

  Joel G Mathew



 On Sun, 25 Nov 2018 at 08:07, Saeed Pooladzadeh 
 wrote:

> Hello
>
>
> I'm trying to use Django on the visual studio but for admin page when
> I uncomment the
>
>  from django.contrib import admin
>
> I get this message :
>
> unexpected token and it can't accept this line of code,
>
> please inform me why.
> Should I install a specific package or something?
>
> thanx
> Saeed
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/24fc6b59-3342-4a9b-b3f5-075e64518c5c%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...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/10d16b02-ea16-4550-b9a1-f098572c20e1%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/5de3847c-b109-4579-8b48-c62284191233%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.

Re: Django doesn't run manage.py: ModuleNotFoundError: No module named 'ProjectName' (clonded Django project))

2018-11-27 Thread Joel Mathew
What I've found helpful in these situations is:

As mentioned just above, always use virtual environment to run your project.
Include the name of the folder of the virtualenv in .gitignore
Use `pip freeze` > requirements.txt
Install modules from requirements.txt in each virtualenv

Sincerely yours,

 Joel G Mathew



On Tue, 27 Nov 2018 at 18:07, Marco Antonio Diaz Valdes <
marko19691...@gmail.com> wrote:

> Hello, my partners and I are working on a Django project using git, a
> partner begin the project and committed it on github, then the rest of us
> copy the project on their respective computers, but when we run the "python
> manage.py runserver" command (or any other command using manage.py) the
> ones who copied the project get the next error:
>
> Traceback (most recent call last): File "manage.py", line 15, in 
> execute_from_command_line(sys.argv) File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/core/management/__init__.py",
> line 381, in execute_from_command_line utility.execute() File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/core/management/__init__.py",
> line 375, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv) File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/core/management/__init__.py",
> line 224, in fetch_command klass = load_command_class(app_name, subcommand)
> File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/core/management/__init__.py",
> line 36, in load_command_class module =
> import_module('%s.management.commands.%s' % (app_name, name)) File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/importlib/__init__.py",
> line 127, in import_module return _bootstrap._gcd_import(name[level:],
> package, level) File "", line 1006, in
> _gcd_import File "", line 983, in
> _find_and_load File "", line 967, in
> _find_and_load_unlocked File "", line 677, in
> _load_unlocked File "", line 728, in
> exec_module File "", line 219, in
> _call_with_frames_removed File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/core/management/commands/migrate.py",
> line 14, in  from django.db.migrations.autodetector import
> MigrationAutodetector File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/db/migrations/autodetector.py",
> line 11, in  from django.db.migrations.questioner import
> MigrationQuestioner File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/db/migrations/questioner.py",
> line 9, in  from .loader import MigrationLoader File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/db/migrations/loader.py",
> line 8, in  from django.db.migrations.recorder import
> MigrationRecorder File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/db/migrations/recorder.py",
> line 9, in  class MigrationRecorder: File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/db/migrations/recorder.py",
> line 22, in MigrationRecorder class Migration(models.Model): File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/db/models/base.py",
> line 87, in __new__ app_config = apps.get_containing_app_config(module)
> File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/apps/registry.py",
> line 249, in get_containing_app_config self.check_apps_ready() File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/apps/registry.py",
> line 131, in check_apps_ready settings.INSTALLED_APPS File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/conf/__init__.py",
> line 57, in __getattr__ self._setup(name) File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/conf/__init__.py",
> line 44, in _setup self._wrapped = Settings(settings_module) File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/conf/__init__.py",
> line 107, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE)
> File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/importlib/__init__.py",
> line 127, in import_module return _bootstrap._gcd_import(name[level:],
> package, level) ModuleNotFoundError: No module na

Re: get_or_delete leading to duplicate creation

2018-11-27 Thread Joel Mathew
You're talking as if this is a bug. If your records are being duplicated,
the problem is your code. It's not unto django to gauge what you need to do
in the database. Be explicit and update the records if you want updation.
Sincerely yours,

 Joel G Mathew



On Tue, 27 Nov 2018 at 18:07, Ankit Khandewal 
wrote:

> Hello,
>
> I am using get_or_create method in my project and this is leading to
> creating duplicate for objects, there created_at time difference is in
> milliseconds, please report this issue to fix.
>
> --
> 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/4c8f9ca3-1379-49de-b37e-1978fc83444b%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_9FC%3D%3DpsxcUTAZGaE%3DaNrRtpNa758VBjbtX3hN7J8HqZg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Unexpected behavior on delete of model

2018-11-27 Thread Joel Mathew
Situation:

I have two Model classes, in two different apps which are part of the same
project. class doctor defined in appointments.models is a set of attributes
associated with a doctor, like name, username, email, phone etc. class
DoctorProfilePic is a Model defined in clinic.models, which has a
StdImageField which stores images. doctor has a One to One mapping to
DoctorProfilePic.

class doctor(models.Model):
docid = models.AutoField(primary_key=True, unique=True) # Need
autoincrement, unique and primary
name = models.CharField(max_length=35)
username = models.CharField(max_length=15)
...
profilepic = models.ForeignKey(DoctorProfilePic, blank=True,
null=True, on_delete=models.CASCADE)
...

class DoctorProfilePic (models.Model):
id = models.AutoField(primary_key=True, unique=True)
name = models.CharField(max_length=255, blank=True)
pic = StdImageField(upload_to="data/media/%Y/%m/%d", blank=True,
variations={
'large': (600, 400),
'thumbnail': (150, 140, True),
'medium': (300, 200),
})
doc = models.ForeignKey('appointments.doctor', blank=True,
null=True, on_delete=models.CASCADE)

Anticipated response:

When user selects one of the profile pics from a selection box, and clicks
Delete, django is supposed to delete the picture from the collection of
pictures uploaded by the doctor.

Problem:

When the delete button is clicked, django deletes both the picture and the
doctor, instead of just the former.

Code:

def removeprofpic(request, docid):
docid = int(docid)
if not IsOwnerorSuperUser(request, docid):
return HttpResponse("You dont have permissions to do this.")
doc = doctor.objects.get(docid = docid)
if request.method == 'POST':
print(request.POST)
picid = int(request.POST.get('profilepic'))
print(f'doc:{doc} picid:{picid}')
pic = DoctorProfilePic.objects.get(doc = doc, id =picid)
pic.delete()
msg = f"Successfully removed profile picture."
else:
msg = "Not a valid POST"
return HttpResponse(msg)

Now I'm guessing my problem is in defining the on_delete=models.CASCADE?
Can someone explain what I've done wrong?
Sincerely yours,

 Joel G Mathew

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


Re: Unexpected behavior on delete of model

2018-11-27 Thread Joel Mathew
Yes, thank you, Todor.
Yesterday night, I ended up doing exactly this.
Sincerely yours,

 Joel G Mathew



On Wed, 28 Nov 2018 at 12:46, Todor Velichkov 
wrote:

> Right now, your doctor will be deleted if its ProfilePicture gets deleted.
> I'm pretty sure you don't want to do that.
> I believe this is what you are looking for:
>
> class Doctor(models.Model):
> # When the profile picture gets delete, clear doctors profile
> picture (set to NULL)
> profilepic = models.ForeignKey(DoctorProfilePic, blank=True, null=
> True, on_delete=models.SET_NULL)
>
>
> class DoctorProfilePic (models.Model):
> # When the doctor gets deleted, delete its picture too (CASCADE)
> # PS. Do not allow orphan ProfilePics (w/o a doctor), i.e.
> blank=False, null=False
> doc = models.ForeignKey('appointments.Doctor', on_delete=models.
> CASCADE)
>
>
>
> On Wednesday, November 28, 2018 at 8:06:11 AM UTC+2, Joel wrote:
>>
>> Ignore the last post. Formatting blues in my main editor.
>>
>> On Wed, 28 Nov, 2018, 11:34 AM Joel >
>>> I think you made a typo in the code. doctor can't be a Foreign key for
>>> class Doctor. Anyway I get your point, and this is the same way I solved it
>>> yesterday.
>>>
>>> On Wed, 28 Nov, 2018, 11:07 AM Saurabh Agrawal >> wrote:
>>>
>>>>
>>>>>
>>>>>
>>>>> class Doctor(models.Model):
>>>>>
>>>>> name = models.CharField(max_length=35)
>>>>>
>>>>> username = models.CharField(max_length=15)
>>>>>
>>>>>
>>>>>
>>>>> class DoctorProfilePic (models.Model):
>>>>>
>>>>> name = models.CharField(max_length=255, blank=True)
>>>>>
>>>>> pic = StdImageField(upload_to="data/media/%Y/%m/%d",
>>>>> blank=True, variations={
>>>>>
>>>>> 'large': (600, 400),
>>>>>
>>>>> 'thumbnail': (150, 140, True),
>>>>>
>>>>> 'medium': (300, 200),
>>>>>
>>>>> })
>>>>>
>>>>> doctor = models.OneToOneField(Doctor, blank=True,
>>>>>
>>>>> null=True, on_delete=models.SET_NULL,
>>>>> related_name="profile_pic")
>>>>>
>>>>>
>>>>>
>>>>
>>>> Setting on_delete to SET_NULL doesn't make much sense here, I think.
>>>> This implies that if a doctor is deleted, the profile pic will be
>>>> preserved, with the FK to doc being set to NULL in db (which doesn't seem
>>>> desirable). I think here CASCADE should work good and will not have the
>>>> issue that the OP is facing.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>
>>>>>
>>>>> …and after saying all that, I wouldn’t make a separate model for the
>>>>> profile picture.  This is what I would do:
>>>>>
>>>>> class Doctor(models.Model):
>>>>>
>>>>> name = models.CharField(max_length=35)
>>>>>
>>>>> username = models.CharField(max_length=15)
>>>>>
>>>>> profile_pic = StdImageField(upload_to="data/media/%Y/%m/%d",
>>>>> blank=True, variations={
>>>>>
>>>>> 'large': (600, 400),
>>>>>
>>>>> 'thumbnail': (150, 140, True),
>>>>>
>>>>> 'medium': (300, 200),
>>>>>
>>>>> })
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> *From:* django...@googlegroups.com [mailto:django...@googlegroups.com]
>>>>> *On Behalf Of *Joel Mathew
>>>>> *Sent:* Tuesday, November 27, 2018 12:24 PM
>>>>> *To:* django...@googlegroups.com
>>>>> *Subject:* Unexpected behavior on delete of model
>>>>>
>>>>>
>>>>>
>>>>> Situation:
>>>>>
>>>>>
>>>>>
>>>>> I have two Model classes, in two different apps w

Re: Easiest front end JavaScript framework to integrate with a Django backend?

2018-11-28 Thread Joel Mathew
Please provide more useful information that merely suggesting the name of a
framework. Please say why you feel this framework is better for working
with django.
Sincerely yours,

 Joel G Mathew



On Wed, 28 Nov 2018 at 18:36, Thanh Tuyền Huỳnh <
huynhthanhtuyen...@gmail.com> wrote:

> Hi guys,
>
> You could refer Vuejs.
>
> Vào 03:20 T.4, 28 Th11 2018 Simon Connah  đã viết:
>
>> I'm in the process of building a website in Django and need to make a
>> specific part of my application dynamic. Because of that I'd like to use
>> a JavaScript frontend framework to build this portion of the site.
>>
>> I was wondering if anyone had any recommendations for which JavaScript
>> framework I should use that integrates well with a Django backend?
>>
>> If anyone is curious I am working on an auction style website.
>>
>> Thank you for any help.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/ee666748-f8c9-37c9-5c12-491ef61ab70d%40gmail.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/CADUa9Eb1vjJ5W61O5ghn8euR3%3D-FU0gWt%2B3D5vdfQadEPpAr1w%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/CAA%3Diw__eLGX9J5bD_eZCBG8pHa9bRXXYtfPPe8wYr77Q0L7AXQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Easiest front end JavaScript framework to integrate with a Django backend?

2018-11-28 Thread Joel Mathew
I've been thinking a lot about the most painless way of learning a
javascript framework. My project is almost complete, and so far everything
has been written in javascript using jquery. But for what I have planned
next, a framework would be immensely helpful. I just wish it was as easy as
learning python and django!
Sincerely yours,

 Joel G Mathew



On Wed, 28 Nov 2018 at 19:37, Jason  wrote:

> Its really personal preference at times, especially for personal
> projects.  That said, when it comes to frameworks like angular, react, vue,
> picking one is like picking a version control solution.
>
> --
> 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/c3112a43-a617-492d-b79c-2223ea3b201b%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_86fyGaehzSn1s3uqAmv%2BqkNuo5nqewN9yGZXRr1Ui5YQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Easiest front end JavaScript framework to integrate with a Django backend?

2018-11-29 Thread Joel Mathew
I didnt see anyone recommending React. Is there any aspect that makes it
difficult to use with django?

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


  1   2   >