How to debug angular frontend with django server on vscode (Unverified Breakpoint)? - django

I'm running a django server for the backend of my application and angular for the frontend side.
Basicaly to make my application work I start my django server:
python manage.py runserver
And on angular I use:
ng build --output-path django_static_folder/ang --watch --output-hashing none
I'm trying to debug angular code using vscode. I have an issue with "Unverified Breakpoint" on vscode. I checked many thread about this issue but none of them talked about how to debug when the server is not managed by angular using ng serve
Here is my actual configuration:
{
"version": "0.1.0",
"configurations": [
{
"name": "Angular debug",
"type": "firefox",
"request": "launch",
"url": "http://127.0.0.1:8000/",
"webRoot": "${workspaceFolder}",
}
]
}
The workspaceFolder is my angular workspace folder.
The url is the one from django server. So when I start the debugger, the firefox app launch and I'm in my application but I cannot put any breakpoint.
I believe that the issue is coming from the fact that I'm not using angular server. Maybe I should but then I don't know how to redirect to the correct url on the django server side ?
Can anyone help me on this subject ?

Related

Run "git pull" for a Django project running on Windows Server 2016 IIS

My current set up has a Django project running on Windows 2016 IIS.
The project is hosted on GitHub for collaboration and I would like to set up a GitHub webhook so whenever there's a push to master branch from any of the collaborators, the IIS Server will run a "git pull" to update the project on the server.
What is normally the setup for this?
What I have tried so far is to create an endpoint in the Django project, this endpoint whenever called will run Python subprocess to run "git pull" command in the project itself. However, whenever I run it, it get a 500 response from IIS.
Thanks #VonC for helping.
I have looked to the log (which was the one in XML) but it wasn't much help.
What I'm posting here was my workaround, not exactly to the answer for the question above.
I used django-background-tasks to add the command subprocess.run(['git', 'pull']) as a task to run later (after a few seconds after that by the #background decorator).
Error 500 means the IIS server throws an error.
You need to check said IIS server logs in order to check at what point in the execution of the webhook endpoint script the error occurs.

How to get link to redirect to expo app during development

How to get link to redirect to expo app during development?
I have a react native expo app. During development started with èxpo start. Now I like to use OAuth 2.0 authentication. Therefor I need a redirect URL.
My app.json looks like:
{
"expo": {
"name": "myapp",
"scheme": "myapp",
"slug": "myapp",
"privacy": "public",
There is a documentation for linking to the app, but it's not clear to me which link to use during development to get redirected to the app launched in expo. https://docs.expo.io/versions/latest/workflow/linking/#linking-to-your-app
I think myapp:// is wrong because the app is still in development using expo start and not deployed as apk as standalone app.
Using https://auth.expo.io/#myuser/myapp resulted in:
Get the right link value at runtime :
Linking.makeUrl()
will resolve dynamicly according to running environment: dev, standalone app...
Linking.createURL() is available in expo-linking#2.0.1 and higher. If you are using an older version, use Linking.makeUrl() instead.

chat socket (web socket)is closing unexpectedly (django-channels)?

console image
i have gone through as it mentioned in the docs(channels) it worked fine until i pasted the code of channel_layers in settings.py
i installed all the specifications mentioned in channel_layers
ASGI_APPLICATION = 'mysite.routing.application'
CHANNEL_LAYERS = {
'default': {
'BACKEND': 'channels_redis.core.RedisChannelLayer',
'CONFIG': {
"hosts": [('127.0.0.1', 6379)],
},
},
}
why is my chat_server closing unexpectedly
First of all check wheather redis is running in your machine or not.
if not google it you will find.
->check these points wheather you had done correctly:
1.check wheather the data you send to sockets are in string format.
2.check the json you are sending to sockets is correctly parsed.
3.similarly check the data received from sockets is correctly parsed.
if you want to automatically reconnect to sockets use
https://github.com/joewalnes/reconnecting-websocket copy the js file there and place the script in your html and then replace WebSocket to ReconnectingWebSocket
This problem arise due to reddis channel not working at backend after configuring in the setting.py you should start the reddis channel
if you are using docker then try this
docker run -p 6379:6379 -d redis:5
if u have connections problem with django-channels,
first install channels --> pip install -U channels
after installing channels add 'channels' install app in your setting.py file and follow these docs to install channels properly in your django project
--> https://channels.readthedocs.io/en/latest/installation.html
after installing django channels now install channels-redis in your django project,
first step is to install redis in your local machine , but install redis 5 or above
follow installing steps to install redis server in ubuntu and download redis direct if you use windows.
download plus installing steps in this link--> https://redis.io/download
after istalling redis in your local machine install channels-redis in your django project
--> pip install channels-redis==2.4.2
this is latest solution of django channels connection problem with redis , i hope this will help you
I had similar problem .
My websocket connect and disconnect immediately ,
Although Redis was installed,
The problem was with the Redis version.
Your Redis version must be greater than five

Cannot access django development server without ssl using chrome

I setup a clean django project with:
django-admin startproject newProject
cd newProject
python manage.py migrate
python manage.py runserver
January 29, 2019 - 00:30:02 Django version 2.1.2, using settings
'unchained.settings' Starting development server at
http://127.0.0.1:8000/
And navigate to http://127.0.0.1:8000/ with Google-Chrome (71.0.3578.98):
[29/Jan/2019 00:30:08] You're accessing the development server over HTTPS, but it only supports HTTP.
[29/Jan/2019 00:30:08] code 400, message Bad request version ('ÊÊÀ+À/À,À0̨̩À\x13À\x14\x00\x9c\x00\x9d\x00/\x005\x00')
[29/Jan/2019 00:30:08] You're accessing the development server over HTTPS, but it only supports HTTP.
So, at some point in the past I activated SSL with a totally unrelated project. And for some strange reason, chrome now expects HTTPS. I could probably fix it by deleting the browser cache, but I don't really want to loose all the data that is in there.
How would you solve this?
Django Development server only uses Http protocol instead of Https. Your site is being opened at https://127.0.0.1:8000/ instead of http://127.0.0.1:8000/
Go to settings .py and change
SECURE_SSL_REDIRECT = False

Publishing Django app writter in Aptana to Heroku

I am new to almost everything web development related. I am using Aptana studio 3 on a Mac and have built a very basic app using Django that works as expected on the Django development server provided with Django. I now want to try out publishing it to a 'real' server. I found out that Aptana has some integration with Heroku and so decided to try and publish there.
On the app explorer in Aptana I am locating my django project (named 'mysite') on the dropdown and then clicking the publish button to run the 'Web Deployment Wizard'. After selecting that I want to publish on Heroku and filling in the details of my Heroku account I click finish. A terminal window opens at the bottom with the command:
heroku create mysite; git push heroku master
I then get:
Authentication failure
Enter your Heroku credentials.
Email:
If I enter my login details, it says 'Authentication success' but then immediately follows with another authentication failure. This repeats indefinitely.
Any ideas what is going wrong?