Home > Back-end >  Accessing Database from other location
Accessing Database from other location

Time:02-20

For my job interview, I got assignment to create CRUD with Django and Postgresql. I created database locally and finished my assignment.

Now I have to upload my code to github. The problem is, they asked for some exampled for CRUD. Developer that is reviewing my code obviously can't access my local DB.

What can I do to solve this issue? Do I have to upload my DB to cloud (if so what is the best way to do that)? Or is there any other way to resolve this?

Thanks in advance

CodePudding user response:

When they download your code they would need to create their own local db, run python manage.py makemigrations and python manage.py migrate, then all the db tables will be created. However, there won't be any initial data.

I recommend downloading your code and running through every step it takes to get your project up and running. This would include things like create an admin user, etc. Then create a basic README with all the steps to make it as easy as possible for them to get it up and running.

Alternatively, you could Dockerize your application and provide a Dockerfile, but that's a bit overkill for a take home interview in my opinion. It may impress the interviewer nonetheless. They may not even want to download and run your project, just review your code in Github.

To provide initial data, you would want to look into writing fixtures. Then have them run python manage.py dumpdata to populate the db.

CodePudding user response:

Just upload it to Heroku or something similar. You already have postgres as database so it's valid way. It is pretty straightforward with Heroku's official guide for django applications. I had same issue in my recruitment process and it was a solution that satisfied recruiter.

Database obviously will be empty unless you prepare some fixtures, which is very good idea. Django docs have something for that.

  • Related