I need to find a way/package to make Atom use autocomplete for Django projects, especially Django templates.
I found this package in Atom's installer, but it doesn't include a shortcut for auto completion of this syntax {% %}, {{ }} which I need the most.
Any help will be appreciated
You could make your own snippets in Atom.
To do that go to Edit > Snippets
In the document that open's you can paste this bit:
'.html.django':
'Example snippet':
'prefix': '%%'
'body': '{% $1 %}$2'
This example would expand to {% %}, placing your cursor inside. To trigger it you type %% and hit tab. A second tab would place the cursor after the closing bracket.
The .html.django part means this snippet is active only in documents that are marked as HTML (Django)
I don't see why you would need a snippet for {{ }} as Atom auto-close's the brackets.
For more information read this - http://flight-manual.atom.io/using-atom/sections/snippets/
Disable atom-django package
I installed the django-templates package
in the django-templates settings in the option Default to Django Templates For File Paths Containing add the value directory_name/
reload atom
When you create an html file inside templates folder the it recognizes it as html django template
I configured it and it works
I faced the same situation and bit explored more inline with #4140tm's comment and found atom-django-templates repo. One can follow the steps given in the repo to have autocomplete in Atom editor
OR please follow below steps that I followed on my Mac.
How to Do it
1. Open "/Users/YourAccountName/.atom/snippets.cson"
2. Copy content from django-templates.cson
3. Paste it in "/Users/YourAccountName/.atom/snippets.cson"
4. Open any .html file and hurrah.... You are ready to Rock.
How it looks
Related
I would like for the Jinja2 package's syntax support to be provided automatically to files with the .html extension, given that the appropriate delimiters ({% .. %}, {{ .. }}) are detected.
I understand this would work for files with the .j2 extension. I am asking if it could be applied to plain HTML files that include Jinja2 syntax, without having to add the entire .html file type (which would then apply it to any HTML file)?
For now, I have been selecting the HTML (Jinja2) option from the syntax definition dropdown menu for each file, obviously not an ideal solution.
The easiest way to do this is to open a .html file, then select View → Syntax → Open all with current extension as… → HTML (Jinja2). This should do the trick. If not, there's a different way that involves writing a plugin, but this should be sufficient.
This still works based on the file's extension. However, highlighting of non-template content should be exactly the same as if you were using the regular HTML syntax.
I wanted to insert multiple live templates. For example whenever I type prop and press tab, then pycharm would write the full property for python.
I wanted to import the following list:
https://github.com/hoffmann/PyCharm-Python-Templates
But I can not find the templates folder in <your home directory>\.<product name><version number>\config\templates, as said in https://www.jetbrains.com/help/pycharm/2016.1/live-templates.html
Also I am using the community edition 2016.1.4.
I got this to work on Windows when I used the path <your home directory>\.PyCharm2018.3\config\jba_config\templates\user.xml (my version of PyCharm is 2018.3.4)
In case this doesn't work for you, you may find where the file belong by following what I did.
Open File | Settings | Editor | Live Templates in PyCharm, created a new template called MyNewUniqueLiveTemplate
On the command line in the directory <user directory>\.PyCharm2018.3\config "grep"ed for the string MyNewUniqueLiveTemplate.
I've had the same issue and found that there is one simplest way to insert multiple live templates.
Just copy desired template code from *.XML file,
open PyCharm's Live Templates Settings (Ctrl+Alt+S -> Editor / Live Templates),
select Template Group (such as Python or create your own like a 'user'),
and paste in the value. That's all!
It works fine dependless of the operating system, PyCharm version and you shouldn't worry about PyCharm config files location.
You can insert in that way multiply live templates at once.
I'm working on a small project where it would be helpful to display trivial web pages. It's being developed in PyCharm, the pro edition.
This is an existing project, so it wasn't created as a Flask app to begin with.
I've added Flask to my requirements.txt and ensured that its installed. However, I don't get autocompletion of any Jinja templates - essentially, the HTML file I created is treated like dumb HTML.
How do I get PyCharm to recognize that I'm using Flask and to act accordingly?
You have to tell PyCharm which folders contain your templates.
Go to Settings/Project: NAME/Project Structure
Click on the folder containing your templates and click the purple Templates button.
It will probably warn you that no template language is specified. If that is the case
go to Settings/Language & Frameworks/Python Template Languages
In the combobox Template Language: select your template language (jinja?)
Under Template file types select the file type (probably HTML)
When you create a project ( File->New Project ) to choose:
After the creation of the project to select the appropriate file:
Creating a new Flask Project will just set the python template language as Jinja2 and give you a skeleton (a web server which respond 'Hello World' to client).
Therefore, if you have a existing project, press Prefences -> Search Python Template Languages -> and now you can change it to Jinja2
How can one include a file in a django template like {% include %} would, but without parsing the file's contents ?
I am aware of {% ssi %} but that last one would not accept relative paths and throws '[Didn't have permission to include file]' at me.
EDIT: this is NOT a duplicate of How can I tell Django templates not to parse a block containing code that looks like template tags? . As I commented here, I need a directive to include a whole file, not a directive to ignore a block inside a template.
Note: I'm trying to include angularJs templates which are in the project's directory, but the syntax conflicts with Django template
If you don't want to have to modify the files you're including, it looks as if the only way to do this is with a custom template tag.
Fortunately, it looks as if someone else has already posted one called include_raw on djangosnippets.org, although it was written for an older version of Django, so you'll have to make some modifications along the lines of those mentioned in one of the comments below the snippet.
I am using multiple language in mezzanine and it is working fine with its own core templates.But I try to use it in my own templates then it is not working.
I have use all things in proper steps. I have locale folder in which django.po consists of all text which I can translate and there encoded django.mo file.
Buy when I choose other then English Lang. in my browser it does not translate my templates text but change the text of core templates.
I don't know why it does not translate my templates data Because if there are any kind of errors then it must not translate core templates but it does.
Please help me to sort out my problem , any suggestion would be appreciated.
Thanks.
Does your .po file contain the word "fuzzy"? If so, you might want to read the following article: http://blog.e-shell.org/124, as mentioned in this previous SO question: Django missing translation of some strings. Any idea why?
If that is not the cause of your issue, are you sure you are using the internationalisation template tags appropriately?
First of all, ensure you are loading the relevant template tags at the top of each of your templates:
{% load i18n %}
Then, for any text you want to make translatable:
{% trans "Insert your text here" %}
See also: https://docs.djangoproject.com/en/dev/topics/i18n/translation/#internationalization-in-template-code and https://docs.djangoproject.com/en/dev/topics/i18n/translation/#implementation-notes.