Django and Authorize.net

2016-06-08 Thread Arshpreet Singh
 
I want to use Django+authorize.net, I have tried merchant but could not 
figure it out, is there any tutorial/information I can use?

-- 
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/b9162495-f5ca-43ef-ad4d-0200b9ddbd97%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: User Registration

2016-06-08 Thread vaibhav
HI,
You can create a custom model like this and define all custom fields within 
it:
class UserInfo(AbstractTimestampClass):
user = models.ForeignKey(User)
address = models.TextField(blank=True, null=True)
city = models.CharField(max_length=25, blank=True, null=True)
postal_code = models.CharField(max_length=20, blank=True, null=True)
state = models.CharField(max_length=40, blank=True, null=True)
country = models.CharField(max_length=100, blank=True, null=True)
company = models.CharField(max_length=100, blank=True, null=True)
phone = models.CharField(max_length=25, blank=True, null=True)
fax = models.CharField(max_length=25, blank=True, null=True)

Note the above model is referring to the in built User model through 
foreign key relationship.
On registration API you would need to create both User and UserInfo objects.
Something like:
user = User.objects.create_user(username=validated_data['email'],
email=validated_data['email'],

password=validated_data['password'],)
UserInfo.objects.create(user=user,
address=validated_data['address'],
city=validated_data['city'],etc.)
That would suffice.

On Wednesday, June 8, 2016 at 4:19:31 PM UTC+5:30, Arshpreet Singh wrote:
>
> I am implementing Django User registration method as provided in the 
> following tutorial: 
>
>
> https://mayukhsaha.wordpress.com/2013/05/09/simple-login-and-user-registration-application-using-django/
>  
>
> It is not using any model/model-form, But I want to connect with 
> User-registration with other defined model. 
>
> Is it possible using the above tutorial or I have to create new 
> UserRegistration model? 
>
> -- 
>
> Thanks 
> Arshpreet Singh 
> Python Developer 
> RevinfoTech 
> Web Development/Data Science/Systems Integration 
> Mobile: (91)987 6458 387 
> http://www.revinfotech.com/ 
> https://www.linkedin.com/in/arsh840 
>

-- 
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/cf5cdce9-f4ab-4605-96f6-d02496b00b45%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Add SQL to every migration creating a field

2016-06-08 Thread TheBeardedTemplar
Hey all,

I'll try to be as clear as I can with this problem - basically I am 
implementing soft-delete functionality in order to allow an 'undo' function 
that extends quite far into the past. My plan is to do it by creating a 
subclass of models.Model that looks like this:

class SoftDeleteModel(models.Model):
"""
A subclass of the Django model object that is used to add safe-delete 
functionality.
"""
deleted_on = models.DateTimeField(blank=True, null=True, default=None, 
editable=False)


#Note that related_name '+' tells Django not to create a backwards 
relation
deleted_by = models.ForeignKey(UserModel, blank=True, null=True, 
on_delete=models.SET_NULL,
   editable=False, related_name='+')

However I've run into an issue where many of my models have uniqueness 
constraints that I don't want to have violated by soft deleted objects. I'm 
using PostgreSQL and would like to do this using partial indexes so I can 
do something like this:

CREATE UNIQUE INDEX idx1 
  ON Post (name, obj_id, deleted_on) 
  WHERE deleted_on IS NULL;


So the unique constraint will only be violated if two objects have the same 
unique field and they haven't been deleted.

The problem is that I will likely have dozens or hundreds of 
SoftDeleteModel's in my database. I could manually modify each migration 
with a RunSQL statement but that would be time consuming. Is there a way 
that I could indicate that any SoftDeleteModel should create a migration 
that modifies each unique constraint into a partial unique constraint? 
Basically like an automatic custom migration?

Thanks

-- 
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/017bca80-5652-412a-bfba-a8bed7b0aa55%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django heroku deploy results in site cant be reached error

2016-06-08 Thread Dave N
My full django deploy issue can be found 
here: 
http://stackoverflow.com/questions/37714253/django-deploy-on-heroku-gives-site-cant-be-reached-response

In summary, my app works locally with runserver, and also works perfectly 
when I use heroku local on 0.0.0.0:5000. When I introduce gunicorn my app 
gives a blank page with "This site can’t be reached, localhost took too 
long to respond”. Looking through heroku logs, I get no error code, just 
evidence of 301 redirects. Same result on sitename.herokuapp.com

Any idea how I can get my app to serve correctly in the wild?

-- 
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/4ec2f132-b3c4-45a9-8205-aa90f223cb3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Test fails when run in whole test suite - but not stand-alone?

2016-06-08 Thread learn django
Hi Adam,

I was hitting same issue but never got chance to debug it.
If the underneath database support database transactions then isn't that
each test will be treated as a separate transaction and transaction should 
be rolled back
after the test is over to keep the database sane ?

On Wednesday, June 8, 2016 at 1:43:40 AM UTC-7, Derek wrote:
>
> Thanks Adam, I will try that.  I think I have been lax in the use of 
> tearDown.
>
> On Thursday, 2 June 2016 21:47:00 UTC+2, Adam wrote:
>>
>> When I've had that happen before, it's because some previous test changed 
>> something (like a setting value or the site domain) that influenced the 
>> test that failed. To narrow it down, I would run all the tests up to and 
>> including the failed one. That should fail, then I start taking out half 
>> the tests before. If the test still fails, I keep cutting in half until I 
>> can determine which previous test is causing issues. If, after cutting out 
>> tests, the problem test passes, then I need to put back in what I took out 
>> since it was one of those.
>>
>> Once I figure out which previous test it was, I can start removing the 
>> individual tests to finally get to the code causing the problem. Usually, 
>> it's a case that a test changed something and I just have to add in the 
>> teardown function to restore the state of whatever was changed.
>>
>> On Thu, 2016-06-02 at 21:33 +0200, Derek wrote:
>>
>> I have a test that is failing when the file it is in is run as part of 
>> all the other test files by the test runner.
>>
>> If I just run only the file that contains this test -  then it passes.
>>
>> (pass/fail refers to the very last assert in the code below.)
>>
>> I'd appreciate any ideas or insights from anyone who can spot an obvious 
>> mistake - or suggest some options to explore.
>>
>> Thanks
>> Derek
>>
>>
>> # THIS IS AN EXTRACT OF RELEVANT CODE (not all of it...)
>> from django.contrib.messages.storage.fallback import FallbackStorage
>> from django.core.urlresolvers import reverse
>> from django.test import TestCase, Client
>> # ... various app-related imports ...
>>
>>
>> class MockRequest(object):
>> """No code needed."""
>> pass
>>
>>
>> REQUEST = MockRequest()
>> # see: https://stackoverflow.com/queI 
>> stions/11938164/why-dont-my-django-\
>> #  unittests-know-that-messagemiddleware-is-installed
>> setattr(REQUEST, 'session', 'session')
>> MESSAGES = FallbackStorage(REQUEST)
>> setattr(REQUEST, '_messages', MESSAGES)
>> setup_test_environment()
>>
>>
>> class PersonAdminTest(TestCase):
>>
>> def setUp(self):
>> self.user, password = utils.user_factory(model=None)
>> self.client = Client()
>> login_status = self.client.login(username=self.user.email, 
>> password=password)
>> self.assertEqual(login_status, True)
>>
>> def test_action_persons_make_unreal(self):
>> try:
>> change_url = reverse('admin:persons_realpersons_changelist')
>> except NoReverseMatch:
>> change_url = '/admin/persons/realpersons/'
>> sys.stderr.write('\n   WARNING: Unable to reverse URL! ... ')
>> response = self.client.get(change_url)
>> self.assertEqual(response.status_code, 200)
>>
>> -- 
>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CAF1Wu3MoGgm_dSToObDX9gH7GQJ%3DTZzGLV7RPOiZk4kvV-_Nbg%40mail.gmail.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>> -- 
>> Adam (ad...@csh.rit.edu)
>>
>>
>>

