help

51 views
Skip to first unread message

Umar Kambala

unread,
Jul 5, 2018, 7:18:47 AM7/5/18
to django...@googlegroups.com
please this what i had after running my Django-admin startproject myproject

  File "c:\users\admin\appdata\local\programs\python\python36-32\lib\site-packages\django\core\management\__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "c:\users\admin\appdata\local\programs\python\python36-32\lib\site-packages\django\core\management\__init__.py", line 365, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "c:\users\admin\appdata\local\programs\python\python36-32\lib\site-packages\django\core\management\__init__.py", line 216, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "c:\users\admin\appdata\local\programs\python\python36-32\lib\site-packages\django\core\management\__init__.py", line 36, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "c:\users\admin\appdata\local\programs\python\python36-32\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "c:\users\admin\appdata\local\programs\python\python36-32\lib\site-packages\django\core\management\commands\startproject.py", line 1, in <module>
    from django.core.management.templates import TemplateCommand
  File "c:\users\admin\appdata\local\programs\python\python36-32\lib\site-packages\django\core\management\templates.py", line 17, in <module>
    from django.template import Context, Engine
ModuleNotFoundError: No module named 'django.template'

what should i do to debug this error please?

Tim Vogt (Tim Vogt)

unread,
Jul 5, 2018, 7:22:04 AM7/5/18
to django...@googlegroups.com
perhaps run the project with python2 or 
do python manage.py migrate.


--
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/CAPkbFbatt4e_SVMPbWEHk--tBKC8VJR6xYcAEjwEJRjMFwT7Wg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Umar Kambala

unread,
Jul 5, 2018, 7:25:31 AM7/5/18
to django...@googlegroups.com
thanks Mr Tim
i have python 3.6 install on my computer, i try running  python manage.py migrate and this is what i got

C:\Users\Admin\Desktop\Django web>python manage.py migrate
python: can't open file 'manage.py': [Errno 2] No such file or directory

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.

Umar Kambala

unread,
Jul 5, 2018, 7:31:02 AM7/5/18
to django...@googlegroups.com

The problem is in line 17 but I don't know how to go by it

import cgi
import mimetypes
import os
import posixpath
import re
import shutil
import stat
import tempfile
from importlib import import_module
from os import path
from urllib.request import urlretrieve

import django
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from django.core.management.utils import handle_extensions


from django.template import Context, Engine

from django.utils import archive
from django.utils.version import get_docs_version

_drive_re = re.compile('^([a-z]):', re.I)
_url_drive_re = re.compile('^([a-z])[:|]', re.I)

