I wrote a very simple django application and uploaded it to pythonanywhere. Through this form (and its base template) I'd like to allow the user to setting date and time using django-bootstrap-datepicker-plus (and django-bootstrap3).
The date-picker widget works fine on my localhost in debugging mode (see a detail of my [local] webpage in this figure), i.e. I can click on the calendar icon to display the calendar widget. My problem is that on the pythonanywhere server the widget cannot be displayed (i.e., the calendar icon is missing and when I click on the rightmost part of the date-time entry field, nothing happens).
I am using the same source code (pulling the latest versions of my github repository). Moreover, the virtual environment on pythonanywhere is set through a requirement.txt file obtained by [pip] freezing my local environment (thus, I am also using the same python packages).
The most likely issue is that you're not serving the static files that are necessary for the widget to work. Check your browser requests in the developer tools to see if you're getting 404s for any resources that may be used by the widget. If they are 404ing, have a look at the PythonAnywhere and Django docs for how to properly serve static resources.
Related
I need to create a desktop app that access a webpage and also need to be able to control it's caching location (such as images of this webpage) for offline usage.
Just like any browser already does?
Yes, but I cannot use any browser like Firefox, Chrome, Chromium... Unless it's in the form of a DLL or something similar (the browser itself cannot be installed)
I already found how to delete cache and how to disable caching, just need to alter the caching directory.
take this code as example:
import webview
webview.create_window('Hello world', 'https://pywebview.flowrl.com/hello')
webview.start()
Let's suppose it downloads a image and stores it in cache.
I need to be able to open multiple instances of the application, each with it's separate caching directory.
Anyone knows how to change the caching directory? something like:
webview.cache.setDir("c://User/user-2")
I'm alright with the usage of other libs such ad flask or bottle (or any other really)
Also, the solution needs to work for both Widows and Ubuntu
Thanks in advance.
As you mentioned, There are third-party libraries you can use. Flask for instance works very well with pywebview. the webview.create_window method accepts an HTTP server(In this case flask). With flask you can then use the flask cache module to specify a directory to store the files
You can check the docs on flask caching to see other possibilities
https://flask-caching.readthedocs.io/en/latest/
If I am given a dataset (say excel file), I would like to deploy a webserver on which I upload this excel file, it runs python/numpy code and displays some figure.
I could also have some checkboxes on the website that would change the parameters in the code.
What tools would you recommend for doing that? What would be the easiest way?
For now I have the python code on jupyter notebook and use:
from ipywidgets.embed import embed_minimal_html
embed_minimal_html('export.html', views=[fig])
to see my figure (fig) locally, by running: python -m http.server 8080
I would like this to be deployed and choosing the file to upload.
In my opinion Django may be the best option for you. It requires Python knowledge and basic HTML/CSS -for basic usage-, that is why I thought it is the best option.
You can develope python scripts and user can able to modify the input for that python script and easily create an dashboard with graphics/calculations.
You may want to check Vitor's website:
Simple is the Best by Vitor Freitas
Use a Github repo to host your code, and then share it via MyBinder.org. An example, that is simpler than yours, but like what you describe in some ways is here. When you get there click the launch badge and a temporary session will spin up. In the notebook that comes up, you can do Run All Cells under the Run menu. The session dies after 10 minutes of inactivity. You can download useful information. See more about the MyBinder project here. I am taking advantage of the drag and drop for file upload that comes with JupyterLab here but there are file upload widgets (see below).
That example one doesn't have fancy widgets like toggles to make the choices but you can add them. For example, see the appmode demo. (Click launch binder button on the page.) You'll see you can have the widgets in the notebook or in the 'appmode'. You can make the interactions with the widgets fancier, too. Some examples featured in the Voila gallery will give you more of an idea of what is possible with the widgets and communicating to your underlying python. All those are on Github and served via temporary sessions from MyBinder.org. Keep in mind those apps can run in the notebook if you want that. The widgets work there in the notebook versions as well, too. And you can directly link to the notebook mode if you prefer, as shown under the heading 'Direct links to start out in notebook mode' here.
I am working on a Python Django project in which in one of the app, I have to do a lot of DOM manipulations. Earlier, I was using jQuery for this purpose but I want to use VueJS because of its virtual DOM. I am using PyCharm Pro. I am not able to use .vue files inside PyCharm. Somehow, I mistakenly set the 'language setting' for .vue file to React RxJS (since Vue also supports RxJS). I then installed Vue plugin for PyCharm and restarted it. Still, I get the same error "Unidentified character <" in the template portion of Vue file. I found that VueJS is now supported with a plugin in PyCharm Pro (https://twitter.com/pycharm/status/848978918120058880).
Can someone tell me what I am missing? What changes in the project or PyCharm settings do I need to make?
Edit: If someone can, please provide any suggestions/alternative solutions to handle DOM manipulations other than jQuery.
Consider setting .vue files in PyCharm to be recognized as HTML files.
I'm currently using PyCharm for a Flask / Vue.js project.
This is what my 'File Types' settings look like for .vue files:
And this is what a .vue file looks like in PyCharm for me:
When you attempt to add the *.vue pattern as an HTML file type, you should be forced by PyCharm to reassign it from the React JSX file type, so you shouldn't need to worry about manually removing the *.vue pattern from the React JSX file type.
I am working in a dev environment using the built in Django web server. One of the inconvenience that I have is everytime I make changes in HTML or Static files it does not apply when I reload the browser until I kill the dev server and run again.
python manage.py runserver localhost:8000
Is there a way so Django will reflect the changes instantly? Thanks in advance
Django reload the server only on changes on .py files. I read different ways to trigger reloading (such as installing a third party app, tweaking caching depending on whether DEBUG = True, etc etc).
The easiest and dumbest way is to make an insignificant slight change in the view you're working on (say, adding a #, removing it) after you edited and saved your template. It is dumb but it works.
I'm trying to use django-ios-notifications to server PUSH notifications via APNS (https://github.com/stephenmuss/django-ios-notifications). I've never used Django before. I've followed the instructions on the modules github page, but have'nt been able to get it working. I've done the following;
*installed required package and django
*added 'ios_notifications', to my INSTALLED_APPS settings file
*synced my local MySQL server with django (a load of new tables were created, for both django and django-ios-notifications, so it appears to be installed correctly, which I was thrilled about)
*start django server
However when I go to the modules config page (URL below) I just see the default 'It worked!
Congratulations on your first Django-powered page.' holding page, not the admin page I expected. (the tutorial on the github page descried a form)
http://127.0.0.1:8000/admin/ios_notifications/apnservice/add/
I guess I need to configure something in djange, I read over the first few pages on the django tutorial but I couldn't see any mention of using installed modules. I'm sure this is a very simple problem to solve, so if anyone could point me in the right direction that would be fantastic.
https://github.com/stephenmuss/django-ios-notifications
You don't seem to have activated Django's admin interface, which you need to access the admin forms. There are concise instructions in the documentation. You can switch to a different version of Django in the lower right corner, if you aren't using 1.5.