how to map urls.py for autocomplete - django-haystack

I'm new to Haystack as well as Django and Python.
I've followed the Haystack Autocomplete tutorial. I have added the following line to my urls.py: url(r'^search/', include('haystack.urls')),
I also have elastic search running, and I can see that it builds the index properly. However, how do I actually get the results in the app? I tried hitting
http://127.0.0.1:9000/search and
http://127.0.0.1:9000/search/autocomplete
in my browser as a test, but I just get "Cannot get search" messages back. Can somebody tell me what I'm doing wrong here?

The default Django port is 8000. Try that :)

Related

OperationalError at /register/

When I am trying to signup in django app on heroku, it's saying no such table: auth_user . I tried to run manage.py migrate -syncdb. It execute successfully but still the problem is same. I works perfectly in development environment.
What can be done to fix this.
I'm not sure what your auth_user model looks like, but I'm going to guess it has a Meta option of managed = False. Switching this to managed = True should resolve the issue. From the django documentation, this ensures that Django will create the necessary tables on migrate commands.
If this is not the case, please provide the code where you defined your model and I'll try an alternate route.

Broadleaf - running locally - problem getting started the API project

I'm trying to run Heat Clinic 6.0.1 locally following getting started tutorial: https://www.broadleafcommerce.com/docs/core/current/getting-started/running-locally
I managed to run admin and site but not the API project. The application starts without problems but when I go to http://localhost:8082/api/v1/swagger-ui.html I get a 404. In the log I see this exception:
javax.servlet.ServletException: Circular view path [error]: would dispatch back to the current handler URL [/error] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
Also trying to log in directly in the API with user broadleafapi and password gives 404.
My environment: Windows 10, jdk 8, maven 3.6
What's wrong? Can you help me? Thank you
Thanks for the report. I reproduced this and it looks like that with the update to Spring Boot 2.0, we did not appropriately override the updated property that specifies the servlet location to embedded Tomcat. Thus, when you went to /api/v1/swagger-ui.html, the application treats it exactly like that URL which is what gave the 404.
Setting the server.servlet.contextPath=/api/v1 property appropriately stripped off this path as part of the servlet context and resolved the 404.
I tested around a bit and was able to 'Authorize' the app (button at the top right of the Swagger page) with the credentials information that get spit out in the logs:
Basic auth configured with user broadleafapi and password: <<generated>>
then I was able to hit the API endpoints.
The changes you will need to make locally in your project to consume the fix are at https://github.com/BroadleafCommerce/DemoSite/commit/422d1cdc37f847afd8bec0be477ab784cbad2e9d#diff-991c59b6dbb0f619b8570d8f8779eaddR11. You will notice that I moved the original definition in default.properties over to common.properties and I recommend that you do the same. To be clear, follow these steps:
Delete the server.servlet.contextPath entry in `api/src/main/resources/runtime-properties/default.properties
Change server.servletPath in api/src/main/resources/runtime-properties/common.properties to server.servlet.contextPath
Thanks for trying out Broadleaf and the report, sorry for the rough early start!

ExpressJS, NodeJs, and MongoDB CRUD Skeleton - Mac

I have recently started working with MongoDB and had it working for a small web test with node JS However. I new my implementation wasn't following a decent MVC structure. I began searching and found this website and read through it. It's implementation look good as well as following a good MVS skeleton structure.
Express/NodeJS/MongoDB CRUD Skeleton
I got to the part where he says 'HOORAY! We've got a functioning web server that is talking to Mongo. Part 1 is accomplished." Unfortunately, I went the local host specified and it says the 'site cannot be reached'. I am still fairly new to NodeJs, Mongo and Express and cannot figure out why it is not working.
I am not sure if I have done a step wrong time and time again which I doubt or if there something is missing that is stopping me from having it working.
The part before it says:
Awesome. Now to test it's all working in the terminal type npm start and you shouldn't see any errors:
kcoleman-mbp:nodewebapp kcoleman$ npm start
> nodewebapp#0.0.1 start /Users/kcoleman/Documents/projects/nodewebapp
> node ./bin/www
That part I get the same outcome with:
nodewebApp and node./bin/www
The page says to navigate to 127.0.0.0:3000, but the localhost usualy defaults to 127.0.0.1. I didn't see any code in the page where he defines the port to 127.0.0.0.
So try connecting to 127.0.0.1:3000.
Coming to nodewebApp and node./bin/www, it could be because the command might be present in pacakge.json. If you delete the nodewebApp from package.json, you won't be seeing the same in the command.

NodeJS: Express: node-blade: Live UI

I am using Node.JS/express and node-blade (npm blade) as the template engine.
I'm trying to take advantage of the fantastic Live-UI feature set in Blade, but can't seem to get the Live updating views working; i.e when rendering content into an element any changes to the Model after the initial render are not reflected in the view.
The client side isn't throwing any errors, and events such as {click} and {change} work in the templates, but the view won't update to any changes in the Model without re-rendering the template.
On the browser;
systemVM = new blade.Model({test: 'stackoverflow'});
$('#wrap').render('pub/login', systemVM);
In the template;
h1 Hello #{test}
input
{change}
test='World!';
Have also tried; (on the browser)
systemVM.observable.test = 'World';
And; (on the browser)
systemVM.observable.test = 'World';
systemVM.invalidate('test');
And; (on the browser)
systemVM.observable.test = 'World';
systemVM.invalidate('test');
systemVM.sync();
Has anyone had experience getting this going?
It's also worth mentioning that the file 'plugins/deps/deps-utils.js' was missing from the spark-standalone.sh build script for using Meteor's 'Spark' and while spark built without it and isn't throwing any errors, I can't help but think that might be the issue. Have tried building spark-standalone from historical git commits, but every time the build throws errors.
Any help would be really appreciated, this is driving me crazy!
Issues were resolved by the standalone Spark.js file found at http://icomputeconsulting.com/spark.js (hope BMiner doesn't mind me posting this link)
Use this link: Un-official GitHub Repo

Drag 'n' Drop files to a Chrome Package App?

Has anyone successfully implemented drag and drop with files from desktop to the app?
I've tried just putting this drag 'n' drop example into the index file but I just get this error:
Can't open same-window link to "file:///C:/Users....whatever"; try target="_blank".
Please share your stories, what you've tried and if you have succeed :)
Some resources to help you:
New Chrome Packaged Apps codelab that we've been working on covers drag-and-drop in both AngularJS and pure JavaScript.
AngularJS drag-and-drop: https://github.com/GoogleChrome/chrome-app-codelab/tree/master/lab5_data/angularjs/2_drop_files
JavaScript drag-and-drop: https://github.com/GoogleChrome/chrome-app-codelab/tree/master/lab5_data/javascript/2_drop_files
There's an early version of docs too for AngularJS drag-and-drop for Chrome at developer.chrome.com/trunk/apps/app_codelab5_data.html#handle_drag_and_dropped_files_and_urls
We're working on the docs to cover both samples though.
I have done this a while ago and it worked.
The problem you've got is that you are creating a file url, then trying to navigate to the url. The navigation is failing, not the read. It's failing due to CSP, and you probably won't be able to override that with a different CSP due to security restrictions we've placed on allowable CSPs.
But, you should be able to just read the file and use the content. You need to change that sample code to use ReadAsText or ReadAsArrayBuffer instead of readAsDataURL. Look here for more details.
Please let us know how you get on!
Just listening for drop won't work. You will have to prevent the default functionality of dragover.
document.body.addEventListener('dragover', function(e) {
e.preventDefault();
}
document.body.addEventListener('drop', function(e) {
alert('it works!')
}

Resources