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

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

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 du

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 re

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

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 Fl

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 shou

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

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

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 page

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

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/

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

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 tuto

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

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

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 cre

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

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

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 manage

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

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

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

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 ap

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 on

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 sys

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

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

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 an

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

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 ove

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

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 Grou

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

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 sh

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 d

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

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

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

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

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=