Re: manage.py runserver error

2019-09-22 Thread Abu Yusuf
It's a shame to use python2 still now. Try to start your django project
with virtualenvironment with python-3 version.
Try to follow the standard way to get start. Everything will be fine.

On Sun, Sep 22, 2019 at 10:09 AM Pawan Jha 
wrote:

> When I run the Command "manage.py runserver" on the command
> prompt(WINDOWS), I get the following error:
> Traceback (most recent call last):
>   File "C:\Documents and Settings\harsh\Desktop\Django\mysite\manage.py",
> line 22, in 
> execute_from_command_line(sys.argv)
>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
> line 364, in execute_from_command_line
> utility.execute()
>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
> line 308, in execute
> settings.INSTALLED_APPS
>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 56,
> in __getattr__
> self._setup(name)
>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 41,
> in _setup
> self._wrapped = Settings(settings_module)
>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 110,
> in __init__
> mod = importlib.import_module(self.SETTINGS_MODULE)
>   File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
> __import__(name)
> ImportError: Import by filename is not supported.
>
> Please Help Me!!!
>
>
> The same happens when i try to run "python -m django --version":
> Traceback (most recent call last):
>   File "C:\Python27\lib\runpy.py", line 174, in _run_module_as_main
> "__main__", fname, loader, pkg_name)
>   File "C:\Python27\lib\runpy.py", line 72, in _run_code
> exec code in run_globals
>   File "C:\Python27\lib\site-packages\django\__main__.py", line 9, in
> 
> management.execute_from_command_line()
>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
> line 364, in execute_from_command_line
> utility.execute()
>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
> line 308, in execute
> settings.INSTALLED_APPS
>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 56,
> in __getattr__
> self._setup(name)
>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 41,
> in _setup
> self._wrapped = Settings(settings_module)
>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 110,
> in __init__
> mod = importlib.import_module(self.SETTINGS_MODULE)
>   File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
> __import__(name)
> ImportError: Import by filename is not supported.
>
> Please 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1db889b0-e7d7-4c50-a019-3dc660372061%40googlegroups.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACNsr2_2dQz9bbBsovQGnw-MgjTt0af-YUh8C1%3D-DVbPBA0ekg%40mail.gmail.com.


Re: manage.py runserver error

2019-09-22 Thread Ashok Rai
You better try using python 3

On Sun, Sep 22, 2019 at 9:55 AM Pawan Jha  wrote:

> When I run the Command "manage.py runserver" on the command
> prompt(WINDOWS), I get the following error:
> Traceback (most recent call last):
>   File "C:\Documents and Settings\harsh\Desktop\Django\mysite\manage.py",
> line 22, in 
> execute_from_command_line(sys.argv)
>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
> line 364, in execute_from_command_line
> utility.execute()
>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
> line 308, in execute
> settings.INSTALLED_APPS
>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 56,
> in __getattr__
> self._setup(name)
>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 41,
> in _setup
> self._wrapped = Settings(settings_module)
>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 110,
> in __init__
> mod = importlib.import_module(self.SETTINGS_MODULE)
>   File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
> __import__(name)
> ImportError: Import by filename is not supported.
>
> Please Help Me!!!
>
>
> The same happens when i try to run "python -m django --version":
> Traceback (most recent call last):
>   File "C:\Python27\lib\runpy.py", line 174, in _run_module_as_main
> "__main__", fname, loader, pkg_name)
>   File "C:\Python27\lib\runpy.py", line 72, in _run_code
> exec code in run_globals
>   File "C:\Python27\lib\site-packages\django\__main__.py", line 9, in
> 
> management.execute_from_command_line()
>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
> line 364, in execute_from_command_line
> utility.execute()
>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
> line 308, in execute
> settings.INSTALLED_APPS
>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 56,
> in __getattr__
> self._setup(name)
>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 41,
> in _setup
> self._wrapped = Settings(settings_module)
>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 110,
> in __init__
> mod = importlib.import_module(self.SETTINGS_MODULE)
>   File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
> __import__(name)
> ImportError: Import by filename is not supported.
>
> Please 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1db889b0-e7d7-4c50-a019-3dc660372061%40googlegroups.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKo87hqPrJwSqNfyE2mXCtww5JGpcN4bfMZ_5EmoYzj4jBLFig%40mail.gmail.com.


