I am a newbie at Django and everytime I try to run (myvenv) C:\Users\lenovo> python manage.py startapp blogit gives me the error:
CommandError: 'blog' conflicts with the name of an existing Python module and cannot be used as an app name. Please try another name.
Am I doing something wrong?
You can't run the command from a directory above your project.
you should do this:
cd projectName
python manage.py startapp blog
Related
First I create a new app book and create a model class book, then I messed up with that. I delete that app and create another app and run python3 manage.py runserver.
Then I get this error:
.
I don't add anything in the new app. What can I do now? Is there anything more I want to specify?
project directory and installed apps
enter image description here
after creating any app in django, you need to add it's name to the INSTALLED_APPS inside the settings.py file.
Also make sure to run makemigrations before running migrate command like below:
python manage.py makemigrations
for a specific app:
python manage.py makemigrations <app name>
I'm new to Python and Django. I'm trying to create a user authentication system with Djoser following an online tutorial. I am getting this error "no module named "auth_system"" when I try to run the server to test the connection with Postman.
Is it because of the way that I organized the folders that my "auth_system" file is not recognized?
Also, is the way that I put all the files into the virtual environment folder correct?
Have you added auth_system to installed app in settings file:
INSTALLED_APPS = [
'auth_system',
]
I will give you a quick reference for how to start a django project and review the arranged files.
Be sure that you have properly installed django.
$ python -m django --version
2)Move to the folder where you will create your project and command:
$ django-admin startproject mysite
Where mysite is the name of your project.
The created files of the project mysite will look like the following:
mysite/
manage.py
mysite/
init.py
settings.py
urls.py
asgi.py
wsgi.py
Now you can test if everything is ok
$ python manage.py runserver
July 08, 2021 - 10:28:12 Django version 3.2, using settings
'mysite.settings' Starting development server at
http://127.0.0.1:8000/ Quit the server with CONTROL-C.
4)You can add a project with the next instruction:
$ python manage.py startapp polls
The created directory polls, looks like this:
polls/
init.py
admin.py
apps.py
migrations/
init.py
models.py
tests.py
views.py
Then you can create a superuser like this:
$ python manage.py createsuperuser --username=admin --email=admin#example.com
Or normal users like this (in python prompt):
from django.contrib.auth.models import User
user = User.objects.create_user('user01', 'user01#example.com', 'user01password')
Hope this useful for you!
More information:
https://docs.djangoproject.com/en/3.2/intro/tutorial01/
Trying to get started with Django on pycharm.
(venv) C:\Users\Vince\PycharmProjects\assignment>python manage.py runserver
But I get this error message whenever i run manage.py:
C:\Users\Vince\AppData\Local\Programs\Python\Python37-32\python.exe: can't open file 'manage.py': [Errno 2] No such file or directory
I do have a django directory opened with a manage.py file in it. Can anyone assist me on what to do?
I have tried other solutions, like:
python -vvvvv manage.py runserver
python manage.py migrate
You need to either specify the exact location of the manage.py file. I.e.:
python3 Users/Vince/Desktop/DjangoProject/manage.py runserver
or cd to the directory it's in and run from there.
cd Users/Vince/Desktop/DjangoProject > python manage.py runserver
I'm following an online tutorial in order to learn Django/Python. I'm using PyCharm Community Edition as my IDE. On Windows 10.
When I run python manage.py startapp myapp at the (venv) prompt in terminal window , no error is shown, and \myapp folder is created with the expected content. However, the file db.sqlite3 is not created, and I can't follow through the rest of the tutorial.
What might be going wrong here?
Thank you very much.
when you start a new django app no database must created.
you can run command
python manage.py migrate
to generate database for your project.
default database is sqlite and stored in file named db.sqlite3
Command python manage.py startapp myapp does not create db.sqlite3.
Run:
python manage.py makemigrations
python manage.py migrate
It will automatically create one if not present.
I created a django app on openshift successfully. But, I'm not able to run syncdb using the following deploy hook.
#!/bin/bash
source $OPENSHIFT_HOMEDIR/python/virtenv/bin/activate
cd $OPENSHIFT_REPO_DIR/wsgi/$OPENSHIFT_APP_NAME
python manage.py syncdb --noinput
What could be wrong? Please help!
I think its simply because you forget to add the right for file execution with chmod +x filename