class TemplateCommand(BaseCommand):
    """
    Copy either a Django application layout template or a Django project
    layout template into the specified directory.

    :param style: A color style object (see django.core.management.color).
    :param app_or_project: The string 'app' or 'project'.
    :param name: The name of the application or project.
    :param directory: The directory to which the template should be copied.
    :param options: The additional variables passed to project or app templates
    """
    requires_system_checks = False
    # The supported URL schemes
    url_schemes = ['http', 'https', 'ftp']
    # Can't perform any active locale changes during this command, because
    # setting might not be available at all.
    leave_locale_alone = True
    # Rewrite the following suffixes when determining the target filename.
    rewrite_template_suffixes = (
        # Allow shipping invalid .py files without byte-compilation.
        ('.py-tpl', '.py'),
    )

    def add_arguments(self, parser):
        parser.add_argument('name', help='Name of the application or project.')
        parser.add_argument('directory', nargs='?', help='Optional destination directory')
        parser.add_argument('--template', help='The path or URL to load the template from.')
        parser.add_argument(
            '--extension', '-e', dest='extensions',
            action='append', default=['py'],
            help='The file extension(s) to render (default: "py"). '
                 'Separate multiple extensions with commas, or use '
                 '-e multiple times.'
        )
        parser.add_argument(
            '--name', '-n', dest='files',
            action='append', default=[],
            help='The file name(s) to render. Separate multiple file names '
                 'with commas, or use -n multiple times.'
        )

    def handle(self, app_or_project, name, target=None, **options):
        self.app_or_project = app_or_project
        self.paths_to_remove = []
        self.verbosity = options['verbosity']

        self.validate_name(name, app_or_project)

        # if some directory is given, make sure it's nicely expanded
        if target is None:
            top_dir = path.join(os.getcwd(), name)
            try:
                os.makedirs(top_dir)
            except FileExistsError:
                raise CommandError("'%s' already exists" % top_dir)
            except OSError as e:
                raise CommandError(e)
        else:
            top_dir = os.path.abspath(path.expanduser(target))
            if not os.path.exists(top_dir):
                raise CommandError("Destination directory '%s' does not "
                                   "exist, please create it first." % top_dir)

        extensions = tuple(handle_extensions(options['extensions']))
        extra_files = []
        for file in options['files']:
            extra_files.extend(map(lambda x: x.strip(), file.split(',')))
        if self.verbosity >= 2:
            self.stdout.write("Rendering %s template files with "
                              "extensions: %s\n" %
                              (app_or_project, ', '.join(extensions)))
            self.stdout.write("Rendering %s template files with "
                              "filenames: %s\n" %
                              (app_or_project, ', '.join(extra_files)))

        base_name = '%s_name' % app_or_project
        base_subdir = '%s_template' % app_or_project
        base_directory = '%s_directory' % app_or_project
        camel_case_name = 'camel_case_%s_name' % app_or_project
        camel_case_value = ''.join(x for x in name.title() if x != '_')

        context = Context(dict(options, **{
            base_name: name,
            base_directory: top_dir,
            camel_case_name: camel_case_value,
            'docs_version': get_docs_version(),
            'django_version': django.__version__,
        }), autoescape=False)

        # Setup a stub settings environment for template rendering
        if not settings.configured:
            settings.configure()
            django.setup()

        template_dir = self.handle_template(options['template'],
                                            base_subdir)
        prefix_length = len(template_dir) + 1

        for root, dirs, files in os.walk(template_dir):

            path_rest = root[prefix_length:]
            relative_dir = path_rest.replace(base_name, name)
            if relative_dir:
                target_dir = path.join(top_dir, relative_dir)
                if not path.exists(target_dir):
                    os.mkdir(target_dir)

            for dirname in dirs[:]:
                if dirname.startswith('.') or dirname == '__pycache__':
                    dirs.remove(dirname)

            for filename in files:
                if filename.endswith(('.pyo', '.pyc', '.py.class')):
                    # Ignore some files as they cause various breakages.
                    continue
                old_path = path.join(root, filename)
                new_path = path.join(top_dir, relative_dir,
                                     filename.replace(base_name, name))
                for old_suffix, new_suffix in self.rewrite_template_suffixes:
                    if new_path.endswith(old_suffix):
                        new_path = new_path[:-len(old_suffix)] + new_suffix
                        break  # Only rewrite once

                if path.exists(new_path):
                    raise CommandError("%s already exists, overlaying a "
                                       "project or app into an existing "
                                       "directory won't replace conflicting "
                                       "files" % new_path)

                # Only render the Python files, as we don't want to
                # accidentally render Django templates files
                if new_path.endswith(extensions) or filename in extra_files:
                    with open(old_path, 'r', encoding='utf-8') as template_file:
                        content = template_file.read()
                    template = Engine().from_string(content)
                    content = template.render(context)
                    with open(new_path, 'w', encoding='utf-8') as new_file:
                        new_file.write(content)
                else:
                    shutil.copyfile(old_path, new_path)

                if self.verbosity >= 2:
                    self.stdout.write("Creating %s\n" % new_path)
                try:
                    shutil.copymode(old_path, new_path)
                    self.make_writeable(new_path)
                except OSError:
                    self.stderr.write(
                        "Notice: Couldn't set permission bits on %s. You're "
                        "probably using an uncommon filesystem setup. No "
                        "problem." % new_path, self.style.NOTICE)

        if self.paths_to_remove:
            if self.verbosity >= 2:
                self.stdout.write("Cleaning up temporary files.\n")
            for path_to_remove in self.paths_to_remove:
                if path.isfile(path_to_remove):
                    os.remove(path_to_remove)
                else:
                    shutil.rmtree(path_to_remove)

    def handle_template(self, template, subdir):
        """
        Determine where the app or project templates are.
        Use django.__path__[0] as the default because the Django install
        directory isn't known.
        """
        if template is None:
            return path.join(django.__path__[0], 'conf', subdir)
        else:
            if template.startswith('file://'):
                template = template[7:]
            expanded_template = path.expanduser(template)
            expanded_template = path.normpath(expanded_template)
            if path.isdir(expanded_template):
                return expanded_template
            if self.is_url(template):
                # downloads the file and returns the path
                absolute_path = self.download(template)
            else:
                absolute_path = path.abspath(expanded_template)
            if path.exists(absolute_path):
                return self.extract(absolute_path)

        raise CommandError("couldn't handle %s template %s." %
                           (self.app_or_project, template))

    def validate_name(self, name, app_or_project):
        a_or_an = 'an' if app_or_project == 'app' else 'a'
        if name is None:
            raise CommandError('you must provide {an} {app} name'.format(
                an=a_or_an,
                app=app_or_project,
            ))
        # Check it's a valid directory name.
        if not name.isidentifier():
            raise CommandError(
                "'{name}' is not a valid {app} name. Please make sure the "
                "name is a valid identifier.".format(
                    name=name,
                    app=app_or_project,
                )
            )
        # Check it cannot be imported.
        try:
            import_module(name)
        except ImportError:
            pass
        else:
            raise CommandError(
                "'{name}' conflicts with the name of an existing Python "
                "module and cannot be used as {an} {app} name. Please try "
                "another name.".format(
                    name=name,
                    an=a_or_an,
                    app=app_or_project,
                )
            )

    def download(self, url):
        """
        Download the given URL and return the file name.
        """
        def cleanup_url(url):
            tmp = url.rstrip('/')
            filename = tmp.split('/')[-1]
            if url.endswith('/'):
                display_url = tmp + '/'
            else:
                display_url = url
            return filename, display_url

        prefix = 'django_%s_template_' % self.app_or_project
        tempdir = tempfile.mkdtemp(prefix=prefix, suffix='_download')
        self.paths_to_remove.append(tempdir)
        filename, display_url = cleanup_url(url)

        if self.verbosity >= 2:
            self.stdout.write("Downloading %s\n" % display_url)
        try:
            the_path, info = urlretrieve(url, path.join(tempdir, filename))
        except IOError as e:
            raise CommandError("couldn't download URL %s to %s: %s" %
                               (url, filename, e))

        used_name = the_path.split('/')[-1]

        # Trying to get better name from response headers
        content_disposition = info.get('content-disposition')
        if content_disposition:
            _, params = cgi.parse_header(content_disposition)
            guessed_filename = params.get('filename') or used_name
        else:
            guessed_filename = used_name

        # Falling back to content type guessing
        ext = self.splitext(guessed_filename)[1]
        content_type = info.get('content-type')
        if not ext and content_type:
            ext = mimetypes.guess_extension(content_type)
            if ext:
                guessed_filename += ext

        # Move the temporary file to a filename that has better
        # chances of being recognized by the archive utils
        if used_name != guessed_filename:
            guessed_path = path.join(tempdir, guessed_filename)
            shutil.move(the_path, guessed_path)
            return guessed_path

        # Giving up
        return the_path

    def splitext(self, the_path):
        """
        Like os.path.splitext, but takes off .tar, too
        """
        base, ext = posixpath.splitext(the_path)
        if base.lower().endswith('.tar'):
            ext = base[-4:] + ext
            base = base[:-4]
        return base, ext

    def extract(self, filename):
        """
        Extract the given file to a temporarily and return
        the path of the directory with the extracted content.
        """
        prefix = 'django_%s_template_' % self.app_or_project
        tempdir = tempfile.mkdtemp(prefix=prefix, suffix='_extract')
        self.paths_to_remove.append(tempdir)
        if self.verbosity >= 2:
            self.stdout.write("Extracting %s\n" % filename)
        try:
            archive.extract(filename, tempdir)
            return tempdir
        except (archive.ArchiveException, IOError) as e:
            raise CommandError("couldn't extract file %s to %s: %s" %
                               (filename, tempdir, e))

    def is_url(self, template):
        """Return True if the name looks like a URL."""
        if ':' not in template:
            return False
        scheme = template.split(':', 1)[0].lower()
        return scheme in self.url_schemes

    def make_writeable(self, filename):
        """
        Make sure that the file is writeable.
        Useful if our source is read-only.
        """
        if not os.access(filename, os.W_OK):
            st = os.stat(filename)
            new_permissions = stat.S_IMODE(st.st_mode) | stat.S_IWUSR
            os.chmod(filename, new_permissions)