Re: manage.py runserver error

2019-09-22 Thread oba stephen
Did you use "python manage.py runserver" or just "manage.py runserver"?

On Sun, Sep 22, 2019, 5:09 AM Pawan Jha  wrote:

> When I run the Command "manage.py runserver" on the command
> prompt(WINDOWS), I get the following error:
> Traceback (most recent call last):
>   File "C:\Documents and Settings\harsh\Desktop\Django\mysite\manage.py",
> line 22, in 
> execute_from_command_line(sys.argv)
>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
> line 364, in execute_from_command_line
> utility.execute()
>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
> line 308, in execute
> settings.INSTALLED_APPS
>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 56,
> in __getattr__
> self._setup(name)
>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 41,
> in _setup
> self._wrapped = Settings(settings_module)
>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 110,
> in __init__
> mod = importlib.import_module(self.SETTINGS_MODULE)
>   File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
> __import__(name)
> ImportError: Import by filename is not supported.
>
> Please Help Me!!!
>
>
> The same happens when i try to run "python -m django --version":
> Traceback (most recent call last):
>   File "C:\Python27\lib\runpy.py", line 174, in _run_module_as_main
> "__main__", fname, loader, pkg_name)
>   File "C:\Python27\lib\runpy.py", line 72, in _run_code
> exec code in run_globals
>   File "C:\Python27\lib\site-packages\django\__main__.py", line 9, in
> 
> management.execute_from_command_line()
>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
> line 364, in execute_from_command_line
> utility.execute()
>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
> line 308, in execute
> settings.INSTALLED_APPS
>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 56,
> in __getattr__
> self._setup(name)
>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 41,
> in _setup
> self._wrapped = Settings(settings_module)
>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 110,
> in __init__
> mod = importlib.import_module(self.SETTINGS_MODULE)
>   File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
> __import__(name)
> ImportError: Import by filename is not supported.
>
> Please 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1db889b0-e7d7-4c50-a019-3dc660372061%40googlegroups.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAAJsLnqegFt%3D0wqq1AGLzEo7qG6TjQAv%2B8iDo478rWG3fYQtXw%40mail.gmail.com.


openLdap authentication in django

2019-09-22 Thread Ankita Gupta
I am trying to add ldap authentication in my django project using 
(django_python3_ldap) 
after running python manage.py ldap_sync_users i am getting this error 
receive_timeout=settings.LDAP_AUTH_RECEIVE_TIMEOUT,
TypeError: __init__() got an unexpected keyword argument 'receive_timeout'

