Re: Django User module extend

2018-01-05 Thread Matemática A3K
On Fri, Jan 5, 2018 at 1:52 PM, Ketul Suthar  wrote:

> class Profile(models.Model):
> user = models.OneToOneField(User, on_delete=models.CASCADE)
> is_manager  = models.BooleanField(default=False)
> manager = models.ForeignKey(User,related_name='user_manager',
> on_delete=
> models.CASCADE, blank=True,null=True)
> def __str__(self):  # __unicode__ for Python 2
> return self.user.username
>
> Is it right ?


Seems so

how can i create form ?
>

One way:
https://simpleisbetterthancomplex.com/tutorial/2016/11/23/how-to-add-user-profile-to-django-admin.html


>
> On 1/5/18, Ketul Suthar  wrote:
> > Can you give me example?
> >
> > On Jan 5, 2018 10:09 PM, "Jani Tiainen"  wrote:
> >
> >> Hi,
> >>
> >> There are numerous ways to achieve what you're asking for, I've been
> >> using
> >> following two:
> >>
> >> You can (and if this a new project, should) create custom user,
> >> regardless
> >> of which one approaches you use.
> >>
> >> 1) For a custom manager add user type field to a custom user model which
> >> says is user a manager or ordinary user. And then add foreign key (or
> >> many
> >> to many if user can have multiple managers) to custom user model to
> self.
> >>
> >> 2)  Have so called "profile", a model with one to one relation to user
> >> model where you put all the same attributes as above.
> >>
> >> Admin can work with both approaches, it's up to you to decide which one
> >> approach suits for you.
> >>
> >> On Fri, Jan 5, 2018 at 6:26 PM, Ketul Suthar 
> wrote:
> >>
> >>> I am beginner to djnago.
> >>>
> >>>
> >>> I want to create app in which admin can create User and Manager and
> >>> manager is assign to user ?
> >>>
> >>> so how can i achieve ? For  that I have to extend user class bacause
> >>> user
> >>> and manager and admin all three can login in system
> >>>
> >>> --
> >>> You received this message because you are subscribed to the Google
> >>> Groups
> >>> "Django users" group.
> >>> To unsubscribe from this group and stop receiving emails from it, send
> >>> an
> >>> email to django-users+unsubscr...@googlegroups.com.
> >>> To post to this group, send email to django-users@googlegroups.com.
> >>> Visit this group at https://groups.google.com/group/django-users.
> >>> To view this discussion on the web visit
> https://groups.google.com/d/ms
> >>> gid/django-users/810439c8-6515-4dc6-808d-643b0f1e38d0%40
> googlegroups.com
> >>>  6515-4dc6-808d-643b0f1e38d0%40googlegroups.com?utm_medium=
> email_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...
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Django users" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> an
> >> email to django-users+unsubscr...@googlegroups.com.
> >> To post to this group, send email to django-users@googlegroups.com.
> >> Visit this group at https://groups.google.com/group/django-users.
> >> To view this discussion on the web visit https://groups.google.com/d/
> >> msgid/django-users/CAHn91oeYGMRN0PcxPHUYtu1k8HheW
> FzwNru5FK%2BmcPZGOkCf8Q%
> >> 40mail.gmail.com
> >>  CAHn91oeYGMRN0PcxPHUYtu1k8HheWFzwNru5FK%2BmcPZGOkCf8Q%
> 40mail.gmail.com?utm_medium=email_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/CANuqdaXN3oFWBPifvfX5ZS-baU6wNVcORp1Jg9dsBp%3Du9Bf0FA%
> 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/CA%2BFDnhK8mQFZPHadTRCV1zd5tqKJLydQ9s5SsUrDXDS3YtESgA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Links to files

2018-01-05 Thread Matemática A3K
On Fri, Jan 5, 2018 at 1:50 PM, Karl Ritchie  wrote:

> Hi I'm very new to Django. I tried searching for this but the answers I
> found aren't very clear. I'm wanting to create links to PDF documents.
> I've created an app called writing with a static folder with PDF files. At
> first I just put an html  link in the template file but it when I ran it it
> said it couldn't find the file.
> I think I have to change the View.py and URL.py in Writing but what do I
> change it to and what do I put in the template file for the link?
>
>
Karl,

"A static file is a static file", it doesn't matter if it is a jpg or a
pdf. You should read
https://docs.djangoproject.com/en/2.0/howto/static-files/ and think that
instead of img tags for jpgs you will use a tags for pdfs

HTH!


>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/dcd1a1fc-3aac-4562-a8c3-159b846a44c0%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/CA%2BFDnh%2Bjz9SSTyivi3DmuY7ZDAbz8rSJbZS7sxocuao%2BZ6F0cQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Trapping underlying exceptions

2018-01-05 Thread Matemática A3K
On Fri, Jan 5, 2018 at 1:45 PM, Stephan Doliov 
wrote:

> Hi,
> I am diving ever deeper into Django and I came upon some behavior that
> frustrated me but perhaps I am just misunderstanding what should happen and
> why.
>
> In writing unit tests for code, I wanted to write one that traps a
> json.decoder.JSONDecodeError by passing in some malformed JSON.
>
> What appears to happen however, is that Django only reports back the very
> last exception that was raised.
>
> In the case of json.decoder.JSONDecodeError, it's initialization raises a
> ValueError here is the code of json.decoder.JSONDecodeError (from my python
> 3.5 install)
>
> class JSONDecodeError(ValueError):
> """Subclass of ValueError with the following additional properties:
>
>
> msg: The unformatted error message
> doc: The JSON document being parsed
> pos: The start index of doc where parsing failed
> lineno: The line corresponding to pos
> colno: The column corresponding to pos
>
>
> """
> # Note that this exception is used from _json
> def __init__(self, msg, doc, pos):
> lineno = doc.count('\n', 0, pos) + 1
> colno = pos - doc.rfind('\n', 0, pos)
> errmsg = '%s: line %d column %d (char %d)' % (msg, lineno, colno,
> pos)
> ValueError.__init__(self, errmsg)
> self.msg = msg
> self.doc = doc
> self.pos = pos
> self.lineno = lineno
> self.colno = colno
>
>
> def __reduce__(self):
> return self.__class__, (self.msg, self.doc, self.pos)
>
>
>
> Once my django parsing code (default django rest framework 3.7.7) steps
> into here, it's own ParseError class sees only the ValueError (which
> redacts the faulty input JSON).
>

This is it, the exception is catch by DRF


>
> Is this a feature? A bug? Something in between?
>
> My desired behavior would be that i could access the JSONDecodeError
> instances doc property to go back and find out exactly which malformed JSON
> was ruining my ability to serve a complete request.
>
> Is there a way I can get Django to make visible the underlying
> JSONDecodeError (that drove a Value Error that django rest framework then
> presents to me wrapped in its ParseError class)?
>
> Clearly, I could change the underlying JSON Decoder code to my liking,
> either by changing it's errmsg or by subclassing (ValueError) it in a way
> to provide more rich information back upstream?  If I run some sample code
> just in python CLI (less django) I get the whole JSONDecodeError exception
> as I desire. So I suspect modding the decoder class is not really what I
> want. But it would be nice if much like a stack trace, I could access
> ParseError instantianted by ValueError instantiated by JSONDecodeError so
> that I could access all the properties of the underlying error
> (JSONDecodeError).  Should I make a feature request? Or is there already a
> toggle I can control somewhere to do this?
>

Refer to the DRF code and see if you can modify it. If you want to make a
feature request, you will have to do it in DRF


>
> Thanks,
> Steve
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/15c7b76c-8dcd-4424-b336-8d0325c3a1e1%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/CA%2BFDnh%2BYRbYtO2OzYatf4r3dN8Ug%3DdRLzGUyz6QfhreoLVfdAg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 2.0.1 admin

2018-01-05 Thread Matemática A3K
On Fri, Jan 5, 2018 at 7:26 PM, Matthew Pava  wrote:

> No.  I even uninstalled Django and reinstalled Django, but the issue
> persists.
>
>
>

Seems like the admin's template tags are not being loaded correctly. Are
you using custom template tags? Did you restart your dev server? after the
upgrade (silly but can be that)?


>
>
> *From:* django-users@googlegroups.com [mailto:django-users@
> googlegroups.com] *On Behalf Of *m1chael
> *Sent:* Friday, January 5, 2018 4:25 PM
> *To:* django-users@googlegroups.com
> *Subject:* Re: Django 2.0.1 admin
>
>
>
> did you ever override your admin templates?
>
>
>
> On Fri, Jan 5, 2018 at 5:20 PM, Matthew Pava  wrote:
>
> Hi everyone,
>
> I am finally able to move to Django 2.0, but I just noticed an error I
> keep getting when attempting to open the admin:
>
>
>
> TemplateSyntaxError at /admin/
>
> Invalid block tag on line 58: 'get_admin_log', expected 'endblock'. Did
> you forget to register or load this tag?
>
>
>
> Does anyone have any ideas?
>
> 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/4dbdb1ab1c37482eb2150fd8f6cd3426%40ISS1.ISS.LOCAL
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAAuoY6PCXSrmZpYgXwHfUMs0rcz_
> g3JFmsexHnL_JOfaWXbzTQ%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/c0ea62a85abb4060ae3e291f0f506384%40ISS1.ISS.LOCAL
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Issue with Python 3.6 and Django 2.0 App Deployment on Shared Hosting

2018-01-05 Thread Matemática A3K
On Mon, Dec 25, 2017 at 7:14 PM, Alok Vaidya  wrote:

> HI All,
>
> I'm a very new into web development as well as very recently started with
> Python 3.6.4 and Django 2.0 and built my first web application
> successfully. Currently I'm in the process of deploying the web-app on a
> shared hosting environment on Bluehost.
>
> I was able to configure both Python and Django latest versions
> successfully on Bluehost server using virstualenv and was able to create my
> test-app ass well on the server directly using SSH client.
>
> Where I'm stuck right now is to make this app work on my domain. I have
> explored everything on google and tried everything possible from my side
> but with no luck in the end. Ever time I try to access my website in my
> local browser, I get the following error message:
>
> 500 Server Error
> A misconfiguration on the server caused a hiccup. Check the server logs,
> fix the problem, then try again.
>
> I understand that it may not be sufficient information for anyone to help
> me with. I'm very new to this whole process of community and forums etc, so
> please let me know in case if you look for any additional info in this
> regard.
>
> I will greatly appreciate any help or pointing me into the right
> direction.
>

In the logs you will find detailed information about the error, you should
start looking at that


>
> Alok.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/d38290f8-dd4e-4038-a958-9fed5b32fa34%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/CA%2BFDnhLB6tOt4HvcyvLF3CnNQQvB%2BLdamiOFDzRN6%2BDjH0EV0A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error following django's documentation 2.0

2018-01-05 Thread Matemática A3K
On Fri, Jan 5, 2018 at 8:32 PM, FernandoJMM 
wrote:

> Hello everyone,
>
> I'm learning django. I am in the official documentation of django link:
>
> *https://docs.djangoproject.com/en/2.0/intro/overview/
> *
>
> After creating the model and doing the migrate I go to the section called 
> *Enjoy
> the free API* to test in the python terminal
>

Did you get to that python terminal by "python manage.py shell" on the base
directory of your project?