Tim Vogt (Tim Vogt)

unread,
Jul 5, 2018, 7:42:31 AM7/5/18
to django...@googlegroups.com
do $ls and find the directory where the manage.py file is.
cd.. to go one directory back



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.

Umar Kambala

unread,
Jul 5, 2018, 7:43:31 AM7/5/18
to django...@googlegroups.com
please i wants to uninstall my django and install new one how do i do that?

Kasper Laudrup

unread,
Jul 5, 2018, 7:46:31 AM7/5/18
to django...@googlegroups.com
On 07/05/2018 01:42 PM, Umar Kambala wrote:
> please i wants to uninstall my django and install new one how do i do that?
>

pip uninstall django
pip install django

Umar Kambala

unread,
Jul 5, 2018, 7:49:34 AM7/5/18
to django...@googlegroups.com

Please am sorry am new to django, I don't really understood what u mean

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

Tim Vogt (Tim Vogt)

unread,
Jul 5, 2018, 7:55:13 AM7/5/18
to django...@googlegroups.com
No problem.
Just look inside the current folder where your command line is present.
There is no manage.py 

So to get to the folder where the manage.py is you have to know in wich folder it is.
And with the command line commando’s you can go there.

cd.. is one folder higher
cd project_name_folder  is one folder deeper

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.

