doconix / django-mako-plus Goto Github PK
View Code? Open in Web Editor NEWConnector for Django + Mako, plus some extras
License: Apache License 2.0
Connector for Django + Mako, plus some extras
License: Apache License 2.0
This isn't an issue for DMP but maybe Django itself (or my inability in this area). What is the recommended practice for storing settings that would be set by the user but would apply to the entire app? For example, lets say an app I'm running should be displayed in a particular theme, a set time zone, or default values that would populate fields within the app. My original thought was to create a 'settings' model but that seems counterintuitive since the database won't ever have more than the one value that will be set on the settings page. The other idea, which I've used for other programming languages, is to create a settings.cfg file of some sort on the system and parse the file. But again, this seems a little clunky to me on DMP. What do you suggest @doconix?
This part of the installation guide mentions to use
python3 manage.py dmp_startapp homepage
But should it be this?
python3 manage.py startapp homepage
I get this error:
C:\Users\spiva\Desktop\IS 413 Final\Test>python manage.py dmp_startapp homepage
Unknown command: 'dmp_startapp'
Type 'manage.py help' for usage.
The Django render function allows the following args:
render(request, template_name, context=None, content_type=None, status=None, using=None)
Two very useful args are content_type
and status
which allow the caller to better tune the properties of the HttpResponse
object that DMP will return.
Without this feature, the caller needs to do something like the following to set these values:
html = dmp_render_to_string(request, 'template.html', params)
return HttpResponse(html, status=201, content_type='text/html')
When I use django-mako-plus, I lost the Werkzeug debugger functionality (using runserver_plus). It seems that DMP is outputting the page without passing it to Werkzeug. Is there some setting that I've missed?
The readme.md file for the scripts and styles folder references images/readme.md
when it should reference media/readme.md
#
Does DMP support Django 1.9 yet?
I am looking the source code of the hue and what to do some change.I noticed that in the .mako file ,It contains javascript and out side of the js we can use the mako syntax and get the variable in the context,but I want to use it in the js function.I don't know how to get it,I think it can be geted,so i asked the way.
social-auth-app-django is a project that is commonly used to simplify social authentication with sites like Twitter and Facebook. Using the system they currently have, authentication is handled by sending users to a url such as <a href="{% url 'social:begin' 'facebook' %}">Sign up</a>
.
DMP converts the templating language so this isn't recognized. Looking at this page of the documentation, it looks like we should be able to get around this by changing the above code to <a href="<% url 'social:begin' 'facebook' %>
.
One possible solution I'm looking into is using regex to ignore certain urls from loading with the DMP engine:
urls.py:
urlpatterns = [
# the built-in Django administrator
url(r'^admin/', admin.site.urls),
# urls for any third-party apps go here
url('oauth/', include('social_django.urls', namespace='social')),
# the DMP router - this should normally be the last URL listed
re_path(r'^(?!(oauth.*)$).+$', include('django_mako_plus.urls')), <-- This is modified
]
The problem with this is that it changes the number of view arguments called which causes the page to display an error.
Is there another way around this?
I understand this project is in the deep freezer, but I do have a few clients who are still using this project. With that in mind, I have a PR with experimental django 4.1 support .
It is also worth noting that django 3.2 will lose support this year, which appears to be the most recent version this project currently supports.
The line in the readme tutorial in the file homepage/views/index.py
gives me an error:
ImportError: cannot import name 'get_renderer'
By changing it to
from django_mako_plus.controller import view_function, router
and then changing
templater = get_renderer('homepage')
to
templater = router.get_renderer('homepage')
the error goes away and everything works fine.
I'm working on a project demonstrating dmp running on docker, and as I've gone through the tutorial to re-familiarize myself with the framework, I've encountered an issue where dmp doesn't seem to include the expected jsm
file.
To replicate, one can clone this project and launch the site with docker-compose up web
which will run the site on localhost:8000
.
If index.jsm
is renamed to index.js
, the homepage app works fine. Otherwise, it doesn't seem to be included in the page's source.
I am trying to use Django syntax in my Mako template. I've followed the directions in the documentation, but it throws an error.
<%block filter="django_syntax(local)">
{% load compress %}
</%block>
I get TypeError: 'Undefined' object is not callable
for the following line <%block filter="django_syntax(local)">
Any suggestions on how to go about fixing this?
I have install my django app in a subdirectory like:
my.domain.com/devSite
and when I hit my application running in:
my.domain.com/devSite/timesheets/index
I see that django-mako-plus is interpreting the path incorrectly. I get:
[Mon Mar 16 16:05:08.744563 2015] [:error] [pid 31279:tid 140465995564800] DEBUG DMP :: processing: app=homepage, page=devSite, func=process_request, urlparams=[u'timesheets', u'index']
[Mon Mar 16 16:05:08.748229 2015] [:error] [pid 31279:tid 140465995564800] DEBUG DMP :: module homepage.views.devSite not found; sending processing directly to template devSite.html
[Mon Mar 16 16:05:08.748460 2015] [:error] [pid 31279:tid 140465995564800] DEBUG DMP :: App homepage is not a designated DMP app. Template rendering is not possible without DJANGO_MAKO_PLUS=True in its __init__.py file.
while I was expecting to read something like:
processing: app=timesheets, page=index, func=process_request, urlparams=[]
How can I inform django-mako-plus to start reading after my subdirectory...?
[edit]: Just to clarify, that the app in the local development server is working fine. Only during my production install (through WSGI) I get that error, when I try to run it from a subdirectory.
Thanks!
Hey,
First I just want to say that I've been using this framework for over 2 years and I absolutely love it. Recently I came across an issue with dmp_collectstatic. After running python manage.py dmp_collectstatic it creates an empty static folder(without any of the css, js, html or any other folders). Not sure exactly what is causing this issue. Just thought I'd bring it to your attention.
Thanks again for making such a spectacular package for Django.
The way routing works with DMP prevents Django's @csrf_exempt
(and probably a myriad of other decorators) from functioning correctly. DMP doesn't actually give the decorated view function back to the CsrfViewMiddleware
– instead it's getting the DMP route_request
function and so it never gets the @csrf_exempt
check to pass.
When I ran these commands: python3 manage.py dmp_startapp homepage
it throws
ImportError: No module named django_mako_plus
DMP requirements state that django 1.8+ are compatible, but after upgrading to 1.10 I get the following error message when I try to start a new DMP app.
(Input) $ python manage.py dmp_startapp homepage
(Output) WARNING Sass integration not enabled.
usage: manage.py dmp_startapp [-h] [--version] [-v {0,1,2,3}]
[--settings SETTINGS] [--pythonpath PYTHONPATH]
[--traceback] [--no-color]
manage.py dmp_startapp: error: unrecognized arguments: homepage
is there a way to link custom/3rdparty css/js files to the base template and add a cgi_id to it?
Following the docs installation instructions exactly raises an "Apps aren't loaded yet" exception. full error message:
`(venv) macs-MBP:BYU webdev mac$ python3 -m django_mako_plus dmp startproject goldenspikes
Traceback (most recent call last):
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_mai
n
"main", mod_spec)
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.6/site-packages/django_mako_plus/main.py", line 51, in
main()
File "/usr/local/lib/python3.6/site-packages/django_mako_plus/main.py", line 46, in main
management.execute_from_command_line()
File "/usr/local/lib/python3.6/site-packages/django/core/management/init.py", line 371, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.6/site-packages/django/core/management/init.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 280, in run_from_argv
parser = self.create_parser(argv[0], argv[1])
File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 254, in create_parser
self.add_arguments(parser)
File "/usr/local/lib/python3.6/site-packages/django_mako_plus/management/commands/dmp.py", line 56, in add_arguments
for name in find_subcommands():
File "/usr/local/lib/python3.6/site-packages/django_mako_plus/management/commands/dmp.py", line 80, in find_subcommands
dmp = apps.get_app_config('django_mako_plus')
File "/usr/local/lib/python3.6/site-packages/django/apps/registry.py", line 145, in get_app_config
self.check_apps_ready()
File "/usr/local/lib/python3.6/site-packages/django/apps/registry.py", line 127, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.`
Is this an issue with the initial dmp template? you can install without dmp in the startproject command, but then cannot use dmp in startapp command
This was an issue on macOS and ubuntu
Is Django 1.8 supported by this app. I'm trying to use the contrib messages app but no messages are appearing on pages. This appears to be because, although they are stored in a cookie, the context processors never get run to provide them as local variables. Is there some voodoo needed because of the changes to the Django template backend?
I'm trying to set my app as the default so it doesn't need to be typed but can't get to the page that describes it since the link is broken, both on github and readthedocs.
https://github.com/doconix/django-mako-plus/blob/master/docs/tutorial_meet_dmp.rst
This package is amazing but I was wondering if there was a way to use it without following dmp routing and view conventions.
I have a django app already, and I would simply like to replace the syntax of my current django templates with what dmp provides with mako. Is there a straightforward way of doing so?
Started a project using the new DMP (comes with Django 2.0) as shown in the tutorial but got import errors from the urls.py:
Server Debug Statements:
File "C:\tmp\dmp_test\lib\site-packages\django_mako_plus\urls.py", line 5, in from django.urls.resolvers import RegexURLPattern # Django 1.10+
ImportError: cannot import name 'RegexURLPattern'
File "C:\tmp\dmp_test\lib\site-packages\django_mako_plus\urls.py", line 8, in from django.core.urlresolvers import RegexURLPattern # Django 1.9
ImportError: No module named 'django.core.urlresolvers'
--
When I drop to Django 1.10.5 everything works except I can't get the JavaScript files to load. The slashes for the .js files are missing:
Console Error in Chrome v.63:
GET http://localhost:8000/static/homepagescriptsindex.js?1513746160 net::ERR_ABORTED
Page Head:
<script> DMP_CONTEXT.set("4.4.8", "u5a39f5b2cb096002923ada07000840", {}); DMP_CONTEXT.linkContextByName("u5a39f5b2cb096002923ada07000840", "homepage/base");</script> <script> DMP_CONTEXT.addScript("u5a39f5b2cb0c6002923ada07000840", "u5a39f5b2cb096002923ada07000840", "homepage/index", "/static/homepage\scripts\index.js?1513746160", false);</script> <script id="u5a39f5b2cb0c6002923ada07000840" data-template="homepage/index" data-context="u5a39f5b2cb096002923ada07000840" src="/static/homepagescriptsindex.js?1513746160"></script> <script>DMP_CONTEXT.linkContextByName("u5a39f5b2cb096002923ada07000840", "homepage/index");</script>In the latest version of dmp the django.contrib.auth.decorators.login_required decorator no longer works. When added to a view, the code is ignored and doesn't raise any errors. Anonymous Users are still able to access the page.
In addition to this, if accessing User information, the page fails to raise an error if the information does not exist. As an example, when trying to display the username with ${request.user.username}, nothing shows up. The page loads as normal, but without any necessary information.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.