-- 
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/ff76d73a-3baf-4053-b539-7734ba53e61d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Adding Tinymce to Admin

2016-06-08 Thread Ankush Thakur
I wish to add TinyMCE editor to my Django-powered app. My Model is a
typical blog model, with a TextField for the actual post contents. Now what
I want is, every time I'm editing the contents (or adding a new blog), I
should be able to write in a WordPress-style editor.

I understand that I'd need to add some third-party app for TinyMCE and then
set it as a widget, but my problem is that the admin templates do not
reside in my project Git repository. They are in the virtualenv directory,
and I'm not sure how I'll be able to integrate them into my project.

A little voice at the back of my head tells me that I won't need to alter
Admin, but I'm not sure. Because I don't have any forms (I directly
edit/create from the Admin), I don't think I can get away with only saying
something like 'content = models.TextField(widget='tinymce')'?

Regards,
Ankush Thakur

-- 
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/CALX%3DrKLBResPR-n8SCibpckFAN5PwhHWSH5xBgEnmPaGLUvsrw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django websites for study and improvement

2016-06-08 Thread Ankush Thakur
Wow, that's quite a lot! Thanks, Akhil! Can I write to you with (silly) 
questions I might have about these? :P

~~Ankush

On Tuesday, May 31, 2016 at 11:39:53 PM UTC+5:30, Akhil Lawrence wrote:
>
> You can get many django based applications from github. 
>
> https://github.com/taigaio/taiga-back
> https://github.com/mayan-edms/mayan-edms/
> https://github.com/stephenmcd/cartridge
>
> You can also refer
>
> https://github.com/rosarior/awesome-django
> https://github.com/search?q=django
>
>
> Even though you are not interested in django internals.. this might be 
> helpful
>
> http://ccbv.co.uk/
>
>
>
> On Tuesday, 31 May 2016 23:26:39 UTC+5:30, Ankush Thakur wrote:
>>
>> Are there any large-ish (I mean, beyond blogs, polls, etc.) websites (web 
>> apps?) out there that are open source and can help me learn in the real 
>> world? I have covered the basics, even converted my own blog into Django, 
>> but I feel I don't know anything about how Django is used out in the wild.
>>
>> I can choose to study the django.contrib apps, but my focus is not on 
>> diving into Django's internals right now.
>>
>> Any recommendations?
>>
>> Regards,
>> Ankush Thakur
>>
>

-- 
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/ab950713-d30b-4ab6-93f2-b7b425816e6b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django websites for study and improvement

2016-06-08 Thread Ankush Thakur
Superb recommendation, Tim! Thanks once again! :D :D

~~Ankush

On Wednesday, June 1, 2016 at 8:18:46 PM UTC+5:30, Tim Graham wrote:
>
> You might enjoy looking at djangoproject.com itself: 
> https://github.com/django/djangoproject.com/
>
> On Tuesday, May 31, 2016 at 1:56:39 PM UTC-4, Ankush Thakur wrote:
>>
>> Are there any large-ish (I mean, beyond blogs, polls, etc.) websites (web 
>> apps?) out there that are open source and can help me learn in the real 
>> world? I have covered the basics, even converted my own blog into Django, 
>> but I feel I don't know anything about how Django is used out in the wild.
>>
>> I can choose to study the django.contrib apps, but my focus is not on 
>> diving into Django's internals right now.
>>
>> Any recommendations?
>>
>> Regards,
>> Ankush Thakur
>>
>

-- 
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/4dc15205-c6b6-4849-8917-390bae65222f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Expiration date option

2016-06-08 Thread 'David Turner' via Django users
Hi James

Just one more quick question:
I have two django models both containing the same information, temps and
companies.
The models both contain the following fields:

odd days
weekends
nights
emergencies

Currently this allows me to filter on these fields in django admin.
My question is would I be better treating these as a many to many model and
using them that way and how would I filter them in django admin?

Best

-david

On 8 June 2016 at 16:04, David Turner  wrote:

> Many thanks for the answer especially the amount of detail in it.
>
> Best
>
> -david
>
> On 8 June 2016 at 09:26, James Schneider  wrote:
>
>> >
>> > Many thanks for your answer which makes perfect sense and yes, this is
>> only required for a single view.
>> > The expiry_date is needed as items are listed by expiry date. So would
>> you suggest removing the has_expired and writing the filter against the
>> expiry date?
>> >
>>
>> Yes, I meant that you should keep the expiry_date field, but eliminate
>> the has_expired field. I had a minor typo above that made it sound like you
>> should eliminate both fields, which is not the case.
>>
>> BTW, I would also suggest changing expiry_date to expiry_datetime and
>> store a full date/time object in it (if you aren't already) to remove
>> ambiguity down the road. You don't want to have to remember that the expiry
>> happens at 00:00 or 07:42 or whether or not the date is inclusive or
>> exclusive on the last day, etc. Using a single point in time makes life
>> grand for you and anyone working on your code who isn't you. All datetimes
>> should be timezone aware and stored in UTC if possible.
>>
>> Regarding writing the filter against expiry_datetime instead of
>> has_expired, the answer is yes, I would suggest doing so. The query is
>> probably marginally more expensive, but code cleanliness and maintenance
>> overhead make it worth it in most cases.
>>
>> I would add an asterisk to my answer though:
>>
>> *only if an object should be considered in an "expired" state if the
>> current (or given) date/time is greater than the expiry_datetime. If the
>> expiry_datetime is in the future, consider the object "not expired".
>>
>> Actually my entire answer is predicated on the * statement above being
>> accurate as my assumption.
>>
>> You will likely end up writing a custom model manager method down the
>> road, especially if you commonly filter against other fields like
>> "is_disabled" where you would need only objects that are not expired and
>> are active/not disabled.
>>
>> -James
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Django users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/django-users/aSj3jGX2CLk/unsubscribe.
>> To unsubscribe from this group and all its topics, 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/CA%2Be%2BciVdqmrjPsnc1U2rkerTRC-1HrSPWE%3D9Q%2Bx%3DDOE4P6BEzQ%40mail.gmail.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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALwQ%2B-tfzvaG2%2BWpfrj4e1PFdS6dHnR238gMCems_tpnS%3D%3DhnA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Expiration date option

2016-06-08 Thread 'David Turner' via Django users
Many thanks for the answer especially the amount of detail in it.

Best

-david

On 8 June 2016 at 09:26, James Schneider  wrote:

> >
> > Many thanks for your answer which makes perfect sense and yes, this is
> only required for a single view.
> > The expiry_date is needed as items are listed by expiry date. So would
> you suggest removing the has_expired and writing the filter against the
> expiry date?
> >
>
> Yes, I meant that you should keep the expiry_date field, but eliminate the
> has_expired field. I had a minor typo above that made it sound like you
> should eliminate both fields, which is not the case.
>
> BTW, I would also suggest changing expiry_date to expiry_datetime and
> store a full date/time object in it (if you aren't already) to remove
> ambiguity down the road. You don't want to have to remember that the expiry
> happens at 00:00 or 07:42 or whether or not the date is inclusive or
> exclusive on the last day, etc. Using a single point in time makes life
> grand for you and anyone working on your code who isn't you. All datetimes
> should be timezone aware and stored in UTC if possible.
>
> Regarding writing the filter against expiry_datetime instead of
> has_expired, the answer is yes, I would suggest doing so. The query is
> probably marginally more expensive, but code cleanliness and maintenance
> overhead make it worth it in most cases.
>
> I would add an asterisk to my answer though:
>
> *only if an object should be considered in an "expired" state if the
> current (or given) date/time is greater than the expiry_datetime. If the
> expiry_datetime is in the future, consider the object "not expired".
>
> Actually my entire answer is predicated on the * statement above being
> accurate as my assumption.
>
> You will likely end up writing a custom model manager method down the
> road, especially if you commonly filter against other fields like
> "is_disabled" where you would need only objects that are not expired and
> are active/not disabled.
>
> -James
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/aSj3jGX2CLk/unsubscribe.
> To unsubscribe from this group and all its topics, 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/CA%2Be%2BciVdqmrjPsnc1U2rkerTRC-1HrSPWE%3D9Q%2Bx%3DDOE4P6BEzQ%40mail.gmail.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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALwQ%2B-tCXfsJsTYwsgAesLcQWH2VxznSnxzH0c1_iR0jTGgUig%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Autocomplete for Admin search field

2016-06-08 Thread Derek
I have not done this; but I think you would need to overwrite the default 
Django template and add in a special widget (such as the 
django-autocomplete-
light one).  Bear in mind you'd also need to handling searching across 
multiple fields.

On Wednesday, 8 June 2016 14:08:54 UTC+2, Александр Жидовленко wrote:
>
> Could search_field in Django Admin has autocomplete?
> http://dl2.joxi.net/drive/2016/06/08/0001/1889/128865/65/95babc09ea.jpg
> In my case I want to type name of product and to see autocomplete list of 
> products.
>
> I found django-autocomplete-light but it uses autocomlete only on 
> change_list pages. Am I wrong?
>

-- 
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/37053c87-0a96-4941-8e3f-e2ab5d5b5416%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Autocomplete for Admin search field

2016-06-08 Thread Александр Жидовленко
Could search_field in Django Admin has autocomplete?
http://dl2.joxi.net/drive/2016/06/08/0001/1889/128865/65/95babc09ea.jpg
In my case I want to type name of product and to see autocomplete list of 
products.

I found django-autocomplete-light but it uses autocomlete only on 
change_list pages. Am I wrong?

-- 
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/365e6f86-87e7-4a26-bcf8-8fe0e2087f93%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: User Registration

2016-06-08 Thread ludovic coues
Have you looked at the django documentation ?
There is a builtin form for creating a new user, working with user
model shipped with django.
https://docs.djangoproject.com/en/1.9/topics/auth/default/#django.contrib.auth.forms.UserCreationForm



2016-06-08 10:46 GMT+02:00 Arshpreet Singh :
> I am implementing Django User registration method as provided in the
> following tutorial:
>
> https://mayukhsaha.wordpress.com/2013/05/09/simple-login-and-user-registration-application-using-django/
>
> It is not using any model/model-form, But I want to connect with
> User-registration with other defined model.
>
> Is it possible using the above tutorial or I have to create new
> UserRegistration model?
>
> --
>
> Thanks
> Arshpreet Singh
> Python Developer
> RevinfoTech
> Web Development/Data Science/Systems Integration
> Mobile: (91)987 6458 387
> http://www.revinfotech.com/
> https://www.linkedin.com/in/arsh840
>
> --
> 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/CAAstK2GtNnR9N%3Dg2-m8ZHKt9R4Bt4nUJFjBXpMdGoD%2B73nujRg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 42

-- 
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/CAEuG%2BTbVAU2uB0b3O_KHWKSkrzENAWboJ63QNkZqoggQTyTyqA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


User Registration

2016-06-08 Thread Arshpreet Singh
I am implementing Django User registration method as provided in the
following tutorial:

https://mayukhsaha.wordpress.com/2013/05/09/simple-login-and-user-registration-application-using-django/

It is not using any model/model-form, But I want to connect with
User-registration with other defined model.

Is it possible using the above tutorial or I have to create new
UserRegistration model?

-- 

Thanks
Arshpreet Singh
Python Developer
RevinfoTech
Web Development/Data Science/Systems Integration
Mobile: (91)987 6458 387
http://www.revinfotech.com/
https://www.linkedin.com/in/arsh840

-- 
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/CAAstK2GtNnR9N%3Dg2-m8ZHKt9R4Bt4nUJFjBXpMdGoD%2B73nujRg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Template Django - Can't display model field in Django Template

2016-06-08 Thread Yan L'kabousse
Hello everyone :)

I want to display some datas on a  wtih Django Template. I have menus 
(for eat in reaturant) But I can't display the menuItems in the  But it 
displays other parts of the table.

Here is my stackoverflow topic if you want more details (model for example) 
: 
http://stackoverflow.com/questions/37684960/django-template-display-model-data?noredirect=1#comment62866889_37684960

Thank you a lot if you can help me on my problem :) 