> and I get an error when executing the *import*, it says that it can not
> find the module.
>
> *The only difference with the documentation* is that I am executing it
> from a *virtualenv*.
>
> it can be fixed ?
>

I think so :)


>
> Thank you all
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/c9941c85-2a42-439f-8999-856507f5f74d%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/CA%2BFDnhK6FjKY3dgv%3Dv5JnFF68FZawM7j1HWYPCWQA0S1OdL_%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Handling Celery Connection Lost Problem

2018-01-05 Thread Matemática A3K
On Fri, Jan 5, 2018 at 9:01 PM, Jason  wrote:

> To reinforce on what Jani Tianen said, this is not a django or python
> issue, nor really a Celery issue.  What you should research and investigate
> is high availability rabbitmq clusters, if this is such a concern for you.
>
> Indeed, Mukul, you should google first :)


> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/bd85fa9c-1917-45dd-84cd-b86a94993098%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/CA%2BFDnhKYePVwsAraPkWBdC4%3DX0bQBm0wVysZgwp7HR9WS8wGTg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Error following django's documentation 2.0

2018-01-05 Thread FernandoJMM
Hello everyone,

I'm learning django. I am in the official documentation of django link:

*https://docs.djangoproject.com/en/2.0/intro/overview/*

After creating the model and doing the migrate I go to the section called 
*Enjoy 
the free API* to test in the python terminal and I get an error when 
executing the *import*, it says that it can not find the module.

*The only difference with the documentation* is that I am executing it from 
a *virtualenv*.

it can be fixed ?

Thank you all

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


Re: Handling Celery Connection Lost Problem

2018-01-05 Thread Jason
To reinforce on what Jani Tianen said, this is not a django or python 
issue, nor really a Celery issue.  What you should research and investigate 
is high availability rabbitmq clusters, if this is such a concern for you.

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


Re: Using fastcgi, Django 2.0, Python 3.6.4, flup6 (includes debug.log) on a shared server

2018-01-05 Thread coreyjbishop
Please disregard this topic and refer to the following for updates:

https://groups.google.com/forum/#!topic/django-users/EgFNBHEyUY4

Again, my apologies for posting it twice. I felt it would be most suitable 
under a different topic, rather than starting a new topic.

Best wishes,

Corey



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


RE: Django 2.0.1 admin

2018-01-05 Thread Matthew Pava
No.  I even uninstalled Django and reinstalled Django, but the issue persists.


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of m1chael
Sent: Friday, January 5, 2018 4:25 PM
To: django-users@googlegroups.com
Subject: Re: Django 2.0.1 admin

did you ever override your admin templates?

On Fri, Jan 5, 2018 at 5:20 PM, Matthew Pava 
> wrote:
Hi everyone,
I am finally able to move to Django 2.0, but I just noticed an error I keep 
getting when attempting to open the admin:

TemplateSyntaxError at /admin/
Invalid block tag on line 58: 'get_admin_log', expected 'endblock'. Did you 
forget to register or load this tag?

Does anyone have any ideas?
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/4dbdb1ab1c37482eb2150fd8f6cd3426%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com.
To post to this group, send email to 
django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAAuoY6PCXSrmZpYgXwHfUMs0rcz_g3JFmsexHnL_JOfaWXbzTQ%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/c0ea62a85abb4060ae3e291f0f506384%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Re: Django 2.0.1 admin

2018-01-05 Thread m1chael
did you ever override your admin templates?

On Fri, Jan 5, 2018 at 5:20 PM, Matthew Pava  wrote:

> Hi everyone,
>
> I am finally able to move to Django 2.0, but I just noticed an error I
> keep getting when attempting to open the admin:
>
>
>
> TemplateSyntaxError at /admin/
>
> Invalid block tag on line 58: 'get_admin_log', expected 'endblock'. Did
> you forget to register or load this tag?
>
>
>
> Does anyone have any ideas?
>
> 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/4dbdb1ab1c37482eb2150fd8f6cd3426%40ISS1.ISS.LOCAL
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Django 2.0.1 admin

2018-01-05 Thread Matthew Pava
Hi everyone,
I am finally able to move to Django 2.0, but I just noticed an error I keep 
getting when attempting to open the admin:

TemplateSyntaxError at /admin/
Invalid block tag on line 58: 'get_admin_log', expected 'endblock'. Did you 
forget to register or load this tag?

Does anyone have any ideas?
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/4dbdb1ab1c37482eb2150fd8f6cd3426%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Re: How do you check if a template is included into another?

2018-01-05 Thread Julio Biason
Hi Luna,

Why not do something like:

Have a base template that you will use for the basic editing, let's call it
`base_content_edit.html`:

{% extends whatever-you-use-as-base-template %}

{% block editor %}

{% endblock %}


and then, when you need a rich editor, you have a new template, say
`rich_content_edit.html`:

{% extend "base_content_edit" %}

{% block editor %}

{% endblock %}


Django templates are more based on the building on top of previous content
than including bits and pieces (although you can do that with no issues).

On Fri, Jan 5, 2018 at 6:03 PM, Luna Tuna 
wrote:

> Say I have a content editing template with a simple text area and title
> field.   Then I'll need a publish button for it of course.
>
> But if I include this conten editor in a larger template, the position of
> the publish button will go to the bottom of additionally included content,
>
> so I only want to render the publish button in the first template if I
> know that content_edit.hml is not included in a larger template.
>
> How would I accomplish 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/ddb6d351-113d-4ff7-ba12-602a9a12a6a0%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*Julio Biason*, Sofware Engineer
*AZION*  |  Deliver. Accelerate. Protect.
Office: +55 51 3083 8101   |  Mobile: +55 51
*99907 0554*

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


How do you check if a template is included into another?

2018-01-05 Thread Luna Tuna
Say I have a content editing template with a simple text area and title 
field.   Then I'll need a publish button for it of course.

But if I include this conten editor in a larger template, the position of 
the publish button will go to the bottom of additionally included content,

so I only want to render the publish button in the first template if I know 
that content_edit.hml is not included in a larger template.

How would I accomplish 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/ddb6d351-113d-4ff7-ba12-602a9a12a6a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Converting Timezone-Naive Project to Timezone-Aware?

2018-01-05 Thread Jani Tiainen
Hi,

Well first, have a staging database where you can test all your changes
"risk free". It will allow you to do changes and determine best practices
to upgrade your data. Since that is staging system, you can do it really
risk free. Only risk is that you may lose some time but your production
system is not affected at all.

Hopefully you do have QA team or at least good QA procedures to test your
system before you can give a green light for your changes. Unit tests help
in certain parts but they can't really tell that there aren't any bugs.

And there isn't really any shortcuts because only way to discover bugs is
that something bad happens, you write a test to reproduce it and then fix
it - there isn't really any way to tell if you have covered all potential
issues with such a conversion before hand. It is guaranteed that you'll
have some problems that you just happened to missed out. For example when
doing math with dates DST changes may introduce interesting results.

And finally - you need to have a DRP - disaster recovery plan. So if things
go really south you need to be prepared to handle it.

On Fri, Jan 5, 2018 at 8:13 PM, Noemi  wrote:

> Hi folks --
>
> We have an existing project with dozens of DateTimeFields and hundreds of
> millions of database records.  It's an old codebase and timezone-naive; but
> upcoming business needs require us to convert the project to be
> timezone-aware.
>
> Not only is this a big change, but it's a risky one, with tons of
> potential for data corruption and bugs.  Last time we tried to introduce a
> single field recorded as UTC instead of local time, we were discovering and
> squashing subtle related bugs and even exceptions for 6 weeks afterwards
> (hurrah for legacy code).  We've been increasing test coverage gradually
> over time, but we don't have heavy coverage of date/time conversions yet,
> and there are still substantial gaps in coverage overall; we don't have the
> manpower to fix that before we begin this initiative.
>
> Our preferred risk-mitigation approach would be to make the change
> incrementally (a few fields at a time) instead of all at once; but that
> doesn't seem possible, since USE_TZ is a globally-applicable setting.
>
> Has anyone made a change like this before, and can you recommend any
> tactics to de-risk the conversion?
>
> Thanks!
> Noemi
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/ed0ea6fb-17ba-4f46-9122-4c97f463ec6b%40googlegroups.com
> 
> .
> 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...

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


Converting Timezone-Naive Project to Timezone-Aware?

2018-01-05 Thread Noemi
Hi folks --

We have an existing project with dozens of DateTimeFields and hundreds of 
millions of database records.  It's an old codebase and timezone-naive; but 
upcoming business needs require us to convert the project to be 
timezone-aware.  

Not only is this a big change, but it's a risky one, with tons of potential 
for data corruption and bugs.  Last time we tried to introduce a single 
field recorded as UTC instead of local time, we were discovering and 
squashing subtle related bugs and even exceptions for 6 weeks afterwards 
(hurrah for legacy code).  We've been increasing test coverage gradually 
over time, but we don't have heavy coverage of date/time conversions yet, 
and there are still substantial gaps in coverage overall; we don't have the 
manpower to fix that before we begin this initiative. 

Our preferred risk-mitigation approach would be to make the change 
incrementally (a few fields at a time) instead of all at once; but that 
doesn't seem possible, since USE_TZ is a globally-applicable setting. 

Has anyone made a change like this before, and can you recommend any 
tactics to de-risk the conversion?  

Thanks!
Noemi

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


Links to files

2018-01-05 Thread Karl Ritchie
Hi I'm very new to Django. I tried searching for this but the answers I 
found aren't very clear. I'm wanting to create links to PDF documents.  
I've created an app called writing with a static folder with PDF files. At 
first I just put an html  link in the template file but it when I ran it it 
said it couldn't find the file.
I think I have to change the View.py and URL.py in Writing but what do I 
change it to and what do I put in the template file for the link?


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


Trapping underlying exceptions

2018-01-05 Thread Stephan Doliov
Hi,
I am diving ever deeper into Django and I came upon some behavior that 
frustrated me but perhaps I am just misunderstanding what should happen and 
why.

In writing unit tests for code, I wanted to write one that traps a 
json.decoder.JSONDecodeError by passing in some malformed JSON.

What appears to happen however, is that Django only reports back the very 
last exception that was raised.

In the case of json.decoder.JSONDecodeError, it's initialization raises a 
ValueError here is the code of json.decoder.JSONDecodeError (from my python 
3.5 install)

class JSONDecodeError(ValueError):
"""Subclass of ValueError with the following additional properties:


msg: The unformatted error message 
doc: The JSON document being parsed
pos: The start index of doc where parsing failed
lineno: The line corresponding to pos
colno: The column corresponding to pos


"""
# Note that this exception is used from _json
def __init__(self, msg, doc, pos):
lineno = doc.count('\n', 0, pos) + 1
colno = pos - doc.rfind('\n', 0, pos) 
errmsg = '%s: line %d column %d (char %d)' % (msg, lineno, colno, 
pos)
ValueError.__init__(self, errmsg) 
self.msg = msg
self.doc = doc
self.pos = pos
self.lineno = lineno
self.colno = colno 


def __reduce__(self):
return self.__class__, (self.msg, self.doc, self.pos)



Once my django parsing code (default django rest framework 3.7.7) steps 
into here, it's own ParseError class sees only the ValueError (which 
redacts the faulty input JSON).

Is this a feature? A bug? Something in between?

My desired behavior would be that i could access the JSONDecodeError 
instances doc property to go back and find out exactly which malformed JSON 
was ruining my ability to serve a complete request.

Is there a way I can get Django to make visible the underlying 
JSONDecodeError (that drove a Value Error that django rest framework then 
presents to me wrapped in its ParseError class)? 

Clearly, I could change the underlying JSON Decoder code to my liking, 
either by changing it's errmsg or by subclassing (ValueError) it in a way 
to provide more rich information back upstream?  If I run some sample code 
just in python CLI (less django) I get the whole JSONDecodeError exception 
as I desire. So I suspect modding the decoder class is not really what I 
want. But it would be nice if much like a stack trace, I could access 
ParseError instantianted by ValueError instantiated by JSONDecodeError so 
that I could access all the properties of the underlying error 
(JSONDecodeError).  Should I make a feature request? Or is there already a 
toggle I can control somewhere to do this?

Thanks,
Steve 

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


Re: Django User module extend

2018-01-05 Thread Ketul Suthar
class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
is_manager  = models.BooleanField(default=False)
manager = models.ForeignKey(User,related_name='user_manager',on_delete=
models.CASCADE, blank=True,null=True)
def __str__(self):  # __unicode__ for Python 2
return self.user.username

Is it right ? how can i create form ?

On 1/5/18, Ketul Suthar  wrote:
> Can you give me example?
>
> On Jan 5, 2018 10:09 PM, "Jani Tiainen"  wrote:
>
>> Hi,
>>
>> There are numerous ways to achieve what you're asking for, I've been
>> using
>> following two:
>>
>> You can (and if this a new project, should) create custom user,
>> regardless
>> of which one approaches you use.
>>
>> 1) For a custom manager add user type field to a custom user model which
>> says is user a manager or ordinary user. And then add foreign key (or
>> many
>> to many if user can have multiple managers) to custom user model to self.
>>
>> 2)  Have so called "profile", a model with one to one relation to user
>> model where you put all the same attributes as above.
>>
>> Admin can work with both approaches, it's up to you to decide which one
>> approach suits for you.
>>
>> On Fri, Jan 5, 2018 at 6:26 PM, Ketul Suthar  wrote:
>>
>>> I am beginner to djnago.
>>>
>>>
>>> I want to create app in which admin can create User and Manager and
>>> manager is assign to user ?
>>>
>>> so how can i achieve ? For  that I have to extend user class bacause
>>> user
>>> and manager and admin all three can login in system
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups
>>> "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an
>>> email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/django-users/810439c8-6515-4dc6-808d-643b0f1e38d0%40googlegroups.com
>>> 
>>> .
>>> 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...
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/
>> msgid/django-users/CAHn91oeYGMRN0PcxPHUYtu1k8HheWFzwNru5FK%2BmcPZGOkCf8Q%
>> 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/CANuqdaXN3oFWBPifvfX5ZS-baU6wNVcORp1Jg9dsBp%3Du9Bf0FA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django User module extend

2018-01-05 Thread Ketul Suthar
Can you give me example?

On Jan 5, 2018 10:09 PM, "Jani Tiainen"  wrote:

> Hi,
>
> There are numerous ways to achieve what you're asking for, I've been using
> following two:
>
> You can (and if this a new project, should) create custom user, regardless
> of which one approaches you use.
>
> 1) For a custom manager add user type field to a custom user model which
> says is user a manager or ordinary user. And then add foreign key (or many
> to many if user can have multiple managers) to custom user model to self.
>
> 2)  Have so called "profile", a model with one to one relation to user
> model where you put all the same attributes as above.
>
> Admin can work with both approaches, it's up to you to decide which one
> approach suits for you.
>
> On Fri, Jan 5, 2018 at 6:26 PM, Ketul Suthar  wrote:
>
>> I am beginner to djnago.
>>
>>
>> I want to create app in which admin can create User and Manager and
>> manager is assign to user ?
>>
>> so how can i achieve ? For  that I have to extend user class bacause user
>> and manager and admin all three can login in system
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/810439c8-6515-4dc6-808d-643b0f1e38d0%40googlegroups.com
>> 
>> .
>> 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...
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAHn91oeYGMRN0PcxPHUYtu1k8HheWFzwNru5FK%2BmcPZGOkCf8Q%
> 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/CANuqdaWeS_evBy16CdnOMyhVMLhp_3aByhq8VCNZv67YJfGtrA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django User module extend

2018-01-05 Thread Jani Tiainen
Hi,

There are numerous ways to achieve what you're asking for, I've been using
following two:

You can (and if this a new project, should) create custom user, regardless
of which one approaches you use.

1) For a custom manager add user type field to a custom user model which
says is user a manager or ordinary user. And then add foreign key (or many
to many if user can have multiple managers) to custom user model to self.

2)  Have so called "profile", a model with one to one relation to user
model where you put all the same attributes as above.

Admin can work with both approaches, it's up to you to decide which one
approach suits for you.

On Fri, Jan 5, 2018 at 6:26 PM, Ketul Suthar  wrote:

> I am beginner to djnago.
>
>
> I want to create app in which admin can create User and Manager and
> manager is assign to user ?
>
> so how can i achieve ? For  that I have to extend user class bacause user
> and manager and admin all three can login in system
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/810439c8-6515-4dc6-808d-643b0f1e38d0%40googlegroups.com
> 
> .
> 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...

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


Django User module extend

2018-01-05 Thread Ketul Suthar
I am beginner to djnago.


I want to create app in which admin can create User and Manager and manager 
is assign to user ?

so how can i achieve ? For  that I have to extend user class bacause user 
and manager and admin all three can login in system

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


Re: Failing to configure Django correctlly (conflict in settings between models.py and manage.py usage).

2018-01-05 Thread Andréas Kühne
Yeah, OK, didn't know about that ability - have never used it :-)

Regards,

Andréas

2018-01-05 16:21 GMT+01:00 Jani Tiainen :

> Hi.
>
> That is a bit misleading information.
>
> It is completely supported using models (and other Django stuff) from
> standalone scripts wihtout using manage.py
>
> It's even documented at https://docs.djangoproject.
> com/en/2.0/topics/settings/
>
> And specially part:
> https://docs.djangoproject.com/en/2.0/topics/settings/#
> calling-django-setup-is-required-for-standalone-django-usage
>
> And you don't even need settings.py file - that is purely optional as well.
>
>
> On Fri, Jan 5, 2018 at 5:09 PM, Andréas Kühne 
> wrote:
>
>> Ah,
>>
>> OK.
>>
>> Now it is a bit more clear.
>>
>> What you are doing is not supported by django. You don't use the django
>> models OUTSIDE of the django project. That is not a supported usecase. You
>> can probably set it up, so that you CAN do that, but I would not recommend
>> it.
>>
>> What are you trying to accomplish by reading the models OUTSIDE of the
>> django project?
>>
>> Regards,
>>
>> Andréas
>>
>> 2018-01-05 15:50 GMT+01:00 alex Tarasiuk :
>>
>>> Here is what I've done so far (it is a new project and I did followed
>>> the tutorial until it didn't worked for me any more).
>>>
>>> Here are the steps of how I created the project:
>>>
>>> 1. django-admin startproject MY_DGANGO
>>>
>>> 2.  python manage.py startapp my_django
>>>
>>> 3.  edited the models.py
>>>
>>> 4. python manage.py makemigrations my_django
>>>
>>> 5. python manage.py sqlmigrate my_django 0001
>>>
>>> 6.  python manage.py migrate
>>>
>>>
>>>
>>> Now after the tables in the DB was created, I want to use it
>>> (add/remove/update date) from my project.
>>>
>>>
>>> 7.  So from my project I’m importing models so I’ll be able to use the
>>> classes I’ve created to extract and add information to/from the DB.
>>>
>>> For example:
>>>
>>> · In models.py:
>>>
>>> Class Person(models.Model):
>>>
>>> first_name = models.CharField(max_length=100, null=False)
>>>
>>> last_name = models.CharField(max_length=100, null=False)
>>>
>>> phone_number = models.CharField(max_length=100, null=False)
>>>
>>> …
>>>
>>>
>>>
>>> · In some file in my project:
>>>
>>> from MY_DGANGO.my_django import models
>>>
>>> ….
>>>
>>> def add_person(first_name, last_name, phone_number):
>>>
>>> …
>>>
>>> person = models.Person(first_name= first_name, last_name= last_name,
>>>
>>> phone_number= phone_number)
>>>
>>> person.save()
>>>
>>> …
>>>
>>> …
>>>
>>> …
>>>
>>> def get_person_by_phone_number(phone_number):
>>>
>>> …
>>>
>>> person = models.Person.objects.filter(phone_number= phone_number)
>>>
>>> …
>>>
>>>
>>> P.S. I'm runnig it without starting any Django server.
>>>
>>>
>>>
>>> On Friday, January 5, 2018 at 4:29:11 PM UTC+2, Andréas Kühne wrote:

 Ok,

 So are you in the folder where the manage.py file resides when you run
 your commands? You have to be in that directory when running manage.py
 commands.

 Also - as long as you haven't done too much already - I would recommend
 starting fresh and looking into the tutorials in the django docs pages on
 how to start a project. See https://docs.djangoproject
 .com/en/2.0/intro/tutorial01/ or https://tutorial.djangogirls.org/en/.

 The settings you have changed there are very strange (as Ramiro pointed
 out) and should definitely not be required. Have you set the 
 DEFAULT_INDEX_TABLESPACE
 setting anywhere? Because that is also something that shouldn't be
 required

 Med vänliga hälsningar,

 Andréas

 2018-01-05 15:17 GMT+01:00 alex Tarasiuk :

> Hi Andréas,
> Thanks for your response.
>
> When I'm removing the lines you've talked about I'm having the
> following error:
>
> django.core.exceptions.ImproperlyConfigured: Requested setting
> DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either
> define the environment variable DJANGO_SETTINGS_MODULE or call
> settings.configure() before accessing settings.
>
> This is why I've added those settings in the first place.
>
>
>
> On Friday, January 5, 2018 at 3:59:31 PM UTC+2, Andréas Kühne wrote:
>>
>> Hi Alex,
>>
>> You shouldn't have anything regarding the settings in models.py.
>>
>> Remove:
>> import os
>> import django
>> os.environ["DJANGO_SETTINGS_MODULE"] = "MY_DJANGO.MY_DJANGO.settings"
>> django.setup()
>>
>> from your models.py file. You should never have any settings in the
>> models.py file at all. Also, you should never reference the django 
>> project
>> folder (your first MY_DJANGO here) in the project. It always has that
>> folder anyway.
>>
>> In 

Re: Failing to configure Django correctlly (conflict in settings between models.py and manage.py usage).

2018-01-05 Thread Jani Tiainen
Hi,

As I did few posts already, you can do it few ways.

I would recommend using custom management command. It will wrap up things
nicely under Django hood, you don't need to figure out how to apply
settings and such which allows you just need to concentrate to make your
code to work.

You can create standalone script as well, it just requires a bit more work
since you would be responsible of making sure that you have setup Django
properly.


On Fri, Jan 5, 2018 at 5:17 PM, alex Tarasiuk  wrote:

> The only thing I need from Django (at this point) is to have the ability
> to communicate with my DB.
> (person = models.Person.objects.filter(phone_number= phone_number) from
> my previous example)
> I'm planning to use the admin page and I might add a GUI in some point.
>
> Regards,
> Alex
>
> On Friday, January 5, 2018 at 5:10:20 PM UTC+2, Andréas Kühne wrote:
>>
>> Ah,
>>
>> OK.
>>
>> Now it is a bit more clear.
>>
>> What you are doing is not supported by django. You don't use the django
>> models OUTSIDE of the django project. That is not a supported usecase. You
>> can probably set it up, so that you CAN do that, but I would not recommend
>> it.
>>
>> What are you trying to accomplish by reading the models OUTSIDE of the
>> django project?
>>
>> Regards,
>>
>> Andréas
>>
>> 2018-01-05 15:50 GMT+01:00 alex Tarasiuk :
>>
>>> Here is what I've done so far (it is a new project and I did followed
>>> the tutorial until it didn't worked for me any more).
>>>
>>> Here are the steps of how I created the project:
>>>
>>> 1. django-admin startproject MY_DGANGO
>>>
>>> 2.  python manage.py startapp my_django
>>>
>>> 3.  edited the models.py
>>>
>>> 4. python manage.py makemigrations my_django
>>>
>>> 5. python manage.py sqlmigrate my_django 0001
>>>
>>> 6.  python manage.py migrate
>>>
>>>
>>>
>>> Now after the tables in the DB was created, I want to use it
>>> (add/remove/update date) from my project.
>>>
>>>
>>> 7.  So from my project I’m importing models so I’ll be able to use the
>>> classes I’ve created to extract and add information to/from the DB.
>>>
>>> For example:
>>>
>>> · In models.py:
>>>
>>> Class Person(models.Model):
>>>
>>> first_name = models.CharField(max_length=100, null=False)
>>>
>>> last_name = models.CharField(max_length=100, null=False)
>>>
>>> phone_number = models.CharField(max_length=100, null=False)
>>>
>>> …
>>>
>>>
>>>
>>> · In some file in my project:
>>>
>>> from MY_DGANGO.my_django import models
>>>
>>> ….
>>>
>>> def add_person(first_name, last_name, phone_number):
>>>
>>> …
>>>
>>> person = models.Person(first_name= first_name, last_name= last_name,
>>>
>>> phone_number= phone_number)
>>>
>>> person.save()
>>>
>>> …
>>>
>>> …
>>>
>>> …
>>>
>>> def get_person_by_phone_number(phone_number):
>>>
>>> …
>>>
>>> person = models.Person.objects.filter(phone_number= phone_number)
>>>
>>> …
>>>
>>>
>>> P.S. I'm runnig it without starting any Django server.
>>>
>>>
>>>
>>> On Friday, January 5, 2018 at 4:29:11 PM UTC+2, Andréas Kühne wrote:

 Ok,

 So are you in the folder where the manage.py file resides when you run
 your commands? You have to be in that directory when running manage.py
 commands.

 Also - as long as you haven't done too much already - I would recommend
 starting fresh and looking into the tutorials in the django docs pages on
 how to start a project. See https://docs.djangoproject
 .com/en/2.0/intro/tutorial01/ or https://tutorial.djangogirls.org/en/.

 The settings you have changed there are very strange (as Ramiro pointed
 out) and should definitely not be required. Have you set the 
 DEFAULT_INDEX_TABLESPACE
 setting anywhere? Because that is also something that shouldn't be
 required

 Med vänliga hälsningar,

 Andréas

 2018-01-05 15:17 GMT+01:00 alex Tarasiuk :

> Hi Andréas,
> Thanks for your response.
>
> When I'm removing the lines you've talked about I'm having the
> following error:
>
> django.core.exceptions.ImproperlyConfigured: Requested setting
> DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either
> define the environment variable DJANGO_SETTINGS_MODULE or call
> settings.configure() before accessing settings.
>
> This is why I've added those settings in the first place.
>
>
>
> On Friday, January 5, 2018 at 3:59:31 PM UTC+2, Andréas Kühne wrote:
>>
>> Hi Alex,
>>
>> You shouldn't have anything regarding the settings in models.py.
>>
>> Remove:
>> import os
>> import django
>> os.environ["DJANGO_SETTINGS_MODULE"] = "MY_DJANGO.MY_DJANGO.settings"
>> django.setup()
>>
>> from your models.py file. You should never have any settings in the
>> models.py file at all. 

Re: Failing to configure Django correctlly (conflict in settings between models.py and manage.py usage).

2018-01-05 Thread Jani Tiainen
Hi.

That is a bit misleading information.

It is completely supported using models (and other Django stuff) from
standalone scripts wihtout using manage.py

It's even documented at
https://docs.djangoproject.com/en/2.0/topics/settings/

And specially part:
https://docs.djangoproject.com/en/2.0/topics/settings/#calling-django-setup-is-required-for-standalone-django-usage

And you don't even need settings.py file - that is purely optional as well.


On Fri, Jan 5, 2018 at 5:09 PM, Andréas Kühne 
wrote:

> Ah,
>
> OK.
>
> Now it is a bit more clear.
>
> What you are doing is not supported by django. You don't use the django
> models OUTSIDE of the django project. That is not a supported usecase. You
> can probably set it up, so that you CAN do that, but I would not recommend
> it.
>
> What are you trying to accomplish by reading the models OUTSIDE of the
> django project?
>
> Regards,
>
> Andréas
>
> 2018-01-05 15:50 GMT+01:00 alex Tarasiuk :
>
>> Here is what I've done so far (it is a new project and I did followed the
>> tutorial until it didn't worked for me any more).
>>
>> Here are the steps of how I created the project:
>>
>> 1. django-admin startproject MY_DGANGO
>>
>> 2.  python manage.py startapp my_django
>>
>> 3.  edited the models.py
>>
>> 4. python manage.py makemigrations my_django
>>
>> 5. python manage.py sqlmigrate my_django 0001
>>
>> 6.  python manage.py migrate
>>
>>
>>
>> Now after the tables in the DB was created, I want to use it
>> (add/remove/update date) from my project.
>>
>>
>> 7.  So from my project I’m importing models so I’ll be able to use the
>> classes I’ve created to extract and add information to/from the DB.
>>
>> For example:
>>
>> · In models.py:
>>
>> Class Person(models.Model):
>>
>> first_name = models.CharField(max_length=100, null=False)
>>
>> last_name = models.CharField(max_length=100, null=False)
>>
>> phone_number = models.CharField(max_length=100, null=False)
>>
>> …
>>
>>
>>
>> · In some file in my project:
>>
>> from MY_DGANGO.my_django import models
>>
>> ….
>>
>> def add_person(first_name, last_name, phone_number):
>>
>> …
>>
>> person = models.Person(first_name= first_name, last_name= last_name,
>>
>> phone_number= phone_number)
>>
>> person.save()
>>
>> …
>>
>> …
>>
>> …
>>
>> def get_person_by_phone_number(phone_number):
>>
>> …
>>
>> person = models.Person.objects.filter(phone_number= phone_number)
>>
>> …
>>
>>
>> P.S. I'm runnig it without starting any Django server.
>>
>>
>>
>> On Friday, January 5, 2018 at 4:29:11 PM UTC+2, Andréas Kühne wrote:
>>>
>>> Ok,
>>>
>>> So are you in the folder where the manage.py file resides when you run
>>> your commands? You have to be in that directory when running manage.py
>>> commands.
>>>
>>> Also - as long as you haven't done too much already - I would recommend
>>> starting fresh and looking into the tutorials in the django docs pages on
>>> how to start a project. See https://docs.djangoproject
>>> .com/en/2.0/intro/tutorial01/ or https://tutorial.djangogirls.org/en/.
>>>
>>> The settings you have changed there are very strange (as Ramiro pointed
>>> out) and should definitely not be required. Have you set the 
>>> DEFAULT_INDEX_TABLESPACE
>>> setting anywhere? Because that is also something that shouldn't be
>>> required
>>>
>>> Med vänliga hälsningar,
>>>
>>> Andréas
>>>
>>> 2018-01-05 15:17 GMT+01:00 alex Tarasiuk :
>>>
 Hi Andréas,
 Thanks for your response.

 When I'm removing the lines you've talked about I'm having the
 following error:

 django.core.exceptions.ImproperlyConfigured: Requested setting
 DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either
 define the environment variable DJANGO_SETTINGS_MODULE or call
 settings.configure() before accessing settings.

 This is why I've added those settings in the first place.



 On Friday, January 5, 2018 at 3:59:31 PM UTC+2, Andréas Kühne wrote:
>
> Hi Alex,
>
> You shouldn't have anything regarding the settings in models.py.
>
> Remove:
> import os
> import django
> os.environ["DJANGO_SETTINGS_MODULE"] = "MY_DJANGO.MY_DJANGO.settings"
> django.setup()
>
> from your models.py file. You should never have any settings in the
> models.py file at all. Also, you should never reference the django project
> folder (your first MY_DJANGO here) in the project. It always has that
> folder anyway.
>
> In settings.py, your INSTALLED_APPS should look like this:
>
> INSTALLED_APPS = [
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'django.contrib.sites',

Re: Failing to configure Django correctlly (conflict in settings between models.py and manage.py usage).

2018-01-05 Thread alex Tarasiuk
The only thing I need from Django (at this point) is to have the ability to 
communicate with my DB.
(person = models.Person.objects.filter(phone_number= phone_number) from my 
previous example)
I'm planning to use the admin page and I might add a GUI in some point.

Regards,
Alex

On Friday, January 5, 2018 at 5:10:20 PM UTC+2, Andréas Kühne wrote:
>
> Ah, 
>
> OK.
>
> Now it is a bit more clear. 
>
> What you are doing is not supported by django. You don't use the django 
> models OUTSIDE of the django project. That is not a supported usecase. You 
> can probably set it up, so that you CAN do that, but I would not recommend 
> it.
>
> What are you trying to accomplish by reading the models OUTSIDE of the 
> django project?
>
> Regards,
>
> Andréas
>
> 2018-01-05 15:50 GMT+01:00 alex Tarasiuk 
> :
>
>> Here is what I've done so far (it is a new project and I did followed the 
>> tutorial until it didn't worked for me any more).
>>
>> Here are the steps of how I created the project:
>>
>> 1. django-admin startproject MY_DGANGO
>>
>> 2.  python manage.py startapp my_django
>>
>> 3.  edited the models.py
>>
>> 4. python manage.py makemigrations my_django
>>
>> 5. python manage.py sqlmigrate my_django 0001
>>
>> 6.  python manage.py migrate
>>
>>  
>>
>> Now after the tables in the DB was created, I want to use it 
>> (add/remove/update date) from my project.
>>
>>
>> 7.  So from my project I’m importing models so I’ll be able to use the 
>> classes I’ve created to extract and add information to/from the DB.
>>
>> For example:
>>
>> · In models.py:
>>
>> Class Person(models.Model):
>>
>> first_name = models.CharField(max_length=100, null=False)
>>
>> last_name = models.CharField(max_length=100, null=False)
>>
>> phone_number = models.CharField(max_length=100, null=False)
>>
>> …
>>
>>  
>>
>> · In some file in my project:
>>
>> from MY_DGANGO.my_django import models
>>
>> ….
>>
>> def add_person(first_name, last_name, phone_number):
>>
>> …
>>
>> person = models.Person(first_name= first_name, last_name= last_name, 
>>
>> phone_number= phone_number)
>>
>> person.save()
>>
>> …
>>
>> …
>>
>> …
>>
>> def get_person_by_phone_number(phone_number):
>>
>> …
>>
>> person = models.Person.objects.filter(phone_number= phone_number)
>>
>> …
>>
>>
>> P.S. I'm runnig it without starting any Django server.
>>
>>
>>
>> On Friday, January 5, 2018 at 4:29:11 PM UTC+2, Andréas Kühne wrote:
>>>
>>> Ok,
>>>
>>> So are you in the folder where the manage.py file resides when you run 
>>> your commands? You have to be in that directory when running manage.py 
>>> commands.
>>>
>>> Also - as long as you haven't done too much already - I would recommend 
>>> starting fresh and looking into the tutorials in the django docs pages on 
>>> how to start a project. See 
>>> https://docs.djangoproject.com/en/2.0/intro/tutorial01/ or 
>>> https://tutorial.djangogirls.org/en/.
>>>
>>> The settings you have changed there are very strange (as Ramiro pointed 
>>> out) and should definitely not be required. Have you set the 
>>> DEFAULT_INDEX_TABLESPACE 
>>> setting anywhere? Because that is also something that shouldn't be 
>>> required
>>>
>>> Med vänliga hälsningar,
>>>
>>> Andréas
>>>
>>> 2018-01-05 15:17 GMT+01:00 alex Tarasiuk :
>>>
 Hi Andréas,
 Thanks for your response.

 When I'm removing the lines you've talked about I'm having the 
 following error:

 django.core.exceptions.ImproperlyConfigured: Requested setting 
 DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either 
 define the environment variable DJANGO_SETTINGS_MODULE or call 
 settings.configure() before accessing settings.

 This is why I've added those settings in the first place.



 On Friday, January 5, 2018 at 3:59:31 PM UTC+2, Andréas Kühne wrote:
>
> Hi Alex,
>
> You shouldn't have anything regarding the settings in models.py.
>
> Remove:
> import os
> import django
> os.environ["DJANGO_SETTINGS_MODULE"] = "MY_DJANGO.MY_DJANGO.settings"
> django.setup()
>
> from your models.py file. You should never have any settings in the 
> models.py file at all. Also, you should never reference the django 
> project 
> folder (your first MY_DJANGO here) in the project. It always has that 
> folder anyway.
>
> In settings.py, your INSTALLED_APPS should look like this:
>
> INSTALLED_APPS = [
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'django.contrib.sites',
> 'django.contrib.admindocs',
>
> 'my_django',
>
> ]
>
>
> Everything should then work as expected.

Re: How to make a place where you could type in data(number)?

2018-01-05 Thread Jani Tiainen
Hi,

You definitely can use Django for that. If you want to learn how to do that
you can start by doing Django tutorial [1] first to get hang of components
and how things tie together in Django.

If you feel that official tutorial is too packed, Django Girls do have very
in depth and excellent tutorial [2].

[1] https://docs.djangoproject.com/en/2.0/intro/
[2] https://tutorial.djangogirls.org/en/

On Fri, Jan 5, 2018 at 1:41 AM, June Kim  wrote:

> I'm looking for a way to set up a place(square box) where you could input
> data(number) on a website. and those data would be saved in somewhere else
> as an excel sheet (.csv)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/f177be88-4911-4e9d-ac8e-66565aff3d32%40googlegroups.com
> 
> .
> 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...

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


Re: Failing to configure Django correctlly (conflict in settings between models.py and manage.py usage).

2018-01-05 Thread Andréas Kühne
Ah,

OK.

Now it is a bit more clear.

What you are doing is not supported by django. You don't use the django
models OUTSIDE of the django project. That is not a supported usecase. You
can probably set it up, so that you CAN do that, but I would not recommend
it.

What are you trying to accomplish by reading the models OUTSIDE of the
django project?

Regards,

Andréas

2018-01-05 15:50 GMT+01:00 alex Tarasiuk :

> Here is what I've done so far (it is a new project and I did followed the
> tutorial until it didn't worked for me any more).
>
> Here are the steps of how I created the project:
>
> 1. django-admin startproject MY_DGANGO
>
> 2.  python manage.py startapp my_django
>
> 3.  edited the models.py
>
> 4. python manage.py makemigrations my_django
>
> 5. python manage.py sqlmigrate my_django 0001
>
> 6.  python manage.py migrate
>
>
>
> Now after the tables in the DB was created, I want to use it
> (add/remove/update date) from my project.
>
>
> 7.  So from my project I’m importing models so I’ll be able to use the
> classes I’ve created to extract and add information to/from the DB.
>
> For example:
>
> · In models.py:
>
> Class Person(models.Model):
>
> first_name = models.CharField(max_length=100, null=False)
>
> last_name = models.CharField(max_length=100, null=False)
>
> phone_number = models.CharField(max_length=100, null=False)
>
> …
>
>
>
> · In some file in my project:
>
> from MY_DGANGO.my_django import models
>
> ….
>
> def add_person(first_name, last_name, phone_number):
>
> …
>
> person = models.Person(first_name= first_name, last_name= last_name,
>
> phone_number= phone_number)
>
> person.save()
>
> …
>
> …
>
> …
>
> def get_person_by_phone_number(phone_number):
>
> …
>
> person = models.Person.objects.filter(phone_number= phone_number)
>
> …
>
>
> P.S. I'm runnig it without starting any Django server.
>
>
>
> On Friday, January 5, 2018 at 4:29:11 PM UTC+2, Andréas Kühne wrote:
>>
>> Ok,
>>
>> So are you in the folder where the manage.py file resides when you run
>> your commands? You have to be in that directory when running manage.py
>> commands.
>>
>> Also - as long as you haven't done too much already - I would recommend
>> starting fresh and looking into the tutorials in the django docs pages on
>> how to start a project. See https://docs.djangoproject
>> .com/en/2.0/intro/tutorial01/ or https://tutorial.djangogirls.org/en/.
>>
>> The settings you have changed there are very strange (as Ramiro pointed
>> out) and should definitely not be required. Have you set the 
>> DEFAULT_INDEX_TABLESPACE
>> setting anywhere? Because that is also something that shouldn't be
>> required
>>
>> Med vänliga hälsningar,
>>
>> Andréas
>>
>> 2018-01-05 15:17 GMT+01:00 alex Tarasiuk :
>>
>>> Hi Andréas,
>>> Thanks for your response.
>>>
>>> When I'm removing the lines you've talked about I'm having the following
>>> error:
>>>
>>> django.core.exceptions.ImproperlyConfigured: Requested setting
>>> DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either
>>> define the environment variable DJANGO_SETTINGS_MODULE or call
>>> settings.configure() before accessing settings.
>>>
>>> This is why I've added those settings in the first place.
>>>
>>>
>>>
>>> On Friday, January 5, 2018 at 3:59:31 PM UTC+2, Andréas Kühne wrote:

 Hi Alex,

 You shouldn't have anything regarding the settings in models.py.

 Remove:
 import os
 import django
 os.environ["DJANGO_SETTINGS_MODULE"] = "MY_DJANGO.MY_DJANGO.settings"
 django.setup()

 from your models.py file. You should never have any settings in the
 models.py file at all. Also, you should never reference the django project
 folder (your first MY_DJANGO here) in the project. It always has that
 folder anyway.

 In settings.py, your INSTALLED_APPS should look like this:

 INSTALLED_APPS = [
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'django.contrib.admindocs',

 'my_django',

 ]


 Everything should then work as expected.

 Regards,

 Andréas

 2018-01-05 13:07 GMT+01:00 alex Tarasiuk :

> Hi, I'm new to Django and having some trouble to configure it.
> I'm using Django 1.11.9 (1.11.5 at first but then upgraded with hopes
> it will solve the issue) and Python 2.7.12 from virtualenv.
>
> Here is my project structure (Please pay attention to upper/lower
> case letters - it is intentionally):
>
> :
>
> module 1
>
> module 2
>
> ...
>
> ...
>
> MY_DJANGO:
>
> MY_DJANGO:

Re: Failing to configure Django correctlly (conflict in settings between models.py and manage.py usage).

2018-01-05 Thread Jani Tiainen
Hi.

You probably want to create Django management command to ease up all
settings and such.

For more information see
https://docs.djangoproject.com/en/2.0/howto/custom-management-commands/


Ei
viruksia. www.avast.com

<#m_-4763703284320586849_m_6545855290324970776_m_6210634856925195094_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Fri, Jan 5, 2018 at 4:50 PM, alex Tarasiuk  wrote:

> Here is what I've done so far (it is a new project and I did followed the
> tutorial until it didn't worked for me any more).
>
> Here are the steps of how I created the project:
>
> 1. django-admin startproject MY_DGANGO
>
> 2.  python manage.py startapp my_django
>
> 3.  edited the models.py
>
> 4. python manage.py makemigrations my_django
>
> 5. python manage.py sqlmigrate my_django 0001
>
> 6.  python manage.py migrate
>
>
>
> Now after the tables in the DB was created, I want to use it
> (add/remove/update date) from my project.
>
>
> 7.  So from my project I’m importing models so I’ll be able to use the
> classes I’ve created to extract and add information to/from the DB.
>
> For example:
>
> · In models.py:
>
> Class Person(models.Model):
>
> first_name = models.CharField(max_length=100, null=False)
>
> last_name = models.CharField(max_length=100, null=False)
>
> phone_number = models.CharField(max_length=100, null=False)
>
> …
>
>
>
> · In some file in my project:
>
> from MY_DGANGO.my_django import models
>
> ….
>
> def add_person(first_name, last_name, phone_number):
>
> …
>
> person = models.Person(first_name= first_name, last_name= last_name,
>
> phone_number= phone_number)
>
> person.save()
>
> …
>
> …
>
> …
>
> def get_person_by_phone_number(phone_number):
>
> …
>
> person = models.Person.objects.filter(phone_number= phone_number)
>
> …
>
>
> P.S. I'm runnig it without starting any Django server.
>
>
>
> On Friday, January 5, 2018 at 4:29:11 PM UTC+2, Andréas Kühne wrote:
>>
>> Ok,
>>
>> So are you in the folder where the manage.py file resides when you run
>> your commands? You have to be in that directory when running manage.py
>> commands.
>>
>> Also - as long as you haven't done too much already - I would recommend
>> starting fresh and looking into the tutorials in the django docs pages on
>> how to start a project. See https://docs.djangoproject
>> .com/en/2.0/intro/tutorial01/ or https://tutorial.djangogirls.org/en/.
>>
>> The settings you have changed there are very strange (as Ramiro pointed
>> out) and should definitely not be required. Have you set the 
>> DEFAULT_INDEX_TABLESPACE
>> setting anywhere? Because that is also something that shouldn't be
>> required
>>
>> Med vänliga hälsningar,
>>
>> Andréas
>>
>> 2018-01-05 15:17 GMT+01:00 alex Tarasiuk :
>>
>>> Hi Andréas,
>>> Thanks for your response.
>>>
>>> When I'm removing the lines you've talked about I'm having the following
>>> error:
>>>
>>> django.core.exceptions.ImproperlyConfigured: Requested setting
>>> DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either
>>> define the environment variable DJANGO_SETTINGS_MODULE or call
>>> settings.configure() before accessing settings.
>>>
>>> This is why I've added those settings in the first place.
>>>
>>>
>>>
>>> On Friday, January 5, 2018 at 3:59:31 PM UTC+2, Andréas Kühne wrote:

 Hi Alex,

 You shouldn't have anything regarding the settings in models.py.

 Remove:
 import os
 import django
 os.environ["DJANGO_SETTINGS_MODULE"] = "MY_DJANGO.MY_DJANGO.settings"
 django.setup()

 from your models.py file. You should never have any settings in the
 models.py file at all. Also, you should never reference the django project
 folder (your first MY_DJANGO here) in the project. It always has that
 folder anyway.

 In settings.py, your INSTALLED_APPS should look like this:

 INSTALLED_APPS = [
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'django.contrib.admindocs',

 'my_django',

 ]


 Everything should then work as expected.

 Regards,

 Andréas

 2018-01-05 13:07 GMT+01:00 alex Tarasiuk :

> Hi, I'm new to Django and having some trouble to configure it.
> I'm using Django 1.11.9 (1.11.5 at first but then upgraded with hopes
> it will solve the issue) and Python 2.7.12 from virtualenv.
>
> Here is my project structure (Please pay attention to upper/lower
> case letters - 

Re: Failing to configure Django correctlly (conflict in settings between models.py and manage.py usage).

2018-01-05 Thread alex Tarasiuk
Here is what I've done so far (it is a new project and I did followed the 
tutorial until it didn't worked for me any more).

Here are the steps of how I created the project:

1. django-admin startproject MY_DGANGO

2.  python manage.py startapp my_django

3.  edited the models.py

4. python manage.py makemigrations my_django

5. python manage.py sqlmigrate my_django 0001

6.  python manage.py migrate

 

Now after the tables in the DB was created, I want to use it 
(add/remove/update date) from my project.


7.  So from my project I’m importing models so I’ll be able to use the 
classes I’ve created to extract and add information to/from the DB.

For example:

· In models.py:

Class Person(models.Model):

first_name = models.CharField(max_length=100, null=False)

last_name = models.CharField(max_length=100, null=False)

phone_number = models.CharField(max_length=100, null=False)

…

 

· In some file in my project:

from MY_DGANGO.my_django import models

….

def add_person(first_name, last_name, phone_number):

…

person = models.Person(first_name= first_name, last_name= last_name, 

phone_number= phone_number)

person.save()

…

…

…

def get_person_by_phone_number(phone_number):

…

person = models.Person.objects.filter(phone_number= phone_number)

…


P.S. I'm runnig it without starting any Django server.



On Friday, January 5, 2018 at 4:29:11 PM UTC+2, Andréas Kühne wrote:
>
> Ok,
>
> So are you in the folder where the manage.py file resides when you run 
> your commands? You have to be in that directory when running manage.py 
> commands.
>
> Also - as long as you haven't done too much already - I would recommend 
> starting fresh and looking into the tutorials in the django docs pages on 
> how to start a project. See 
> https://docs.djangoproject.com/en/2.0/intro/tutorial01/ or 
> https://tutorial.djangogirls.org/en/.
>
> The settings you have changed there are very strange (as Ramiro pointed 
> out) and should definitely not be required. Have you set the 
> DEFAULT_INDEX_TABLESPACE 
> setting anywhere? Because that is also something that shouldn't be 
> required
>
> Med vänliga hälsningar,
>
> Andréas
>
> 2018-01-05 15:17 GMT+01:00 alex Tarasiuk 
> :
>
>> Hi Andréas,
>> Thanks for your response.
>>
>> When I'm removing the lines you've talked about I'm having the following 
>> error:
>>
>> django.core.exceptions.ImproperlyConfigured: Requested setting 
>> DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either 
>> define the environment variable DJANGO_SETTINGS_MODULE or call 
>> settings.configure() before accessing settings.
>>
>> This is why I've added those settings in the first place.
>>
>>
>>
>> On Friday, January 5, 2018 at 3:59:31 PM UTC+2, Andréas Kühne wrote:
>>>
>>> Hi Alex,
>>>
>>> You shouldn't have anything regarding the settings in models.py.
>>>
>>> Remove:
>>> import os
>>> import django
>>> os.environ["DJANGO_SETTINGS_MODULE"] = "MY_DJANGO.MY_DJANGO.settings"
>>> django.setup()
>>>
>>> from your models.py file. You should never have any settings in the 
>>> models.py file at all. Also, you should never reference the django project 
>>> folder (your first MY_DJANGO here) in the project. It always has that 
>>> folder anyway.
>>>
>>> In settings.py, your INSTALLED_APPS should look like this:
>>>
>>> INSTALLED_APPS = [
>>> 'django.contrib.admin',
>>> 'django.contrib.auth',
>>> 'django.contrib.contenttypes',
>>> 'django.contrib.sessions',
>>> 'django.contrib.messages',
>>> 'django.contrib.staticfiles',
>>> 'django.contrib.sites',
>>> 'django.contrib.admindocs',
>>>
>>> 'my_django',
>>>
>>> ]
>>>
>>>
>>> Everything should then work as expected.
>>>
>>> Regards,
>>>
>>> Andréas
>>>
>>> 2018-01-05 13:07 GMT+01:00 alex Tarasiuk :
>>>
 Hi, I'm new to Django and having some trouble to configure it.
 I'm using Django 1.11.9 (1.11.5 at first but then upgraded with hopes 
 it will solve the issue) and Python 2.7.12 from virtualenv.

 Here is my project structure (Please pay attention to upper/lower case 
 letters - it is intentionally):

 :

 module 1

 module 2

 ...

 ...

 MY_DJANGO:

 MY_DJANGO:

 __init__.py

 settings.py

 urls.py

 wsgi.py

 my_django:

 migrations

 __init__.py

 admin.py

 apps.py

 models.py

 tests.py

 views.py

 __init__.py

 manage.py
  
 in models.py I've added:

 import os
 import django
 os.environ["DJANGO_SETTINGS_MODULE"] = "MY_DJANGO.MY_DJANGO.settings"
 django.setup()

 before the models import from django.db.


Re: Failing to configure Django correctlly (conflict in settings between models.py and manage.py usage).

2018-01-05 Thread Andréas Kühne
Ok,

So are you in the folder where the manage.py file resides when you run your
commands? You have to be in that directory when running manage.py commands.

Also - as long as you haven't done too much already - I would recommend
starting fresh and looking into the tutorials in the django docs pages on
how to start a project. See
https://docs.djangoproject.com/en/2.0/intro/tutorial01/ or
https://tutorial.djangogirls.org/en/.

The settings you have changed there are very strange (as Ramiro pointed
out) and should definitely not be required. Have you set the
DEFAULT_INDEX_TABLESPACE
setting anywhere? Because that is also something that shouldn't be
required

Med vänliga hälsningar,

Andréas

2018-01-05 15:17 GMT+01:00 alex Tarasiuk :

> Hi Andréas,
> Thanks for your response.
>
> When I'm removing the lines you've talked about I'm having the following
> error:
>
> django.core.exceptions.ImproperlyConfigured: Requested setting
> DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either
> define the environment variable DJANGO_SETTINGS_MODULE or call
> settings.configure() before accessing settings.
>
> This is why I've added those settings in the first place.
>
>
>
> On Friday, January 5, 2018 at 3:59:31 PM UTC+2, Andréas Kühne wrote:
>>
>> Hi Alex,
>>
>> You shouldn't have anything regarding the settings in models.py.
>>
>> Remove:
>> import os
>> import django
>> os.environ["DJANGO_SETTINGS_MODULE"] = "MY_DJANGO.MY_DJANGO.settings"
>> django.setup()
>>
>> from your models.py file. You should never have any settings in the
>> models.py file at all. Also, you should never reference the django project
>> folder (your first MY_DJANGO here) in the project. It always has that
>> folder anyway.
>>
>> In settings.py, your INSTALLED_APPS should look like this:
>>
>> INSTALLED_APPS = [
>> 'django.contrib.admin',
>> 'django.contrib.auth',
>> 'django.contrib.contenttypes',
>> 'django.contrib.sessions',
>> 'django.contrib.messages',
>> 'django.contrib.staticfiles',
>> 'django.contrib.sites',
>> 'django.contrib.admindocs',
>>
>> 'my_django',
>>
>> ]
>>
>>
>> Everything should then work as expected.
>>
>> Regards,
>>
>> Andréas
>>
>> 2018-01-05 13:07 GMT+01:00 alex Tarasiuk :
>>
>>> Hi, I'm new to Django and having some trouble to configure it.
>>> I'm using Django 1.11.9 (1.11.5 at first but then upgraded with hopes
>>> it will solve the issue) and Python 2.7.12 from virtualenv.
>>>
>>> Here is my project structure (Please pay attention to upper/lower case
>>> letters - it is intentionally):
>>>
>>> :
>>>
>>> module 1
>>>
>>> module 2
>>>
>>> ...
>>>
>>> ...
>>>
>>> MY_DJANGO:
>>>
>>> MY_DJANGO:
>>>
>>> __init__.py
>>>
>>> settings.py
>>>
>>> urls.py
>>>
>>> wsgi.py
>>>
>>> my_django:
>>>
>>> migrations
>>>
>>> __init__.py
>>>
>>> admin.py
>>>
>>> apps.py
>>>
>>> models.py
>>>
>>> tests.py
>>>
>>> views.py
>>>
>>> __init__.py
>>>
>>> manage.py
>>>
>>> in models.py I've added:
>>>
>>> import os
>>> import django
>>> os.environ["DJANGO_SETTINGS_MODULE"] = "MY_DJANGO.MY_DJANGO.settings"
>>> django.setup()
>>>
>>> before the models import from django.db.
>>>
>>> in manage.py, in the main
>>>
>>> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MY_DJANGO.settings")
>>>
>>> was auto generated by Django
>>>
>>> in settings.py, in INSTALLED_APPS:
>>>
>>> INSTALLED_APPS = [
>>> 'django.contrib.admin',
>>> 'django.contrib.auth',
>>> 'django.contrib.contenttypes',
>>> 'django.contrib.sessions',
>>> 'django.contrib.messages',
>>> 'django.contrib.staticfiles',
>>> 'django.contrib.sites',
>>> 'django.contrib.admindocs',
>>>
>>> =='MY_DJANGO.my_django', or 'my_django', = Here is
>>> the problem
>>>
>>> ]
>>>
>>>
>>> Problem description:
>>>
>>> if I use 'MY_DJANGO.my_django' in INSTALLED_APPS then running 'python
>>> manage.py check' command yields:
>>>
>>>  ImportError: No module named MY_DJANGO.settings
>>>
>>>
>>>
>>>
>>> and if I use 'my_django' in INSTALLED_APPS then I have an import error
>>> while importing models:
>>>
>>>  from MY_DJANGO.my_django import models (in some file) yields:
>>>
>>> ImportError: No module named my_django
>>>
>>>
>>> Also tried to add  ''my_django.apps.MyDjangoConfig' to INSTALLED_APPS,
>>> and it didn't helped.
>>>
>>> What am I doing wrong??
>>>
>>> Thanks in advance,
>>> Alex.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> --
>>> You received this message because you are subscribed 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 

