django models

105 views
Skip to first unread message

Ramandeep Kaur

unread,
Aug 7, 2018, 1:17:00 PM8/7/18
to Django users
My question is that how to delete models in django?

Christophe Pettus

unread,
Aug 7, 2018, 2:35:32 PM8/7/18
to django...@googlegroups.com

> On Aug 7, 2018, at 10:14, Ramandeep Kaur <hpramand...@gmail.com> wrote:
>
> My question is that how to delete models in django?

Do you need to delete a model *class*, or a model *instance*?

--
-- Christophe Pettus
x...@thebuild.com

Gerald Brown

unread,
Aug 7, 2018, 8:52:48 PM8/7/18
to django...@googlegroups.com

Just delete the code in models.py and run ./manage.py makemigrations and ./manage.py migrate.


On Wednesday, 08 August, 2018 01:14 AM, Ramandeep Kaur wrote:
My question is that how to delete models in 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...@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/42e646fa-af94-4250-b04a-5765e2975c3e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ramandeep Kaur

unread,
Aug 8, 2018, 2:44:42 AM8/8/18
to django...@googlegroups.com
when i run this ./manage.py makemigrations it gives some error. Don't know what to do.

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    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 <module>
    from django.db.migrations.autodetector import MigrationAutodetector
  File "C:\Python27\lib\site-packages\django\db\migrations\autodetector.py", line 13, in <module>
    from django.db.migrations.questioner import MigrationQuestioner
  File "C:\Python27\lib\site-packages\django\db\migrations\questioner.py", line 12, in <module>
    from .loader import MigrationLoader
  File "C:\Python27\lib\site-packages\django\db\migrations\loader.py", line 10, in <module>
    from django.db.migrations.recorder import MigrationRecorder
  File "C:\Python27\lib\site-packages\django\db\migrations\recorder.py", line 12, in <module>
    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_TABLESPACE
  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.

On Wed, Aug 8, 2018 at 6:22 AM, Gerald Brown <gsbr...@gmail.com> wrote:

Just delete the code in models.py and run ./manage.py makemigrations and ./manage.py migrate.


On Wednesday, 08 August, 2018 01:14 AM, Ramandeep Kaur wrote:
My question is that how to delete models in 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+unsubscribe@googlegroups.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+unsubscribe@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Gerald Brown

unread,
Aug 8, 2018, 3:51:24 AM8/8/18
to django...@googlegroups.com

The last line of the error message tells you what to do.  Create a Secret Key in your settings.py file because it says it is now empty.

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.

Balasriharsha Cheeday

unread,
Aug 8, 2018, 9:47:31 AM8/8/18
to Django users
You must have removed the secret key in settings.py file, try re-adding that secret key, then it should work just fine

Ramandeep Kaur

unread,
Aug 8, 2018, 9:51:02 AM8/8/18
to django...@googlegroups.com
I am new at Django so I don't know how to create secret key. please explain me.

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.
--
You received this message because you are subscribed 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.
--
You received this message because you are subscribed 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/CAL18nxmkKT9JPrvxnzQ3n1hs-KXXEUzBSX0YYqr-PP69K_PPJw%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...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Matthew Pava

unread,
Aug 8, 2018, 9:55:52 AM8/8/18
to django...@googlegroups.com

Well, you could generate a SECRET KEY here:

https://www.miniwebtool.com/django-secret-key-generator/

 

Then in your settings.py file you need to add this line:

SECRET_KEY = “[insert secret key here]”

 

https://docs.djangoproject.com/en/dev/ref/settings/#secret-key

Ramandeep Kaur

unread,
Aug 9, 2018, 1:12:25 AM8/9/18
to django...@googlegroups.com
i set the secret key but its again giving me the same errror.
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.

To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.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+unsubscribe@googlegroups.com.


To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

--
You received this message because you are subscribed to the Google Groups "Django users" group.

To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.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+unsubscribe@googlegroups.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+unsubscribe@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

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

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Mike Dewhirst

