0

I am using Angular as my front end and Django as back end.

What I am facing is my server load the static file really slowly.Although,when I ran the server,the html shows the static file exist, but when I click on the url, it just keep load the file and eventually crashed.This is the GitHub link:https://github.com/Honesty1997/my-lotto-game.git

Hope you can help me find the problem!I am sure the django static file settings are all right!

1 Answer 1

1

I found some issues with your app

1. miss using double quote in script tag inside index_production.html. You need to use single quote between two double quote.

There is many places in your code miss using the double quote, please double check that. You can change your code this:

//             +--------------------------------+---- use single quote instead
//             v                                v
src="{% static '/node_modules/angular/angular.js' %}"

2. Use absolute path instead of relpath

angular.module('app').component('myComponent', {
    templateUrl: "/static/js/app.template.html", // <---- add '/' before static
    controller: ['$http', appController],
});

3. Move all your static files under 'src'

src
|---facebooklotto
|---lotto
|---static
|---db.sqlite3
|---manage.py

And change your static file setting like this:

STATIC_URL = '/static/'
# STATIC_ROOT = os.path.join(BASE_DIR, "static")
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "static"),
]

After making the changes above, I can run your webapp. Hope it would help...

Sign up to request clarification or add additional context in comments.

2 Comments

I'll try this!Thanks for help!
It can run correctly!I will check the Django static file doc again......I think I misuse the static setting.....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.