{% trans "My menus" %}
  
  
  
  {% trans "Name" %}
  {% trans "Detail" %}
  {% trans "Action" %}
  
  {% for menu in menus %}


  {{menu.title}} - {{menu.validDate|date:"d.m.Y"}}
  {% if menu.midi and menu.soir %}
  - Midi & Soir
  {% elif menu.midi %}
  - Midi
  {% elif menu.soir %}
  - Soir
  {% endif %}


{% for paragraph in menuParagraph %}
{{paragraph.text}}
{% for menuItem in menuItems %}
{% if menuItem.paragraph.text == paragraph.text %}

{{menuItem.descrShort}} 
({{menuItem.menuItemId.name}})

{% endif %}
{% endfor %}
{% endfor %} -->
  {% for menuitem in menuitems %}
{{menuitem.descrShort}} ({{menuItem.menuItemId.name}})
  {% endfor %}


|


{% endfor %}
  



-- 
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/f14f07bf-2a5d-4d14-a0e7-b048aafbefb7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Test cases are always referring to default database in case of Multiple databases

2016-06-08 Thread vaibhav
Hi,
I am trying to run some test cases on one of the apps of my Django Project.
My settings.py file specifies two different databases as follows:

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
},
'guest': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.guest.sqlite3'),
}
}


My models are as follows:

class Industry(AbstractTimestampClass):
name = models.CharField(max_length=100, unique=True)

def __str__(self):
return self.name

def __unicode__(self):
return self.name

class Meta:
verbose_name_plural = "Industries"



class Aim(AbstractTimestampClass):
name = models.CharField(max_length=100, unique=True)
icon = models.CharField(max_length=255)

def __str__(self):
return self.name

def __unicode__(self):
return self.name


class Campaign(AbstractTimestampClass):
website = models.CharField(max_length=255)
industry = models.ManyToManyField(Industry,   
related_name='related_industry_guest_campaigns')
aim = models.ManyToManyField(Aim, 
related_name='related_aim_guest_campaigns')
tracking_id = models.CharField(max_length=50, null=True, 
blank=True, db_index=True)

def save(self, *args, **kwargs):
'''add custom events while saving category'''
if self.id is None:
self.tracking_id = str(uuid.uuid4())
super(Campaign, self).save(*args, **kwargs)

def __str__(self):
return str(self.id)

def __unicode__(self):
return str(self.id)

My serializer is as follows:

class GuestCampaignSerializer(serializers.ModelSerializer):
class Meta:
model = Campaign
fields = ('website', 'tracking_id', 'industry', 'aim',   
 'created_on')

def validate(self, data):
if data['website']:
parsed_url = urlparse(data['website'])
data['website'] = parsed_url.scheme + '://' + 
 parsed_url.netloc
return data

def create(self, validated_data):
try:
campaign = 
Campaign.objects.using('guest').create(website=validated_data['website'])
campaign.save(using='guest')
campaign.aim.clear()
campaign.aim.set(validated_data['aim'],using='guest')
campaign.industry.clear()

campaign.industry.set(validated_data['industry'],using='guest')
return campaign
except Exception as e:
print "Exception in GuestCampaignSerializer - " + str(e)


The view is as follows:

class GuestCampaignViewSet(APIView):
permission_classes = (permissions.AllowAny,)
serializer = GuestCampaignSerializer

def post(self, request):
'''
Create new guest variation
---
type:
website:
required: true
type: string

responseMessages:
-   code: 200
message: 
-   code: 400
message: Bad request

consumes:
- application/json

produces:
- application/json
'''
try: 
print "In Guest campaign create"
print Industry.objects.using('guest').all()
data = self.serializer(data=request.data)
if data.is_valid():
campaign_obj = data.save()

# save first page w.r.t newly created campaign info
page_obj = Page()
page_obj.url = request.data['website']
page_obj.campaign_id = campaign_obj.id
page_obj.save(using='guest')

return Response({
"campaign" : {
"tracking_id": data.data['tracking_id'],
},
"page":  {
   "id": page_obj.id,
},
}, status=status.HTTP_201_CREATED)
else:
return Response({
"error" : {
"message" : "Error while creating the Guest 
Campaign",
"details" : data.errors
}
}, status=status.HTTP_400_BAD_REQUEST)

except Exception as e:
return Response({
"details": str(e)
}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)


The test case is as follows:


FieldDoesNotExist during custom migration

2016-06-08 Thread Gagaro
Hello,

I'm trying to make a migration to change a field ("filter") from a 
ForeignKey to a CharField. The migration is as follow :

class Migration(migrations.Migration):

operations = [
migrations.AddField(
model_name='Rendition',
name='filter2',
field=models.CharField(max_length=255, db_index=True),
),
migrations.RunPython(forwards_data_migration, reverse_data_migration
),
migrations.RemoveField(model_name='Rendition', name='filter'),
migrations.DeleteModel('Filter'),
migrations.RenameField(model_name='Rendition', old_name='filter2', 
new_name='filter'),
]

When running the migration, I have the following error:

django.core.exceptions.FieldDoesNotExist: Rendition has no field named 
> u'filter'
>

The error happens  during the RemoveField (migrations.RemoveField(model_name
='Rendition', name='filter')).

So, a couple questions:

* Is there a better way to change a field type (with data migration)?
* Why do I have this error, when my field is present?

The migration can be found there: 
https://github.com/Gagaro/wagtail/blob/02f4804b49d6f8b65ffb193d7a0dfc7872d323bd/wagtail/wagtailimages/migrations/0014_remove_filter_model.py
And the relevant model is 
there: 
https://github.com/Gagaro/wagtail/blob/02f4804b49d6f8b65ffb193d7a0dfc7872d323bd/wagtail/wagtailimages/models.py#L458-L516

Thanks

-- 
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/377e7587-05fe-4479-93e1-813be3609437%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Non Ascii character in upload file crash in python 3

2016-06-08 Thread Xavier Ordoquy
Hi,

Le mercredi 8 juin 2016 10:13:46 UTC+2, luisza14 a écrit :
>
> I am using supervisor and gunicorn for production run as fondomutual user.
>
> $ env | grep LANG
> LANG=es_CR.UTF-8
> LANGUAGE=es_CR:es
>

Supervisor doesn't propagate the locales to its supervised processes. You 
need to set them explicitly in process configuration file.

Regards,
Xavier,
Linovia.

-- 
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/9cd0eb3f-c26e-42c6-b74a-2fd69594d5ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Non Ascii character in upload file crash in python 3

2016-06-08 Thread Michal Petrucha
On Wed, Jun 08, 2016 at 02:13:23AM -0600, Luis Zárate wrote:
> I am using supervisor and gunicorn for production run as fondomutual user.
> 
> $ env | grep LANG
> LANG=es_CR.UTF-8
> LANGUAGE=es_CR:es

Are you certain that when supervisord is started by
init/systemd/upstart, it is also launched with the same locale?
Sometimes, init scripts deliberately set the locale to C or POSIX; I
remember encountering something similar with Apache on Debian a few
years ago.

Good luck,

Michal

-- 
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/20160608092648.GZ29054%40konk.org.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


Re: Test fails when run in whole test suite - but not stand-alone?

2016-06-08 Thread Derek
Thanks Adam, I will try that.  I think I have been lax in the use of 
tearDown.

On Thursday, 2 June 2016 21:47:00 UTC+2, Adam wrote:
>
> When I've had that happen before, it's because some previous test changed 
> something (like a setting value or the site domain) that influenced the 
> test that failed. To narrow it down, I would run all the tests up to and 
> including the failed one. That should fail, then I start taking out half 
> the tests before. If the test still fails, I keep cutting in half until I 
> can determine which previous test is causing issues. If, after cutting out 
> tests, the problem test passes, then I need to put back in what I took out 
> since it was one of those.
>
> Once I figure out which previous test it was, I can start removing the 
> individual tests to finally get to the code causing the problem. Usually, 
> it's a case that a test changed something and I just have to add in the 
> teardown function to restore the state of whatever was changed.
>
> On Thu, 2016-06-02 at 21:33 +0200, Derek wrote:
>
> I have a test that is failing when the file it is in is run as part of all 
> the other test files by the test runner.
>
> If I just run only the file that contains this test -  then it passes.
>
> (pass/fail refers to the very last assert in the code below.)
>
> I'd appreciate any ideas or insights from anyone who can spot an obvious 
> mistake - or suggest some options to explore.
>
> Thanks
> Derek
>
>
> # THIS IS AN EXTRACT OF RELEVANT CODE (not all of it...)
> from django.contrib.messages.storage.fallback import FallbackStorage
> from django.core.urlresolvers import reverse
> from django.test import TestCase, Client
> # ... various app-related imports ...
>
>
> class MockRequest(object):
> """No code needed."""
> pass
>
>
> REQUEST = MockRequest()
> # see: https://stackoverflow.com/queI stions/11938164/why-dont-my-django-\
> #  unittests-know-that-messagemiddleware-is-installed
> setattr(REQUEST, 'session', 'session')
> MESSAGES = FallbackStorage(REQUEST)
> setattr(REQUEST, '_messages', MESSAGES)
> setup_test_environment()
>
>
> class PersonAdminTest(TestCase):
>
> def setUp(self):
> self.user, password = utils.user_factory(model=None)
> self.client = Client()
> login_status = self.client.login(username=self.user.email, 
> password=password)
> self.assertEqual(login_status, True)
>
> def test_action_persons_make_unreal(self):
> try:
> change_url = reverse('admin:persons_realpersons_changelist')
> except NoReverseMatch:
> change_url = '/admin/persons/realpersons/'
> sys.stderr.write('\n   WARNING: Unable to reverse URL! ... ')
> response = self.client.get(change_url)
> self.assertEqual(response.status_code, 200)
>
> -- 
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAF1Wu3MoGgm_dSToObDX9gH7GQJ%3DTZzGLV7RPOiZk4kvV-_Nbg%40mail.gmail.com
>  
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
> -- 
> Adam (ad...@csh.rit.edu )
>
>
>

-- 
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/fee4ed8a-ff68-41ce-965a-500e5d8aa694%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Expiration date option

2016-06-08 Thread James Schneider
>
> Many thanks for your answer which makes perfect sense and yes, this is
only required for a single view.
> The expiry_date is needed as items are listed by expiry date. So would
you suggest removing the has_expired and writing the filter against the
expiry date?
>

Yes, I meant that you should keep the expiry_date field, but eliminate the
has_expired field. I had a minor typo above that made it sound like you
should eliminate both fields, which is not the case.

BTW, I would also suggest changing expiry_date to expiry_datetime and store
a full date/time object in it (if you aren't already) to remove ambiguity
down the road. You don't want to have to remember that the expiry happens
at 00:00 or 07:42 or whether or not the date is inclusive or exclusive on
the last day, etc. Using a single point in time makes life grand for you
and anyone working on your code who isn't you. All datetimes should be
timezone aware and stored in UTC if possible.

Regarding writing the filter against expiry_datetime instead of
has_expired, the answer is yes, I would suggest doing so. The query is
probably marginally more expensive, but code cleanliness and maintenance
overhead make it worth it in most cases.

I would add an asterisk to my answer though:

*only if an object should be considered in an "expired" state if the
current (or given) date/time is greater than the expiry_datetime. If the
expiry_datetime is in the future, consider the object "not expired".

Actually my entire answer is predicated on the * statement above being
accurate as my assumption.

You will likely end up writing a custom model manager method down the road,
especially if you commonly filter against other fields like "is_disabled"
where you would need only objects that are not expired and are active/not
disabled.

-James

-- 
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/CA%2Be%2BciVdqmrjPsnc1U2rkerTRC-1HrSPWE%3D9Q%2Bx%3DDOE4P6BEzQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Non Ascii character in upload file crash in python 3

2016-06-08 Thread Luis Zárate
I am using supervisor and gunicorn for production run as fondomutual user.

$ env | grep LANG
LANG=es_CR.UTF-8
LANGUAGE=es_CR:es


2016-06-08 2:09 GMT-06:00 Luis Zárate :

> After obj.save().
>
> File 
> "/home/fondomutual/entornos/fomeucr/lib/python3.4/site-packages/django/db/models/base.py"
>  in save_base
>   736. updated = self._save_table(raw, cls, force_insert, 
> force_update, using, update_fields)
>
> File 
> "/home/fondomutual/entornos/fomeucr/lib/python3.4/site-packages/django/db/models/base.py"
>  in _save_table
>   798.   for f in non_pks]
>
> File 
> "/home/fondomutual/entornos/fomeucr/lib/python3.4/site-packages/django/db/models/base.py"
>  in 
>   798.   for f in non_pks]
>
> File 
> "/home/fondomutual/entornos/fomeucr/lib/python3.4/site-packages/django/db/models/fields/files.py"
>  in pre_save
>   311. file.save(file.name, file, save=False)
>
> File 
> "/home/fondomutual/entornos/fomeucr/lib/python3.4/site-packages/django/db/models/fields/files.py"
>  in save
>   93. self.name = self.storage.save(name, content, 
> max_length=self.field.max_length)
>
> File 
> "/home/fondomutual/entornos/fomeucr/lib/python3.4/site-packages/django/core/files/storage.py"
>  in save
>   53. name = self.get_available_name(name, max_length=max_length)
>
> File 
> "/home/fondomutual/entornos/fomeucr/lib/python3.4/site-packages/django/core/files/storage.py"
>  in get_available_name
>   89. while self.exists(name) or (max_length and len(name) > 
> max_length):
>
> File 
> "/home/fondomutual/entornos/fomeucr/lib/python3.4/site-packages/django/core/files/storage.py"
>  in exists
>   294. return os.path.exists(self.path(name))
>
> File "/home/fondomutual/entornos/fomeucr/lib/python3.4/genericpath.py" in 
> exists
>   19. os.stat(path)
>
> Exception Type: UnicodeEncodeError at /vistapublica/perfil/editar
> Exception Value: 'ascii' codec can't encode character '\xd1' in position 74: 
> ordinal not in range(128)
> Request information:
> GET: No GET data
>
>
>
> 2016-06-08 2:06 GMT-06:00 Stephen J. Butler :
>
>> Whats the stack trace?
>>
>> On Wed, Jun 8, 2016 at 3:01 AM, Luis Zárate  wrote:
>>
>>> $ python manage.py shell
>>>
>>> >>> import sys
>>> >>> sys.getfilesystemencoding()
>>> 'utf-8'
>>>
>>>
>>>
>>> 2016-06-08 1:57 GMT-06:00 Stephen J. Butler :
>>>
 Have you tried this?

 https://docs.djangoproject.com/en/1.9/ref/unicode/#files

 You probably have a system setup where ASCII is the filesystem
 encoding. It tells you a way to fix that on Linux/Unix.

 On Wed, Jun 8, 2016 at 2:44 AM, Luis Zárate  wrote:

> Hi,
>
> I am having this issue in server production, I developed with python 3 
> and with others fields work great but when file is involved I don't know 
> how to intermediate and remove non ascii characters.
>
> Part of my stack trace is:
>
> Internal Server Error: /vistapublica/perfil/editar
>
> UnicodeEncodeError at /vistapublica/perfil/editar
> 'ascii' codec can't encode character '\xd1' in position 74: ordinal not 
> in range(128)
>
> FILES:
> foto = 
>
> So, how can I fix this issue?.
>
>
>
> --
> "La utopía sirve para caminar" Fernando Birri
>
>
> --
> 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/CAG%2B5VyPwsBhF_YSp-Htg_P24x9R2L0nzGgb9bOxsLBRmOr%2BP6w%40mail.gmail.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 https://groups.google.com/group/django-users.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/CAD4ANxUNNePQXj16Z_dOAgpueSobT%2BP0SJSN09J%2B8B3D7qUGrg%40mail.gmail.com
 

Re: Non Ascii character in upload file crash in python 3

2016-06-08 Thread Luis Zárate
After obj.save().

File 
"/home/fondomutual/entornos/fomeucr/lib/python3.4/site-packages/django/db/models/base.py"
in save_base
  736. updated = self._save_table(raw, cls, force_insert,
force_update, using, update_fields)

File 
"/home/fondomutual/entornos/fomeucr/lib/python3.4/site-packages/django/db/models/base.py"
in _save_table
  798.   for f in non_pks]

File 
"/home/fondomutual/entornos/fomeucr/lib/python3.4/site-packages/django/db/models/base.py"
in 
  798.   for f in non_pks]

File 
"/home/fondomutual/entornos/fomeucr/lib/python3.4/site-packages/django/db/models/fields/files.py"
in pre_save
  311. file.save(file.name, file, save=False)

File 
"/home/fondomutual/entornos/fomeucr/lib/python3.4/site-packages/django/db/models/fields/files.py"
in save
  93. self.name = self.storage.save(name, content,
max_length=self.field.max_length)

File 
"/home/fondomutual/entornos/fomeucr/lib/python3.4/site-packages/django/core/files/storage.py"
in save
  53. name = self.get_available_name(name, max_length=max_length)

File 
"/home/fondomutual/entornos/fomeucr/lib/python3.4/site-packages/django/core/files/storage.py"
in get_available_name
  89. while self.exists(name) or (max_length and len(name) >
max_length):

File 
"/home/fondomutual/entornos/fomeucr/lib/python3.4/site-packages/django/core/files/storage.py"
in exists
  294. return os.path.exists(self.path(name))

File "/home/fondomutual/entornos/fomeucr/lib/python3.4/genericpath.py" in exists
  19. os.stat(path)

Exception Type: UnicodeEncodeError at /vistapublica/perfil/editar
Exception Value: 'ascii' codec can't encode character '\xd1' in
position 74: ordinal not in range(128)
Request information:
GET: No GET data



2016-06-08 2:06 GMT-06:00 Stephen J. Butler :

> Whats the stack trace?
>
> On Wed, Jun 8, 2016 at 3:01 AM, Luis Zárate  wrote:
>
>> $ python manage.py shell
>>
>> >>> import sys
>> >>> sys.getfilesystemencoding()
>> 'utf-8'
>>
>>
>>
>> 2016-06-08 1:57 GMT-06:00 Stephen J. Butler :
>>
>>> Have you tried this?
>>>
>>> https://docs.djangoproject.com/en/1.9/ref/unicode/#files
>>>
>>> You probably have a system setup where ASCII is the filesystem encoding.
>>> It tells you a way to fix that on Linux/Unix.
>>>
>>> On Wed, Jun 8, 2016 at 2:44 AM, Luis Zárate  wrote:
>>>
 Hi,

 I am having this issue in server production, I developed with python 3 and 
 with others fields work great but when file is involved I don't know how 
 to intermediate and remove non ascii characters.

 Part of my stack trace is:

 Internal Server Error: /vistapublica/perfil/editar

 UnicodeEncodeError at /vistapublica/perfil/editar
 'ascii' codec can't encode character '\xd1' in position 74: ordinal not in 
 range(128)

 FILES:
 foto = 

 So, how can I fix this issue?.



 --
 "La utopía sirve para caminar" Fernando Birri


 --
 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/CAG%2B5VyPwsBhF_YSp-Htg_P24x9R2L0nzGgb9bOxsLBRmOr%2BP6w%40mail.gmail.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 https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAD4ANxUNNePQXj16Z_dOAgpueSobT%2BP0SJSN09J%2B8B3D7qUGrg%40mail.gmail.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> "La utopía sirve para caminar" Fernando Birri
>>
>>
>> --
>> 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 

Re: Non Ascii character in upload file crash in python 3

2016-06-08 Thread Luis Zárate
I am in Debian,

in /etc/locale.gen
es_CR.UTF-8 UTF-8

 $ locale -a
C
C.UTF-8
es_CR.utf8
POSIX


2016-06-08 2:01 GMT-06:00 Luis Zárate :

> $ python manage.py shell
>
> >>> import sys
> >>> sys.getfilesystemencoding()
> 'utf-8'
>
>
>
> 2016-06-08 1:57 GMT-06:00 Stephen J. Butler :
>
>> Have you tried this?
>>
>> https://docs.djangoproject.com/en/1.9/ref/unicode/#files
>>
>> You probably have a system setup where ASCII is the filesystem encoding.
>> It tells you a way to fix that on Linux/Unix.
>>
>> On Wed, Jun 8, 2016 at 2:44 AM, Luis Zárate  wrote:
>>
>>> Hi,
>>>
>>> I am having this issue in server production, I developed with python 3 and 
>>> with others fields work great but when file is involved I don't know how to 
>>> intermediate and remove non ascii characters.
>>>
>>> Part of my stack trace is:
>>>
>>> Internal Server Error: /vistapublica/perfil/editar
>>>
>>> UnicodeEncodeError at /vistapublica/perfil/editar
>>> 'ascii' codec can't encode character '\xd1' in position 74: ordinal not in 
>>> range(128)
>>>
>>> FILES:
>>> foto = 
>>>
>>> So, how can I fix this issue?.
>>>
>>>
>>>
>>> --
>>> "La utopía sirve para caminar" Fernando Birri
>>>
>>>
>>> --
>>> 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/CAG%2B5VyPwsBhF_YSp-Htg_P24x9R2L0nzGgb9bOxsLBRmOr%2BP6w%40mail.gmail.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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAD4ANxUNNePQXj16Z_dOAgpueSobT%2BP0SJSN09J%2B8B3D7qUGrg%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> "La utopía sirve para caminar" Fernando Birri
>
>
>


-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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/CAG%2B5VyNXDR-BkQLYKBdptD4CePNyO1%3DqP5Qh6xW6FSh_5sp98A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Non Ascii character in upload file crash in python 3

2016-06-08 Thread Stephen J. Butler
Whats the stack trace?

On Wed, Jun 8, 2016 at 3:01 AM, Luis Zárate  wrote:

> $ python manage.py shell
>
> >>> import sys
> >>> sys.getfilesystemencoding()
> 'utf-8'
>
>
>
> 2016-06-08 1:57 GMT-06:00 Stephen J. Butler :
>
>> Have you tried this?
>>
>> https://docs.djangoproject.com/en/1.9/ref/unicode/#files
>>
>> You probably have a system setup where ASCII is the filesystem encoding.
>> It tells you a way to fix that on Linux/Unix.
>>
>> On Wed, Jun 8, 2016 at 2:44 AM, Luis Zárate  wrote:
>>
>>> Hi,
>>>
>>> I am having this issue in server production, I developed with python 3 and 
>>> with others fields work great but when file is involved I don't know how to 
>>> intermediate and remove non ascii characters.
>>>
>>> Part of my stack trace is:
>>>
>>> Internal Server Error: /vistapublica/perfil/editar
>>>
>>> UnicodeEncodeError at /vistapublica/perfil/editar
>>> 'ascii' codec can't encode character '\xd1' in position 74: ordinal not in 
>>> range(128)
>>>
>>> FILES:
>>> foto = 
>>>
>>> So, how can I fix this issue?.
>>>
>>>
>>>
>>> --
>>> "La utopía sirve para caminar" Fernando Birri
>>>
>>>
>>> --
>>> 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/CAG%2B5VyPwsBhF_YSp-Htg_P24x9R2L0nzGgb9bOxsLBRmOr%2BP6w%40mail.gmail.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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAD4ANxUNNePQXj16Z_dOAgpueSobT%2BP0SJSN09J%2B8B3D7qUGrg%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> "La utopía sirve para caminar" Fernando Birri
>
>
> --
> 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/CAG%2B5VyO_utrotMx%2B6mHs3r3ttA09Vinkd4o0yi1168gTxYHGMw%40mail.gmail.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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAD4ANxU_5J7q5TSdzivvCEuMsmR_YJz%3Dk6nDUm5qpQ%3DRnEJWvQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Non Ascii character in upload file crash in python 3

2016-06-08 Thread Luis Zárate
$ python manage.py shell

>>> import sys
>>> sys.getfilesystemencoding()
'utf-8'



2016-06-08 1:57 GMT-06:00 Stephen J. Butler :

