Asp.net View States in Django - django

I am asp.net developer, currently switched to django. I am working on first app and have to maintain user data for some time and then send it to db unless user save button is clicked.
I want to know if django provides some kinds of alternatives to view states to store data temp within a webpage.

You didn't explain what "view states" are, but I guess you are looking for sessions.

Its unclear what you are actually looking for, because viewstates is just a way to preserve data.
If you need to store information for a particular user, but not commit it to a database, use sessions as Daniel suggested.
If you are create a multi-step form (also called a "wizard"), and need to preserve state between each step/form; use Form Wizard.

Related

How to Assign States to Viewers of Django Web Application?

Problem Statement
I'm working on building out a single-page Django web app and am trying to implement the following functionality:
- All viewers of the page are associated with a state. There are buttons on the page which enable viewers to change their state.
- The application stores a list of all current viewers of the page, and their associated states. Whenever a user changes their state, this stored list of viewers updates with this new information.
- The application should display how many people are online (viewing the page) at a given time.
Blockers
I'm unsure of how to collect a list of all current viewers of a page in Django, nor how to collect how many users are currently viewing the page.
Ideally, my application would not require a login to use: therefore, I'd rather either associate viewer state with a user object that doesn't require sign-in, or not associate viewer state with a user object (I'm still new to user objects though, so forgive me if this point doesn't make complete sense).
What I'm Looking For
A discussion of higher-level strategies which I can use to implement this functionality, or other places to look to gain insight in tackling my problem. I'm pretty new to Django, so I'd appreciate it if answers also direct me to locations in my Django project which are of relevance (e.g. "Consider doing X in views.py, then..."). Alternatively, if there are GitHub projects you know of with similar functionality, if you could direct me to them to investigate further, that would also be appreciated.
I'd be happy to offer further clarification as required. Thanks in advance!

Store temporary information in sitecore

I've a doubt about the best practices related with Sitecore.
I will need to store a form information when the user presses Save button while he's still filling all the form before submit. Therefore, in case he goes to the website in the next day he will see the already filled information and he can submit.Because the form is long and splitted in four steps.
My doubt is more related with the best practices for Sitecore. Where should I store this information?
Should I create a table inside sitecore_core or other existing database and read from there? (If there's any way to do that with Sitecore libs)
Or should I create my own database, probably with just two tables, to store that information?
Thanks
You should create your own database and store the information there. It is no best practice to add tables to the Sitecore databases and storing this information inside one of the existing tables (ie Sitecore items) is also not the way to go.
So just go for the custom database.
If you are using user profiles and (xdb) analytics data and want to store the form data there anyway, that could also be an option (using a custom facet).
You should use WFFM for saving any form information. In case if you want to send/save any additional information then you add your custom save action. Like for example we save data from the contact us form and newsletter form to Eloqua or Marketo for other purposes using custom action.

Django handling automatic data creation through URL's

hello guys hopefully you guys are willing to work with a newbie I'm working in django and handling a google map (in jscript) which upon displaying a marker I have set a link that is clickable that opens a django url passing data regarding the location of that marker. If that data does not exist in the database I have created a definition in my view that does a check and populates the database with that data if it does not exist. Now the issue here is that what ever you type in for the url parameters ends up becoming populated in the database since there is nothing to validate it against regardless of whether you click in the google map or not. Now what I was looking to do was limit this database addition strictly to when a user clicks on a google map link, what would you guys recommend?
ajax, sessions etc... ? and how to go about it an example per se?
It would be good to have more info.
As a general rule, the http GET method shouldn't be used to change data. In this case, use a POST request, probably through AJAX.

Suggestions for an Authenticated Web Form solution

I am tasked with creating a web form for people to update their details. I have existing data which I need to authenticate users against to make sure we are updating the correct person. I get the feeling that if I code this from scratch I will be reinventing the wheel.
I'm looking either for an online survey solution like SurveyMonkey (but not SurveyMonkey as it does no have automatic authentication) or a web form system that I can install and configure.
Seems like I need to build my own.
I will code in PHP and use a MySQL database. The login screen will take three bits of information, which if found in a record in the database, will show the user a screen with their old data, and a form for updating this data. They enter their new data and hit submit which will put their information into another table in the database.
Nothing to hard but I'd rather use a pre-made system which is already debugged and comes with with some built in tools so the users can manipulate the data.

How to store user preferences in a web app?

i would like to know a good software engineering way to store user preferences in a web app.
to clarify further, my app has commands that the user can choose, so
i added a button that when some commands are selected, these commands are saved as favorites somewhere on the client's machine, that way if user X logs in at anytime he can check his favorite commands and load them automatically..
how to save these commands and where? and taking into consideration that several users using the same computer should not have access to each's favorites, so i want the favorite to be saved based on userID. where and how to save them? cookies? xml? and using php or javascript is better?
thx a lot for your help:)
The best way to do this is have them log in whenever accessing your site. Then you store all of the preferences on your server and deliver them down through your UI to their browser. This will mean that it doesn't matter what browser/device they happen to be using, their settings will follow them.
I'm not sure I like the idea of modifying someone's "favorites" in their browser. I'm not sure I'd stick with a site that wanted that level of control over my browser.
Now, if you are just talking about having a page on your site that had a list of "favorites", then that's okay. Just keep it server side.
Most typical would be to store them in a database of some sort on the server side, easily accessable by the UserID. Keep in mind 'preferences' are different from 'state'. State variables are usually stored via whatever cookie mechanism you are using.
What is your web app using to hold the data on the back-end? Most likely, that is where you will want to store user preferences. Since you will already be accessing that back-end (a database, perhaps?) to authenticate the user for login, retrieving that user's preferences is a simple step from there.
The real story here is that we need more details. Are you storing authentication information in a database, or something else? How are your user sessions stored (i.e., when a user logs in, how does your web app tell that his browser is logged in on subsequent requests)? Your question seems to state this, but to clarify, are these PHP pages containing some amount of Javascript?
Depends on your requirements. You will need to choose either to store user preferences in your database, provided your users authenticate, this is probably preferred solution. But if it meets your requirements you can save user preferences in a cookie.
Here is are javascript functions and jquery plugin with examples on how to work with cookies.