Umar Kambala

unread,
Jul 5, 2018, 8:02:57 AM7/5/18
to django...@googlegroups.com

Thanks Mr Tim, I have reinstall new django and everything is working fine now. Thanks for your time and patience am really grateful

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

Umar Kambala

unread,
Jul 6, 2018, 7:13:29 AM7/6/18
to django...@googlegroups.com
please this the error i got when i run python manage.py makemigrations 

 File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 347, in execute
    django.setup()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\registry.py", line 112, in populate
    app_config.import_models()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\config.py", line 198, in import_models
    self.models_module = import_module(models_module_name)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\Admin\Desktop\Django Web\myproject\boards\models.py", line 10, in <module>
    class Topic (models.Model):
  File "C:\Users\Admin\Desktop\Django Web\myproject\boards\models.py", line 13, in Topic
    board = models.ForeignKey(Board, related_name='topics')
TypeError: __init__() missing 1 required positional argument: 'on_delete'


this are the codes

from django.db import models
from django.contrib.auth.models import User


class Board(models.Model):
name = models.CharField(max_length=30, unique=True)
description = models.CharField(max_length=100)


class Topic (models.Model):
subject = models.CharField(max_length=255)
last_updated = models.DateTimeField()
board = models.ForeignKey(Board, related_name='topics')
starter = models.ForeignKey(User, related_name='topics')


