Re:

2022-09-26 Thread Tom Lafferty
814-380-6157

Thank you

-Tom



On Mon, Sep 26, 2022 at 4:12 PM Giovanni Silva  wrote:

> +5531995321877
>
>
> Em 26 de set. de 2022, à(s) 15:31, Daniel Joseph <
> ogooluwawealth.jo...@gmail.com> escreveu:
>
> Daniel Joseph
> +2348036267282
>
> On Mon, 26 Sept 2022 at 13:53, Abdulfarid Olakunle 
> wrote:
>
>> Hello fellow developers, I will be creating a WhatsApp group chat later
>> in the day, So I will like my fellow Python Django Developers to join the
>> group. It will be much easier to discuss there and I will sacrifice myself
>> out for anyone who need my service.
>>
>> God bless you all
>> Enjoy your day
>> Biliaminu
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CA%2BccuR0goa8Mu9MqNLyZtCAJedHKpVZ6pFfrpXKFJdjaRrgttQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CA%2BccuR0goa8Mu9MqNLyZtCAJedHKpVZ6pFfrpXKFJdjaRrgttQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAMHD5ZQi5ydGYETT6BKfkzJhUs7ncVn4fYTugqsAQtLVPnuj1g%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAMHD5ZQi5ydGYETT6BKfkzJhUs7ncVn4fYTugqsAQtLVPnuj1g%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/9C30BDC1-6374-4FE7-A19B-C31330C591EE%40gmail.com
> <https://groups.google.com/d/msgid/django-users/9C30BDC1-6374-4FE7-A19B-C31330C591EE%40gmail.com?utm_medium=email&utm_source=footer>
> .
>

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


Re: controlling stdout

2020-12-05 Thread Tom Sgouros
Thank you. Now I guess I'll work on figuring out *where* it was redirected.

But the "dunder" version of sys.stdout is an excellent clue -- I did not
know about that, and bonus gratitude points for giving me a new word to use.

 -Tom

On Sat, Dec 5, 2020 at 9:06 AM Shaheed Haque  wrote:

> I would hazard a guess that Django has already redirected stderr and or
> stdout before your code gets to run.
>
> I recommend that you stop your code in the debugger just *before* you try
> your redirection and look at the state of sys.stderr and sys.stdout. Also,
> I'm not sure if you are aware of the dunder versions of these (see
> https://docs.python.org/3/library/sys.html)? Comparing sys.stdout with
> sys.__stdout__ might reveal interesting results for example.
>
> Once you know what Django has already done, I expect you will be able to
> progress.
>
> On Sat, 5 Dec 2020, 13:18 Tom Sgouros,  wrote:
>
>> Matlab is the native language of the group for which I am building this
>> interface. It is for access to ocean sensor data, and it's being done this
>> way so the scientists whose sensors they are can use a significant body of
>> legacy code in their analyses. (Though I was planning to sneak in an option
>> to use python scripts because that's what I prefer.)
>>
>> But the fact remains that I have no trouble capturing stdout when I run
>> this python on the command line and it doesn't work when I run it as part
>> of a Django views.py and I don't where to begin trying to understand why
>> not.
>>
>>  -Tom
>>
>> On Fri, Dec 4, 2020 at 3:33 PM Kris A. Stern 
>> wrote:
>>
>>> Why not try something Python based instead which is also free. What kind
>>> of functionality are you looking for? Are you planning to plot, if so you
>>> could try numpy, scipy, and matplotlib.
>>>
>>> On Sat, 5 Dec 2020 at 02:02, Tom Sgouros  wrote:
>>>
>>>> Anybody have any random thoughts about this? I have run out of ideas to
>>>> test.
>>>>
>>>> Thank you,
>>>>
>>>>  -Tom
>>>>
>>>> On Wed, Dec 2, 2020 at 10:32 PM Tom Sgouros  wrote:
>>>>
>>>>> Hello all:
>>>>>
>>>>> I have a Django application that dispatches processing to a matlab
>>>>> script using exec. How can I capture the stdout and stderr of the script's
>>>>> execution?
>>>>>
>>>>> Outside of Django, this works for a dumb matlab script called tt that
>>>>> just prints a message:
>>>>>
>>>>> >>> import matlab.engine, StringIO
>>>>> >>> eng = matlab.engine.start_matlab()
>>>>> >>> out = StringIO.StringIO()
>>>>> >>> err = StringIO.StringIO()
>>>>> >>> exec('eng.tt(25, stdout=out, stderr=err)')
>>>>> >>> out.getvalue()
>>>>> "This is a disp command.\n\nret =\n\n '25\n\n"
>>>>>
>>>>> Inside a Django method, the exec seems to function properly, but the
>>>>> out and err variables remain empty. Where's my output? Did the logging
>>>>> system snatch it? I assume I'm missing something obvious here but any
>>>>> pointers would be welcome.
>>>>>
>>>>> Thank you,
>>>>>
>>>>>  -Tom
>>>>>
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Django users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to django-users+unsubscr...@googlegroups.com.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/django-users/35b264b3-f793-4131-a6e4-700e51aebbfan%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/django-users/35b264b3-f793-4131-a6e4-700e51aebbfan%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Django users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to django-users+unsubscr...@googlegroups.com.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/django-users/CAFUviqs6XXxfzOq

Re: controlling stdout

2020-12-05 Thread Tom Sgouros
Matlab is the native language of the group for which I am building this
interface. It is for access to ocean sensor data, and it's being done this
way so the scientists whose sensors they are can use a significant body of
legacy code in their analyses. (Though I was planning to sneak in an option
to use python scripts because that's what I prefer.)

But the fact remains that I have no trouble capturing stdout when I run
this python on the command line and it doesn't work when I run it as part
of a Django views.py and I don't where to begin trying to understand why
not.

 -Tom

On Fri, Dec 4, 2020 at 3:33 PM Kris A. Stern  wrote:

> Why not try something Python based instead which is also free. What kind
> of functionality are you looking for? Are you planning to plot, if so you
> could try numpy, scipy, and matplotlib.
>
> On Sat, 5 Dec 2020 at 02:02, Tom Sgouros  wrote:
>
>> Anybody have any random thoughts about this? I have run out of ideas to
>> test.
>>
>> Thank you,
>>
>>  -Tom
>>
>> On Wed, Dec 2, 2020 at 10:32 PM Tom Sgouros  wrote:
>>
>>> Hello all:
>>>
>>> I have a Django application that dispatches processing to a matlab
>>> script using exec. How can I capture the stdout and stderr of the script's
>>> execution?
>>>
>>> Outside of Django, this works for a dumb matlab script called tt that
>>> just prints a message:
>>>
>>> >>> import matlab.engine, StringIO
>>> >>> eng = matlab.engine.start_matlab()
>>> >>> out = StringIO.StringIO()
>>> >>> err = StringIO.StringIO()
>>> >>> exec('eng.tt(25, stdout=out, stderr=err)')
>>> >>> out.getvalue()
>>> "This is a disp command.\n\nret =\n\n '25\n\n"
>>>
>>> Inside a Django method, the exec seems to function properly, but the out
>>> and err variables remain empty. Where's my output? Did the logging system
>>> snatch it? I assume I'm missing something obvious here but any pointers
>>> would be welcome.
>>>
>>> Thank you,
>>>
>>>  -Tom
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/35b264b3-f793-4131-a6e4-700e51aebbfan%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/35b264b3-f793-4131-a6e4-700e51aebbfan%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAFUviqs6XXxfzOqQ4uCnVBEo2cN%2BbMMPHPEO-wtbxPVa94PtHw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAFUviqs6XXxfzOqQ4uCnVBEo2cN%2BbMMPHPEO-wtbxPVa94PtHw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAMxZ8Sm7avV%3Df664b%3D8hYQWgAUwvpL%2BLVZV%3D31Hy21B2xeSDtA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAMxZ8Sm7avV%3Df664b%3D8hYQWgAUwvpL%2BLVZV%3D31Hy21B2xeSDtA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

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


Re: controlling stdout

2020-12-04 Thread Tom Sgouros
Anybody have any random thoughts about this? I have run out of ideas to
test.

Thank you,

 -Tom

On Wed, Dec 2, 2020 at 10:32 PM Tom Sgouros  wrote:

> Hello all:
>
> I have a Django application that dispatches processing to a matlab script
> using exec. How can I capture the stdout and stderr of the script's
> execution?
>
> Outside of Django, this works for a dumb matlab script called tt that just
> prints a message:
>
> >>> import matlab.engine, StringIO
> >>> eng = matlab.engine.start_matlab()
> >>> out = StringIO.StringIO()
> >>> err = StringIO.StringIO()
> >>> exec('eng.tt(25, stdout=out, stderr=err)')
> >>> out.getvalue()
> "This is a disp command.\n\nret =\n\n '25\n\n"
>
> Inside a Django method, the exec seems to function properly, but the out
> and err variables remain empty. Where's my output? Did the logging system
> snatch it? I assume I'm missing something obvious here but any pointers
> would be welcome.
>
> Thank you,
>
>  -Tom
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/35b264b3-f793-4131-a6e4-700e51aebbfan%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/35b264b3-f793-4131-a6e4-700e51aebbfan%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

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


controlling stdout

2020-12-02 Thread Tom Sgouros
Hello all:

I have a Django application that dispatches processing to a matlab script 
using exec. How can I capture the stdout and stderr of the script's 
execution?

Outside of Django, this works for a dumb matlab script called tt that just 
prints a message:

>>> import matlab.engine, StringIO
>>> eng = matlab.engine.start_matlab()
>>> out = StringIO.StringIO()
>>> err = StringIO.StringIO()
>>> exec('eng.tt(25, stdout=out, stderr=err)')
>>> out.getvalue()
"This is a disp command.\n\nret =\n\n '25\n\n"

Inside a Django method, the exec seems to function properly, but the out 
and err variables remain empty. Where's my output? Did the logging system 
snatch it? I assume I'm missing something obvious here but any pointers 
would be welcome.

Thank you,

 -Tom


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/35b264b3-f793-4131-a6e4-700e51aebbfan%40googlegroups.com.


Re: How to best secure environment variables (secret key, passwords etc.) stored in .yml files?

2020-02-07 Thread Tom Moore
Thanks everyone for responding to this question. Nice to know (in a way) 
that I'm not overthinking it.. although now I'm worried about all the 
different ways a key could be compromised.

Your suggestions for separating out a .env file and using gitignore is 
really helpful.

Tom

On Thursday, January 30, 2020 at 8:01:59 PM UTC, Michael Rohan wrote:
>
> Hi,
>
> Just fyi, it was, in part, to solve this problem that I implemented the 
> django-yamlconf module:
>
> https://django-yamlconf.readthedocs.io/en/latest/
>
> While getting the data into either a private yaml file or env variable in 
> the container isn't addressed, it does allow injecting the values into the 
> Django app without modifying the committed sources.
>
> Take care,
> Michael.
>
> On Thu, Jan 30, 2020 at 6:46 AM Chris Wedgwood  > wrote:
>
>> Hi Tom
>>
>> You are definitely not overthinking this. it's important.
>>
>> This is an area that has baked my noodle for a while now and I always am 
>> left wondering "Do I have this right?" "Am I vulnerable to attack?" . 
>> and I still haven't figured it out completely. It's like static files  I 
>> never really feeel like I get it entirely :)
>>
>> Firstly you should never need to store a password/token/secret in Source 
>> Control ever. If you are stop and think there must be a better way.
>>
>> I use environment variables .env to store my secrets but the trick is 
>> ALWAYS put that in your .gitignore  file. If you start a new git repository 
>> there is an option to create a .gitignore file 
>> for Python that is a great starting point.
>>
>> To complement my *.env* file it has a .env.example file that I DO put in 
>> source control with a dummy password.
>>
>> .env file:
>>
>> MAILGUN_API_KEY =asjdhasds78dy9s8dy012287e210eu209e72
>>
>> .env.example:
>>
>> MAILGUN_API_KEY=ThisIsNotARealToken
>>
>> So when I do local development  I can populate my .env fie with local dev 
>> secrets.
>>
>> For production deployments, I use *Ansible *for which I provide 
>> production tokens and secrets in a separate file also not in source control.
>>
>> The Ansible deployment requires an ssh password that I store in a 
>> Password Manager that has two-factor authentication.
>>
>> The docker-compose file can read environment variables from the .env file.
>>
>> Have a look at Django-Cookiecutter and see how they do it. That helped me 
>> a lot when I started out
>>
>> cheers
>> Chris
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Thursday, 30 January 2020 12:41:01 UTC, Tom Moore wrote:
>>>
>>> Hi there, I'm following the guidelines by making sure the environment 
>>> variables are stored outside of the settings.py files.
>>>
>>> The project is "dockerised" and so the environment variables have been 
>>> stored in files *docker-compose.yml* and *docker-compose-prod.yml*.
>>>
>>> This includes things like the project's secret key, API keys, and 
>>> database passwords.
>>>
>>> *My question is: *
>>> • Just because environment variables are stored in .yml files, won't 
>>> they be equally insecure the moment I commit the project folder to a git 
>>> repo (and especially if I push that repo to GitHub)?
>>> e.g. the Secret Key will forevermore be stored in the git repo (in 
>>> earlier versions, even if I later move it to another file in subsequent 
>>> commits).
>>>
>>> Is there an even more secure way of storing environment variables? Or am 
>>> I overthinking it (as I'm the only developer and the GitHub repo is set to 
>>> Private)?
>>>
>>> Many thanks in advance for your 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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/55f28dec-7c9a-4cae-b658-f89772aa1bd7%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/55f28dec-7c9a-4cae-b658-f89772aa1bd7%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> -- 
> Michael Rohan
> mro...@acm.org 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e54a3ad3-1df3-49aa-8ae0-7378f3c91ace%40googlegroups.com.


Re: What's a recommended/common approach to staging and production apps in Heroku, using Docker containers?

2020-02-07 Thread Tom Moore
Hi Alvaro,

Thanks very much for the suggestion, nice to understand how two containers 
can be set up to interact with each other.

Tom

On Thursday, January 30, 2020 at 1:10:02 PM UTC, Álvaro Durán wrote:
>
> Hi Tom,
> I had a similar problem a while ago using React and Django as separate 
> containers, this tutorial helped me very much: 
> https://dev.to/englishcraig/creating-an-app-with-docker-compose-django-and-create-react-app-31lf
>
> I'm not aware whether that's suitable to your case, but if it is so, I put 
> together a cookiecutter based on that tutorial that you may want to have a 
> look at if you fancy: https://github.com/ohduran/cookiecutter-react-django
>
> Happy to hear comments from other people on the quality of this tutorial 
> while using Heroku.
>
> Alvaro.
>
> On Thursday, 30 January 2020 13:41:01 UTC+1, Tom Moore wrote:
>>
>> Hi there, 
>>
>>
>> I'm trying to set up *staging* and *production* apps in Heroku. Nothing 
>> fancy, just a way to test the app is running okay on Heroku's platform 
>> before it gets pushed to production.
>>
>>
>> The project is containerised in Docker.
>>
>>
>> I've tried setting up a pipeline in Heroku, but when I click "promote to 
>> production" on the staging app, Heroku displays an error saying that action 
>> is not supported for docker containers.
>>
>>
>> If that's true (and Docker is still popular), what is a recommended 
>> workflow for this?
>>
>>
>> The only workaround I can think of is to simply have two apps running in 
>> Heroku (*project-name-staging* and *project-name-production*) and just 
>> push the codebase to one and then the other manually from my local machine. 
>> But surely there's a better way.
>>
>>
>> Thanks very much in advance for your 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bccd01d8-942e-487b-b4cd-0efa957cf99f%40googlegroups.com.


How to best secure environment variables (secret key, passwords etc.) stored in .yml files?

2020-01-30 Thread Tom Moore
Hi there, I'm following the guidelines by making sure the environment 
variables are stored outside of the settings.py files.

The project is "dockerised" and so the environment variables have been 
stored in files *docker-compose.yml* and *docker-compose-prod.yml*.

This includes things like the project's secret key, API keys, and database 
passwords.

*My question is: *
• Just because environment variables are stored in .yml files, won't they 
be equally insecure the moment I commit the project folder to a git repo 
(and especially if I push that repo to GitHub)?
e.g. the Secret Key will forevermore be stored in the git repo (in earlier 
versions, even if I later move it to another file in subsequent commits).

Is there an even more secure way of storing environment variables? Or am I 
overthinking it (as I'm the only developer and the GitHub repo is set to 
Private)?

Many thanks in advance for your 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/887bcd5b-4525-4a54-a4e5-5eae32b20041%40googlegroups.com.


What's a recommended/common approach to staging and production apps in Heroku, using Docker containers?

2020-01-30 Thread Tom Moore


Hi there, 


I'm trying to set up *staging* and *production* apps in Heroku. Nothing 
fancy, just a way to test the app is running okay on Heroku's platform 
before it gets pushed to production.


The project is containerised in Docker.


I've tried setting up a pipeline in Heroku, but when I click "promote to 
production" on the staging app, Heroku displays an error saying that action 
is not supported for docker containers.


If that's true (and Docker is still popular), what is a recommended 
workflow for this?


The only workaround I can think of is to simply have two apps running in 
Heroku (*project-name-staging* and *project-name-production*) and just push 
the codebase to one and then the other manually from my local machine. But 
surely there's a better way.


Thanks very much in advance for your 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f840735e-2833-4f8e-bb94-ebc3beb90b4e%40googlegroups.com.


How to filter a Window query?

2020-01-01 Thread Tom J. Wassing
I am search for a solution to filter the results of a query which uses
a window function. I would like to reduce the results set to only
include the entries where the row number is smaller than 10. It is not
supported by the ORM to filter directly on this query set
(https://code.djangoproject.com/ticket/28333). Is there a workaround
for this?

For example (not working):

row_number = Window(
expression=RowNumber(),
output_field='row',
partition_by=(TruncDate('created')),
order_by=F('created').desc())

posts_with_row = (Post.objects
 .annotate(row=row_number)
 .filter(row_number__range=(1, 10)))

Best,

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1674aa7c-6e0e-4157-9178-16bc34226bb0%40googlegroups.com.


Django is not working

2019-08-22 Thread Tom Gertin
Hello, I have successfully install Django 1.11.22. However, I believe 
something is wrong because I cannot get the command that lists its version 
to work, in addition the manage.py help command also produces the same 
error. Here is the error.

$ pip install Django==1.11.22
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 
2020. Please upgrade your Python as Python 2.7 won't be maintained after 
that date. A future version of pip will drop support for Python 2.7.
Collecting Django==1.11.22
  Using cached 
https://files.pythonhosted.org/packages/70/22/237da71dc112f2bba335c18380bc403fba430c44cc4da088824e77652738/Django-1.11.22-py2.py3-none-any.whl
Requirement already satisfied: pytz in 
/home/ubuntu/.venv/my_geonode/lib/python2.7/site-packages (from 
Django==1.11.22) (2019.1)
Installing collected packages: Django
  Found existing installation: Django 1.11.21
Uninstalling Django-1.11.21:
  Successfully uninstalled Django-1.11.21
Successfully installed Django-1.11.22
WARNING: You are using pip version 19.1.1, however version 19.2.2 is 
available.
You should consider upgrading via the 'pip install --upgrade pip' command.
$ python -m django --version
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
  File 
"/home/ubuntu/.venv/my_geonode/lib/python2.7/site-packages/django/__main__.py", 
line 9, in 
management.execute_from_command_line()
  File 
"/home/ubuntu/.venv/my_geonode/local/lib/python2.7/site-packages/django/core/management/__init__.py",
 
line 364, in execute_from_command_line
utility.execute()
  File 
"/home/ubuntu/.venv/my_geonode/local/lib/python2.7/site-packages/django/core/management/__init__.py",
 
line 338, in execute
django.setup()
  File 
"/home/ubuntu/.venv/my_geonode/local/lib/python2.7/site-packages/django/__init__.py",
 
line 27, in setup
apps.populate(settings.INSTALLED_APPS)
  File 
"/home/ubuntu/.venv/my_geonode/local/lib/python2.7/site-packages/django/apps/registry.py",
 
line 85, in populate
app_config = AppConfig.create(entry)
  File 
"/home/ubuntu/.venv/my_geonode/local/lib/python2.7/site-packages/django/apps/config.py",
 
line 120, in create
mod = import_module(mod_path)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named contrib

Help would be appreciated. Also, what is odd is that if I enter the python 
console, I can import django and print out the version.

Thanks,

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/471a2ef7-8032-420f-8fd2-027f005d1d55%40googlegroups.com.


django-webpack-loader problem

2019-03-04 Thread Tom Zhang
Hi, all,

Hi, did anyone used this library before?

https://github.com/owais/django-webpack-loader

In my html, I put {% load render_bundle from webpack_loader %} in the
html, then I have {% render_bundle 'main' 'js' %}. However, django
says SyntaxError('invalid syntax', ('', 1, 2, "{%
render_bundle 'main.js' %}"))

This is the new error info:

WebpackBundleLookupError at /chem_ocr/rxn
Cannot resolve bundle main.
Request Method: GET
Request URL: http://localhost:8000/chem_ocr/rxn
Django Version: 2.1.5
Exception Type: WebpackBundleLookupError
Exception Value:
Cannot resolve bundle main.
Exception Location:
/var/www/ocr/venv/lib/python3.6/site-packages/webpack_loader/loader.py
in get_bundle, line 83
Python Executable: /var/www/ocr/venv/bin/python3
Python Version: 3.6.7
Python Path:
['/var/www/ocr/ocr',
 '/home/think/.vscode/extensions/ms-python.python-2019.2.5433/pythonFiles',
 '/usr/lib/python36.zip',
 '/usr/lib/python3.6',
 '/usr/lib/python3.6/lib-dynload',
 '/var/www/ocr/venv/lib/python3.6/site-packages']
Server time: Mon, 4 Mar 2019 07:32:14 +



Does anyone know why? Thanks

Tom

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


Re: Django template

2019-02-08 Thread Tom Zhang
Thanks. I know how to do this according to Django way. But if you use 
Django's way to transfer data, it makes it difficult to move to other 
frameworks, right? What do you think?

On Saturday, February 9, 2019 at 1:42:19 AM UTC-5, Mikko wrote:
>
> Hi,
>
> You can connect your backend to frontend using views.py file. In views.py 
> you can get and sort your data from SQL and send it to your html. 
>
> You probably should do tutorial or watch youtube videos (as I did since I 
> get bored in reading very fast) to learn more. CodingEntrepreneur has done 
> quite up to date videos, though you might need to check some point from 
> tutorial sheets as well.
> Here is a link to backend-frontend video, but better to see the series 
> from the beginning when you are new:
>
>
> https://www.youtube.com/watch?v=h05UEays2KI&list=PLEsfXFp6DpzTD1BD1aWNxS2Ep06vIkaeW&index=17
>
> My example from views.py, where I get and sort data from my database and 
> connect it to my webpage. In your html you need some code to get the data 
> from views.py.
>
> *views.py*
>
> from django.shortcuts import render
> from .models import news 
>
> def Home(request):
> worlddata = 
> news.objects.filter(subsection__exact='World').order_by('-created')[:8]
> args = {'worlddata': worlddata}
> return render(request, "news/home.html", args)
>
> In* home.html* (bolded ones is the code you need to connect to your 
> views.py)
>
> *{% for news in worlddata %}*
>  *{{ news.title }}* 
> 
> *{% endfor %}*
>
> -Mikko
>
>
> la 9. helmik. 2019 klo 8.15 Tom Zhang (compute...@gmail.com ) 
> kirjoitti:
>
>> Thanks. But if I do this way, how do I transfer data between back-end and 
>> front-end? Do I use post request?
>>
>>
>> On Friday, February 8, 2019 at 8:35:28 PM UTC-5, Nitin Kalmaste wrote:
>>>
>>> You are correct,
>>> You are using HTML and JavaScript as template in django. You need to 
>>> store static files like css/images/JavaScript in static folder and 
>>> configure static folder in the settings file
>>>
>>> On Sat, Feb 9, 2019, 1:00 AM Mikko Meronen >>
>>>> Hi,
>>>>
>>>> Have to say that Im still beginner in Django and coding, but I think 
>>>> you just create you html files to your templates folder, and in the end 
>>>> you 
>>>> are basically using just html. Django can just find your html file from 
>>>> templates folder.
>>>>
>>>> Im just learning javascript and I assume i can save my js-file to 
>>>> templates folder as well and connect it to my html.
>>>>
>>>> -Mikko
>>>>
>>>> pe 8.2.2019 klo 21.07 Tom Zhang  kirjoitti:
>>>>
>>>>> Hi, all,
>>>>>
>>>>> If I don't want to use Django template engine and I just want to use 
>>>>> regular html/javacript, how do I configure settings.py?
>>>>> I am thinking about the portability issue. For example, if I want to 
>>>>> move away from django in the future, I hope my templates can still be 
>>>>> used 
>>>>> in other frameworks, at least, with minimum changes.
>>>>> My settings are:
>>>>>
>>>>> TEMPLATES = [
>>>>> {
>>>>> 'BACKEND': 'django.template.backends.django.DjangoTemplates',
>>>>> 'DIRS': [os.path.join(BASE_DIR, 'templates')],
>>>>> 'APP_DIRS': True,
>>>>> 'OPTIONS': {
>>>>> 'context_processors': [
>>>>> 'django.template.context_processors.debug',
>>>>> 'django.template.context_processors.request',
>>>>> 'django.contrib.auth.context_processors.auth',
>>>>> 'django.contrib.messages.context_processors.messages',
>>>>> ],
>>>>> },
>>>>> },
>>>>> ]
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Tom
>>>>>
>>>>> -- 
>>>>> You received this message because you are subscribed to the Google 
>>>>> Groups "Django users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>>> an email to django-users...@googlegroups.com.
>>>>

Re: Django template

2019-02-08 Thread Tom Zhang
Thanks. But if I do this way, how do I transfer data between back-end and 
front-end? Do I use post request?


On Friday, February 8, 2019 at 8:35:28 PM UTC-5, Nitin Kalmaste wrote:
>
> You are correct,
> You are using HTML and JavaScript as template in django. You need to store 
> static files like css/images/JavaScript in static folder and configure 
> static folder in the settings file
>
> On Sat, Feb 9, 2019, 1:00 AM Mikko Meronen   wrote:
>
>> Hi,
>>
>> Have to say that Im still beginner in Django and coding, but I think you 
>> just create you html files to your templates folder, and in the end you are 
>> basically using just html. Django can just find your html file from 
>> templates folder.
>>
>> Im just learning javascript and I assume i can save my js-file to 
>> templates folder as well and connect it to my html.
>>
>> -Mikko
>>
>> pe 8.2.2019 klo 21.07 Tom Zhang > 
>> kirjoitti:
>>
>>> Hi, all,
>>>
>>> If I don't want to use Django template engine and I just want to use 
>>> regular html/javacript, how do I configure settings.py?
>>> I am thinking about the portability issue. For example, if I want to 
>>> move away from django in the future, I hope my templates can still be used 
>>> in other frameworks, at least, with minimum changes.
>>> My settings are:
>>>
>>> TEMPLATES = [
>>> {
>>> 'BACKEND': 'django.template.backends.django.DjangoTemplates',
>>> 'DIRS': [os.path.join(BASE_DIR, 'templates')],
>>> 'APP_DIRS': True,
>>> 'OPTIONS': {
>>> 'context_processors': [
>>>     'django.template.context_processors.debug',
>>> 'django.template.context_processors.request',
>>> 'django.contrib.auth.context_processors.auth',
>>> 'django.contrib.messages.context_processors.messages',
>>> ],
>>> },
>>> },
>>> ]
>>>
>>> Thanks,
>>>
>>> Tom
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django-users...@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/237d37a9-a913-430c-8861-eeedb8f6bece%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/django-users/237d37a9-a913-430c-8861-eeedb8f6bece%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...@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/CAGD0jjJju_32dqxzuz56z1EUqPnGirQFMFgn0RPOP_qWEGznPA%40mail.gmail.com
>>  
>> <https://groups.google.com/d/msgid/django-users/CAGD0jjJju_32dqxzuz56z1EUqPnGirQFMFgn0RPOP_qWEGznPA%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/14ac6d90-7e51-45dc-9a15-7a5938a6a471%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django template

2019-02-08 Thread Tom Zhang
I will give it a try first. Thanks

On Friday, February 8, 2019 at 2:30:39 PM UTC-5, Mikko wrote:
>
> Hi,
>
> Have to say that Im still beginner in Django and coding, but I think you 
> just create you html files to your templates folder, and in the end you are 
> basically using just html. Django can just find your html file from 
> templates folder.
>
> Im just learning javascript and I assume i can save my js-file to 
> templates folder as well and connect it to my html.
>
> -Mikko
>
> pe 8.2.2019 klo 21.07 Tom Zhang > 
> kirjoitti:
>
>> Hi, all,
>>
>> If I don't want to use Django template engine and I just want to use 
>> regular html/javacript, how do I configure settings.py?
>> I am thinking about the portability issue. For example, if I want to move 
>> away from django in the future, I hope my templates can still be used in 
>> other frameworks, at least, with minimum changes.
>> My settings are:
>>
>> TEMPLATES = [
>> {
>> 'BACKEND': 'django.template.backends.django.DjangoTemplates',
>> 'DIRS': [os.path.join(BASE_DIR, 'templates')],
>> 'APP_DIRS': True,
>> 'OPTIONS': {
>> 'context_processors': [
>> 'django.template.context_processors.debug',
>> 'django.template.context_processors.request',
>> 'django.contrib.auth.context_processors.auth',
>> 'django.contrib.messages.context_processors.messages',
>> ],
>> },
>> },
>> ]
>>
>> Thanks,
>>
>> Tom
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@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/237d37a9-a913-430c-8861-eeedb8f6bece%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/237d37a9-a913-430c-8861-eeedb8f6bece%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/493fdb29-83cd-46ea-bde9-cc27d6cecd90%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django template

2019-02-08 Thread Tom Zhang
Hi, all,

If I don't want to use Django template engine and I just want to use 
regular html/javacript, how do I configure settings.py?
I am thinking about the portability issue. For example, if I want to move 
away from django in the future, I hope my templates can still be used in 
other frameworks, at least, with minimum changes.
My settings are:

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
        'django.contrib.messages.context_processors.messages',
],
},
},
]