settings.py 
"""
Django settings for ldap_login project.

Generated by 'django-admin startproject' using Django 2.2.5.

For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""

import os



# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'e93h60d73)mo#8x%q8p0=7mu3%t#!qgfp60xw*5z0+%r22n)n!'

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

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
'django_python3_ldap',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'allauth', # new
'allauth.account', # new
'allauth.socialaccount', # new
'allauth.socialaccount.providers.google', 

   
'pages',
'users',
'crispy_forms',
'bootstrapform',

]
CRISPY_TEMPLATE_PACK = 'bootstrap4'

AUTHENTICATION_BACKENDS = (
"django_python3_ldap.auth.LDAPBackend",
"django.contrib.auth.backends.ModelBackend",
"allauth.account.auth_backends.AuthenticationBackend",
 
)

SITE_ID = 1

ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_USERNAME_REQUIRED = False
AUTH_USER_MODEL = 'users.CustomUser'


LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"handlers": {
"console": {
"class": "logging.StreamHandler",
},
},
"loggers": {
"django_python3_ldap": {
"handlers": ["console"],
"level": "INFO",
},
},
}

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'ldap_login.urls'

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

WSGI_APPLICATION = 'ldap_login.wsgi.application'


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

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


# Password validation
# 
https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 
'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 
'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 
'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 
'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


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

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

 
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/

STATIC_URL = '/static/'


# The URL of the LDAP server.
LDAP_AUTH_URL = "ldap://lab.gdy.club:389";

# Initiate TLS on connection.
LDAP_AUTH_USE_TLS = False

# The LDAP search base for looking up users.
LDAP_AUTH_SEARCH_BASE = "ou=users,dc=lab,dc=gdy,dc=club"

# The LDAP class that represents a user.
LDAP_AUTH_OBJECT_CLASS = "inetOrgPerson"

# User model fields mapped to the LDAP
# attributes that represent them.
LDAP_AUTH_USER_FIELDS = {
"username": "uid",
"first_name": "givenName",
"last_name": "sn",
"email": "mail",
}

# A tuple of django model fields used to uniquely identify a us

openLdap authentication in django

2019-09-22 Thread Ankita Gupta
I am trying to add ldap authentication in my django project using 
(django_python3_ldap) 
after running python manage.py ldap_sync_users i am getting this error 
receive_timeout=settings.LDAP_AUTH_RECEIVE_TIMEOUT,
TypeError: __init__() got an unexpected keyword argument 'receive_timeout'

settings.py 
"""
Django settings for ldap_login project.

Generated by 'django-admin startproject' using Django 2.2.5.

For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""

import os



# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'e93h60d73)mo#8x%q8p0=7mu3%t#!qgfp60xw*5z0+%r22n)n!'

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

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
'django_python3_ldap',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'allauth', # new
'allauth.account', # new
'allauth.socialaccount', # new
'allauth.socialaccount.providers.google', 

   
'pages',
'users',
'crispy_forms',
'bootstrapform',

]
CRISPY_TEMPLATE_PACK = 'bootstrap4'

AUTHENTICATION_BACKENDS = (
"django_python3_ldap.auth.LDAPBackend",
"django.contrib.auth.backends.ModelBackend",
"allauth.account.auth_backends.AuthenticationBackend",
 
)

SITE_ID = 1

ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_USERNAME_REQUIRED = False
AUTH_USER_MODEL = 'users.CustomUser'


LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"handlers": {
"console": {
"class": "logging.StreamHandler",
},
},
"loggers": {
"django_python3_ldap": {
"handlers": ["console"],
"level": "INFO",
},
},
}

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'ldap_login.urls'

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

WSGI_APPLICATION = 'ldap_login.wsgi.application'


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

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


# Password validation
# 
https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 
'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 
'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 
'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 
'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


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

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

 
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/

STATIC_URL = '/static/'


# The URL of the LDAP server.
LDAP_AUTH_URL = "ldap://lab.gdy.club:389";

# Initiate TLS on connection.
LDAP_AUTH_USE_TLS = False

# The LDAP search base for looking up users.
LDAP_AUTH_SEARCH_BASE = "ou=users,dc=lab,dc=gdy,dc=club"

# The LDAP class that represents a user.
LDAP_AUTH_OBJECT_CLASS = "inetOrgPerson"

# User model fields mapped to the LDAP
# attributes that represent them.
LDAP_AUTH_USER_FIELDS = {
"username": "uid",
"first_name": "givenName",
"last_name": "sn",
"email": "mail",
}

# A tuple of django model fields used to uniquely identify a us

Re: convert python 3 to python2

2019-09-22 Thread Ankita Gupta


On Saturday, September 21, 2019 at 11:07:21 PM UTC+5:30, Sipum wrote:
>
> Hi Ankita,
>
> In coming January, python 2 is going to retire. So better to use python 3.
>
Only official access is denied, we can still work in python2. Anyway thanks.

>  
>

> Thanks
>
> On Sat, 21 Sep, 2019, 11:02 PM Ankita Gupta,  > wrote:
>
>> Not related to Django, I have a project made in python3 but due to some 
>> package installation, i need to convert my project to python2. Is there any 
>> method or package to solve 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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/875549f9-5bca-4280-88fd-db197ca577dc%40googlegroups.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/408bd2a0-add7-450d-a004-d5fc22bc4b45%40googlegroups.com.


