Maybe somebody can show an example of such a task, or specify where to look.
I would suggest taking a look at the example given by Joel Hooks.
Download DjangoAMF for this.
Add the amf middleware to middlewares list in settings.py.
To authenticate you just have to use #permission_required decorator on views from amf.django
and add this to your settings.py
AMF_AUTH_FUNC = 'amf.django.authenticate'
Its tested in integrating Flex and DJango. For more details visit, DjangoAMF.
Related
I've been working on a Django-Mongodb application. I was trying to use django-registration module in my project, but never got it to work.
https://github.com/lig/django-registration-me
Have anyone used django-registration in their django-nonrel? If you do, can you point me some instructions? What should User model look like since it is in django-nonrel?
Thanks in advance,
Since nobody really answered it, and I figured it out. I will just answer my own question as the reference for others who might be having the same problem.
I found it easier to use Mongoengine Authentication backend on top of Django authentication. Use the following in settings.py.
AUTHENTICATION_BACKENDS = (
'mongoengine.django.auth.MongoEngineBackend',
)
SESSION_ENGINE = 'mongoengine.django.sessions'
https://mongoengine-odm.readthedocs.org/en/latest/django.html
Apart from that you use pretty much the same code as in regular django, and a bit different at accessing the user from request. Just need to:
from mongoengine.django.auth import User
And if you use form in django, you probably end up using form for mongodb instead.
https://github.com/jschrewe/django-mongodbforms
I've been trying out Ruby on Rails and really like the RESTful approach for the URL's.
Now I'm trying to learn Django and I want to create the same kind of nested URL's as I did with Rails.
Lets say I wanna do this: /categories/12/products/13
This is what I've came up with, but does not seem to work:
url(r'^categories/(?P<category_id>\d+)/products/(?P<product_id>\d+/$)', 'my_app.views.product', name="product"),
How should this be done? Also, how could you use the url template helper for creating this kind of link?
Check out TastyPie. It's a drop-in REST Api for Django similar to what you're used to in Rails and will get you going in the right direction without too much work.
Glad you got it sorted, as TastyPie was mentioned I would also recommend Django REST framework also.
In a template you can use Link title
To create a url in your python code you can use reverse:
from django.core.urlresolvers import reverse
url = reverse('product', args=[category_id, product_id])
Is there a good way to have both the login and register forms for django-registration on one page? I've had trouble finding a way to do it now that the backend system is enforced. Is there a view that can be overwritten that would allow you to add both forms to it? Anyone done this before or can point to an article about this?
Edit: Just to clarify I have the whole django-registration and login system set up and working properly, I'd just like to get both forms on the same page. I do not have access to their views.
Just hard-code your login-form in the registration-html-template. It should work like a charm.
You can always override the default login and registration views/templates. You can take a look at this link and see if this was what you were thinking to do. Then, you can read the Django documentation for further information about making custom login and registration views and templates as well.
I wnat to confirm registration without email verification
How can it config?
And, Where is the django-registration views?
Can I change the registration views?
Thank you.
You could use django-social-auth to make users register with their social account (which has been verified already). This would have the added bonus of being much quicker to sign up via.
You can see the registration views here. If you want to change them, copy the urls from django-registration's urls.py and put them into your own urls.py, then link them to a new views.py file and wrap the registration views with your own custom code.
Django-registration comes with a default backend as well as a simple backend.
The default backend takes care of the email verification / activation.
If you want to disable the email verification in django-registration, then you'd need to use the simple backend instead.
Add something like the following to your urls.py:
(r'^registration/', include('registration.backends.simple.urls')),
i would use janrain or gigya, i think janrain is better, it's just my opinion.
anyway what that would do is let people login using facebook, gmail, twitter etc.. like the django social auth...i'm just giving you other options :)
I am currently working an a webapp, using mongoengine and django, which will require users to create an account from a registration page. I know MongoEngine has an authentication backend, but does it also include a registration form, etc..., like django itself does? If not, are there any example projects which show how to implement this? The only open-source mongoengine project I've found is django-mumblr, but I can't find the examples I want in it.
I'm not interested in alternative options, such as MongoKit or mango for handling authentication.
I am just getting started with django and mongoDB, so please excuse my lack of knowledge. Thanks in advance for the help!
Not tried it out yet, but https://github.com/lig/django-registration-me by http://twitter.com/#!/lig1 looks like it could be a good bet.