Webpack prod config vs dev config issues - django

I am trying to reuse one webapp that's been open sourced a while ago that was written using some Django and ReactJS... Now I am a devops engineer so my skillset when it comes to JS and even Django are fairly limited so I am stuck .. My main problem is that this webapp can run just fine locally.. so I can start it and connect using http://localhost:8000 , but whenever I try and set it up on a server and make it "public" for the internal network it fails with accessing all the JS assets.
I know the problem comes with my webpack configs but I can't sort it out.. Been trying all day but I can't even find the proper documentation since it's using Webpack 2.5.
https://github.com/tsprasath/estate/tree/master/webpack
I am attaching the link to the webpack configs from the repo.. If anyone can at least point me to the right thing to look at, that would be helpful.
Thanks in advance!

I dont think its an issue with your webpack. You are trying to run your react app (which is at client side) from django server. I believe you will need to use some kind of middleware to let django know that it needs to use static files generated for react using webpack. I dont know exactly how its done, but same procedure is followed if react app needs to be served from node/express server.
Or see if this helps: https://github.com/nicholaskajoh/React-Django

Related

How do I know if my Django project is ready to be deployed?

I already finished my project that I made with django, and I want to upload it. I already bought the domain, and they are about to host it for me.. once they give me the host, I just upload it and that's it? Or are there more steps to do within the code? What do I have to do?. that is, once everything is uploaded to the host, will everything be seen?
And the Admin will continue to work, when in the search engine put /admin/ ???.
that is, I wonder what are all the steps to follow so that once I host my page everything can be seen.
that is, what things would have to be configured in the congif.py, and other things.
I would appreciate a lot if you give me advice/tips/solutions..
What I know is that I have to change the debug to DEBUG=False ...
And I don't know anything else, once they pass me the port and other host information, I simply upload the files of my project to the host and that's it, nothing more? Isn't it necessary to write more code to show it?
Excuse me, I have never displayed a page
There are a lot of steps involved in deploying your code to production. I suggest you check out a guide like this to get a better idea of what you need to do in order to deploy your website. Additionally, you can run the command python manage.py check --deploy for a quick, though insufficient, review of your code to see if it is ready to be pushed to production.
Django is an excellent choice for developing basic to more advanced websites. The web framework works well in local and production environments. Just the same way the local environment server is not suitable for a production environment, there are things you need to configure before deploying your Django website. Take a look at the links below
Https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
https://docs.djangoproject.com/en/4.1/howto/deployment/
https://github.com/vintasoftware/django-production-launch-checklist/blob/master/checklist-en.md

HTML5 Application (Cloud Foundry) - 404 Not Found nginx

I deployed a React-Application with the Staticfile Buildpack to Cloudfoundry on the SAP Cloud Platform which has different routes (e.g."/login", etc.)
When I access the app with the provided URL (e.g. "www.exampleurl.com") and navigate through my app everything works, the different pages with different routes are working as expected.
My problem now is that, everytime I want to reload a page or if I want to access the application with an additional path attached initally e.g "www.exampleurl.com/todo-route" instead of just "www.exampleurl.com/" I get an 404 Not Found nginx error.
Is this problem related to the application router I need to configure before deploying my application or is it something different.
Unfortunately, I am not getting smarter from reading the documentation and resources on this are very rare in general.
I would appreciate some advice very much. Thank you in advance.
For people having trouble with single-page applications as well:
I found an answer already myself.
Refering to this post:
Deploy single page application Angular: 404 Not Found nginx
You need to add a "Staticfile" file in your dist or build folder with "pushstate: enabled".
You can also refer to the cloudfoundry documentation for the staticfile buildpack: https://docs.cloudfoundry.org/buildpacks/staticfile/index.html
Hope that will help some people on the way.

Use ember cli mock server as actual server

I'm using ember-cli with Firebase for my data. I also have a simple server file I created with http-mock that handles some processes for Twilio. Is there a way to use that http-mock as an actual server on Heroku? I have found an embercli stack for heroku but I'm not sure how to make that use the server file I have:
https://github.com/tonycoco/heroku-buildpack-ember-cli
Thank you in advance for the help.
I believe that build pack just deploys your app's static files to Heroku.
The http-mock file you're working with within Ember CLI is a Node Express app. So, you'd need to host it on a server that can serve node apps somewhere.
In theory you could write a script that does that (deploys it separately) while keeping it within your main repo, but like others have said that's probably not a good idea.
In the future, though, you probably will be able to use http-mocks both for clicking around your app with ember serve, and for use in your tests.

django-gcm under lighttpd/fastcgi?

Has anyone gotten the django-gcm server running under lighttpd using fastcgi?
I know how to get a general django application running under lighttpd/fastcgi, but I haven't been able to find instructions specifically for running the django-gcm server in this environment.
I've been trying various things and searching for examples, but so far, I have come up empty-handed.
Thanks for any pointers to docs or suggestions.
Django-gcm is reusable application like others. Just create new django project and add 'gcm' to your INSTALLED_APPS in your settings.py file. Btw in django-gcm package you have example of server application which you can simply run under lighttpd/fastcgi.

Modifying existing Django site

I am completely new to this Django world. I haven't tried it ever before.
Now the problem is as below;
One of my clients was hosting his site somewhere else that I don't know and they built the site using Django. The host company doesn't allow to make any changes on their server, instead they provided the zip file for all the files in the site to me; so that now I can host my client's site.
As I don't know anything about Django, can someone please shed a light where I should start from?
Thanks in advance.
Cheers.
Sach
First of all, install Django on the development machine. Start by trying to get the development server run on your machine.
Gather requirements: check the settings.py for installed apps against the default Django settings.py file. See if there are any popular django apps that site depends on. If there are any, then you probably will have to install them, too.
In which format was the database provided? Will you move to another more appropriate format? Python bindings for databases are required too.
Considering the fact that you have inherited this project and probably will need to make some changes, consider installing django-south, so you can easily make changes to the database schema.
If you get the site running properly on your own machine, consider deplyoment. Is there a lot of static content? (if so, consider nginx). Set up apache2 and install the mod_wsgi module. Deploy.
Work your way through the Django tutorial first. Then look into Django Book as has been mentioned. Django IRC channel (#django) on Freenode is also great for help.
Your best bet would be to learn about Django before trying to jump in head first - https://www.djangoproject.com/ contains documentation as well as tutorials on creating Django apps.
Django is fairly easy to setup if you already have the code written. You'll need to install the chosen database and then simply follow the tutorial on the Django website
Django comes with a built-in server so it's very easy to run the website for development without needing Apache, nginx or much else.
I learned using the Django Book. Django is an easy-to-use framework, you should be fine.
Also, in the short-term there's a file called views.py and separate folder containing templates. If you're familiar with MVC (MVT in Django) this contains the views for the site in function form. There's probably (but not always) a folder for templates which contains a lot of the HTML for the site. Just a good starting pointing for basic modifications.
You can perhaps start here. https://docs.djangoproject.com/en/dev/howto/deployment/
First, find out the django version required by your client. Install that on a server (not a production one), setup apache and mod_wsgi. The zip files may go to a dir which can be included in the mod_wsgi configuration.
Find about the static files and setup apache or any other lightweight webserver to server it.
You may not be a developer, but have a try with the django book. It can give you a good idea how its structured.