Re: how to rectify this error

2019-09-22 Thread Sundararajan Seshadri
n you check if the port 8000 is used by something else? 

On Friday, September 20, 2019 at 9:59:58 PM UTC+5:30, idb solutions wrote:
>
> the server isn't running.
>
>

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


setting ForeignKey/OneToOneField in pre_save is not effective - bug?

2019-09-22 Thread Martín Massera
Hi guys I'm posting this here before creating a ticket, not sure if this is 
intended behavior but it looks like a bug to me.

I have a pre_save method that populates a non-nullable OneToOneField in 
case it is not set at save time. 

 class A(Model):

b = models.OneToOneField(B, on_delete=CASCADE)

@staticmethod
def pre_save(sender, instance, **kwargs):
try:
instance.b
except RelatedObjectDoesNotExist:
instance.b = B()
instance.b.save()

pre_save.connect(A.pre_save, A)

Even though the B object gets created and saved, the reference is not saved 
to the instance so I get a "not null constraint failed" error in the 
database.

If I set the field as nullable, of course I don't get the not null error, 
but the property instance.b is still not being updated.

How can I force the update of this property? Is this a bug or intended? 
>From the docs it seems this would be one of the purposes of the pre_save 
signal (ie: the typical "calculate the slug of a field in the pre_save" 
example)
I'm using django 2.2.4

Thanks!

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


Re: how to rectify this error

2019-09-22 Thread Sundararajan Seshadri
Oops...I meant 'can you'.

Alternatively try 8001 or 8002 (or...) in the DOS window and point the 
browser to the corresponding port.

And, yes, migrate command also needs to be run. But that will not affect 
the starting of the server.

---

On Friday, September 20, 2019 at 9:59:58 PM UTC+5:30, idb solutions wrote:
>
> the server isn't running.
>
>

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


Re: setting ForeignKey/OneToOneField in pre_save is not effective - bug?

2019-09-22 Thread Martín Massera
Ok I found the source of the problem, which is the order of assigning and 
saving the b object. Saving first and assigning later works:

b = B()

b.save()

instance.b = b



On Sunday, September 22, 2019 at 10:53:32 AM UTC-3, Martín Massera wrote:
>
> Hi guys I'm posting this here before creating a ticket, not sure if this 
> is intended behavior but it looks like a bug to me.
>
> I have a pre_save method that populates a non-nullable OneToOneField in 
> case it is not set at save time. 
>
>  class A(Model):
>
> b = models.OneToOneField(B, on_delete=CASCADE)
>
> @staticmethod
> def pre_save(sender, instance, **kwargs):
> try:
> instance.b
> except RelatedObjectDoesNotExist:
> instance.b = B()
> instance.b.save()
>
> pre_save.connect(A.pre_save, A)
>
> Even though the B object gets created and saved, the reference is not 
> saved to the instance so I get a "not null constraint failed" error in the 
> database.
>
> If I set the field as nullable, of course I don't get the not null error, 
> but the property instance.b is still not being updated.
>
> How can I force the update of this property? Is this a bug or intended? 
> From the docs it seems this would be one of the purposes of the pre_save 
> signal (ie: the typical "calculate the slug of a field in the pre_save" 
> example)
> I'm using django 2.2.4
>
> Thanks!
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b60e124b-242c-47d2-80f3-825f52fc679a%40googlegroups.com.


Re: manage.py runserver error

2019-09-22 Thread Badal Raina
First, work on python environment and then continue your job


*Badal Raina*


On Sun, 22 Sep 2019 at 15:39, Ashok Rai  wrote:

> You better try using python 3
>
> On Sun, Sep 22, 2019 at 9:55 AM Pawan Jha 
> wrote:
>
>> When I run the Command "manage.py runserver" on the command
>> prompt(WINDOWS), I get the following error:
>> Traceback (most recent call last):
>>   File "C:\Documents and Settings\harsh\Desktop\Django\mysite\manage.py",
>> line 22, in 
>> execute_from_command_line(sys.argv)
>>   File
>> "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
>> 364, in execute_from_command_line
>> utility.execute()
>>   File
>> "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
>> 308, in execute
>> settings.INSTALLED_APPS
>>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 56,
>> in __getattr__
>> self._setup(name)
>>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 41,
>> in _setup
>> self._wrapped = Settings(settings_module)
>>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 110,
>> in __init__
>> mod = importlib.import_module(self.SETTINGS_MODULE)
>>   File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
>> __import__(name)
>> ImportError: Import by filename is not supported.
>>
>> Please Help Me!!!
>>
>>
>> The same happens when i try to run "python -m django --version":
>> Traceback (most recent call last):
>>   File "C:\Python27\lib\runpy.py", line 174, in _run_module_as_main
>> "__main__", fname, loader, pkg_name)
>>   File "C:\Python27\lib\runpy.py", line 72, in _run_code
>> exec code in run_globals
>>   File "C:\Python27\lib\site-packages\django\__main__.py", line 9, in
>> 
>> management.execute_from_command_line()
>>   File
>> "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
>> 364, in execute_from_command_line
>> utility.execute()
>>   File
>> "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
>> 308, in execute
>> settings.INSTALLED_APPS
>>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 56,
>> in __getattr__
>> self._setup(name)
>>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 41,
>> in _setup
>> self._wrapped = Settings(settings_module)
>>   File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 110,
>> in __init__
>> mod = importlib.import_module(self.SETTINGS_MODULE)
>>   File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
>> __import__(name)
>> ImportError: Import by filename is not supported.
>>
>> Please 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/1db889b0-e7d7-4c50-a019-3dc660372061%40googlegroups.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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAKo87hqPrJwSqNfyE2mXCtww5JGpcN4bfMZ_5EmoYzj4jBLFig%40mail.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BMA24YPb7kfUE%2BcO%2BrZT6GoqwRF1AAM8VdXnrmRS%3D_RF3b%3Dfw%40mail.gmail.com.


where to report django issues?

2019-09-22 Thread MW
unlike other github project, there is no "issues" link on

https://github.com/django/django


I'm wondering where to report django (source code) issues?

Thanks.

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


Re: where to report django issues?

2019-09-22 Thread James Schneider
>From the main website: https://code.djangoproject.com/

Also from the FAQ:

https://docs.djangoproject.com/en/2.2/faq/help/#i-think-i-ve-found-a-bug-what-should-i-do

https://docs.djangoproject.com/en/2.2/internals/contributing/bugs-and-features/#reporting-bugs

HTH,

-James

On Sun, Sep 22, 2019, 10:53 AM MW  wrote:

> unlike other github project, there is no "issues" link on
>
> https://github.com/django/django
>
>
> I'm wondering where to report django (source code) issues?
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/2228313e-f816-4386-aa0d-6ebdff5963da%40googlegroups.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciWtPzafHcUqy%3DG7J%2BfGVBq_-jKev4rAX0r2DRqkzPnm%2BQ%40mail.gmail.com.


Re: Nested Model

2019-09-22 Thread Davin Pore
Noted this. Thankyou.


On Thursday, 19 September 2019 19:10:17 UTC+8, Ayser shuhaib wrote:
>
> I’m not sure if I understood your question but for example:
> enterprise.type will give you the value of type.
>
> On Thu, 19 Sep 2019 at 10:00, Davin Pore > 
> wrote:
>
>> [image: API_Box.JPG]
>>
>>
>> On Thursday, 19 September 2019 14:35:03 UTC+8, Davin Pore wrote:
>>>
>>> Seeking for your kind assistance on how to get the value of this using 
>>> nested model on django restapi.
>>>
>>> [image: image.png]
>>> Thank you.
>>>
>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/4a58dd13-7669-40e6-b6c4-1768902ec1fd%40googlegroups.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/22c47009-e9f4-4d77-84ec-bfbf74b10869%40googlegroups.com.


Re: manage.py runserver error