Thanks,

Tom

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


Django template

2019-02-08 Thread Tom Zhang
Hi,

If I don't want to use any Django template and I just want to use regular 
html/javascript, how should I setup the template config in settings.py?

Right now, my settings are:

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
        'django.contrib.messages.context_processors.messages',
],
},
},
]

Thanks,

Tom

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


Re: New to Django

2018-12-16 Thread tom riddle
Thanks for the responses. I was able to figure this out - I believe my
issue was that I did not activate the virtual environment and cd into the
folder containing the Django-admin exec file. Once I did that the command
worked.

On Sun, Dec 16, 2018 at 5:47 AM Okware Aldo  wrote:

> I can remotely help, provide access me with remote access or push code
> github
>
> On Sat, 15 Dec 2018, 20:54 
>> Hello - I'm trying to get Django up and running and I'm having some
>> likely trivial trouble. I'm following the "Writing your first Django app"
>> tutorial, but I'm getting stuck trying to create the project using 
>> 'django-admin
>> startproject mysite'. The output says command not found. I've tried
>> troubleshooting but haven't had any luck so far. Any assistance is much
>> appreciated.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send 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/b2057d6f-270c-4916-bf6d-da1cbf4e7c87%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/CAMEZma9fAWn%3DzToF-DF%2B4KyRZjEH_KYAc2_rThE8jcVt2gPQNw%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/CAKWYn%3DE8BB%3DZ-nRa398MVhKHL6efd-jyPtZfZAbaUiUjj6kvXw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multiple Database Setup problem !?

2018-11-02 Thread &#x27;Tom Evans' via Django users
Hi David

Your router isn't configured correctly. This applies to all the
allow_foo() methods, but see allow_migrate [1] as an example:

  Determine if the migration operation is allowed to run on the
database with alias db. Return True if the operation should run, False
if it shouldn’t run, or None if the router has no opinion.

Your routers *should* be having an opinion about whether that
app/model can be migrated on a specific database! For instance, you
say "the last app" should stay only on validations, but what your
ValidationRouter says is "If the app label is called fourth_model, run
migrations on this database", but it never checks what the database
is.

For ValidationRouter.allow_migrate you probably want something like this:

  def allow_migrate(self, ...):
  if app_label == "fourth_model":
  return db == "validations"
  elif db == "validations":
  return False

EG:
* if the app label is an app that should be in the validations DB,
allow migrate when the db is the validations DB
* if it isn't and the DB is the validations DB, don't allow migrations to it
* if neither of those things, this router doesn't care.

Similarly, for allow_relations() you should be returning False when
the models should not be related.

Incidentally, all python functions return None if the end of the
function is reached without an explicit return value, so you never
have to end your functions with an explicit "return None".

Cheers

Tom

[1] https://docs.djangoproject.com/en/2.1/topics/db/multi-db/#allow_migrate
On Tue, Oct 30, 2018 at 10:09 AM David Lubomirov
 wrote:
>
> Hello,
>
> In my project I have 3 applications, and I'm trying to split them across 2 
> databases.
>
> More specifically 2 of the apps and Django "auth" application should work 
> with the first database,
> and the last application should remain in the second database.
>
> These are the DB settings:
>
> DATABASE_ROUTERS = [
> '.PrimaryRouter',
> '.ValidationRouter'
> ]
>
> DATABASES = {
> 'default': {},
> 'primary': {
> 'NAME': 'primary',
> 'ENGINE': 'django.db.backends.postgresql',
> 'USER': '',
> 'PASSWORD': '',
> 'HOST': 'localhost',
> },
> 'validations': {
> 'NAME': 'validations',
> 'ENGINE': 'django.db.backends.postgresql',
> 'USER': '',
> 'PASSWORD': '',
> 'HOST': 'localhost',
> }
> }
>
> Therefore these are the class routers:
>
> class PrimaryRouter:
> """
> Router to control all database operations for the following applications:
> - first_model
> - second_model
> - auth
> """
> def db_for_read(self, model, **hints):
> if model._meta.app_label == 'auth' or \
> model._meta.app_label == 'first_model' or \
> model._meta.app_label == 'second_model':
>
> return 'primary'
>
> return None
>
> def db_for_write(self, model, **hints):
> if model._meta.app_label == 'auth' or \
> model._meta.app_label == 'first_model' or \
> model._meta.app_label == 'second_model':
>
> return 'primary'
>
> return None
>
> def allow_relation(self, first_object, second_object, **hints):
> if first_object._meta.app_label == 'auth' or \
> second_object._meta.app_label == 'auth':
>
> return True
>
> if first_object._meta.app_label == 'first_model' or \
> second_object._meta.app_label == 'first_model':
>
> return True
>
> if first_object._meta.app_label == 'second_model' or \
> second_object._meta.app_label == 'second_model':
>
> return True
>
> return None
>
> def allow_migrate(self, db, app_label, model_name=None, **hints):
> if app_label == 'auth' or \
> app_label == 'first_model' or \
> app_label == 'second_model':
>
> return db == 'primary'
>
> return None
>
>
> class ValidationRouter:
> """
> Router to control all database operations for the following applications:
> - fourth_model
> "&

Re: Help.... Django : Change Backend as mysql and create sample example using django ORM

2018-08-30 Thread Tom Forbes
Ensure you are using MySQL 5.6 or higher:
https://docs.djangoproject.com/en/2.1/ref/databases/#version-support

To find your version run SELECT VERSION();



On 30 August 2018 at 05:37:52, Sonali Vighne (sonalivig...@gmail.com) wrote:

MySQL  version-  6.0.8-alpha-community

On Wednesday, August 29, 2018 at 7:26:09 PM UTC+5:30, Tom Forbes wrote:
>
> What version of MySQL are you running?
>
> On Tuesday, 28 August 2018 07:00:52 UTC+1, Sonali Vighne wrote:
>>
>> I will paste full error and stack trace here.
>>
>> This is occurred when I am giving “python manage.py migrate” command
>>
>>
>>
>> Operations to perform:
>>
>>   Apply all migrations: admin, auth, contenttypes, sessions
>>
>> Running migrations:
>>
>> Traceback (most recent call last):
>>
>>   *File
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
>> line 83, in _execute*
>>
>> return self.cursor.execute(sql)
>>
>>   *File
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\mysql\base.py",
>> line 71, in execute*
>>
>> return self.cursor.execute(query, args)
>>
>>   *File
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
>> line 250, in execute*
>>
>> self.errorhandler(self, exc, value)
>>
>>   *File
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\connections.py",
>> line 50, in defaulterrorhandler*
>>
>> raise errorvalue
>>
>>   *File
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
>> line 247, in execute*
>>
>> res = self._query(query)
>>
>>   *File
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
>> line 411, in _query*
>>
>> rowcount = self._do_query(q)
>>
>>   *File
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
>> line 374, in _do_query*
>>
>> db.query(q)
>>
>>   *File
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\connections.py",
>> line 277, in query*
>>
>> _mysql.connection.query(self, query)
>>
>> _mysql_exceptions.ProgrammingError: (1064, "You have an error in your
>> SQL syntax; check the manual that corresponds to your MySQL server version
>> for the right syntax to use near '(6) NOT NULL)' at line 1")
>>
>>
>>
>> The above exception was the direct cause of the following exception:
>>
>>
>>
>> Traceback (most recent call last):
>>
>>   *File
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\migrations\recorder.py",
>> line 55, in ensure_schema*
>>
>> editor.create_model(self.Migration)
>>
>>   *File
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\base\schema.py",
>> line 312, in create_model*
>>
>> self.execute(sql, params or None)
>>
>>   *File
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\base\schema.py",
>> line 133, in execute*
>>
>> cursor.execute(sql, params)
>>
>>   *File
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
>> line 100, in execute*
>>
>> return super().execute(sql, params)
>>
>>   *File
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
>> line 68, in execute*
>>
>> return self._execute_with_wrappers(sql, params, many=False,
>> executor=self._execute)
>>
>>   *File
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
>> line 77, in _execute_with_wrappers*
>>
>> return executor(sql, params, many, context)
>>
>>   *File
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
>> line 85, in _execute*
>>
>> return self.cursor.execute(sql, params)
>>
>>  

Re: Help.... Django : Change Backend as mysql and create sample example using django ORM

2018-08-29 Thread Tom Forbes
What version of MySQL are you running? 

On Tuesday, 28 August 2018 07:00:52 UTC+1, Sonali Vighne wrote:
>
> I will paste full error and stack trace here.
>
> This is occurred when I am giving “python manage.py migrate” command
>
>  
>
> Operations to perform:
>
>   Apply all migrations: admin, auth, contenttypes, sessions
>
> Running migrations:
>
> Traceback (most recent call last):
>
>   *File 
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
>  
> line 83, in _execute*
>
> return self.cursor.execute(sql)
>
>   *File 
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\mysql\base.py",
>  
> line 71, in execute*
>
> return self.cursor.execute(query, args)
>
>   *File 
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
>  
> line 250, in execute*
>
> self.errorhandler(self, exc, value)
>
>   *File 
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\connections.py",
>  
> line 50, in defaulterrorhandler*
>
> raise errorvalue
>
>   *File 
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
>  
> line 247, in execute*
>
> res = self._query(query)
>
>   *File 
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
>  
> line 411, in _query*
>
> rowcount = self._do_query(q)
>
>   *File 
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
>  
> line 374, in _do_query*
>
> db.query(q)
>
>   *File 
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\connections.py",
>  
> line 277, in query*
>
> _mysql.connection.query(self, query)
>
> _mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL 
> syntax; check the manual that corresponds to your MySQL server version for 
> the right syntax to use near '(6) NOT NULL)' at line 1")
>
>  
>
> The above exception was the direct cause of the following exception:
>
>  
>
> Traceback (most recent call last):
>
>   *File 
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\migrations\recorder.py",
>  
> line 55, in ensure_schema*
>
> editor.create_model(self.Migration)
>
>   *File 
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\base\schema.py",
>  
> line 312, in create_model*
>
> self.execute(sql, params or None)
>
>   *File 
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\base\schema.py",
>  
> line 133, in execute*
>
> cursor.execute(sql, params)
>
>   *File 
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
>  
> line 100, in execute*
>
> return super().execute(sql, params)
>
>   *File 
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
>  
> line 68, in execute*
>
> return self._execute_with_wrappers(sql, params, many=False, 
> executor=self._execute)
>
>   *File 
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
>  
> line 77, in _execute_with_wrappers*
>
> return executor(sql, params, many, context)
>
>   *File 
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
>  
> line 85, in _execute*
>
> return self.cursor.execute(sql, params)
>
>   *File 
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\utils.py",
>  
> line 89, in __exit__*
>
> raise dj_exc_value.with_traceback(traceback) from exc_value
>
>   *File 
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
>  
> line 83, in _execute*
>
> return self.cursor.execute(sql)
>
>   *File 
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\mysql\base.py",
>  
> line 71, in execute*
>
> return self.cursor.execute(query, args)
>
>   *File 
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
>  
> line 250, in execute*
>
> self.errorhandler(self, exc, value)
>
>   *File 
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\connections.py",
>  
> line 50, in defaulterrorhandler*
>
> raise errorvalue
>
>   *File 
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
>  
> line 247, in execute*
>
> res = self._query(query)
>
>   *File 
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
>  
> line 411, in

New Uvicorn release. (Alternative to Daphne for Django Channels)

2018-08-14 Thread Tom Christie
Hi folks,

I've been putting a lot of work into Uvicorn lately.
It's an ASGI server, similar to Daphne, and can be used as the server to 
run Django channels (amongst other things).

https://www.uvicorn.org/

It's got lots of nice behavior around resource limiting, graceful restarts, 
support for pypy and windows, fast uvloop/httptools or wsproto/wsaccel 
options for cpython, etc...

I think we're getting towards the point that it might be worth adding 
alternate servers to the official Django channels documentation,
but I'd like to get a bit more feedback from folks using the server for 
channels, on if there are any integration issues that I'm not aware of.

(I expect that most folks using uvicorn at the moment are using it with API 
Star, rather than channels.)

There's also another ASGI webserver, Hypercorn...

https://github.com/pgjones/hypercorn

I'd also be keen to get any feedback from folks running django channels 
with either `uvicorn` or `hypercorn`.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/3f02a37b-3d18-44d7-b70a-a63c73427ba9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


SMTPRecipientsRefused: Sender address rejected: not owned by user

2018-05-15 Thread Tom Tanner
I have a Django app running on a server with uWSGI and nginx. 

In my `local_settings.py` file I have this:

###
# EMAIL SETUP #
###
EMAIL_HOST = 'smtp.privateemail.com'
EMAIL_HOST_USER = 'supp...@mydomain.com'
EMAIL_HOST_PASSWORD = 'MY EMAIL PASSWORD'
EMAIL_PORT = 465
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True



# OTHER EMAIL SETTINGS #

ADMIN_EMAIL = "ad...@mydomain.com"
SUPPORT_EMAIL = "supp...@mydomain.com"
DEFAULT_FROM_EMAIL = ADMIN_EMAIL
SERVER_EMAIL = ADMIN_EMAIL

I run `python manage.py runserver` on my local machine in the Django 
project's virtual environment. I fill out the password reset form at 
`password_rest/` using the email `my.perso...@gmail.com` and submit it. I 
get this error.

SMTPRecipientsRefused: {u'my.perso...@gmail.com': (553, '5.7.1 
: Sender address rejected: not owned by user 
supp...@mydomain.com')}

My website's email provider is Namecheap.

Why do I get this error when testing on my local machine? What must I 
change/add to get rid of 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/c159b190-4604-4b2d-90d6-562f9b4950db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Password reset in Django on nginx server writes to log file instead of sending email

2018-05-14 Thread Tom Tanner
I have a Django app running on a server with uWSGI and nginx. 

In my `local_settings.py` file I have this:

###
# EMAIL SETUP #
###
EMAIL_HOST = 'smtp.privateemail.com'
EMAIL_HOST_USER = 'supp...@mydomain.com'
EMAIL_HOST_PASSWORD = 'MY EMAIL PASSWORD'
EMAIL_PORT = 465
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True



# OTHER EMAIL SETTINGS #

ADMIN_EMAIL = "ad...@mydomain.com"
SUPPORT_EMAIL = "supp...@mydomain.com"


When I fill out the `/password_reset/` template with an email and submit 
the form, the address I enter gets no password-reset message. Nothing is 
logged to *error.log*. Here's what I see in *uwsgi.log*

[pid: 3354|app: 0|req: 1489/2206] 73.49.35.42 () {44 vars in 948 bytes} 
[Mon May 14 16:59:06 2018] GET /login-register/ => generated 7480 bytes in 
39 msecs (HTTP/1.1 200) 3 headers in 102 bytes (2 switches on core 0)
[pid: 3355|app: 0|req: 718/2207] 73.49.35.42 () {44 vars in 994 bytes} [
Mon May 14 16:59:14 2018] GET /password_reset/ => generated 3669 bytes in 38 
msecs (HTTP/1.1 200) 4 headers in 256 bytes (1 switches on core 0)
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Subject: Password reset on Default
From: webmaster@localhost
To: email.to.send.password.re...@gmail.com
Date: Mon, 14 May 2018 16:59:16 -
Message-ID: <20180514165916.3354.5092@my-ubuntu-server-hostname.mydomain
.com>



Hello,

You received this email because a request was made to reset the password
.


If you requested this, go to the following page and choose a new 
password: https://127.0.0.1:8000/reset/MQ/4w6-efc1272e976075dfd881/

Your username: MyUsername

Thank you.




---
[pid: 3354|app: 0|req: 1490/2208] 73.49.35.42 () {52 vars in 1194 bytes} 
[Mon May 14 16:59:16 2018] POST /password_reset/ => generated 0 bytes in 22 
msecs (HTTP/1.1 302) 4 headers in 138 bytes (1 switches on core 0)
[pid: 3355|app: 0|req: 719/2209] 73.49.35.42 () {46 vars in 1035 bytes} 
[Mon May 14 16:59:16 2018] GET /password_reset/done/ => generated 2877 
bytes in 40 msecs (HTTP/1.1 200) 3 headers in 102 bytes (1 switches on core 
0)



What must I change so that Django will email the email I input in the 
`/password_reset` template?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/e6dd4643-4692-42b0-adf7-670fc973ee71%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


IOError when trying to send email in Django app

2018-05-11 Thread Tom Tanner
I have a Django app running on a server with uWSGI and nginx. 

In my `local_settings.py` file I have this:

###
# EMAIL SETUP #
###
EMAIL_HOST = 'smtp.privateemail.com'
EMAIL_HOST_USER = 'supp...@mydomain.com'
EMAIL_HOST_PASSWORD = 'MY EMAIL PASSWORD'
EMAIL_PORT = 587
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True



# OTHER EMAIL SETTINGS #

ADMIN_EMAIL = "ad...@mydomain.com"
SUPPORT_EMAIL = "supp...@mydomain.com"


When I fill out the `/password_reset/` template with an email and submit 
the form, the email I enter gets no email. 

I see these lines in my `uwsgi.log` file after I submit the password reset 
form.

Fri May 11 17:48:10 2018 - SIGPIPE: writing to a closed pipe/socket/fd 
(probably the client disconnected) on request /password_reset/ (ip 
73.49.35.42) !!!
Fri May 11 17:48:10 2018 - uwsgi_response_write_headers_do(): Broken 
pipe [core/writer.c line 248] during POST /password_reset/ (73.49.35.42)
IOError: write error

What error is this? Why won't the password reset email send?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/5a50ba30-9709-48a9-a937-bd9afb8bbf30%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: 400 error, nginx debug log confusion, Django app

2018-05-11 Thread Tom Tanner
I ran `sudo reboot` and `sudo service nginx configtest && sudo service 
nginx restart`. Now the site loads just fine. I don't know which of those 
two commands did it.

On Friday, May 11, 2018 at 12:22:11 PM UTC-4, Tom Tanner wrote:
>
> Note: `mydomain.com` is not my real domain name.
>
> When I go to `test.mydomain.com`, I get a page that just says `Bad 
> Request (400)`. 
>
> I'm running a Django app located at `/home/django/product_blog`.
>
> Here are the contents of my nginx file at 
> `/etc/nginx/sites-available/BRBR2`.
>
> server {
> listen 80;
> server_name test.mydomain.com;
> error_log /var/log/nginx/debug.log debug;
> 
> location = /favicon.ico { access_log off; log_not_found off; }
> location /static/ {
> root /home/django/product_blog;
> }
> 
> location / {
> include uwsgi_params;
> uwsgi_pass  
> unix:/home/django/product_blog/product_blog.sock;
> }
> }
>
> When I go to the debug file after trying to load the site, I see this: 
> https://pastebin.com/GchPd1MD.
>
> The file at `/var/log/nginx/error.log` shows nothing.
>
> How do I find the source of the 400 error?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/f51f5b16-59d5-438d-8cd8-27f8264ad5c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


400 error, nginx debug log confusion, Django app

2018-05-11 Thread Tom Tanner
Note: `mydomain.com` is not my real domain name.

When I go to `test.mydomain.com`, I get a page that just says `Bad Request 
(400)`. 

I'm running a Django app located at `/home/django/product_blog`.

Here are the contents of my nginx file at 
`/etc/nginx/sites-available/BRBR2`.

server {
listen 80;
server_name test.mydomain.com;
error_log /var/log/nginx/debug.log debug;

location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/django/product_blog;
}

location / {
include uwsgi_params;
uwsgi_pass  
unix:/home/django/product_blog/product_blog.sock;
}
}

When I go to the debug file after trying to load the site, I see this: 
https://pastebin.com/GchPd1MD.

The file at `/var/log/nginx/error.log` shows nothing.

How do I find the source of the 400 error?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/c8f497b0-8d9c-4695-a1ff-39abddc90bf5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


committing migration files

2018-04-30 Thread Tom Scrace
Hi all,

The way I've always worked, developers run `makemigrations` locally, and 
commit migration files to the repo.

However, a suggestion has recently come my way that a better strategy is to 
only commit model changes to the repo (leaving the migrations directory 
gitignored), and then run `makemigrations` in whatever environment the app 
needs to run, whether that's another developer's laptop, or in production. 
The putative benefit is that this avoids the possibility of migration 
conflicts, and always guarantees a clean migration from the state of a 
database schema to the state of the Django models.

Googling around, this opinion seems to be moderately widespread, although 
the official docs, and the *majority* of commenters seem to agree that 
committing migration files is the right way.

I think I agree, but I can't quite put my finger on decisive arguments 
against the idea of not committing migration files. I feel like I am 
missing something.

What are some reasons we should go the route of committing migration files?

Thanks,
Tom

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


How do I move my development data tables to production server?

2018-04-23 Thread Tom Tanner
Hey all, I have a bunch of tables on my local Django project. I set up the 
project on my production server and ran `manage.py migrate`. That set up 
the tables, but now I want to move the rows from my local tables to the 
ones on the production server. Both local and production server use 
Postgres. Is there a Django way to move the table data to production?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/f65cd8eb-6399-4ee7-8830-84b19ea9b689%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Trying to understand two messages from `manage.py check --deploy`

2018-04-23 Thread Tom Tanner
I get these two messages after running `python manage.py check --deploy`

?: (security.W001) You do not have 
'django.middleware.security.SecurityMiddleware' in your MIDDLEWARE_CLASSES 
so the SECURE_HSTS_SECONDS, SECURE_CONTENT_TYPE_NOSNIFF, 
SECURE_BROWSER_XSS_FILTER, and SECURE_SSL_REDIRECT settings will have no 
effect.
?: (security.W019) You have 
'django.middleware.clickjacking.XFrameOptionsMiddleware' in your 
MIDDLEWARE_CLASSES, but X_FRAME_OPTIONS is not set to 'DENY'. The default 
is 'SAMEORIGIN', but unless there is a good reason for your site to serve 
other parts of itself in a frame, you should change it to 'DENY'.

I do not understand what each of them mean or if I should be worried. Can 
anyone translate these to plain English?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/1c0b2ca2-644c-4eac-9494-d3239e22f220%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How do I use `password_reset_confirm.html` with AngularJS?

2018-03-21 Thread Tom Tanner


I want to integrate AngularJS in my custom password_reset_confirm.html template 
in Django. But when I fill out a new password and hit "submit," nothing 
happens.

Here's more info in better 
formatting: 
https://stackoverflow.com/questions/49396333/how-do-i-use-password-reset-confirm-html-with-angularjs

Can anyone 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/a6e87b9e-cc33-4604-a669-bf353f5b0923%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Get data from an external api into my database.

2018-03-20 Thread &#x27;Tom Evans' via Django users
On Tue, Mar 20, 2018 at 10:23 AM, Mukesh Jha  wrote:
> I want to access a api from http://open-platform.theguardian.com/ or
> https://newsapi.org/ and load it into my sqlite database. The data in these
> site is in json format and I want them to get converted into my database
> model format and store in it and later on use them as when queried. I am
> clueless as I am quite new in this development system. Please help if
> possible.
>

Adjust for your needs:

  data = requests.get(url).json()
  for datum in data:
  MyModel.objects.save(**datum)

Cheers

Tom

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


Re: Trouble deploying Django/wagtail on Ubuntu 14.04

2018-03-20 Thread &#x27;Tom Evans' via Django users
It is not looking for "home_page.html", it is looking for
"base/home_page.html". On the error page it lists the locations it is
searching for the template, and explicitly says the directories that
are being searched.

You say the file is at
/home//bakerydemo/bakerydemo/templates/base/home_page.html

It says it is looking in /var/www/bakerydemo/templates/

This means that your TEMPLATES['DIRS'] setting is wrong.

Looking at the configuration section of the error report shows that
you have put a relative path into TEMPLATE['DIRS']. Use
settings.PROJECT_ROOT to make that in to an absolute path, as the
example settings.py tells you to do.

Cheers

Tom

PS - there is very little point anonymising your username when you
share the full error report.

On Tue, Mar 20, 2018 at 4:14 PM, drone4four  wrote:
> Thank you, Andreas.  I added the python-path to my Apache ssl.conf and the
> Internal Server Error is gone now. It appears WSGI is serving my Django
> project perfectly.
>
> I adjusted ALLOWED_HOSTS just fine. But now Django is saying something about
> "TemplateDoesNotExist at /" in base/home_page.html.  You can see the full
> Django traceback here: https://daniel496.agency/
>
> $ locate home_page.html
> /home//.virtualenvs/wagtailbakerydemo/lib/python3.4/site-packages/wagtail/project_template/home/templates/home/home_page.html
> /home//bakerydemo/bakerydemo/templates/base/home_page.html
>
> The home_page.html file is present but apparently it is not being referred
> to properly in my configuration.  Can anyone shed some light on what the
> issue could be now?
>
> Thanks.
>
> On Tuesday, March 20, 2018 at 5:45:27 AM UTC-4, Cictani wrote:
>>
>> You have to set the python-path too:
>>
>> WSGIDaemonProcess bakerydemo
>> python-home=/home//.virtualenvs/wagtailbakerydemo/
>> python-path=/home//bakerydemo/
>>
>> In the logs you see "No module named 'bakerydemo'" because you did not add
>> the project directory to the python-path. Hope this works.
>>
>> Best regards
>>
>> Andreas
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send 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/d90b8924-5458-4c0e-8f0f-2866af4dd156%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/CAFHbX1%2B%2BfRpK3EqfqqojAt9%2BUyWyx79QYo-nopq0zx38Bdi93Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Running makemigrations in pluggable nested app using AppConfig

2018-03-19 Thread &#x27;Tom Evans' via Django users
In order to make it "work", I imported the models from foo_lib.django
app.models into foo_lib.models. Django was then able to find the
models, and create the migration files.

They are all in the wrong place however, that part of the library
should have nothing to do with django and so this obviously isn't
correct.

I didn't mention it in the first post, this is for
py{27,34,35,36}-dj{108,109,110,111,200}, and developing against
py36-dj200

Cheers

Tom

On Mon, Mar 19, 2018 at 3:35 PM, Tom Evans  wrote:
> Hi all
>
> I'm writing a small library which will be bundled together with a
> pluggable django app.
>
> The app provides a bunch of different AppConfig instances, the end
> user chooses one and pops it in their INSTALLED_APPS:
>
>   INSTALLED_APPS += [ 'foo_lib.contrib.django_app.configs.FooAppConfig', ]
>
> All the AppConfigs have their name attribute set to "foo_lib", they
> have their path attribute set to the directory containing models.py
> and there is a default AppConfig
>
> I have a test project that I'm using to run "makemigrations" and so
> on. With INSTALLED_APPS as above, django cannot find any changes for
> "foo_lib". If I supply the dotted path to the appconfig to
> "makemigrations", I am told:
>
>"App 'foo_lib.contrib.django.configs.FooAppConfig' could not be
> found. Is it in INSTALLED_APPS?"
>
> which is quite amusing.
>
> If I replace the path to the appconfig with the dotted path to the
> module, and then use "makemigrations django_app", then the migrations
> get created, but obviously that seriously sucks.
>
> Furthermore, even with the migration files in place, they are not
> actually acted upon when running migrate or tests.
>
>
> What is the correct way to do this?
>
> Cheers
>
> Tom

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


Running makemigrations in pluggable nested app using AppConfig

2018-03-19 Thread &#x27;Tom Evans' via Django users
Hi all

I'm writing a small library which will be bundled together with a
pluggable django app.

The app provides a bunch of different AppConfig instances, the end
user chooses one and pops it in their INSTALLED_APPS:

  INSTALLED_APPS += [ 'foo_lib.contrib.django_app.configs.FooAppConfig', ]

All the AppConfigs have their name attribute set to "foo_lib", they
have their path attribute set to the directory containing models.py
and there is a default AppConfig

I have a test project that I'm using to run "makemigrations" and so
on. With INSTALLED_APPS as above, django cannot find any changes for
"foo_lib". If I supply the dotted path to the appconfig to
"makemigrations", I am told:

   "App 'foo_lib.contrib.django.configs.FooAppConfig' could not be
found. Is it in INSTALLED_APPS?"

which is quite amusing.

If I replace the path to the appconfig with the dotted path to the
module, and then use "makemigrations django_app", then the migrations
get created, but obviously that seriously sucks.

Furthermore, even with the migration files in place, they are not
actually acted upon when running migrate or tests.


What is the correct way to do this?

Cheers

Tom

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


How do I set up an AngularJS-driven form to work with Django password reset functionality?

2018-03-13 Thread Tom Tanner
I'm working on a web page with AngularJS v1.5.6. This page has other forms. 
I want to add a "Reset password" form to this page.

I've seen this Django password reset for tutorial: 
https://simpleisbetterthancomplex.com/tutorial/2016/09/19/how-to-create-password-reset-view.html.
 
But I'm unsure how I'd apply it to my situation.

My questions is how would I set up urls.py and views.py to handle this?

Here's the example code on 
StackOverflow: 
https://stackoverflow.com/questions/49265097/how-do-i-set-up-an-angularjs-driven-form-to-work-with-django-password-reset-func

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/33acd11a-6a05-4d50-88c4-be93268e417f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: UUIDs eventually choke as primary key

2018-02-23 Thread &#x27;Tom Evans' via Django users
On Fri, Feb 23, 2018 at 4:20 PM, M Mackey  wrote:
> I have noticed in the python
> path that there are two paths to .../lib/python3.6. One from my virtualenv,
> and one at /usr/local/.  Not sure where to clear that up, since I don't
> believe I've got my apache env set up to pull from both places.

That would happen if you created your virtualenv with
--use-site-packages, it, er, puts the path to the site packages in the
pythonpath.

Cheers

Tom

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


StaticLiveServerTestCase: database emptied after first test after upgrading to Django 1.11

2018-02-23 Thread &#x27;Tom Evans' via Django users
Hi all

We have a bunch of functional tests derived from
StaticLiveServerTestCase using selenium that have started failing
after upgrading from Django 1.8 to Django 1.11.

The database is initially populated via data migrations, but after
running one test it all the data loaded via migrations has been
removed from the database, and all subsequent tests fail because the
expected data is not in the database.

Note that this is after running one test, not one test case; if we run
each test from an affected test case individually, they pass; if we
run the entire test case, the first test passes and the rest fail.

These tests were initially written under Django 1.8, with the data
coming from the same migrations, and they worked correctly in Django
1.8.

I looked back through the release notes and documentation; rollback
emulation[1] via serialized_rollback=True appeared promising, but
after enabling it we had IntegrityErrors immediately after finishing
the first test; it appears as though when it was attempting to re-load
the serialized data back in to the database, the data was still there:

Any thoughts? I've included some of the output below - running without
serialized_rollback[2] and with[3]. Unfortunately, I cannot share much
of the code itself.

Cheers

Tom

[1] 
https://docs.djangoproject.com/en/1.11/topics/testing/overview/#rollback-emulation
[2]
tests.functional_tests.test_search_defaults.DefaultSearchResultsTest
test_browsing_to_a_saved_search_keeps_the_default_hero_block ...
[, , ]
ok
test_infinite_scrolling_of_search_results ... []
ERROR
screenshotting to
/home/london/te/moat-effortless_web_app/reports/screendumps/DefaultSearchResultsTest.test_infinite_scrolling_of_search_results-window0-2
018-02-23T11.59.55.png
dumping page HTML to
/home/london/te/moat-effortless_web_app/reports/screendumps/DefaultSearchResultsTest.test_infinite_scrolling_of_search_results-window
0-2018-02-23T11.59.55.html
writing har log to
/home/london/te/moat-effortless_web_app/reports/screendumps/DefaultSearchResultsTest.test_infinite_scrolling_of_search_results-window0-
2018-02-23T11.59.55.har.logwriting browser log to
/home/london/te/moat-effortless_web_app/reports/screendumps/DefaultSearchResultsTest.test_infinite_scrol
ling_of_search_results-window0-2018-02-23T11.59.55.browser.logLast URL
visited was http://dev-vip04.london.mintel.ad:53066/facelift/
http requests made during test:



==
ERROR: test_infinite_scrolling_of_search_results
(tests.functional_tests.test_search_defaults.DefaultSearchResultsTest)
--
Traceback (most recent call last):
  File 
"/data/home/london/te/moat-effortless_web_app/web_app/tests/functional_tests/test_search_defaults.py",
line 10, in test_infinite_scrolling_of_searc
h_results
homepage = HomePage.browse_to_directly(self)
  File 
"/data/home/london/te/moat-effortless_web_app/web_app/tests/functional_tests/pages/base.py",
line 61, in browse_to_directly
page.wait_for_page_load()
  File 
"/data/home/london/te/moat-effortless_web_app/web_app/tests/functional_tests/pages/home.py",
line 248, in wait_for_page_load
self.test.waitFor(_assert_page_ready)
  File 
"/data/home/london/te/moat-effortless_web_app/web_app/tests/functional_tests/base.py",
line 394, in waitFor
return function_with_assertion(*args)
  File 
"/data/home/london/te/moat-effortless_web_app/web_app/tests/functional_tests/pages/home.py",
line 246, in _assert_page_ready
'div.home-page'
  File 
"/data/home/london/te/moat-effortless_web_app/env/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py",
line 397, in find_element_by_css_selector
return self.find_element(by=By.CSS_SELECTOR, value=css_selector)
  File 
"/data/home/london/te/moat-effortless_web_app/env/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py",
line 707, in find_element
{'using': by, 'value': value})['value']
  File 
"/data/home/london/te/moat-effortless_web_app/env/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py",
line 196, in execute
self.error_handler.check_response(response)
  File 
"/data/home/london/te/moat-effortless_web_app/env/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py",
line 181, in check_response
raise exception_class(message, screen, stacktrace)
NoSuchElementException: Message: {"errorMessage":"Unable to find
element with css selector
'div.home-page'","request":{"headers":{"Accept":"application/json","Accept-Encoding":"identity","Connection":"close","Content-Length":"104","Content-Type":"application/json;charset=UTF-8",&quo

Attaching `ng-model` to Select widget gives "?undefined:undefined?" `option` value attribute

2018-02-19 Thread Tom Tanner
How do I solve this problem with Django and AngularJS where the first 
`option` on my `select` tag displays wrong? Full info: 
https://stackoverflow.com/questions/48872768/attaching-ng-model-to-select-widget-gives-undefinedundefined-option-val

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/9e8e8299-70a3-43dd-b3ce-eb043335c776%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Stripe problem: InvalidRequestError: This customer has no attached payment source

2018-02-18 Thread Tom Tanner
I've been following the Quickstart guides from Stripe.

https://stripe.com/docs/quickstart

https://stripe.com/docs/subscriptions/quickstart


This is what my form looks like:


{% csrf_token %}
{% for field in registration_form %}
{{ field }}
{% if field.errors %}
{{ field.errors.as_text|cut:"* 
"|escape }}
{% endif %} 
{% endfor %}
{% if registration_form.non_field_errors %}
{{ 
registration_form.non_field_errors.as_text|cut:"* "|escape }}
{% endif %}


  


Register


var displayError=   document.getElementById('card-errors');
var stripe= Stripe("pk_test_BjhejGz5DZNcSHUVaqoipMtF");
var elements=   stripe.elements();

var style=  {
base: {
fontSize: "1.1875rem",
fontSmoothing: "always",
fontWeight: "600"
}
};

var card=   elements.create("card",{style:style});
card.mount("#card-element");
card.addEventListener('change', function(event) {

if (event.error) {
displayError.textContent = event.error.message;
} else {
displayError.textContent = '';
}
});

var formID= "register-form";
var form=   document.getElementById(formID);
form.addEventListener("submit",function(event){
event.preventDefault();

stripe.createToken(card).then(function(result){
if(result.error) {
displayError.textContent=   result.error.message;
} else {
stripeTokenHandler(result.token, formID);
}   
})
});
// tut 
https://stripe.com/docs/stripe-js/elements/quickstart#create-form
function stripeTokenHandler(token, formID) {
// Insert the token ID into the form so it gets submitted 
to the server
var form = document.getElementById(formID);
var hiddenInput = document.createElement('input');
hiddenInput.setAttribute('type', 'hidden');
hiddenInput.setAttribute('name', 'stripeToken');
hiddenInput.setAttribute('value', token.id);
form.appendChild(hiddenInput);
// Submit the form
form.submit();
}





Then my `views.py` has this:

 if registration_form.is_valid():
  stripe.api_key= "sk_test_8rdFokhVsbsJJysHeKgyrMTc"
  stripeCustomer= stripe.Customer.create(
   email=request.POST["username"],
  )
  subscription= stripe.Subscription.create(
   customer=stripeCustomer["id"],
   items=[{"plan":"plan_CLFfBrRAKl7TRt"}],
  )



This gives me an error:


Internal Server Error: /login-register/
Traceback (most recent call last):
  File 
"/home/myUserName/myDjangoProjectWithStripe/local/lib/python2.7/site-packages/django/core/handlers/exception.py"
, line 42, in inner
response = get_response(request)
  File 
"/home/myUserName/myDjangoProjectWithStripe/local/lib/python2.7/site-packages/django/core/handlers/base.py"
, line 249, in _legacy_get_response
response = self._get_response(request)
  File 
"/home/myUserName/myDjangoProjectWithStripe/local/lib/python2.7/site-packages/django/core/handlers/base.py"
, line 178, in _get_response
response = middleware_method(request, callback, callback_args, 
callback_kwargs)
  File 
"/home/myUserName/myDjangoProjectWithStripe/local/lib/python2.7/site-packages/mezzanine/pages/middleware.py"
, line 98, in process_view
return view_func(request, *view_args, **view_kwargs)
  File 
"/home/myUserName/myDjangoProjectWithStripe/product_blog/theme/views.py", 
line 154, in login_register
items=[{"plan":"plan_CLFfBrRAKl7TRt"}],
  File 
"/home/myUserName/myDjangoProjectWithStripe/local/lib/python2.7/site-packages/stripe/api_resources/subscription.py"
, line 33, in create
return super(Subscription, cls).create(**params)
  File 
"/home/myUserName/myDjangoProjectWithStripe/local/lib/python2.7/site-packages/stripe/api_resources/abstract/createable_api_resource.py"
, line 17, in create
response, api_key = requestor.request('post', url, params, headers)
  File 
"/home/myUserName/myDjangoProjectWithStripe/local/lib/python2.7/site-packages/stripe/api_requestor.py"
, line 153, in request
resp = self.interpret_response(rbody, rcode, rheaders)
  File 
"/home/myUserName/myDjangoProjectW

Noob question: Is the User model compatible with subscription-style website?

2018-02-14 Thread Tom Tanner
I'm working on a Django-powered subscription website with a Django-powered 
CMS backend. Can the User model, or a derived class, be made to be 
compatible with this idea? In my case, I want to store a user's username, 
password, and subscription ID. 

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


How do I move a project from one computer to another?

2018-02-12 Thread Tom Tanner
I have a Django project that I want to work on with another computer. Do I 
need to backup my current project's Postgres database and restore it on the 
other computer's Postgres database to get my project up and running there? 
Or is there a Django way to do this?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/b5ab2022-4fd1-4f8f-bb40-d4194bbf397f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How do I convert an existing column to Foreign Key?

2018-01-29 Thread Tom Tanner
I have two models `model_a` and `model_b`, where their tables look 
something like this...


Table `a` looks something like this -- first row is column names, both 
contain characters:

id |  tractce   | someString
2  |  "0011900" | "Label here"

Table `b`:

id | tractFIPS
1  | "0011900"



Here's code from `models.py`:

class model_a(models.Model):
tractce = models.CharField(max_length=6)
someString = models.TextField()


class model_b(models.Model):
tractFIPS = models.CharField(max_length=6)



I want to convert `model_b` so that the `tractFIPS` field is a foreign key 
referencing `model_a`. Something like this I guess...

class model_b(models.Model):
tractFIPS_FK = models.ForeignKey(model_a)



And the table for `model_b` would look something like this in the end:

id |  tractFIPS_FK_id
1  |  2


How do I convert `model_b`'s `tractFIPS` field to a foreign key with the 
correct values in them? 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/a347bdbc-9cd7-4cda-a0f6-873812c360e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: unbound method save() must be called with MyModel instance as first argument

2018-01-23 Thread Tom Tanner
In my case, I'm using `setattr()` because I need to access a field via 
string and set it. I can't do `obj.myCol = "blah blah"` because this whole 
code is part of a `manage.py` command I'm setting up that asks the user to 
input the name of the model and column they want to add a new record for.

On Tuesday, January 23, 2018 at 7:59:11 PM UTC-5, Costja Covtushenko wrote:
>
> Hi,
>
> It looks like with get_model() you’ve gotten Model class not Model 
> instance.
> You can use `save()` on instance only.
> You need to have something like:
>
> class_ = get_model(…)
> instance = class_()
> instance.save()
>
> I hope that make sense to you.
>
> Regards,
> C.
>
> On Jan 23, 2018, at 7:43 PM, Tom Tanner  > wrote:
>
> get_model
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/f06c409b-ca0a-4350-8736-26ad0553ab67%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


unbound method save() must be called with MyModel instance as first argument

2018-01-23 Thread Tom Tanner
I'm using `setattr()` to set attributes of a new object of a Django model.

obj = apps.get_model(app_label="theme", model_name="MyModel")
setattr(obj,"myCol",100)
obj.save()


I got this error: `TypeError: unbound method save() must be called with 
DataPopulationTracts2016 instance as first argument (got nothing instead)`.

I want to save the new instance of `MyModel` to the model, using 
`get_model()` and `setattr()` to make a new instance of the model and set 
its attributes. How do I make `get_model()` and `setattr()` work with 
`save()`?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/d1e137f5-c415-45e2-9d7c-965fb3a3eb02%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I set the value of a model object's property after using `get_field()`?

2018-01-23 Thread Tom Tanner
Hey Dylan, sorry again. My situation is a bit more complex. Let me try 
clarifying...

I have...
obj = apps.get_model(app_label="myApp", model_name="myModel")

But I cannot do...
obj.setattr()

I may be going about this wrong, but my script asks the user to type the 
name of the model they want to access into the terminal, hence the `obj` 
line. Then the script asks the user to type in the column name they want to 
access. So if the user inputs "myColumn", I'd like to be able to do 
something like `obj.myColumn = "Some value"`. Is this possible, or am I on 
the wrong track?

On Monday, January 22, 2018 at 9:02:46 PM UTC-5, Dylan Reinhold wrote:
>
> Andrew,
>You do not to get the field with _meta.get_field just use setattr which 
> takes a string as the field name.
> Now if you are creating a new instance of your model and are just passing 
> a single field all other fields would need to have defaults or be null=True.
>
> In your do stuff area you can just run this to create a new object with 
> the string 'Test Text':
>
> model_instance = model()
> setattr(model_instance, column_name, 'Test Text')
> model_instance.save()
>
>  
> Dylan
>
>
> On Mon, Jan 22, 2018 at 5:32 PM, Tom Tanner  > wrote:
>
>> Darn, is this possible with a new object of the model? My idea is to in 
>> the end let the user input information that will be made into a new record 
>> to add to the model. But I need the user to type in the model they want to 
>> use...
>>
>>
>> On Monday, January 22, 2018 at 1:09:53 PM UTC-5, Andrew Standley wrote:
>>
>>> Hey Tom,
>>> First you'll need to create or get a particular instance of your 
>>> model using one of it's managers  `model.objects` and a query. Ex for a 
>>> model with a unique 'name' charfield: `model_obj = 
>>> model.objects.get(name='MyObject')`
>>> You can then use the column_name to set that attribute on the instance 
>>> `setattr(model_obj, column_name) = 100` and finally save those changes 
>>> `model_obj.save()`
>>> See https://docs.djangoproject.com/en/1.11/topics/db/queries/#
>>> -Andrew
>>> On 1/21/2018 9:44 PM, Tom Tanner wrote:
>>>
>>> I'm making a terminal command for my Django app:
>>>
>>> from django.core.management.base import BaseCommand, CommandError
>>> from django.core.exceptions import FieldDoesNotExist
>>> from django.apps import apps
>>> 
>>> 
>>> class Command(BaseCommand):
>>> def add_arguments(self, parser):
>>> parser.add_argument(
>>> "--app",
>>> dest="app",
>>> required=True,
>>> )
>>> 
>>> parser.add_argument(
>>> "--model",
>>> dest="model",
>>> required=True,
>>> )
>>> 
>>> parser.add_argument(
>>> "--col",
>>> dest="col",
>>> required=True,
>>> )
>>> 
>>> def handle(self, *args, **options):
>>> app_label = options.get('app')
>>> model_name = options.get('model')
>>> column_name = options.get('col')
>>> 
>>> try:
>>> model = apps.get_model(app_label=app_label, model_name=
>>> model_name)
>>> except LookupError as e:
>>> msg = 'The model "%s" under the app "%s" does not 
>>> exist!' \
>>>   % (model_name, app_label)
>>> raise CommandError(msg)
>>> try:
>>> column = model._meta.get_field(column_name)
>>> except FieldDoesNotExist as e:
>>> msg = 'The column "%s" does not match!' % column_name
>>> raise CommandError(msg)
>>> else:
>>> print(column, type(column))
>>> # Do stuff here with the column, model.
>>>
>>>
>>> Right now, `column` is `>> column_name>`. I want this instance of `model` to have `column_name` set to 
>>> `100`. How can I set and save this instance in this manner?
>>> -- 
>>> Y

Re: How do I set the value of a model object's property after using `get_field()`?

2018-01-22 Thread Tom Tanner
Darn, is this possible with a new object of the model? My idea is to in the 
end let the user input information that will be made into a new record to 
add to the model. But I need the user to type in the model they want to 
use...

On Monday, January 22, 2018 at 1:09:53 PM UTC-5, Andrew Standley wrote:
>
> Hey Tom,
> First you'll need to create or get a particular instance of your model 
> using one of it's managers  `model.objects` and a query. Ex for a model 
> with a unique 'name' charfield: `model_obj = 
> model.objects.get(name='MyObject')`
> You can then use the column_name to set that attribute on the instance 
> `setattr(model_obj, column_name) = 100` and finally save those changes 
> `model_obj.save()`
> See https://docs.djangoproject.com/en/1.11/topics/db/queries/#
> -Andrew
> On 1/21/2018 9:44 PM, Tom Tanner wrote:
>
> I'm making a terminal command for my Django app:
>
> from django.core.management.base import BaseCommand, CommandError
> from django.core.exceptions import FieldDoesNotExist
> from django.apps import apps
> 
> 
> class Command(BaseCommand):
> def add_arguments(self, parser):
> parser.add_argument(
> "--app",
> dest="app",
> required=True,
> )
> 
> parser.add_argument(
> "--model",
> dest="model",
> required=True,
> )
> 
> parser.add_argument(
> "--col",
> dest="col",
> required=True,
> )
> 
> def handle(self, *args, **options):
> app_label = options.get('app')
> model_name = options.get('model')
> column_name = options.get('col')
> 
> try:
> model = apps.get_model(app_label=app_label, model_name=
> model_name)
> except LookupError as e:
> msg = 'The model "%s" under the app "%s" does not exist!' 
> \
>   % (model_name, app_label)
> raise CommandError(msg)
> try:
> column = model._meta.get_field(column_name)
> except FieldDoesNotExist as e:
> msg = 'The column "%s" does not match!' % column_name
> raise CommandError(msg)
> else:
> print(column, type(column))
> # Do stuff here with the column, model.
>
>
> Right now, `column` is ` column_name>`. I want this instance of `model` to have `column_name` set to 
> `100`. How can I set and save this instance in this manner?
> -- 
> You received this message because you are subscribed 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 *MailScanner has detected definite fraud in the 
> website at "groups.google.com". Do not trust this website:* *MailScanner 
> has detected definite fraud in the website at "groups.google.com". Do not 
> trust this website:* https://groups.google.com/group/django-users 
> <https://groups.google.com/group/django-users>.
> To view this discussion on the web visit *MailScanner has detected 
> definite fraud in the website at "groups.google.com". Do not trust this 
> website:* *MailScanner has detected definite fraud in the website at 
> "groups.google.com". Do not trust this website:* 
> https://groups.google.com/d/msgid/django-users/2caa4cd5-cb62-4bee-8e41-6182bfba792a%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/2caa4cd5-cb62-4bee-8e41-6182bfba792a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit *MailScanner has detected definite fraud in the 
> website at "groups.google.com". Do not trust this website:* *MailScanner 
> has detected definite fraud in the website at "groups.google.com". Do not 
> trust this website:* https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.
>
> -- 
> This message has been scanned for viruses and dangerous content by 
> *E.F.A. Project* <http://www.efa-project.org>, and is believed to be 
> clean. 
> Click here to report this message as spam. 
> <http://lsefa1.linear-systems.com/cgi-bin/learn-msg.cgi?id=D18A7100A34.A4

How do I set the value of a model object's property after using `get_field()`?

2018-01-21 Thread Tom Tanner
I'm making a terminal command for my Django app:

from django.core.management.base import BaseCommand, CommandError
from django.core.exceptions import FieldDoesNotExist
from django.apps import apps


class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument(
"--app",
dest="app",
required=True,
)

parser.add_argument(
"--model",
dest="model",
required=True,
)

parser.add_argument(
"--col",
dest="col",
required=True,
)

def handle(self, *args, **options):
app_label = options.get('app')
model_name = options.get('model')
column_name = options.get('col')

try:
model = apps.get_model(app_label=app_label, model_name=
model_name)
except LookupError as e:
msg = 'The model "%s" under the app "%s" does not exist!' \
  % (model_name, app_label)
raise CommandError(msg)
try:
column = model._meta.get_field(column_name)
except FieldDoesNotExist as e:
msg = 'The column "%s" does not match!' % column_name
raise CommandError(msg)
else:
print(column, type(column))
# Do stuff here with the column, model.


Right now, `column` is ``. I want this instance of `model` to have `column_name` set to 
`100`. How can I set and save this instance in this manner?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/2caa4cd5-cb62-4bee-8e41-6182bfba792a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Two command-line questions. How do I get a list of model names? How do I match a user-inputted string with a model name?

2018-01-17 Thread Tom Tanner
I've got the following in `management/commands/my_command.py`:

from django.core.management.base import BaseCommand, CommandError
from django.conf import settings

import os.path, csv

from theme.models import *
 
class Command(BaseCommand):
  def handle(self, *args, **options):
   modelName= raw_input("Enter model name: ")
   print "you entered", modelName


I want to show the user a list of all model names. I want to take the 
user's input and see if's an existing model. How do I do this?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/2d5a05da-27e1-40ba-9884-478aecb2efe5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


I plan to have lots of data tables with similar structure. How do you recommend I model them?

2018-01-10 Thread Tom Tanner
Hey everyone,

I have a bunch of text files that each have a bunch of columns in common. I 
plan to import these files into PostgreSQL tables. The website user will be 
able to send a GET request to query a table and get back data from it. 
Since most of the tables will have a bunch of columns in common, how should 
I structure them in my `models.py`?

Here's a couple examples of tab-delimited text files I'll import.

NAME S1903_C02_001E state county tract State-County-Tract-ID
Census Tract 201, Autauga County, Alabama 66000 01 001 020100 
01001020100
Census Tract 202, Autauga County, Alabama 41107 01 001 020200 
01001020200
Census Tract 203, Autauga County, Alabama 51250 01 001 020300 
01001020300



and 

NAME S1903_C02_001F S1903_C02_001G state county tract State-County-Tract
-ID
Census Tract 201, Autauga County, Alabama 66000 4040 01 001 020100 
01001020100
Census Tract 202, Autauga County, Alabama 41107 192837 01 001 020200 
01001020200
Census Tract 203, Autauga County, Alabama 51250 39482 01 001 020300 
01001020300


As you can see, they have several columns in common. I wouldn't want to 
repeat myself in `models.py` by listing the same columns over and over.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/e5fc9dab-c0aa-4fb8-a66c-5f507a18f4b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I make a Django model from a tab-delimited data file?

2018-01-10 Thread Tom Tanner
Thanks you two. I'll check out that parser.

On Monday, January 8, 2018 at 9:38:44 PM UTC-5, Tom Tanner wrote:
>
> I have a tab-delimited data file that looks something like this:
>
>
> NAME S1903_C02_001E state county tract State-County-Tract-ID
> Census Tract 201, Autauga County, Alabama 66000 01 001 020100 01001020100
> Census Tract 202, Autauga County, Alabama 41107 01 001 020200 01001020200
> Census Tract 203, Autauga County, Alabama 51250 01 001 020300 01001020300
>
> I want to make a Django model named `MyModel` with three columns: "name", 
> "data", and "geoid", which correspond to the file's columns "NAME", 
> "S1903_C02_001E", and "State-County-Tract-ID." Can I do this via command 
> line, or with a custom Python script? I'm running my Django project locally 
> on a computer running Debian 9.3. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/3437a3bc-6a71-4a21-a410-7ede182cb83d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How do I make a Django model from a tab-delimited data file?

2018-01-08 Thread Tom Tanner
I have a tab-delimited data file that looks something like this:


NAME S1903_C02_001E state county tract State-County-Tract-ID
Census Tract 201, Autauga County, Alabama 66000 01 001 020100 01001020100
Census Tract 202, Autauga County, Alabama 41107 01 001 020200 01001020200
Census Tract 203, Autauga County, Alabama 51250 01 001 020300 01001020300

I want to make a Django model named `MyModel` with three columns: "name", 
"data", and "geoid", which correspond to the file's columns "NAME", 
"S1903_C02_001E", and "State-County-Tract-ID." Can I do this via command 
line, or with a custom Python script? I'm running my Django project locally 
on a computer running Debian 9.3. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/389d8f38-6dbc-43a0-8a69-d20aa13ca844%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I use Django to execute PostGIS query to get polygons within four points?

2018-01-08 Thread Tom Tanner
Nah, didn't seem to work either. I ended up going with 
`.execute()`: 
https://docs.djangoproject.com/en/2.0/topics/db/sql/#executing-custom-sql-directly

On Sunday, January 7, 2018 at 11:49:16 PM UTC-5, Jani Tiainen wrote:
>
> Hi.
>
> __within is probably correct lookup. 
>
> You can find all lookups at:  
> https://docs.djangoproject.com/en/2.0/ref/contrib/gis/geoquerysets/
>
> 8.1.2018 2.36 "Tom Tanner" > 
> kirjoitti:
>
>> I get this error when trying Jani's example: "FieldError: Unsupported 
>> lookup 'inside' for MultiPolygonField or join on the field not permitted."
>>
>> On Sunday, January 7, 2018 at 7:33:51 PM UTC-5, Tom Tanner wrote:
>>>
>>> Thanks for replying, Jani. I should mention My `geom` field is a 
>>> MultiPolygon, so I can't use `from_bbox` it seems...
>>>
>>> On Sunday, January 7, 2018 at 3:45:55 AM UTC-5, Jani Tiainen wrote:
>>>>
>>>> Something like following should work. Didn't checked if that actually 
>>>> works.
>>>>
>>>> Mymodel.objects.filter(geom__inside=Polygon.from_bbox((x1,y1,x2,y2), 
>>>> srid=1234))   
>>>>
>>>> On Sun, Jan 7, 2018 at 10:41 AM, Jani Tiainen  wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I didn't realize what you were asking for. :D
>>>>>
>>>>> Django has bunch of spatial queries, so you're looking some of those 
>>>>> __inside, __within lookups. Coordinate transformations do happen 
>>>>> automatically so you just need to provide srid for you "envelope".
>>>>>
>>>>> On Sun, Jan 7, 2018 at 1:48 AM, Tom Tanner  
>>>>> wrote:
>>>>>
>>>>>> Here's a sample PostGIS query I use to get geometries within four 
>>>>>> points:
>>>>>>
>>>>>> SELECT *
>>>>>> FROM myTable
>>>>>> WHERE ST_MakeEnvelope(-97.82381347656252, 30.250444940663296, -
>>>>>> 97.65901855468752, 30.29595835209862, 4326) && ST_Transform(myTable.
>>>>>> geom,4326);
>>>>>>
>>>>>>
>>>>>> With this query, I can get all rows within those four points. How do 
>>>>>> I execute this query or similar queries in Django or GeoDjango?
>>>>>>
>>>>>> -- 
>>>>>> You received this message because you are subscribed 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/aac95827-0c79-4aef-84cf-646ca82cfffa%40googlegroups.com
>>>>>>  
>>>>>> <https://groups.google.com/d/msgid/django-users/aac95827-0c79-4aef-84cf-646ca82cfffa%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -- 
>>>>> Jani Tiainen
>>>>>
>>>>> - Well planned is half done, and a half done has been sufficient 
>>>>> before...
>>>>>
>>>>
>>>>
>>>>
>>>> -- 
>>>> Jani Tiainen
>>>>
>>>> - Well planned is half done, and a half done has been sufficient 
>>>> before...
>>>>
>>> -- 
>> You received this message because you are subscribed 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/67a80f04-1ea1-45b7-bfce-76863ae0f13e%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/67a80f04-1ea1-45b7-bfce-76863ae0f13e%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/b4623f71-52c7-4cd0-8dba-8e2e770875dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I use Django to execute PostGIS query to get polygons within four points?

2018-01-07 Thread Tom Tanner
I get this error when trying Jani's example: "FieldError: Unsupported 
lookup 'inside' for MultiPolygonField or join on the field not permitted."

On Sunday, January 7, 2018 at 7:33:51 PM UTC-5, Tom Tanner wrote:
>
> Thanks for replying, Jani. I should mention My `geom` field is a 
> MultiPolygon, so I can't use `from_bbox` it seems...
>
> On Sunday, January 7, 2018 at 3:45:55 AM UTC-5, Jani Tiainen wrote:
>>
>> Something like following should work. Didn't checked if that actually 
>> works.
>>
>> Mymodel.objects.filter(geom__inside=Polygon.from_bbox((x1,y1,x2,y2), 
>> srid=1234))   
>>
>> On Sun, Jan 7, 2018 at 10:41 AM, Jani Tiainen  wrote:
>>
>>> Hi,
>>>
>>> I didn't realize what you were asking for. :D
>>>
>>> Django has bunch of spatial queries, so you're looking some of those 
>>> __inside, __within lookups. Coordinate transformations do happen 
>>> automatically so you just need to provide srid for you "envelope".
>>>
>>> On Sun, Jan 7, 2018 at 1:48 AM, Tom Tanner  
>>> wrote:
>>>
>>>> Here's a sample PostGIS query I use to get geometries within four 
>>>> points:
>>>>
>>>> SELECT *
>>>> FROM myTable
>>>> WHERE ST_MakeEnvelope(-97.82381347656252, 30.250444940663296, -
>>>> 97.65901855468752, 30.29595835209862, 4326) && ST_Transform(myTable.
>>>> geom,4326);
>>>>
>>>>
>>>> With this query, I can get all rows within those four points. How do I 
>>>> execute this query or similar queries in Django or GeoDjango?
>>>>
>>>> -- 
>>>> You received this message because you are subscribed 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/aac95827-0c79-4aef-84cf-646ca82cfffa%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/django-users/aac95827-0c79-4aef-84cf-646ca82cfffa%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>>
>>> -- 
>>> Jani Tiainen
>>>
>>> - Well planned is half done, and a half done has been sufficient 
>>> before...
>>>
>>
>>
>>
>> -- 
>> Jani Tiainen
>>
>> - Well planned is half done, and a half done has been sufficient before...
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/67a80f04-1ea1-45b7-bfce-76863ae0f13e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I use Django to execute PostGIS query to get polygons within four points?

2018-01-07 Thread Tom Tanner
Thanks for replying, Jani. I should mention My `geom` field is a 
MultiPolygon, so I can't use `from_bbox` it seems...

On Sunday, January 7, 2018 at 3:45:55 AM UTC-5, Jani Tiainen wrote:
>
> Something like following should work. Didn't checked if that actually 
> works.
>
> Mymodel.objects.filter(geom__inside=Polygon.from_bbox((x1,y1,x2,y2), 
> srid=1234))   
>
> On Sun, Jan 7, 2018 at 10:41 AM, Jani Tiainen  > wrote:
>
>> Hi,
>>
>> I didn't realize what you were asking for. :D
>>
>> Django has bunch of spatial queries, so you're looking some of those 
>> __inside, __within lookups. Coordinate transformations do happen 
>> automatically so you just need to provide srid for you "envelope".
>>
>> On Sun, Jan 7, 2018 at 1:48 AM, Tom Tanner > > wrote:
>>
>>> Here's a sample PostGIS query I use to get geometries within four points:
>>>
>>> SELECT *
>>> FROM myTable
>>> WHERE ST_MakeEnvelope(-97.82381347656252, 30.250444940663296, -
>>> 97.65901855468752, 30.29595835209862, 4326) && ST_Transform(myTable.geom
>>> ,4326);
>>>
>>>
>>> With this query, I can get all rows within those four points. How do I 
>>> execute this query or similar queries in Django or GeoDjango?
>>>
>>> -- 
>>> You received this message because you are subscribed 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/aac95827-0c79-4aef-84cf-646ca82cfffa%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/django-users/aac95827-0c79-4aef-84cf-646ca82cfffa%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> -- 
>> Jani Tiainen
>>
>> - Well planned is half done, and a half done has been sufficient before...
>>
>
>
>
> -- 
> Jani Tiainen
>
> - Well planned is half done, and a half done has been sufficient before...
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/ab0234b5-109b-4833-b223-c12870cb654d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How do I use Django to execute PostGIS query to get polygons within four points?

2018-01-06 Thread Tom Tanner
Here's a sample PostGIS query I use to get geometries within four points:

SELECT *
FROM myTable
WHERE ST_MakeEnvelope(-97.82381347656252, 30.250444940663296, -
97.65901855468752, 30.29595835209862, 4326) && ST_Transform(myTable.geom,
4326);


With this query, I can get all rows within those four points. How do I 
execute this query or similar queries in Django or GeoDjango?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/aac95827-0c79-4aef-84cf-646ca82cfffa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Hi, a little help here.

2017-12-15 Thread &#x27;Tom Evans' via Django users
Please reply with the full error message. Also, I am pretty sure that
when pip fails to build something it also says "Full log message
available in /foo/bar/quuz.log". If it does, please also send the
contents of that log file.

Cheers

Tom

On Fri, Dec 15, 2017 at 12:41 AM, Aaron  wrote:
> I wasn't sure where to ask this question and then I found this place. I've
> got a MacBook running mac OS High Sierra.  I've been trying to install
> Django for a while. Whenever I try, I get an error that says "Command
> "python setup.py egg_info" failed with error code 1 in
> /private/var/folders/8y/lq4gsyx97_q171qrh2q18z0hgn/T/pip-build-cZ0Fno/django/"
> in terminal. I'm not sure what to do. 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/a202cdff-dc2e-416d-9462-3b7cfe11d46b%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/CAFHbX1%2BV-5ff1841m3-0nShnf_ZQQ71JDG0EHjpN41F5jdz7rg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Migrations circular dependency on upgrade to Django 1.11

2017-12-15 Thread &#x27;Tom Evans' via Django users
After more investigating, it seems that the problem was due to the
squashed migrations and the migrations they replaced both being
present. After removing all migrations (from our apps) listed in
"replaces" and fixing up the dependencies to not point at the old
squashed migration (which I guess was the real problem?) I now get no
circular dependencies (woo!)

Unfortunately they still don't run, so that's the next task :(

Cheers

Tom

On Fri, Dec 15, 2017 at 11:37 AM, Tom Evans  wrote:
> Hi all
>
> I'm updating a project from Django 1.8 to 1.11, however the migrations
> which ran correctly under 1.8 now raise a CircularDependencyError for
> (effortless_auth.0001_initial, app.0028_create_south_korea_data_set,
> effortless_auth.0003_add_dev_group,
> app.0027_create_effortless_verticals), which I'll summarise:
>
> effortless_auth.0001_initial
> Depends:
> auth.__first__, places.__first__, auth.0006_require_contenttypes_0002
> Adds:
> AccountManager, DataSetType, PropValue, SpeedTestResult,
> Vertical -> no FKs outside of app
> GroupExtension -> (modified after creation to add fk to auth.Group)
> PropDefinition -> fk to auth.Group
> UserEvent -> fk to auth.User (settings.AUTH_USER_MODEL)
> UserProp -> fk to auth.User (settings.AUTH_USER_MODEL)
> Modifies:
> GroupExtension -> add fk to auth.Group
>
> app.0028_create_south_korea_data_set
> Depends:
> effortless_auth.003_add_dev_group
> Runs:
> Creates DataSetType instance
>
> effortless_auth.0003_add_dev_group
> Depends:
> effortless_auth.0002_create_custom_content_group
> Runs:
> Creates and populates a Group and GroupExtension
>
> app.0027_create_effortless_verticals
> Depends:
> effortless_auth.003_add_dev_group
> Runs:
> Creates 4 Vertical instances
>
> I do not see what is circular from this, the graph should surely be:
> auth.__first__
> auth
> auth.0006
> effortless_auth.0001
> ..
> effortless_auth.0003
> ...
> app.0027
> app.0028
>
> Why does this now confuse Django? I have a feeling this is due to
> swappable models for auth (which we do not use, this project was
> started with AUTH_USER_MODEL unset, but another project which re-uses
> some of our libraries does do).
>
> I can share more of the migrations, there is some additional
> complexity I have skipped over because effortless_auth used to be part
> of "app" and 'app' has had migrations squashed in the past, so many of
> these migrations have "replaces" attributes also.
>
> Cheers
>
> Tom

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


Migrations circular dependency on upgrade to Django 1.11

2017-12-15 Thread &#x27;Tom Evans' via Django users
Hi all

I'm updating a project from Django 1.8 to 1.11, however the migrations
which ran correctly under 1.8 now raise a CircularDependencyError for
(effortless_auth.0001_initial, app.0028_create_south_korea_data_set,
effortless_auth.0003_add_dev_group,
app.0027_create_effortless_verticals), which I'll summarise:

effortless_auth.0001_initial
Depends:
auth.__first__, places.__first__, auth.0006_require_contenttypes_0002
Adds:
AccountManager, DataSetType, PropValue, SpeedTestResult,
Vertical -> no FKs outside of app
GroupExtension -> (modified after creation to add fk to auth.Group)
PropDefinition -> fk to auth.Group
UserEvent -> fk to auth.User (settings.AUTH_USER_MODEL)
UserProp -> fk to auth.User (settings.AUTH_USER_MODEL)
Modifies:
GroupExtension -> add fk to auth.Group

app.0028_create_south_korea_data_set
Depends:
effortless_auth.003_add_dev_group
Runs:
Creates DataSetType instance

effortless_auth.0003_add_dev_group
Depends:
effortless_auth.0002_create_custom_content_group
Runs:
Creates and populates a Group and GroupExtension

app.0027_create_effortless_verticals
Depends:
effortless_auth.003_add_dev_group
Runs:
Creates 4 Vertical instances

I do not see what is circular from this, the graph should surely be:
auth.__first__
auth
auth.0006
effortless_auth.0001
..
effortless_auth.0003
...
app.0027
app.0028

Why does this now confuse Django? I have a feeling this is due to
swappable models for auth (which we do not use, this project was
started with AUTH_USER_MODEL unset, but another project which re-uses
some of our libraries does do).

I can share more of the migrations, there is some additional
complexity I have skipped over because effortless_auth used to be part
of "app" and 'app' has had migrations squashed in the past, so many of
these migrations have "replaces" attributes also.

Cheers

Tom

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


How do I customize the "username already exists" message?

2017-12-03 Thread Tom Tanner
My `forms.py` has a custom user-creation class...
class RegisterForm(UserCreationForm):
 error_messages= {
  "password_mismatch": _("Passwords do not match."),
 }

Which error message do I need to replace for when the user chooses a 
username that already exists?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/ab10c9df-afcb-4b08-a69c-2c31a78d4a7d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I customize form error messages?

2017-12-03 Thread Tom Tanner
Nevermind, I figured out I needed to edit `forms.py`.

My custom login class...

class LoginForm(AuthenticationForm):
 error_messages= {
  "invalid_login": _("Incorrect %(username)s/password combo")
 }
 # more code here...
}


On Sunday, December 3, 2017 at 9:46:09 PM UTC-5, Tom Tanner wrote:
>
> In my login form, I have this code:
>
>  {% if login_form.non_field_errors %}
>   {{ login_form.non_field_errors.as_text|cut:"* 
> "|escape 
> }}
>  {% endif %}
>
> If a user enters the wrong username/password combo, the error reads like 
> this: 'Please enter a correct username and password. Note that both fields 
> may be case-sensitive." I'd like to change this message and other error 
> messages. How do I do this?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/3ac863e5-c73b-4b86-ad40-9a30aa7dbe9e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How do I customize form error messages?

2017-12-03 Thread Tom Tanner
In my login form, I have this code:

 {% if login_form.non_field_errors %}
  {{ login_form.non_field_errors.as_text|cut:"* "|escape 
}}
 {% endif %}

If a user enters the wrong username/password combo, the error reads like 
this: 'Please enter a correct username and password. Note that both fields 
may be case-sensitive." I'd like to change this message and other error 
messages. How do I do this?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/0bcec941-56f1-4442-9436-2e7cb9411454%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Login form error not showing up for wrong username/password combo

2017-12-03 Thread Tom Tanner
That did it.

On Saturday, December 2, 2017 at 10:59:58 PM UTC-5, Constantine Covtushenko 
wrote:
>
> Hi Tom,
>
> It seems like your are trying to show error that relates to form rather to 
> particular field.
> I see '__all__' key in example from console.
>
> And you did not create any html tag to show such errors on the page.
> All I see that you printed just field specific errors.
>
> Probably you should print at the top of your form something like this:
> *{{ form.non_field_errors }}*
>
> Regards,
> Constantine C.
>
> On Sat, Dec 2, 2017 at 12:38 AM, Tom Tanner  > wrote:
>
>> I have this code in my login form.
>>  {% for field in login_form %}
>>   {{ field }}
>>   {% if field.errors %}
>>{{ field.errors.as_text|cut:"* "|escape }}
>>   {% endif %} 
>>  {% endfor %}
>>
>> The user must enter a valid email address in the "username" field. If the 
>> user enters a string not formatted like an email, I'll see this error in 
>> the `p` tag: "Enter a valid email address."
>>
>> But if the user enters a bad email/password combo, nothing shows up. In 
>> my `views.py`, I have a section that looks something like
>> if login_form.is_valid:
>>   ...
>> else:
>>   print login_form.errors 
>>
>> Here's what Django prints to console. "> class="errorlist">__all__Please 
>> enter a correct username and password. Note that both fields may be 
>> case-sensitive."
>>
>> Why does the error print to console but not into my `p` tag?
>>
>> -- 
>> You received this message because you are subscribed 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/f4dfcfa5-c687-439e-9e3a-8cb6f0b2c826%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/f4dfcfa5-c687-439e-9e3a-8cb6f0b2c826%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Sincerely yours,
> Constantine C
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/5c2b680b-e544-4839-93d9-f00f8d274672%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Login form error not showing up for wrong username/password combo

2017-12-01 Thread Tom Tanner
I have this code in my login form.
 {% for field in login_form %}
  {{ field }}
  {% if field.errors %}
   {{ field.errors.as_text|cut:"* "|escape }}
  {% endif %} 
 {% endfor %}

The user must enter a valid email address in the "username" field. If the 
user enters a string not formatted like an email, I'll see this error in 
the `p` tag: "Enter a valid email address."

But if the user enters a bad email/password combo, nothing shows up. In my 
`views.py`, I have a section that looks something like
if login_form.is_valid:
  ...
else:
  print login_form.errors 

Here's what Django prints to console. "__all__Please enter a correct username and 
password. Note that both fields may be case-sensitive."

Why does the error print to console but not into my `p` tag?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/f4dfcfa5-c687-439e-9e3a-8cb6f0b2c826%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I customize registration form HTML?

2017-12-01 Thread Tom Tanner
Where can I find all the options like {{ form.name }} ?

On Friday, December 1, 2017 at 9:27:21 AM UTC-5, yingi keme wrote:
>
>
>
> Yingi Kem
>
> On 1 Dec 2017, at 3:25 PM, yingi keme > 
> wrote:
>
> Intead of rendering it with the as_p. You can render them individually.
> ie
>
> {{form.name}}
> {{form.username}}
>
>  In the forms.py, in each of the fields, add widget attributes.
>
> def MyForm(forms.ModelForm):
> name = forms.CharField(label='name', 
> widget=forms.TextInput(attrs={'placeholder':'Name', 
> 'class':'yourInputFieldClassName'}))
>
>
>
> Yingi Kem
>
> On 1 Dec 2017, at 1:50 AM, Tom Tanner  > wrote:
>
> The HTML for the user registration form looks like this:
> 
>  {% csrf_token %}
>  {{ registration_form.as_p }}
>  Register
> 
>
> I understand that the `registration_form.as_p` line automatically gives me 
> the form's HTML. But I'd like to customize that HTML. For instance, I'd 
> like the label text to be placeholders instead. How do I do this?
>
> If it helps, `registration_form` is `UserCreationForm()`
>
> -- 
> You received this message because you are subscribed 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/12490918-6d56-4079-ab53-9b8cb6f9fd9b%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/12490918-6d56-4079-ab53-9b8cb6f9fd9b%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/e0b39886-e521-40aa-a28e-ebca5213d42b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How do I customize registration form HTML?

2017-11-30 Thread Tom Tanner
The HTML for the user registration form looks like this:

 {% csrf_token %}
 {{ registration_form.as_p }}
 Register


I understand that the `registration_form.as_p` line automatically gives me 
the form's HTML. But I'd like to customize that HTML. For instance, I'd 
like the label text to be placeholders instead. How do I do this?

If it helps, `registration_form` is `UserCreationForm()`

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/12490918-6d56-4079-ab53-9b8cb6f9fd9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why does Django say my login form is invalid? How can I find out why Django thinks it is?

2017-11-29 Thread Tom Tanner
I removed that line, but nothing changed.

On Wednesday, November 29, 2017 at 11:58:28 PM UTC-5, Matemática A3K wrote:
>
>
>
> On Thu, Nov 30, 2017 at 12:35 AM, Tom Tanner  > wrote:
>
>> What would I need to change? 
>>
>> I tried changing the ...
>> fields= ("username",)
>>
>> ... to ...
>> fields= ("username","email",)
>> or...
>> fields= ("email",)
>>
>> Nothing seemed to change. the `login_form.is_valid()` still is `False`.
>>
>> Sorry if the question is dumb, I'm still learning Django thru working 
>> with it.
>>
>>
> Try not using fields at all, that will use the fields in AuthenticationForm
>  
>
>>
>>
>> On Wednesday, November 29, 2017 at 12:21:04 AM UTC-5, Matemática A3K 
>> wrote:
>>>
>>>
>>> class LoginForm(AuthenticationForm):
>>>>  username= forms.EmailField(label=_("Email"), max_length=254)
>>>>
>>>>
>>>>  class Meta:
>>>>  model= User
>>>>
>>>  
>>>
>>>>
>>>>  fields= ("username",)
>>>>
>>>>
>>> If you use "fields = ("username")" you are restricting the fields to 
>>> just that field, and the authentication form needs also password to be valid
>>>  
>>>
>>>>
>>>> -- 
>>>> You received this message because you are subscribed 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/1e861f42-2115-4377-848c-67c59d122610%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/django-users/1e861f42-2115-4377-848c-67c59d122610%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...@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/7dafbe54-6563-401b-9461-b857f9340d64%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/7dafbe54-6563-401b-9461-b857f9340d64%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/c506fa03-09f7-4f69-b464-ec2d789baf65%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why does Django say my login form is invalid? How can I find out why Django thinks it is?

2017-11-29 Thread Tom Tanner
What would I need to change? 

I tried changing the ...
fields= ("username",)

... to ...
fields= ("username","email",)
or...
fields= ("email",)

Nothing seemed to change. the `login_form.is_valid()` still is `False`.

Sorry if the question is dumb, I'm still learning Django thru working with 
it.



On Wednesday, November 29, 2017 at 12:21:04 AM UTC-5, Matemática A3K wrote:
>
>
> class LoginForm(AuthenticationForm):
>>  username= forms.EmailField(label=_("Email"), max_length=254)
>>
>>
>>  class Meta:
>>  model= User
>>
>  
>
>>
>>  fields= ("username",)
>>
>>
> If you use "fields = ("username")" you are restricting the fields to just 
> that field, and the authentication form needs also password to be valid
>  
>
>>
>> -- 
>> You received this message because you are subscribed 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/1e861f42-2115-4377-848c-67c59d122610%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/7dafbe54-6563-401b-9461-b857f9340d64%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Why does Django say my login form is invalid? How can I find out why Django thinks it is?

2017-11-28 Thread Tom Tanner
My `forms.py` looks like this. (I want user's email to be their login 
username. 
from django.utils.translation import ugettext_lazy as _

from django import forms
from django.contrib.auth.forms import AuthenticationForm
from django.contrib.auth.models import User

class LoginForm(AuthenticationForm):
 username= forms.EmailField(label=_("Email"), max_length=254)


 class Meta:
 model= User
 fields= ("username",)

`views.py`:
def login_register(request, template="pages/login_register.html"):
 if request.method=="POST":
  login_form= LoginForm(request.POST)
  if login_form.is_valid():
   print "Login form valid"
   return redirect(home_slug())
  # else:
  #  print "Login invalid"
 else:
  login_form= LoginForm()
 return render(request, template, {"login_form": login_form})


`login_register.html`:
 
  {% csrf_token %}
  {{ login_form.as_p }}
  Log in
 

The login form accepts two fields labeled "Email" and "Password." But when 
I hit "Log in" button, the page just seems to refresh. If I uncomment the 
`print` statement, it prints, indicating that 
`login_form.is_valid()!=True`. Why does Django do this?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/1e861f42-2115-4377-848c-67c59d122610%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I limit my login form to just email and password?

2017-11-26 Thread Tom Tanner
Adding `exclude=["username"]` does nothing. Same if I replace "username" 
with "email" or "user".

On Sunday, November 26, 2017 at 2:44:44 PM UTC-5, Matemática A3K wrote:
>
>
>
> On Sun, Nov 26, 2017 at 12:55 AM, Tom Tanner  > wrote:
>
>> My `models.py` has this:
>> class MyUser(AbstractBaseUser):
>>  email= models.CharField(max_length=254, unique=True)
>>  USERNAME_FIELD= "email"
>>
>> My `forms.py` has this:
>> class LoginForm(AuthenticationForm):
>>  email= forms.EmailField(label=_("Email"), max_length=254)
>>
>>  class Meta:
>>   model= MyUser
>>   fields= ("email",)
>>
>> The form on the template has three fields: Username, Password and Email, 
>> in that Order. I want only Email and Password to show up in the form. How 
>> do I do that?
>>
>
> https://docs.djangoproject.com/en/1.11/topics/forms/modelforms/#selecting-the-fields-to-use
>  
>
>> -- 
>> You received this message because you are subscribed 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/4e9a3109-3dd0-4754-91f2-44731154920c%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/4e9a3109-3dd0-4754-91f2-44731154920c%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/b5db6a84-e370-4ccf-8fb6-2d2486f88a60%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How do I limit my login form to just email and password?

2017-11-25 Thread Tom Tanner
My `models.py` has this:
class MyUser(AbstractBaseUser):
 email= models.CharField(max_length=254, unique=True)
 USERNAME_FIELD= "email"

My `forms.py` has this:
class LoginForm(AuthenticationForm):
 email= forms.EmailField(label=_("Email"), max_length=254)

 class Meta:
  model= MyUser
  fields= ("email",)

When a user goes to "/signin/", Django loads `sign_in.html`:
 Log in
 
  {% csrf_token %}
  {{ login_form.as_p }}
  Log in
 

The form on the template has three fields: Username, Password and Email, in 
that Order. I want only Email and Password to show up in the form. How do I 
do that?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/4e9a3109-3dd0-4754-91f2-44731154920c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How can I learn to make a user login?

2017-11-25 Thread Tom Tanner
I see Django has an auth URLfor logging in. How do I construct the login 
form?

I have a template that will have both login and register forms on it. My 
view `login_register` looks something like this:

def login_register(request, template="pages/login_register.html"):
 '''
 Display registration and login forms.
 Process user registration.
 Process user login.
 '''
 if request.method=="POST":
  registration_form= UserCreationForm(request.POST)
  if registration_form.is_valid():
   registration_form.save()
   username = registration_form.cleaned_data.get("username")
   raw_password = registration_form.cleaned_data.get("password1")
   user = authenticate(username=username, password=raw_password)
   login(request, user)
   return redirect(home_slug())
  else:
   registration_form = UserCreationForm()
   return render(request, template, {"registration_form": registration_form
})

The template for this view:
 
  Log in
  
   {% csrf_token %}
   {{ login_form.as_p }}
  
 
 
  Register
  
   {% csrf_token %}
   {{ registration_form.as_p }}
   Register
  
 

It seems like `UserCreationForm` makes the register form. So how do I make 
the login form?

On Saturday, November 25, 2017 at 3:14:25 PM UTC-5, Daniel Roseman wrote:
>
> On Saturday, 25 November 2017 19:59:10 UTC, Tom Tanner wrote:
>>
>> To put it another way: Is there something like `UserCreationForm`, but 
>> for logging in users?
>>
>> On Saturday, November 25, 2017 at 2:20:11 PM UTC-5, Tom Tanner wrote:
>>>
>>> I guess what I mean is... 
>>>
>>> What’s function do I need to use that: 
>>> A) logs in the user 
>>> B) returns an error if there’s a problem logging in?
>>
>>
> Did you read the docs, where these are fully documented?
>
> https://docs.djangoproject.com/en/1.11/topics/auth/default/#module-django.contrib.auth.views
> --
> DR. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To 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/ac8ae345-b886-40e6-8c9f-fd1b6d75c54e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How can I learn to make a user login?

2017-11-25 Thread Tom Tanner
To put it another way: Is there something like `UserCreationForm`, but for 
logging in users?

On Saturday, November 25, 2017 at 2:20:11 PM UTC-5, Tom Tanner wrote:
>
> I guess what I mean is... 
>
> What’s function do I need to use that: 
> A) logs in the user 
> B) returns an error if there’s a problem logging in?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/92c16e09-1af1-4a17-b749-b49e3af8819e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How can I learn to make a user login?

2017-11-25 Thread Tom Tanner
I guess what I mean is...

What’s function do I need to use that:
A) logs in the user 
B) returns an error if there’s a problem logging in?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/7b40c4d3-54fc-4f59-b577-6bd49fe12939%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How can I learn to make a user login?

2017-11-25 Thread Tom Tanner
I've read this tutorial 

 
on making a simple user registration form. But what about a form for just 
logging in existing users? I can make a registration form with `views.py` 
looking like this:

 registration_form.save()
 email= registration_form.cleaned_data.get("email")
 raw_password= registration_form.cleaned_data.get("password1")
 user= authenticate(username=email, password=raw_password)
 login(request, user)
 return redirect(home_slug())

Is there an example of how to make the backend for logging in 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/a99e8479-2a7a-4c64-b6bf-8c3f1e0d025f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I make Django show the "user already exists" message when someone tries to register with an existing username?

2017-11-24 Thread Tom Tanner
Thanks for replying. Looks like it'll be easier for me to combine these 
into one view.

On Thursday, November 23, 2017 at 7:13:16 PM UTC-5, Tom Tanner wrote:
>
> My `urls.py` has this:
> url("^login_register/$", views.login_register, name="login_register"),
> url("^register/$", views.register, name="register"),
>
> `views.py` has this:
> def login_register(request, template="pages/login_register.html"):
>  '''
>  Display registration and login forms
>  '''
>  registration_form= RegisterForm()
>  return render(request, template, {"registration_form": registration_form
> })
>
>
>
>
> def register(request):
>  '''
>  Process user registration
>  '''
>  if request.method=="POST":
>   form= RegisterForm(request.POST)
>   print form.is_valid()
>   if form.is_valid():
>form.save()
>email= form.cleaned_data.get("email")
>raw_password= form.cleaned_data.get("password1")
>user= authenticate(username=email, password=raw_password)
>login(request, user)
>return redirect(home_slug())
>  else:
>   return redirect(reverse("login_register"))
>
>
> `login_register.html` form HTML looks like this:
>  Register
>  
>{% csrf_token %}
>{{ registration_form.as_p }}
>Register
>  
>
>
> When I fill out registration with an email that already exists, I get this 
> error: `ValueError: The view theme.views.register didn't return an 
> HttpResponse object. It returned None instead.`. That's because when 
> `form.is_valid()` is False, there is no return value. What do I need to 
> return so that the message on the Registration form states the email 
> already exists?
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/acd3f42f-9859-4c0c-8f00-e8147c0bbc2b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How do I make Django show the "user already exists" message when someone tries to register with an existing username?

2017-11-23 Thread Tom Tanner
My `urls.py` has this:
url("^login_register/$", views.login_register, name="login_register"),
url("^register/$", views.register, name="register"),

`views.py` has this:
def login_register(request, template="pages/login_register.html"):
 '''
 Display registration and login forms
 '''
 registration_form= RegisterForm()
 return render(request, template, {"registration_form": registration_form})




def register(request):
 '''
 Process user registration
 '''
 if request.method=="POST":
  form= RegisterForm(request.POST)
  print form.is_valid()
  if form.is_valid():
   form.save()
   email= form.cleaned_data.get("email")
   raw_password= form.cleaned_data.get("password1")
   user= authenticate(username=email, password=raw_password)
   login(request, user)
   return redirect(home_slug())
 else:
  return redirect(reverse("login_register"))


`login_register.html` form HTML looks like this:
 Register
 
   {% csrf_token %}
   {{ registration_form.as_p }}
   Register
 


When I fill out registration with an email that already exists, I get this 
error: `ValueError: The view theme.views.register didn't return an 
HttpResponse object. It returned None instead.`. That's because when 
`form.is_valid()` is False, there is no return value. What do I need to 
return so that the message on the Registration form states the email 
already exists?


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/62069844-3db2-44b0-95b2-afde1abcd28b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I make my form send a POST request to a specified view?

2017-11-23 Thread Tom Tanner
Thanks, k2, this helped.

On Thursday, November 23, 2017 at 5:22:43 PM UTC-5, k2527806 wrote:
>
> login_register.html :
>
>  
>  {% csrf_token %}
>  {{ registration_form.as_p }}
>  Register
>  
>
>
> On Nov 24, 2017 1:42 AM, "Tom Tanner"  > wrote:
>
>> My page has a registration form at `"/login_register/"`. I want the form 
>> to send a POST request to `"/register/"`. Here's my code so far.
>>
>> `urls.py`:
>> url("^login_register/$", views.login_register, name="login_register"),
>> url("^register/$", views.register, name="register"),
>>
>>
>> `views.py`:
>> def login_register(request, template="pages/login_register.html"):
>>  '''
>>  Display registration and login forms
>>  '''
>>  registration_form= RegisterForm()
>>  return render(request, template, {"registration_form": registration_form
>> })
>>
>>
>> def register(request):
>>  '''
>>  Process user registration
>>  '''
>>  if request.method=="POST":
>># Some code here
>>
>>
>> `pages/login_register.html`:
>>  # For this example, I only include the registration form's HTML
>>  Register
>>  
>>  {% csrf_token %}
>>  {{ registration_form.as_p }}
>>  Register
>>  
>>
>>
>> When I hit "Register" on the form, my browser sends a POST request to 
>> "login_register/". I want it to send a POST request to "register/". How do 
>> I do this?
>>
>> -- 
>> You received this message because you are subscribed 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/72030063-8482-4723-9f2c-b25b17656a43%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/72030063-8482-4723-9f2c-b25b17656a43%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/5eb78826-d762-4dc9-af12-915365af5f41%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How do I make my form send a POST request to a specified view?

2017-11-23 Thread Tom Tanner
My page has a registration form at `"/login_register/"`. I want the form to 
send a POST request to `"/register/"`. Here's my code so far.

`urls.py`:
url("^login_register/$", views.login_register, name="login_register"),
url("^register/$", views.register, name="register"),


`views.py`:
def login_register(request, template="pages/login_register.html"):
 '''
 Display registration and login forms
 '''
 registration_form= RegisterForm()
 return render(request, template, {"registration_form": registration_form})


def register(request):
 '''
 Process user registration
 '''
 if request.method=="POST":
   # Some code here


`pages/login_register.html`:
 # For this example, I only include the registration form's HTML
 Register
 
 {% csrf_token %}
 {{ registration_form.as_p }}
 Register
 


When I hit "Register" on the form, my browser sends a POST request to 
"login_register/". I want it to send a POST request to "register/". How do 
I do this?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/72030063-8482-4723-9f2c-b25b17656a43%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I customize a user registration form so it only requires email and password fields?

2017-11-20 Thread Tom Tanner
I changed a few things. 

`models.py` now has this:

class MyUser(AbstractBaseUser):
email= models.CharField(max_length=254, unique=True)
USERNAME_FIELD= "email"

`forms.py`"

class RegisterForm(UserCreationForm):
email= forms.EmailField(label=_("Email"), max_length=254)

class Meta:
model= MyUser
fields= ("email",)

`views.py`:

def register(request, template="register.html", redirect='/'):
if request.method=="POST":
form= RegisterForm(request.POST)
if form.is_valid():
form.save()
email= form.cleaned_data.get("email")
raw_password= form.cleaned_data.get("password1")
user= authenticate(username=email, password=raw_password)
login(request, user)
return redirect('/')
else:
form= RegisterForm()
return render(request, template, {"form": form})

The form looks the same when rendered, with one "Email" field and two 
password fields. But now when I try to register I get this error: 
`'AnonymousUser' object has no attribute '_meta'`. And when navigated back 
to the form and reentered the email I used, the page refreshed and put this 
message above the form: `"My user with this Email already exists."`.

So Django makes the user, but there's a problem with processing stuff after 
the user's creation, I guess?

On Monday, November 20, 2017 at 4:26:16 PM UTC-5, Tom Tanner wrote:
>
> Hello Amitesh,
>
> When you say to return HttpReponse(), how would that code look? And I'm 
> still learning Django, but how would this make it so that the only required 
> fields on my registration form are "email" and "password?"
>
> Thanks.
>
> On Sunday, November 19, 2017 at 11:30:51 PM UTC-5, Amitesh Sahay wrote:
>>
>> Hello Tom, 
>>
>> Django comes inbuilt with user authentication functions which is almost 
>> more than enough in most of the requirements.
>> In your case, you just need to import User model in models.py and in 
>> views.py under "if" statement just return HttpResponse. You dont need to 
>> write anything else. For email and password you don't need custom models 
>> and views. 
>>
>> Amitesh
>>
>> Sent from Yahoo Mail on Android 
>> <https://overview.mail.yahoo.com/mobile/?.src=Android>
>>
>> On Mon, Nov 20, 2017 at 8:50, Tom Tanner
>>  wrote:
>> I'm following this [tutorial](
>> https://simpleisbetterthancomplex.com/tutorial/2017/02/18/how-to-create-user-sign-up-view.html)
>>  
>> on making simple registration forms in Django. I'd like to make a user 
>> registration form that requires only two fields: "Email" and "Password." No 
>> second password field, just one.
>>
>> So far, My `views.py` looks like this: 
>>
>> def register(request, template="register.html", redirect='/'):
>> if request.method=="POST":
>> form= RegisterForm(request.POST)
>> if form.is_valid():
>> form.save()
>> email= form.cleaned_data.get("email")
>> raw_password= form.cleaned_data.get("password1")
>> user= authenticate(email=email, password=raw_password)
>> login(request, user)
>> return redirect('/')
>> else:
>> form= RegisterForm()
>> return render(request, template, {"form": form})
>>  
>> `forms.py` has this class in it:
>>
>> class RegisterForm(UserCreationForm):
>> email= forms.EmailField(label=_("Email"), max_length=254)
>> 
>> class Meta:
>> model= User
>> fields= ("email",)
>>
>> `register.html` looks simple:
>>
>> {% extends "base.html" %}
>> {% block main %}
>> Register
>> 
>> {% csrf_token %}
>> {{ form.as_p }}
>> Register
>> 
>> {% endblock main %}
>>
>> In `urls.py`, I have this line in `urlpatterns`: `url("^register/$", 
>> views.register, name="register"),`.
>>
>> But my registration forms looks like this, with an Email field and two 
>> Password fields: http://i.imgur.com/b359A5Z.png. And if I fill out all 
>> three fields and hit "Register," I get this error: `UNIQUE constraint 
>> failed: auth_user.username`.
>>
>> Any idea why I'm getting this error? And how can I make sure my form only 
>> has two fields: Email and Password?
>>
>> -- 
>> You received this message because you are subscribed to t

Re: How do I customize a user registration form so it only requires email and password fields?

2017-11-20 Thread Tom Tanner
Hello Amitesh,

When you say to return HttpReponse(), how would that code look? And I'm 
still learning Django, but how would this make it so that the only required 
fields on my registration form are "email" and "password?"

Thanks.

On Sunday, November 19, 2017 at 11:30:51 PM UTC-5, Amitesh Sahay wrote:
>
> Hello Tom, 
>
> Django comes inbuilt with user authentication functions which is almost 
> more than enough in most of the requirements.
> In your case, you just need to import User model in models.py and in 
> views.py under "if" statement just return HttpResponse. You dont need to 
> write anything else. For email and password you don't need custom models 
> and views. 
>
> Amitesh
>
> Sent from Yahoo Mail on Android 
> <https://overview.mail.yahoo.com/mobile/?.src=Android>
>
> On Mon, Nov 20, 2017 at 8:50, Tom Tanner
> > wrote:
> I'm following this [tutorial](
> https://simpleisbetterthancomplex.com/tutorial/2017/02/18/how-to-create-user-sign-up-view.html)
>  
> on making simple registration forms in Django. I'd like to make a user 
> registration form that requires only two fields: "Email" and "Password." No 
> second password field, just one.
>
> So far, My `views.py` looks like this: 
>
> def register(request, template="register.html", redirect='/'):
> if request.method=="POST":
> form= RegisterForm(request.POST)
> if form.is_valid():
> form.save()
> email= form.cleaned_data.get("email")
> raw_password= form.cleaned_data.get("password1")
> user= authenticate(email=email, password=raw_password)
> login(request, user)
> return redirect('/')
> else:
> form= RegisterForm()
> return render(request, template, {"form": form})
>  
> `forms.py` has this class in it:
>
> class RegisterForm(UserCreationForm):
> email= forms.EmailField(label=_("Email"), max_length=254)
> 
> class Meta:
> model= User
> fields= ("email",)
>
> `register.html` looks simple:
>
> {% extends "base.html" %}
> {% block main %}
> Register
> 
> {% csrf_token %}
> {{ form.as_p }}
> Register
> 
> {% endblock main %}
>
> In `urls.py`, I have this line in `urlpatterns`: `url("^register/$", 
> views.register, name="register"),`.
>
> But my registration forms looks like this, with an Email field and two 
> Password fields: http://i.imgur.com/b359A5Z.png. And if I fill out all 
> three fields and hit "Register," I get this error: `UNIQUE constraint 
> failed: auth_user.username`.
>
> Any idea why I'm getting this error? And how can I make sure my form only 
> has two fields: Email and Password?
>
> -- 
> You received this message because you are subscribed 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/94d23f3b-25ee-437d-8302-ad80d6ecc1a1%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/94d23f3b-25ee-437d-8302-ad80d6ecc1a1%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/dd1dbb48-c624-4311-8726-22d405a3a8b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How do I customize a user registration form so it only requires email and password fields?

2017-11-19 Thread Tom Tanner
I'm following this 
[tutorial](https://simpleisbetterthancomplex.com/tutorial/2017/02/18/how-to-create-user-sign-up-view.html)
 
on making simple registration forms in Django. I'd like to make a user 
registration form that requires only two fields: "Email" and "Password." No 
second password field, just one.

So far, My `views.py` looks like this: 

def register(request, template="register.html", redirect='/'):
if request.method=="POST":
form= RegisterForm(request.POST)
if form.is_valid():
form.save()
email= form.cleaned_data.get("email")
raw_password= form.cleaned_data.get("password1")
user= authenticate(email=email, password=raw_password)
login(request, user)
return redirect('/')
else:
form= RegisterForm()
return render(request, template, {"form": form})
 
`forms.py` has this class in it:

class RegisterForm(UserCreationForm):
email= forms.EmailField(label=_("Email"), max_length=254)

class Meta:
model= User
fields= ("email",)

`register.html` looks simple:

{% extends "base.html" %}
{% block main %}
Register

{% csrf_token %}
{{ form.as_p }}
Register

{% endblock main %}

In `urls.py`, I have this line in `urlpatterns`: `url("^register/$", 
views.register, name="register"),`.

But my registration forms looks like this, with an Email field and two 
Password fields: http://i.imgur.com/b359A5Z.png. And if I fill out all 
three fields and hit "Register," I get this error: `UNIQUE constraint 
failed: auth_user.username`.

Any idea why I'm getting this error? And how can I make sure my form only 
has two fields: Email and Password?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/94d23f3b-25ee-437d-8302-ad80d6ecc1a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to save user permissions from custom user edit form

2017-11-04 Thread DJ-Tom
Hi,

I have created the following user form for my custom user model:

class UsersForm(ModelForm):
class Meta:
model = UserAccount
fields = ('is_active', 'is_superuser', 'is_templog', 'is_crewreg', 
'is_spaceman','first_name', 'last_name',
  'company', 'address1', 'address2', 'address3', 'zipcode', 
'city', 'country', 'email', 'favourite_event',
  'user_permissions')

def __init__(self, *args, **kwargs):
super(UsersForm, self).__init__(*args, **kwargs)
self.fields['country'].required = False
self.fields['user_permissions'].widget.attrs['class'] = 'input-xxlarge'
self.fields['user_permissions'].widget.attrs['style'] = 
'min-height:150px'
self.fields['user_permissions'].help_text = 'Specific permissions for 
this user. Hold down "Control", or "Command" on a Mac, to select more than one.'



But when I save it via form.save(), any changed permissions are not saved. 
What do I have to do to change this? 

thanks 
Thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/7c11c2b2-4c2e-46d5-93cd-97924cf79bc9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Remove/undo a multi table inheritance

2017-11-02 Thread &#x27;Tom Evans' via Django users
Does it work if you do it in several stages (each one is a separate
migration action):

* Add the OneToOneField, make it nullable, still using MTI
* Add a python migration that populates it from the existing MTI information
* Remove the MTI
* Make the 1-2-1 field as you like it (remove null=True etc)

Of course, this won't get rid of MTI, as MTI is simply a normalized
way of specifying that other models have a one to one correspondence
with a base model - if you express this as model inheritance, or if
you express it as an explicit 1-2-1 with a base model makes no
difference to the underlying structure of the tables, and hence any
performance characteristics will not change, so why bother?

Cheers

Tom

On Thu, Nov 2, 2017 at 9:11 AM,   wrote:
> Hi,
>
> I have introduced a multi table inheritance in the past. Now I am trying to
> remove it again by adding an explicit one-to-one relation from the child
> table to the parent. So my starting point is:
>
> from django.db import models
>
> class Place(models.Model):
>  name = models.CharField(max_length=50)
>  address = models.CharField(max_length=80)
>
> class Restaurant(Place):
>  serves_hot_dogs = models.BooleanField(default=False)
>  serves_pizza = models.BooleanField(default=False)
>
>
> And I want to end up with something similar to this:
>
>
> from django.db import models
>
> class Place(models.Model):
>  name = models.CharField(max_length=50)
>  address = models.CharField(max_length=80)
>
> class Restaurant(models.Model):
>  place_ptr = models.OneToOneField(Place)
>  serves_hot_dogs = models.BooleanField(default=False)
>  serves_pizza = models.BooleanField(default=False)
>
> When running make migrations it will prompt me for an initial value for the
> newly introduced `id` field, which I don't know howto provide.
>
>
> I attempt the following fixes:
>
>
>- introducing an Integer field, copy data from the implicit OneToOneField
> and making both explicit while switiching the primary_key at the same time
> (fails in sqlite with NOT NULL constraint and primary key issues on
> postgres)
>
>- writing a SplitDatabaseAndState migration where in the State part the
> model is deleted and recreated, while in the database part the shema editor
> is used to alter the fields as needed, that didn't work either
>
>
> So there are two questions that come to my mind:
>
>
> 1. What is the proper way to undo a multi table inheritance?
>
> 2. Is there even an official way to change the primary key of a model in
> Django, that does work without SQL migrations?
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send 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/ff8be877-1eb8-419b-b456-89d20e9c09d8%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/CAFHbX1L2O%2Bw%3DGzvG1Y8zsFWqFTsEaPQDFPHiHSjK_MJN4MhgJA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: CSRF and API Calls

2017-09-25 Thread Tom Gorup
The view for csrf token is what I'm testing out now. I created a standard 
GET handler which should be returning the CSRF token. I was hoping to see 
how others have solved the problem. Possibly more elegantly that a "pre" 
GET to the POST just to obtain the CSRF token; however, at the same time I 
understand the need. 

I would prefer not to make the calls exempt for the obvious security 
reasons.


On Friday, September 22, 2017 at 2:17:08 PM UTC-4, Matthew Pava wrote:
>
> Do you have access to the Django backend code?
>
> You could disable CSRF validation by applying the @csrf_exempt decorator 
> to the corresponding view functions.
>
> Maybe you could create a view that returns only the CSRF token (through 
> AJAX?) that you can utilize as needed?
>
>  
>
> *From:* django...@googlegroups.com  [mailto:
> django...@googlegroups.com ] *On Behalf Of *Tom Gorup
> *Sent:* Friday, September 22, 2017 8:46 AM
> *To:* Django users
> *Subject:* CSRF and API Calls
>
>  
>
> I'm having a bit of an issue. I'm attempting to utilize a Javascript/React 
> App to interact with a Django backend without the use of templates (hence 
> no {%csrftoken%} available). As I understand CSRF middleware, the CSRF 
> token comes with the form on the GET and is provided in the POST; however, 
> if I'm not utilizing the templates and the app is completely separate from 
> Django. 
>
>  
>
> How do I go about obtaining the CSRF token prior to making the 
> POST/PUT/etc.?
>
>  
>
> Let me know if you need more context. Appreciate any assistance!
>
> -- 
> You received this message because you are subscribed 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 djang...@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/13ecce96-2de8-4a42-8b1e-3b98ccbae524%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/13ecce96-2de8-4a42-8b1e-3b98ccbae524%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/f0c08232-d39f-418e-8467-3e3af69dbad8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


CSRF and API Calls

2017-09-22 Thread Tom Gorup
I'm having a bit of an issue. I'm attempting to utilize a Javascript/React 
App to interact with a Django backend without the use of templates (hence 
no {%csrftoken%} available). As I understand CSRF middleware, the CSRF 
token comes with the form on the GET and is provided in the POST; however, 
if I'm not utilizing the templates and the app is completely separate from 
Django. 

How do I go about obtaining the CSRF token prior to making the 
POST/PUT/etc.?

Let me know if you need more context. Appreciate any assistance!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/13ecce96-2de8-4a42-8b1e-3b98ccbae524%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Bizarre URL behaviour after deploying

2017-08-31 Thread &#x27;Tom Evans' via Django users
On Thu, Aug 31, 2017 at 2:09 AM, Bernd Wechner  wrote:
> Daniel,
>
> Yes, I have deployed, that is the problem in a sense. URLs are clean in dev
> and suddenly contain an app_name when deployed.
>
> Not sure what you mean by configuration? The Django settings are here:
>
> https://github.com/bernd-wechner/CoGs/blob/master/CoGs/settings.py
>
> The rest of the config is uwsgi under lighttpd, but none of that is likely
> to impact the appearance of an app_name in my URLs all of a sudden. I don't
> mind sharing the config files, but it's a distraction I fear.

I think you will be surprised.

I'm surprised your diagnosis doesn't point you at this straight away,
if the URLs are correct on one site but incorrect on another site, and
both sites run the exact same python/django code, then the error is
certainly in the bits that are different.

Cheers

Tom

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


Re: A lot of Problems with Migrating (conceptual)

2017-08-23 Thread &#x27;Tom Evans' via Django users
On Tue, Aug 22, 2017 at 8:37 PM, Alexander Joseph
 wrote:
> Thanks for all the advice.
>
> One more question - could project structure be causing issues with
> migrations? I'm working on a large project and many apps in my project have
> several layers of "sub-apps". My structure looks something like this...

This approach seems appealing, but personally I think it is a bad idea
because the ease of introducing dependencies between apps is extremely
high. Even when the apps are all tightly related to a particular
project (to the extent their package name is
"fooproject-some-function"), I think its better to simply develop each
one as a standalone app, separate from the other apps and not
requiring the other apps in order to test/develop.

With this approach, you will not get unnecessarily thin apps simply
because you cannot easily couple two apps together, and everything
within the app should have high cohesion. Remember (or discover :)
that in software engineering, high quality code is loosely coupled (it
doesn't depend on many external things) and highly cohesive (the
things within the module are related to each other).

I would also avoid the use of subapps. First off, Django only uses the
final part of the dotted import path as the app name -
'engineering.products.product1' has the same name as
'accounting.invoices.product1' (I know that doesn't exist, but...). I
have a (unsubstantiated) theory that your migration woes are down to
subapps.

Long model files are not good, but I'd also disagree with 2SoD that
getting to 5 models means a new app because of long files - what
ridiculousness! If your model file is getting long, replace it with a
model directory, each model in a separate module, and all of them
imported in the __init__. You should split your app when it is no
longer cohesive (or more accurately, when the level of cohesion is
upsetting and/or slows development). 2SoD is good, but its not a holy
text!

Cheers

Tom

PS

Make sure you have a sensible workflow for migrations - I'm assuming
you are using some sort of version control. While you are developing
your changes, you might generate a lot of temporary migrations. You do
not want to apply these migrations to live, so you should squash them
- either manually, using squashmigrations or by migrating the DB back
to before they existed, remove them and recreate them. If you do the
last one, remember to preserve any custom logic you have placed in the
migration.

At the end of the day, the migrations you commit are what will run on
your production database, so you should ensure they do exactly what
you are expecting them to do and are running in the correct order.
Particularly if you have a lot of small apps, getting the dependencies
right is essential.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 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/CAFHbX1J-Oxam2oHB37ap3rY5Sio2%2BR0WGMKKpmPtT-5JMaGDHA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: TypeError: __init__() takes 2 positional arguments but 3 were given (django-material)

2017-07-28 Thread &#x27;Tom Evans' via Django users
Your error refers to part of a class you haven't included,
ClientsForm, and it has an error to do with a class called Stacked,
which you haven't shown where it is imported from. Hard to diagnose
further..

Cheers

Tom

On Thu, Jul 27, 2017 at 1:02 AM, Elias Coutinho
 wrote:
> Traceback (most recent call last):
>   File
> "/home/eliaspai/danibraz/.danibraz/lib/python3.5/site-packages/django/utils/autoreload.py",
> line 226, in wrapper
> fn(*args, **kwargs)
>   File
> "/home/eliaspai/danibraz/.danibraz/lib/python3.5/site-packages/django/core/management/commands/runserver.py",
> line 121, in inner_run
> self.check(display_num_errors=True)
>   File
> "/home/eliaspai/danibraz/.danibraz/lib/python3.5/site-packages/django/core/management/base.py",
> line 374, in check
> include_deployment_checks=include_deployment_checks,
>   File
> "/home/eliaspai/danibraz/.danibraz/lib/python3.5/site-packages/django/core/management/base.py",
> line 361, in _run_checks
> return checks.run_checks(**kwargs)
>   File
> "/home/eliaspai/danibraz/.danibraz/lib/python3.5/site-packages/django/core/checks/registry.py",
> line 81, in run_checks
> new_errors = check(app_configs=app_configs)
>   File
> "/home/eliaspai/danibraz/.danibraz/lib/python3.5/site-packages/django/core/checks/urls.py",
> line 14, in check_url_config
> return check_resolver(resolver)
>   File
> "/home/eliaspai/danibraz/.danibraz/lib/python3.5/site-packages/django/core/checks/urls.py",
> line 24, in check_resolver
> for pattern in resolver.url_patterns:
>   File
> "/home/eliaspai/danibraz/.danibraz/lib/python3.5/site-packages/django/utils/functional.py",
> line 35, in __get__
> res = instance.__dict__[self.name] = self.func(instance)
>   File
> "/home/eliaspai/danibraz/.danibraz/lib/python3.5/site-packages/django/urls/resolvers.py",
> line 313, in url_patterns
> patterns = getattr(self.urlconf_module, "urlpatterns",
> self.urlconf_module)
>   File
> "/home/eliaspai/danibraz/.danibraz/lib/python3.5/site-packages/django/utils/functional.py",
> line 35, in __get__
> res = instance.__dict__[self.name] = self.func(instance)
>   File
> "/home/eliaspai/danibraz/.danibraz/lib/python3.5/site-packages/django/urls/resolvers.py",
> line 306, in urlconf_module
> return import_module(self.urlconf_name)
>   File
> "/home/eliaspai/.pyenv/versions/3.5.0/lib/python3.5/importlib/__init__.py",
> line 126, in import_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 986, in _gcd_import
>   File "", line 969, in _find_and_load
>   File "", line 958, in _find_and_load_unlocked
>   File "", line 673, in _load_unlocked
>   File "", line 662, in exec_module
>   File "", line 222, in
> _call_with_frames_removed
>   File "/home/eliaspai/dani/config/urls.py", line 20, in 
> url(r'^cadastro/', include('danibraz.persons.urls',
> namespace='persons')),
>   File
> "/home/eliaspai/danibraz/.danibraz/lib/python3.5/site-packages/django/conf/urls/__init__.py",
> line 50, in include
> urlconf_module = import_module(urlconf_module)
>   File
> "/home/eliaspai/.pyenv/versions/3.5.0/lib/python3.5/importlib/__init__.py",
> line 126, in import_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 986, in _gcd_import
>   File "", line 969, in _find_and_load
>   File "", line 958, in _find_and_load_unlocked
>   File "", line 673, in _load_unlocked
>   File "", line 662, in exec_module
>   File "", line 222, in
> _call_with_frames_removed
>   File "/home/eliaspai/dani/danibraz/persons/urls.py", line 5, in 
> from danibraz.persons.views import clients, employees
>   File "/home/eliaspai/dani/danibraz/persons/views.py", line 6, in 
> from danibraz.persons.forms import ClientsForm, EmployeeForm
>   File "/home/eliaspai/dani/danibraz/persons/forms.py", line 31, in 
> class ClientsForm(Form):
>   File "/home/eliaspai/dani/danibraz/persons/forms.py", line 52, in
> ClientsForm
> Stacked(1, 'addresses'),
> TypeError: __init__() takes 1 positional argument but 3 were given
>
>
>
>
> Em terça-feira, 25 de julho de 2017 18:16:20 UTC-3, Tim Graham escreveu:
>>
>> Please give the exception traceback.
>>
>> On Tuesday, July 25, 2017 at 3:35:41 PM UTC-4, Elias Coutinho wrote:
>>>
>>> Hello guys!
>>

Re: serving over either 80 or 443

2017-07-20 Thread &#x27;Tom Evans' via Django users
On Wed, Jul 19, 2017 at 9:55 PM, Larry Martell  wrote:
> This is probably not strictly a Django question, but I'm hoping
> someone here has had to solve this before.
>
> We have a django app that is sometimes deployed in an environment with
> SSL and talks over port 443, and other times is deployed in a non-SSL
> environment and talks over port 80.  In our templates we serve CSS and
> JS files with this: href="https://0.0.0.0:443/..."; When running over
> port 80 that does not work. Is there a way to tell in the template if
> we are using port 80 or 443 and adjust the href accordingly?
>

For links within the same site, use relative URLs.

For resources on other sites, use protocol relative URLs, like:

  //www.foo.com/foo/bar

The resource will be loaded using whatever protocol the page
requesting it was loaded with.

Cheers

Tom

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


Re: How to get extra data in clean_data?

2017-07-18 Thread &#x27;Tom Evans' via Django users
On Tue, Jul 18, 2017 at 2:13 PM, 李余通  wrote:
> Thank you very much!you are right
> I solve the problem:
> [...]
> And last,I want konw how to send a web pag (can auto jumps Specific
> location) to others,such as you url
> "https://github.com/django/django/blob/master/django/contrib/auth/forms.py#L64";

Perhaps reading some simple documentation about HTML might be more
assistance than asking several thousand people to do it for you?

Anyway - Anchors:

http://html.com/anchors-links/

Cheers

Tom

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


Re: How to get extra data in clean_data?

2017-07-18 Thread &#x27;Tom Evans' via Django users
As described in the docs on form and field validation, if you want to
validate one field using another field, you do so in the clean()
method:

https://docs.djangoproject.com/en/1.8/ref/forms/validation/

and in detail

https://docs.djangoproject.com/en/1.8/ref/forms/validation/#cleaning-and-validating-fields-that-depend-on-each-other

Cheers

Tom

On Tue, Jul 18, 2017 at 10:19 AM, 李余通  wrote:
> My mind is here:
>
> class Register(forms.Form):
> passwd =
> forms.CharField(max_length=20,label='密码',widget=forms.PasswordInput)
> repasswd =
> forms.CharField(max_length=20,label='重复密码',widget=forms.PasswordInput)
>
> def clean_passwd(self):
> passwd = self.cleaned_data['passwd']
> repasswd = self.cleaned_data['repasswd'] #here is error
>
> if passwd != repasswd:
> raise forms.ValidationError('两次密码不一致')
> return passwd
>
> So,problems is i want to check passwd and repasswd same,How to solve?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send 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/ab8a7050-37c8-4547-9b86-5bd16821ede9%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/CAFHbX1LbDR7QxRsGZB6dC6doYPONvURcANrVxfUT_r%3DtT4h_9w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to create a fixed-length binary field with a unique constraint?

2017-07-13 Thread &#x27;Tom Evans' via Django users
On Tue, Jul 11, 2017 at 12:05 AM, Mike Morris  wrote:
> From your description (save a SHA-256 checksum),  you do not need a binary
> field. Binaries are always of indeterminant length; they can hold photos,
> executables, sound files, etc.
>
> By definition, a SHA -256 is 256 bytes of ASCII.
>
> You probably want a CharField(length=256).
>

BinaryField is arbitrary size, binaries are not. The binary
representation of a SHA-256 is significantly smaller (it's 256 *bits*,
or 32 bytes), hence why the OP wants to store his binary objects in
the most efficient format possible, not 2 or 8 times that size.

Its like storing an IPv4 address as the 15 bytes string
"10.123.132.254" or the 4 byte integer 175867134.

Guido:

You can make your own custom database types quite simply (completely untested):

class FixedSizedBinaryField(models.BinaryField):
  def __init__(self, num_bytes=None, *args, **kwargs):
self.nbytes = num_bytes
super(FixedSizedBinaryField, self).__init__(*args, **kwargs)

  def deconstruct(self):
name, path, args, kwargs = super(FixedSizedBinaryField, self).deconstruct()
kwargs[''num_bytes'] = self.nbytes
return name, path, args, kwargs

  def db_type(self, connection):
return "binary(%d)" % self.nbytes

For more details, check out the docs on custom fields:

https://docs.djangoproject.com/en/1.11/howto/custom-model-fields/

Cheers

Tom

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


Re: django implementation group by every two hours,

2017-07-13 Thread &#x27;Tom Evans' via Django users
On Tue, Jul 11, 2017 at 10:22 AM, kanhaiya yadav
 wrote:
> Hi,
>
> I have a model
> class XyzModel (models.Model):
>name = models.CharField(max_length=NAME_LENGTH)
>unique_id = models.CharField(max_length=NAME_LENGTH)
>info = models.CharField(max_length=NAME_LENGTH, blank=True)
>violation_time = models.DateTimeField()
>
>
>
>
> I have many rows in the database. So I want to group by the results for
> every two hours or for every four hours.
> I want the result something like
>
> name   violation_date
> interval counts
> abc   2017-07-01
> 06:00 - 08:00   20
> xyz   2017-07-01
> 08:00 - 10:00   30
>
> My query is
> XyzModel.objects
> .extra({"day": "date_trunc('hour',violation_time)"}
> .values("day")
> .order_by("day")
> .annotate(count=Count("id"))
> But using this query I can only group the result by one hour interval. I
> want to group by more than one hour interval.

You realise your "day" parameter is actually hours, right?

.extra({'day', 'TRUNC(EXTRACT(hour FROM violation_time) / 2)'})

'day' will then be the 0-based index of the 2 hour periods, starting
from midnight, so a value of 5 would mean 10 AM - 12 AM.

Cheers

Tom

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


Re: save cropped image with PIL to database

2017-07-13 Thread &#x27;Tom Evans' via Django users
On Mon, Jul 3, 2017 at 11:09 AM, shahab emami  wrote:
> hello
>
> i have a question and i cant find answer with search.
>
> i want to save cropped image in database then :
> this is my model:
>
> class Photo(models.Model):
> file= models.ImageField(upload_to='%Y/%m/%d',
> blank=True,null=True)
>
>
> i have a form then user can select image and send to view like this:
>
> 
> {% csrf_token %}
>
>   
>
> 
>
>   
>
>
> and in the view i have this :
>
> from PIL import Image
>
>
> def save_photo(request):
>
> _photo, created = models.Photo.objects.get_or_create(pk=1)
>
> if request.method == 'POST':
> photo = request.FILES.get('file')

This is a django.core.files.File (or subclass) object. It is file-like
and can be treated as a file.

>
> image = Image.open(photo)
>
> cropped_image = image.crop((100, 100, 200, 200))
> resized_image = cropped_image.resize((200, 200), Image.ANTIALIAS)

resized_image is a pil.Image. Again, it is file-like, but it is not a
django.core.files.File...

> _photo.file = resized_image
> _photo.save()

so this doesn't work. You will need to wrap the PIL.Image file-like
object with the django File class (remember appropriate imports):

_photo.file = File(resized_image)
_photo.save()


Cheers

Tom

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


Re: Vim plugin that does Django code completion?

2017-07-13 Thread &#x27;Tom Evans' via Django users
Hi Robert

Ignore the helpful people telling you to stop using vim and use some
god awful UI, the plugin you are looking for is called jedi.vim

https://github.com/davidhalter/jedi-vim

Debian has a package, vim-python-jedi, or you can install using
Pathogen or Vundle.

Cheers

Tom

On Fri, Jul 7, 2017 at 4:27 PM, Robert F.  wrote:
> Is there a Vim plugin that does code completion for Django?  I'd like to be
> able to type something like "foobar = models." and hit Tab and see a list of
> classes like CharField or Foreign key.  Alternately, I'd be OK with entering
> an abbreviation that would bring up the proper code snippet.  The Django
> documentation suggests YouCompleteMe but it appears to only handle Python
> code, not Django specifically.  Also, I haven't been able to get it to work
> on my Mac laptop.
>
> I almost exclusively do editing of Django files on a remote Debian server
> from my Mac laptop.  I know PyCharm provides the ability to edit remote
> files and it has Vim emulation but it's pretty expensive and I'm not sure
> how closely the emulator emulates Vim.  SublimeText appears to have a
> "Djaneiro" package that does what I need but it looks like editing remote
> files is rather difficult with Sublime.  Doesn't Vim have better support for
> Django code completion that's comparable to these two applications?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send 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/166226ca-2fc6-4454-9baf-0d871c552a8f%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/CAFHbX1LySk_S4BBrTOho8mWD6AcJM8JO231%2B25rmnZOBjS0YWA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: value of checkbox aren't saved in the form

2017-05-31 Thread &#x27;Tom Evans' via Django users
Your checkbox fields on the form are "market" and "sector", but your
"Parameters" model doesn't have fields with those names, and you
aren't doing anything with the values from the form in your save()
method.

Where were you expecting those checkboxes to be saved?

Cheers

Tom

On Wed, May 31, 2017 at 1:15 PM,   wrote:
> i am a beginner with Django. I don''t know what the problem with the value
> of checkbox. When i enter to the saved form the value of checkbox aren't
> save.The image is here . Please I need your help, I loose too much time on
> this.
>
> This is my forms.py:
>
> class BacktestForm(forms.ModelForm):
>
> period_start = forms.DateField(initial=datetime.datetime.today().date() -
> datetime.timedelta(days=365+16),
> widget=forms.widgets.DateInput(format="%Y/%m/%d"),
> input_formats=["%Y/%m/%d"])
> period_end = forms.DateField(initial=datetime.datetime.today().date() -
> datetime.timedelta(days=16),
> widget=forms.widgets.DateInput(format="%Y/%m/%d"),
> input_formats=["%Y/%m/%d"])
>
> market =
> forms.MultipleChoiceField(required=False,widget=CheckboxSelectMultiple,
> choices=MARKET_CHOICES)
> sector =
> forms.MultipleChoiceField(required=False,widget=CheckboxSelectMultiple,
> choices= MEDIA_CHOICES)
> class Meta:
> model = Parameters
>
> This is my models.py:
>
> class Parameters(models.Model):
>
> user = models.ForeignKey(User)
> title = models.CharField('title', max_length=100, default='', blank=True,
> help_text='Use an indicative name, related to the chosen parameters')
> type = models.CharField('forecast type', choices=FORECAST_TYPES,
> max_length=20, default="backtest")
>
> #input characteristics
> price_1_min = models.FloatField('1. Price, min', default=0.1,
> validators=[MinValueValidator(0.1), MaxValueValidator(2)])
>
> def get_backtest_url(self):
> return reverse('saved_backtest', kwargs={'pk': self.pk})
>
>
> The save function in views.py:
>
>
> if request.method == 'POST':
> if form.is_valid():
> if 'save' in request.POST:
> obj = form.save(commit= False)
> obj.user = request.user
> obj.type = "backtest"
> obj.save()
> messages.info(request, 'Saved!')
> return redirect(obj.get_backtest_url())
>
>
> The template for the saved form is :
>
>   {% if user.is_authenticated %}
> {% if user.profile.is_active %}
>    Saved from "Backtesting"
> 
> {% for param in user.parameters_set.all %}
> {% if param.type == "backtest" %}
>   style="width:100%">
>   
> Saved File
> 
> Created at
> 
>
>   
>
>  href='{{param.get_backtest_url}}'>{{param.title}}   
>{{param.created_at}} 
>
>  
> 
> {% endif %}
> {% endfor %}
> 
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/55e259b4-8986-41d0-849e-4fe809001ff0%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/CAFHbX1KXUD5%3DZRT%2Bu4k3EBLnzC%3D5MLt6LCPO-UX%2BWJrLrAT5wQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to fix "plural forms expression could be dangerous"

2017-05-18 Thread &#x27;Tom Evans' via Django users
You need to change INTEGER and EXPRESSION for the correct values. I
believe for zh you want "nplurals=1; plural=0;"

Cheers

Tom

On Thu, May 18, 2017 at 7:41 AM, Martin Brochhaus
 wrote:
> Hi everyone,
>
> in my project, I am generating my .po files like this:
>
> python manage.py makemessages --ignore=node_modules/* --ignore=*migrations/*
> --ignore=*tests/* --ignore=__init__.py --ignore=submodules/*
> --ignore=fabfile* -l zh_CN
>
> Usually this results in the following line being added to my `django.po`
> file:
>
> "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
>
> When this line is in the file and when I switch the language to Chinese, I
> will get this error:
>
> ValueError at /zh-cn/
> plural forms expression could be dangerous
>
> When I delete that line and run `./manage.py compilemessages`, everything
> seems to work fine, but this is obviously can't be a good solution and would
> mess up my deployment workflow quite a bit.
>
> So my question is: Why does this line pop up in my .po file? What if I
> change that expression to something valid, would it be overwritten with that
> same faulty expression again when I run makemessages? What would a correct
> expression look like for Chinese?
>
> Best regards,
> Martin
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send 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/5db9fbc1-9f59-4947-a214-0af82c8c4458%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/CAFHbX1K1tFqLUozgn%3DjZxdFF18WDJGYB2-rxra_-m2%2BvxKj3gw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Deployment showing list of directory

2017-05-08 Thread &#x27;Tom Evans' via Django users
On Mon, May 8, 2017 at 11:08 AM, sarfaraz ahmed  wrote:
> Hello Guys,
> [ .. ]
> This is conf file for Apache
> --
> 
> ServerAdmin ad...@testarhamcollections.com
> DocumentRoot "C:/Apache24/htdocs/testarhamcollections"
> ServerName www.testarhamcollections.com
> ServerAlias testarhamcollections.com
> ErrorLog
> "C:/Apache24/htdocs/testarhamcollections/logs/testarhamcollections.com-error.log"
> CustomLog
> "C:/Apache24/htdocs/testarhamcollections/logs/testarhamcollections.com-access.log"
> common
>
> WSGIScriptAlias /
> "c:/Apache24/htdocs/testarhamcollections/project1/wsgi.py"
>
> Alias / "c:/Apache24/htdocs/testarhamcollections"
> Alias /static/ "c:/Apache24/htdocs/testarhamcollections/static/"
> Alias /media/ "c:/Apache24/htdocs/testarhamcollections/static/media/"

DANGER!

Python/WSGI is not like PHP, the program files should not live in web
accessible directory.
Your WSGI script should not be in a web accessible directory.
The only things that should be in a web accessible directory are your
static htdocs, which are collected to that location by Django using
the command "collectstatic".

Your project files should be OUTSIDE the document root and NOT aliased
into it in any way!


A typical layout should look like so:


c:/DjangoProjects/project_name
├── htdocs
├── logs
├── my_project
│   ├── manage.py
│   ├── my_app1
│   │   ├── __init__.py
│   │   ├── admin.py
│   │   ├── apps.py
│   │   ├── migrations
│   │   │   └── __init__.py
│   │   ├── models.py
│   │   ├── tests.py
│   │   └── views.py
│   ├── my_app2
│   │   ├── __init__.py
│   │   ├── admin.py
│   │   ├── apps.py
│   │   ├── migrations
│   │   │   └── __init__.py
│   │   ├── models.py
│   │   ├── tests.py
│   │   └── views.py
│   └── my_project
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
└── my_virtual_env

The only directory of those that should be web accessible is htdocs,
and none of your code should live there.

Cheers

Tom

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


Re: Unicode error in __unicode__(self) function

2017-05-08 Thread &#x27;Tom Evans' via Django users
What data is "Jón"?

Is it u'J\xf3n' or something else? (print repr(self.fname))

Cheers

Tom

On Mon, May 8, 2017 at 5:10 PM, rmschne  wrote:
> I have a Django setup that has worked for a very long time. Yesterday I
> upgraded from Django 1.10 to 1.11.1 and am getting the error:
>
> raise DjangoUnicodeDecodeError(s, *e.args)
> django.utils.encoding.DjangoUnicodeDecodeErrorJón
> : 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in
> range(128). You passed in  ( 'soc_util.models.Meetingattendee'>)
>
> when in the code simply printing the "Meetingattendee" object with
>
> def __unicode__(self):
> print self.fname
> return self.fname
>
> The above is a simplified version. The error first cropped up on the more
> complex version
>
> def __unicode__(self):
> s=u'%s: %s, %s %s, %-12s, %s %s, %s, INV:%s, PO:%s, ItemCode:%s' %
> (self.id,self.meeting.date.strftime("%d-%b-%Y"),self.table,self.seat,\
> self.attendeestatus.status,self.fname, self.lname,
> self.affiliation, \
> self.invoiceno,self.ponumber,self.itemcode)
> return s
>
> where I eventually determined that the code was not working when working the
> field self.fname.
>
> self.fname fails when it is "Jón".  Works fin with "Jon", of course.
>
> I have not tried to revert back to Django 1.10, but i guess that's the next
> step unless there is something in Django 1.11.1 that was changed that
> affects this. I can't find anything mentioned in the release notes.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send 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/4d37cc78-7fe9-41b6-bcba-eb788465e54f%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/CAFHbX1Lw_gfZANGr95XFM2RSoRVemtnv3YSvC3zK1FTgbnSiGg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


  1   2   3   4   5   6   7   8   9   10   >