Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
216 views
in Technique[技术] by (71.8m points)

python - How to run cloned Django project?

I am a junior software engineer and am quite new to Django. I built this app and am working on a README to explain to others how to fork, clone and setup the app on their own machines. I've gotten stuck while trying to re-create the steps.

This is the order in which I've drawn up the steps:

  1. Fork and clone the repo
  2. Source a virtual environment
  3. Pip install requirements.txt
  4. Obtain access_token and secret_key and store in secrets.sh
  5. Setup a Postgres DB, create user & database
  6. Migrate (?) - This is where I get stuck!

I tried migrating the app but there are no migrations to apply.

I tried django-admin startproject ig_miner_app . but am getting this error code:

CommandError: /Users/Erin/Desktop/CodeByEAllard/project/instagram_miner/manage.py already exists, overlaying a project or app into an existing directory won't replace conflicting files

If I can get this sorted out, I should just be able to run the server like normal, right?

I'm sure I'm missing something (or many things) but don't know what they are. I feel silly because I was obviously able to create the app in the first place, but can't figure out how to explain to someone else to do the same! Does any have suggestions for how to get the server to run?

Thank you!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

First off, you are getting that error because you are starting a project within the same directory as the cloned project, this directory already contains an app with the name ig_miner_app hence the name conflict.

As regards steps to running the project by other users , this should work.

clone the project

git clone https://github.com/erinallard/instagram_miner.git 

create and start a a virtual environment

virtualenv env --no-site-packages

source env/bin/activate

Install the project dependencies:

pip install -r requirements.txt

create a file named "secrets.sh"

touch secrets.sh (mac and linux)

obtain a secret from MiniWebTool key and add to secrets.sh

export SECRET_KEY='<secret_key>'

add secrets.sh to .gitignore file

create a postgres db and add the credentials to settings.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'db_name',
        'USER': 'name',
        'PASSWORD': '',
        'HOST': 'localhost',
        'PORT': '',
    }
}

then run

python manage.py migrate

create admin account

python manage.py createsuperuser

then

python manage.py makemigrations ig_miner_app

to makemigrations for the app

then again run

python manage.py migrate

to start the development server

python manage.py runserver

and open localhost:8000 on your browser to view the app.

I believe this should get the app up and running on others' machines. Let me know if you get stuck on any of these steps so I make edits, if not, you can just use it and add any other relevant info I might not have added.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...