sometime simplest things are so complex!
I have some javascript which works fine. I decided to put it in a seperate javascript file that I want to link to my template.
I have put it in folder scripts/a_ajax.js off the root of the application.
Whatever folder structure I've tried has not worked.
I've also read something about that I must put a reference in urlpatterns but I'm not sure what I had to do.
Can anyone help tell me what I have to do to embed this code as a file?
thx
If your Django version is 1.3+: https://docs.djangoproject.com/en/dev/howto/static-files/
If your Django version 1.2.* or lower: https://docs.djangoproject.com/en/1.2/howto/static-files/
Related
I installed everything like in official tutorial https://www.jetbrains.com/help/webstorm/prettier.html#ws_prettier_reformat_code and it doesn't work on save, although the checkbox is set.
What can I do to make it work?
Prettier version: 2.7.1
WebStorm version: 2022.2.2
Must be WEB-57086, Prettier plugin doesn't work if you have a directory name in a glob pattern.
Try changing the Run for files: back to default value, {**/*,*}.{js,ts,jsx,tsx,scc,scss,sass}
Also make sure you have correct file extensions included, for instance if you are working with Vue add vue to the list:
{**/*,*}.{js,ts,jsx,tsx,vue}
I'm new to the Django. I am currently use VS code as my code editor.
In order to work on the Django project, in the user settings of the VS code, I include the following code to use pylint_django as the default linter.
"python.linting.pylintArgs": [
"--load-plugins=pylint_django", "--errors-only"
],
However, in another python file, which is just a regular python file, I got an error, saying "Django is not available on the PYTHONPATHpylint(django-not-available)"
If I comment the above code in the user setting, the error goes away. I think the problem is pylint-django is used as default linter, even for non-Django python file.
My question is I didn't find the solution to solve this problem. Could you please help me on this? Thank you so much. I really appreciate it.
The problem is solved when I uninstall the globally installed pylint_django.
I'm coding css and javascript file for my web project. That files I put in app folder. I use "git add ." and "git push origin +(branch_name)", but I clone project again, I don't call that static files I wrote. How do I solve problem?
Your query is a little unclear to proceed with exact solution
Still, collect-static does the job for static files in Django.
A similar issue was raised, which can be of help to you.
for me the following command do the trick:
python manage.py collectstatic
But plz note that it also depends on the way like where you would like to host your static files and so on. For example, I use azure storage account to host the static files, therefore in my case I have to configure the setting.py also.
Hope you can solve ur problem soon. (btw surprise to know the leaf village uses django, too... )
I have a project that I would like to use foundation 5 with. I have been through the steps of creating a new foundation project using the CLI but I don't like it. There is too many files and the structure does not match what I want. So...
I am intending to add only the required files to my project and use compass to compile all the css.
I have noticed in the project created on the CLI a few things that confuse me and would like some help in clearing them up.
In the project created on the CLI there are two _settings.scss files one under the foundation directory in bower_components and one in MY_PROJECT\scss. I'm assuming that because of this add_import_path "bower_components/foundation/scss" line in the config.rb, which of those files has preference?
Why does MY_PROJECT/stylesheets not have normalize.css (or foundation.css) in it? And how are they not there? (in my custom setup they are being generated, albeit in subdirectories of stylesheets, also the foundation.css that is being generated for me has no settings changes applied so I guess it shouldn't be being generated)
If you take a look inside \bower_components\foundation\scss you'll see the file foundation.scss. That file imports all the stylesheets for all the additional components that come in the Foundation 5 "package." In your root scss directory, the app.scss is what compiles the SASS into \stylesheets\app.css. So rather than this:
#import "foundation";
Uncomment the individual components you'll be using. Something like this:
#import
//"foundation/components/accordion",
//"foundation/components/alert-boxes",
"foundation/components/block-grid",
//"foundation/components/breadcrumbs",
//"foundation/components/button-groups",
//"foundation/components/buttons",
"foundation/components/clearing",
"foundation/components/dropdown",
//"foundation/components/dropdown-buttons",
//"foundation/components/flex-video",
"foundation/components/forms",
"foundation/components/grid",
//"foundation/components/inline-lists",
//"foundation/components/joyride",
//"foundation/components/keystrokes",
//"foundation/components/labels",
//"foundation/components/magellan",
//"foundation/components/orbit",
//"foundation/components/pagination",
//"foundation/components/panels",
//"foundation/components/pricing-tables",
//"foundation/components/progress-bars",
"foundation/components/reveal",
"foundation/components/side-nav",
//"foundation/components/split-buttons",
"foundation/components/sub-nav",
//"foundation/components/switches",
"foundation/components/tables",
//"foundation/components/tabs",
//"foundation/components/thumbs",
//"foundation/components/tooltips",
"foundation/components/top-bar",
"foundation/components/type",
"foundation/components/offcanvas",
"foundation/components/visibility";
If you'd like to streamline your file structure, I would suggest you remove any scss files from the \bower_components\foundation\scss\foundation\components directory that you will not use. Same with the js directory. You don't actually need to modify anything in the bower_components directory to get everything to work. Not entirely sure why it's all contained within bower_components, but I imagine it's got something to do with being able to update the core components later with future releases.
Someone else could probably give a more educated answer.
p.s. - make sure to compass watch in your CLI to see any of those changes made to your SASS files.
I have a pycharm project and, presumably, a Django project. Perhaps they are one and the same, perhaps not - I'm unsure as to the distinction.
Anyway, in my settings.py file (which is in the root of project directory, which is what I presume is my pycharm project) I have:
ROOT_URLCONF = 'dumpstown.urls'
Does that mean dumpstown is my project name? Or my pycharm project name? What is the distinction? Because I also have a folder called dumpstownapp and this has all my models.py and view.py files. I would have thought that dumpstownapp was the Django project, but I really don't know!
So, to be concise:
In this folder setup
folderA
folderB
views.py
models.py
<other stuff>
templates folder
settings.py
<other stuff>
which is the "Django project name" ~ and by that I mean, if I have a UserProfile defined in my models.py (shown above) what would be the AUTH_PROFILE_MODULE entry I'd need for it? I'm getting several understandings from the django docs - I'd assume
dumpstownapp.models.UserProfile
But from the docs I'd get
dumpstownapp.UserProfile
Or maybe my app is called dumpstown? and then what do I get?
FolderA is the Django project folder, and folderB is the Django app folder.
I haven't used a UserProfile, but according to the docs ( https://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users) it should contain a string containing the Django app name and the model name separated by a dot, so "dumpstownapp.UserProfile" should be correct. If you show the error someone can probably give you better help..
Django documentation used to say that the parent of the project folder (i.e. the parent of folderA) should be on the path, but I believe that has been changed to also include the project folder itself (i.e. folderA) -- since it makes sharing of Django apps much easier. PyCharm seems to assume that is the case, since pressing Alt+F7 to auto-add an import for a newly used module create an import statement that assumes folderA is on the import path (I'm a relative newcomer to PyCharm, and I'm using it on a project that started in the Django 0.96 era, so I might just have things set up wrong..) But folderA is both the Django and the PyCharm project (the .idea file is where PyCharm stores its project data).
In one of my django-app git-submodule projects I needed to find out the name of the Django project that django-app/library was used in. To that end, I tried to get the path of the file that was being executed, find my package in the path and take the folder above it. However, it turned out that on the production server the project was deployed in a folder with a different name (a standard name like www or something along those lines). So this way is not fully reliable.
So I ended up setting a PROJECT variable in the django settings file and using that instead.