-
Notifications
You must be signed in to change notification settings - Fork 291
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
CRUD #21
Comments
Can you add some code? Can't see what's wrong without it. |
This is the js file I used. I'll put gists of the other files if necessary |
The problem is that you redefine the query method with isArray = false, while query returns an array of objects. |
Well removing that gives me the same error. I seem to be getting an html page instead of the the model object |
The html is probably django debug page, so the issue seems to be in the django code. Angular is set up correctly after fixing the isArray quirk. What does the html page say? |
This is the html |
It looks like the view you have on crud/task isn't a subclass of CRUD view, since you get a html response rather than json data. |
So how do I make it a subclass? |
There's an example in the docs. You need 2 views, one that returns html page and another one that is a subclass of NgCRUDView. |
You mean like this
I already have that in views.py |
Yes, exactly. I guess crud/task doesn't point to this view in urlconf then. |
Actually it does
|
Well if you get a HTML response there must be something wrong in the urlconf. NgCRUDView never returns html. Probably you have a entry in urlconf that matches crud/task and points to the HTML view. |
No, there are no other entries for crud/task.
and these are the url patterns I have
|
So just to be clear, Task.query() returns a HTML page, the one viewTask should be returning? Can you add some django logs? |
Yes exactly. I'm getting a runtime error
|
Could you post the whole traceback at least? Or alternatively the whole code if you're okay with that. |
@dasf, here is the whole code |
Oh, the problem is that ForeignKey fields can't be serialized, which raises an Exception. I will make a fix and create a pull request. As a temporary workaround you can remove the fk field in your view.
|
This has now been fixed in 0.6.1 I suggest you reinstall django-angular to get the latest version. If you still have problems please reopen the issue. |
@dasf, Sorry for following this up a little late, but I tried using a model without foreign key and that didn't work either. I'm still getting html instead of json. |
Did you update django-angular? Also if you still get HTML response please post the response you're getting. |
@dasf, yes I did update django-angular to version 0.6.1 The HTML response is view returned by viewTask in the code |
After a while of trying I can't get your code to run, getting some weird errors, might look into it when I have more time. If you're using the latest version from https://github.com/thegeorgeous/tripping-octo-tyrion, the problem is you have the temporary fix for 0.6.0 in your code. And that won't work with 0.6.0 either since you're calling the wrong view in super(). This works now, without overriding the get_fields() method.
If after this you're still getting any errors please attach some django logs. |
This is what I get in the Firebug console
and this is the djangologs I get
|
The problem is that you have 'crud/task' in angular service config, so when making a request it appends that to current path, thus making a request to '/timesheet/viewtask/crud/task'. Which is matched by regex for your normal HTML view. In your case you need '/crud/task' in the service config, so that when making a request from /timesheet/view the query goes to 'crud/task', without the timesheet part. |
That worked!!! Thanks for bearing with me @dasf !! :-) |
Simple CRUD query to get all objects returns HTML page instead of object, generating the following error
The text was updated successfully, but these errors were encountered: