Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discovery not filling in required JS module/function handlers #117

Open
scornflake opened this issue Sep 28, 2013 · 2 comments
Open

Discovery not filling in required JS module/function handlers #117

scornflake opened this issue Sep 28, 2013 · 2 comments

Comments

@scornflake
Copy link

I have been following the setup instructions here:
http://django-dajaxice.readthedocs.org/en/latest/installation.html

INSTALLED_APPS and other vars are setup as per doco.
A sample view page loads, and contains the JS in the , but the JS itself looks like this:

var Dajaxice = {








get_cookie: function(name)
{
    var cookieValue = null;
    if (document.cookie && document.cookie != '') {
        var cookies = document.cookie.split(';');
        for (var i = 0; i < cookies.length; i++) {
            var cookie = cookies[i].toString().replace(/^\s+/, "").replace(/\s+$/, "");
            // Does this cookie string begin with the name we want?
            if (cookie.substring(0, name.length + 1) == (name + '=')) {
                cookieValue = decodeURIComponent(cookie.substring(name.length + 1));

i.e: no module or functions have been generated, thus the JS code doesn't exist to be called, to initiate an AJAX request.

My ajax.py is:

@dajaxice_register(method='GET')
def test_call(request):
    return json.dumps("<b>Foo</b>")

I've inserted logging into my ajax.py, and it's definitely being loaded by auto discovery as part of urls.py.

I have tried to check that dajax is discovering my functions, however (and this may be my limited understanding of python) I cannot iterate the 'modules' properties of dajaxice_functions (it's NoneType) to check that the discovery added something into the dajax state. I get an exception:

for module in dajaxice_functions._modules:
    logger.info("module: {0}".format(module))

TypeError: 'NoneType' object is not iterable

So either my python foo sucks (very possible) or discovery is in fact not registering that function.

I'm at a bit of a loss as to how to proceed. It looks close to working; but the lack of function discovery has me stumped. Any tips / pointers?

@abakan-zz
Copy link

I have a similar problem. My module functions are found in dajaxice.core.js when I run the development server, but when I collect static files they are not in there. I just get what you showed above. Do you also have them when you run dev server?

@scornflake
Copy link
Author

For me the prob was that I didn’t see anywhere at all that I had to collect static, I thought it was dynamic.

Works on both dev+other for me, but then I’m running vagrant + ansible, so dev+prod is the same VM, same codebase...

N

On 17/10/2013, at 7:09 am, Ahmet Bakan [email protected] wrote:

I have a similar problem. My module functions are found in dajaxice.core.js when I run the development server, but when I collect static files they are not in there. I just get what you showed above. Do you also have them when you run dev server?


Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants