How to delete all data from Ember Data store? [duplicate] - ember.js

This question already has answers here:
Ember.js Data how to clear datastore
(7 answers)
Closed 9 years ago.
In the Ember.js application I'm working on, that uses Ember-data, once the user gets to a point on the screen, I want to delete all state stored in the ember-data Store associated with the application, and start with a clean slate that can start pulling data from the server. Anyone know how to do it?

I don't think there is an easy way. The only way ATM is loop over all your DS.Model classes and destroy the records individually.
App.Model.all().forEach(model) ->
model.destroy();
App.Model2.all().forEach(model) ->
model.destroy()

Related

How to create a Django post feed that gradually renders posts in batches as you scroll down? [duplicate]

This question already has an answer here:
infinite scrolling using django
(1 answer)
Closed 11 months ago.
I am trying to make a Django post feed without pagination, but hypothetically, once there are more than a thousand posts, it would be too heavy to always render all of the posts available. So I am trying to find a way to mimic what many other websites with infinite feeds (like Twitter for example) do so that it renders only a batch of posts, and then renders additional ones once you scroll down to the end of the already rendered ones.
I am using a function view instead of the class view.
Thank you in advance for any help.
It sounds like you should have an API to return paginated results from Django side,
and in your front end side, fetches say 5-10 posts at a time
GET /posts/?offset=0&limit=10
And you can implement a JS function that is hooked to the onScroll event that looks for if you have reached the end of the post already fetched. There are many libraries that do this for you by the way.
Here's a reference guide for basically exactly what you are looking for too: https://palewi.re/posts/2010/11/07/django-recipe-twitter-style-infinite-scroll/

How best to bite-size a form in Django, with no data persistence: What's the most Djangonic method? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
Firstly, the scenario in my question:
I want to deliver a form in bitesize stages, with the valid completion of one stage leading to the next until all stages are complete.
On completion, I'd like to use data once, and then forget it completely so I'm not holding on to any user data at all.
My options as I see it are:
Multiple views each with a unique form all bound to a single model. The final submit button in the chain triggers data in the model to be accessed, used and then that particular row removed.
Multiple views each with unbound forms, each adding data to a cookie, which is then read on the final submit, data used and the cookie deleted (either using sessions or plain old js hard coded into each template).
A single view and template containing a single unbound form, which progressively un-hides divs containing each stage until all stages are completed and final 'submit' posts data from the form, allows a view to process it and forgets it.
I can actualise all three of the above, but which is the most 'Djangonic' method, or is there a better method still?
There is a library made from the Django guys for this case: https://django-formtools.readthedocs.io/en/latest/wizard.html
It's not dynamic though, so when you click "proceed", it will render a new page. But you can probably write a javascript module, that can handle this. But I wouldn't go that far, it's a lot of work for little benefit. Just just django-form-tools and use the wizard you want and do whatever you need in the done stage of your view.

Facebook query for commenter name not working [duplicate]

This question already has answers here:
Facebook Graph API Comment Doesn't Return From
(2 answers)
Closed 5 years ago.
I have a problem retrieving information regarding the person commenting on the post using the graph API. I'm retriving as follow.
/comment-id?fields=message,from
https://developers.facebook.com/docs/graph-api/changelog/version2.11#gapi-90-pages:
/page/* — User information will not be included in GET responses for any objects owned by (on) a Page unless the request is made with a Page access token. This affects all nodes and edges that return data for objects owned by a Page.

The concept of django admin when adding information with foreign keys [duplicate]

This question already has answers here:
Django: adding an "Add new" button for a ForeignKey in a ModelForm
(3 answers)
Closed 6 years ago.
I really can't find the right words to Google this so I am here to find help. I want to use the idea of the admin page in django where when you add an information and it has a foreign key, a plus sign is present beside the field and with that, you can add data that pops up in a new window and after saving, the new data automatically reflects the selection.
Okay. I solved the add button. Now what I want is the data will appear after saving in the select drop down. I haven't had the answer to it yet
This is easy, if even the other model(which is your foreign key) is added to the Admin. It directly shows the plus button. But, if you don't want that.
I guess you are searching for InlineModelAdmin.

ember-data does not support embedded objects [duplicate]

This question already has an answer here:
Ember-data embedded records current state?
(1 answer)
Closed 8 years ago.
i'm working with ember data rev-11 and django tastypie. Looks like now ember-data does not support embeded resources but support sideloads (django tastypie does not support it). What is the best solution?
Thanks
This is not valid for Ember Data 1.0 beta+, see duplicate answer
Ember-data still supports embedded. You just need the right configuration. Here how you can do it:
DS.RESTAdapter.map('App.Foo',{
bar:{
embedded:'always'
}
})
App.Foo = DS.Model.extend({
bar: DS.belongsTo(App.Bar,{embedded:'always'}),
});
Available values for embedded are: always and load.
load: The child records are embedded when loading, but should be saved
as standalone records. In order for this to work, the child records
must have an ID.
always: The child records are embedded when loading, and are saved
embedded in the same record. This, of course, affects the dirtiness of
the records (if the child record changes, the adapter will mark the
parent record as dirty).
Similar settings apply for HasMany relationship, see this reply for more details