Re: django models

2018-08-09 Thread Ramandeep Kaur
when i run my manage.py server its giving me invalid syntax error.
  File "C:\Users\Dell\vms2\vms2\settings\base.py", line 18
from .base import *pip install django-generate-secret-key
 ^
SyntaxError: invalid syntax


On Thu, Aug 9, 2018 at 12:14 PM, Mike Dewhirst 
wrote:

> Ok. If it is saying the secret key is empty and you have spelled
> SECRET_KEY correctly and it is not empty then manage.py is loading the
> wrong settings.
>
> Does manage.py runserver work?
>
>
> On 9/08/2018 3:48 PM, Ramandeep Kaur wrote:
>
>> Thanks but again getting same error.
>> PS C:\Users\Dell\vms2> python manage.py makemigrations
>> --settings=vms2.settings
>> Traceback (most recent call last):
>>   File "manage.py", line 10, in 
>> execute_from_command_line(sys.argv)
>>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
>> line 353, in execute_from_command_line
>> utility.execute()
>>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
>> line 345, in execute
>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
>> line 195, in fetch_command
>> klass = load_command_class(app_name, subcommand)
>>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
>> line 39, in load_command_class
>> module = import_module('%s.management.commands.%s' % (app_name,
>> name))
>>   File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
>> __import__(name)
>>   File 
>> "C:\Python27\lib\site-packages\django\core\management\commands\makemigrations.py",
>> line 8, in 
>> from django.db.migrations.autodetector import MigrationAutodetector
>>   File "C:\Python27\lib\site-packages\django\db\migrations\autodetector.py",
>> line 13, in 
>> from django.db.migrations.questioner import MigrationQuestioner
>>   File "C:\Python27\lib\site-packages\django\db\migrations\questioner.py",
>> line 12, in 
>> from .loader import MigrationLoader
>>   File "C:\Python27\lib\site-packages\django\db\migrations\loader.py",
>> line 10, in 
>> from django.db.migrations.recorder import MigrationRecorder
>>   File "C:\Python27\lib\site-packages\django\db\migrations\recorder.py",
>> line 12, in 
>> class MigrationRecorder(object):
>>   File "C:\Python27\lib\site-packages\django\db\migrations\recorder.py",
>> line 26, in MigrationRecorder
>> class Migration(models.Model):
>>   File "C:\Python27\lib\site-packages\django\db\migrations\recorder.py",
>> line 27, in Migration
>> app = models.CharField(max_length=255)
>>   File "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py",
>> line 1072, in __init__
>> super(CharField, self).__init__(*args, **kwargs)
>>   File "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py",
>> line 166, in __init__
>> self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESP
>> ACE
>>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 55,
>> in __getattr__
>> self._setup(name)
>>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 43,
>> in _setup
>> self._wrapped = Settings(settings_module)
>>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line
>> 120, in __init__
>> raise ImproperlyConfigured("The SECRET_KEY setting must not be
>> empty.")
>> django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must
>> not be empty.
>> PS C:\Users\Dell\vms2> python manage.py makemigrations
>> --settings=vms2.settings
>> Traceback (most recent call last):
>>   File "manage.py", line 10, in 
>> execute_from_command_line(sys.argv)
>>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
>> line 353, in execute_from_command_line
>> utility.execute()
>>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
>> line 345, in execute
>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
>> line 195, in fetch_command
>> klass = load_command_class(app_name, subcommand)
>>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
>> line 39, in load_command_class
>> module = import_module('%s.management.commands.%s' % (app_name,
>> name))
>>   File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
>> __import__(name)
>>   File 
>> "C:\Python27\lib\site-packages\django\core\management\commands\makemigrations.py",
>> line 8, in 
>> from django.db.migrations.autodetector import MigrationAutodetector
>>   File "C:\Python27\lib\site-packages\django\db\migrations\autodetector.py",
>> line 13, in 
>> from django.db.migrations.questioner import MigrationQuestioner
>>   File "C:\Python27\lib\site-packages\django\db\migrations\questioner.py",
>> line 12, in 
>> from .loader import MigrationLoader
>>   File "C:\Python27\lib\site-packages\d

Re: django models

2018-08-09 Thread Kasper Laudrup

Hi Ramandeep,

On 08/09/2018 09:25 AM, Ramandeep Kaur wrote:

when i run my manage.py server its giving me invalid syntax error.
  File "C:\Users\Dell\vms2\vms2\settings\base.py", line 18
    from .base import *pip install django-generate-secret-key
                         ^
SyntaxError: invalid syntax



What does your settings.py look like?

Have you really written "from .base import *pip install 
django-generate-secret-key" in there?


Kind regards,

Kasper Laudrup

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/000fb49c-8c46-9c67-1d2e-54e781795e17%40stacktrace.dk.
For more options, visit https://groups.google.com/d/optout.


Re: django models

2018-08-09 Thread Ramandeep Kaur
 import os
import sys

from django.core.exceptions import ImproperlyConfigured
from .base import *pip install django-generate-secret-key

def get_env_variable(var_name):
try:
return os.environ[var_name]
except KeyError:
error_msg = "Set the %s environment variable" % var_name
raise ImproperlyConfigured(error_msg)

BASE_DIR = os.path.dirname(os.path.dirname
(os.path.dirname(os.path.abspath(__file__

sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '{{ secret_key }}'



# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False

ALLOWED_HOSTS = ['52.220.91.39']

# Application definition

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
)

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'user_profiles.middleware.CustomCsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = 'vms2.urls'

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

WSGI_APPLICATION = 'vms2.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}

# django-allauth settings

AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'allauth.account.auth_backends.AuthenticationBackend',
)

ACCOUNT_USERNAME_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = "none"
ACCOUNT_EMAIL_REQUIRED = False
ACCOUNT_AUTHENTICATION_METHOD = "username"
ACCOUNT_LOGIN_ATTEMPTS_LIMIT = None
ACCOUNT_EMAIL_CONFIRMATION_ANONYMOUS_REDIRECT_URL = "/"
ACCOUNT_EMAIL_CONFIRMATION_AUTHENTICATED_REDIRECT_URL =
"/user_details/edit/"
ACCOUNT_LOGIN_ON_EMAIL_CONFIRMATION = True

# rest_auth settings

REST_AUTH_SERIALIZERS = {
'USER_DETAILS_SERIALIZER':
'user_profiles.serializers.UserSerializer'
}

REST_AUTH_REGISTER_SERIALIZERS = {
'REGISTER_SERIALIZER':
'authentication.serializers.UserRegisterSerializer'
}


# Email settings for gmail
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
# EMAIL_HOST_USER = get_env_variable('EMAIL_HOST_USER')
# EMAIL_HOST_PASSWORD = get_env_variable('EMAIL_HOST_PASSWORD')
# DEFAULT_FROM_EMAIL = get_env_variable('DEFAULT_FROM_EMAIL')

# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


hi kasper,this is my settings.py


On Thu, Aug 9, 2018 at 1:11 PM, Kasper Laudrup 
wrote:

> Hi Ramandeep,
>
> On 08/09/2018 09:25 AM, Ramandeep Kaur wrote:
>
>> when i run my manage.py server its giving me invalid syntax error.
>>   File "C:\Users\Dell\vms2\vms2\settings\base.py", line 18
>> from .base import *pip install django-generate-secret-key
>>  ^
>> SyntaxError: invalid syntax
>>
>>
> What does your settings.py look like?
>
> Have you really written "from .base import *pip install
> django-generate-secret-key" in there?
>
> Kind regards,
>
> Kasper Laudrup
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> 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/000fb49c-8c46-9c67-1d2e-54e781795e17%40stacktrace.dk.
>
> 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 

Re: django models

2018-08-09 Thread Kasper Laudrup

Hi Ramandeep,

On 08/09/2018 09:57 AM, Ramandeep Kaur wrote:


hi kasper,this is my settings.py



What you have added to your settings.py doesn't make any sense. It is 
not valid Python code as your Python interpreter correctly tells you. I 
have no idea what you tried to achieve by writing that.


Read up on Python and modules here:

https://docs.python.org/3/tutorial/modules.html

Kind regards,

Kasper Laudrup

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


Array List

2018-08-09 Thread Dheeraj Kumar
Array = [0,0,4,2,6,9,0,5,2,0,9,5,9]
Make it in squnce n tell maximum value n repitation value without using in
build function.

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


Re: Array List

2018-08-09 Thread Kasper Laudrup

Hi Dheeraj,

On 08/09/2018 10:22 AM, Dheeraj Kumar wrote:

Array = [0,0,4,2,6,9,0,5,2,0,9,5,9]
Make it in squnce n tell maximum value n repitation value without using 
in build function.




How is this related to Django?

Kind regards,

Kasper Laudrup

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


Re: Array List

2018-08-09 Thread Dheeraj Kumar
It is a basic question put in interview for python developer where
mentioned django too.

On Thu 9 Aug, 2018, 1:55 PM Kasper Laudrup,  wrote:

> Hi Dheeraj,
>
> On 08/09/2018 10:22 AM, Dheeraj Kumar wrote:
> > Array = [0,0,4,2,6,9,0,5,2,0,9,5,9]
> > Make it in squnce n tell maximum value n repitation value without using
> > in build function.
> >
>
> How is this related to Django?
>
> Kind regards,
>
> Kasper Laudrup
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8bc561c8-22de-4a40-5fd5-4bccf1bced9d%40stacktrace.dk
> .
> 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/CANwUEV_javpWm%2B6FiZ%2Bt1M7M5z3EZWhT8KakkmCLDnR3Vm_vZg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django models

2018-08-09 Thread Mike Dewhirst

On 9/08/2018 5:25 PM, Ramandeep Kaur wrote:

when i run my manage.py server its giving me invalid syntax error.
  File "C:\Users\Dell\vms2\vms2\settings\base.py", line 18
    from .base import *pip install django-generate-secret-key
                         ^
SyntaxError: invalid syntax


There is evidence here.

Below you tried python manage.py makemigrations --settings=vms2.settings

But above we can see it perhaps should have been ...

python manage.py makemigrations --settings=vms2.settings.base

However, there appears to be another problem. In the base.py file above 
we can see a suspicious line 18 quoted by the error traceback ...


from .base import *pip install django-generate-secret-key

That looks like a concatenation of two lines being

from .base import *

pip install django-generate-secret-key

Firstly, from .base import * is a typical incantation usually found at 
the top of a developer's settings file which wants to inherit all the 
base settings and then tweak a few. Having that line in the base.py file 
won't work because that says to import itself. Remove it from base.py.


For example it might appear at the top of 
C:\Users\Dell\vms2\vms2\settings\ramandeep.py and in there you might 
want DEBUG = True


If so, your settings file when running makemigrations then ought to be ...

python manage.py makemigrations --settings=vms2.settings.ramandeep

Secondly, the pip install line will never work in any settings file. It 
needs to be removed as well.


For the moment, follow the above clues to clean up whatever settings 
files might be involved. Then find the SECRET_KEY = line in base.py and 
temporarily make it look something like this ...


SECRET_KEY = 'xkshjfsdrhkhdjhkekjrlkj6456k3h46hkljlk'

Once you get everything working you can generate a new secret key by 
executing that "pip install ..." line in a command prompt.


There might be a few more things you need to clean up and the traceback 
ought to provide hints.


Good luck

Mike




On Thu, Aug 9, 2018 at 12:14 PM, Mike Dewhirst > wrote:


Ok. If it is saying the secret key is empty and you have spelled
SECRET_KEY correctly and it is not empty then manage.py is loading
the wrong settings.

Does manage.py runserver work?


On 9/08/2018 3:48 PM, Ramandeep Kaur wrote:

Thanks but again getting same error.
PS C:\Users\Dell\vms2> python manage.py makemigrations
--settings=vms2.settings
Traceback (most recent call last):
  File "manage.py", line 10, in 
    execute_from_command_line(sys.argv)
  File
"C:\Python27\lib\site-packages\django\core\management\__init__.py",
line 353, in execute_from_command_line
    utility.execute()
  File
"C:\Python27\lib\site-packages\django\core\management\__init__.py",
line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File
"C:\Python27\lib\site-packages\django\core\management\__init__.py",
line 195, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File
"C:\Python27\lib\site-packages\django\core\management\__init__.py",
line 39, in load_command_class
    module = import_module('%s.management.commands.%s' %
(app_name, name))
  File "C:\Python27\lib\importlib\__init__.py", line 37, in
import_module
    __import__(name)
  File

"C:\Python27\lib\site-packages\django\core\management\commands\makemigrations.py",
line 8, in 
    from django.db.migrations.autodetector import
MigrationAutodetector
  File
"C:\Python27\lib\site-packages\django\db\migrations\autodetector.py",
line 13, in 
    from django.db.migrations.questioner import
MigrationQuestioner
  File
"C:\Python27\lib\site-packages\django\db\migrations\questioner.py",
line 12, in 
    from .loader import MigrationLoader
  File
"C:\Python27\lib\site-packages\django\db\migrations\loader.py",
line 10, in 
    from django.db.migrations.recorder import MigrationRecorder
  File
"C:\Python27\lib\site-packages\django\db\migrations\recorder.py",
line 12, in 
    class MigrationRecorder(object):
  File
"C:\Python27\lib\site-packages\django\db\migrations\recorder.py",
line 26, in MigrationRecorder
    class Migration(models.Model):
  File
"C:\Python27\lib\site-packages\django\db\migrations\recorder.py",
line 27, in Migration
    app = models.CharField(max_length=255)
  File
"C:\Python27\lib\site-packages\django\db\models\fields\__init__.py",
line 1072, in __init__
    super(CharField, self).__init__(*args, **kwargs)
  File
"C:\Python27\lib\site-packages\django\db\models\fields\__init__

Re: Array List

2018-08-09 Thread Kasper Laudrup

Hi Dheeraj,

On 08/09/2018 10:31 AM, Dheeraj Kumar wrote:
It is a basic question put in interview for python developer where 
mentioned django too.




Yes, this seems like it should be fairly easy to implement for anyone 
with basic experience in Python or any other programming language.


I suggest you pick up a book or online tutorial on Python programming.

Good luck.

Kind regards,

Kasper Laudrup

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


Re: Array List

2018-08-09 Thread Dheeraj Kumar
Can u tell me please.

On Thu 9 Aug, 2018, 2:15 PM Kasper Laudrup,  wrote:

> Hi Dheeraj,
>
> On 08/09/2018 10:31 AM, Dheeraj Kumar wrote:
> > It is a basic question put in interview for python developer where
> > mentioned django too.
> >
>
> Yes, this seems like it should be fairly easy to implement for anyone
> with basic experience in Python or any other programming language.
>
> I suggest you pick up a book or online tutorial on Python programming.
>
> Good luck.
>
> Kind regards,
>
> Kasper Laudrup
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/fb0cf319-7a8d-a2c8-79f8-0089b2ccd134%40stacktrace.dk
> .
> 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/CANwUEV_q1UQz8wbpfHu9VxHdghnLzFQDgzxEwcYpPyVPxxhGHQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django models

2018-08-09 Thread Mike Dewhirst

On 9/08/2018 6:40 PM, Ramandeep Kaur wrote:
I removed pip install django-generate-secret-key and now i am getting 
invalid syntax error.

Thanks guys:)


Did you follow all the steps?

Have you looked closely at the traceback for clues to fix the syntax error?

I'm going off the air now until the morning.

Good luck



On Thu, Aug 9, 2018 at 2:04 PM, Mike Dewhirst > wrote:


On 9/08/2018 5:25 PM, Ramandeep Kaur wrote:

when i run my manage.py server its giving me invalid syntax error.
  File "C:\Users\Dell\vms2\vms2\settings\base.py", line 18
    from .base import *pip install django-generate-secret-key
                         ^
SyntaxError: invalid syntax


There is evidence here.

Below you tried python manage.py makemigrations
--settings=vms2.settings

But above we can see it perhaps should have been ...

python manage.py makemigrations --settings=vms2.settings.base

However, there appears to be another problem. In the base.py file
above we can see a suspicious line 18 quoted by the error
traceback ...

from .base import *pip install django-generate-secret-key

That looks like a concatenation of two lines being

from .base import *

pip install django-generate-secret-key

Firstly, from .base import * is a typical incantation usually
found at the top of a developer's settings file which wants to
inherit all the base settings and then tweak a few. Having that
line in the base.py file won't work because that says to import
itself. Remove it from base.py.

For example it might appear at the top of
C:\Users\Dell\vms2\vms2\settings\ramandeep.py and in there you
might want DEBUG = True

If so, your settings file when running makemigrations then ought
to be ...

python manage.py makemigrations --settings=vms2.settings.ramandeep

Secondly, the pip install line will never work in any settings
file. It needs to be removed as well.

For the moment, follow the above clues to clean up whatever
settings files might be involved. Then find the SECRET_KEY = line
in base.py and temporarily make it look something like this ...

SECRET_KEY = 'xkshjfsdrhkhdjhkekjrlkj6456k3h46hkljlk'

Once you get everything working you can generate a new secret key
by executing that "pip install ..." line in a command prompt.

There might be a few more things you need to clean up and the
traceback ought to provide hints.

Good luck

Mike




On Thu, Aug 9, 2018 at 12:14 PM, Mike Dewhirst
mailto:mi...@dewhirst.com.au>> wrote:

Ok. If it is saying the secret key is empty and you have
spelled SECRET_KEY correctly and it is not empty then
manage.py is loading the wrong settings.

Does manage.py runserver work?


On 9/08/2018 3:48 PM, Ramandeep Kaur wrote:

Thanks but again getting same error.
PS C:\Users\Dell\vms2> python manage.py makemigrations
--settings=vms2.settings
Traceback (most recent call last):
  File "manage.py", line 10, in 
    execute_from_command_line(sys.argv)
  File
"C:\Python27\lib\site-packages\django\core\management\__init__.py",
line 353, in execute_from_command_line
    utility.execute()
  File
"C:\Python27\lib\site-packages\django\core\management\__init__.py",
line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File
"C:\Python27\lib\site-packages\django\core\management\__init__.py",
line 195, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File
"C:\Python27\lib\site-packages\django\core\management\__init__.py",
line 39, in load_command_class
    module = import_module('%s.management.commands.%s' %
(app_name, name))
  File "C:\Python27\lib\importlib\__init__.py", line 37,
in import_module
    __import__(name)
  File

"C:\Python27\lib\site-packages\django\core\management\commands\makemigrations.py",
line 8, in 
    from django.db.migrations.autodetector import
MigrationAutodetector
  File

"C:\Python27\lib\site-packages\django\db\migrations\autodetector.py",
line 13, in 
    from django.db.migrations.questioner import
MigrationQuestioner
  File
"C:\Python27\lib\site-packages\django\db\migrations\questioner.py",
line 12, in 
    from .loader import MigrationLoader
  File
"C:\Python27\lib\site-packages\django\db\migrations\loader.py",
line 10, in 
    from django.db.migrations.recorder import
MigrationRecor

Required UI designer

2018-08-09 Thread pranay reddy
 Requirements:- JavaScript,css,Ajax, jQuery,html5 and xhtml
Location: Bangalore
Exl techno solutions
Exp package:2-3 lpa
Experience required:0-2 year

Interested cadidates send mail to
pranai.re...@ekatechserv.com or
pranaireddy...@gmail.com

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


Re: Django Generic Date Views

2018-08-09 Thread Michal Petrucha
On Wed, Aug 08, 2018 at 05:42:06AM -0700, Gerald Brown wrote:
> 
> 
> On Wednesday, August 8, 2018 at 8:15:21 PM UTC+8, Jason wrote:
> >
> > what have you tried so far?  What issues are you having with the 
> > documentation examples?
> >
> > "can't get them to work" is really uninformative,  RIGHT.
> >
> 
> What I tried was the TodayArchiveView by following the docs. When I enter 
> http://127.0.0.1:8000/admin/visit/today/ in my browser I get a 404 error
> 
> The code in my views.py file is:
> class PaymentTodayArchiveView(TodayArchiveView):
> vi = Visit.objects.all()
> date_field = "visit_date"
> 
> The code in my URLS.py file is:
> path('today/', PaymentTodayArchiveView, name="today"),
> 
> In the docs is says ".as_view()" should be added to 
> PaymentTodayArchiveView. When I add that I get "AttributeError: 'function' 
> object has no attribute 'as_view'" error.

This exception indicates that you didn't define
PaymentTodayArchiveView as a class, but rather as a function (which is
not consistent with the code you pasted above). As long as
PaymentTodayArchiveView is defined as a subclass of TodayArchiveView,
like in your snippet, you should be able to call ``as_view`` on it.

So yes, using ``PaymentTodayArchiveView.as_view()`` in your URL config
would be correct, as long as the definition of PaymentTodayArchiveView
is correct.

And regarding the name (``queryset`` vs. ``vi``) – the point of using
generic views is that the default implementation of the view supplies
most functionality. Most of the time, you're able to configure what
objects the view operates on by setting certain class attributes in
your customized subclasses. In this case, all of the generic date
views by default look at the ``queryset`` class attribute when they
want to read objects from the database, not ``vi``, which is why you'd
typically use that name in your subclass.

Good luck,

Michal

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


signature.asc
Description: Digital signature


Re: Learning django

2018-08-09 Thread diloudup
There is also a wonderful tutorial on Djangogirls. But it is not quite the 
last version of Django. 

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


data retrival from django db.sqlite3

2018-08-09 Thread ruban bharath
how to retrieve a selected data from django inbuilt database

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


Re: data retrival from django db.sqlite3

2018-08-09 Thread Kasper Laudrup

Hi Ruban,

On 08/09/2018 08:48 AM, ruban bharath wrote:

how to retrieve a selected data from django inbuilt database



If you don't want to use SQL and sqlites client program, you can use the 
dbshell command with django manage, eg.:


# ./manage,py dbshell

Kind regards,

Kasper Laudrup

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


Re: Field forced to not-null

2018-08-09 Thread Phlip Pretorius
Thank you Andréas and Jason

That solved my problem

Regards,

Phlip

On Monday, August 6, 2018 at 3:02:01 PM UTC+2, Andréas Kühne wrote:
>
> Hi Philip,
>
> The field is required because you haven't allowed it to be blank - and 
> django admin requires fields to have the following attributes if you don't 
> require them:
> Active = models.CharField(max_length=1, null=True, blank=True)
>
> Otherwise the GUI will mark the field as required.
> See here: https://docs.djangoproject.com/en/2.1/ref/models/fields/#blank
>
> Regards,
>
> Andréas
>
> 2018-08-06 12:54 GMT+02:00 Phlip Pretorius 
> >:
>
>> Hallo,
>>
>> I have created a model that looks like this:
>>
>> 
>> class ActionType(models.Model):
>> """The type of actions that must be taken at a meeting with respect to
>> agenda points e.g. 'Decide', 'Take Note'etc.
>> """
>> AtpCode = models.CharField(max_length=4)
>> AtpDesc = models.CharField(max_length=80, null=False)
>> Active = models.CharField(max_length=1, null=True)
>>
>> class Meta:
>> unique_together = (('AtpCode'),)
>>
>> def __str__(self):
>> """Return a string representation of the model"""
>> return self.AtpCode
>> 
>>
>> I am using SQLite as I am developing.
>>
>> When I deploy this model to SQLite, the Active field is forced to be 
>> non-null although explicitly indicate the null=True.
>>
>> Any idea why this is happening? I have deleted the complete Django 
>> project and started from scratch only to find the same scenario; when I 
>> click save, I get the following message.
>>
>>
>> Any advice will be welcomed.
>>
>> Regards,
>>
>> Phlip
>>
>> -- 
>> You received this message because you are subscribed 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/c897956a-d5c1-42d6-a77c-ec8c46670815%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/d365045e-2f42-4889-880a-840950d6e01c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Generic Date Views

2018-08-09 Thread Gerald Brown
One thing I discovered is that I had the line for the url.py file in my 
top level url.py.  I moved it to myapp/url.p but still same 404 error, 
however no longer get the "has no attribute" error


How do I call this view?  Tried from the browser 
"http://127.0.0.1:8000/today/"; and I get "__init__() takes 1 positional 
argument but 2 were given" error.


Tried "http://127.0.0.1:8000/visit/today/"; and I get 404 error.

In the line "queryset = Visit.objects.all()" won't that select all of 
the records in the database when I only want the records for today which 
I then use to create a reportlab pdf file? Prior to trying to use these 
generic date views I was able to generate the file but only for the 
current date.


Are there any more suggestions?

TIA...

On Thursday, 09 August, 2018 06:14 PM, Michal Petrucha wrote:

On Wed, Aug 08, 2018 at 05:42:06AM -0700, Gerald Brown wrote:


On Wednesday, August 8, 2018 at 8:15:21 PM UTC+8, Jason wrote:

what have you tried so far?  What issues are you having with the
documentation examples?

"can't get them to work" is really uninformative,  RIGHT.


What I tried was the TodayArchiveView by following the docs. When I enter
http://127.0.0.1:8000/admin/visit/today/ in my browser I get a 404 error

The code in my views.py file is:
class PaymentTodayArchiveView(TodayArchiveView):This is exactly as it is in my code and also in the docs except I 
changed Article to Payment.

 vi = Visit.objects.all()I changed vi to queryset and it made NO difference.
 date_field = "visit_date"

The code in my URLS.py file is:
path('today/', PaymentTodayArchiveView, name="today"),

In the docs is says ".as_view()" should be added to
PaymentTodayArchiveView. When I add that I get "AttributeError: 'function'
object has no attribute 'as_view'" error.

This exception indicates that you didn't define
PaymentTodayArchiveView as a class, but rather as a function (which is
not consistent with the code you pasted above). As long as
PaymentTodayArchiveView is defined as a subclass of TodayArchiveView,
like in your snippet, you should be able to call ``as_view`` on it.

So yes, using ``PaymentTodayArchiveView.as_view()`` in your URL config
would be correct, as long as the definition of PaymentTodayArchiveView
is correct.

And regarding the name (``queryset`` vs. ``vi``) – the point of using
generic views is that the default implementation of the view supplies
most functionality. Most of the time, you're able to configure what
objects the view operates on by setting certain class attributes in
your customized subclasses. In this case, all of the generic date
views by default look at the ``queryset`` class attribute when they
want to read objects from the database, not ``vi``, which is why you'd
typically use that name in your subclass.

Good luck,

Michal



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


Re: Django Generic Date Views

2018-08-09 Thread Michal Petrucha
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

On Thu, Aug 09, 2018 at 07:54:29PM +0800, Gerald Brown wrote:
> One thing I discovered is that I had the line for the url.py file in my top
> level url.py.  I moved it to myapp/url.p but still same 404 error, however
> no longer get the "has no attribute" error
> 
> How do I call this view?  Tried from the browser
> "http://127.0.0.1:8000/today/"; and I get "__init__() takes 1 positional
> argument but 2 were given" error.
> 
> Tried "http://127.0.0.1:8000/visit/today/"; and I get 404 error.

I'm afraid you're going to need to provide more detail – how about you
post the full traceback that you're getting?

Also, the question which URL is correct is hard to answer unless you
post all the relevant URL configs.

> In the line "queryset = Visit.objects.all()" won't that select all of the
> records in the database when I only want the records for today which I then
> use to create a reportlab pdf file? Prior to trying to use these generic
> date views I was able to generate the file but only for the current date.

You lost me at the part about reportlab, but ``Visit.objects.all()``
does not actually fetch anything from the database yet. It only
returns a QuerySet that can be processed further (you can add more
filter expressions, set ordering, and whatnot), and only fetches data
if you actually evaluate it (for example by iterating over it).

So you'd typically just set that as the ``queryset`` attribute on a
generic view, and then every time the view is executed, it will take
that unevaluated queryset, add all the necessary filters to only
select items for today, and then fetch those.

Michal
-BEGIN PGP SIGNATURE-
Version: GnuPG v1

iQIcBAEBCgAGBQJbbC7JAAoJEHA7T/IPM/klCh8P/j9iQowdzLeuTNpz5sQpahiU
KhiePgASItMSnKhwFN5Qv++5eV21dl7fViBFPfkQtQ6hNxJXewX8M7kElvr9dmh3
/8GxmkzrW+yuqBgagzNXHOtMi3zvmrFxkiwR6vKcMoTJUR8jsMFnvvkpeCEqFJas
vj7kCbNPJ26GuIWCvFkmtBf2wpd18L49EuPly88nqt+R5tLNNzZ9h9hHzLB8Jr7f
Lq6m397Rxz9oAk/tXw7XFiOB/tIm3jG77XUGYzhv424qEo9a5R1WFOL+s+MoOkdi
wxdb/WEzk9gxf5+v9HtDI3eRYkqaE1WWXQOe7cGTWlDhW/FPXmuI8dSqQOKYbDCL
bNEzcq/bXpIvy0Ot5Ja4RB7OKXBOyd7QElfkF5TTYCyc9JEH8IavwhAtJlL1S6J9
mkzcUjsv9nTqjPqSBBd0bLrNtm5VCyz731w4KvrSHPVTMPJkplkYDWsf1kL6XPEZ
yybYAlMmNF2RA0MelSAjQw3FNAGK2CEXN0Pq+wja3dZs16zv+Y2vhEUhTgFgVmld
KxGmcoULk05UAsbRqboQMBDubfatUxLuGY4MNKARI39T5vLmuzbwkdlv3T0viFVu
OAKIliDdgYP7yUb3uZI1DK1UhgZKxjHTbLt/Es7yGkXFMRYdvJ7pv6TQ69prjrVp
8B5S03RXDeThmAEffLjr
=erht
-END PGP SIGNATURE-

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


Recursive one-to-many foreign key on the same table

2018-08-09 Thread Phlip Pretorius
I want to build a one-to-many recursive foreign key on a table in Django.

The concept is something like this:

Table: staff/person

staff numberSurnameFirstnamesSupervisor
4637ZondoJulien
859076VanderbildtJohn4637

That is, Julien Zondo is John Vanderbildt's supervisor and to enter the 
staff number in the supervisor field, it must exist in the staff table.

Each staff member can have only one supervisor but a person can be the 
supervisor of many staff members.

I have read the documentation at 
https://docs.djangoproject.com/en/2.1/ref/models/fields/#recursive-relationships
 
but i do not get the gist of it

I want to build an index table on three levels where a level 1 index will 
have no predecessor
Level 2 indexes must have a level 1 predecessor and a level 3 index must 
have a level 2 pedecessor.

Can this be done by using recursive relationships or should this be done in 
a business layer?

Here is part of the definition of the model:
=
Class DecisionIndex(models.Model):
"""A mechanism to index decision taken by a committee"""
IndexCode = models.CharField(max_length=6)
IndexDesc = models.CharField(max_length=80, null=False)
IndexLevel = models.IntegerField(choices=list(zip(range(1, 4),
  range(1, 4))),
 null=False)
IndexPredecessor = models.ForeignKey('self',
 on_delete=models.CASCADE,
 limit_choices_to={'IdexLevel': 1},)


I get the following error message:
no such column: komadm_apps_decisionindex.IndexPredecessor_idno such 
column: 

Any help will be welcome.

Regards,

Phlip

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


Re: Recursive one-to-many foreign key on the same table

2018-08-09 Thread Marius Räsener
Hey Philip,

while I can't help you with your actual implementation I wanted to link you 
to this presentation abuot the topic, it's worth time spend I think ...

https://www.youtube.com/watch?v=CRxjoklS8v0&index=7&list=PLY_che_OEsX3aZo5RttI6Fj2XZ7nTjhBu

recursive models are tricky, especially to query afterwards - your example 
might be not super complicated (yet) but still, I recommend the video...

Marius

Am Donnerstag, 9. August 2018 14:42:13 UTC+2 schrieb Phlip Pretorius:
>
> I want to build a one-to-many recursive foreign key on a table in Django.
>
> The concept is something like this:
>
> Table: staff/person
>
> staff numberSurnameFirstnamesSupervisor
> 4637ZondoJulien
> 859076VanderbildtJohn4637
>
> That is, Julien Zondo is John Vanderbildt's supervisor and to enter the 
> staff number in the supervisor field, it must exist in the staff table.
>
> Each staff member can have only one supervisor but a person can be the 
> supervisor of many staff members.
>
> I have read the documentation at 
> https://docs.djangoproject.com/en/2.1/ref/models/fields/#recursive-relationships
>  
> but i do not get the gist of it
>
> I want to build an index table on three levels where a level 1 index will 
> have no predecessor
> Level 2 indexes must have a level 1 predecessor and a level 3 index must 
> have a level 2 pedecessor.
>
> Can this be done by using recursive relationships or should this be done 
> in a business layer?
>
> Here is part of the definition of the model:
>
> =
> Class DecisionIndex(models.Model):
> """A mechanism to index decision taken by a committee"""
> IndexCode = models.CharField(max_length=6)
> IndexDesc = models.CharField(max_length=80, null=False)
> IndexLevel = models.IntegerField(choices=list(zip(range(1, 4),
>   range(1, 4))),
>  null=False)
> IndexPredecessor = models.ForeignKey('self',
>  on_delete=models.CASCADE,
>  limit_choices_to={'IdexLevel': 
> 1},)
>
> 
>
> I get the following error message:
> no such column: komadm_apps_decisionindex.IndexPredecessor_idno such 
> column: 
>
> Any help will be welcome.
>
> Regards,
>
> Phlip
>

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


Re: Recursive one-to-many foreign key on the same table

2018-08-09 Thread Jason
i would look at https://github.com/django-mptt/django-mptt and see if that 
fits your needs.  Sounds like you want to implement a limited level tree 
structure in a db table.  If so, this package is a very good one.

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


issue with bootstrap

2018-08-09 Thread Tosin Ayoola
Halo guyz working on a Django project that requires me using bootstrap but 
the issue I'm having is that I can use the load static to include bootstrap 
@ be base_generic.html, but can't use it with the index page, tried fixing 
it, what should I do, how to i fix this and move on ?

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


i need help

2018-08-09 Thread Aladin Masen


Please how can i use the django_markdown  with django 2

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


How to add a language in Django that its not supported by default?

2018-08-09 Thread Deniz Bazan


Im trying to make a website in 5 languages. The main language should be 
kurdish but it is not supported by Django default. I tried already the how 
to add new languages into Django? 


but it didnt work for me. I receive an error mesagge

**LANG_INFO = dict(django.conf.locale.LANG_INFO.items() + 
EXTRA_LANG_INFO.items())

TypeError: unsupported operand type(s) for +: 'dict_items' and 
'dict_items'**

I also tried already to copy an english *po file* and rename it "ku" 
(kurdish) and i added into django/conf/*init*.py the language info.

'ku': {
'bidi': False,
'code': 'ku',
'name': 'Kurdish',
'name_local': 'Kurdî',},

I can see the language by languages option by template but when i click it 
i receive an error message.

File "/usr/lib/python3.6/gettext.py", line 91, in _tokenizeraise 
ValueError('invalid token in plural form: %s' % value)

ValueError: invalid token in plural form: EXPRESSION

Does anybody know how can i fix it? Thanks so much!

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


Re: New language adding error('Unknown language code si.')

2018-08-09 Thread Deniz Bazan
Hi Kumara, did you  find a solution for your question, because i have same 
problem. 

Am Montag, 30. April 2018 14:04:01 UTC+2 schrieb lakshitha kumara:
>
> Hello Jason,
>
> *Thanks you for your reply but **unfortunately** that example not working 
> any more with django 2 and python 3 .*
>
>
> *Thanks*
> On Monday, April 30, 2018 at 7:47:45 AM UTC+5:30, lakshitha kumara wrote:
>>
>> Hello Guys 
>>
>> I added new language to django . language called Sinhala. My code is look 
>> like this.
>>
>> On settings page 
>>
>> LANGUAGE_CODE = 'en'
>> LANGUAGES = [
>> ('si', _('Sinhala')),
>> ('en', _('English')),
>> ]
>> TIME_ZONE = 'UTC'
>>
>> USE_I18N = True
>>
>> USE_L10N = True
>>
>> USE_TZ = True
>>
>> LOCALE_PATHS = (
>> os.path.join(os.path.dirname(__file__), "../locale"),
>> )
>>
>> On locale folder 
>>
>> __init__.py
>>
>> LANG_INFO = {
>> 'si': {
>> 'bidi': False,
>> 'code': 'si',
>> 'name': 'Sinhala',
>> 'name_local': 'Sinhala',
>> },
>> }
>> I ran this command after that 
>>
>> manage.py makemessages -l si
>> manage.py compilemessages
>>
>>
>> When i goes to admin URL with sinhala language its working fine i try get 
>> all supported language give this error 
>>
>> {% csrf_token %}
>> 
>> 
>> {% get_current_language as LANGUAGE_CODE %}
>> {% get_available_languages as LANGUAGES %}
>> {% get_language_info_list for LANGUAGES as languages %}
>> {% for language in languages %}
>> > LANGUAGE_CODE %} selected{% endif %}>
>> {{ language.name_local }} ({{ language.code }})
>> 
>> {% endfor %}
>> 
>> 
>> 
>>
>>

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


Re: Recursive one-to-many foreign key on the same table

2018-08-09 Thread Tosin Ayoola
thanks for the response but can you help me go through the code probably
i'm the person making mistake in my code this the github link:
https://github.com/olaneat/ask_the_schools

On Thu, Aug 9, 2018 at 3:00 PM, Marius Räsener  wrote:

> Hey Philip,
>
> while I can't help you with your actual implementation I wanted to link
> you to this presentation abuot the topic, it's worth time spend I think ...
>
> https://www.youtube.com/watch?v=CRxjoklS8v0&index=7&list=PLY_che_
> OEsX3aZo5RttI6Fj2XZ7nTjhBu
>
> recursive models are tricky, especially to query afterwards - your example
> might be not super complicated (yet) but still, I recommend the video...
>
> Marius
>
> Am Donnerstag, 9. August 2018 14:42:13 UTC+2 schrieb Phlip Pretorius:
>>
>> I want to build a one-to-many recursive foreign key on a table in Django.
>>
>> The concept is something like this:
>>
>> Table: staff/person
>>
>> staff numberSurnameFirstnamesSupervisor
>> 4637ZondoJulien
>> 859076VanderbildtJohn4637
>>
>> That is, Julien Zondo is John Vanderbildt's supervisor and to enter the
>> staff number in the supervisor field, it must exist in the staff table.
>>
>> Each staff member can have only one supervisor but a person can be the
>> supervisor of many staff members.
>>
>> I have read the documentation at https://docs.djangoproject.com
>> /en/2.1/ref/models/fields/#recursive-relationships but i do not get the
>> gist of it
>>
>> I want to build an index table on three levels where a level 1 index will
>> have no predecessor
>> Level 2 indexes must have a level 1 predecessor and a level 3 index must
>> have a level 2 pedecessor.
>>
>> Can this be done by using recursive relationships or should this be done
>> in a business layer?
>>
>> Here is part of the definition of the model:
>> 
>> =
>> Class DecisionIndex(models.Model):
>> """A mechanism to index decision taken by a committee"""
>> IndexCode = models.CharField(max_length=6)
>> IndexDesc = models.CharField(max_length=80, null=False)
>> IndexLevel = models.IntegerField(choices=list(zip(range(1, 4),
>>   range(1, 4))),
>>  null=False)
>> IndexPredecessor = models.ForeignKey('self',
>>  on_delete=models.CASCADE,
>>  limit_choices_to={'IdexLevel':
>> 1},)
>> 
>> 
>>
>> I get the following error message:
>> no such column: komadm_apps_decisionindex.IndexPredecessor_idno such
>> column:
>>
>> Any help will be welcome.
>>
>> Regards,
>>
>> Phlip
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/bc512a99-625d-4ac1-8a2d-0ffd4a5692be%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/CAHLKn72cYVcYVO%3Dsp7srrSkt2TD8uwa2MMiDP118-pF7g29tHw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Deploying a Frozen Django app over IIS

2018-08-09 Thread Clay Records
Hello,



I’m trying to deploy my Django application to another server so that it can
run over IIS. I can deploy the application just fine when there is a local
installation of Python to use, but I don’t want to require this other
server to download Python just to run this website. I have been using
PyInstaller to freeze my application so that an installation of Python is
included in the project, but this breaks some things required for IIS. My
web.config file can’t point towards a Python executable to run scripts
because it has been lumped into one file with all my other project files,
the wFastCgi that configures the application for IIS doesn’t exist anymore,
and the WSGI Handler fails because the directory path is no longer the same.



Ultimately, I am just confused on how to proceed. Is there a good way to
deployed a frozen Django application over IIS so that the users don’t need
a Python installation? Ideally the .py files would also be hidden so that
they are not editable, but that is not a pressing concern.



Here is a Stack Overflow question I posted that may have more info about my
issue:
https://stackoverflow.com/questions/51756109/deploying-a-frozen-python-application-over-iis



Thank you for your help!



*Clay Records*

Materials Information App Developer

Materials Data Management

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


Re: issue with bootstrap

2018-08-09 Thread Kasper Laudrup

Hi Tosin,

On 09/08/2018 14.52, Tosin Ayoola wrote:


  Halo guyz working on a Django project that requires me using bootstrap
  but the issue I'm having is that I can use the load static to include
  bootstrap @ be base_generic.html, but can't use it with the index
  page, tried fixing it, what should I do, how to i fix this and move on ?



You're question is extremely vague, so it's not really clear how you are 
using bootstrap and what your problem is.


I have personally used django-bootstrap4:

https://django-bootstrap4.readthedocs.io/en/latest/

Which works well in my experience.

If you have problems using it in other templates than your base 
template, remember that you need to load it on every template you use, 
even if it's extending another template that has already loaded the 
template library.


Hope that helps. Otherwise, please provide some more information.

Kind regards,

Kasper Laudrup

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


Re: i need help

2018-08-09 Thread Kasper Laudrup

Hi Aladin,

On 09/08/2018 15.07, Aladin Masen wrote:



Please how can i use the django_markdown  with django 2



You probably can't, since the library seems to be unmaintained and not 
updated for use with Django 2, unless you want to fork it and make the 
changes needed for supporting Django 2.


I have used django-markdownx:

https://neutronx.github.io/django-markdownx/

Which was just fine for my (very basic) requirements.

A better option might be to use django-markup:

https://django-markup.readthedocs.io/en/latest/index.html

I don't have any experience with that, but I plan to look into it.

Hope that helps.

Kind regards,

Kasper Laudrup

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/46ae51c1-773b-8bda-7ecd-167d790654fa%40stacktrace.dk.
For more options, visit https://groups.google.com/d/optout.


Re: Array List

2018-08-09 Thread Kasper Laudrup

Hi Dheeraj,

On 09/08/2018 10.53, Dheeraj Kumar wrote:

Can u tell me please.



Tell you what?

Where to find books or tutorials on how to learn to program in Python?

Not really, since I honestly don't know.

I'm sure there are some very good books and tutorials for learning 
Python for beginners and quite a lot of really awful ones, but I cannot 
really recommend anything.


Try to search for it online or ask in a Python related forum/mailing 
list, then I'm sure someone far more qualified people than me are 
willing to help you.


Help you debug you code?

Sure, but since your problem is not really related to Django, I don't 
think this is the right place to do that.


Post what you have tried so far to a 
forum/subreddit/mailinglist/whatever related to that and I'm sure 
someone will help you.


Write the code for you so you can land a job that you're not qualified for?

Definitely not.

Kind regards,

Kasper Laudrup


On Thu 9 Aug, 2018, 2:15 PM Kasper Laudrup, > wrote:


Hi Dheeraj,

On 08/09/2018 10:31 AM, Dheeraj Kumar wrote:
 > It is a basic question put in interview for python developer where
 > mentioned django too.
 >

Yes, this seems like it should be fairly easy to implement for anyone
with basic experience in Python or any other programming language.

I suggest you pick up a book or online tutorial on Python programming.

Good luck.

Kind regards,

Kasper Laudrup

-- 
You received this message because you are subscribed to the Google

Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to django-users+unsubscr...@googlegroups.com
.
To post to this group, send email to django-users@googlegroups.com
.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit

https://groups.google.com/d/msgid/django-users/fb0cf319-7a8d-a2c8-79f8-0089b2ccd134%40stacktrace.dk.
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/CANwUEV_q1UQz8wbpfHu9VxHdghnLzFQDgzxEwcYpPyVPxxhGHQ%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/bd69d12e-aa44-6c13-5f0a-d54b891dcee1%40stacktrace.dk.
For more options, visit https://groups.google.com/d/optout.


django

2018-08-09 Thread vasu
while running python manage.py runserver 8080 this in cmd ...i am getting 
cant open file 'manage.py' .But i followed the documentation 
properly.help me with 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/399c812e-887c-4b2f-919a-d11e5c0e2709%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


New member: Germano Carella. I need help with django, limit_choices_to and admin interface

2018-08-09 Thread Germano Carella
Hi,
I'm Germano from Italy. I'm new of django.
Probably this discussion has many many examples, but I can't find 
my situation.
I have two models, Book and Chapters.
These are simple models, I need them only for educational purpose.

class Book(models.Model):
title=models.CharField(max_length=250)
chapters = models.ManyToManyField('Chapters')

class Chapters(models.Model):
title_of_chapter = models.CharField(max_length=250)
text=models.TextField()

Now, in admin interface I can add chapters on a new book and it works fine.
So, whdn I try to add a second book I can see chapters of book I added 
previously.

When I add a new book I want see only chapter of this book. List must be 
empty if I'm adding a new book.
It's very simple, but I can't find a way to make it working.

I tried somethings, such as 
chapters= 
models.ManyToManyField('Chapters',limit_choices_to=Q('book__title'=title))
But this not works.
I know Chapters has book_set, that is the set of references for a chapter.

There is a way to make it working? 

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


Re: New member: Germano Carella. I need help with django, limit_choices_to and admin interface

2018-08-09 Thread Julio Biason
Hi Germano,

When you use "ManyToMany", you're saying "any book can have any chapter and
vice versa". That's obviously what you don't want. What you want is "A book
has a closed set of chapters". This is done by thinking a bit on the other
way with Django: Instead of saying "There is a list of chapters of this
book", you say "The chapter belongs to a single book" with a foreign key:

class Book(models.Model):
   title = models.CharField(max_length=250)

class Chapters(models.Model):
   title = models.CharField(max_length=250)
   text = models.TextField()
   book = models.ForeignKey(Book)

Now a chapter can belong only to a book.

On Thu, Aug 9, 2018 at 4:34 PM, Germano Carella 
wrote:

> Hi,
> I'm Germano from Italy. I'm new of django.
> Probably this discussion has many many examples, but I can't find
> my situation.
> I have two models, Book and Chapters.
> These are simple models, I need them only for educational purpose.
>
> class Book(models.Model):
> title=models.CharField(max_length=250)
> chapters = models.ManyToManyField('Chapters')
>
> class Chapters(models.Model):
> title_of_chapter = models.CharField(max_length=250)
> text=models.TextField()
>
> Now, in admin interface I can add chapters on a new book and it works fine.
> So, whdn I try to add a second book I can see chapters of book I added
> previously.
>
> When I add a new book I want see only chapter of this book. List must be
> empty if I'm adding a new book.
> It's very simple, but I can't find a way to make it working.
>
> I tried somethings, such as
> chapters= models.ManyToManyField('Chapters',limit_choices_to=Q('
> book__title'=title))
> But this not works.
> I know Chapters has book_set, that is the set of references for a chapter.
>
> There is a way to make it working?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/2f104d64-50f4-433b-a764-be29d9a77f0c%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/CAEM7gE0rAfJPYbgKxgHCRYwVuAEBGQrz5X2WxOJdOW6mG%3DzK3Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django

2018-08-09 Thread Julio Biason
Hi Vasu,

manage.py should be created when you run "django-admin startproject
". It should also create a directory called "" where
manage.py exists. That's where you should run the runserver command.

On Thu, Aug 9, 2018 at 4:39 PM, vasu  wrote:

> while running python manage.py runserver 8080 this in cmd ...i am getting
> cant open file 'manage.py' .But i followed the documentation
> properly.help me with 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/399c812e-887c-4b2f-919a-d11e5c0e2709%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/CAEM7gE2egO5uivcb64CLtzD%3D30mYCWF5JaeW902FK0%2BNRh2xoA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django

2018-08-09 Thread Welly Iskand
On Friday, August 10, 2018 at 3:54:54 AM UTC+7, vasu wrote:
>
> while running python manage.py runserver 8080 this in cmd ...i am getting 
> cant open file 'manage.py' .But i followed the documentation 
> properly.help me with this
>


hi vasu
you can try use command 
./manage.py runserver
 
regards
welly iskand

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


Re: New member: Germano Carella. I need help with django, limit_choices_to and admin interface

2018-08-09 Thread germano carella

Hi Julio,

Thanks, now is clear.

Ok, I created models correctly and createa book in admin interface. Now 
I can create chapters to add this book.


Now I want to learn how to create an interface that allows an user to 
add a new book, click on next button and add chapters to this book that 
is selected by default in book select list.


Can you point me in a tutorial, or document?

Thanks in advance,

Germano


Il 09/08/2018 22:59, Julio Biason ha scritto:

Hi Germano,

When you use "ManyToMany", you're saying "any book can have any 
chapter and vice versa". That's obviously what you don't want. What 
you want is "A book has a closed set of chapters". This is done by 
thinking a bit on the other way with Django: Instead of saying "There 
is a list of chapters of this book", you say "The chapter belongs to a 
single book" with a foreign key:


class Book(models.Model):
   title = models.CharField(max_length=250)

class Chapters(models.Model):
   title = models.CharField(max_length=250)
   text = models.TextField()
   book = models.ForeignKey(Book)

Now a chapter can belong only to a book.

On Thu, Aug 9, 2018 at 4:34 PM, Germano Carella 
mailto:germano.care...@gmail.com>> wrote:


Hi,
I'm Germano from Italy. I'm new of django.
Probably this discussion has many many examples, but I can't find
my situation.
I have two models, Book and Chapters.
These are simple models, I need them only for educational purpose.

class Book(models.Model):
    title=models.CharField(max_length=250)
    chapters = models.ManyToManyField('Chapters')

class Chapters(models.Model):
    title_of_chapter = models.CharField(max_length=250)
    text=models.TextField()

Now, in admin interface I can add chapters on a new book and it
works fine.
So, whdn I try to add a second book I can see chapters of book I
added previously.

When I add a new book I want see only chapter of this book. List
must be empty if I'm adding a new book.
It's very simple, but I can't find a way to make it working.

I tried somethings, such as
chapters=
models.ManyToManyField('Chapters',limit_choices_to=Q('book__title'=title))
But this not works.
I know Chapters has book_set, that is the set of references for a
chapter.

There is a way to make it working?
-- 
You received this message because you are subscribed to the Google

Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to django-users+unsubscr...@googlegroups.com
.
To post to this group, send email to django-users@googlegroups.com
.
Visit this group at https://groups.google.com/group/django-users
.
To view this discussion on the web visit

https://groups.google.com/d/msgid/django-users/2f104d64-50f4-433b-a764-be29d9a77f0c%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/CAEM7gE0rAfJPYbgKxgHCRYwVuAEBGQrz5X2WxOJdOW6mG%3DzK3Q%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/56a615c7-da95-c0b4-2079-a3b581e43c39%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Array List

2018-08-09 Thread Mike Dewhirst

On 10/08/2018 4:41 AM, Kasper Laudrup wrote:

Hi Dheeraj,

On 09/08/2018 10.53, Dheeraj Kumar wrote:

Can u tell me please.



Tell you what?

Where to find books or tutorials on how to learn to program in Python?

Not really, since I honestly don't know.

I'm sure there are some very good books and tutorials for learning 
Python for beginners and quite a lot of really awful ones, but I 
cannot really recommend anything.


www.diveintopython3.net/



Try to search for it online or ask in a Python related forum/mailing 
list, then I'm sure someone far more qualified people than me are 
willing to help you.


Help you debug you code?

Sure, but since your problem is not really related to Django, I don't 
think this is the right place to do that.


Post what you have tried so far to a 
forum/subreddit/mailinglist/whatever related to that and I'm sure 
someone will help you.


Write the code for you so you can land a job that you're not qualified 
for?


Definitely not.

Kind regards,

Kasper Laudrup


On Thu 9 Aug, 2018, 2:15 PM Kasper Laudrup, > wrote:


    Hi Dheeraj,

    On 08/09/2018 10:31 AM, Dheeraj Kumar wrote:
 > It is a basic question put in interview for python developer 
where

 > mentioned django too.
 >

    Yes, this seems like it should be fairly easy to implement for 
anyone

    with basic experience in Python or any other programming language.

    I suggest you pick up a book or online tutorial on Python 
programming.


    Good luck.

    Kind regards,

    Kasper Laudrup

    --     You received this message because you are subscribed to 
the Google

    Groups "Django users" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to django-users+unsubscr...@googlegroups.com
    .
    To post to this group, send email to django-users@googlegroups.com
    .
    Visit this group at https://groups.google.com/group/django-users.
    To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/fb0cf319-7a8d-a2c8-79f8-0089b2ccd134%40stacktrace.dk.
    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/CANwUEV_q1UQz8wbpfHu9VxHdghnLzFQDgzxEwcYpPyVPxxhGHQ%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/5b98463e-9a19-659a-ea68-24d46fc6d8bf%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Multi Tenancy

2018-08-09 Thread Andrew Fam
Hi all, I have a saas solution currently sitting in 1 instance using a 
postgres db.
Due to recent expansions, I need to keep the data in the country of which 
it came from. e.g Malaysia or Philippines will have a database of their 
own. 
In addition, some companies are asking for on - prem versions and I was 
thinking it might be good for them to own their database while we keep the 
application server.
Does anyone have an idea of how to solve this issue and what is the most 
elegant way of doing this?

Some background to this.
I have a tenant model that is storing the country using countryfield.
Some models directly link to the tenant model, others reference a field 
which is tied to a model with the tenant model.


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


Re: Multi Tenancy

2018-08-09 Thread Mike Dewhirst

On 10/08/2018 11:45 AM, Andrew Fam wrote:
Hi all, I have a saas solution currently sitting in 1 instance using a 
postgres db.
Due to recent expansions, I need to keep the data in the country of 
which it came from. e.g Malaysia or Philippines will have a database 
of their own.
In addition, some companies are asking for on - prem versions and I 
was thinking it might be good for them to own their database while we 
keep the application server.
Does anyone have an idea of how to solve this issue and what is the 
most elegant way of doing this?


It is an interesting problem I'm going to have to solve one day. So no I 
can't help but I'll watch this thread.


I'm particularly interested in security aspects.




Some background to this.
I have a tenant model that is storing the country using countryfield.
Some models directly link to the tenant model, others reference a 
field which is tied to a model with the tenant model.



--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to django-users+unsubscr...@googlegroups.com 
.
To post to this group, send email to django-users@googlegroups.com 
.

Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/be6fb573-50fa-4f48-be37-712d1a279859%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/a0162458-4f5f-5e2d-d3c9-9127cc73a3a3%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: Multi Tenancy

2018-08-09 Thread Andrew Fam
Yeah it'll be good to leave some ideas here so that ppl don't have to make 
painful changes down the line to fit the system later.
The current solutions require too much work and are not that flexible.


On Friday, August 10, 2018 at 10:32:47 AM UTC+8, Mike Dewhirst wrote:
>
> On 10/08/2018 11:45 AM, Andrew Fam wrote:
>
> Hi all, I have a saas solution currently sitting in 1 instance using a 
> postgres db. 
> Due to recent expansions, I need to keep the data in the country of which 
> it came from. e.g Malaysia or Philippines will have a database of their 
> own. 
> In addition, some companies are asking for on - prem versions and I was 
> thinking it might be good for them to own their database while we keep the 
> application server.
> Does anyone have an idea of how to solve this issue and what is the most 
> elegant way of doing this?
>
>
> It is an interesting problem I'm going to have to solve one day. So no I 
> can't help but I'll watch this thread. 
>
> I'm particularly interested in security aspects.
>
>
>
> Some background to this.
> I have a tenant model that is storing the country using countryfield.
> Some models directly link to the tenant model, others reference a field 
> which is tied to a model with the tenant model.
>
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users...@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/be6fb573-50fa-4f48-be37-712d1a279859%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/3dccb4bb-b72a-4b53-a36c-85a99e67e0ae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


ValueError at /api/list/ invalid literal for int() with base 10: '35/like'

2018-08-09 Thread mounikesh mintu
hey guys when i tried to like  a post in drf i have got in to an error 

models.py

class status(models.Model):
user=models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE, 
null=False)
# user=models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE)

content=models.TextField(blank=True,null=True)

image=models.ImageField(upload_to="upload",null=True,blank=True)
updated=models.DateTimeField(auto_now=True)
time=models.DateTimeField(auto_now_add=True)

likes=models.ManyToManyField(settings.AUTH_USER_MODEL,blank=True,related_name='post_likes')

def __str__(self):
return self.content

serilaizers

serializers.py

class statusSerializer(serializers.ModelSerializer):
# user_name = serializers.ReadOnlyField(source='user.username')
user=UserPublicSerializer(read_only=True)
# rating=RatingSerializer(required=False)
# rating=RatingSerializer()

class Meta:
model=status
fields=['id','user','content','image','likes']

views.py

@api_view(['POST'])def LikesApi(self,request,id):
# status = get_object_or_404(id=request.POST.get('id', ''))
status = get_object_or_404(id=id)

status.likes.add(request.user)
serializer = statusSerializer(status)
return Response(serializer.data, status=status.HTTP_201_CREATED)

i have tried both the ways with regards of that question from stack

@api_view(['POST'])def LikesApi(self,request,id):
serializer=statusSerializer(data=request.DATA)
if serializer.is_valid():

serializer.object.content_object=get_object_or_404(status,id=request.POST.get('id',
 ''))
serializer.object.likes.add(request.user)
serializer.save()
return  RestResponse(serializer.data, status=status.HTTP_201_CREATED)
return RestResponse(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

here is my urls.py

urlpatterns = [
# url(r'^$/', StatusListSearchApi.as_view()),
url(r'^list/', StatusListSearchApi.as_view()),
url(r'^user/', UserPost.as_view()),

url(r'^like/(?P\d+)/$',LikesApi),

post objects are present in my api/list/ url

http://127.0.0.1:8000/api/list/like?id=35

when i fired this url i cant see any incremination of likes in my 
browasable api detailview

http://127.0.0.1:8000/api/like?id=35

tried this as well but rather got a page not found 404 error

but when i tried 

this url pattern

http://127.0.0.1:8000/api/list/?id=35/like

i have got that value error 

please can anyone help me

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


Re: Multi Tenancy

2018-08-09 Thread Mike Dewhirst

On 10/08/2018 12:36 PM, Andrew Fam wrote:
Yeah it'll be good to leave some ideas here so that ppl don't have to 
make painful changes down the line to fit the system later.

The current solutions require too much work and are not that flexible.


On Friday, August 10, 2018 at 10:32:47 AM UTC+8, Mike Dewhirst wrote:

On 10/08/2018 11:45 AM, Andrew Fam wrote:

Hi all, I have a saas solution currently sitting in 1 instance
using a postgres db.
Due to recent expansions, I need to keep the data in the country
of which it came from. e.g Malaysia or Philippines will have a
database of their own.
In addition, some companies are asking for on - prem versions and
I was thinking it might be good for them to own their database
while we keep the application server.
Does anyone have an idea of how to solve this issue and what is
the most elegant way of doing this?




Don't know about your application but mine generates its main benefit 
for clients in sharing the public side of their information while 
keeping their proprietary info safe. That means some models in the 
public schema and some in private/tenant schemas. Django will let me do 
that if I understand the router docs correctly. However, some clients 
want all their data in their own private database and shared publically 
via their own website. That is a retrograde solution so it means when 
they discover that they really want to put their public facing info into 
the main public database I'll need a REST API so they can publish it.




It is an interesting problem I'm going to have to solve one day.
So no I can't help but I'll watch this thread.

I'm particularly interested in security aspects.




Some background to this.
I have a tenant model that is storing the country using countryfield.
Some models directly link to the tenant model, others reference a
field which is tied to a model with the tenant model.


-- 
You received this message because you are subscribed to the

Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to django-users...@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/be6fb573-50fa-4f48-be37-712d1a279859%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/3dccb4bb-b72a-4b53-a36c-85a99e67e0ae%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/485c759d-523d-edfe-90dd-e2409410d5a7%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: New member: Germano Carella. I need help with django, limit_choices_to and admin interface

2018-08-09 Thread germano carella

I found a tutorial!

I studied ForeignKey and how it works with sets... Now, I'll learn how 
to create a form and how to save the new data in set.


Thanks!



Il 09/08/2018 22:59, Julio Biason ha scritto:

Hi Germano,

When you use "ManyToMany", you're saying "any book can have any 
chapter and vice versa". That's obviously what you don't want. What 
you want is "A book has a closed set of chapters". This is done by 
thinking a bit on the other way with Django: Instead of saying "There 
is a list of chapters of this book", you say "The chapter belongs to a 
single book" with a foreign key:


class Book(models.Model):
   title = models.CharField(max_length=250)

class Chapters(models.Model):
   title = models.CharField(max_length=250)
   text = models.TextField()
   book = models.ForeignKey(Book)

Now a chapter can belong only to a book.

On Thu, Aug 9, 2018 at 4:34 PM, Germano Carella 
mailto:germano.care...@gmail.com>> wrote:


Hi,
I'm Germano from Italy. I'm new of django.
Probably this discussion has many many examples, but I can't find
my situation.
I have two models, Book and Chapters.
These are simple models, I need them only for educational purpose.

class Book(models.Model):
    title=models.CharField(max_length=250)
    chapters = models.ManyToManyField('Chapters')

class Chapters(models.Model):
    title_of_chapter = models.CharField(max_length=250)
    text=models.TextField()

Now, in admin interface I can add chapters on a new book and it
works fine.
So, whdn I try to add a second book I can see chapters of book I
added previously.

When I add a new book I want see only chapter of this book. List
must be empty if I'm adding a new book.
It's very simple, but I can't find a way to make it working.

I tried somethings, such as
chapters=
models.ManyToManyField('Chapters',limit_choices_to=Q('book__title'=title))
But this not works.
I know Chapters has book_set, that is the set of references for a
chapter.

There is a way to make it working?
-- 
You received this message because you are subscribed to the Google

Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to django-users+unsubscr...@googlegroups.com
.
To post to this group, send email to django-users@googlegroups.com
.
Visit this group at https://groups.google.com/group/django-users
.
To view this discussion on the web visit

https://groups.google.com/d/msgid/django-users/2f104d64-50f4-433b-a764-be29d9a77f0c%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/CAEM7gE0rAfJPYbgKxgHCRYwVuAEBGQrz5X2WxOJdOW6mG%3DzK3Q%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/2cadbc8e-ccdc-2283-9a58-7097c6a4f010%40gmail.com.
For more options, visit https://groups.google.com/d/optout.