class Post(models.Model):
message = models.TextField(max_length=4000)
topic = models.ForeignKey(Topic, related_name='posts')
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(null=True)
created_by = models.ForeignKey(User, related_name='posts')
updated_by = models.ForeignKey(User, null=True, related_name='+')

Gerald Brown

unread,
Jul 6, 2018, 7:28:33 AM7/6/18
to django...@googlegroups.com

In any field that is a ForeignKey you now have to add "on_delete = ???" (there are a number of options to replace the ???). 

See the last line of the error message as it shows you the file and line number of where the error is.

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

Anirudh choudhary

unread,
Jul 6, 2018, 7:39:36 AM7/6/18
to django...@googlegroups.com
Add on_delete = models.CASCADE 
 EVERY WHERE YOU ARE USING FOREIGN KEY

rahul sawra

unread,
Jul 6, 2018, 7:42:33 AM7/6/18
to django...@googlegroups.com
You can Also Use on_delete= models.PROTECT whereever You use ForeignKey!

Umar Kambala

unread,
Jul 6, 2018, 8:15:24 AM7/6/18
to django...@googlegroups.com

Please am sorry, am new to django I hvnt understood what u mean. If u could further explain it to me. Thanks

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.

Umar Kambala

unread,
Jul 6, 2018, 8:17:24 AM7/6/18
to django...@googlegroups.com

Please sorry am new to django, if u could further explain it to me. Thanks

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.

Umar Kambala

unread,
Jul 6, 2018, 8:42:50 AM7/6/18
to django...@googlegroups.com

Please this wat I now hv am I correct?

On_delete = models.PROTECT

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.

Umar Kambala

unread,
Jul 6, 2018, 8:44:18 AM7/6/18
to django...@googlegroups.com

And I still gets de same error

Kasper Laudrup

unread,
Jul 6, 2018, 8:51:03 AM7/6/18
to django...@googlegroups.com
Hi Umar,

On 07/06/2018 02:14 PM, Umar Kambala wrote:
> Please am sorry, am new to django I hvnt understood what u mean. If u
> could further explain it to me. Thanks
>

Which part don't you understand?

I'm far from an expert on relational databases, but you need at least
some understanding of the concept if you want to use models in Django.

If that is the case, I suggest you start by reading the Wikipedia
article on the subject:

https://en.wikipedia.org/wiki/Relational_database

There's a huge difference between using models.PROTECT and
models.CASCADE and you have to understand that difference. If you start
by reading that article, it should hopefully become a bit clearer.

Kind regards,

Kasper Laudrup

Gerald Brown

unread,
Jul 6, 2018, 9:29:31 AM7/6/18
to django...@googlegroups.com

At https://docs.djangoproject.com/en/2.0/ref/models/fields/ it lists a list of various options, and Protect is one of the options so, yes you are correct.  However PROTECT prevents that record from being deleted so you might want to use CASCADE instead of PROTECT.

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.

pushp...@gmail.com

unread,
Jul 6, 2018, 11:02:07 AM7/6/18
to Django users
Hi,
Before migrate you have to run python manage.py makemigrations this command after you will run migrate or runserver.

Avi gehlot

unread,
Jul 6, 2018, 11:21:59 AM7/6/18
to django...@googlegroups.com
Because you run your project pyathon manage.py 
Than this error generate you open your project than >settings scroll down than app name write your project working properly 

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

Avi gehlot

unread,
Jul 6, 2018, 11:22:37 AM7/6/18
to django...@googlegroups.com
Foreign key not working properly 

--
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,
Jul 6, 2018, 11:39:48 AM7/6/18
to django...@googlegroups.com

Anthony Flury

unread,
Jul 9, 2018, 1:16:29 PM7/9/18
to django...@googlegroups.com
On 06/07/18 13:43, Umar Kambala wrote:
>   File
> "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py",
> line 347, in execute

YOU need to add an on_delete argument to every ForeignKey definition -
such as the one in line 13.

