Django Forms API in GAE SDK 1.7.4 - django

I have read under SDK release notes 1.7.3 that GAE supports Django 1.4. I know that Django models can't be used in GAE as we have Google's own models. But what about Django Form API, particularly displaying a form using a template? Can that be used in SDK 1.7.4?

Yes, of course you can use the form API and display it in the template. But what you can't do with plain Django on GAE is build a modelform automatically from a db.Model or ndb.Model. You have to use plain forms, defining the fields and setting the data back to the model entity manually.

While you can't use django model forms, GAE provides a forms library that provides similar functionality for db.Model based models.
https://developers.google.com/appengine/articles/djangoforms
I'm not sure if there's an equivalent for ndb.

Related

Are Django forms ever used in Django Rest Framework?

The DRF tutorial includes the following line about DRF serializers vs Django forms:
The first thing we need to get started on our Web API is to provide a
way of serializing and deserializing the snippet instances into
representations such as json. We can do this by declaring serializers
that work very similar to Django's forms.
But from what I can see, it says nothing else about the relationship between forms and serializers.
Since DRF doesn't need the Forms' ability to render a model in a template, is it fair to assume that Forms have no purpose in DRF, and that serializers can handle all of the validation traditionally completed with forms?
If so, when I'm building an API, can I forget about templates and forms entirely?
Django REST Framework is used for creating REST API's which send XML or JSON.
Django Forms is used for creating HTML forms based on a given model.
As the role of an API generally doesn't involve sending HTML, Django forms would not be used.

Serializers vs. Forms. How can I have both?

Salut friends,
I have been working with Django on a project for over a year now, and this project doesn't quite have forms (just a few). The way it is done is without Django Rest Framework, simple crispy forms, which are validated when the POST arrives at the corresponding view.
A month ago, I started to work on a different project, much bigger, that in the greatest part relies on forms. This project uses Django Rest Framework, serializers + viewsets, and renders forms through DRF serializers.
After attaining a certain understanding of all the validations that can be done with DRF serializers, I started to imagine it'd be a good idea to bring serializers and viewsets to my older project in order to enjoy the better structure offered by DRF.
Here is my question: Can (crispy) forms and serializers work well together? Is it better to render my forms with DRF if deciding to stick with DRF? I saw a couple of people who use both, but it is unclear to me at this point. Is there a more standard way to do so, which is used by a majority?
Thanks!
I use DRF with Crispy Forms, I started doing so from the start of using DRF because they recommended it in their documentation...
Requirements REST framework requires the following:
Python (2.7, 3.2, 3.3, 3.4, 3.5)
Django (1.8, 1.9, 1.10)
The following packages are optional:
coreapi (1.32.0+) - Schema generation support.
Markdown (2.1.0+) - Markdown support for the browsable API.
django-filter (0.9.2+) Filtering support.
django-crispy-forms - Improved HTML display for filtering.
django-guardian (1.1.1+) - Object level permissions support

how to use django restframework as a backend for mobile apps

I need to built an "API". Using django restframework. API has to support multiple platforms like mobile apps, webapps.
API will be used as a backend which will store all information. But my problem is how do I access users information using API. I mean normally django has user model. And we access user related stuff using request.user. But how do I access request.user information using API. Please pardon me for asking such question. But as I am new to developing API for Mobile apps. I am facing difficulty.
I think the easiest way to think about it, is that Django Rest Framework will (normally) return or process JSON data, rather than an HTML page / HTML form data.
Your models stay the same.
If you use Django's ModelForms then DRF's ModelSerialzers are very similar in use.
Likewise, using Django's class based generic views, are very similar to DRF's generic views are very similar - except rather than processing POST data from an HTML forms, they will receive JSON data. The generic views cover the same things - create via POST, update via PUT, delete via DELETE.
Like I say the main difference is that you will be dealing with JSON in place of HTML.
(You could easily use bog standard Django views without the rest-framework and return or process JSON. DRF takes a fair bit of the boilerplate code out of the process).

Can i use django reversion only for Admin or front end as well

I am trying to use Django reversion so that i can have the audit log of all changes done to all models in front end application done in Angular JS as front end and Django REST as backend.
I am thinking of using Django Reversion and their docs say this
https://django-reversion.readthedocs.org/en/latest/how-it-works.html
Any models that use subclasses of VersionAdmin in the admin interface
will be automatically registered with django-reversion. As such, it is
only necessary to manually register these models if you wish to
override the default registration settings.
Now does that mean that i can only use that in admin site only and not on models being saved via frond end.
Of course you can use it in the frontend as well, study its API on how to create versions yourself and handle restoring of previous/deleted versions manually as you will have to integrate it with your UI yourself...

Django nonrel Models

I have been looking at the documentation on django nonrel but think i have confused my self.
I have a project using the setup instructions found at http://www.allbuttonspressed.com/projects/djangoappengine#installation and continued to setup a django application. I am making a simple news feed. Now it has come to create the models but there appears to be two ways of doing this, using models.Model or db.Model.
models.Model is the django way of doing it, and if I create a model using this it appears to use nosql, this also allows me use of the built in admin.
db.Models is the non-rel way of doing things. If I create the model using this is appears to use nosql again but this method does not let me make use of the django admin. I thought the point of django non-rel was to let me make use of the admin and a majority of the default functionality in django.
I would also like to ask what is the difference between django non-rel and pure django on app engine and how does this affect how the models are created?
This is incorrect:
db.Models is the non-rel way of doing things
Where did you get this idea? db.Models is the AppEngine way of doing things. django-nonrel allows you to use the Django way even though you're on AppEngine. As you say, the point of django-nonrel is to allow you to use the admin etc, for which you need to do things the Django way, ie models.Model.