Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
Let's say you have a universal college application. The user inputs their information and the universal application submits the correct subset of information to each school.
What is a good approach to organizing the data validation?
For example, when a user decides to apply to school A you must validate that the user has input into the universal application all of the information required for school A.
This process is repeated for school B, school C, etc. Most of the information that must be validated is probably the same for each application, with some small differences.
Is there a library or architecture that would be optimal for setting this up? I've looked into solutions like Cerberus or Py-Good which help with the validation part, but not really the high-level approach.
In Rails, I have seen a solution called validation contexts. I am trying to implement this in Python (Django).
If you are working with Django, it has everything you will need to validate incoming data. The standard way to validate data with Django is through forms (and more specifically, form validation.)
From the docs:
Django’s role in forms
Handling forms is a complex business. Consider Django’s admin, where
numerous items of data of several different types may need to be
prepared for display in a form, rendered as HTML, edited using a
convenient interface, returned to the server, validated and cleaned
up, and then saved or passed on for further processing.
Django’s form functionality can simplify and automate vast portions of
this work, and can also do it more securely than most programmers
would be able to do in code they wrote themselves.
You will find some helpful examples in the links that I've posted. I would recommend looking at the clean method.
If the logic is mostly the same for each scenario, but with slight differences, you will likely be able to create a single form that can process the data appropriately based on what the user has selected.
Hope this helps.
Related
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 8 years ago.
Improve this question
I have been looking at django-tastypie and django-rest-framework.
What is the advantage of using an API?
I've thought of following use cases. Which use cases is an API primarily intended for?
'External developers' who wants to use the data from my website on their own website?
For me to get a nice overview of my data (even though the admin does this job good)?
Use the create, read, update and delete functions in ajax calls on different pages on my website?
Or should all views that get data from a model get the data through an API to check permissions etc.?
I have read some of the documentation for both APIs but it's still not completely clear to me.
Django has request.is_ajax() and Django 1.7 introduced JsonResponse so I cannot see why a big complex framework could make a better job sending and receiving json but I guess I'm wrong based on the number of developers who use the api frameworks :-D
For the exact same reasons than you used the django-admin for the admin instead of writing views, forms and templates from scratch:
less work
tested and approved by many other developers
therefore more secured
DRF has a really nice architecture. When you use it, you'd think "that's how I would have done it" (the truth is "this is how I wish I would have done it").
DRF also let you browse/test the API via HTML.
'External developers' who wants to use the data from my website on their own website?
Yes
For me to get a nice overview of my data (even though the admin does this job good)?
Admin is better indeed for that.
Use the create, read, update and delete functions in ajax calls on
different pages on my website?
Yes
Or should all views that get data from a model get the data through an
API to check permissions etc.?
You don't have to get data through your API (is that what you mean?). I've never setup an application this way. That being said, you can do it, start by building an API both for you and external developers especially if you're going to use a lot of Javascript.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I heard a lot of people talking about Django on various forums. But I am having a very basic question : What is meant by Framework and why Django is used.
After listening a lot about Django, I ran few chapters for Django (from Djangobook.com). After running these chapters, I am wondering how Django can be used to create a very simple website. (Website should have few pages like Home, Favorites, About, Contact linked to each other and will be providing static content).
Can Django be used for creation of such website? I searched a lot on internet but couldn't find any relevant examples, I only encountered with the examples for creation of blog, forum sites etc. If Django can be used for creation of this website, what should be the approach.
Can someone please explain this basic term "Framework" and its significance?
No. It's not for making websites. Your sample just sounds like you want plain old HTML.
Django is for creating web applications. That is, software, normally backed by a database, that includes some kind of interactivity, that operates through a browser. A Framework provides a structure and common methods for making this kind of software.
I think what you're looking for is a very simple CMS (Content Management System), there are many of those available in all kinds of languages/frameworks. Django has django-cms and mezzanine (among others).
What django is really awesome at is building dynamic websites really fast, you don't need to worry about most things, you just define your data model and off you go (almost). If you want to have a better insight into what's possible, have a look at the django tutorial (under "First Steps"), it gives you a good introduction to django and how to build websites using it.
Django can be used to create dynamic high-security web applications. For creating a static website like the one you asked, HTML is enough.
Tutorial for creating a django application can be found here.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'd like to data mine my Outlook mailboxes at work to be able to learn more about interactions with people and their areas of expertise:
Generate social graphs from To: and Cc: lists to show people as nodes on a network with lines between who they interact with
Tag people with concepts (i.e. from pronouns and recognised definitive company concepts and synonyms within emails)
This would give an insight into who does what (including showing how their work changes overtime) and perhaps assist other ways of knowledge sharing and documentation.
My question broken down into parts:
Is there an alternative Outlook client to datamine emails
Or working examples of using some kind of API library
Would like to do this live at a certain frequency, so that it updates as more emails are created
Also, I'm considering applying things I will learn from the following book: "Natural Language Processsing With Python": http://shop.oreilly.com/product/9780596516499.do (this post is not a stealth advert for this book or outlook, I am not the author nor work for the publisher). BUT any language will be fine - I can always bolt-on ideas from this book later.
Concerns might be that this has big brother connotations but it also has benefits whereby the primary email system can continue to be used without being impacted and this adds value by becoming a business social media overlay to find people with certain knowledge quickly.
Update
Parallel question voted closed on superuser.com (as duplication is not necessary and I guess that widest choice of answers will be programming based) - so please add your answers to this stackoverflow question right here, not the one on superuser.com
Question also posted here for non-programming angle (to see if existing application available): https://superuser.com/questions/343981/outlook-alternative-or-working-demos-of-apis-into-outlook-to-datamine-emails-to-p
Update 2
Any language is fine. Python is in this Question's tags but that is because a book on Python is mentioned, rather than me requiring answers to be Python based. I can accept answers in any language. If I also wanted to apply what was in the book then I could always "bolt-on" Python code onto the answer if need be.
You can link outlook folders to databases
-- outlookcode.com/article.aspx?ID=25
-- support.microsoft.com/kb/209946
...and once extracted to: list, cc: list and email text body strings from the database, you could consider ideas for data mining the data from the book "Natural Language Processsing With Python": http://shop.oreilly.com/product/9780596516499.do (this post is not a stealth advert for this book or outlook, I am not the author nor work for the publisher).
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Anyone could recommend a good guide/tutorial/article with tips/guidelines in how to organize and partition a large Django project?
I'm looking for advices in what to do when you need to start factorizing the initial unique files (models.py, urls.py, views.py) and working with more than a few dozens of entities.
Each "application" should be small -- a single reusable entity plus a few associated tables. We have about 5 plus/minus 2 tables per application model. Most of our half-dozen applications are smaller than 5 tables. One has zero tables in the model.
Each application should be designed to be one reusable concept. In our case, each application is a piece of the overall site; the applications could be removed and replaced separately.
Indeed, that's our strategy. As our requirements expand and mature, we can remove and replace applications independently from each other.
It's okay to have applications depend on each other. However, the dependency has to be limited to the obvious things like "models" and "forms". Also, applications can depend on the names in each other's URL's. Consequently, your named URL's must have a form like "application-view" so the reverse function or the {% url %} tag can find them properly.
Each application should contain it's own batch commands (usually via a formal Command that can be found by the django-admin script.
Finally, anything that's more complex than a simple model or form that's shared probably doesn't belong to either application, but needs to be a separate shared library. For example, we use XLRD, but wrap parts of it in our own class so it's more like the built-in csv module. This wrapper for XLRD isn't a proper part of any one application, to it's a separate module, outside the Django applications.
I've found it to be helpful to take a look at large open-source Django projects and take note of how that project does it. Django's site has a good list of open-source projects:
http://code.djangoproject.com/wiki/DjangoResources#Open-SourceDjangoprojects
As does Google (although most of these are smaller add-in template tags and Middleware:
http://code.google.com/hosting/search?q=label:django
Of course, just because one project does it one way does not mean that that way is The Right Way (or The Wrong Way). Some of those projects are more successful than others.
In the end, the only way to really learn what works and doesn't work is to try it out yourself. All the tips and hints in the world wont help unless you try it out yourself, but they may help you get started in the right direction.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I'd like to write a python library to wrap a REST-style API offered by a particular Web service. Does anyone know of any good learning resources for such work, preferably aimed at intermediate Python programmers?
I'd like a good article on the subject, but I'd settle for nice, clear code examples.
CLARIFICATION: What I'm looking to do is write a Python client to interact with a Web service -- something to construct HTTP requests and parse XML/JSON responses, all wrapped up in Python objects.
I can't point you to any article on how to do it, but I think there are a few libraries that can be good models on how to design your own.
PyAws for example. I didn't see the source code so I can't tell you how good it is as code example, but the features and the usage examples in their website should be a useful design model
Universal Feed Parser is not a wrapper for a webservice (it's an RSS parser library), but it's a great example of a design that prioritizes usage flexibility and hiding implementation details. I think you can get very good usage ideas for your wrapper there.
My favorite combination is httplib2 (or pycurl for performance) and simplejson. As REST is more "a way of design" then a real "protocol" there is not really a reusable thing (that I know of). On Ruby you have something like ActiveResource. And to be honest, even that would just expose some tables as a webservice, whereas the power of xml/json is that they are more like "views" that can contain multiple objects optimized for your application. I hope this makes sense :-)
This tutorial page could be a good starting place (but it doesn't contain everything you need).
You should take a look at PyFacebook. This is a python wrapper for the Facebook API, and it's one of the most nicely done API's I have ever used.
You could checkout pythenic jobs, a nice, simple, but well-formed "Python wrapper around the Authentic Jobs ... API" as a good example. That's what I'm doing now :)