Learning to read tracebacks really does help - the error you posted
contains the information you need :

  File "C:\Users\Admin\Desktop\Django Web\myproject\boards\models.py",
line 13, in Topic
    board = models.ForeignKey(Board, related_name='topics')
TypeError: __init__() missing 1 required positional argument: 'on_delete'

Quite often the very last few lines of the error message will tell you
exactly what the error is and which line - in this case :

The error is on line 13 of boards/models.py
The error is in the Topic class
the error is on the line that is : "board = models.ForeignKey(Board,
related_name='topics')"
the actual error is that the line is missing the on_delete argument - it
really is that simple.
--
--
Anthony Flury
email : *Anthon...@btinternet.com*
Twitter : *@TonyFlury <https://twitter.com/TonyFlury/>*

Anthony Flury

unread,
Jul 9, 2018, 1:23:01 PM7/9/18
to django...@googlegroups.com
On 05/07/18 12:49, Umar Kambala wrote:
>
> Please am sorry am new to django, I don't really understood what u mean
>
I know that Tim has helped you in this occassion but  you really do need
to  know how to find your way around a computer

the commands 'ls' and 'cd ..'

are nothing to do with Django - they are basic commands for managing
your file system which will work regardless of whether you use Django or not

I know in a previous answer, someone suggested that you learn some basic
Python knowledge, can I also suggest that you learn some basic console
commands - how to change directory, list files, delete and rename files
how to look at the file details (file size, dates etc). These are all
useful things when you are trying to do development.


> On Jul 5, 2018 11:42 AM, "Tim Vogt (Tim Vogt)" <timt...@gmail.com
> <mailto:timt...@gmail.com>> wrote:
>
> do $ls and find the directory where the manage.py file is.
> cd.. to go one directory back
>
>
>
>> Op 5 jul. 2018, om 13:25 heeft Umar Kambala
>> <umark...@gmail.com <mailto:umark...@gmail.com>> het
>> volgende geschreven:
>>
>> thanks Mr Tim
>> i have python 3.6 install on my computer, i try running python
>> manage.py migrate and this is what i got
>>
>> C:\Users\Admin\Desktop\Django web>python manage.py migrate
>> python: can't open file 'manage.py': [Errno 2] No such file or
>> directory
>>
>> On Thu, Jul 5, 2018 at 4:21 AM, Tim Vogt (Tim Vogt)
>> <timt...@gmail.com <mailto:timt...@gmail.com>> wrote:
>>
>> perhaps run the project with python2 or
>> do python manage.py migrate.
>>
>>
>>> Op 5 jul. 2018, om 13:18 heeft Umar Kambala
>>> <umark...@gmail.com <mailto:umark...@gmail.com>> het
>>> 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/CAPkbFbatt4e_SVMPbWEHk--tBKC8VJR6xYcAEjwEJRjMFwT7Wg%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/C04E4BEF-E8FF-4EF0-936A-69F04E1DD061%40gmail.com
>> <https://groups.google.com/d/msgid/django-users/C04E4BEF-E8FF-4EF0-936A-69F04E1DD061%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/CAPkbFbbQ2ufECP6emgND2LD_fKKk%2BNHuF_KoyWP7c6EN-z3QZw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAPkbFbbQ2ufECP6emgND2LD_fKKk%2BNHuF_KoyWP7c6EN-z3QZw%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/34C036D9-E62B-4441-919B-D9CC2F53F784%40gmail.com
> <https://groups.google.com/d/msgid/django-users/34C036D9-E62B-4441-919B-D9CC2F53F784%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>.
> 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/CAPkbFbbjYhT0joH%2BFxQNuxzaggU9m%3DNN7meTyvC2t7dbMrVLGA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAPkbFbbjYhT0joH%2BFxQNuxzaggU9m%3DNN7meTyvC2t7dbMrVLGA%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.


--
Reply all
Reply to author
Forward
0 new messages