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.
Related
I hosted a small django project on virtual machine on digital ocean. Before I started using digital ocean to serve static files everything worked fine. But immediately I created a storage space and push my static files there the static files are not being served on the webpage, including django admin page (the project pages are showing net::ERR_ABORTED 403 (Forbidden). I have already installed django_storages and boto3.
I got some hint as to the possible cause of the problem when I clicked on digital ocean aws bucket url that looks like https://django-space-storage.nyc3.digitaloceanspaces.com. When I cliked on it I got the following error:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
It seems the browser is rendering my django pages as xml instead of html. I might be wrong with this assumption because I'm finding a hard time trying to understand what is actually going on. My question is, how do I cause the browser to render my django pages as html instead of xml?
The django geoposition widget shows up in admin when I am testing everything on my laptop with the django test server. However, when I put everything onto my production server, there is no map showing up and no labels showing up for the latitude and longitude. Both setups are using django == 2.1.7 and geoposition == 0.3.0. The production server is being served with nginx and gunicorn.
I opened the browser inspection window and it turned out that the geoposition.js is being served by django before jQuery is being called. So I tried calling jQuery directly in the geoposition.js file, but there is still no widget. I then revert everything back to it's original stage and I am now including js = (setting.STATIC_URL + 'geoposition/geoposition.js") in a media class in admin.py. This is causing two maps to appear in my test server, but still no map in my production server. I added an if statement so that it doesn't run if jQuery is not loaded, so no jQuery errors on the first geoposition.js being served. I added some console.log() statements to the file so I can see where it is at and it is getting into the main function fine, but not getting into the $('.geopostion-widget').each(function() ...
When I look at the html, the map and latitude and longitude values are wrapped in a div of class = "geoposition-widget", but that there is no such div from my production server which makes sense as to why the '.geopostion-widget' function is not doing anything. It seems to be putting in that div automatically on my test server, which it is supposed to do, but not on my production server.
Any clue as to why this is happening? Do I just need to create a custom form for the admin on my production server and wrap the field in a div with class = '.geopostion-widget'? This just seems kind of janky since it is working fine on my test server. Or does it have something to do with the way it's being served with gunicorn and nginx?
Found the answer on github here - https://github.com/philippbosch/django-geoposition/issues/83.
imdario's answer at the bottom solved it. Upgraded geoposition package to imdario's geoposition pakcage with 'pip install django-geoposition-2' and voila - it works.
I am trying to access a proprietary website which provides access to a large database. The database is quite large (many billions of entries). Each entry in the database is a link to a webpage that is essentially a flat file containing the information that I need.
I have about 2000 entries from the database and their corresponding webpages in the database. I have two related issues that I am trying to resolve:
How to get wget (or any other similar program) to read cookie data. I downloaded my cookies from google chrome (using: https://chrome.google.com/webstore/detail/cookiestxt/njabckikapfpffapmjgojcnbfjonfjfg?hl=en) but for some reason the html downloaded by wget still cannot be rendered as a webpage. Similarly, I have not been able to get Google Chrome from the command line to read cookies. These cookies are needed to access the database, since they contain my credentials.
In my context, it would be OK if the webpage was downloaded as a PDF, but I cannot seem to figure out how to download a webpage as a pdf using wget or similar tools. I tried using automate-save-page-as (https://github.com/abiyani/automate-save-page-as) but I continuously get an error of the browser not being in my PATH.
I solved both of these issues:
Problem 1: I switched away from wget, curl and python's requests to simply using the selenium webdriver in python. Using selenium, I did not have to deal with issues such as passing cookies,headers, post and get, since it actually opens a browser. This also has a plus that as I was writing the script to use selenium, I could inspect the page and see what it was doing as it was doing it.
Problem 2: Selenium has a method called page_source, which downloaded the html of the webpage. When I tested it, it rendered the html correctly.
I am looking for an example about how to display git log data about a commit.
I get the commit via shell script; then retrieve the info about this commit and make it pretty. Now I would like to add on a web app in Django, the capability to pass hash and project repo name, so I can display thee info in a nice way.
Altho I can't find tutorial that show how to build a web app for django, that display a page in this way. I just start with the tutorials today, so I don't know much. I also need to read from file, so I don't need a database nor the model, right?
IS this too complicate for a first Django app?
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.