2019-09-22 Thread Sanjeev Shukla
to check version of django use - >django-admin --version

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/73f2844c-7d5a-4bdf-80ca-cec882dcd6ca%40googlegroups.com.


[Django][ Pandas] TypeError: crosstab() missing 1 required positional argument: 'columns'

2019-09-22 Thread Dilipkumar Noone
Hi,

I am new to django.

MyTask:
==
while handling asynchronous task in Django using celery i need to export 
some data to excel and need to create a pivotal table from it,
I am using "crosstab" in pandas.[ 
https://pandas.pydata.org/pandas-docs/version/0.17.0/generated/pandas.crosstab.html
 ]

*I have a data frame[df] like below:*
*df :*

# read the specific columns from an excel file.
require_cols = ['ID', 'Category', 'PatchLeve1', 'HQ Domain Owners', 
'LGSIDomainOwners', 'Ownershipstatus']

# only read the specific columns from an excel file.
df = pd.read_excel(excel_name, use_cols=require_cols)


SerialNo RecordId Category SecurityPatchLevel Applicability Description 
GSP_ID HQDomainOwners LGSIDomainOwners OwnerShipStatus 
1 16 Google Security Patch 2019-02-01 O https://www.collab.com/en/20 
CVE_2019_201920 IT1 IT1   
2 17 Google Security Patch 2019-02-01 O https://www.collab.com/en/21 
CVE_2019_201921 Connectivity-GPS Connectivity-GPS   
3 18 Google Security Patch 2019-02-01 O https://www.collab.com/en/22 
CVE_2019_201922 Media-Framework MM   


===
while executing below statement, cross tab i am getting *TypeError: 
crosstab() missing 1 required positional argument: 'columns'*
===

*gsp_pivoted_table= pd.crosstab([df.Category,df.LGSIDomainOwners],margins=True)*

---

print("crosstab for LGSIDomainOwner and ownership status Count")
gsp_pending_notification = 
pd.crosstab([df.LGSIDomainOwners,df.OwnerShipStatus], margins=True)

return gsp_pivoted_table, gsp_pending_notification;


==



Please let us know how to proceed further.


Regards,
N.Dilip Kumar.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/df08beb7-379f-4a7e-89ca-d5255da18872%40googlegroups.com.


Re: convert python 3 to python2

2019-09-22 Thread Shakil Ahmmed
How Can I Use ['get', 'post', 'put', 'patch', 'delete', 'head', 'options',
'trace'] in One Class

On Sun, Sep 22, 2019 at 4:14 PM Ankita Gupta 
wrote:

>
>
> On Saturday, September 21, 2019 at 11:07:21 PM UTC+5:30, Sipum wrote:
>>
>> Hi Ankita,
>>
>> In coming January, python 2 is going to retire. So better to use python 3.
>>
> Only official access is denied, we can still work in python2. Anyway
> thanks.
>
>>
>>
>
>> Thanks
>>
>> On Sat, 21 Sep, 2019, 11:02 PM Ankita Gupta, 
>> wrote:
>>
>>> Not related to Django, I have a project made in python3 but due to some
>>> package installation, i need to convert my project to python2. Is there any
>>> method or package to solve 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...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/875549f9-5bca-4280-88fd-db197ca577dc%40googlegroups.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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/408bd2a0-add7-450d-a004-d5fc22bc4b45%40googlegroups.com
> 
> .
>


-- 

Shakil Ahmmed
about.me/shakilahmmed


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


Class Based View All Methods

2019-09-22 Thread Shakil Ahmmed
How Can i Use Those Methods In One Class Base View ['get', 'post', 'put', 
'patch', 'delete', 'head', 'options', 'trace']

Example:

from django.views import View

class Home(View):
  def get(self, request, *args, **kwargs):

return HttpResponse('Hello, World!')

def post(self, request, *args, **kwargs):

return HttpResponse('Hello, World!')


def put(self, request, *args, **kwargs):

return HttpResponse('Hello, World!')


def delete(self, request, *args, **kwargs):

return HttpResponse('Hello, World!')

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