Django reusable apps checklist

2017-04-04 Thread Filipe Ximenes
Hi everyone,

yesterday Flávio  gave a talk about 
"Qualities of great reusable Django apps" at DjangoCon Europe. We put 
together most of his ideas from the talk and published as a hot site:

http://djangoappschecklist.com/

The code is open source and we would love to get feedbacks on improvements 
as well as new additions. Just open an issue to contribute: 
https://github.com/vintasoftware/django-apps-checklist

If you want to see the full talk, it's already available at: 
https://www.youtube.com/watch?v=NVVABF4Yj-U&feature=youtu.be&t=32145

Best,
Filipe

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d2aacb6d-90ed-4391-a371-6de386489133%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Custom Users and ios django questions

2015-07-08 Thread Filipe Ximenes
On Mon, Jul 6, 2015 at 11:47 AM, Lee Kazushi  wrote:

> Hi everyone,
>
> I am newbie in django so i'm a bit confused on some  features. I have to
> do a project for university. It consists in a desktop-web app where
> employees can do some staff like handle files, recording files, uploading
> files on a mysql database, and an ios native app (written in objective c)
> where a user can register himself, log in and ask for the data that the
> employees have saved early.
> First of all:  It's possible to do a server app that communicates with an
> ios app (sending-recieve data, notifications) using django-frameworks (and
> i suppose also django-rest-framework)? If yes, do you have some
> tutorials/guide/book to suggest to understand better how this communication
> work and how i can really do this thing?
>
Yes, this is possible. The main difference between a web app that
communicates with a browser and one that communicates with a mobile
application is that while a the first has to deliver DATA and LAYOUT, the
second only needs to send DATA, because the layout is already programmed in
obejective-c. And this is were Django-REST-framework (DRF) comes handy.
Pure Django is mainly thought to deliver templates with HTML (data and
layout) code, DRF simply adds a layer to the framework so it can return
data using popular formats like: JSON, XML, yaml. So keep in mind DRF only
helps you doing the job, you could also provide this kind of data using
pure Django without DRF.

>
> My second question is related to Custumizing Users on Django.
> For my project i need two classes of user:
> - Employee (with registration_id as primary key): this user can only log
> in on desktop-app
> - Driver : this user can only log in  on ios-app
>
> can i have multiple custom users, for instance :
> class Employees(AbstractBaseUser):
> registration_id = models.IntegerField(max_length=10,unique=True,
> null=True, blank=True)
> first_name = models.CharField(max_length=30, null=True, blank=True)
> last_name = models.CharField(max_length=60, null=True, blank=True)
> #etc etc etc
>
> class Driver(AbstractBaseUser):
>license_plate =
>first_name = 
>#etc etc etc
>
>
> is that reasonable?
>
This i reasonable but you will end up with some problems. Django is thought
to have a single user table and this is the behavior most third part
django-app (django plugins or extensions) expect. My advise would be to
have a single user table, than you can use one of the many strategies to
differentiate types of users, for example:
- Boolean field indication
- A separate "profile" model

>
> Sorry for my bad English.
> I will appeciate any kind of help
> Thank you
> Cheers
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/2aa960dd-1b95-427e-bb41-c497fcb6333c%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/2aa960dd-1b95-427e-bb41-c497fcb6333c%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB3skW5j3fLaXDTTcD1784rtjNYp8c1gB3qiFD2Bv7_q%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django urls and Angular ui router

2015-07-01 Thread Filipe Ximenes
You can eigther save your partial templates inside your "static" folder
(and fetch it just like any static document), or if you are doing some
"django processing" before sending the partial, you will need to write
individual views for each one of then.

On Wed, Jul 1, 2015 at 5:06 AM, ABEL D  wrote:

> I am a front end developer in django and angularjs app.  I am using
> templates and partials  in angular. Do I need to define each and every
> templates url in django to get its file from the server. If not how to do
> this in Django?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/246b0968-f6ef-4eea-acd2-ab3393b94304%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/246b0968-f6ef-4eea-acd2-ab3393b94304%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB3R-SUN%2BtCdfizf8w5GVfi3OJU2rpzfupn%3D2eBh0sMAqA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ValueError: Dependency on unknown app

2015-06-26 Thread Filipe Ximenes
.CharField(max_length=50)
>> is_active = models.BooleanField(default=False)
>> date_joined = models.DateTimeField(auto_now_add=True)
>>
>> objects = AppUserManager()
>>
>> USERNAME_FIELD = 'email'
>> REQUIRED_FIELDS = ['first_name', 'last_name']
>>
>> def get_full_name(self):
>> return ' '.join([self.first_name, self.last_name])
>>
>> def get_short_name(self):
>> return self.first_name
>>
>> def __str__(self):
>> return self.get_full_name()
>>
>> def has_perm(self, perm, obj=None):
>> """Does the user have a specific permission?"""
>> # Simplest possible answer: Yes, always
>> return True
>>
>> def has_module_perms(self, app_label):
>> """Does the user have permissions to view the app `app_label`?"""
>> # Simplest possible answer: Yes, always
>> return True
>>
>> @property
>> def is_staff(self):
>> """Is the user a member of staff?"""
>> # If role is admin or manager
>> return self.role == 1 or self.role == 2
>>
>>
>> Without AUTH_USER_MODEL migrations going well. Please help.
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/6bc750f3-2774-407a-9827-978e739fe0f0%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/6bc750f3-2774-407a-9827-978e739fe0f0%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2Be%2BciV%3DpNU4zMpQLJdcQ%2BAKfuWPyA-BSNAP5vqr3%3DSSBiaxag%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CA%2Be%2BciV%3DpNU4zMpQLJdcQ%2BAKfuWPyA-BSNAP5vqr3%3DSSBiaxag%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB3BezGjtpstZ7CQi0XOe21SVkd9rrRCymxciTX457CbZA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multiple User Roles design

2015-06-13 Thread Filipe Ximenes
You can try django-role-permissions, its an app that does exactly what you
need. It's built on top of django's permissions system and requires no new
models.
https://github.com/vintasoftware/django-role-permissions


On Sat, Jun 13, 2015 at 10:23 AM, Gergely Polonkai 
wrote:

> Hello,
>
> if you create groups, you don’t have to create different models for
> different roles (well, unless you have different data to store for Students
> and Instructors). Just connect the correct User object with the correct
> Group.
>
> Another method is to use the Permission handling system of Django,
> although it is a bit more complex.
>
> Best,
> Gergely
>
> 2015-06-13 10:22 GMT+02:00 Frankline :
>
>> *Hi all,*
>>
>> *I am creating a project that will require two different user roles: An
>> Instructor role and a Student role. Both will use a common login form. An
>> Instructor can assign a Student to a Course. Both will have access to
>> different parts of the system.*
>>
>> *I wish to know the best way to model this. Currently I'm thinking of the
>> following:*
>>
>> *1) Use a single User model having a user_type field*
>>
>> *2) Create Instructor and Student model that both inherit from base User
>> model.*
>>
>> *3) Create an Instructor and a Student group and then assign people to
>> the correct group based on some value at the time of registration.*
>>
>> *Is there a better way to handle this apart from the above? What are the
>> best practices to follow in this case? Or perhaps add a UserProfile?*
>>
>> *Regards,*
>> *Frankline*
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAEAUGdXR2n0XR6gV1fMbvHxMLAJryvo7n6gJJOE615z%3DVWwpJQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAEAUGdXR2n0XR6gV1fMbvHxMLAJryvo7n6gJJOE615z%3DVWwpJQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CACczBUK11KXp542vqVZLTfPEG9qbcKjjAQVonPNjf4uDaO3VbA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CACczBUK11KXp542vqVZLTfPEG9qbcKjjAQVonPNjf4uDaO3VbA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB1tCg_754GTzVXj0Zf2AP_eWaif9guN%2BonUu3SU46Ad%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Squashed migration

2015-06-12 Thread Filipe Ximenes
Hi Cherie, maybe you can run your tests without the migrations. This django
app may solve your problem:
https://github.com/henriquebastos/django-test-without-migrations/

On Fri, Jun 12, 2015 at 6:38 AM, Cherie Pun  wrote:

> Hi,
>
> I have trying to experiment with squashmigration to see if it will make it
> faster to build the database when running tests. So I have squashed the
> migrations following the instructions on the Django website. However when I
> run the tests, it still uses the original migrations. I thought Django
> automatically uses the squashed one over the separated ones. Is there some
> settings that I have to configure? Also, it says that no optimisation was
> available even though there are a few AddField which should in theory be
> combined into AddModel.
>
> Any help or suggestions will be much appreciated, thanks!
>
> Cherie
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/9288958d-0214-4cd2-9b51-dd173a8e83ae%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/9288958d-0214-4cd2-9b51-dd173a8e83ae%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB2LMVvigsNXfo3bRfidTAd%3DmgctQ9Trmm4tO%2BqMGfdi%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django post response method post not allowed

2015-05-28 Thread Filipe Ximenes
I assume you are using Django REST Framework.
ListAPIViews only accepts GET requests, because well, it's supposed only to
list stuff. If you need to add data, try the CreateAPIView, or depending on
what you want, a ListCreateAPIView.

On Thu, May 28, 2015 at 10:58 AM, Shekar Tippur  wrote:

> Hello,
>
> I am trying to post a request via curl.
>
> curl -H  "Authorization: Bearer $usertoken" -X POST -d
> '{"username":"foo1","object":"XYZ","prefs":"likes"}' http://
> ${endpoint}/setProfile/
>
> Here is the entry in my urls.py
>
> url(r'^setProfile/', AddToUserProfile),
>
>
> class AddToUserProfile(generics.ListAPIView):
> queryset = UserPrefs.objects.all()
> serializer_class = UserPrefSerializer
>
>
> class UserPrefSerializer(serializers.ModelSerializer):
> class Meta:
> model = UserPrefs
> fields = ('id', 'prefs', 'obj_id', 'user_id')
> depth = 1
>
>
> I get a response - {"detail":"Method \"POST\" not allowed."}
>
>
> Is there anything else I need to specify?
>
>
> - Shekar
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d8db1691-e60d-4a46-9598-47227bd4c6e9%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/d8db1691-e60d-4a46-9598-47227bd4c6e9%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB3Zkc8%2BuVFcA8oD5M_9SAKMv6QAKboPGyUY2C2pBQn%3DwA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to pass a queryset for each different field Admin Inlines

2015-05-27 Thread Filipe Ximenes
Think I got it now.
Can you see if this stackoverflow answer solves your problem:
http://stackoverflow.com/questions/5329586/django-modelchoicefield-filtering-query-set-and-setting-default-value-as-an-obj

On Wed, May 27, 2015 at 9:41 AM, Felipe  wrote:

> Hello, Filipe Ximenes, in fact it is not so difficult. To avoid using
> ajax, what I do is initialize each form inline with a default value. Few
> ATTRIBUTES has verified and initialize no possibility that the fronentd
> they can edit. All right up here, but the problem is that for each
> attribute requires its respestivo initialized value, which is made by a
> queryset to each forminline initialized.
>
> self.initial = [{'attribute': a} for a in obj.category.attributes.all()] #
> This initial attribute value, whit one for inline, Now need pass queryset a
> each value_option
>
> If I have 10 ATTRIBUTES "obj.category.attributes.all", then initialize the
> form 10 form inlines no ability to edit and then "value_option" we pass
> your respestivos values with a queryset, "but the problem is that you have
> to spend a queryset" different "to each form inline"
>
> Example form inlines 3, whit two fields, Attribute and Value Option
> Inline 1 Values initial "Attribute": *Colors* and *Value Option* now
> requires queryset depending on its initial value, all this is built before
> loading the frontend, that is, that everything is done in the backend
> Inline 2 Values initial "Attribute": *Size .... "''"*
> Inline 3 Values initial "Attribute": *Equipment  ''''*
>
>
> El miércoles, 27 de mayo de 2015, 5:24:09 (UTC-5), Filipe Ximenes escribió:
>>
>> From what I could understand, you want to change the options of the
>> "value options" field depending on the selected "attribute".
>> Since the choosing of the "attribute" happens in the frontend and there's
>> no page refresh, the backend does not know about it, and therefore cannot
>> filter the "value options".
>> For this to work, you will need to write some javascript code to perform
>> the filtering in the browser after the attribute is choosen.
>> It can also be achived with a ajax call.
>> Either way, not the easiest to do in django admin.
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f782dcfe-f68b-4c92-b458-0724ff5fbb8e%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/f782dcfe-f68b-4c92-b458-0724ff5fbb8e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB2eS2ajrVYs2O7EpKcovkHKo0yOAKLeYYbR9uAfu%3Dq%2BnQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to pass a queryset for each different field Admin Inlines

2015-05-27 Thread Filipe Ximenes
>From what I could understand, you want to change the options of the "value
options" field depending on the selected "attribute".
Since the choosing of the "attribute" happens in the frontend and there's
no page refresh, the backend does not know about it, and therefore cannot
filter the "value options".
For this to work, you will need to write some javascript code to perform
the filtering in the browser after the attribute is choosen.
It can also be achived with a ajax call.
Either way, not the easiest to do in django admin.
Someone can help me ?, he took days trying to fix this and nothing to get
it, if I could just iterate a QuerySet each model choice of the form. The
only thing achieved is that a queryset applies to all forms inline, but I
need a different one for each inline.
def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == "value_option":
kwargs["queryset"] = request._obj_.category.attributes.all()
return super(AttributeInline,
self).formfield_for_foreignkey(db_field, request, **kwargs)


 --
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/50459949-79eb-4452-b6b9-386517669525%40googlegroups.com

.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB1gW8NXSWK2UVjrHg9cAx5ugMQJD5M69m%2BDggTuaA8NKw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Choosing an auth module: Login via Facebook, Google, ...

2015-05-06 Thread Filipe Ximenes
I have some experience with python-social-auth.
https://github.com/omab/python-social-auth
It's a very good tool, well maintained, and with good support. The problem
with it, is that it's a generic package, it works with a lot of frameworks
and ORM configurations and this turns it a bit complicated to get started.
But also because of this, it's very customisable.
If you are willing to spend some time studying the lib, this is a very good
and powerful choice.

On Wed, May 6, 2015 at 3:45 AM, rush  wrote:

> Hi,
>
> What kind of issues do you have?
>
> It should support 1.8 now. You can even check that support request for 1.8
> is already closed at github (
> https://github.com/pennersr/django-allauth/issues/858).
>
> --
> wbr,
> rush.
>
>
>
> 06.05.2015, 09:17, "guettli" :
>
> I need a library to let users loging via Facebook, Google, ...
>
> I looked at this page:
>
> https://www.djangopackages.com/grids/g/authentication/
>
> It's hard for me to decide which one to use.
>
> I have no special requirements except the end user experience should be
> good.
> The login for new users should be as simple as possible.
>
> Can you give me an advice?
>
> I tried django-all-auth, but it has issues with Django 1.8
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f365689f-73a2-4934-b64b-7963f9671bc6%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/f365689f-73a2-4934-b64b-7963f9671bc6%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5628571430894754%40web12j.yandex.ru
> <https://groups.google.com/d/msgid/django-users/5628571430894754%40web12j.yandex.ru?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB2NUrzoTdmQU%3DbzRN9hAczRdOjh5MFWHcRP3f3PbXZtow%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: design pattern to handle multiple groups from the same view

2015-05-05 Thread Filipe Ximenes
An alternative [but not a simple one] is to have this customisations as a
generic configuration in a database table.
If changes are "visual" only, you could have multiple templates and only
change the one you are rendering for given client. Or have this handled by
template tags. "Partial templates" may also help.
It really depends on what is changing and how many of this customisations
you need.


On Tue, May 5, 2015 at 1:17 PM, Abraham Varricatt <
abraham.varric...@googlemail.com> wrote:

> Hello everyone,
>
> I'm working on an e-commerce site. There is a generic version of the site
> available to the open internet and customized versions available to
> enterprise users. Now, when I say 'customized', I'm mostly talking about
> really minor customization's. If the current user belongs to ABC
> organization, change the menu display order. If she comes from XYZ company,
> don't show certain options .. etc. A lot of our view code looks like this;
>
> def view1(request):
> ...
> ...
> if (request.user.company == 'ABC'):
>context['ABC-option1'] = 'something'
>...
>context['ABC-option3'] = 'different'
> ...
> if (request.user.company == 'XYZ'):
>context['XYZ-option1'] = 'an option'
>...
>context['XYZ-option3'] = 'manager'
> ...
> ...
> return render(request, 'templates/index.html', context)
>
> The template isn't any better. Sure, we inherit from a base.html, but
> there is a LOT of if..else..if set of statements scattered everywhere.
>
> My instincts tell me that there has to be a better way of handling this
> situation - that there has to be a better way of handling these different
> scenarios than using so many if-else statements everywhere. I'm aware that
> I could set something up using inheritance in my views, but .. ... well,
> what I'd like is some way to handle the different scenarios OUTSIDE the
> views and templates. Something like say, if I have an about-me page, for
> all my users I want to be able to do,
>
>
> def about_me(request):
> ...
> return render(request, 'aboutme.html', context)
>
>
> Primarily, this is about keeping the code clean. All the about-me view
> function should (ideally) do is return a view. It (ideally) shouldn't have
> to worry about which organization a user might belong to, in-order to show
> a different set of addresses!
>
> Any suggestions/alternatives will be appreciated.
>
> -Abraham V.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4ffb12d3-27cc-4efb-9957-1001ebe7db85%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/4ffb12d3-27cc-4efb-9957-1001ebe7db85%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB2Y6da7Q50bzs97A1WWS7LeUc9JJmNBiepDT%3DNG490s6Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: DRF - Which Authentication to use?

2015-05-04 Thread Filipe Ximenes
This is an interesting question. This question enlights some possibilities:
http://stackoverflow.com/questions/21978658/invalidating-json-web-tokens
But none of then gives is a definitive solution. Does anyone have other
ideas about the subject?
On May 1, 2015 10:13 AM, "Nabeel Valapra"  wrote:

> I have prior experience in Django. Recently I got a project to build in
> REST architecture. I learned the basics of Django Rest Framework. But I am
> stuck with the authentication system.
>
> I planned serve my frontend in anguarjs an host it on app.mydomain.com,
> and the DRF on api.mydomain.com. So all the end application (android,
> IOS) can pull the the data from api.mydomain.com
>
> Here I don't want to use session authentication system, it doesn't play
> nice with CORS. I am more interested on JSONWebToken than Token Based
> Authentication because its signed and allows refresh token option too.
>
> But, 1. How do I invalidate the existing tokens on password change? 2. How
> to destroy the token in a mobile lost scenario?
>
> Is there any better authentication solution?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/fabc7ac3-7343-48dc-8cfe-db909a5d6795%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB1Bj9gQfv7oCXH_PnZGeS%2B0m-dmfELXG9y0XXUEy2GuoQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Migrations During Development

2015-04-25 Thread Filipe Ximenes
You should keep all project migrations, they will be used to update the
database everytime a change is made. This applies to your local project,
the staging server (if you have one) and your production server.
If you are worried about having to many migrations, you can delete the ones
that were not applied in other machines, and generate a single one with all
the changes.

About the database, it can be deleted, but you don't need to do this, your
database data should only exist in your computer and not in the Django
project you are deploying.

On Sat, Apr 25, 2015 at 9:26 AM, Timothy W. Cook  wrote:

> Django 1.8  Python 3.4 PostgreSQL 9.3
>
> During development I am creating several migrations. It seems unnecessary
> to keep these since they only exist on my dev machine.
> Any data that I have created can be thrown away too.
>
> Is it safe to delete these migrations  (and the database) before deploying
> to the next stage for testing by users?
>
>
> --
>
> 
> Timothy Cook
> LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
> MLHIM http://www.mlhim.org
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3WNb8XWUWLyN%2B7fq4u7Er3dczOqgBKLODdVnE3cLxOr-g%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3WNb8XWUWLyN%2B7fq4u7Er3dczOqgBKLODdVnE3cLxOr-g%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB2RW_39b-8nm0Jm%2BAg9%2Bc%3DV0F4%3Dnm%3D%2B3DM7U-f3njV%3DNw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How should I develop a web site and mobile apps(iOS/Android) as Facebook(using DRF + Angularjs)?

2015-04-16 Thread Filipe Ximenes
Yes, you can develop a website were some data is processed and presented in
the template by the backend, and some is fetched using AJAX
(Javascript/Angular) from the frontend.

I do not know a specific tutorial to point you, but from a quick search,
this one seems to cover a lot of things:
https://thinkster.io/django-angularjs-tutorial/

On Thu, Apr 16, 2015 at 5:03 PM, 백병화  wrote:

>
>>
> Thank you very much for the professional advice :)
>
> I have more questions..
>
> Is there a way to develop a web site by combining MPA and SPA ?
>
> And..
>
> Can you please recommend a tutorial of django+angularjs that is about
> configuration, building structure, and etc for dividing backend and
> frontend ?
>
>>   --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/61b3252f-679e-4918-9309-4811a6001102%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/61b3252f-679e-4918-9309-4811a6001102%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB3uqiMy6qWxZRbgKwk92dMT%3DL003tYqPVSgycnezpK44w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How should I develop a web site and mobile apps(iOS/Android) as Facebook(using DRF + Angularjs)?

2015-04-16 Thread Filipe Ximenes
1) The Facebook WEBSITE is a MPA, but some of it's content is loaded via
ajax (like the newsfeed). The Facebook mobile app is a native application.
The Android one is developed in Java, and the iOS is developed in Objectve-C

2) If you use a cross-paltform framework like Cordova you will be
programming in HTML/CSS and Javascript. The framework will handle the
generation of the apps for each platform from your javascript code.
HTML/CSS will define how the app looks and Javascript will handle fetching
data from the server and presenting it on the app. AngularJS is a
Javascript framework that give you some nice tools, but you are free to
chose between using it or not.

3) There's no such a thing as "the best cross-platform to fit DRF". The
backend (Django/DRF) will handle storing and processing data, and the
mobile app will fetch data from the backend and show it to the user. The
platform you will use and the backend are separated things and do not
interfere within each other.
About using native or cross-platform, I expressed MY OPNION in the second
email of the last message:
https://groups.google.com/forum/#!topic/django-users/B8v9wjR4-M0
But this is a polemic subject, other people may have different opinions
about it.

On Thu, Apr 16, 2015 at 4:12 PM, 백병화  wrote:

> Thank you very much for replying my question.
> I'm a student in Korea, so my english grammar is not good. I'm sorry for
> that.
>
> I'm wondering to create a web site as Facebook.
>
> I have 3 questions.
>
> 1) Is facebook developed as SPA? or Is it developed as SPA+MPA ?
>
> 2) Last time, I understood as when I use DRF with Angularjs, it is not
> needed to make front-end for Android/iOS. Did I misunderstand about it ?
>
> 3) If I need to develop front-end for iOS/Android, I'm curious what
> cross-platform is the best to fit DRF. Also I'm curious whether the
> cross-platform is good when it is compared to Native Apps.
>
> Thank you for replying!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/cb9633d6-5571-45c1-91c0-a1118faf7e26%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/cb9633d6-5571-45c1-91c0-a1118faf7e26%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB1P4GNcUL5txKUAGGjAtY17uC-Xdb0nzF7onoHa3E%2BRcA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How should I develop a web site and mobile apps(iOS/Android) as Facebook(using DRF + Angularjs)?

2015-04-16 Thread Filipe Ximenes
Hi,

I think I partially answered this to you in your previous question:
https://groups.google.com/forum/#!topic/django-users/B8v9wjR4-M0
Can you tell me if you didn't understand something?

Mobile and AngularJS apps don't work exactly the same as a normal web page.
While in a normal web page, the frontend (what the user sees) is processed
in the backend (django) and sent to the user, in a Mobile or AngularJS app,
the frontend is already in the user device and it only fetches the data to
fill in the frontend.
The default Django behaviour is to work with "normal web pages", but when
you use Django REST Framework it makes it easy to develop APIs and return
JSON data (JSON is one of the most popular data formats).

Now, normal iOS apps are build in Objective-C, normal Android apps are
developed in Java. But it's possible to built both iOS and Android apps
using Javascript, some of the frameworks that do this are:
Cordova/Phonegap, Titanium and Ionic (witch is AngularJS compatible).

There are lots of tutorials in the interned for all this technologies.
This is pretty much the basics of how this works. Feel free to ask more
specific questions if you need more detailed response.



On Thu, Apr 16, 2015 at 1:25 PM, 백병화  wrote:

> I want to develop a web site and mobile apps(iOS/Android) as Facebook.by
> using Django REST Framework AND Angularjs.
> I'm confused about what steps should I follow..
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f26fe122-e66f-4760-ad2c-9a74e60d5238%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/f26fe122-e66f-4760-ad2c-9a74e60d5238%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB3K%3D9vwXVvrHSOezO7yN7MZ1fbrgeq2R3pQdsmpr1BTxA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: form detail view using generic view

2015-04-16 Thread Filipe Ximenes
Hi Pradeep,

when data is saved, you want to show it in the form or as "view-only"?
If it is a form you need, Use a CreateView, and the redirect it to a
UpdateView. Otherwise, do a CreateView and redirect to a TemplateView.

CreateView ->
https://docs.djangoproject.com/en/1.8/ref/class-based-views/generic-editing/#django.views.generic.edit.CreateView
UpdateView ->
https://docs.djangoproject.com/en/1.8/ref/class-based-views/generic-editing/#django.views.generic.edit.UpdateView
TemplateView ->
https://docs.djangoproject.com/en/1.8/ref/class-based-views/base/#templateview

On Thu, Apr 16, 2015 at 11:22 AM, Pradeep gopi 
wrote:

> iam new to django.  i want to develop a web page with a form with some
> data to enter after saving the data in the database the data must be shown
> on the same page from where it has been submitted
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/25de8b0d-a833-4b70-bd71-21cb3f7858ae%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/25de8b0d-a833-4b70-bd71-21cb3f7858ae%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB0-Piu9GZFGh27WLs24-9LMuN9mCJoGwyhYMgQt6XTY0Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Please advise about pros/cons of cross-platform as Phonegap and Titanium in combination with Django.

2015-04-13 Thread Filipe Ximenes
About cross-platform mobile development: my advice is to only use then if
it's a simple app. If you are planning to do something more complex, like
some innovative interface or expecting a very fluid interaction, it's often
not a good choice.
Many times you will struggle to replicate mobile behaviour using this
technology. Also, it's common to need to interact with native modules, and
sometimes you will even need to develop your own native modules. Trust me:
it's not funny to juggle between javascript, objective-c, and java.
Otherwise, i've worked with Phonegap, it's a good framework, has a lot of
open source packages developed by the community.
Also, consider Ionic: http://ionicframework.com/

On Mon, Apr 13, 2015 at 3:22 PM, Filipe Ximenes 
wrote:

> I'm assuming your current application is not a SPA (single page
> application).
> Django is a good option for serving data for a mobile app, you just need
> to develop an API. Django default behaviour is to serve full html pages,
> but when you are working with mobile apps you are only interested in the
> actual data from your django application, therefore a JSON (or other format
> you'd like to use) it's a better choice. There are a some libs that will
> help you developing an API, the most used ones are: Tastypie and Django
> REST framework (DRF). I really like working with DRF, it's a very powerful
> tool, very popular and with an active community.
>
> http://django-rest-framework.org/
>
> Also, in my company, when we are doing applications that will interact
> with mobile devices, we do all the backend logic in an API and for the
> frontend, we do a SPA using Angular.js. This way we keep all the logic in a
> single place, accelerating the backend development and reducing the amount
> of code needed to maintain.
>
> On Mon, Apr 13, 2015 at 2:45 PM, 백병화  wrote:
>
>> Hi All
>> I'm using
>> django+python+mariadb+mysql+redis+html5+css3+javascript+jquery+nginx 4 web
>> development
>> and I'm wondering cross-platform as Phonegap or titanium for mobile apps.
>> Colud you plz advise about pros/cons of them(In combination with
>> Django+Python)?
>> Thank you for reading ma article.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/cdb48ad5-8a01-4362-84a2-5233407c9405%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/cdb48ad5-8a01-4362-84a2-5233407c9405%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
>
>
> *Filipe Ximenes*+55 (81) 8245-9204
>
> *Vinta Software Studio*http://www.vinta.com.br
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB0k4MmzBPDoESPzOStwP8%3DuTNewP4UywZ5Pr-JKfou83Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Please advise about pros/cons of cross-platform as Phonegap and Titanium in combination with Django.

2015-04-13 Thread Filipe Ximenes
I'm assuming your current application is not a SPA (single page
application).
Django is a good option for serving data for a mobile app, you just need to
develop an API. Django default behaviour is to serve full html pages, but
when you are working with mobile apps you are only interested in the actual
data from your django application, therefore a JSON (or other format you'd
like to use) it's a better choice. There are a some libs that will help you
developing an API, the most used ones are: Tastypie and Django REST
framework (DRF). I really like working with DRF, it's a very powerful tool,
very popular and with an active community.

http://django-rest-framework.org/

Also, in my company, when we are doing applications that will interact with
mobile devices, we do all the backend logic in an API and for the frontend,
we do a SPA using Angular.js. This way we keep all the logic in a single
place, accelerating the backend development and reducing the amount of code
needed to maintain.

On Mon, Apr 13, 2015 at 2:45 PM, 백병화  wrote:

> Hi All
> I'm using
> django+python+mariadb+mysql+redis+html5+css3+javascript+jquery+nginx 4 web
> development
> and I'm wondering cross-platform as Phonegap or titanium for mobile apps.
> Colud you plz advise about pros/cons of them(In combination with
> Django+Python)?
> Thank you for reading ma article.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/cdb48ad5-8a01-4362-84a2-5233407c9405%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/cdb48ad5-8a01-4362-84a2-5233407c9405%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB1umJ9QvGA68365g_78Q6qfoQsdwUTMMsAGoQE4%2BMnmXw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Accessing to my user

2015-04-02 Thread Filipe Ximenes
Try:

p = Persona.objects.get(user__username='foo')

​

On Thu, Apr 2, 2015 at 12:24 PM,  wrote:

> I have this
> class Persona(models.Model):7
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L7>
>"""Person class:8
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L8>
> * user: a user9
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L9>
> * presentation: some paragraph for other knowing you10
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L10>
> * availability: the availability of user for knowing new
> people. See 'AVAILABILITY' tuples explanation11
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L11>
>"""12
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L12>
># 'Available' means you want to meet new people now13
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L13>
># and 'Unavailable' means you don't want to meet new people.14
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L14>
># Useful for not anoying you new users.15
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L15>
>AVAILABILITY = (16
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L16>
>('Y', 'Available'),17
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L17>
>('N', 'Unavailable'),18
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L18>
>)19
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L19>
> 20
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L20>
> 21
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L21>
>user = models.OneToOneField(User)22
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L22>
>presentation = models.CharField(max_length=254, blank=True)23
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L23>
>availability = models.CharField(max_length=1, choices=AVAILABILITY,
> default='Y')24
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L24>
> 25
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L25>
>def __str__(self):26
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L26>
>return self.user.username27
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L27>
> 28
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L28>
>def username(self):29
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L29>
>return self.user.username30
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L30>
> 31
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L31>
>def full_name(self):32
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L32>
>return "{0}, {1}".format(self.user.last_name, self.user.
> first_name)33
> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L33>
>
>
> How can I do to acces to Persona which has user.username=='foo'?
>
> Thanks in advance,
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/599f61a6-6f87-4dd7-a3f2-7a4b3693a185%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/599f61a6-6f87-4dd7-a3f2-7a4b3693a185%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB1yVcigp4%3D0xX5KD4-F_dW4P%2Bp3BmamWjHHnNe_cyNA5w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using Unicode in django

2015-04-02 Thread Filipe Ximenes
Not sure I understood the problem. Are you trying to print only the data in
the "importance" field?
If so, try:

class Crop(models.Model):
name = models.CharField(max_length=30)
importance = models.TextField()
cultivation = models.TextField()
def __unicode__(self):
return u'%s' % (self.importance,)

​

On Thu, Apr 2, 2015 at 10:01 AM, temiloluwa adesina <
adesinatemilol...@gmail.com> wrote:

> Hello
> I just joined this group and i have problems with representing multiple
> fields in admin using __unicode__, when i try to call this data it returns
> just one of them:
>
> class Crop(models.Model):
> name = models.CharField(max_length=30)
> importance = models.TextField()
> cultivation = models.TextField()
> def __unicode__(self):
> return u'%s %s %s' % (self.name, self.importance, self.cultivation
> )
>
>
> <https://lh3.googleusercontent.com/-2cHWwMHqUnY/VR09L1-ntvI/AGY/AdVaYuoL6As/s1600/Screenshot%2B%2840%29.png>
> but rather than returning just the data in the importance field, it
> returns all the data in each separate field together.
>
> Pls i would appreciate anyone's assistance.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/504bf928-7259-4d17-994c-115e98a78a4b%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/504bf928-7259-4d17-994c-115e98a78a4b%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB2h4TtWBoyf1yAzBppUj-jNAs3B%2BF%2BiZB3DX8twcjbR0A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Upgrade to django 1.7- ImproperlyConfigured -Tastypie label duplicate? help

2015-03-31 Thread Filipe Ximenes
Thats strange.
Are you using pip to install dependencies? Try uninstalling everything and
reinstalling again.
Make sure INSTALLED_APPS is not being defined somewhere else in the code.
Does the error persists if you set DEBUG = False locally?

On Tue, Mar 31, 2015 at 10:21 AM, amarshall  wrote:

> Hi Filipe,
>
> I have few apps installed. When I comment out the tastypie line my app
> builds but gets an error in production because tastypie app isn't found.
> Here it is:
>
> INSTALLED_APPS = (
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'rest_framework',
># 'south',   // commented out after upgrade to Django 1.7
> 'tastypie',
> 'lokal',#my app
> )
>
>
>
> On Tuesday, March 31, 2015 at 5:52:55 AM UTC-4, Filipe Ximenes wrote:
>>
>> Can you show us your INSTALED_APPS?
>> It may be the case you have a lot of apps installed and is not seeing a
>> duplicate reference to tastypie.
>> On Mar 29, 2015 9:43 PM, "amarshall"  wrote:
>>
>>> Hi,
>>>
>>>  So I updated my django project from django 1.6 to 1.7.7 and when I run
>>> "python manage.py migrate" I get this error stating that I have a duplicate
>>> label.
>>>
>>> Here's the traceback
>>>
>>>   Creating tables...
>>>   Installing custom SQL...
>>>   Installing indexes...
>>> Running migrations:
>>>   Applying tastypie.0001_initial...Traceback (most recent call last):
>>>   File "manage.py", line 11, in 
>>> execute_from_command_line(sys.argv)
>>>   File "/usr/local/lib/python2.7/dist-packages/django/core/
>>> management/__init__.py", line 385, in execute_from_command_line
>>> utility.execute()
>>>   File "/usr/local/lib/python2.7/dist-packages/django/core/
>>> management/__init__.py", line 377, in execute
>>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>>   File "/usr/local/lib/python2.7/dist-packages/django/core/
>>> management/base.py", line 288, in run_from_argv
>>> self.execute(*args, **options.__dict__)
>>>   File "/usr/local/lib/python2.7/dist-packages/django/core/
>>> management/base.py", line 338, in execute
>>> output = self.handle(*args, **options)
>>>   File "/usr/local/lib/python2.7/dist-packages/django/core/
>>> management/commands/migrate.py", line 161, in handle
>>> executor.migrate(targets, plan, fake=options.get("fake", False))
>>>   File "/usr/local/lib/python2.7/dist-packages/django/db/
>>> migrations/executor.py", line 68, in migrate
>>> self.apply_migration(migration, fake=fake)
>>>   File "/usr/local/lib/python2.7/dist-packages/django/db/
>>> migrations/executor.py", line 96, in apply_migration
>>> if self.detect_soft_applied(migration):
>>>   File "/usr/local/lib/python2.7/dist-packages/django/db/
>>> migrations/executor.py", line 140, in detect_soft_applied
>>> apps = project_state.render()
>>>   File "/usr/local/lib/python2.7/dist-packages/django/db/
>>> migrations/state.py", line 57, in render
>>> self.apps = Apps([AppConfigStub(label) for label in 
>>> sorted(self.real_apps
>>> + list(app_labels))])
>>>   File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py",
>>> line 56, in __init__
>>> self.populate(installed_apps)
>>>   File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py",
>>> line 89, in populate
>>> "duplicates: %s" % app_config.label)
>>> django.core.exceptions.ImproperlyConfigured: Application labels aren't
>>> unique, duplicates: tastypie
>>>
>>>
>>> Not sure what to do here. I remove tastypie from the list of
>>> INSTALLED_APPS in my settings and everything works fine. but I do need it.
>>> Any suggestions ?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@go

Re: Upgrade to django 1.7- ImproperlyConfigured -Tastypie label duplicate? help

2015-03-31 Thread Filipe Ximenes
Can you show us your INSTALED_APPS?
It may be the case you have a lot of apps installed and is not seeing a
duplicate reference to tastypie.
On Mar 29, 2015 9:43 PM, "amarshall"  wrote:

> Hi,
>
>  So I updated my django project from django 1.6 to 1.7.7 and when I run
> "python manage.py migrate" I get this error stating that I have a duplicate
> label.
>
> Here's the traceback
>
>   Creating tables...
>   Installing custom SQL...
>   Installing indexes...
> Running migrations:
>   Applying tastypie.0001_initial...Traceback (most recent call last):
>   File "manage.py", line 11, in 
> execute_from_command_line(sys.argv)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py"
> , line 385, in execute_from_command_line
> utility.execute()
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py"
> , line 377, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> line 288, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> line 338, in execute
> output = self.handle(*args, **options)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py"
> , line 161, in handle
> executor.migrate(targets, plan, fake=options.get("fake", False))
>   File
> "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py",
> line 68, in migrate
> self.apply_migration(migration, fake=fake)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py",
> line 96, in apply_migration
> if self.detect_soft_applied(migration):
>   File
> "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py",
> line 140, in detect_soft_applied
> apps = project_state.render()
>   File
> "/usr/local/lib/python2.7/dist-packages/django/db/migrations/state.py",
> line 57, in render
> self.apps = Apps([AppConfigStub(label) for label in sorted(self.real_apps
> + list(app_labels))])
>   File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py",
> line 56, in __init__
> self.populate(installed_apps)
>   File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py",
> line 89, in populate
> "duplicates: %s" % app_config.label)
> django.core.exceptions.ImproperlyConfigured: Application labels aren't
> unique, duplicates: tastypie
>
>
> Not sure what to do here. I remove tastypie from the list of
> INSTALLED_APPS in my settings and everything works fine. but I do need it.
> Any suggestions ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/7e4cfbf8-d3e0-4e0e-a38c-b83930ffa3b6%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB3KXRBBSsVOCcAJ-BDi7Av%2B_JLFHBChHik069dKvksUUg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Performance of file-based sessions vs database-backed sessions

2015-03-27 Thread Filipe Ximenes
>From what I understand, using file based sessions will work with no
problems in production environment. But, you will have a problem in case
you need to horizontally scale (have multiple machines serving your app)
your system. In this situation, since files from one machine wont be able
to access from others, the session engine will not always work.
I'm not sure about performance [in a single machine] compared to database
session though.

On Fri, Mar 27, 2015 at 12:14 PM, David Riddle  wrote:

> I am using Django 1.7, and I have read the documentation on
> the SESSION_ENGINE setting. It is not clear to me what are the advantages
> and disadvantages of using file-based sessions. Do file-based sessions have
> better or worse performance than database-backed sessions? Are file-based
> sessions appropriate for production environments with large amounts of
> traffic?
>
> Thank you,
>
> David Riddle
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CABX-mpWYMZ9GQqTduk4RoJfagPAbQ9%3DnChkcu0znqQxtxMBoiQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CABX-mpWYMZ9GQqTduk4RoJfagPAbQ9%3DnChkcu0znqQxtxMBoiQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB2Y8YKcZ47M1s%3Dkv1%3Dw2_HHGYEA-tu3xGchS%3Do6gnow%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Search user from Database

2015-03-27 Thread Filipe Ximenes
Just checking: when you say you are adding users using

Group.users.add(user)
​
in this case `Group` is an instance of the Group model and NOT the actual
model, correct?

if so, you can make a query using the same instance, looking for the user:

user = Group.user.filter(user).first()
if user:
print('user exists in this group')
else:
print('user does not exists in this group')

​

On Thu, Mar 26, 2015 at 11:24 PM, nobody  wrote:

> Hi,
>
> Sorry for asking a new B question. I have following code in a module.py:
>
>
> class Group(models.Model):
> ..
>  users = models.ManyToManyField(User, blank=True, null=True)
> .
>
> I can add user or delete user by calling Group.users.add(user) or
> Group.users.remove(user), but how can I check if the user has already in
> the database?
>
> Thank you.
>
>  -j
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/017b0bc2-ff5c-4a42-936d-00da2b246cbf%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/017b0bc2-ff5c-4a42-936d-00da2b246cbf%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB19Dsbi7cC1XF8nSVvNEkbQm7_gQq84bXZDCTxj%3DBcVzw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Textarea taking htnml tags

2015-03-27 Thread Filipe Ximenes
Can you send us the code of the view and the template of this form?

On Fri, Mar 27, 2015 at 3:27 AM,  wrote:

> Hie to all,
> In one of my template i am using text area. The issue is that when i write
> html tags with some image link using img tag, when i am saving this i am
> getting image on the desription field.
>
> Actual-Image is comming
>
> Expected-I want HTML code to be displayed in the discription.
>
> Please suggest
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/32bb3e0a-1eb1-46d1-94fe-4135c7c916df%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/32bb3e0a-1eb1-46d1-94fe-4135c7c916df%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB3OPdmK11XzPFf--2MBT6evTDu-RuRrPArem1PbZT2FmA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Accessing django app from another app with ajax

2015-03-26 Thread Filipe Ximenes
My mistake.


On Thu, Mar 26, 2015 at 11:42 AM, aRkadeFR  wrote:

>  But from the first email, the debug settings is already at True
> and he is not getting a stacktrace...
>
>
> On 03/26/2015 03:40 PM, Filipe Ximenes wrote:
>
> In case there's no one using your project and there's no sensitive data in
> it, you can briefly set DEBUB to True in the server to see stack traces.
>
> On Thu, Mar 26, 2015 at 11:26 AM, Larry Martell 
> wrote:
>
>> On Thu, Mar 26, 2015 at 10:20 AM, aRkadeFR  wrote:
>> > You should setup your project so you're able to retrieve the
>> > stacktrace on a 500 server error.
>>
>> When there is a stack trace I get it (e.g. when I was getting the 403
>> error). There was no stack trace when I was getting the 500. But the
>> 500 is resolved. I am now fighting the 400 error, which also gives no
>> stack trace.
>>
>>
>> >
>> >
>> > On 03/26/2015 12:25 PM, Larry Martell wrote:
>> >>
>> >> On Thu, Mar 26, 2015 at 7:22 AM, aRkadeFR  wrote:
>> >>>
>> >>> Do you have the stacktrace? Without it it's gonna be hard
>> >>> to help you.
>> >>>
>> >>> My only guess is CORS (Cross-Origin Resource Sharing)? But
>> >>> you should have the same error on local dev if you have similar
>> >>> setup from your production.
>> >>
>> >> There was no stacktrace. But I figured that this issue - I did not
>> >> have a slash on the end of the URL. I added that, then instead of a
>> >> 500 I got a 403 Forbidden, because it didn't like the CSRF token, but
>> >> I am sending that. So I disabled CSRF and then I get a 400 bad
>> >> request, again no stacktrace. ALLOWED_HOSTS is ['*'] so that's not the
>> >> cause.
>> >>
>> >>
>> >>>
>> >>> On 03/26/2015 02:04 AM, Larry Martell wrote:
>> >>>>
>> >>>> I have a webservice written in django and I want to call it from a
>> non
>> >>>> django app with ajax. Both apps run on the same host. When I call the
>> >>>> webservice with curl it works fine, but when I call it with ajax from
>> >>>> the other app I get a 500 internal server error. There are no errors
>> >>>> in the web server log. DEBUG is True, and ALLOWED_HOSTS = ['*']. When
>> >>>> I run the dev server and connect to that I get no errors, just the
>> 500
>> >>>> error. I tried setting a breakpoint in the view, but it never makes
>> it
>> >>>> there.
>> >>>>
>> >>>> Anyone have any ideas as to why this is happening or how I could
>> debug
>> >>>> it further?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>>  To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CACwCsY5Ea%3DiJbXMfC14Ep-fQ%2BCjE7RYzu4XZ5xiDCUUECGXB7Q%40mail.gmail.com
>> .
>>  For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
>  --
>
>
> *Filipe Ximenes *+55 (81) 8245-9204 <%2B55%20%2881%29%208245-9204>
>
> *Vinta Software Studio *http://www.vinta.com.br
>--
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAA-QWB3zLJUjsA_nXpMOAQNJw13CFUtZ2Xio8op4bzOZnLxuzA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAA-QWB3zLJUjsA_nXpMOAQNJw13CFUtZ2Xio8op4bzOZnLxuzA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to djan

Re: Accessing django app from another app with ajax

2015-03-26 Thread Filipe Ximenes
In case there's no one using your project and there's no sensitive data in
it, you can briefly set DEBUB to True in the server to see stack traces.

On Thu, Mar 26, 2015 at 11:26 AM, Larry Martell 
wrote:

> On Thu, Mar 26, 2015 at 10:20 AM, aRkadeFR  wrote:
> > You should setup your project so you're able to retrieve the
> > stacktrace on a 500 server error.
>
> When there is a stack trace I get it (e.g. when I was getting the 403
> error). There was no stack trace when I was getting the 500. But the
> 500 is resolved. I am now fighting the 400 error, which also gives no
> stack trace.
>
>
> >
> >
> > On 03/26/2015 12:25 PM, Larry Martell wrote:
> >>
> >> On Thu, Mar 26, 2015 at 7:22 AM, aRkadeFR  wrote:
> >>>
> >>> Do you have the stacktrace? Without it it's gonna be hard
> >>> to help you.
> >>>
> >>> My only guess is CORS (Cross-Origin Resource Sharing)? But
> >>> you should have the same error on local dev if you have similar
> >>> setup from your production.
> >>
> >> There was no stacktrace. But I figured that this issue - I did not
> >> have a slash on the end of the URL. I added that, then instead of a
> >> 500 I got a 403 Forbidden, because it didn't like the CSRF token, but
> >> I am sending that. So I disabled CSRF and then I get a 400 bad
> >> request, again no stacktrace. ALLOWED_HOSTS is ['*'] so that's not the
> >> cause.
> >>
> >>
> >>>
> >>> On 03/26/2015 02:04 AM, Larry Martell wrote:
> >>>>
> >>>> I have a webservice written in django and I want to call it from a non
> >>>> django app with ajax. Both apps run on the same host. When I call the
> >>>> webservice with curl it works fine, but when I call it with ajax from
> >>>> the other app I get a 500 internal server error. There are no errors
> >>>> in the web server log. DEBUG is True, and ALLOWED_HOSTS = ['*']. When
> >>>> I run the dev server and connect to that I get no errors, just the 500
> >>>> error. I tried setting a breakpoint in the view, but it never makes it
> >>>> there.
> >>>>
> >>>> Anyone have any ideas as to why this is happening or how I could debug
> >>>> it further?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CACwCsY5Ea%3DiJbXMfC14Ep-fQ%2BCjE7RYzu4XZ5xiDCUUECGXB7Q%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB3zLJUjsA_nXpMOAQNJw13CFUtZ2Xio8op4bzOZnLxuzA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to create a multi valued field in the model?

2015-03-23 Thread Filipe Ximenes
I'd also recommend using the "Choices" functionality of the Django Model
Utils project. It will give you good tools to keep the code readable,
simplify access and presentation of data:

https://django-model-utils.readthedocs.org/en/latest/utilities.html#choices

On Mon, Mar 23, 2015 at 4:34 PM, Vijay Khemlani  wrote:

> You can use an IntegerField with choices
>
> https://docs.djangoproject.com/en/1.7/ref/models/fields/#choices
>
> On Mon, Mar 23, 2015 at 4:28 PM, Daniel Grace  wrote:
>
>> How to create a field with multiple values?  For example an integer field
>> that takes on particular values:
>>
>> state = models.IntegerField()
>>
>> ... where state=0 represents 'pending', state=1 represents 'accepted' and
>> state=2 represents 'rejected'.
>> Is it possible to put these values / constants into the model?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/0ffb0a31-d900-4b62-826b-b779bab472a2%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/0ffb0a31-d900-4b62-826b-b779bab472a2%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALn3ei1X%2Bam5Mdwq6Upz_CCnEaea8XaZkKbEnpHL3MC25CrmJQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CALn3ei1X%2Bam5Mdwq6Upz_CCnEaea8XaZkKbEnpHL3MC25CrmJQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB3qK3Vex8%2Bzf2xFX%2BzRb9CMjfuoWaAU8uYMNk6umo4NxA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Data migration script populating db table - testing

2015-03-23 Thread Filipe Ximenes
One way to do it is to run all operations, don't call "save" and verify
"manually" if objects are correct.
I don't know about other methods, but if someone else does it would be
great.

On Sun, Mar 22, 2015 at 6:29 AM, Murthy Sandeep 
wrote:

> Hi
>
> I have created an data migration script for populating one of
> app db tables with data from a JSON file.  First I ran
>
> python manage.py makemigrations --empty TPP_App
>
>
>
> (‘TPP_App’ is the name of my app) and then I added a custom
> method called populate_db which will use bulk_create to add
> multiple entries to the table, and then do a save() to write the
> changes to the db.  At the moment the custom method is empty
> because I am still working on it, but the script looks like this right
> now
>
> # -*- coding: utf-8 -*-
> from __future__ import unicode_literals
>
> from django.db import models, migrations
>
> def populate_db( apps, schema_editor ):
> print ‘Populating db from JSON file...'
>
> class Migration(migrations.Migration):
>
> dependencies = [
> ('TPP_App', '0003_auto_20150224_2024'),
> ]
>
> operations = [
>migrations.RunPython( populate_db ),
> ]
>
> How do I test this script to make sure the custom method works
> as expected, before I run it fully?  Can I call this from the interpreter
> and test it with the db API?
>
> At the moment if I do
>
> python manage.py migrate
>
> it reports there are no migrations to apply.
>
> Sandeep
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/10767D81-937A-4F08-983A-B055C4AB3982%40sandeepmurthy.is
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB34WORCeaYAYxSN6FewAKJ1xhzVZcJitQFiL7s9eBDS%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django phonegap CORS

2015-03-18 Thread Filipe Ximenes
Awesome, sounds good!

On Wed, Mar 18, 2015 at 4:57 AM, Florian Auer  wrote:

> Hello Filipe
>
> The idea with the inAppBrowser was great.
> I allready was using this plugin but not that way
>
> Solution for me looks like the following:
> 1. I'm still using djangorestframework-jwt in the first to check the user
> credentials
>- token given from server = credentials OK
>- no token in response = wrong credentials
> 2. launch the inApp browser in "hidden mode" for the login screen and
> inject the credentials by script
> 3. use callbacvk from injection to turn inApp browser in "visible mode"
>
> Many Thanx for our help
>
> Am Freitag, 13. März 2015 21:33:36 UTC+1 schrieb Filipe Ximenes:
>>
>> Alright, I think I got what you want now.
>>
>> The first solution that comes to mind is to perform everything in the
>> browser. That way, you will first perform "window.open()" and then show a
>> "login view" from django server.
>>
>> I don't have any experience with Phonegap, but it seems that this can
>> also help you:
>> http://docs.phonegap.com/en/edge/cordova_inappbrowser_
>> inappbrowser.md.html#addEventListener
>>
>> Maybe if you attach a "loadstart" event to the browser and save user
>> credentials to "localStorage" or a cookie, using the method described here:
>> http://blogs.telerik.com/appbuilder/posts/13-12-23/
>> cross-window-communication-with-cordova's-inappbrowser
>>
>> Since everything will be working in a common browser application (not a
>> single page application, or phonegap app), I'd suggest you to work with
>> default Django cookie session and not with a token based authentication.
>> This will be simpler since once you set the cookie, the browser will take
>> care off passing it over page requests and you will not need to make
>> customisations to your Django views regarding authentication.
>>
>> On Fri, Mar 13, 2015 at 4:53 PM, Florian Auer  wrote:
>>
>>> Hello Filipe
>>>
>>> Thank you for the reply.
>>> Well the $http object was till now unknown for me.. there we can see how
>>> poor my AngularJS knowledge is till now.
>>>
>>> But as far as i understood the documentation i am not able to bring up a
>>> browser window by this that takes over the control of the app.
>>>
>>>
>>> The idea behind all is the following, maybe i did not describe it well.
>>>
>>> The App is only thought a a "startUp wrapper" with stored credentials in
>>> form of a login token.
>>> That token is claimed in a first asynchronous request with user
>>> credentials asked for interactively.
>>> Later on when the token is known, the app only sets the headers an calls
>>> the django web page where the user gets logged in due the header
>>> automatically.
>>>
>>> At the moment I was using the JWT (http://getblimp.github.io/
>>> django-rest-framework-jwt/) to claim a token. But i do not know how to
>>> use this to let the user been logged in with the call of a browser window.
>>> Maybe I need tho turn over to TokenBasedAuthentification like described
>>> in (http://www.django-rest-framework.org/api-guide/authentication/#
>>> tokenauthentication)?
>>> But then I will still have the same problem... How to bring the token
>>> into the headers and thenn call a page from the server rendered inside the
>>> browser in UI mode (not in the app as sub page)
>>>
>>> My idea was, that an phonegap app is nothing more than a browser
>>> rendered app.
>>> When I can create a request to a server to claim an Auth Token and be
>>> able to set this into the headers, the next Ui request to the server
>>> (launching another browser window by window.open()) will let me call
>>> directly to a restricted view.
>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/
>>> msgid/django-users/db6f6050-b1b9-4ea4-9729-94a3184c5e82%
>>> 40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/db6f605

Re: Django Query to get max rating

2015-03-18 Thread Filipe Ximenes
>From what I could understand, you are trying to fetch all the top ratings
for each question in a group, correct?

The problem is that this query:

top_rated_list = Ratings.objects.get(rating = max_rating)
​
is returning more than one rating instance. "get" queries are supposed to
return a single result, if you need more than one, you should be using a
"filter" query.

This is happening because there are more than one rating with a max_rating
in your database. What i think you really meant to be doing is to fetch the
best for rating for a single question, so your query would look like this:

top_rated_list = Ratings.objects.get(rating = max_rating, question=i)
​
But, this can also lead to the same error when two users give a question
the same rate.
In this case, if it doesn't mater if you pick one or the other, a fix for
this can be:

top_rated_list = Ratings.objects.filter(rating = max_rating,
question=i).first()
​
Now, the way you are doing this, the "top_rated_list" will only have one
rating object everytime. To return a list of ratings, you should appending
to the list:

question_top_rate =  Ratings.objects.filter(rating = max_rating,
question=i).first()
top_rated_list.append(question_top_rate)

​
Also, the way you are modelling the relationships, there is a many to many
relationship from a Group to a Question, so a question belongs to multiple
groups. If this is the behaviour you are looking for, you should be using
a ManyToManyField as documented here:
https://docs.djangoproject.com/en/1.7/ref/models/fields/#manytomanyfield
also, take a look in the "through" parameter:
https://docs.djangoproject.com/en/1.7/ref/models/fields/#django.db.models.ManyToManyField.through
It what your really wanted was to a question belong to a single group, it
would make more sense to have a ForeignKey to Group in the Question model.

You can also optimize the way you are doing the queries, but that's another
topic.
-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB0c%2B-u4KS%3D8rJARQsOhJpQK84B1C_NOc_zV2ErUq2FaeQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django phonegap CORS

2015-03-17 Thread Filipe Ximenes
Hey, I wrote a blog post about CORS and Django with more details about the
subject:
http://www.vinta.com.br/blog/2015/django-cors.html

=)

On Fri, Mar 13, 2015 at 5:32 PM, Filipe Ximenes 
wrote:

> Alright, I think I got what you want now.
>
> The first solution that comes to mind is to perform everything in the
> browser. That way, you will first perform "window.open()" and then show a
> "login view" from django server.
>
> I don't have any experience with Phonegap, but it seems that this can also
> help you:
>
> http://docs.phonegap.com/en/edge/cordova_inappbrowser_inappbrowser.md.html#addEventListener
>
> Maybe if you attach a "loadstart" event to the browser and save user
> credentials to "localStorage" or a cookie, using the method described here:
>
> http://blogs.telerik.com/appbuilder/posts/13-12-23/cross-window-communication-with-cordova's-inappbrowser
>
> Since everything will be working in a common browser application (not a
> single page application, or phonegap app), I'd suggest you to work with
> default Django cookie session and not with a token based authentication.
> This will be simpler since once you set the cookie, the browser will take
> care off passing it over page requests and you will not need to make
> customisations to your Django views regarding authentication.
>
> On Fri, Mar 13, 2015 at 4:53 PM, Florian Auer  wrote:
>
>> Hello Filipe
>>
>> Thank you for the reply.
>> Well the $http object was till now unknown for me.. there we can see how
>> poor my AngularJS knowledge is till now.
>>
>> But as far as i understood the documentation i am not able to bring up a
>> browser window by this that takes over the control of the app.
>>
>>
>> The idea behind all is the following, maybe i did not describe it well.
>>
>> The App is only thought a a "startUp wrapper" with stored credentials in
>> form of a login token.
>> That token is claimed in a first asynchronous request with user
>> credentials asked for interactively.
>> Later on when the token is known, the app only sets the headers an calls
>> the django web page where the user gets logged in due the header
>> automatically.
>>
>> At the moment I was using the JWT (
>> http://getblimp.github.io/django-rest-framework-jwt/) to claim a token.
>> But i do not know how to use this to let the user been logged in with the
>> call of a browser window.
>> Maybe I need tho turn over to TokenBasedAuthentification like described
>> in (
>> http://www.django-rest-framework.org/api-guide/authentication/#tokenauthentication
>> )?
>> But then I will still have the same problem... How to bring the token
>> into the headers and thenn call a page from the server rendered inside the
>> browser in UI mode (not in the app as sub page)
>>
>> My idea was, that an phonegap app is nothing more than a browser rendered
>> app.
>> When I can create a request to a server to claim an Auth Token and be
>> able to set this into the headers, the next Ui request to the server
>> (launching another browser window by window.open()) will let me call
>> directly to a restricted view.
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/db6f6050-b1b9-4ea4-9729-94a3184c5e82%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/db6f6050-b1b9-4ea4-9729-94a3184c5e82%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
>
>
> *Filipe Ximenes*+55 (81) 8245-9204
>
> *Vinta Software Studio*http://www.vinta.com.br
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB3vtvnHbmgfZWGOefLMgkbH0SyqAEZ3VZgGaYRdoNRCUw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: forms of 2 tables upload files

2015-03-17 Thread Filipe Ximenes
You can keep the ModelForm just like the tutorial and override the "save"
method.
It will look something like this:

class MyForm(forms.ModelForm):
the_file = forms.FileField(required=True)

class Meta:
model = Person
fields = ('name', 'email', 'the_file')

def save(self, commit=True):
person = super(MyForm, self).save(commit)

file_instance = FileModel(the_file=self.cleaned_data['the_file'])

if commit:
file_instance.save()

return person
-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB3fFrOiU7yDtnEcPo33SmrNCSUSNX3%3DNZOLmi-WHQf2BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django phonegap CORS

2015-03-13 Thread Filipe Ximenes
Alright, I think I got what you want now.

The first solution that comes to mind is to perform everything in the
browser. That way, you will first perform "window.open()" and then show a
"login view" from django server.

I don't have any experience with Phonegap, but it seems that this can also
help you:
http://docs.phonegap.com/en/edge/cordova_inappbrowser_inappbrowser.md.html#addEventListener

Maybe if you attach a "loadstart" event to the browser and save user
credentials to "localStorage" or a cookie, using the method described here:
http://blogs.telerik.com/appbuilder/posts/13-12-23/cross-window-communication-with-cordova's-inappbrowser

Since everything will be working in a common browser application (not a
single page application, or phonegap app), I'd suggest you to work with
default Django cookie session and not with a token based authentication.
This will be simpler since once you set the cookie, the browser will take
care off passing it over page requests and you will not need to make
customisations to your Django views regarding authentication.

On Fri, Mar 13, 2015 at 4:53 PM, Florian Auer  wrote:

> Hello Filipe
>
> Thank you for the reply.
> Well the $http object was till now unknown for me.. there we can see how
> poor my AngularJS knowledge is till now.
>
> But as far as i understood the documentation i am not able to bring up a
> browser window by this that takes over the control of the app.
>
>
> The idea behind all is the following, maybe i did not describe it well.
>
> The App is only thought a a "startUp wrapper" with stored credentials in
> form of a login token.
> That token is claimed in a first asynchronous request with user
> credentials asked for interactively.
> Later on when the token is known, the app only sets the headers an calls
> the django web page where the user gets logged in due the header
> automatically.
>
> At the moment I was using the JWT (
> http://getblimp.github.io/django-rest-framework-jwt/) to claim a token.
> But i do not know how to use this to let the user been logged in with the
> call of a browser window.
> Maybe I need tho turn over to TokenBasedAuthentification like described in
> (
> http://www.django-rest-framework.org/api-guide/authentication/#tokenauthentication
> )?
> But then I will still have the same problem... How to bring the token into
> the headers and thenn call a page from the server rendered inside the
> browser in UI mode (not in the app as sub page)
>
> My idea was, that an phonegap app is nothing more than a browser rendered
> app.
> When I can create a request to a server to claim an Auth Token and be able
> to set this into the headers, the next Ui request to the server (launching
> another browser window by window.open()) will let me call directly to a
> restricted view.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/db6f6050-b1b9-4ea4-9729-94a3184c5e82%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/db6f6050-b1b9-4ea4-9729-94a3184c5e82%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB2avGQ-c2twL%3DAsM5rgzbuJ3U0G6wNS-4oeMSUARJ2rUA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django phonegap CORS

2015-03-13 Thread Filipe Ximenes
You should not be using window.open() to perform requests in Angular.
Instead, use Angular $http service for this:
https://docs.angularjs.org/api/ng/service/$http

With $http you'll be able to send requests with parameters, headers and any
configuration you need.

On Fri, Mar 13, 2015 at 8:55 AM, Florian Auer  wrote:

> Thanks to Filipe, the asynchronous request to django is working correctly.
> A request to the endpoint url results in a JSON response with the token in
> it.
>
> But now I have another gap in my "logic".
>
> Inside this angular app the django site is requested via a call like this,
> to takeover control from the app.
> var ref = window.open(url, '_self', 'location=yes');
> ref.addEventListener('exit', function(event) {
> alert(event.type);
> });
>
> The question is, how can I make a call the restricted view on the django
> site with the token included, to log in the user.
> Would it be a possibility to add the token as GET argument to the url?
>
> too many trees in this forest :)
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/00ca9fea-316e-405b-95ba-3bc554a0274d%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/00ca9fea-316e-405b-95ba-3bc554a0274d%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB2XEXv1wUqwHaVeqOn7S_5hpM-v4tnWYyO4e_Yk-0BU%3Dg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django phonegap CORS

2015-03-11 Thread Filipe Ximenes
Not 100% sure I understood your question, but it seems that you are trying
to overcome the CORS only from the frontend side when you should be
treating it from the Django side.
Could you take a look on this package:
https://github.com/ottoyiu/django-cors-headers

If it suits your needs, a good idea is to have your API endpoints beginning
with something like "/api/{whatever you want}" and set:

CORS_ORIGIN_ALLOW_ALL = True

CORS_URLS_REGEX = r'^/api/.*$'
-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-QWB3EOZ0_snd7r5TK%2B8oJVJ0ZG1AbV81b2Qp%2B_4uPD30AkA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.