unread,
Aug 9, 2018, 2:45:23 AM8/9/18
to Django users
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
> PS C:\Users\Dell\vms2> python manage.py makemigrations
> --settings=vms2.settings
> On Thu, Aug 9, 2018 at 11:13 AM, Mike Dewhirst <mi...@dewhirst.com.au
> <mailto:mi...@dewhirst.com.au>> wrote:
>
> On 9/08/2018 3:11 PM, Ramandeep Kaur wrote:
>> i set the secret key but its again giving me the same errror.
>> django.core.exceptions.ImproperlyConfigured: The SECRET_KEY
>> setting must not be empty.
>
> Try running the migrations command with the settings option so
> manage.py can find them.
>
> python manage.py makemigrations --settings=<project.settings>
>
>
>>
>> On Wed, Aug 8, 2018 at 7:24 PM, Matthew Pava
>> <Matthe...@iss.com <mailto:Matthe...@iss.com>> wrote:
>>
>> Well, you could generate a SECRET KEY here:
>>
>> https://www.miniwebtool.com/django-secret-key-generator/
>> <https://www.miniwebtool.com/django-secret-key-generator/>
>>
>> Then in your settings.py file you need to add this line:
>>
>> SECRET_KEY = “[insert secret key here]”
>>
>> https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
>> <https://docs.djangoproject.com/en/dev/ref/settings/#secret-key>
>>
>> *From:*django...@googlegroups.com
>> <mailto:django...@googlegroups.com>
>> [mailto:django...@googlegroups.com
>> <mailto:django...@googlegroups.com>] *On Behalf Of
>> *Ramandeep Kaur
>> *Sent:* Wednesday, August 8, 2018 8:50 AM
>> *To:* django...@googlegroups.com
>> <mailto:django...@googlegroups.com>
>> *Subject:* Re: django models
>> django-users...@googlegroups.com
>> <mailto:django-users...@googlegroups.com>.
>> To post to this group, send email to
>> django...@googlegroups.com
>> <mailto:django...@googlegroups.com>.
>> <https://groups.google.com/group/django-users>.
>> <https://groups.google.com/d/msgid/django-users/42e646fa-af94-4250-b04a-5765e2975c3e%40googlegroups.com?utm_medium=email&utm_source=footer>.
>> For more options, visit
>> https://groups.google.com/d/optout
>> <https://groups.google.com/d/optout>.
>>
>> --
>> You received this message because you are subscribed
>> to the Google Groups "Django users" group.
>> To unsubscribe from this group and stop receiving
>> emails from it, send an email to
>> django-users...@googlegroups.com
>> <mailto:django-users...@googlegroups.com>.
>> To post to this group, send email to
>> django...@googlegroups.com
>> <mailto:django...@googlegroups.com>.
>> <https://groups.google.com/group/django-users>.
>>
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/ebb428c7-b1cd-46e2-e139-9fe96a884353%40gmail.com
>> <https://groups.google.com/d/msgid/django-users/ebb428c7-b1cd-46e2-e139-9fe96a884353%40gmail.com?utm_medium=email&utm_source=footer>.
>>
>>
>>
>> For more options, visit
>> https://groups.google.com/d/optout
>> <https://groups.google.com/d/optout>.
>>
>> --
>> You received this message because you are subscribed
>> to the Google Groups "Django users" group.
>> To unsubscribe from this group and stop receiving
>> emails from it, send an email to
>> django-users...@googlegroups.com
>> <mailto:django-users...@googlegroups.com>.
>> To post to this group, send email to
>> django...@googlegroups.com
>> <mailto:django...@googlegroups.com>.
>> <https://groups.google.com/group/django-users>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAL18nxmkKT9JPrvxnzQ3n1hs-KXXEUzBSX0YYqr-PP69K_PPJw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAL18nxmkKT9JPrvxnzQ3n1hs-KXXEUzBSX0YYqr-PP69K_PPJw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>> For more options, visit
>> https://groups.google.com/d/optout
>> <https://groups.google.com/d/optout>.
>>
>> --
>> You received this message because you are subscribed to
>> the Google Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails
>> from it, send an email to
>> django-users...@googlegroups.com
>> <mailto:django-users...@googlegroups.com>.
>> To post to this group, send email to
>> django...@googlegroups.com
>> <mailto:django...@googlegroups.com>.
>> <https://groups.google.com/group/django-users>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/f04ab2c6-1eea-9430-f05c-a51b4f2d7fc0%40gmail.com
>> <https://groups.google.com/d/msgid/django-users/f04ab2c6-1eea-9430-f05c-a51b4f2d7fc0%40gmail.com?utm_medium=email&utm_source=footer>.
>> For more options, visit
>> https://groups.google.com/d/optout
>> <https://groups.google.com/d/optout>.
>>
>> --
>> You received this message because you are subscribed to the
>> Google Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from
>> it, send an email to
>> django-users...@googlegroups.com
>> <mailto:django-users...@googlegroups.com>.
>> To post to this group, send email to
>> django...@googlegroups.com
>> <mailto:django...@googlegroups.com>.
>> <https://groups.google.com/group/django-users>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAL18nx%3D5uzirrxr0kJAHKZ0B3ubHWo82e7hP5AjRNQO4ZeCRYw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAL18nx%3D5uzirrxr0kJAHKZ0B3ubHWo82e7hP5AjRNQO4ZeCRYw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>> For more options, visit https://groups.google.com/d/optout
>> <https://groups.google.com/d/optout>.
>> --
>> You received this message because you are subscribed to the
>> Google Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from
>> it, send an email to
>> django-users...@googlegroups.com
>> <mailto:django-users...@googlegroups.com>.
>> To post to this group, send email to
>> django...@googlegroups.com
>> <mailto:django...@googlegroups.com>.
>> <https://groups.google.com/group/django-users>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/229da8adeb1d4fe7b006648c29decbcc%40ISS1.ISS.LOCAL
>> <https://groups.google.com/d/msgid/django-users/229da8adeb1d4fe7b006648c29decbcc%40ISS1.ISS.LOCAL?utm_medium=email&utm_source=footer>.
>>
>>
>> For more options, visit https://groups.google.com/d/optout
>> <https://groups.google.com/d/optout>.
>>
>>
>> --
>> You received this message because you are subscribed to the
>> Google Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email to django-users...@googlegroups.com
>> <mailto:django-users...@googlegroups.com>.
>> To post to this group, send email to
>> django...@googlegroups.com <mailto:django...@googlegroups.com>.
>> <https://groups.google.com/group/django-users>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAL18nxnWMzzW57wTv_%3DSutWLkkMyOfTzi3Xd5gu4LSH7N5N3Pg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAL18nxnWMzzW57wTv_%3DSutWLkkMyOfTzi3Xd5gu4LSH7N5N3Pg%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>> For more options, visit https://groups.google.com/d/optout
>> <https://groups.google.com/d/optout>.
>
>

