Monday, November 30, 2015

Re: Clear view cache using @cache_page

I don't know of a simple way. Here's something I wrote to achieve that on djangoproject.com (invalidating a cached blog post on save):

https://github.com/django/djangoproject.com/blob/90e92fd18543f95685c24f84dc5e1269a5acc38a/blog/models.py#L105-L116

Adding something to Django to help with this seems useful.

On Monday, November 30, 2015 at 12:43:29 PM UTC-5, Dimitris R wrote:
Hello, 

I am using Django 1.8.2 and caching my views using the @cache_page decorator:

@cache_page(60 * 5)
def view_name(request, obj_id):
  [...]

Is there a way to clear the cached entry programmatically, prior of the cache timeout?

Thanks, 
Dimitris

--
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+unsubscribe@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/8a74117b-0905-4660-bd73-3e47d9c833ae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: RemoteUserMiddleware stay logged in

Does the PersistentRemoteUserMiddleware added in Django 1.9 help?

https://docs.djangoproject.com/en/1.9/howto/auth-remote-user/#using-remote-user-on-login-pages-only

On Monday, November 30, 2015 at 3:36:00 PM UTC-5, Dan Davis wrote:
So, where I work we have a CAS server we like to use.   We like to use it with mod_auth_cas.    So far, so good - RemoteUserMiddleware is my friend.   The problem here is that REMOTE_USER will not be set unless the URI is protected by CAS, and if the URI is protected by CAS, then the user will be redirected right away.    This is fine for admin URLs, but I want the CAS cookie to be validated/checked only on some URLs, without redirect.    So, REMOTE_USER should be set only if the cookie is present and valid.

Does anyone have any suggestions, either how I should change mod_auth_cas or my Apache directives to support this, or how I should change my use of RemoteUserMiddleware to allow this.

Thanks,

-Dan

--
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+unsubscribe@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/ca120cbe-748a-4a3f-b351-474989311435%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

RemoteUserMiddleware stay logged in

So, where I work we have a CAS server we like to use.   We like to use it with mod_auth_cas.    So far, so good - RemoteUserMiddleware is my friend.   The problem here is that REMOTE_USER will not be set unless the URI is protected by CAS, and if the URI is protected by CAS, then the user will be redirected right away.    This is fine for admin URLs, but I want the CAS cookie to be validated/checked only on some URLs, without redirect.    So, REMOTE_USER should be set only if the cookie is present and valid.

Does anyone have any suggestions, either how I should change mod_auth_cas or my Apache directives to support this, or how I should change my use of RemoteUserMiddleware to allow this.

Thanks,

-Dan

--
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+unsubscribe@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/f39f3b30-c418-4491-bd5d-2e4105544b9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Clear view cache using @cache_page

Hello, 

I am using Django 1.8.2 and caching my views using the @cache_page decorator:

@cache_page(60 * 5)
def view_name(request, obj_id):
  [...]

Is there a way to clear the cached entry programmatically, prior of the cache timeout?

Thanks, 
Dimitris

--
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+unsubscribe@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/03ede9ef-e35e-4a34-8cb7-5ce0416430df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Timezone import error

Hi kbnk, monoBOT,

Thank you both, your answers on the spot, I have tried using the filter and it's working, I may need to delete one of the records to get this sorted, thanks again.

>>> Question.objects.filter(pub_date__year=current_year)
[<Question: What's up?>, <Question: What's up?>]

Best regards,
Ahmed Abdullah

On Sunday, 29 November 2015 19:38:41 UTC+3, monoBOT monoBOT wrote:
Hello Ahmed

you are using the get method, get can only return 1 item and its returning more than 1 in your case 2, thats the second error, but there is an import error also somewhere in your code, but the traceback you are sending is not concluyent.

2015-11-29 15:11 GMT+00:00 <ahmed.ab...@gmail.com>:
Hi,

I'm practicing Django v 1.8.6 (Writing your first Django app, part 1) and getting error when trying to import timezone, also I have installed pytz, when I try to use the import timezone package I'm getting ImportError. 

My settings.py has USE_TZ set to true by default, also, I had to change the TIME_ZONE from UTC to Asia/Bahrain but still I'm getting the below error, kindly if anyone have advice on the below error?

