Since i'm using EAK, each time I save a model, I have an extra request method. It's more annoying then anything and I'd like to disable it. I haven't found anything in the documentation regarding this. Has anyone ever disabled it or am I stuck with it?
I may be wrong here, but this doesn't sound like a problem with Ember-App-Kit. Are you by any chance using CORS to send your requests? You say that it sends an OPTIONS request when you save a model, but you didn't mention that it sends one when it fetches a model. This makes me think that it's a preflighted request that is unavoidable if you're using CORS. We had this same issue about a month ago and we decided to ditch CORS in favor of a proxy server.
I've never used Ember-App-Kit, but it's just a build tool, so I can't imagine how it would affect your Ember-Data adapter.
Related
I have a basic user management project that I'm using off of which to scaffold other projects. It is a Vue CLI 3 front end and Django/Django REST Framework/Django REST Auth back end. The project I'm posting here uses sqllite but it can relatively easily be converted to another db.
Here is the link to the full repo for anyone who is willing to download to try to replicate my issue: https://github.com/JVP3122/user-project
I'm having a very strange problem in that when I log out of the site and then try to log back in directly from the same page it seems that axios is adding the payload to the beginning of the request method.
For example, in the images found in the post I put up in Imgur (https://imgur.com/a/bEsx662) the user name is simply "test" with the password "password", and when I try to log back in after logging out the subsequent login attempt is no longer a POST route, but instead a {}POST route. If I try again, the route becomes a {"USERNAME":"TEST","PASSWORD":"PASSWORD"}POST method.
I've tried looking at the config in the axios request interceptor, looking at the dispatch method in the rest_framework source code, and I can't figure out what is going on or how to solve this. It's a small bug that doesn't take away from the rest of the functionality, but it's a bug nonetheless.
Any help would be appreciated.
Did you try:
setting up new project (npm reinstall, clear npm cache etc..)
using axios.post instead of custom made HTTP object
I don't see anything in the backend that could interrupt the request and customise method as described in the original post.
Hopefully one of these two options above will resolve it.
Responded in your issue axios/axios#1994.
I have an app in django project which is exposed to only post method. I want to know whether it is compulsory to expose this app to other types of requests like get, put, and delete or not.
Thank you in advance
Seems improbable that a web framework wont handle a the very least GET and POST request, but if it the case, there is no point for you to have GET, PUT and DELETE endpoints indeed.
I've done research on Django Postman and it seems to be the most solid private user to user messaging platform out there. I've looked at the Django Postman documentation but it's very template orientated. For developers who use Django as a back end and only care about the views.py and urls.py, the documentation doesn't say much.
I did however find this: https://bitbucket.org/psam/django-postman/src/6ff9fdf9c33f7365a7235a789af2e47f47d9c4fa/postman/views.py?at=default
It seems pretty promising so I'm going to give it a try. My only issue is how can one set up the postman views in views.py and the urls in urls.py to create a messaging system similar to Facebook's?
(ie. A thread like messaging conversation system, a central inbox where all the messages come together from each user showing the last message from each user, messages in the inbox are sorted by conversation rather than the message, the time of the last message sent, allowing multiple recipients)
Below I've posted a picture of Facebook's messaging platform. This is what I am essentially trying to achieve with Django Postman.
Facebook Example http://screenshots.en.sftcdn.net/en/scrn/73000/73077/facebook-19-371x535.jpg
If you have any pointers, hints and ideas on how I can set up the views.py, I would greatly appreciate it! Thank You
I've run into this issue before.
You need to strictly override some of the views in there by clonning/forking the project and install it from your own location, because as you noted, postman is template-oriented because it's meant to only get the needed templates configured and a few settings. I mean, the backend is meant to work as is.
What you need to do is override stuff like:
Message model's recipient field to be a ManyToManyField
customize the views based on your needs and be careful with Message.replied_at
make sure you allow a user to reply to their own messages (by default, it was not allowed when I ran into this, not sure now)
Depending on your needs, maybe you'll want to override something else, but this is a good start. If you need it facebook-like, you'll need to use some push libraries as Pusher or Juggernaut, maybe you're interested in them also.
Good luck! :)
I've been working through an issue with my django project. The issue is I've got one project, which will retrieve data for users of different clients. I need to know 'from where' a viewer is coming from (request.path [my original solution]). I've been looking at a number of different options which sound close to what I want to do, but I'm not sure what the best option is, not having done this before.
My first option was to add a url in the urls.py with a 'tag' or 'keyword' then look for that tag/keyword in the request.path, which I'd add as a session key. Then go onto get the data.
Something else I started looking at was the sites framework. After reading through the documentation, I'm still confused how sites actually works, so I'm not sure if this is the right option.
Another solution talked about using middleware, this came up in connection with the research into using the sites framework.
And then yet another talked about doing this in apache.
Could some one help point me in the right direction?
Cheers,
T
If you need to know from which URL came your user to your currrent page you should check the REFERER http header, available in request.META.get('HTTP_REFERER').
See http://docs.djangoproject.com/en/1.2/ref/request-response/#ref-request-response for more informations.
Be careful though, the referer meta is not mandatory and could be missing due to private browsing or direct access to the page from the URL bar.
It's not completely clear from your question, but if you're asking for the URL that the user was on before coming to the current page, you probably want request.META['HTTP_REFERRER'].
Edit after comment
That would be a very bad idea. Global variables are not safe given that you potentially have multiple requests being processed at the same time. The referrer is already available from the request, which can be accessed in all views and templates, so I don't know what else a middleware would give you.
I need to have a status message that is set while processing an initial request appear after a redirect occurs. A pretty normal thing to need to do but I'm unclear how to use the session object to do this in Django. I know there's a plugin someone made: https://github.com/danielfm/django-flash/wiki
Is that the recommended way of handling this situation in Django or can something simpler be done with the default install of Django?
Looks like this is part of django as of 1.2:
http://docs.djangoproject.com/en/dev/ref/contrib/messages/
There is no standardized (in Django) method yet for session messages.
Here's a good discussion of the issues: Towards a Standard for Django Session Messages
Besides the django-flash project you already found there is a least one other one: django-notify.