Django project folder doesn’t push to gitlab - django

When I try to push my Django project into my gitlab repository it, all the files gets pushed properly except for the project folder it gets uploaded with a remove icon and text next to it that looks like that: # it 1080bae7

That looks like a submodule, or at least a gitlink (just a SHA1 entry)
Check if you see a .gitmodules in your repo.
If you don't see one, that means you have a nested git repo.
You can
convert that folder (nested repo) into an actual submodule, or
merge the nested repo into your main repo.

I renamed the folder, pushed it and renamed it again.

Related

Azure web app intermittently copying code from tmp to home

I am deploying a Django appication to a Azure Web App via Github Actions. The code is consistently deployed to the tmp folder but is not always copied to wwwroot, even though Oryx deployment logs state that the contents are copied. What causes this intermittent behaviour?
Detecting platforms...
Detected following platforms:
python: 3.8.12
Using intermediate directory '/tmp/8da59cae1f18fde'.
Copying files to the intermediate directory...
Done in 0 sec(s).
Source directory : /tmp/8da59cae1f18fde
Destination directory: /home/site/wwwroot
Python Version: /opt/python/3.8.12/bin/python3.8
Creating directory for command manifest file if it doesnot exist
Removing existing manifest file
Python Virtual Environment: antenv
Creating virtual environment...
Activating virtual environment...
Running pip install...
Content in source directory is a Django app
Running collectstatic...
Done in 18 sec(s).
Not a vso image, so not writing build commands
Preparing output...
Copying files to destination directory '/tmp/_preCompressedDestinationDir'...
Done in 31 sec(s).
Compressing content of directory '/tmp/_preCompressedDestinationDir'...
Copied the compressed output to '/home/site/wwwroot'
Removing existing manifest file
Creating a manifest file...
Manifest file created.
Done in 244 sec(s).
For others that may be struggling with this same issue, specifically with Django applications, I have landed on the following workaround:
After learning more about how Oryx build actually works, I now understand that the code IS copied to wwwroot - but as a tarball. The code is then extracted to tmp and executed in this folder. This causes a challenge running django migrations as the migration folder is not persistent at the location where the code is run from, i.e. you are not able to run migrations automatically from the tmp folder (because, assuming you are not putting your migrations in source control, there is no migration history here.) and you are not able to run migrations from wwwroot (because the new code only exists in the tarball). So, in order to persist migration history you will need to:
Extract output.tar.gz in its entirety to wwwroot and overwrite existing files.
OR
Do 1. ONCE in order to get your project structure ready to perform migrations in wwwroot, and after this copy only the files needed to detect database changes (in my case settings.py, forms.py, models.py and admin.py) from tmp to wwwroot. This can be done automatically by editing the startup command.

Not able to ignore static files from getting pushed to git in Django project

I had pushed a new Django project BTRE to my git repository. But I can't ignore the static files from pushed to the repository even though I have mentioned the directories in .gitignore file.
-BTRE_Project
|-btre
|-static
This is my .gitignore file:
# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/
# in your Git repository. Update and uncomment the following line accordingly.
btre/static/
I have tried deleting the repository and pushing again after updating the .gitignore file.
if you want to ignore your static folder and all the files inside static folder than put this in your .gitignore file
static/
this will ignore static directory and files inside that
You can add ignore by adding the folder path in .gitignore file also use git lfs if you want to commit static files.

Github pages 404, not loading repository content

I created chineseantiquebuyers/chineseantiquebuyers.github.io repository, cloned it first then pushed dummy index.html but when checking chineseantiquebuyers.github.io I have 404.
Any idea how to fix it?
I tried few different things like, putting files in /docs directory, creating branch gh-pages, and dropping files from some jekyll project.
After dropping jekyll files I finally achieved not having 404 but repository content displayed.
I don't know what issue was.

"github" and "git heroku" easy way to keep both

Until now I used svn as source control. At this time I have started a new project and it is stored on gitHub.
Issue is that Heroku and GitHub, both use git. First one to publish app and second one for version control.
My app schema is:
base-dir <--github base
some-text-files (Readme, ... )
django-project-dir <--heroku base
manage.py
main-app-dir
settings.py
other-app-dirs
views.py
models.py
When I push to gitHub base-dir and all subfolders are pushed.
To Heroku only django-project-dir should be pushed.
Notice: I have tried to create a new git repository at django-project-dir level but git take it as a submodule and excluded from gitHub.
Because this is a new project I can easily change to another schema dirs.
My question:
What is the easy way to coexist both Heroku and GitHub git configurations?
Your best option is probably to push the full repository to Heroku, but make sure Heroku ignores all files not required to run your application (see https://devcenter.heroku.com/articles/slug-compiler). Alternatively, consider creating two repositories (one for documentation and one for production code).
Your best bet is to move you readme and other files to your project root. Then just add GitHub as a separate remote (when you're in your project directory).
git remote add origin https://github.com/USERNAME/REPO
Then you can push to GitHub with git push origin master. You will have to do a forced push (the -f option) the first time assuming you're pushing what used to be the repo you used exclusively for Heroku.
You'll still be able to push to Heroku with git push heroku master.
You should have two remotes.
This is good and even desirable.
You have github and that's your remote code repository of record.
Then you have a current deployment via heroku and that is the 2nd remote.
Heroku is actually set up to use git as part of the system of pushing changes to your site on it.

how to push to a remote only some directories or files? in git

I'm using heroku to develop a Django app and they use git to push the code. My problem is that they need this file structure:
heroku_project/
requirements.txt (this a pip requirements file)
procfile (this file tell heroku how to run your app)
django_project (the project itself)
lib
bin
build
lib (these 4 folders belong to my python virtual env)
So i have to have my git initialised on this folder so this means that there are this additional files:
heroku_Project/
.gitignore
.git
According to their instructions inside .gitignore there should be these lines:
bin
build
include
lib
.Python
*.pyc
The problem is that I want to track those virtual env folders, because sometimes I install python only for testing and I discard them later, or I make experimental changes on them and I wish I could undo those changes using git, my question is how can i track these folders so I need to remove them from the .gitignore. The problem is when i do
git push heroku master
As this will push those folders and we don't want that, so how I can selectively push files and directories? Or what kind of work flow would you use to solve this problem?
Thanks
First, if you're doing active development in Heroku then you may be dead in the water. But if your doing development on your local machine - branches may be able to help you out.
My advice to you would be to create a separate branch for deploying code to heroku. In this scenario you could use the master branch for active development, and keep those virtual environment folders in there - and have a separate branch (say, "production") for deploying the code to heroku.
Whenever you're ready to release a new version of your code, you should switch over to the production branch, merge in the changes from master, delete those virtual environment folders, then push to Heroku. In practice, that command sequence will look something like this.
$ git checkout production
$ git merge master
$ rm -Rf bin build include lib .Python *.pyc
$ git commit -a -m "Cleanup for production."
$ git push heroku production
That seems as though it will be the best working solution. Some vectors you may want to look into on your own:
Ways to automate the process of deleting the files via shell scripts and git hooks.
To make sure that Heroku can use a branch other than "master" for running code (I would think that it should be able to).
To see if it may be possible to use different .gitignore files in different branches, and if so - whether or not that will remove the cleanup process of deleting those files manually.
Hope this helps!
Why don't you try virtualenvwrapper? It separates the virtualenv from your development environment.
Typical scenario is that you work on one virtualenv, let's say "main_env".
mkvirtualenv main_env
And when you need another one for testing, you can do
mkvirtualenv test_env
and you can switch between them with one command: workon [name]. You really shouldn't keep those files in git. They're simply not related to project. And thanks to virtualenwrapper, you don't need git to switch between those virtual environments.
If you insist on keeping them, well, you can simply NOT stage them in git. If you don't add a file/folder with git add, it won't be sent to the server.