Ramandeep Kaur

unread,
Aug 9, 2018, 3:26:42 AM8/9/18
to django...@googlegroups.com
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


        *From:*django-users@googlegroups.com
        <mailto:django-users@googlegroups.com>
        [mailto:django-users@googlegroups.com
        <mailto:django-users@googlegroups.com>] *On Behalf Of

        *Ramandeep Kaur
        *Sent:* Wednesday, August 8, 2018 8:50 AM
        *To:* django...@googlegroups.com
        <mailto:django-users@googlegroups.com>
                    django-users+unsubscribe@googlegroups.com
                    <mailto:django-users+unsubscrib...@googlegroups.com>.

                    To post to this group, send email to
                    django...@googlegroups.com
                    <mailto:django-users@googlegroups.com>.

                    Visit this group at
                    https://groups.google.com/group/django-users
                    <https://groups.google.com/group/django-users>.
                    To view this discussion on the web visit
                    https://groups.google.com/d/msgid/django-users/42e646fa-af94-4250-b04a-5765e2975c3e%40googlegroups.com
                    <https://groups.google.com/d/msgid/django-users/42e646fa-af94-4250-b04a-5765e2975c3e%40googlegroups.com?utm_medium=email&utm_source=footer>.
                    For more options, visit
                    https://groups.google.com/d/optout
                    <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+unsubscribe@googlegroups.com
                <mailto:django-users+unsubscrib...@googlegroups.com>.

                To post to this group, send email to
                django...@googlegroups.com
                <mailto:django-users@googlegroups.com>.

                Visit this group at
                https://groups.google.com/group/django-users
                <https://groups.google.com/group/django-users>.

                To view this discussion on the web visit
                https://groups.google.com/d/msgid/django-users/ebb428c7-b1cd-46e2-e139-9fe96a884353%40gmail.com
                <https://groups.google.com/d/msgid/django-users/ebb428c7-b1cd-46e2-e139-9fe96a884353%40gmail.com?utm_medium=email&utm_source=footer>.



                For more options, visit
                https://groups.google.com/d/optout
                <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+unsubscribe@googlegroups.com
                <mailto:django-users+unsubscrib...@googlegroups.com>.

                To post to this group, send email to
                django...@googlegroups.com
                <mailto:django-users@googlegroups.com>.

                Visit this group at
                https://groups.google.com/group/django-users
                <https://groups.google.com/group/django-users>.
                To view this discussion on the web visit
                https://groups.google.com/d/msgid/django-users/CAL18nxmkKT9JPrvxnzQ3n1hs-KXXEUzBSX0YYqr-PP69K_PPJw%40mail.gmail.com
                <https://groups.google.com/d/msgid/django-users/CAL18nxmkKT9JPrvxnzQ3n1hs-KXXEUzBSX0YYqr-PP69K_PPJw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
                For more options, visit
                https://groups.google.com/d/optout
                <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

            To post to this group, send email to
            django...@googlegroups.com
            <mailto:django-users@googlegroups.com>.

            Visit this group at
            https://groups.google.com/group/django-users
            <https://groups.google.com/group/django-users>.
            To view this discussion on the web visit
            https://groups.google.com/d/msgid/django-users/f04ab2c6-1eea-9430-f05c-a51b4f2d7fc0%40gmail.com
            <https://groups.google.com/d/msgid/django-users/f04ab2c6-1eea-9430-f05c-a51b4f2d7fc0%40gmail.com?utm_medium=email&utm_source=footer>.
            For more options, visit
            https://groups.google.com/d/optout
            <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

        To post to this group, send email to
        django...@googlegroups.com
        <mailto:django-users@googlegroups.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

        To post to this group, send email to
        django...@googlegroups.com
        <mailto:django-users@googlegroups.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,

    To post to this group, send email to
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@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/011b3128-20de-04b5-2e19-607bbef75059%40dewhirst.com.au.

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

Kasper Laudrup

unread,
Aug 9, 2018, 3:42:40 AM8/9/18
to django...@googlegroups.com
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

Ramandeep Kaur

unread,
Aug 9, 2018, 3:58:35 AM8/9/18
to django...@googlegroups.com
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

# 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

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

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


hi kasper,this is my settings.py


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

Kasper Laudrup

unread,
Aug 9, 2018, 4:03:03 AM8/9/18
to django...@googlegroups.com
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

Mike Dewhirst

unread,
Aug 9, 2018, 4:34:52 AM8/9/18
to django...@googlegroups.com, Ramandeep Kaur
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

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.

Mike Dewhirst

unread,
Aug 9, 2018, 4:55:29 AM8/9/18
to Ramandeep Kaur, Django users
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


Mike Dewhirst

unread,
Aug 9, 2018, 8:26:33 PM8/9/18
to Ramandeep Kaur, Django users
Ramandeep

You need to hit 'Reply all' or 'Reply list' so your message goes to the list and you maximise your chances of getting help.

It looks like you got past the earlier errors with your settings files if you are now seeing a syntax error. If that is the case it is usually best to start a new thread with a new subject line.

Your urls.py file seems to have invalid syntax on line 398 but your excerpt has no line numbers and you did not include that part of the traceback which showed the actual error. It would cost me too much time to go looking for that needle.

Additionally, you haven't told us what version of Django you are using. From your other snippets I can see you are using Windows and Python 2.7 and you are not using virtualenv.

It looks like a sophisticated urls.py which is not consistent with your claimed inexperience with Django. What is the context of your current problems? If we know more about your scenario, our advice can perhaps be better focused for you.

Cheers

Mike

On 10/08/2018 3:15 AM, Ramandeep Kaur wrote:
i am not getting why i am having this error.please help
File "C:\Users\Dell\vms2\vms2\urls.py", line 398
     ^
SyntaxError: invalid syntax

My urls.py is

from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.views.generic import TemplateView
from rest_framework_nested import routers
from rest_auth.views import LogoutView
from locations.views import LocationViewSet
from tasks.views import TaskViewSet, BeneficiaryTasksView, AssignedTasksView, CreatedTasksView, tasks_assign, tasks_smart_assign, FilterTasksView, PaginatedTaskViewSet, get_tasks_length, get_tasks_page_size, export_tasks_view, create_bulk_tasks, import_data_view, get_filtered_tasks_length, PledgedTasksView,create_task
from task_types.views import TaskTypeViewSet
from task_status.views import TaskStatusViewSet
from feedback_types.views import FeedbackTypeViewSet
from organisations.views import OrganisationViewSet
from authentication.views import UserViewSet
from user_profiles.views import *
from forms.views import FormViewSet, FormDataViewSet, DataByFormView, PersistentFormViewSet, PersistentFormDataView,export_filtered_form_data
from training_kits.views import *
from stages.views import StageViewSet
from notes.views import NoteViewSet, BeneficiaryNotesView, CreatedNotesView
from user_messages.views import MessageViewSet, BeneficiaryMessagesView, SentMessagesView
from todos.views import TodoViewSet, AssignedTodosView, CreatedTodosView, BeneficiaryTodosView
from tags.views import (TagViewSet, LightTagViewSet, UserTagsView, UserLightTagsView,
RemoveUserFromTag, RemoveExclusiveTagFromTag,
AddTagToUser, AddTagsToUser, AddExclusiveTagToTag)
from message_templates.views import MessageTemplateViewSet
#from calls.views import CallViewSet, BeneficiaryCallsView, CallerCallsView
from task_status_categories.views import TaskStatusCategoryViewSet, CreatedTaskStatusCategoriesView, getTaskCompletedFlagChoices
#from actions.views import get_action_classes, ActionViewSet
from events.views import EventViewSet
from event_conditions.views import EventConditionViewSet, getEventConditionTypes, HelplineEventConditionsView, NormalEventConditionsView
from hooks.views import HookViewSet
from ivrs.views import IVRViewSet, BeneficiaryIVRsView, SentIVRsView, FeedbackIVRView
from ivr_templates.views import IVRTemplateViewSet
from exotel.views import MissedCall, ExotelViewSet, IncSMS, Lottery, DostPaid, DostMother, DostFather
from guilds.views import GuildViewSet, add_users_to_guild
from notices.views import NoticeViewSet
from spaces.views import SpaceViewSet
from space_types.views import SpaceTypeViewSet, add_spaces
from interests.views import InterestViewSet, LightInterestViewSet, AddInterestsToUser, RemoveInterestsFromUser, UserInterestsView
from pledges.views import PledgeViewSet, TaskPledgesView, UserPledgesView
from party_invitations.views import PartyInvitationViewSet, SentPartyInvitationsView, ReceivedPartyInvitationsView
from task_comments.views import TaskCommentViewSet, TaskCommentDetailedViewSet, TaskCommentsView, CommentedCommentsView
from follows.views import FollowViewSet, FollowerFollowsView, FollowedFollowsView, get_follow
from centers.views import CenterViewSet
from locations.views import LocationViewSet
from kits.views import KitViewSet
from parents.views import ParentViewSet,ParentWorkerListViewSet
from worker.views import WorkerViewSet
from child.views import ChildViewSet
from payments.views import PaymentViewSet,PaymentWorkerListViewSet,PaymentDateListViewSet
#from assessments.views import AssessmentViewSet
from questions.views import QuestionViewSet
#from assessmentreports.views import AssessmentItemViewSet
router = routers.SimpleRouter()
router.register(r'centers',CenterViewSet)
router.register(r'kits',KitViewSet)
router.register(r'parents',ParentViewSet)
router.register(r'workers',WorkerViewSet)
router.register(r'child',ChildViewSet)
#router.register(r'assessments',AssessmentViewSet)
router.register(r'questions',QuestionViewSet)
#router.register(r'assessmentitems',AssessmentItemViewSet)
router.register(r'payments',PaymentViewSet)
router.register(r'locations', LocationViewSet)
router.register(r'tasks', TaskViewSet)
router.register(r'task_types', TaskTypeViewSet)
router.register(r'task_status', TaskStatusViewSet)
router.register(r'feedback_types', FeedbackTypeViewSet)
router.register(r'stages', StageViewSet)
router.register(r'organisations', OrganisationViewSet)
router.register(r'users_model', UserViewSet)
router.register(r'users', UserDetailViewSet)
router.register(r'forms', FormViewSet)
router.register(r'forms-data', FormDataViewSet)
router.register(r'trainingkits', TrainingKitViewSet)
router.register(r'trainingkitpages', TrainingKitPagesViewSet)
router.register(r'pages', PageViewSet)
router.register(r'notes', NoteViewSet)
router.register(r'messages', MessageViewSet)
router.register(r'todos', TodoViewSet)
router.register(r'tags', TagViewSet)
router.register(r'light_tags', LightTagViewSet)
router.register(r'message_templates', MessageTemplateViewSet)
#router.register(r'calls', CallViewSet)
router.register(r'task_status_categories', TaskStatusCategoryViewSet)
router.register(r'events', EventViewSet)
router.register(r'event_conditions', EventConditionViewSet)
router.register(r'hooks', HookViewSet)
#router.register(r'actions', ActionViewSet)
router.register(r'ivrs', IVRViewSet)
router.register(r'ivr_templates', IVRTemplateViewSet)
router.register(r'exotel', ExotelViewSet)
router.register(r'guilds', GuildViewSet)
router.register(r'paginated_tasks', PaginatedTaskViewSet)
router.register(r'notices', NoticeViewSet)
router.register(r'spaces', SpaceViewSet)
router.register(r'space_types', SpaceTypeViewSet)
router.register(r'persistent_forms', PersistentFormViewSet)
router.register(r'interests', InterestViewSet)
router.register(r'light_interests', LightInterestViewSet)
router.register(r'pledges', PledgeViewSet)
router.register(r'party_invitations', PartyInvitationViewSet)
router.register(r'task_comments', TaskCommentViewSet)
router.register(r'task_comments_detailed', TaskCommentDetailedViewSet)
router.register(r'follows', FollowViewSet)
urlpatterns = patterns ('',
url(r'^dbmodels/', include('dbmodels.urls')),
url(r'^signup/$', TemplateView.as_view(template_name="signup.html"),
name='signup'),
url(r'^email-verification/$',
TemplateView.as_view(template_name="email_verification.html"),
name='email-verification'),
url(r'^login/$', TemplateView.as_view(template_name="login.html"),
name='login'),
url(r'^logout/$', LogoutView.as_view(), name='logout'),
url(r'^password-reset/$',
TemplateView.as_view(template_name="password_reset.html"),
name='password-reset'),
url(r'^password-rest/confirm/$',
TemplateView.as_view(template_name="password_reset_confirm.html"),
name='password-reset-confirm'),
url(r'^user-details/$',
TemplateView.as_view(template_name="user_details.html"),
name='user-details'),
url(r'^user-details/edit/$',
TemplateView.as_view(template_name="user_details_edit.html"),
name='user-details-edit'),
url(r'^password-change/$',
TemplateView.as_view(template_name="password_change.html"),
name='password-change'),
url(r'^password-reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', # noqa
TemplateView.as_view(template_name="password_reset_confirm.html"),
name='password_reset_confirm'),
url(r'^accounts/', include('allauth.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^rest-auth/user/(?P<token>\w+)/$',
CustomUserDetailsView.as_view(),
name='rest_user_details_custom'),
url(r'^rest-auth/registration/account-confirm-email/(?P<key>.+)/$',
verifyEmailRedirect,
name='account_confirm_email'),
url(r'^rest-auth/password/reset/confirm/$',
passwordResetConfirmRedirect.as_view()),
url(r'^rest-auth/registration/$',
CustomRegisterView.as_view(),
name='custom_user_register'),
url(r'^rest-auth/registration/', include('rest_auth.registration.urls')),
url(r'^rest-auth/', include('rest_auth.urls')),
url('^api/v1/users/usertype/(?P<user_type>\w+)/$',
UserTypeUserList.as_view(),
name='usertype_user'),
url('^api/v1/users/usertypes/',
UserTypesUserList.as_view(),
name='usertypes_users'),
url('^api/v1/admin/users/(?P<user_id>\w+)/$',
UserManagementAdmin.as_view(),
name='user_management_admin'),
url('^api/v1/user/altmobile/(?P<user_id>\w+)/$',
AlternateNumbersList.as_view(),
name='user_alt_mobile'),
url('^api/v1/users/usertype/$',
getUserTypes,
name='usertypes'),
url('^api/v1/users/guild/(?P<guild_pk>\w+)/$',
GuildMembersList.as_view(),
name='guild_members_list'),
url('^api/v1/trainingkits/pagetypes/$',
getPageContentTypes,
name="trainingkit_pagetypes"),
url('^api/v1/pages/fileupload/$',
PageFileUpload.as_view(),
name='trainingkit_page_fileupload'),
url('^api/v1/form-data/(?P<form_id>\w+)/$', DataByFormView.as_view()),
url('^api/v1/notes/beneficiary/(?P<user_pk>\w+)/$',
BeneficiaryNotesView.as_view(),
name='beneficiary_notes'),
url('^api/v1/notes/creator/(?P<user_pk>\w+)/$',
CreatedNotesView.as_view(),
name='created_notes'),
url('^api/v1/messages/beneficiary/(?P<user_pk>\w+)/$',
BeneficiaryMessagesView.as_view(),
name='beneficiary_messages'),
url('^api/v1/messages/sender/(?P<user_pk>\w+)/$',
SentMessagesView.as_view(),
name='sent_messages'),
url('^api/v1/party_invitations/sender/(?P<sender_pk>\w+)/$',
SentPartyInvitationsView.as_view(),
name='sent_invitations'),
url('^api/v1/party_invitations/invitee/(?P<invitee_pk>\w+)/$',
ReceivedPartyInvitationsView.as_view(),
name='received_invitations'),
url('^api/v1/task_comments_detailed/commentor/(?P<commentor_pk>\w+)/$',
CommentedCommentsView.as_view(),
name='commented_comments'),
url('^api/v1/task_comments_detailed/task/(?P<task_pk>\w+)/$',
TaskCommentsView.as_view(),
name='task_comments'),
url('^api/v1/ivrs/beneficiary/(?P<user_pk>\w+)/$',
BeneficiaryIVRsView.as_view(),
name='beneficiary_ivrs'),
url('^api/v1/ivrs/sender/(?P<user_pk>\w+)/$',
SentIVRsView.as_view(),
name='sent_ivrs'),
url('^api/v1/ivrs/feedback/$',
FeedbackIVRView.as_view(),
name='feedback_ivr'),
url('^api/v1/todos/assignee/(?P<user_pk>\w+)/$',
AssignedTodosView.as_view(),
name='assigned_todos'),
url('^api/v1/todos/creator/(?P<user_pk>\w+)/$',
CreatedTodosView.as_view(),
name='created_todos'),
url('^api/v1/todos/beneficiary/(?P<user_pk>\w+)/$',
BeneficiaryTodosView.as_view(),
name='beneficiary_todos'),
url('^api/v1/tasks/assignee/(?P<user_pk>\w+)/$',
AssignedTasksView.as_view(),
name='assigned_tasks'),
url('^api/v1/tasks/creator/(?P<user_pk>\w+)/$',
CreatedTasksView.as_view(),
name='created_tasks'),
url('^api/v1/tasks/beneficiary/(?P<user_pk>\w+)/$',
BeneficiaryTasksView.as_view(),
name='beneficiary_tasks'),
url('^api/v1/tasks/assign/',
tasks_assign,
name='tasks_assign'),
url('^api/v1/tasks/smart_assign/',
tasks_smart_assign,
name='tasks_smart_assign'),
url('^api/v1/tasks/filter/',
FilterTasksView.as_view(),
name='filter_tasks'),
url('^api/v1/users/filter/',
UserDetailFilterViewSet.as_view(),
name='filter_users'),
url('^api/v1/tasks/length/',
get_tasks_length,
name='tasks_length'),
url('^api/v1/filtered_tasks/length/',
get_filtered_tasks_length,
name='filtered_tasks_length'),
url('^api/v1/tags/user/(?P<user_pk>\w+)/$',
UserTagsView.as_view(),
name='user_tags'),
url('^api/v1/light_tags/user/(?P<user_pk>\w+)/$',
UserLightTagsView.as_view(),
name='user_tags'),
url('^api/v1/follows/follower/(?P<follower_pk>\w+)/$',
FollowerFollowsView.as_view(),
name='follower_follows'),
url('^api/v1/follows/followed/(?P<followed_pk>\w+)/$',
FollowedFollowsView.as_view(),
name='followed_follows'),
url('^api/v1/follows/get_follow/$', get_follow, name='get_follow'),
url('^api/v1/remove_tag/$', RemoveUserFromTag.as_view(), name='remove_tag'),
url('^api/v1/remove_mutually_exclusive_tag/$', RemoveExclusiveTagFromTag.as_view(), name='remove_exclusive_tag'),
url('^api/v1/add_tag/$', AddTagToUser.as_view(), name='add_tag'),
url('^api/v1/add_tags/$', AddTagsToUser.as_view(), name='add_tags'),
url('^api/v1/add_mutually_exclusive_tag/$', AddExclusiveTagToTag.as_view(), name='add_exclusive_tag'),
url('^api/v1/interests/(?P<user_pk>\w+)/$', UserInterestsView.as_view(), name='user_interests'),
url('^api/v1/add_interests/$', AddInterestsToUser.as_view(), name='add_interests'),
url('^api/v1/remove_interests/$', RemoveInterestsFromUser.as_view(), name='remove_interests'),
url('^api/v1/calls/beneficiary/(?P<beneficiary_pk>\w+)/$',
# BeneficiaryCallsView.as_view(),
# name='beneficiary_calls'),
url('^api/v1/calls/caller/(?P<caller_pk>\w+)/$',
# CallerCallsView.as_view(),
# name='caller_calls'),
url('^api/v1/pledges/user/(?P<user_pk>\w+)/$',
UserPledgesView.as_view(),
name='user_pledges'),
url('^api/v1/pledges/task/(?P<task_pk>\w+)/$',
TaskPledgesView.as_view(),
name='task_pledges'),
url('^api/v1/tasks/pledged/(?P<user_pk>\w+)/$',
PledgedTasksView.as_view(),
name='pledged_tasks'),
url('^api/v1/task_status_categories/creator/(?P<user_pk>\w+)/$',
CreatedTaskStatusCategoriesView.as_view(),
name='created_task_status_categories'),
url('^api/v1/task_status_categories/flag_choices/',
getTaskCompletedFlagChoices,
name='task_completed_flag_choices'),
# url('^api/v1/get_action_classes/', get_action_classes),
url('^api/v1/event_conditions/event_condition_types/$',
getEventConditionTypes,
name='event_condition_types'),
url('^api/v1/event_conditions/helpline/$',
HelplineEventConditionsView.as_view(),
name='helpline_event_conditions'),
url('^api/v1/event_conditions/normal/$',
NormalEventConditionsView.as_view(),
name='normal_event_conditions'),
url('^api/v1/missedcall/$', MissedCall.as_view()),
url('^api/v1/incsms/$', IncSMS.as_view()),
url('^api/v1/lottery/$', Lottery.as_view()),
url('^api/v1/dostfather/$', DostFather.as_view()),
url('^api/v1/dostmother/$', DostMother.as_view()),
url('^api/v1/dostpaid/$', DostPaid.as_view()),
url('^api/v1/guilds/add_users/', add_users_to_guild),
url('^api/v1/space_types/add_spaces/', add_spaces),
url('^api/v1/tasks/page_size/', get_tasks_page_size),
url('^api/v1/persistent_form_data/(?P<user_pk>\w+)/$',
PersistentFormDataView.as_view(),
name='persistent_form_data'),
url('^api/v1/tasks/export/$',
export_tasks_view,
name='export_tasks'),
url('^api/v1/tasks/import/$',
import_data_view,
name='import_data'),
url('^api/v1/form/filter/$',
export_filtered_form_data,
name='export_form_data'),
url('^api/v1/tasks/bulk_create/$',
create_bulk_tasks,
name='create_bulk_tasks'),
url('api/v1/tasks/create/$',
create_task,
name='create_task'),
url('^api/v1/payments/worker/(?P<worker>\w+)/$',
PaymentWorkerListViewSet.as_view(),
name='worker_payments'),
url('^api/v1/payments/date/(?P<date>\w+)/$',
PaymentDateListViewSet.as_view(),
name='date_payments'),
url('^api/v1/parents/worker/(?P<worker>\w+)/$',
ParentWorkerListViewSet.as_view(),
name='worker_parents'),
url('^api/v1/', include(router.urls)),
url(r'^.*$',
TemplateView.as_view(template_name="home.html"),
name='home'),
)

Ramandeep Kaur

unread,
Aug 10, 2018, 1:36:46 AM8/10/18
to Mike Dewhirst, Django users
This is 395 line where i am getting the error.

guys,i need your help.whenever i run the makemigrations command and then i am facing error. strange thing is that it indicates the error in line 395 which is in the end where i dont write any code.
PS C:\Users\Dell\vms2> python manage.py makemigrations
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    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\base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 398, in execute
    self.check()
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 426, in check
    include_deployment_checks=include_deployment_checks,
  File "C:\Python27\lib\site-packages\django\core\checks\registry.py", line 75, in run_checks
    new_errors = check(app_configs=app_configs)
  File "C:\Python27\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "C:\Python27\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
    for pattern in resolver.url_patterns:
  File "C:\Python27\lib\site-packages\django\utils\functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Python27\lib\site-packages\django\core\urlresolvers.py", line 417, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "C:\Python27\lib\site-packages\django\utils\functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Python27\lib\site-packages\django\core\urlresolvers.py", line 410, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
  File "C:\Users\Dell\vms2\vms2\urls.py", line 395

     ^
SyntaxError: invalid syntax


Mike Dewhirst

unread,
Aug 10, 2018, 3:29:22 AM8/10/18
to django...@googlegroups.com, Ramandeep Kaur
What version of Django are you using? It looks like an old version.

I'm using 1.11 and patterns is no longer used. Instead, all the url(...), lines are enclosed in a list like this ...

patterns = [
    url(r'^admin/filebrowser/', include(fbsite.urls)),
    url(r'^tinymce/', include('tinymce.urls')),
    url(r'', include('course.urls')),
    url(r'', include('billing.urls')),
]

However, if you are using an old version of Django and it matches your code, using patterns should not matter. I don't know which was the last version to use patterns.

If you decide to upgrade Django, the most modern version you can use is 1.11.15 because that is the last version which supports Python 2.7.

In my experience, the syntax error you are seeing usually indicates mismatched parentheses. The traceback will be counting opening and closing brackets and can only report a missing parenthesis when it gets to the bottom of the code.

You can test my theory here by adding one closing parenthesis at the end to see if the error changes. If it does, you will have to find where the mismatch is and fix it. If not, try adding another one.
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.

Kasper Laudrup

unread,
Aug 10, 2018, 4:09:24 AM8/10/18
to django...@googlegroups.com
Hi Ramandeep,
On 08/10/2018 07:36 AM, Ramandeep Kaur wrote:

> strange thing is that it indicates the error in line 395 which is in
> the end where i dont write any code.

It looks like your error is not closing the call to url() here:

> url('^api/v1/calls/beneficiary/(?P<beneficiary_pk>\w+)/$',
> # BeneficiaryCallsView.as_view(),
> # name='beneficiary_calls'),
> url('^api/v1/calls/caller/(?P<caller_pk>\w+)/$',
> # CallerCallsView.as_view(),
> # name='caller_calls'),

The interpreter will try to look for the matching end ')' and give error
out when it doesn't find that at the end of the file.

Errors like these can indeed be a bit hard to track down. Which editor
are you using?

If you use an editor that understands Python, it can be quite a lot
easier to debug these things in my experience or even avoid them in the
first place.

I heard good things about pycharm, but I don't have any experience with
that myself (I use emacs).

Don't know if that would have helped you here. Just a suggestion.

Kind regards,

Kasper Laudrup

Ramandeep Kaur

unread,
Aug 10, 2018, 9:43:28 AM8/10/18
to Django users
thanks i got my  mistake but now again i am getting an error.
my urls.py:
#from centers.views import CenterViewSet
from locations.views import LocationViewSet
from kits.views import KitViewSet
from parents.views import ParentViewSet,ParentWorkerListViewSet
from worker.views import WorkerViewSet
from child.views import ChildViewSet
from payments.views import PaymentViewSet,PaymentWorkerListViewSet,PaymentDateListViewSet
#from assessments.views import AssessmentViewSet
from questions.views import QuestionViewSet
#from assessmentreports.views import AssessmentItemViewSet

router = routers.SimpleRouter()

#router.register(r'centers',CenterViewSet)
urlpatterns = patterns('',
url('^api/v1/calls/beneficiary/(?P<beneficiary_pk>\w+)/$',
# BeneficiaryCallsView.as_view(),
# name='beneficiary_calls'),
# url('^api/v1/calls/caller/(?P<caller_pk>\w+)/$'),
# CallerCallsView.as_view(),
# name='caller_calls'),

url(r'^.*$',TemplateView.as_view(template_name="home.html"), name='home'), error line
)
)



  File "C:\Users\Dell\vms2\vms2\urls.py", line 392, in <module>
    url(r'^.*$',TemplateView.as_view(template_name="home.html"), name='home'),
TypeError: url() takes at most 5 arguments (29 given)

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

Kasper Laudrup

unread,
Aug 10, 2018, 10:51:52 AM8/10/18
to django...@googlegroups.com
Hi Ramandeep,

The problem is pretty much the same as before: Mismatched parentheses, but I'll leave to you to figure out where. It's pretty easy to spot.

Did you find an editor that helps you syntax check python code?

It'll make your life a lot easier.

Kind regards,

Kasper Laudrup
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

Ramandeep Kaur

unread,
Aug 14, 2018, 2:27:31 AM8/14/18
to Django users
hi guys, i need your help
when i run makemigrations command,  i got error:
django.db.migrations.exceptions.NodeNotFoundError: Migration task_types.0004_tasktype_training_kit dependencies reference nonexistent parent node (u'training_kits', u'0003_auto_20160914_0722')

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.

--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

--
You received this message because you are subscribed 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.

Andréas Kühne

unread,
Aug 14, 2018, 3:20:43 AM8/14/18
to django...@googlegroups.com
Hi,

The error is pretty self explanatory. 

There is a missing migration file:
 (u'training_kits', u'0003_auto_20160914_0722')

So check your training_kits app for a migration that is called 0003_auto_20160914_0722.py.

This migration is a dependency for the migration: 
0004_tasktype_training_kit.py in the task_types app.

Regards,

Andréas

To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.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+unsubscribe@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
Reply all
Reply to author
Forward
0 new messages