I am working on deploying a django app to heroku and I am having trouble with the webbrowser module. The function initially creates a pdf from html using pdfkit (this part works fine). Afterwards, I use '''webbrowser.open_new_tab''' to render the pdf in a new tab. This works perfectly locally, but not when I deploy to Heroku :( I checked the Heroku log, and it indicates that the pdf is being properly compiled and that the webbrowser command is successfully called, but alas, a new tab is not opened... Are there any suggestions on how best to tackle this issue? Perhaps I am missing an important environment variable that allows me to open new pages on the user's browser?
Thank you,
-- Carter
Related
I hope someone can help out with this one. I have been using djangocms to build a simple frontend centric website for a client so they can maintain their own content. There is nothing fancy in this setup. Just a few template.html files, a little css and djangocms to pull it all together. There are no other forms, models, views or anything at this stage. Just pure djangocms.
Originally I was working with django 1.8.6 and the image picker seemed to work fine. I could upload my files and next to each one there is a selector icon which works and all was great. See below image. This was using cmsplugin-filer.
Then I tried to upgrade the website to Django version 1.11.13 and I started to run into this problem. The file select that you see above is no longer available to the user. I have spent days working on this and in my travels I found that apparently cmsplugin-filer is now deprecated. So I removed it and switched to the recommended djangocms-filer install thinking that might solve my problem...but no. After many many hours of head scratching I figured it must be something in my project throwing things out, so I have done a 100% clean install using the prescribed djangocms-installer. Other than connecting it to a postgresql database, it is a completely vanilla installation, and yet it still does not work. All I get is the image below. A simple tick box but no way of selecting the image nor anyway of saving what I have selected. Uploading files is fine and I can create folders and images upload into them perfectly fine.
Below is a snapshot of my pip freeze showing everything installed in my virtualenv and the associated versions.
My settings file is almost 100% standard so I don't understand why I can't get this to work. Note: If, when I am adding the plugin to my template, I don't select the Choose File Button but simply drag an image into the grey rectangle, it all works fine. My file gets uploaded into the unsorted uploads folder and the image is selected into my template all in one go, but using the choose file route, where I have more control over my files and how they are stored, doesn't.
Does anyone have any idea what I might be missing please?
UPDATE:
Django CMS overrides some static files and there are some old ones in your browser cache. You need to clear your caches or open the page using incognito window.
I am using django-ckeditor python package in my django app (django 1.11 + python 2.7). I have integrated it with s3 and it is hosted on Heroku. So far everything runs smooth.
Earlier I had an issue that non admin user could not upload images to server thus can not use any images as a part of their content. I fixed it by overriding ckeditor's browse and upload view. When i tested it it was working just fine. I pushed it to production.
Now none of my user can use ckeditors image upload or browse feature. when I try it, (as an admin or as regular user) it works. some users reported that app crashes, some said image wont show up despite uploading to server (also I can't see it in my s3 bucket.)
other images are working well with s3 for all users. but ckeditors images are working only for me, no matter which machine or which role I try as.
I also checked heroku apps, but they are not helpful at all.
Does anyone have idea any guesses why this could be happening.
It is my first time trying to get a Django application live on the net but I am having an issue with the URls.
The working local URL of my application is
http://localhost:8000/surveythree/ - This works as expected.
However when I upload my project to my hosting account I cant seem to locate the relevant page using the shortened URL as provided by the URLconf, in this case it should be /surveythree/
url(r'^surveythree/$', SurveyWizard.as_view([SurveyForm1, SurveyForm2, SurveyForm3, SurveyForm4, SurveyForm5])),
I can locate the page if I use the full filepath however.
http://www.mywebsite.com/bias_experiment/src/survey/templates/formtools/wizard/wizard_form.html
I thought the benefit of the URLconf was to shorten the URL to something like one of the following
http://www.mywebsite.com/bias_experiment/surveythree/
http://www.mywebsite.com/bias_experiment/src/surveythree/
http://www.mywebsite.com/bias_experiment/src/survey/surveythree/
Is there something simple that I am missing here? If anyone could tell me what the shortened URL should be based on the above it would be great. I have been trying multiple combinations for a while now but I don't know if I am going around in circles or doing it wrong.
Thanks in advance.
It doesn't look like you have actually deployed your site with a proper server. You can't just upload the files to any webserver and expect then to run: you need to configure a wsgi server and connect it to your app.
The documentation is here but to be honest I'd be amazed if your college server supported it at all, if all you have is a shared folder. You may be able to get it to work with FastCGI, but I wouldn't hold out a whole lot of hope.
(And even though you say that going to that long URL "works", I'd guarantee that all you're seeing is the raw HTML template. There's no way that any actual dynamic functionality will be working like that, as you'd see if you actually tried to submit the form at that URL.)
Deploying Django apps is much more complicated. To run in more "production" environment you will need to configure:
virtualenv to keep pip modules which your app required separate from global environment.
nginx for hosting static files ( you can copy them to some folder with ./manage.py collectstatic.
WSGI server: uWSGI or Gunicorn are both nice choices.
supervisor: for running and restarting WSGI and any other apps (for example celery) running in background
It's a lot for a start, so it's good to follow some tutorial and use ready to use config snippets.
I am trying to use HTSQL for one of my Django projects. For that I followed the procedure given HERE for furnishing HTSQL/Django requirements. Then I cloned the HTSQL repository for trying the example/demo in it from HERE. I am testing this on Django v1.4. The default db used in the demo example is sqlite3. In Django python shell, the queries are working fine now as per THIS question. But as demonstrated on HTSQL Website, it has a very powerful frontend to communicate with the database and also generates efficient queries (reference). I am trying to use this particular feature for my Django application which is also demonstrated in the demo/example django app from HTSQL. In the demo app, when I started my local django server and tried to access the following url:
localhost:8000/htsql/
The page loads and when I write the following lines:
/polls_poll
to see the data from the polls_poll table, the RUN button does nothing and so does the more drop down menu. No error, no response, no data fetched from the polls_poll table. Then I noticed that the page wasn't loading properly i.e this trace was generated on the Django server terminal. So basically,
codemirror .js and .css files were throwing HTTP 500 error. For that I searched for the links of the codemirror .css and .js files and provided those links in the index.html of the HTSQL resided in the static folder. Following is its path:
>>> /usr/local/lib/python2.7/dist-packages/htsql/tweak/shell/static
Now the terminal trace has changed to THIS
But still the RUN button does nothing and no data is fetched from the table polls_poll
Am I doing something wrong or missing something??
CodeMirror just changed the download URL for their packages, which broke HTSQL shell. You either need to apply the following patch manually:
https://bitbucket.org/prometheus/htsql/changeset/f551f8996610bb68f2f8530fc6c0dbf6b5c34d90
or you can wait for the next bugfix release of HTSQL, which will be out in a day or two.
everytime i test my selenium test, the instant of firefox will popup and show page of selenium rc. It's ok and cool. But i have problem. For every test i also have to see a firefox's page pop up and shown selenium plugin have been add to firefox.
is there any way to configure selenium so it initiate firefox without a popup page cause after a hundred test, it start to irritate me ;D
I'm sure this is a duplicate of another SO question, as I feel like I've answered it before, but I can't find it. If I do subsequently find it then I will update my answer.
You need to set the extensions.lastAppVersion preference to match the version of Firefox that you're launching. Otherwise you will generally have an additional tab in Firefox and the Addons manager popup.
You may need to configure Selenium to use a custom Firefox profile in order to make this change.
Removing the extensions.rdf file from profile directory will fix this issue . I have created a separate profile for Selenium tests, which is only used for Selenium Tests. I would love to hear if there is other way around . My "extensions.lastAppVersion" is updated and reflects the current browser version therefore the above trick does not work for me .
Remember, invoking selenium by user will re-create extensions.rdf file, therefore I prefer to keep separate profile for Selenium
Having found this answer and had a go, I found that merging the Extensions.rdf and extensions.ini file from the temporary profile created in a Selenium session and putting that into your Custom Profile directory solves this problem.
When merging extensions.ini, be careful to avoid getting the pathnames wrong.
Use this -
From the address bar type “about:config” and add/update the following:
- extensions.update.notifyUser (type=boolean; value=false)
- extensions.newAddons (type=boolean; value=false)
It worked for me.