> Have you tried this?
>
> https://docs.djangoproject.com/en/1.9/ref/unicode/#files
>
> You probably have a system setup where ASCII is the filesystem encoding.
> It tells you a way to fix that on Linux/Unix.
>
> On Wed, Jun 8, 2016 at 2:44 AM, Luis Zárate  wrote:
>
>> Hi,
>>
>> I am having this issue in server production, I developed with python 3 and 
>> with others fields work great but when file is involved I don't know how to 
>> intermediate and remove non ascii characters.
>>
>> Part of my stack trace is:
>>
>> Internal Server Error: /vistapublica/perfil/editar
>>
>> UnicodeEncodeError at /vistapublica/perfil/editar
>> 'ascii' codec can't encode character '\xd1' in position 74: ordinal not in 
>> range(128)
>>
>> FILES:
>> foto = 
>>
>> So, how can I fix this issue?.
>>
>>
>>
>> --
>> "La utopía sirve para caminar" Fernando Birri
>>
>>
>> --
>> 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/CAG%2B5VyPwsBhF_YSp-Htg_P24x9R2L0nzGgb9bOxsLBRmOr%2BP6w%40mail.gmail.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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAD4ANxUNNePQXj16Z_dOAgpueSobT%2BP0SJSN09J%2B8B3D7qUGrg%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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/CAG%2B5VyO_utrotMx%2B6mHs3r3ttA09Vinkd4o0yi1168gTxYHGMw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Non Ascii character in upload file crash in python 3

2016-06-08 Thread Stephen J. Butler
Have you tried this?

https://docs.djangoproject.com/en/1.9/ref/unicode/#files

You probably have a system setup where ASCII is the filesystem encoding. It
tells you a way to fix that on Linux/Unix.

On Wed, Jun 8, 2016 at 2:44 AM, Luis Zárate  wrote:

> Hi,
>
> I am having this issue in server production, I developed with python 3 and 
> with others fields work great but when file is involved I don't know how to 
> intermediate and remove non ascii characters.
>
> Part of my stack trace is:
>
> Internal Server Error: /vistapublica/perfil/editar
>
> UnicodeEncodeError at /vistapublica/perfil/editar
> 'ascii' codec can't encode character '\xd1' in position 74: ordinal not in 
> range(128)
>
> FILES:
> foto = 
>
> So, how can I fix this issue?.
>
>
>
> --
> "La utopía sirve para caminar" Fernando Birri
>
>
> --
> 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/CAG%2B5VyPwsBhF_YSp-Htg_P24x9R2L0nzGgb9bOxsLBRmOr%2BP6w%40mail.gmail.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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAD4ANxUNNePQXj16Z_dOAgpueSobT%2BP0SJSN09J%2B8B3D7qUGrg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Non Ascii character in upload file crash in python 3

2016-06-08 Thread Luis Zárate
Hi,

I am having this issue in server production, I developed with python 3
and with others fields work great but when file is involved I don't
know how to intermediate and remove non ascii characters.

Part of my stack trace is:

Internal Server Error: /vistapublica/perfil/editar

UnicodeEncodeError at /vistapublica/perfil/editar
'ascii' codec can't encode character '\xd1' in position 74: ordinal
not in range(128)

FILES:
foto = 

So, how can I fix this issue?.



-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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/CAG%2B5VyPwsBhF_YSp-Htg_P24x9R2L0nzGgb9bOxsLBRmOr%2BP6w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Expiration date option

2016-06-08 Thread 'David Turner' via Django users
Hi

Many thanks for your answer which makes perfect sense and yes, this is only
required for a single view.
The expiry_date is needed as items are listed by expiry date. So would you
suggest removing the has_expired and writing the filter against the expiry
date?

Thanks


On 7 June 2016 at 23:35, James Schneider  wrote:

>
> On Jun 7, 2016 1:35 PM, "'David Turner' via Django users" <
> django-users@googlegroups.com> wrote:
> >
> > Being new to Django I have a problem which I am not able to resolve.
> >
> > I have a model which has the following fields:
> > expiry_date = models.DateField(null=True, blank=True,)
> > has_expired = models.BooleanField(verbose_name='Has Expired',
> >default=True,
> )
> >
> > I need to keep expired items in the database for reporting purposes.
> >
> > My question is how do I  show only the non-expired items in my views.?
> >
> > Would the solution be via a model manager?
> >
> >
>
> Probably, yes.
>
> If you only need to filter out expired items in a single view, you may
> just want to override/append the query set used in that single view with
> filter(has_expired=False).
>
> If you plan on needing this query filtering in multiple locations, then
> you'll want to create a custom model manager method that includes the
> desired filter.
>
> On a side note, you may not need the has_expired fields at all if your
> business logic dictates that any instance with an expiry_date that has
> already passed should be considered expired. It would mitigate the need for
> the extra logic to keep the has_expired field in sync with the expiry_date.
> Otherwise you may end up with objects with an expiry_date in the future but
> showing expired, and vice versa. I try to avoid those types of field
> dependencies, and DB normalization purists will likely complain about it.
>
> -James
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/aSj3jGX2CLk/unsubscribe.
> To unsubscribe from this group and all its topics, 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/CA%2Be%2BciVY43_D-9YF9PK_intnsEkd%2BRDJoSVr6h-O79%2BzP%2B3Gcg%40mail.gmail.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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALwQ%2B-swvJ7-Crs7%3DZLpJF5YcQ%2BgHAfpL4KQT9EVNkcZ%3D-nEBQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


User object and session object usage.

2016-06-08 Thread learn django
Hi,

Am trying to write a customized authentication model.
In authenticate function I do the following.

def authenticate(self, username=None, password=None):
try:
# Check if this user is valid on the mail server
s.auth = HttpNtlmAuth(username, password, s)
except:
return None

try:
# Check if the user exists in Django's local database
user = User.objects.get(email=username)
except User.DoesNotExist:
# Create a user in Django's local database
user = User.objects.create_user(time.time(), username, 
'passworddoesntmatter')

return user


When does this user object get deleted eventually ?

Once the user is authenticated am going to associate it with session.
Will this authenticate function get called again and again if multiple 
requests are made in the same session ?

I want to take the logoff functionality out of the client so i will be 
setting expiry in the session.
When the session expires i.e expiry time is 0 or less, i will again 
authenticate the user and reset expiry time.
That way session remains intact. Is there a better approach to this ?

When clearsession is called session object will get deleted from DB, will 
it also trigger deletion of User object ? 

-- 
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/af631185-ab5e-4dda-bacb-89fdcb2dd88e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.