Re: Failing to configure Django correctlly (conflict in settings between models.py and manage.py usage).

2018-01-05 Thread alex Tarasiuk
Hi Andréas,
Thanks for your response.

When I'm removing the lines you've talked about I'm having the following 
error:

django.core.exceptions.ImproperlyConfigured: Requested setting 
DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either 
define the environment variable DJANGO_SETTINGS_MODULE or call 
settings.configure() before accessing settings.

This is why I've added those settings in the first place.



On Friday, January 5, 2018 at 3:59:31 PM UTC+2, Andréas Kühne wrote:
>
> Hi Alex,
>
> You shouldn't have anything regarding the settings in models.py.
>
> Remove:
> import os
> import django
> os.environ["DJANGO_SETTINGS_MODULE"] = "MY_DJANGO.MY_DJANGO.settings"
> django.setup()
>
> from your models.py file. You should never have any settings in the 
> models.py file at all. Also, you should never reference the django project 
> folder (your first MY_DJANGO here) in the project. It always has that 
> folder anyway.
>
> In settings.py, your INSTALLED_APPS should look like this:
>
> INSTALLED_APPS = [
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'django.contrib.sites',
> 'django.contrib.admindocs',
>
> 'my_django',
>
> ]
>
>
> Everything should then work as expected.
>
> Regards,
>
> Andréas
>
> 2018-01-05 13:07 GMT+01:00 alex Tarasiuk 
> :
>
>> Hi, I'm new to Django and having some trouble to configure it.
>> I'm using Django 1.11.9 (1.11.5 at first but then upgraded with hopes it 
>> will solve the issue) and Python 2.7.12 from virtualenv.
>>
>> Here is my project structure (Please pay attention to upper/lower case 
>> letters - it is intentionally):
>>
>> :
>>
>> module 1
>>
>> module 2
>>
>> ...
>>
>> ...
>>
>> MY_DJANGO:
>>
>> MY_DJANGO:
>>
>> __init__.py
>>
>> settings.py
>>
>> urls.py
>>
>> wsgi.py
>>
>> my_django:
>>
>> migrations
>>
>> __init__.py
>>
>> admin.py
>>
>> apps.py
>>
>> models.py
>>
>> tests.py
>>
>> views.py
>>
>> __init__.py
>>
>> manage.py
>>  
>> in models.py I've added:
>>
>> import os
>> import django
>> os.environ["DJANGO_SETTINGS_MODULE"] = "MY_DJANGO.MY_DJANGO.settings"
>> django.setup()
>>
>> before the models import from django.db.
>>
>> in manage.py, in the main
>>
>> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MY_DJANGO.settings")
>>
>> was auto generated by Django 
>>
>> in settings.py, in INSTALLED_APPS:
>>
>> INSTALLED_APPS = [
>> 'django.contrib.admin',
>> 'django.contrib.auth',
>> 'django.contrib.contenttypes',
>> 'django.contrib.sessions',
>> 'django.contrib.messages',
>> 'django.contrib.staticfiles',
>> 'django.contrib.sites',
>> 'django.contrib.admindocs',
>>
>> =='MY_DJANGO.my_django', or 'my_django', = Here is 
>> the problem
>>
>> ]
>>
>>
>> Problem description:
>>
>> if I use 'MY_DJANGO.my_django' in INSTALLED_APPS then running 'python 
>> manage.py check' command yields:
>>
>>  ImportError: No module named MY_DJANGO.settings
>>
>>
>>  
>>
>> and if I use 'my_django' in INSTALLED_APPS then I have an import error 
>> while importing models:
>>
>>  from MY_DJANGO.my_django import models (in some file) yields:
>>
>> ImportError: No module named my_django 
>>
>>
>> Also tried to add  ''my_django.apps.MyDjangoConfig' to INSTALLED_APPS, 
>> and it didn't helped.
>>
>> What am I doing wrong??
>>
>> Thanks in advance,
>> Alex.
>>
>>  
>>
>>
>>
>>
>>
>>
>>  
>>
>> -- 
>> You received this message because you are subscribed 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/bb9251bb-7bce-4eec-b8ac-90b031db1284%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/31d7a9d0-a861-4814-a4d5-9771ba828918%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Failing to configure Django correctlly (conflict in settings between models.py and manage.py usage).

2018-01-05 Thread Ramiro Morales
On Fri, Jan 5, 2018 at 9:07 AM, alex Tarasiuk  wrote:

> Hi, I'm new to Django and having some trouble to configure it.
> I'm using Django 1.11.9 (1.11.5 at first but then upgraded with hopes it
> will solve the issue) and Python 2.7.12 from virtualenv.
>
> Here is my project structure (Please pay attention to upper/lower case
> letters - it is intentionally):
>
> :
>
> module 1
>
> module 2
>
> ...
>
> ...
>
> MY_DJANGO:
>
> MY_DJANGO:
>
> __init__.py
>
> settings.py
>
> urls.py
>
> wsgi.py
>
> my_django:
>
> migrations
>
> __init__.py
>
> admin.py
>
> apps.py
>
> models.py
>
> tests.py
>
> views.py
>
> __init__.py
>
> manage.py
>
> in models.py I've added:
>
> import os
> import django
> os.environ["DJANGO_SETTINGS_MODULE"] = "MY_DJANGO.MY_DJANGO.settings"
> django.setup()
>
> before the models import from django.db.
>
> in manage.py, in the main
>
> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MY_DJANGO.settings")
>
> was auto generated by Django
>
> in settings.py, in INSTALLED_APPS:
>
> INSTALLED_APPS = [
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'django.contrib.sites',
> 'django.contrib.admindocs',
>
> =='MY_DJANGO.my_django', or 'my_django', = Here is
> the problem
>
> ]
>
>
> Problem description:
>
> if I use 'MY_DJANGO.my_django' in INSTALLED_APPS then running 'python
> manage.py check' command yields:
>
>  ImportError: No module named MY_DJANGO.settings
>
>
>
>
> and if I use 'my_django' in INSTALLED_APPS then I have an import error
> while importing models:
>
>  from MY_DJANGO.my_django import models (in some file) yields:
>
> ImportError: No module named my_django
>
>
> Also tried to add  ''my_django.apps.MyDjangoConfig' to INSTALLED_APPS,
> and it didn't helped.
>
> What am I doing wrong??
>
>

You describe the problem you are seeing but don't tell why you are setting
things up .

What are you trying to achieve with things like this:

*in models.py I've added:*

import os
import django
os.environ["DJANGO_SETTINGS_MODULE"] = "MY_DJANGO.MY_DJANGO.settings"
django.setup()

*before the models import from django.db.*

or

*in settings.py, in INSTALLED_APPS:*

INSTALLED_APPS = [
...
=='MY_DJANGO.my_django', or 'my_django', = Here is the
problem

]


*Also tried to add  ''my_django.apps.**MyDjangoConfig' to INSTALLED_APPS,
and it didn't helped.*

All of this is very unconventional.

If you are starting with Django you should refrain from doing weird things.
Django currently does no magic outside the Python import system so there is
no need to over complicate.

TBH No upgrade of Django is going to help you the mess you currently have.


-- 
Ramiro Morales
@ramiromorales

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


Re: Failing to configure Django correctlly (conflict in settings between models.py and manage.py usage).

2018-01-05 Thread Andréas Kühne
Hi Alex,

You shouldn't have anything regarding the settings in models.py.

Remove:
import os
import django
os.environ["DJANGO_SETTINGS_MODULE"] = "MY_DJANGO.MY_DJANGO.settings"
django.setup()

from your models.py file. You should never have any settings in the
models.py file at all. Also, you should never reference the django project
folder (your first MY_DJANGO here) in the project. It always has that
folder anyway.

In settings.py, your INSTALLED_APPS should look like this:

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.admindocs',

'my_django',

]


Everything should then work as expected.

Regards,

Andréas

2018-01-05 13:07 GMT+01:00 alex Tarasiuk :

> Hi, I'm new to Django and having some trouble to configure it.
> I'm using Django 1.11.9 (1.11.5 at first but then upgraded with hopes it
> will solve the issue) and Python 2.7.12 from virtualenv.
>
> Here is my project structure (Please pay attention to upper/lower case
> letters - it is intentionally):
>
> :
>
> module 1
>
> module 2
>
> ...
>
> ...
>
> MY_DJANGO:
>
> MY_DJANGO:
>
> __init__.py
>
> settings.py
>
> urls.py
>
> wsgi.py
>
> my_django:
>
> migrations
>
> __init__.py
>
> admin.py
>
> apps.py
>
> models.py
>
> tests.py
>
> views.py
>
> __init__.py
>
> manage.py
>
> in models.py I've added:
>
> import os
> import django
> os.environ["DJANGO_SETTINGS_MODULE"] = "MY_DJANGO.MY_DJANGO.settings"
> django.setup()
>
> before the models import from django.db.
>
> in manage.py, in the main
>
> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MY_DJANGO.settings")
>
> was auto generated by Django
>
> in settings.py, in INSTALLED_APPS:
>
> INSTALLED_APPS = [
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'django.contrib.sites',
> 'django.contrib.admindocs',
>
> =='MY_DJANGO.my_django', or 'my_django', = Here is
> the problem
>
> ]
>
>
> Problem description:
>
> if I use 'MY_DJANGO.my_django' in INSTALLED_APPS then running 'python
> manage.py check' command yields:
>
>  ImportError: No module named MY_DJANGO.settings
>
>
>
>
> and if I use 'my_django' in INSTALLED_APPS then I have an import error
> while importing models:
>
>  from MY_DJANGO.my_django import models (in some file) yields:
>
> ImportError: No module named my_django
>
>
> Also tried to add  ''my_django.apps.MyDjangoConfig' to INSTALLED_APPS,
> and it didn't helped.
>
> What am I doing wrong??
>
> Thanks in advance,
> Alex.
>
>
>
>
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/bb9251bb-7bce-4eec-b8ac-90b031db1284%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/CAK4qSCcenCaiZDFrcPPd3WoZgrj_O3d219kOOx27knBCfFs0Wg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to make a place where you could type in data(number)?

2018-01-05 Thread Derek
You may not need Django for this.  You could just use Flask e.g.

https://pythonspot.com/flask-web-forms/
and
https://stackoverflow.com/questions/27379486/retrieving-html-form-data-and-storing-in-csv-with-flask-python

but, as with all web frameworks, you need to look at the fundamentals of 
how Flask works first (otherwise you copy-and-paste without understanding 
why).

On Friday, 5 January 2018 01:46:25 UTC+2, June Kim wrote:
>
> I'm looking for a way to set up a place(square box) where you could input 
> data(number) on a website. and those data would be saved in somewhere else 
> as an excel sheet (.csv)
>

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


Failing to configure Django correctlly (conflict in settings between models.py and manage.py usage).

2018-01-05 Thread alex Tarasiuk
Hi, I'm new to Django and having some trouble to configure it.
I'm using Django 1.11.9 (1.11.5 at first but then upgraded with hopes it 
will solve the issue) and Python 2.7.12 from virtualenv.

Here is my project structure (Please pay attention to upper/lower case 
letters - it is intentionally):

:

module 1

module 2

...

...

MY_DJANGO:

MY_DJANGO:

__init__.py

settings.py

urls.py

wsgi.py

my_django:

migrations

__init__.py

admin.py

apps.py

models.py

tests.py

views.py

__init__.py

manage.py
 
in models.py I've added:

import os
import django
os.environ["DJANGO_SETTINGS_MODULE"] = "MY_DJANGO.MY_DJANGO.settings"
django.setup()

before the models import from django.db.

in manage.py, in the main

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MY_DJANGO.settings")

was auto generated by Django 

in settings.py, in INSTALLED_APPS:

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.admindocs',

=='MY_DJANGO.my_django', or 'my_django', = Here is the 
problem

]


Problem description:

if I use 'MY_DJANGO.my_django' in INSTALLED_APPS then running 'python 
manage.py check' command yields:

 ImportError: No module named MY_DJANGO.settings


 

and if I use 'my_django' in INSTALLED_APPS then I have an import error 
while importing models:

 from MY_DJANGO.my_django import models (in some file) yields:

ImportError: No module named my_django 


Also tried to add  ''my_django.apps.MyDjangoConfig' to INSTALLED_APPS, and 
it didn't helped.

What am I doing wrong??

Thanks in advance,
Alex.

 






 

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


Re: Handling Celery Connection Lost Problem

2018-01-05 Thread Jani Tiainen
Hi,

This is not really Django issue at all.

You should contact celery/rabbitmq support channels to get help with
building high availability messaging backend.

5.1.2018 13.36 "Mukul Mantosh"  kirjoitti:

>
> @Matemática A3K
>
> *If you restart rabbitmq at this point, does it works? *
>
> After restarting rabbitmq everything is working fine. This example simply
> tells that whenever rabbitmq is down your code is going to stuck, so we
> need to design high available rabbitmq server which will be available
> during heavy workloads.
>
> Is there any solution to this problem because it is a common scenario when
> a broker might fail.
>
> On Thursday, January 4, 2018 at 1:04:06 AM UTC+5:30, Matemática A3K wrote:
>>
>>
>>
>> On Wed, Jan 3, 2018 at 6:25 AM, Mukul Mantosh 
>> wrote:
>>
>>> *I'm not sure about understanding you, where are you trying to call it
>>> again? from ipython?*
>>>
>>> I am calling from Django, the code is inside the view.
>>>
>>> *def test(request):*
>>> *  try:*
>>> *add.delay(2, 2)*
>>> *  except add.OperationalError as exc:*
>>> *print('error')*
>>> *return HttpResponse('working')*
>>>
>>> Point 1 - Stop RabbitMQ Server from terminal manually. (sudo service
>>> rabbitmq-server stop).
>>> Point 2 - Reload the view from the browser, it will immediately throw
>>> connection refused error which i could catch easily using try except block
>>> as provided in above example.
>>> Point 3 - If you try again reloading the page it hangs up over there.
>>> and it won't send any http response because it is still waiting and waiting
>>> to get response.
>>>
>>
>> I think this might be because celery can't enqueue the task, so it does
>> not "return" to django
>>
>>
>>> Point 4 - You can see celery in background trying to reconnect to the
>>> broker every 5-10 seconds.
>>>
>>
>> If you restart rabbitmq at this point, does it works?
>>
>>
>>>
>>>
>>> *For what I understood, your problem is assuming that if a celery task
>>> fails, it won't be retried :)*
>>>
>>> It should be retried but i can't make a user wait for it because signup
>>> process is very quick and we cannot halt any user because our connection is
>>> lost. I just simply want if connection lost try for 10 seconds if connected
>>> its good otherwise just move on don't get stuck.
>>>
>>> Even if i tried add.apply_async((2, 2), retry=False) but it is still
>>> not working and the page is not giving back the HTTP Response.
>>>
>>> I think i have cleared everything what you wanted to know @Matemática
>>> A3K.
>>>
>>
>> https://github.com/celery/celery/issues/3241
>> https://github.com/celery/celery/issues/3921
>>
>> Seems that it is retried by celery, but with a missing rabbitmq broker it
>> won't work at all. If you take away the broker, you are taking away how it
>> works, there is no way of delivering messages. The problem is how to ensure
>> the broker is always working.
>>
>> Again, this seems more appropriate for the celery community :)
>>
>>
>>>
>>> On Wednesday, January 3, 2018 at 2:08:24 PM UTC+5:30, Matemática A3K
>>> wrote:



 On Tue, Jan 2, 2018 at 11:14 PM, Mukul Mantosh 
 wrote:

> I am not using result backend my question is that when the broker
> connection is lost it throws a connection refused exception which i could
> normally catch through the following given below code.
>
> *try:*
> *  add.delay(2, 2)*
> *except add.OperationalError as exc:*
> *  print('error');*
>
> Reference 1: http://docs.celeryproject.org/en/latest/userguide/calling
> .html#connection-error-handling
> Reference 2: https://github.com/celery/celery/issues/3933
>
>
> This try except block works only one time and next time when i try to
> call again add.delay(2,2)the code is waiting to execute because celery
> is re-trying to establish the connection with the broker.
>
>
 I'm not sure about understanding you, where are you trying to call it
 again? from ipython?


> I just simply don't want to do, for example: There is a website where
> a user signup as a new user and we have to send an verification email
> through celery and suddenly the connection gets lost then the code will be
> in waiting state because celery is again retrying to establish a 
> connection
> with the lost broker.
>
>
 I agree that this may be better for a celery mailing list, as "low
 level" celery is probably not the main expertise of most of the people
 reading here, as Jason said, for what I understand
 http://docs.celeryproject.org/en/latest/userguide/calling.ht
 ml#calling-retry should be sufficient for the "normal" cases.

 Have in mind that exception will be raised at the celery level, not
 django because it's async, http://docs.celeryproject.org/
 en/latest/userguide/calling.html#linking-callbacks-errbacks. Django

Re: Handling Celery Connection Lost Problem

2018-01-05 Thread Mukul Mantosh

@Matemática A3K  

*If you restart rabbitmq at this point, does it works? *

After restarting rabbitmq everything is working fine. This example simply 
tells that whenever rabbitmq is down your code is going to stuck, so we 
need to design high available rabbitmq server which will be available 
during heavy workloads.

Is there any solution to this problem because it is a common scenario when 
a broker might fail.

On Thursday, January 4, 2018 at 1:04:06 AM UTC+5:30, Matemática A3K wrote:
>
>
>
> On Wed, Jan 3, 2018 at 6:25 AM, Mukul Mantosh  > wrote:
>
>> *I'm not sure about understanding you, where are you trying to call it 
>> again? from ipython?*
>>
>> I am calling from Django, the code is inside the view.
>>
>> *def test(request):*
>> *  try:*
>> *add.delay(2, 2)*
>> *  except add.OperationalError as exc:*
>> *print('error')*
>> *return HttpResponse('working')*
>>
>> Point 1 - Stop RabbitMQ Server from terminal manually. (sudo service 
>> rabbitmq-server stop).
>> Point 2 - Reload the view from the browser, it will immediately throw 
>> connection refused error which i could catch easily using try except block 
>> as provided in above example.
>> Point 3 - If you try again reloading the page it hangs up over there. and 
>> it won't send any http response because it is still waiting and waiting to 
>> get response.
>>
>
> I think this might be because celery can't enqueue the task, so it does 
> not "return" to django 
>  
>
>> Point 4 - You can see celery in background trying to reconnect to the 
>> broker every 5-10 seconds.
>>
>
> If you restart rabbitmq at this point, does it works?
>  
>
>>
>>
>> *For what I understood, your problem is assuming that if a celery task 
>> fails, it won't be retried :)*
>>
>> It should be retried but i can't make a user wait for it because signup 
>> process is very quick and we cannot halt any user because our connection is 
>> lost. I just simply want if connection lost try for 10 seconds if connected 
>> its good otherwise just move on don't get stuck.
>>
>> Even if i tried add.apply_async((2, 2), retry=False) but it is still  
>> not working and the page is not giving back the HTTP Response. 
>>
>> I think i have cleared everything what you wanted to know @Matemática A3K
>> .
>>
>
> https://github.com/celery/celery/issues/3241
> https://github.com/celery/celery/issues/3921
>
> Seems that it is retried by celery, but with a missing rabbitmq broker it 
> won't work at all. If you take away the broker, you are taking away how it 
> works, there is no way of delivering messages. The problem is how to ensure 
> the broker is always working.
>
> Again, this seems more appropriate for the celery community :)
>
>
>>
>> On Wednesday, January 3, 2018 at 2:08:24 PM UTC+5:30, Matemática A3K 
>> wrote:
>>>
>>>
>>>
>>> On Tue, Jan 2, 2018 at 11:14 PM, Mukul Mantosh  
>>> wrote:
>>>
 I am not using result backend my question is that when the broker 
 connection is lost it throws a connection refused exception which i could 
 normally catch through the following given below code.

 *try:*
 *  add.delay(2, 2)*
 *except add.OperationalError as exc:*
 *  print('error');*

 Reference 1: 
 http://docs.celeryproject.org/en/latest/userguide/calling.html#connection-error-handling
 Reference 2: https://github.com/celery/celery/issues/3933


 This try except block works only one time and next time when i try to 
 call again add.delay(2,2)the code is waiting to execute because celery 
 is re-trying to establish the connection with the broker.


>>> I'm not sure about understanding you, where are you trying to call it 
>>> again? from ipython?
>>>  
>>>
 I just simply don't want to do, for example: There is a website where a 
 user signup as a new user and we have to send an verification email 
 through 
 celery and suddenly the connection gets lost then the code will be in 
 waiting state because celery is again retrying to establish a connection 
 with the lost broker.


>>> I agree that this may be better for a celery mailing list, as "low 
>>> level" celery is probably not the main expertise of most of the people 
>>> reading here, as Jason said, for what I understand 
>>> http://docs.celeryproject.org/en/latest/userguide/calling.html#calling-retry
>>>  
>>> should be sufficient for the "normal" cases.
>>>
>>> Have in mind that exception will be raised at the celery level, not 
>>> django because it's async, 
>>> http://docs.celeryproject.org/en/latest/userguide/calling.html#linking-callbacks-errbacks.
>>>  
>>> Django delegates the task to celery and celery takes care of executing it. 
>>> If you need to perfect warranty of execution, do it sync, inside the django 
>>> view send the verification mail, where you can show to the user that the 
>>> confirmation mail hasn't been sent.
>>>  
>>>
 How can we solve this 

Re: How can i get more clear understanding on django models?

2018-01-05 Thread Etienne Robillard

you can put docstrings to document what the classes are doing.. :-)

cheers,

Etienne


Le 2018-01-05 à 05:52, utpalbrahma1...@gmail.com a écrit :

from  django.db  import  models


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


class  Choice(models.Model):
 question  =  models.ForeignKey(Question,  on_delete=models.CASCADE)
 choice_text  =  models.CharField(max_length=200)
 votes  =  models.IntegerField(default=0)
--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to django-users+unsubscr...@googlegroups.com 
.
To post to this group, send email to django-users@googlegroups.com 
.

Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/39e00f5e-41d1-4d17-8116-41db3c6ab072%40googlegroups.com 
.

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


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

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


How can i get more clear understanding on django models?

2018-01-05 Thread utpalbrahma1995


from django.db import models

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

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

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