>>> from polls.models import Question, Choice
>>> Question.objects.all()
[<Question: What's up?>, <Question: What's up?>]
>>> Question.objects.filter(id=1)
[<Question: What's up?>]
>>> Question.objects.filter(id=2)
[<Question: What's up?>]
>>> Question.objects.filter(id=3)
[]
>>> Question.objects.filter(question_text__startswith='What')
[<Question: What's up?>, <Question: What's up?>]
>>> from django.utils import timezone
>>> current_year = timezone.now().year
>>> Question.objects.get(pub_date__year=current_year)
Traceback (most recent call last):
  File "C:\Users\abdullaha\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\management\commands\shell.py", line 69, in h
andle
    self.run_shell(shell=options['interface'])
  File "C:\Users\abdullaha\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\management\commands\shell.py", line 61, in r
un_shell
    raise ImportError
ImportError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Users\abdullaha\AppData\Local\Programs\Python\Python35\lib\site-packages\django\db\models\manager.py", line 127, in manager_metho
d
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "C:\Users\abdullaha\AppData\Local\Programs\Python\Python35\lib\site-packages\django\db\models\query.py", line 338, in get
    (self.model._meta.object_name, num)
polls.models.MultipleObjectsReturned: get() returned more than one Question -- it returned 2!
>>>

Best regards,
Ahmed Abdullah

--
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/f6953f2e-f9a6-46c7-aec8-f337b772fc9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
monoBOT
Visite mi sitio(Visit my site): monobotsoft.es/blog/

--
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+unsubscribe@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/cccb90ea-cdf7-4a51-9cf0-ca9add0b4f4b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sunday, November 29, 2015

Re: Django rest framework - error 'TokenAuthentication' object has no attribute 'has_permission

My bad. This was due to the permissions I had set on my class based view.

I took out the tokenauthentication and it now works well.

- 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+unsubscribe@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/9bf006ca-9aef-47de-a7a6-8a26e4899c9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Correct way to do async forms





--
"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+unsubscribe@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/CAG%2B5VyMQZ1YCDxKy4GnX8KT6FJ04-HPQZeKCWxJW%3D_FujcUR7g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Can you remove a model's last field of SQLite3 in Django 1.8?

No, you can't because of two things:

1. SQLite doesn't allow an 'ALTER TABLE ... DROP COLUMN ...'

We get away with that by creating a new table and copying the data
over: https://www.sqlite.org/lang_altertable.html

2. SQLite doesn't allow a 'CREATE TABLE' statement without any columns:
https://www.sqlite.org/lang_createtable.html

/Markus

On Sun, Nov 29, 2015 at 09:17:53AM -0800, KwangYoun Jung wrote:
>Can you remove a model's last field of SQLite3 in Django 1.8?
>
>I have a model that has only one column in SQLite3.
>When I remove a last field of the model, I get an error like below
>
>
>
>*django.db.utils.OperationalError: near ")": syntax error*Anyone knows
>about this issue ?
>
>--
>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+unsubscribe@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/951e9cbd-2540-43eb-a951-6a3722f3ee3d%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+unsubscribe@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/20151129202807.GA10673%40pyler.local.
For more options, visit https://groups.google.com/d/optout.

Re: Correct way to do async forms

I like to borrow rails-ujs library which enables very easy async links, forms and much more with just few HTML attributes (<a data-remote="true" > and similar. ). You can just bind on the "ajax:success" event on your form/link to react on the response.

--
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+unsubscribe@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/4d29cca9-b9ab-42b7-82dd-fdff12ce9a54%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Can you remove a model's last field of SQLite3 in Django 1.8?

On Sunday, 29 November 2015 17:17:54 UTC, KwangYoun Jung wrote:
Can you remove a model's last field of SQLite3 in Django 1.8?

I have a model that has only one column in SQLite3.
When I remove a last field of the model, I get an error like below

django.db.utils.OperationalError: near ")": syntax error

Anyone knows about this issue ?

No, nobody knows anything about this issue because you didn't give any details. What does "remove a last field" mean? When are you getting that error? What code did you run?
--
DR. 

--
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+unsubscribe@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/2b4881ad-e68f-4279-9ab5-990e443b0a31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Can you remove a model's last field of SQLite3 in Django 1.8?

Can you remove a model's last field of SQLite3 in Django 1.8?

I have a model that has only one column in SQLite3.
When I remove a last field of the model, I get an error like below

django.db.utils.OperationalError: near ")": syntax error

Anyone knows about this issue ?

--
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+unsubscribe@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/951e9cbd-2540-43eb-a951-6a3722f3ee3d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Timezone import error

Hello Ahmed

you are using the get method, get can only return 1 item and its returning more than 1 in your case 2, thats the second error, but there is an import error also somewhere in your code, but the traceback you are sending is not concluyent.

2015-11-29 15:11 GMT+00:00 <ahmed.abdullah.bh@gmail.com>:
Hi,

I'm practicing Django v 1.8.6 (Writing your first Django app, part 1) and getting error when trying to import timezone, also I have installed pytz, when I try to use the import timezone package I'm getting ImportError. 

My settings.py has USE_TZ set to true by default, also, I had to change the TIME_ZONE from UTC to Asia/Bahrain but still I'm getting the below error, kindly if anyone have advice on the below error?

>>> from polls.models import Question, Choice
>>> Question.objects.all()
[<Question: What's up?>, <Question: What's up?>]
>>> Question.objects.filter(id=1)
[<Question: What's up?>]
>>> Question.objects.filter(id=2)
[<Question: What's up?>]
>>> Question.objects.filter(id=3)
[]
>>> Question.objects.filter(question_text__startswith='What')
[<Question: What's up?>, <Question: What's up?>]
>>> from django.utils import timezone
>>> current_year = timezone.now().year
>>> Question.objects.get(pub_date__year=current_year)
Traceback (most recent call last):
  File "C:\Users\abdullaha\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\management\commands\shell.py", line 69, in h
andle
    self.run_shell(shell=options['interface'])
  File "C:\Users\abdullaha\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\management\commands\shell.py", line 61, in r
un_shell
    raise ImportError
ImportError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Users\abdullaha\AppData\Local\Programs\Python\Python35\lib\site-packages\django\db\models\manager.py", line 127, in manager_metho
d
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "C:\Users\abdullaha\AppData\Local\Programs\Python\Python35\lib\site-packages\django\db\models\query.py", line 338, in get
    (self.model._meta.object_name, num)
polls.models.MultipleObjectsReturned: get() returned more than one Question -- it returned 2!
>>>

Best regards,
Ahmed Abdullah

--
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+unsubscribe@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/f6953f2e-f9a6-46c7-aec8-f337b772fc9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
monoBOT
Visite mi sitio(Visit my site): monobotsoft.es/blog/

--
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+unsubscribe@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%2BxOsGCjDSJ_PDv8_gi8etYeFv6MxjgjCM-zJp4FkQ458YOwAA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Timezone import error

Hi Ahmed,

When an error happens in an expect: block, python 3 shows the original error caught by the try/expect block, as well as the new error. In this case, the ImportError is the original error, and it's nothing you should worry about: Django catches it and handles it accordingly. Admittedly, the error is slightly confusing. The ImportError has nothing to do with timezones or pytz. 

The real error is the second one, the MultipleObjectsReturned exception. Question.objects.get() expects that exactly one object is returned by the database. If there are no objects returned, or more than one is returned, it will raise an expection. If you want to get all objects published in the current year, you can use Question.objects.filter(put_date__year=current_year) instead.

Marten

On Sunday, November 29, 2015 at 4:17:29 PM UTC+1, ahmed.ab...@gmail.com wrote:
Hi,

I'm practicing Django v 1.8.6 (Writing your first Django app, part 1) and getting error when trying to import timezone, also I have installed pytz, when I try to use the import timezone package I'm getting ImportError. 

My settings.py has USE_TZ set to true by default, also, I had to change the TIME_ZONE from UTC to Asia/Bahrain but still I'm getting the below error, kindly if anyone have advice on the below error?

>>> from polls.models import Question, Choice
>>> Question.objects.all()
[<Question: What's up?>, <Question: What's up?>]
>>> Question.objects.filter(id=1)
[<Question: What's up?>]
>>> Question.objects.filter(id=2)
[<Question: What's up?>]
>>> Question.objects.filter(id=3)
[]
>>> Question.objects.filter(question_text__startswith='What')
[<Question: What's up?>, <Question: What's up?>]
>>> from django.utils import timezone
>>> current_year = timezone.now().year
>>> Question.objects.get(pub_date__year=current_year)
Traceback (most recent call last):
  File "C:\Users\abdullaha\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\management\commands\shell.py", line 69, in h
andle
    self.run_shell(shell=options['interface'])
  File "C:\Users\abdullaha\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\management\commands\shell.py", line 61, in r
un_shell
    raise ImportError
ImportError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Users\abdullaha\AppData\Local\Programs\Python\Python35\lib\site-packages\django\db\models\manager.py", line 127, in manager_metho
d
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "C:\Users\abdullaha\AppData\Local\Programs\Python\Python35\lib\site-packages\django\db\models\query.py", line 338, in get
    (self.model._meta.object_name, num)
polls.models.MultipleObjectsReturned: get() returned more than one Question -- it returned 2!
>>>

Best regards,
Ahmed Abdullah

--
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+unsubscribe@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/58d4cbd4-0cd4-46a1-b978-79d2544b7215%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Timezone import error

Hi,

I'm practicing Django v 1.8.6 (Writing your first Django app, part 1) and getting error when trying to import timezone, also I have installed pytz, when I try to use the import timezone package I'm getting ImportError. 

My settings.py has USE_TZ set to true by default, also, I had to change the TIME_ZONE from UTC to Asia/Bahrain but still I'm getting the below error, kindly if anyone have advice on the below error?

>>> from polls.models import Question, Choice
>>> Question.objects.all()
[<Question: What's up?>, <Question: What's up?>]
>>> Question.objects.filter(id=1)
[<Question: What's up?>]
>>> Question.objects.filter(id=2)
[<Question: What's up?>]
>>> Question.objects.filter(id=3)
[]
>>> Question.objects.filter(question_text__startswith='What')
[<Question: What's up?>, <Question: What's up?>]
>>> from django.utils import timezone
>>> current_year = timezone.now().year
>>> Question.objects.get(pub_date__year=current_year)
Traceback (most recent call last):
  File "C:\Users\abdullaha\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\management\commands\shell.py", line 69, in h
andle
    self.run_shell(shell=options['interface'])
  File "C:\Users\abdullaha\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\management\commands\shell.py", line 61, in r
un_shell
    raise ImportError
ImportError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Users\abdullaha\AppData\Local\Programs\Python\Python35\lib\site-packages\django\db\models\manager.py", line 127, in manager_metho
d
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "C:\Users\abdullaha\AppData\Local\Programs\Python\Python35\lib\site-packages\django\db\models\query.py", line 338, in get
    (self.model._meta.object_name, num)
polls.models.MultipleObjectsReturned: get() returned more than one Question -- it returned 2!
>>>

Best regards,
Ahmed Abdullah

--
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+unsubscribe@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/f6953f2e-f9a6-46c7-aec8-f337b772fc9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Saturday, November 28, 2015

Django rest framework - error 'TokenAuthentication' object has no attribute 'has_permission



Hello,

I am trying to use oauth2 provider as described in http://django-oauth-toolkit.readthedocs.org/en/latest/rest-framework/getting_started.html#step-1-minimal-setup

'TokenAuthentication' object has no attribute 'has_permission.

Curl - curl -H "Authorization: Bearer $access_token" -H "Content-Type: application/json" -d '{"address": "afdsgsgsd", "another_address": "afedtgertretre"}'  -X POST http://localhost:8000/test

Here is my settings.py:


MIDDLEWARE_CLASSES = (
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'oauth2_provider.middleware.OAuth2TokenMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.security.SecurityMiddleware',
)

REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'oauth2_provider.ext.rest_framework.OAuth2Authentication',
),
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',

)
}

and my urls.py

url(r'^test', Test.as_view() , name='Test'),

Error I am getting:

Request Method:POST
Request URL:http://localhost:8000/test
Django Version:1.8.6
Exception Type:AttributeError
Exception Value:
'TokenAuthentication' object has no attribute 'has_permission'
Exception Location:/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/rest_framework/views.py in check_permissions, line 318
Python Executable:/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4
Python Version:3.4.3
Python Path:
['/Users/ctippur/PycharmProjects/dropboat',   '/Users/ctippur/PycharmProjects/dropboat',   '/Library/Frameworks/Python.framework/Versions/3.4/lib/python34.zip',   '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4',   '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/plat-darwin',   '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/lib-dynload',   '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages']


--
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+unsubscribe@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/d9e99fa9-c895-4fec-94f3-f67789d81e88%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Unresolved references error in Pycharm Community edition

Agreed, but it is very good to use virualenv, a requirements file and then set the PyCharm project interpreter to your virtualenv one, then PyCharm picks up all the imports and can alert you if you're importing something wrongly or if you want to view the declaration of a function. I also really like django cookiecutter. https://github.com/pydanny/cookiecutter-django

Dan



On 28 November 2015 at 11:33, aftnix <aftnix@gmail.com> wrote:
On শুক্রবার 27 নভে 2015 03:04 অপরাহ্ণ, Sneha R wrote:
Hi,

I am new to Pycharm and I am trying to run a Django project in Pycharm
Community edition 5.0.1 but there are few import errors saying
''Unresolved reference'" . I am using Python 2.7. How do I solve this
error ?

--
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+unsubscribe@googlegroups.com
<mailto:django-users+unsubscribe@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto: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/52667e5d-998a-4b49-b3c9-b8c4d3842133%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/52667e5d-998a-4b49-b3c9-b8c4d3842133%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

Obviously you would first at least try to run the project from command line using "python manage.py runserver" before doing anything with an IDE. IDE's are never good choice for django development IMHO

--
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+unsubscribe@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/565990F2.2030603%40gmail.com.

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



--
Wildman and Herring Limited, Registered Office: 52 Great Eastern Street, London, EC2A 3EP, Company no: 05766374

--
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+unsubscribe@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/CAPZHCY6okWECJCFbmU-Bx_Fz9xigUrVsN7ov30wnuyHbZFPJ3A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Correct way to do async forms

Hi, 

If you want to do it async, you need to use JavaScript to make ajax requests. And you need an endpoint that would respond to your ajax request. You can use the same django view to both serve the html and handle the JS request. However, that might make the business logic more complex. I would usually have a separate view for it. 

Regards,
Masnun



On Saturday, November 28, 2015 at 7:08:02 AM UTC+6, Jonty Needham wrote:

Hi,
I need to do a file upload in django where if the file fails appropriate checks then an error is raised back to the user without 500ing the page.

I've got a form that does what I want, however it returns the error in a new page, but I want it returned in place. So I need an async call. What's the correct easy to do all this? I've seen a method on line where I need to write another view to take care of the form data but that seems ugly. It seems like there should be a better easy in django.

Thanks in advance.
Jonty

--
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+unsubscribe@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/358bee2f-0bae-4087-aca7-233c1a8de998%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Unresolved references error in Pycharm Community edition

On শুক্রবার 27 নভে 2015 03:04 অপরাহ্ণ, Sneha R wrote:
> Hi,
>
> I am new to Pycharm and I am trying to run a Django project in Pycharm
> Community edition 5.0.1 but there are few import errors saying
> ''Unresolved reference'" . I am using Python 2.7. How do I solve this
> error ?
>
> --
> 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+unsubscribe@googlegroups.com
> <mailto:django-users+unsubscribe@googlegroups.com>.
> To post to this group, send email to django-users@googlegroups.com
> <mailto: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/52667e5d-998a-4b49-b3c9-b8c4d3842133%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/52667e5d-998a-4b49-b3c9-b8c4d3842133%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Obviously you would first at least try to run the project from command
line using "python manage.py runserver" before doing anything with an
IDE. IDE's are never good choice for django development IMHO

--
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+unsubscribe@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/565990F2.2030603%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Friday, November 27, 2015

Correct way to do async forms

Hi,
I need to do a file upload in django where if the file fails appropriate checks then an error is raised back to the user without 500ing the page.

I've got a form that does what I want, however it returns the error in a new page, but I want it returned in place. So I need an async call. What's the correct easy to do all this? I've seen a method on line where I need to write another view to take care of the form data but that seems ugly. It seems like there should be a better easy in django.

Thanks in advance.
Jonty

--
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+unsubscribe@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/CANOQRbw7fjf-nA3%3DrmdpAWO1akBDXFAFkspa9f%3DK8K44R%3Dgxxw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Problem with login and register form

You should send both forms to the context, as in:


args['form_login'] = AuthenticationForm()
args['form_register'] = UserCreationForm()

And change the template to the appropriate form names. Also, change {% if user.is_authenticated == False %} to {% if not user.is_authenticated %}.

On Wednesday, November 25, 2015 at 4:24:29 PM UTC-2, Dariusz Mysior wrote:
Before template access_ownsite.html I had separated on few templates like login, register etc .html and it work's but now when I split it, a form is not forward to access_ownsite.html

W dniu wtorek, 24 listopada 2015 21:34:30 UTC+1 użytkownik Dariusz Mysior napisał:
Hi I had a problem with display a form of login and register, please look on it.

my template access_ownsite.html

{% load staticfiles %}

<!DOCTYPE html>
<html lang="en">
<head>
   
<title>{% block title %}{% endblock %}</title>
   
<link rel="stylesheet" type="text/css" href="{% static 'ownsite/css/style.css' %}" />


</head>
<body>
{% block content %}
<div id="header">
    {% if user.is_authenticated %}
       
<p>Jesteś zalogowany <a href='ownsite/my_view'>{{ user.username }}</a></p>
       
<p><a href='/accounts/logout_view'>wyloguj</a></p>
    {% else %}
       
<h2>Login</h2>
       
<form action = '/accounts/login_view/' method = 'post'>{% csrf_token %}
        {{form.as_p}}
       
<input type='submit' value='Log' />
       
</form>
    {% endif %}
</div>
<div id="content">
   
<div id="left_content">
        {% block logout_msg %}
           
<p> {{ info }} </p>
           
<p>Nikt nie jest zalogowany w tym momencie.</p>
        {% endblock %}
   
</div>
   
<div id="right_content">
        {% if user.is_authenticated == False %}
           
<h2>Register</h2>
           
<form action = '/accounts/register_user/' method = 'post'>{% csrf_token %}
                {{form.as_p}}
               
<input type='submit' value='Register' />
           
</form>
        {% endif %}
   
</div>
</div>
<div id="footer">
<p>copyright &copy; Dariusz Mysior</p>
</div>
{% endblock %}
</body>
</html>


my view.py

from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from django.shortcuts import render_to_response, render
from django.http import  HttpResponseRedirect
from django.core.context_processors import csrf
from django.contrib.auth import authenticate, login, logout


def login_view(request):
   
if request.method == 'POST':
        username
= request.POST['username']
        password
= request.POST['password']
        user
= authenticate(username=username, password=password)
       
if user is not None:
           
if user.is_active:
                login
(request, user)
               
return HttpResponseRedirect('/accounts/my_view')
           
else:
               
# Return a 'disabled account' error message
                ...
       
else:
           
...

--
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+unsubscribe@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/87bf02b7-ee2f-4046-9baa-20089f63aef6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Unresolved references error in Pycharm Community edition

This error is on run console or on some dialog of pycharm?

On Fri, Nov 27, 2015 at 7:04 AM, Sneha R <sneha2606@gmail.com> wrote:
Hi,

I am new to Pycharm and I am trying to run a Django project in Pycharm Community edition 5.0.1 but there are few import errors saying ''Unresolved reference'" . I am using Python 2.7. How do I solve this error ?

--
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+unsubscribe@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/52667e5d-998a-4b49-b3c9-b8c4d3842133%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Ezequiel Bertti
E-Mail: ebertti@gmail.com
Cel: (21) 99188-4860

--
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+unsubscribe@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/CACrQMYprLfxqwFpEAitQK05%3DdW%3DJM1opreiKXMwah2684u%3Dn3w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Using request object in settings.py for custom logging

Anyone with any idea how to solve this problem?

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+unsubscribe@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/9fcbf7ab-0076-47c9-8f44-e20d369bdb3b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Unresolved references error in Pycharm Community edition

Hi,

I am new to Pycharm and I am trying to run a Django project in Pycharm Community edition 5.0.1 but there are few import errors saying ''Unresolved reference'" . I am using Python 2.7. How do I solve this error ?

--
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+unsubscribe@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/52667e5d-998a-4b49-b3c9-b8c4d3842133%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: changes are not being published, help!

I expect a psychic will be required in the early stages. You'll need
to try and, at least, make a connection between your website and the
subject of this group (i.e. django). But, in truth, I don't expect it
will help; I think you probably need to contact whomever built your
website for you.

On 26/11/2015, Hellen Tiethoff <hellentiethoff@gmail.com> wrote:
> Hi,
>
> I have made changes on my website, but each time when i press the buttton
> "request to publish" i receive the error 501 bad gateway.
> My internet works fine, this is how i did it in the past and it woked then,
>
> but not now.
>
> Who can help me to publish my changes?
>
> Thanxs, Hellen
>
> --
> 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+unsubscribe@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/fd36766e-a86a-4f64-a151-586605bbd59f%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+unsubscribe@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/CAHCf7OHgVS9%2Bf8GCxy0j_Hze3S%3DH43yxMz_hVtGW3AUD1M0%2Big%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.