s3-File Upload Generate Error Message: FileNotFoundError

2023-01-03 Thread ramdom Use
Hello to All!
I need your help figuring out how to solve this issue I'm having while 
trying to upload directly to s3 bucket.
I have a function that works perfectly outside of django, I'm trying to 
implement it within django so as to be able to upload directly to s3. 

1. I do want to first save the file locally
2. Though I'm testing it with one s3 bucket, ultimately the application 
will deal with several buckets; I'm not trying to use s3 as a 
storage/backend, but rather to use django's UI as a file transfer point 
from any end user to his s3 bucket.

This is my scripts (

#function carrying out the upload to s3
def s3_upload_file(file_name, bucket, object_name=None):

if object_name is None:
object_name = file_name
# Upload the file
s3_client = boto3.client('s3')
try:
response = s3_client.upload_file(file_name, bucket, object_name)
except ClientError as e:
logging.error(e)
return False
return True

#function serving to upload the file - linked to UI/django form
#@login_required
def upload_file(request):
if request.method == 'POST':
form = UploadFileForm(request.POST, request.FILES)
if form.is_valid():
file = request.FILES['file'].name
file = str(file)
s3_upload_file(file, 'django-to-s3')#calling the fucntion 
# as it takes the uploaded file as input. 
return HttpResponseRedirect('/success/url/')
else:
form = UploadFileForm()
return render(request, 'aws/file_upload.html', {'form': form})

I'm using this line:  file = str(file), in attempt to cast 
request.FILES['file'] as a string, otherwise 
s3_upload_file(file, 'django-to-s3') throws an error. Attached are 
screenshots of what I get when I run the cmd python manage.py runserver

I will truly appreciate your help. 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a1848b26-3b08-4178-9ec8-2f96a3506d28n%40googlegroups.com.


error message

2022-03-23 Thread Abhinandan K

   
   - 
   

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6697d5ff-49bb-45e7-ae4e-8e02565301cbn%40googlegroups.com.


Re: i am trying to learn django from django documentation but i am getting an error message in the first part of the documentation

2021-07-04 Thread Lalit Suthar
rewrite polls/urls.py like below
path(''", views.index, name='index'),

On Fri, 25 Jun 2021 at 18:59, Symaxx  wrote:

> I started learning Django from the documentation but it was very hard for
> me and it took me a very long time to grasp the concept
>
> I suggest you try using books by w.s vincent http://wsvincent.com/books/ these
> are the best for me and them help you stay engaged
>
> On Wed, Jun 23, 2021 at 5:19 PM vatsal narula 
> wrote:
>
>> Using the URLconf defined in blogs.urls, Django tried these URL patterns,
>> in this order:
>>
>> admin/ The current path, polls/, didn’t match any of these. this is the
>> error i am getting after i wrote the following code:
>>
>>1.
>>
>>for urls.py
>>from django.contrib import admin from django.urls import include,
>>path urlpatterns = [ path('polls/', include('polls.urls')), path('admin/',
>>admin.site.urls), ]
>>2.
>>
>>for polls/urls.py
>>from django.urls import path from . import views urlpatterns = [
>>path('', views.index, name='index'), ]
>>
>> 3.for polls/views.py
>>
>>  """ from django.http import HttpResponse
>> def index(request): return HttpResponse("Hello, world. You're at the
>> polls index.") """
>>
>> *how i can i remove this error in vs code*
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/5750b076-eddf-400d-b180-4ec7d46aa0e3n%40googlegroups.com
>> 
>> .
>>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CANPYDAttdvo3pLcQQ_j5uS3T0%2BNvYB_eSXn%2BMmS%2BO9s9n0i4OQ%40mail.gmail.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGp2JVEmazmCMq-01YuibMWmT7ecR2kYY%2BhezB2em%3DGcbst88Q%40mail.gmail.com.


Re: i am trying to learn django from django documentation but i am getting an error message in the first part of the documentation

2021-06-25 Thread Symaxx
I started learning Django from the documentation but it was very hard for
me and it took me a very long time to grasp the concept

I suggest you try using books by w.s vincent http://wsvincent.com/books/ these
are the best for me and them help you stay engaged

On Wed, Jun 23, 2021 at 5:19 PM vatsal narula 
wrote:

> Using the URLconf defined in blogs.urls, Django tried these URL patterns,
> in this order:
>
> admin/ The current path, polls/, didn’t match any of these. this is the
> error i am getting after i wrote the following code:
>
>1.
>
>for urls.py
>from django.contrib import admin from django.urls import include, path
>urlpatterns = [ path('polls/', include('polls.urls')), path('admin/',
>admin.site.urls), ]
>2.
>
>for polls/urls.py
>from django.urls import path from . import views urlpatterns = [
>path('', views.index, name='index'), ]
>
> 3.for polls/views.py
>
>  """ from django.http import HttpResponse
> def index(request): return HttpResponse("Hello, world. You're at the polls
> index.") """
>
> *how i can i remove this error in vs code*
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5750b076-eddf-400d-b180-4ec7d46aa0e3n%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANPYDAttdvo3pLcQQ_j5uS3T0%2BNvYB_eSXn%2BMmS%2BO9s9n0i4OQ%40mail.gmail.com.


i am trying to learn django from django documentation but i am getting an error message in the first part of the documentation

2021-06-23 Thread vatsal narula


Using the URLconf defined in blogs.urls, Django tried these URL patterns, 
in this order:

admin/ The current path, polls/, didn’t match any of these. this is the 
error i am getting after i wrote the following code:

   1. 
   
   for urls.py
   from django.contrib import admin from django.urls import include, path 
   urlpatterns = [ path('polls/', include('polls.urls')), path('admin/', 
   admin.site.urls), ] 
   2. 
   
   for polls/urls.py
   from django.urls import path from . import views urlpatterns = [ 
   path('', views.index, name='index'), ] 

3.for polls/views.py

 """ from django.http import HttpResponse
def index(request): return HttpResponse("Hello, world. You're at the polls 
index.") """ 

*how i can i remove this error in vs code*

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5750b076-eddf-400d-b180-4ec7d46aa0e3n%40googlegroups.com.


Re: I am getting an error message about a non-nullable field in existing rows, even though I dropped all rows via the admin interface

2020-09-12 Thread Mislav Jurić
coolguy:

I tried it without the quotes. Maybe that was the issue.

Dana subota, 12. rujna 2020. u 20:33:52 UTC+2 korisnik coolguy napisao je:

> Keep this handy as well... 
>
> https://docs.djangoproject.com/en/3.1/ref/migration-operations/#addfield
>
> On Saturday, September 12, 2020 at 1:43:37 PM UTC-4 mislav@gmail.com 
> wrote:
>
>> A question to coolguy:
>>
>> *What should I have done if I selected option 1?* I get the Python shell 
>> and if I input a default value - let's say "te...@test.com", what else 
>> do I need to do? I tried to just provide the default value, but it wouldn't 
>> accept it, complaining that it was invalid Python (as it is). *Do I need 
>> to select the existing rows from the database and set them all to have the 
>> value of the new field to the default value? If yes, how do I do this most 
>> efficiently (in code)?*
>>
>> Best,
>> Mislav
>>
>> Dana subota, 12. rujna 2020. u 18:21:14 UTC+2 korisnik coolguy napisao je:
>>
>>> just FYI...
>>>
>>> You didn't have to delete the db.sqllite3 file rather would have 
>>> followed on-screen direction and provided a default value to persist in the 
>>> existing records in your database. Later you could have edited the info 
>>> through your program and make correction.
>>>
>>> This is pretty normal situation where we added new fields/properties in 
>>> our model while database has existing records. You wouldn't be able to 
>>> delete the database in case you are using relational database like postgres 
>>> or mysql.
>>>
>>> Thanks
>>>
>>> On Saturday, September 12, 2020 at 10:44:11 AM UTC-4 
>>> mislav@gmail.com wrote:
>>>
 Hey Danish,

 I was able to resolve the error by deleting the *db.sqlite3* file from 
 my project root directory and all of the *migrations* folders from all 
 of my apps.

 Thank you for responding.

 Best,
 Mislav


 Dana subota, 12. rujna 2020. u 14:56:13 UTC+2 korisnik 
 mailto...@gmail.com napisao je:

> you need to give default value in email. seems few records are already 
> exist.
>
> else delete sqllite file and try again.
>
> On Sat, Sep 12, 2020 at 6:22 PM Mislav Jurić  
> wrote:
>
>> Hey guys,
>>
>> I added an EmailField 
>>  
>> to some of my already existing models. When I tried to run:
>>
>> *python manage.py makemigrations*
>>
>> I got the following prompt:
>>
>>
>>
>>
>>
>> *You are trying to add a non-nullable field 'email' to employee 
>> without a default; we can't do that (the database needs something to 
>> populate existing rows).Please select a fix: 1) Provide a one-off 
>> default 
>> now (will be set on all existing rows with a null value for this column) 
>> 2) 
>> Quit, and let me add a default in models.pySelect an option: *
>>
>> I quit the prompt (option two). Then I went ahead and commented out 
>> the new EmailField in the models I added them and I dropped all of the 
>> database rows in my entire database (not just the rows related to the 
>> models where I added the new email field; I dropped every row from every 
>> table).
>>
>> Then I uncommented the new EmailField and tried to run:
>>
>> *python manage.py makemigrations*
>>
>> again, *but I still get the prompt above*! I selected option 1 a few 
>> times, but I'm not sure what I need to do. I tried to supply a value for 
>> that field, but the prompt is a Python shell, so I'm not sure what I 
>> need 
>> to do if I select option 1.
>>
>> *How do I fix this?*
>>
>> Best,
>> Mislav
>>
>>
>> -- 
>> 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 view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CABTqP_HKzXHOAKC-y0AedjsxtBcgKLEk9Cj9J7nhgoD1EpNf%2BA%40mail.gmail.com
>>  
>> 
>> .
>>
>
>
> -- 
> Thanks & Regards 
>   
> Regards, 
> Danish
>


-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ef66474e-3867-43d4-abbe-9183cd08d2cen%40googlegroups.com.


Re: I am getting an error message about a non-nullable field in existing rows, even though I dropped all rows via the admin interface

2020-09-12 Thread coolguy
Keep this handy as well... 

https://docs.djangoproject.com/en/3.1/ref/migration-operations/#addfield

On Saturday, September 12, 2020 at 1:43:37 PM UTC-4 mislav@gmail.com 
wrote:

> A question to coolguy:
>
> *What should I have done if I selected option 1?* I get the Python shell 
> and if I input a default value - let's say "te...@test.com", what else do 
> I need to do? I tried to just provide the default value, but it wouldn't 
> accept it, complaining that it was invalid Python (as it is). *Do I need 
> to select the existing rows from the database and set them all to have the 
> value of the new field to the default value? If yes, how do I do this most 
> efficiently (in code)?*
>
> Best,
> Mislav
>
> Dana subota, 12. rujna 2020. u 18:21:14 UTC+2 korisnik coolguy napisao je:
>
>> just FYI...
>>
>> You didn't have to delete the db.sqllite3 file rather would have followed 
>> on-screen direction and provided a default value to persist in the existing 
>> records in your database. Later you could have edited the info through your 
>> program and make correction.
>>
>> This is pretty normal situation where we added new fields/properties in 
>> our model while database has existing records. You wouldn't be able to 
>> delete the database in case you are using relational database like postgres 
>> or mysql.
>>
>> Thanks
>>
>> On Saturday, September 12, 2020 at 10:44:11 AM UTC-4 mislav@gmail.com 
>> wrote:
>>
>>> Hey Danish,
>>>
>>> I was able to resolve the error by deleting the *db.sqlite3* file from 
>>> my project root directory and all of the *migrations* folders from all 
>>> of my apps.
>>>
>>> Thank you for responding.
>>>
>>> Best,
>>> Mislav
>>>
>>>
>>> Dana subota, 12. rujna 2020. u 14:56:13 UTC+2 korisnik 
>>> mailto...@gmail.com napisao je:
>>>
 you need to give default value in email. seems few records are already 
 exist.

 else delete sqllite file and try again.

 On Sat, Sep 12, 2020 at 6:22 PM Mislav Jurić  
 wrote:

> Hey guys,
>
> I added an EmailField 
>  
> to some of my already existing models. When I tried to run:
>
> *python manage.py makemigrations*
>
> I got the following prompt:
>
>
>
>
>
> *You are trying to add a non-nullable field 'email' to employee 
> without a default; we can't do that (the database needs something to 
> populate existing rows).Please select a fix: 1) Provide a one-off default 
> now (will be set on all existing rows with a null value for this column) 
> 2) 
> Quit, and let me add a default in models.pySelect an option: *
>
> I quit the prompt (option two). Then I went ahead and commented out 
> the new EmailField in the models I added them and I dropped all of the 
> database rows in my entire database (not just the rows related to the 
> models where I added the new email field; I dropped every row from every 
> table).
>
> Then I uncommented the new EmailField and tried to run:
>
> *python manage.py makemigrations*
>
> again, *but I still get the prompt above*! I selected option 1 a few 
> times, but I'm not sure what I need to do. I tried to supply a value for 
> that field, but the prompt is a Python shell, so I'm not sure what I need 
> to do if I select option 1.
>
> *How do I fix this?*
>
> Best,
> Mislav
>
>
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CABTqP_HKzXHOAKC-y0AedjsxtBcgKLEk9Cj9J7nhgoD1EpNf%2BA%40mail.gmail.com
>  
> 
> .
>


 -- 
 Thanks & Regards 
   
 Regards, 
 Danish

>>>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/eb23d859-0d78-4115-a461-cf8bd547493dn%40googlegroups.com.


Re: I am getting an error message about a non-nullable field in existing rows, even though I dropped all rows via the admin interface

2020-09-12 Thread coolguy
Interesting... did you try the email with quotes or without it

On Saturday, September 12, 2020 at 1:43:37 PM UTC-4 mislav@gmail.com 
wrote:

> A question to coolguy:
>
> *What should I have done if I selected option 1?* I get the Python shell 
> and if I input a default value - let's say "te...@test.com", what else do 
> I need to do? I tried to just provide the default value, but it wouldn't 
> accept it, complaining that it was invalid Python (as it is). *Do I need 
> to select the existing rows from the database and set them all to have the 
> value of the new field to the default value? If yes, how do I do this most 
> efficiently (in code)?*
>
> Best,
> Mislav
>
> Dana subota, 12. rujna 2020. u 18:21:14 UTC+2 korisnik coolguy napisao je:
>
>> just FYI...
>>
>> You didn't have to delete the db.sqllite3 file rather would have followed 
>> on-screen direction and provided a default value to persist in the existing 
>> records in your database. Later you could have edited the info through your 
>> program and make correction.
>>
>> This is pretty normal situation where we added new fields/properties in 
>> our model while database has existing records. You wouldn't be able to 
>> delete the database in case you are using relational database like postgres 
>> or mysql.
>>
>> Thanks
>>
>> On Saturday, September 12, 2020 at 10:44:11 AM UTC-4 mislav@gmail.com 
>> wrote:
>>
>>> Hey Danish,
>>>
>>> I was able to resolve the error by deleting the *db.sqlite3* file from 
>>> my project root directory and all of the *migrations* folders from all 
>>> of my apps.
>>>
>>> Thank you for responding.
>>>
>>> Best,
>>> Mislav
>>>
>>>
>>> Dana subota, 12. rujna 2020. u 14:56:13 UTC+2 korisnik 
>>> mailto...@gmail.com napisao je:
>>>
 you need to give default value in email. seems few records are already 
 exist.

 else delete sqllite file and try again.

 On Sat, Sep 12, 2020 at 6:22 PM Mislav Jurić  
 wrote:

> Hey guys,
>
> I added an EmailField 
>  
> to some of my already existing models. When I tried to run:
>
> *python manage.py makemigrations*
>
> I got the following prompt:
>
>
>
>
>
> *You are trying to add a non-nullable field 'email' to employee 
> without a default; we can't do that (the database needs something to 
> populate existing rows).Please select a fix: 1) Provide a one-off default 
> now (will be set on all existing rows with a null value for this column) 
> 2) 
> Quit, and let me add a default in models.pySelect an option: *
>
> I quit the prompt (option two). Then I went ahead and commented out 
> the new EmailField in the models I added them and I dropped all of the 
> database rows in my entire database (not just the rows related to the 
> models where I added the new email field; I dropped every row from every 
> table).
>
> Then I uncommented the new EmailField and tried to run:
>
> *python manage.py makemigrations*
>
> again, *but I still get the prompt above*! I selected option 1 a few 
> times, but I'm not sure what I need to do. I tried to supply a value for 
> that field, but the prompt is a Python shell, so I'm not sure what I need 
> to do if I select option 1.
>
> *How do I fix this?*
>
> Best,
> Mislav
>
>
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CABTqP_HKzXHOAKC-y0AedjsxtBcgKLEk9Cj9J7nhgoD1EpNf%2BA%40mail.gmail.com
>  
> 
> .
>


 -- 
 Thanks & Regards 
   
 Regards, 
 Danish

>>>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8f0c98b3-bea3-4e47-977c-61323df4cf23n%40googlegroups.com.


Re: I am getting an error message about a non-nullable field in existing rows, even though I dropped all rows via the admin interface

2020-09-12 Thread Mislav Jurić
A question to coolguy:

*What should I have done if I selected option 1?* I get the Python shell 
and if I input a default value - let's say "t...@test.com", what else do I 
need to do? I tried to just provide the default value, but it wouldn't 
accept it, complaining that it was invalid Python (as it is). *Do I need to 
select the existing rows from the database and set them all to have the 
value of the new field to the default value? If yes, how do I do this most 
efficiently (in code)?*

Best,
Mislav

Dana subota, 12. rujna 2020. u 18:21:14 UTC+2 korisnik coolguy napisao je:

> just FYI...
>
> You didn't have to delete the db.sqllite3 file rather would have followed 
> on-screen direction and provided a default value to persist in the existing 
> records in your database. Later you could have edited the info through your 
> program and make correction.
>
> This is pretty normal situation where we added new fields/properties in 
> our model while database has existing records. You wouldn't be able to 
> delete the database in case you are using relational database like postgres 
> or mysql.
>
> Thanks
>
> On Saturday, September 12, 2020 at 10:44:11 AM UTC-4 mislav@gmail.com 
> wrote:
>
>> Hey Danish,
>>
>> I was able to resolve the error by deleting the *db.sqlite3* file from 
>> my project root directory and all of the *migrations* folders from all 
>> of my apps.
>>
>> Thank you for responding.
>>
>> Best,
>> Mislav
>>
>>
>> Dana subota, 12. rujna 2020. u 14:56:13 UTC+2 korisnik 
>> mailto...@gmail.com napisao je:
>>
>>> you need to give default value in email. seems few records are already 
>>> exist.
>>>
>>> else delete sqllite file and try again.
>>>
>>> On Sat, Sep 12, 2020 at 6:22 PM Mislav Jurić  
>>> wrote:
>>>
 Hey guys,

 I added an EmailField 
  
 to some of my already existing models. When I tried to run:

 *python manage.py makemigrations*

 I got the following prompt:





 *You are trying to add a non-nullable field 'email' to employee without 
 a default; we can't do that (the database needs something to populate 
 existing rows).Please select a fix: 1) Provide a one-off default now (will 
 be set on all existing rows with a null value for this column) 2) Quit, 
 and 
 let me add a default in models.pySelect an option: *

 I quit the prompt (option two). Then I went ahead and commented out the 
 new EmailField in the models I added them and I dropped all of the 
 database 
 rows in my entire database (not just the rows related to the models where 
 I 
 added the new email field; I dropped every row from every table).

 Then I uncommented the new EmailField and tried to run:

 *python manage.py makemigrations*

 again, *but I still get the prompt above*! I selected option 1 a few 
 times, but I'm not sure what I need to do. I tried to supply a value for 
 that field, but the prompt is a Python shell, so I'm not sure what I need 
 to do if I select option 1.

 *How do I fix this?*

 Best,
 Mislav


 -- 
 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 view this discussion on the web visit 
 https://groups.google.com/d/msgid/django-users/CABTqP_HKzXHOAKC-y0AedjsxtBcgKLEk9Cj9J7nhgoD1EpNf%2BA%40mail.gmail.com
  
 
 .

>>>
>>>
>>> -- 
>>> Thanks & Regards 
>>>   
>>> Regards, 
>>> Danish
>>>
>>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1920b7b0-a595-44e3-9c7f-2897fdb8a58bn%40googlegroups.com.


Re: I am getting an error message about a non-nullable field in existing rows, even though I dropped all rows via the admin interface

2020-09-12 Thread Mohammad Ahshan Danish
yes it works after deletion because old records get deleted.

but better approach is to do changes in migration.py files

On Sat, Sep 12, 2020 at 8:14 PM Mislav Jurić 
wrote:

> Hey Danish,
>
> I was able to resolve the error by deleting the *db.sqlite3* file from my
> project root directory and all of the *migration* folders from all of my
> apps.
>
> Thank you for responding.
>
> Best,
> Mislav
>
> Dana subota, 12. rujna 2020. u 14:56:13 UTC+2 korisnik mailto...@gmail.com
> napisao je:
>
>> you need to give default value in email. seems few records are already
>> exist.
>>
>> else delete sqllite file and try again.
>>
>> On Sat, Sep 12, 2020 at 6:22 PM Mislav Jurić 
>> wrote:
>>
>>> Hey guys,
>>>
>>> I added an EmailField
>>> 
>>> to some of my already existing models. When I tried to run:
>>>
>>> *python manage.py makemigrations*
>>>
>>> I got the following prompt:
>>>
>>>
>>>
>>>
>>>
>>> *You are trying to add a non-nullable field 'email' to employee without
>>> a default; we can't do that (the database needs something to populate
>>> existing rows).Please select a fix: 1) Provide a one-off default now (will
>>> be set on all existing rows with a null value for this column) 2) Quit, and
>>> let me add a default in models.pySelect an option: *
>>>
>>> I quit the prompt (option two). Then I went ahead and commented out the
>>> new EmailField in the models I added them and I dropped all of the database
>>> rows in my entire database (not just the rows related to the models where I
>>> added the new email field; I dropped every row from every table).
>>>
>>> Then I uncommented the new EmailField and tried to run:
>>>
>>> *python manage.py makemigrations*
>>>
>>> again, *but I still get the prompt above*! I selected option 1 a few
>>> times, but I'm not sure what I need to do. I tried to supply a value for
>>> that field, but the prompt is a Python shell, so I'm not sure what I need
>>> to do if I select option 1.
>>>
>>> *How do I fix this?*
>>>
>>> Best,
>>> Mislav
>>>
>>>
>>> --
>>> 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 view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CABTqP_HKzXHOAKC-y0AedjsxtBcgKLEk9Cj9J7nhgoD1EpNf%2BA%40mail.gmail.com
>>> 
>>> .
>>>
>>
>>
>> --
>> Thanks & Regards
>>
>> Regards,
>> Danish
>>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ac5c4f4d-8b2f-469d-9e7a-260a415d4644n%40googlegroups.com
> 
> .
>


-- 
Thanks & Regards

Regards,
Danish

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPQdaF094eV_UnOOLg0N%3DktYb%3DpaBQa5nSRVbAyrxu4gNmMCAA%40mail.gmail.com.


Re: I am getting an error message about a non-nullable field in existing rows, even though I dropped all rows via the admin interface

2020-09-12 Thread coolguy
just FYI...

You didn't have to delete the db.sqllite3 file rather would have followed 
on-screen direction and provided a default value to persist in the existing 
records in your database. Later you could have edited the info through your 
program and make correction.

This is pretty normal situation where we added new fields/properties in our 
model while database has existing records. You wouldn't be able to delete 
the database in case you are using relational database like postgres or 
mysql.

Thanks

On Saturday, September 12, 2020 at 10:44:11 AM UTC-4 mislav@gmail.com 
wrote:

> Hey Danish,
>
> I was able to resolve the error by deleting the *db.sqlite3* file from my 
> project root directory and all of the *migrations* folders from all of my 
> apps.
>
> Thank you for responding.
>
> Best,
> Mislav
>
>
> Dana subota, 12. rujna 2020. u 14:56:13 UTC+2 korisnik mailto...@gmail.com 
> napisao je:
>
>> you need to give default value in email. seems few records are already 
>> exist.
>>
>> else delete sqllite file and try again.
>>
>> On Sat, Sep 12, 2020 at 6:22 PM Mislav Jurić  
>> wrote:
>>
>>> Hey guys,
>>>
>>> I added an EmailField 
>>>  
>>> to some of my already existing models. When I tried to run:
>>>
>>> *python manage.py makemigrations*
>>>
>>> I got the following prompt:
>>>
>>>
>>>
>>>
>>>
>>> *You are trying to add a non-nullable field 'email' to employee without 
>>> a default; we can't do that (the database needs something to populate 
>>> existing rows).Please select a fix: 1) Provide a one-off default now (will 
>>> be set on all existing rows with a null value for this column) 2) Quit, and 
>>> let me add a default in models.pySelect an option: *
>>>
>>> I quit the prompt (option two). Then I went ahead and commented out the 
>>> new EmailField in the models I added them and I dropped all of the database 
>>> rows in my entire database (not just the rows related to the models where I 
>>> added the new email field; I dropped every row from every table).
>>>
>>> Then I uncommented the new EmailField and tried to run:
>>>
>>> *python manage.py makemigrations*
>>>
>>> again, *but I still get the prompt above*! I selected option 1 a few 
>>> times, but I'm not sure what I need to do. I tried to supply a value for 
>>> that field, but the prompt is a Python shell, so I'm not sure what I need 
>>> to do if I select option 1.
>>>
>>> *How do I fix this?*
>>>
>>> Best,
>>> Mislav
>>>
>>>
>>> -- 
>>> 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 view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/CABTqP_HKzXHOAKC-y0AedjsxtBcgKLEk9Cj9J7nhgoD1EpNf%2BA%40mail.gmail.com
>>>  
>>> 
>>> .
>>>
>>
>>
>> -- 
>> Thanks & Regards 
>>   
>> Regards, 
>> Danish
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b280d8c4-6a4e-44bd-99d0-58d69e3b25dcn%40googlegroups.com.


Re: I am getting an error message about a non-nullable field in existing rows, even though I dropped all rows via the admin interface

2020-09-12 Thread Mislav Jurić
Hey Danish,

I was able to resolve the error by deleting the *db.sqlite3* file from my 
project root directory and all of the *migrations* folders from all of my 
apps.

Thank you for responding.

Best,
Mislav


Dana subota, 12. rujna 2020. u 14:56:13 UTC+2 korisnik mailto...@gmail.com 
napisao je:

> you need to give default value in email. seems few records are already 
> exist.
>
> else delete sqllite file and try again.
>
> On Sat, Sep 12, 2020 at 6:22 PM Mislav Jurić  wrote:
>
>> Hey guys,
>>
>> I added an EmailField 
>>  to 
>> some of my already existing models. When I tried to run:
>>
>> *python manage.py makemigrations*
>>
>> I got the following prompt:
>>
>>
>>
>>
>>
>> *You are trying to add a non-nullable field 'email' to employee without a 
>> default; we can't do that (the database needs something to populate 
>> existing rows).Please select a fix: 1) Provide a one-off default now (will 
>> be set on all existing rows with a null value for this column) 2) Quit, and 
>> let me add a default in models.pySelect an option: *
>>
>> I quit the prompt (option two). Then I went ahead and commented out the 
>> new EmailField in the models I added them and I dropped all of the database 
>> rows in my entire database (not just the rows related to the models where I 
>> added the new email field; I dropped every row from every table).
>>
>> Then I uncommented the new EmailField and tried to run:
>>
>> *python manage.py makemigrations*
>>
>> again, *but I still get the prompt above*! I selected option 1 a few 
>> times, but I'm not sure what I need to do. I tried to supply a value for 
>> that field, but the prompt is a Python shell, so I'm not sure what I need 
>> to do if I select option 1.
>>
>> *How do I fix this?*
>>
>> Best,
>> Mislav
>>
>>
>> -- 
>> 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 view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CABTqP_HKzXHOAKC-y0AedjsxtBcgKLEk9Cj9J7nhgoD1EpNf%2BA%40mail.gmail.com
>>  
>> 
>> .
>>
>
>
> -- 
> Thanks & Regards 
>   
> Regards, 
> Danish
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e91810c3-1faa-443c-91e1-e8b4c6553b7dn%40googlegroups.com.


Re: I am getting an error message about a non-nullable field in existing rows, even though I dropped all rows via the admin interface

2020-09-12 Thread Mislav Jurić
Hey Danish,

I was able to resolve the error by deleting the *db.sqlite3* file from my 
project root directory and all of the *migration* folders from all of my 
apps.

Thank you for responding.

Best,
Mislav

Dana subota, 12. rujna 2020. u 14:56:13 UTC+2 korisnik mailto...@gmail.com 
napisao je:

> you need to give default value in email. seems few records are already 
> exist.
>
> else delete sqllite file and try again.
>
> On Sat, Sep 12, 2020 at 6:22 PM Mislav Jurić  wrote:
>
>> Hey guys,
>>
>> I added an EmailField 
>>  to 
>> some of my already existing models. When I tried to run:
>>
>> *python manage.py makemigrations*
>>
>> I got the following prompt:
>>
>>
>>
>>
>>
>> *You are trying to add a non-nullable field 'email' to employee without a 
>> default; we can't do that (the database needs something to populate 
>> existing rows).Please select a fix: 1) Provide a one-off default now (will 
>> be set on all existing rows with a null value for this column) 2) Quit, and 
>> let me add a default in models.pySelect an option: *
>>
>> I quit the prompt (option two). Then I went ahead and commented out the 
>> new EmailField in the models I added them and I dropped all of the database 
>> rows in my entire database (not just the rows related to the models where I 
>> added the new email field; I dropped every row from every table).
>>
>> Then I uncommented the new EmailField and tried to run:
>>
>> *python manage.py makemigrations*
>>
>> again, *but I still get the prompt above*! I selected option 1 a few 
>> times, but I'm not sure what I need to do. I tried to supply a value for 
>> that field, but the prompt is a Python shell, so I'm not sure what I need 
>> to do if I select option 1.
>>
>> *How do I fix this?*
>>
>> Best,
>> Mislav
>>
>>
>> -- 
>> 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 view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CABTqP_HKzXHOAKC-y0AedjsxtBcgKLEk9Cj9J7nhgoD1EpNf%2BA%40mail.gmail.com
>>  
>> 
>> .
>>
>
>
> -- 
> Thanks & Regards 
>   
> Regards, 
> Danish
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ac5c4f4d-8b2f-469d-9e7a-260a415d4644n%40googlegroups.com.


Re: I am getting an error message about a non-nullable field in existing rows, even though I dropped all rows via the admin interface

2020-09-12 Thread Mohammad Ahshan Danish
you need to give default value in email. seems few records are already
exist.

else delete sqllite file and try again.

On Sat, Sep 12, 2020 at 6:22 PM Mislav Jurić 
wrote:

> Hey guys,
>
> I added an EmailField
>  to
> some of my already existing models. When I tried to run:
>
> *python manage.py makemigrations*
>
> I got the following prompt:
>
>
>
>
>
> *You are trying to add a non-nullable field 'email' to employee without a
> default; we can't do that (the database needs something to populate
> existing rows).Please select a fix: 1) Provide a one-off default now (will
> be set on all existing rows with a null value for this column) 2) Quit, and
> let me add a default in models.pySelect an option: *
>
> I quit the prompt (option two). Then I went ahead and commented out the
> new EmailField in the models I added them and I dropped all of the database
> rows in my entire database (not just the rows related to the models where I
> added the new email field; I dropped every row from every table).
>
> Then I uncommented the new EmailField and tried to run:
>
> *python manage.py makemigrations*
>
> again, *but I still get the prompt above*! I selected option 1 a few
> times, but I'm not sure what I need to do. I tried to supply a value for
> that field, but the prompt is a Python shell, so I'm not sure what I need
> to do if I select option 1.
>
> *How do I fix this?*
>
> Best,
> Mislav
>
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CABTqP_HKzXHOAKC-y0AedjsxtBcgKLEk9Cj9J7nhgoD1EpNf%2BA%40mail.gmail.com
> 
> .
>


-- 
Thanks & Regards

Regards,
Danish

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPQdaF14z3tAGNDKsk5HYNDG4v%3DpZv6fHbSpC5AtyDdhwzR9zQ%40mail.gmail.com.


I am getting an error message about a non-nullable field in existing rows, even though I dropped all rows via the admin interface

2020-09-12 Thread Mislav Jurić
Hey guys,

I added an EmailField
 to
some of my already existing models. When I tried to run:

*python manage.py makemigrations*

I got the following prompt:





*You are trying to add a non-nullable field 'email' to employee without a
default; we can't do that (the database needs something to populate
existing rows).Please select a fix: 1) Provide a one-off default now (will
be set on all existing rows with a null value for this column) 2) Quit, and
let me add a default in models.pySelect an option: *

I quit the prompt (option two). Then I went ahead and commented out the new
EmailField in the models I added them and I dropped all of the database
rows in my entire database (not just the rows related to the models where I
added the new email field; I dropped every row from every table).

Then I uncommented the new EmailField and tried to run:

*python manage.py makemigrations*

again, *but I still get the prompt above*! I selected option 1 a few times,
but I'm not sure what I need to do. I tried to supply a value for that
field, but the prompt is a Python shell, so I'm not sure what I need to do
if I select option 1.

*How do I fix this?*

Best,
Mislav

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABTqP_HKzXHOAKC-y0AedjsxtBcgKLEk9Cj9J7nhgoD1EpNf%2BA%40mail.gmail.com.


Re: NoReverseMatch error message - Please help

2020-03-31 Thread victor awakan
Sometimes the error can be from your url.py or even views.py and also make
sure no typo. Check each on e of the above carefully. Hopefully you might
see the bug.

Cheers

On Tue 31. Mar 2020 at 18.06, Jeff Waters  wrote:

> Thanks Ryan.
>
> I've just tried that, but I still get an error message.
>
> By the way, is it definitely .id and not _id? I've seen both, and Django
> docs says: 'Behind the scenes, Django appends "_id" to the field name to
> create its database column name, which makes me wonder if it might be _id.
>
> Incidentally, I've also tried amending the relevant URL path to
> path('add_comment/', views.add_comment, name='add_comment')
> - with underscore and with a dot before the id - but that doesn't work.
>
> Jeff
>
>
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4473f031-abfa-428a-8804-debaf5a41c93%40googlegroups.com
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAAipwd_Bjw%2BajNSVfyKcO5f27i2oxEmHoppnun2sA399eqcVxg%40mail.gmail.com.


Re: NoReverseMatch error message - Please help

2020-03-31 Thread Jeff Waters
Thanks Ryan.

I've just tried that, but I still get an error message. 

By the way, is it definitely .id and not _id? I've seen both, and Django docs 
says: 'Behind the scenes, Django appends "_id" to the field name to create its 
database column name, which makes me wonder if it might be _id.

Incidentally, I've also tried amending the relevant URL path to 
path('add_comment/', views.add_comment, name='add_comment') - 
with underscore and with a dot before the id - but that doesn't work.

Jeff



-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4473f031-abfa-428a-8804-debaf5a41c93%40googlegroups.com.


Re: NoReverseMatch error message - Please help

2020-03-31 Thread Ryan Nowakowski

Based on the rest of your template from the github link, looks like:

{% url 'nowandthen:add_comment' image.id %}

...should instead be:

{% url 'nowandthen:add_comment' p.image.id %}

On 3/31/20 7:08 AM, Jeff Waters wrote:

I am putting together a website which has a photo gallery where users can add 
comments. When I go to the photo gallery page, I get the following error 
message:

NoReverseMatch at /photo_feed/ Reverse for 'add_comment' with arguments '('',)' 
not found. 1 pattern(s) tried: ['add_comment/$']

The code for the relevant part of the HTML document is as follows:

 comments
 {% if not comments %}
 No comments
 {% endif %}
 {% for x in comment %}
 
 
 Comment by {{ x.user }}
 
 {{ x.created_on }}
 
 
 {{ x.body | linebreaks }}
 
 {% endfor %}
 
 
 {% if new_comment %}
 Your comment has been posted.
 {% else %}
 Leave a comment
 
 {{ comment_form.as_p }}
 {% csrf_token %}
 Submit
 {% endif %}
The URLs.py entry for add_comment is path('add_comment/', 
views.add_comment, name='add_comment'). Removing the int: image_id doesn't fix the 
problem.

When I go into admin, no ids appear to have been generated for the photos. 
Could it be that the problem is that there are missing IDs? If so, how do I fix 
this?

The repository URL is https://github.com/EmilyQuimby/my_now_and_then.

Thank you.



--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6e0854a3-ae89-d1a7-8fcf-98fbbadc9a3e%40fattuba.com.


Re: NoReverseMatch error message - Please help

2020-03-31 Thread Kasper Laudrup

Hi Jeff,

On 31/03/2020 14.08, Jeff Waters wrote:

I am putting together a website which has a photo gallery where users can add 
comments. When I go to the photo gallery page, I get the following error 
message:

NoReverseMatch at /photo_feed/ Reverse for 'add_comment' with arguments '('',)' 
not found. 1 pattern(s) tried: ['add_comment/$']



Trailing slashes are part of the path, so "/foobar/" is not the same as 
"/foobar".


Hopefully that should give you a hint to what is most likely the cause 
of your problem.


Kind regards,

Kasper Laudrup

--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/860f1f56-b008-f38b-3b01-8ff985f5d88f%40stacktrace.dk.


NoReverseMatch error message - Please help

2020-03-31 Thread Jeff Waters
I am putting together a website which has a photo gallery where users can add 
comments. When I go to the photo gallery page, I get the following error 
message:

NoReverseMatch at /photo_feed/ Reverse for 'add_comment' with arguments '('',)' 
not found. 1 pattern(s) tried: ['add_comment/$']

The code for the relevant part of the HTML document is as follows:

comments
{% if not comments %}
No comments
{% endif %}
{% for x in comment %}


Comment by {{ x.user }}

{{ x.created_on }}


{{ x.body | linebreaks }}

{% endfor %}


{% if new_comment %}
Your comment has been posted.
{% else %}
Leave a comment

{{ comment_form.as_p }}
{% csrf_token %}
Submit
{% endif %}
The URLs.py entry for add_comment is path('add_comment/', 
views.add_comment, name='add_comment'). Removing the int: image_id doesn't fix 
the problem.

When I go into admin, no ids appear to have been generated for the photos. 
Could it be that the problem is that there are missing IDs? If so, how do I fix 
this?

The repository URL is https://github.com/EmilyQuimby/my_now_and_then.

Thank you.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bb078990-f0e1-484a-a3dc-366f018b1df6%40googlegroups.com.


Re: Password reset token expired - get an error message

2020-01-22 Thread mohamed Alisaleh
بتاريخ الأربعاء، 22 يناير، 2020 5:55:58 م UTC+3، كتب wagner:
> Hello together,
> i found out that i can set a PASSWORD_RESET_TIMEOUT_DAYS variable in settings.
> This worked for me. After one day the token is expired and when i try to set 
> a new password, the page does a reload.
> So nothing happens. This is correct. Is there a good way / workaround to get 
> an error message, when the token is expired?
> 
> 
> Thank you,
> Danny 

 اين الرابط الإعدادات لائعادةكلمة تسجيل الدخول 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/66b7bd61-3fb7-43da-841d-71e0206983d6%40googlegroups.com.


Re: Password reset token expired - get an error message

2020-01-22 Thread mohamed Alisaleh
بتاريخ الأربعاء، 22 يناير، 2020 5:55:58 م UTC+3، كتب wagner:
> Hello together,
> i found out that i can set a PASSWORD_RESET_TIMEOUT_DAYS variable in settings.
> This worked for me. After one day the token is expired and when i try to set 
> a new password, the page does a reload.
> So nothing happens. This is correct. Is there a good way / workaround to get 
> an error message, when the token is expired?
> 
> 
> Thank you,
> Danny 

اشتراك 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7f459121-f890-4e62-a5e1-2f10b06b49a7%40googlegroups.com.


Password reset token expired - get an error message

2020-01-22 Thread wagner
Hello together,
i found out that i can set a PASSWORD_RESET_TIMEOUT_DAYS variable in 
settings.
This worked for me. After one day the token is expired and when i try to 
set a new password, the page does a reload.
So nothing happens. This is correct. Is there a good way / workaround to 
get an error message, when the token is expired?

Thank you,
Danny 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a45cb1c6-638a-4262-9a58-62eba0b37024%40googlegroups.com.


Re: Running polls tutorial, see the error message "The empty path didn't match any of these."

2019-12-30 Thread Jose M.
Thansk you are the man! yep this helped me in 2019! Cheers!

On Saturday, February 24, 2018 at 10:23:25 PM UTC-5, Dylan Reinhold wrote:
>
> What you are seeing is correct.
> That congratulations page is only displayed by django when you have no 
> url's defined other than admin. Once you add your first URL django gets out 
> of the way and does not show that splash screen.
>
> The error is saying you do no have anything defined in your URLs as / (or 
> empty), The polls app is in /polls/ (http://localhost:8000/polls/). Which 
> at this point in the tutorial is correct.
>
> Dylan
>
> On Sat, Feb 24, 2018 at 3:09 PM, Chunjing Jia  > wrote:
>
>> Hi,
>>
>> I am running Django 2.0 tutorial01 for polls. I am seeing this error 
>> message 
>>
>> Using the URLconf defined in mysite.urls, Django tried these URL 
>> patterns, in this order:
>>
>>1. polls/
>>2. admin/
>>
>> The empty path didn't match any of these.
>>
>> Without adding polls, my code works fine, and I can see the rocket and 
>> congratulation page. But after adding polls, I always get this error 
>> message. Even if I use the example code that I found from github with the 
>> all the correct setting... 
>>
>> Does this mean that my installation for Python3 and Django 2.0 may be 
>> problematic? What other possibles error may be here? 
>>
>> Thanks a lot!
>>
>> Best,
>> CJ
>>
>> -- 
>> 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...@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/7663c42a-06fc-4fc5-9604-dd92143c7ab3%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/7663c42a-06fc-4fc5-9604-dd92143c7ab3%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d3094873-bce8-4342-a148-b6f99a58db32%40googlegroups.com.


Re: Running polls tutorial, see the error message "The empty path didn't match any of these."

2018-02-25 Thread Chunjing Jia
Thank you Dylan! Now I see what's going on there.

Best,
Chunjing

On Saturday, February 24, 2018 at 4:56:10 PM UTC-8, Chunjing Jia wrote:
>
> Hi,
>
> I am running Django 2.0 tutorial01 for polls. I am seeing this error 
> message 
>
> Using the URLconf defined in mysite.urls, Django tried these URL 
> patterns, in this order:
>
>1. polls/
>2. admin/
>
> The empty path didn't match any of these.
>
> Without adding polls, my code works fine, and I can see the rocket and 
> congratulation page. But after adding polls, I always get this error 
> message. Even if I use the example code that I found from github with the 
> all the correct setting... 
>
> Does this mean that my installation for Python3 and Django 2.0 may be 
> problematic? What other possibles error may be here? 
>
> Thanks a lot!
>
> Best,
> CJ
>

-- 
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/c24ad298-b792-4381-afbd-2480349bd29b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Running polls tutorial, see the error message "The empty path didn't match any of these."

2018-02-24 Thread Dylan Reinhold
What you are seeing is correct.
That congratulations page is only displayed by django when you have no
url's defined other than admin. Once you add your first URL django gets out
of the way and does not show that splash screen.

The error is saying you do no have anything defined in your URLs as / (or
empty), The polls app is in /polls/ (http://localhost:8000/polls/). Which
at this point in the tutorial is correct.

Dylan

On Sat, Feb 24, 2018 at 3:09 PM, Chunjing Jia <jiacju...@gmail.com> wrote:

> Hi,
>
> I am running Django 2.0 tutorial01 for polls. I am seeing this error
> message
>
> Using the URLconf defined in mysite.urls, Django tried these URL
> patterns, in this order:
>
>1. polls/
>2. admin/
>
> The empty path didn't match any of these.
>
> Without adding polls, my code works fine, and I can see the rocket and
> congratulation page. But after adding polls, I always get this error
> message. Even if I use the example code that I found from github with the
> all the correct setting...
>
> Does this mean that my installation for Python3 and Django 2.0 may be
> problematic? What other possibles error may be here?
>
> Thanks a lot!
>
> Best,
> CJ
>
> --
> 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/7663c42a-06fc-4fc5-9604-dd92143c7ab3%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/7663c42a-06fc-4fc5-9604-dd92143c7ab3%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Running polls tutorial, see the error message "The empty path didn't match any of these."

2018-02-24 Thread Chunjing Jia
Hi,

I am running Django 2.0 tutorial01 for polls. I am seeing this error 
message 

Using the URLconf defined in mysite.urls, Django tried these URL patterns, 
in this order:

   1. polls/
   2. admin/

The empty path didn't match any of these.

Without adding polls, my code works fine, and I can see the rocket and 
congratulation page. But after adding polls, I always get this error 
message. Even if I use the example code that I found from github with the 
all the correct setting... 

Does this mean that my installation for Python3 and Django 2.0 may be 
problematic? What other possibles error may be here? 

Thanks a lot!

Best,
CJ

-- 
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/7663c42a-06fc-4fc5-9604-dd92143c7ab3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Tutorial 2 - Ver2.0 - python manage.py makemigrations polls - Error message when running

2018-02-04 Thread Daniel Hepper
Hi, you have a typo in your models.py in this line:

 votes = models.InterferField(default=0)

It should be IntegerField.

Cheers,
Daniel

CanuckT  schrieb am So. 4. Feb. 2018 um 21:06:

> Hi,  new to programming and trying the tutorial out for Django.
>
> Using this guide:  https://docs.djangoproject.com/en/2.0/intro/tutorial02/
>
> Running this command:  python manage.py makemigrations polls
>
> I get this output - way over my head. Any ideas?
> (I have tried changing the settings.py INSTALLED_APPS to just 'polls' as
> suggested in some other posts, same results.
>
> Thanks!
>
>
> Traceback (most recent call last):
>
>   File "manage.py", line 15, in 
>
> execute_from_command_line(sys.argv)
>
>   File
> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/__init__.py",
> line 371, in execute_from_command_line
>
> utility.execute()
>
>   File
> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/__init__.py",
> line 347, in execute
>
> django.setup()
>
>   File
> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/__init__.py",
> line 24, in setup
>
> apps.populate(settings.INSTALLED_APPS)
>
>   File
> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/apps/registry.py",
> line 112, in populate
>
> app_config.import_models()
>
>   File
> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/apps/config.py",
> line 198, in import_models
>
> self.models_module = import_module(models_module_name)
>
>   File
> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py",
> line 126, in import_module
>
> return _bootstrap._gcd_import(name[level:], package, level)
>
>   File "", line 994, in _gcd_import
>
>   File "", line 971, in _find_and_load
>
>   File "", line 955, in
> _find_and_load_unlocked
>
>   File "", line 665, in _load_unlocked
>
>   File "", line 678, in exec_module
>
>   File "", line 219, in
> _call_with_frames_removed
>
>   File "/Users/tdehnke/djlearn/mysite/polls/models.py", line 9, in 
>
> class Choice(models.Model):
>
>   File "/Users/tdehnke/djlearn/mysite/polls/models.py", line 12, in Choice
>
> votes = models.InterferField(default=0)
>
> AttributeError: module 'django.db.models' has no attribute 'InterferField'
>
> --
> 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/aa4a1ae5-8dfa-4eab-a739-14ed87ec5f05%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Tutorial 2 - Ver2.0 - python manage.py makemigrations polls - Error message when running

2018-02-04 Thread CanuckT
Hi,  new to programming and trying the tutorial out for Django.

Using this guide:  https://docs.djangoproject.com/en/2.0/intro/tutorial02/

Running this command:  python manage.py makemigrations polls

I get this output - way over my head. Any ideas?
(I have tried changing the settings.py INSTALLED_APPS to just 'polls' as 
suggested in some other posts, same results.

Thanks!


Traceback (most recent call last):

  File "manage.py", line 15, in 

execute_from_command_line(sys.argv)

  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/__init__.py",
 
line 371, in execute_from_command_line

utility.execute()

  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/__init__.py",
 
line 347, in execute

django.setup()

  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/__init__.py",
 
line 24, in setup

apps.populate(settings.INSTALLED_APPS)

  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/apps/registry.py",
 
line 112, in populate

app_config.import_models()

  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/apps/config.py",
 
line 198, in import_models

self.models_module = import_module(models_module_name)

  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py",
 
line 126, in import_module

return _bootstrap._gcd_import(name[level:], package, level)

  File "", line 994, in _gcd_import

  File "", line 971, in _find_and_load

  File "", line 955, in _find_and_load_unlocked

  File "", line 665, in _load_unlocked

  File "", line 678, in exec_module

  File "", line 219, in 
_call_with_frames_removed

  File "/Users/tdehnke/djlearn/mysite/polls/models.py", line 9, in 

class Choice(models.Model):

  File "/Users/tdehnke/djlearn/mysite/polls/models.py", line 12, in Choice

votes = models.InterferField(default=0)

AttributeError: module 'django.db.models' has no attribute 'InterferField'

-- 
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/aa4a1ae5-8dfa-4eab-a739-14ed87ec5f05%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: do i always have to reload/return render a page to show the errors? if i press go back on browser, i see screens with the error message

2017-11-03 Thread fábio andrews rocha marques
I'm using python code to verify the fields. I'm doing it on a View. But 
with javascript maybe I can solve this issue where i don't need to reload 
the page. But if i do that, can i do things like check the database to see 
if it already contains some value? Or store something on request.session 
for later?

On Thursday, November 2, 2017 at 6:43:18 PM UTC-3, James Schneider wrote:
>
>
>
> On Thu, Nov 2, 2017 at 12:57 PM, fábio andrews rocha marques <
> fabioandrews...@gmail.com > wrote:
>
>> To use django forms is to use the django Form class and it's components 
>> on a view? How will this solve the issue? If i use the components, don't i 
>> have to re-render the page when a user makes an error on the form?
>>
>>
> Are you submitting and rendering the information entirely via JavaScript? 
> That would be the only case where you may get errant messages on the same 
> page where the user submitted the form. You'll need to examine your JS 
> workflow, as that is not a Django issue.  
>
> You'll integrate the form usage within your view. The Django tutorial 
> covers this using both function-based views and class-based views. You 
> should do this even when submitting the information via AJAX/JS, but the 
> page doesn't necessarily need to be redirected because your JS will handle 
> re-rendering the page properly. I'd recommend the Django Rest Framework 
> package in that case. 
>
> -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/f089a104-ed0e-4ae0-9567-668e4422fb57%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: do i always have to reload/return render a page to show the errors? if i press go back on browser, i see screens with the error message

2017-11-02 Thread James Schneider
On Thu, Nov 2, 2017 at 12:57 PM, fábio andrews rocha marques <
fabioandrewsrochamarq...@gmail.com> wrote:

> To use django forms is to use the django Form class and it's components on
> a view? How will this solve the issue? If i use the components, don't i
> have to re-render the page when a user makes an error on the form?
>
>
Are you submitting and rendering the information entirely via JavaScript?
That would be the only case where you may get errant messages on the same
page where the user submitted the form. You'll need to examine your JS
workflow, as that is not a Django issue.

You'll integrate the form usage within your view. The Django tutorial
covers this using both function-based views and class-based views. You
should do this even when submitting the information via AJAX/JS, but the
page doesn't necessarily need to be redirected because your JS will handle
re-rendering the page properly. I'd recommend the Django Rest Framework
package in that case.

-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%2BciVaD43g-u4tXc_Org%3DnX6%2BJuAdu1w%3Dtq0viQ9RA5gWYvQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: do i always have to reload/return render a page to show the errors? if i press go back on browser, i see screens with the error message

2017-11-02 Thread fábio andrews rocha marques
To use django forms is to use the django Form class and it's components on 
a view? How will this solve the issue? If i use the components, don't i 
have to re-render the page when a user makes an error on the form?

On Tuesday, October 31, 2017 at 7:50:38 PM UTC-3, James Schneider wrote:
>
>
>
> On Oct 30, 2017 4:46 PM, "fábio andrews rocha marques" <
> fabioandrews...@gmail.com > wrote:
>
> Let's say i have a "register a new user" View and on this page, when the 
> user forgets to inform a password or a username, i show a message to him on 
> the same page saying "you forgot the password". The way i do this is by 
> doing this(on my View.py in a function called cadastrarprofessor):
>
> nomeusuario = request.POST['usuario'] #username
> nomesenha = request.POST['senha'] #password
> nomeemail = request.POST['email'] #email
>
> if not nomeusuario:
> return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': 
> False, 'error_message': "informe um usuário", 
> 'nomeemailcadastro':nomeemail, 'nomesenhacadastro':nomesenha})
> elif not nomesenha:
> return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': 
> False, 'error_message': "informe uma senha", 'nomeemailcadastro':nomeemail, 
> 'nomeusuariocadastro':nomeusuario})
> elif not nomeemail:
> return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': 
> False, 'error_message': "informe um email", 'nomesenhacadastro':nomesenha, 
> 'nomeusuariocadastro':nomeusuario})
>
> And my template for this page(cadastro.html) is like this:
> 
> Cadastro
> 
> {% csrf_token %}
> Usuário: 
> {% if nomeusuariocadastro %}
>  nomeusuariocadastro }}>
> {% else %}
> 
> {% endif %}
>
>
> ... (DO THE SAME TO SENHA/PASSWORD AND EMAIL)
>
> 
> 
> 
> 
> {% csrf_token %}
> 
> {% if cadastrorealizadocomsucesso is True %}cadastro realizado com 
> sucesso!{% endif %}
> {% if error_message %}{{ error_message }}{% endif 
> %}
>
> So, every time the user forgets to mention a username or email or password 
> in this screen, i use render to redirect the user to the same page but this 
> time displaying a error_message. Let's say he did forget to fill the 
> textfield with a username... he goes back to the same page and sees the 
> error message. After that, let's say everything is right and he finally 
> registers a new user, he sees "cadastro realizado com sucesso"(sucessfully 
> registered new user) and stays on the same page. But when he goes back a 
> page(pressing "back" on the browser), instead of going back to the page 
> before the cadastro.html, he goes back to the same page cadastro.html but 
> displaying the error message for the "you forgot to mention your username". 
> I don't want him to go back to the same page with error message, i want to 
> make him go back to my main menu. 
>
>
> There is very little that you can do to prevent this type of behavior when 
> the user presses the back button.
>
> After the user successfully authenticates, they should be redirected to 
> the proper landing page by using an HTTP 302 redirect. This is very common 
> and baked in to all of the generic form handling views provided by Django. 
> If the page is redirected, then the user will encounter a warning pop up 
> from the browser asking if they want to resubmit the data. Generally this 
> is enough to scare users away from using the back button, but even if they 
> do continue through the warning, they'll simply reauthenticate and be 
> redirected to the same landing page, again.
>
> If that is not happening, them your form processing workflow is incorrect.
>
> From your view, you aren't using Django forms at all. I would highly 
> encourage you to do so, especially to better understand how form data 
> should be processed and validated, and how to properly handle responses 
> back to the client. The Django tutorial covers this topic. 
>
> -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/9875e51c-ede8-4a9b-890a-75da0e8c0183%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: do i always have to reload/return render a page to show the errors? if i press go back on browser, i see screens with the error message

2017-10-31 Thread Matthew Pava
Hmmm, yes, I have a slightly different situation then.
You might want to employ something with the query string.  Django, by default, 
uses “next” as a parameter on the Login screen.  When the user successfully 
logs in, they are redirected to the URL specified in the “next” GET parameter.  
It doesn’t address the issue of pressing the Back button, but the user may be 
discouraged from pressing the back button if they actually end up on the page 
that they were expecting to be at in the first place.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of fábio andrews rocha marques
Sent: Tuesday, October 31, 2017 1:02 PM
To: Django users
Subject: Re: do i always have to reload/return render a page to show the 
errors? if i press go back on browser, i see screens with the error message

How did you use the never_cache? Because if i just put @never_cache before the 
def of my view: def cadastrarprofessor(request):, it's like it doesn't do 
anything (i am on the login page, I go to the registration page, inform a name 
of a user that already exists, click "register", the system refreshes the page 
telling me that the user already exists and when i press the "back button" from 
the browser, it goes back to the registration page with empty fields, which is 
not what iwant. I want to go back to the login page, the page before the 
registration). Do I have to use @never_cache and remove all the return render 
from my function? What should i return instead?
On Tuesday, October 31, 2017 at 2:46:01 PM UTC-3, Matthew Pava wrote:
I had a similar issue and even tried using sessions, but I eventually found 
that never_cache worked beautifully for me.  I didn’t have to worry about 
sessions any more.

From: django...@googlegroups.com 
[mailto:django...@googlegroups.com] On Behalf Of fábio andrews 
rocha marques
Sent: Tuesday, October 31, 2017 12:19 PM
To: Django users
Subject: Re: do i always have to reload/return render a page to show the 
errors? if i press go back on browser, i see screens with the error message

I found this topic within stackoverflow: 
https://stackoverflow.com/questions/10906548/django-redirect-behavior-with-back-button

 that seems to me that the user was having the same problem as i am. The only 
answer i found could work was from magicTuscan, but he just said "I would save 
the last site path as a session, then retrieve via the view when the page is 
called again via the back button". I've tried to contact him but didn't get an 
answer. Is it possible to override the "browser back button" behavior on django 
using sessions?
--
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 djang...@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/3ad05d02-cecd-4560-9654-82d2ed1106ca%40googlegroups.com<https://groups.google.com/d/msgid/django-users/3ad05d02-cecd-4560-9654-82d2ed1106ca%40googlegroups.com?utm_medium=email_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/fa86e291-ad2e-4b5a-b78a-1e98327189ce%40googlegroups.com<https://groups.google.com/d/msgid/django-users/fa86e291-ad2e-4b5a-b78a-1e98327189ce%40googlegroups.com?utm_medium=email_source=footer>.
For more options, visit https://groups.google.com/d/optout.

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


Re: do i always have to reload/return render a page to show the errors? if i press go back on browser, i see screens with the error message

2017-10-31 Thread James Schneider
On Oct 31, 2017 11:02 AM, "fábio andrews rocha marques" <
fabioandrewsrochamarq...@gmail.com> wrote:

How did you use the never_cache? Because if i just put @never_cache before
the def of my view: def cadastrarprofessor(request):, it's like it doesn't
do anything (i am on the login page, I go to the registration page, inform
a name of a user that already exists, click "register", the system
refreshes the page telling me that the user already exists and when i press
the "back button" from the browser, it goes back to the registration page
with empty fields, which is not what iwant. I want to go back to the login
page, the page before the registration). Do I have to use @never_cache and
remove all the return render from my function? What should i return instead?


I would recommend you remove any modifications related to caching. Caching
is not your issue, and in most cases should only be tuned in specific
circumstances, and after your intended functionality is implemented and
working. Refer to my other thread for a different direction.

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


Re: do i always have to reload/return render a page to show the errors? if i press go back on browser, i see screens with the error message

2017-10-31 Thread James Schneider
On Oct 30, 2017 4:46 PM, "fábio andrews rocha marques" <
fabioandrewsrochamarq...@gmail.com> wrote:

Let's say i have a "register a new user" View and on this page, when the
user forgets to inform a password or a username, i show a message to him on
the same page saying "you forgot the password". The way i do this is by
doing this(on my View.py in a function called cadastrarprofessor):

nomeusuario = request.POST['usuario'] #username
nomesenha = request.POST['senha'] #password
nomeemail = request.POST['email'] #email

if not nomeusuario:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso':
False, 'error_message': "informe um usuário",
'nomeemailcadastro':nomeemail, 'nomesenhacadastro':nomesenha})
elif not nomesenha:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso':
False, 'error_message': "informe uma senha", 'nomeemailcadastro':nomeemail,
'nomeusuariocadastro':nomeusuario})
elif not nomeemail:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso':
False, 'error_message': "informe um email", 'nomesenhacadastro':nomesenha,
'nomeusuariocadastro':nomeusuario})

And my template for this page(cadastro.html) is like this:

Cadastro

{% csrf_token %}
Usuário: 
{% if nomeusuariocadastro %}

{% else %}

{% endif %}


... (DO THE SAME TO SENHA/PASSWORD AND EMAIL)





{% csrf_token %}

{% if cadastrorealizadocomsucesso is True %}cadastro realizado com
sucesso!{% endif %}
{% if error_message %}{{ error_message }}{% endif %}

So, every time the user forgets to mention a username or email or password
in this screen, i use render to redirect the user to the same page but this
time displaying a error_message. Let's say he did forget to fill the
textfield with a username... he goes back to the same page and sees the
error message. After that, let's say everything is right and he finally
registers a new user, he sees "cadastro realizado com sucesso"(sucessfully
registered new user) and stays on the same page. But when he goes back a
page(pressing "back" on the browser), instead of going back to the page
before the cadastro.html, he goes back to the same page cadastro.html but
displaying the error message for the "you forgot to mention your username".
I don't want him to go back to the same page with error message, i want to
make him go back to my main menu.


There is very little that you can do to prevent this type of behavior when
the user presses the back button.

After the user successfully authenticates, they should be redirected to the
proper landing page by using an HTTP 302 redirect. This is very common and
baked in to all of the generic form handling views provided by Django. If
the page is redirected, then the user will encounter a warning pop up from
the browser asking if they want to resubmit the data. Generally this is
enough to scare users away from using the back button, but even if they do
continue through the warning, they'll simply reauthenticate and be
redirected to the same landing page, again.

If that is not happening, them your form processing workflow is incorrect.

>From your view, you aren't using Django forms at all. I would highly
encourage you to do so, especially to better understand how form data
should be processed and validated, and how to properly handle responses
back to the client. The Django tutorial covers this topic.

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


Re: do i always have to reload/return render a page to show the errors? if i press go back on browser, i see screens with the error message

2017-10-31 Thread fábio andrews rocha marques
How did you use the never_cache? Because if i just put @never_cache before 
the def of my view: def cadastrarprofessor(request):, it's like it doesn't 
do anything (i am on the login page, I go to the registration page, inform 
a name of a user that already exists, click "register", the system 
refreshes the page telling me that the user already exists and when i press 
the "back button" from the browser, it goes back to the registration page 
with empty fields, which is not what iwant. I want to go back to the login 
page, the page before the registration). Do I have to use @never_cache and 
remove all the return render from my function? What should i return instead?
On Tuesday, October 31, 2017 at 2:46:01 PM UTC-3, Matthew Pava wrote:
>
> I had a similar issue and even tried using sessions, but I eventually 
> found that never_cache worked beautifully for me.  I didn’t have to worry 
> about sessions any more.
>
>  
>
> *From:* django...@googlegroups.com  [mailto:
> django...@googlegroups.com ] *On Behalf Of *fábio andrews 
> rocha marques
> *Sent:* Tuesday, October 31, 2017 12:19 PM
> *To:* Django users
> *Subject:* Re: do i always have to reload/return render a page to show 
> the errors? if i press go back on browser, i see screens with the error 
> message
>
>  
>
> I found this topic within stackoverflow: 
> https://stackoverflow.com/questions/10906548/django-redirect-behavior-with-back-button
>
>  
>
>  that seems to me that the user was having the same problem as i am. The 
> only answer i found could work was from magicTuscan, but he just said "I 
> would save the last site path as a session, then retrieve via the view when 
> the page is called again via the back button". I've tried to contact him 
> but didn't get an answer. Is it possible to override the "browser back 
> button" behavior on django using sessions?
>
> -- 
> 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 djang...@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/3ad05d02-cecd-4560-9654-82d2ed1106ca%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/3ad05d02-cecd-4560-9654-82d2ed1106ca%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


RE: do i always have to reload/return render a page to show the errors? if i press go back on browser, i see screens with the error message

2017-10-31 Thread Matthew Pava
I had a similar issue and even tried using sessions, but I eventually found 
that never_cache worked beautifully for me.  I didn’t have to worry about 
sessions any more.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of fábio andrews rocha marques
Sent: Tuesday, October 31, 2017 12:19 PM
To: Django users
Subject: Re: do i always have to reload/return render a page to show the 
errors? if i press go back on browser, i see screens with the error message

I found this topic within stackoverflow: 
https://stackoverflow.com/questions/10906548/django-redirect-behavior-with-back-button

 that seems to me that the user was having the same problem as i am. The only 
answer i found could work was from magicTuscan, but he just said "I would save 
the last site path as a session, then retrieve via the view when the page is 
called again via the back button". I've tried to contact him but didn't get an 
answer. Is it possible to override the "browser back button" behavior on django 
using sessions?
--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/3ad05d02-cecd-4560-9654-82d2ed1106ca%40googlegroups.com<https://groups.google.com/d/msgid/django-users/3ad05d02-cecd-4560-9654-82d2ed1106ca%40googlegroups.com?utm_medium=email_source=footer>.
For more options, visit https://groups.google.com/d/optout.

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


Re: do i always have to reload/return render a page to show the errors? if i press go back on browser, i see screens with the error message

2017-10-31 Thread fábio andrews rocha marques
I found this topic within 
stackoverflow: 
https://stackoverflow.com/questions/10906548/django-redirect-behavior-with-back-button

 that seems to me that the user was having the same problem as i am. The 
only answer i found could work was from magicTuscan, but he just said "I 
would save the last site path as a session, then retrieve via the view when 
the page is called again via the back button". I've tried to contact him 
but didn't get an answer. Is it possible to override the "browser back 
button" behavior on django using sessions?

-- 
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/3ad05d02-cecd-4560-9654-82d2ed1106ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: do i always have to reload/return render a page to show the errors? if i press go back on browser, i see screens with the error message

2017-10-31 Thread fábio andrews rocha marques
Yes, my code has an else condition that always returns a render. The 
error_message is populated according to the error made by the user, like 
"forgot your username","forgot password", "username already exists".

Since i always need to return an httpresponse or render in my django view, 
will the page always refresh?

Here's the full code of my view currently:

def cadastrarprofessor(request):
if 'terminarcadastroprofessor' in request.POST:
# if this is a POST request we need to process the form data
if request.method == 'POST':
nomeusuario = request.POST['usuario']
nomesenha = request.POST['senha']
nomeemail = request.POST['email']
print("nomeusuario:")
print(nomeusuario)
if not nomeusuario:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': 
False, 'error_message': "informe um usuário", 
'nomeemailcadastro':nomeemail, 'nomesenhacadastro':nomesenha})
elif not nomesenha:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': 
False, 'error_message': "informe uma senha", 'nomeemailcadastro':nomeemail, 
'nomeusuariocadastro':nomeusuario})
elif not nomeemail:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': 
False, 'error_message': "informe um email", 'nomesenhacadastro':nomesenha, 
'nomeusuariocadastro':nomeusuario})
elif User.objects.filter(username=nomeusuario).exists():
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': 
False, 'error_message': "nome de usuário já existe", 
'nomesenhacadastro':nomesenha, 'nomeusuariocadastro':nomeusuario, 
'nomeemailcadastro':nomeemail})
else:
usuarionovo = User.objects.create_user(nomeusuario, nomeemail, nomesenha)
novoprofessor = Professor(user=usuarionovo,nome=nomeusuario)
novoprofessor.save()
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': True})
else:
return render(request,'index.html')
else:
#vou para tela do inicio do cadastro. Era um link entao nao tem POST
return render(request, 
'cadastro.html',{'cadastrorealizadocomsucesso':False})





On Tuesday, October 31, 2017 at 1:47:31 PM UTC-3, Matthew Pava wrote:
>
> > to do this, i just have to put the @never_cache on my View's method, 
> right?
>
>  
>
> Yes.
>
>  
>
> Upon further investigation of your code, I suggest looking into Django 
> forms and utilizing them.  Also, you shouldn’t need to use two forms on 
> your log-in view.  The submit button should go inside the log-in form.
>
>  
>
> To get back to fixing your current code, do you have an else condition 
> that always returns a render?  And, yes, you need to return an HttpResponse 
> object in all of your view functions, which is returned by the render 
> function.  It looks like you are always populating ‘error_message,’ which 
> is why there is always an error_message rendered.
>
>  
>
> *From:* django...@googlegroups.com  [mailto:
> django...@googlegroups.com ] *On Behalf Of *fábio andrews 
> rocha marques
> *Sent:* Tuesday, October 31, 2017 11:06 AM
> *To:* Django users
> *Subject:* Re: do i always have to reload/return render a page to show 
> the errors? if i press go back on browser, i see screens with the error 
> message
>
>  
>
> to do this, i just have to put the @never_cache on my View's method, 
> right? (after importing 'from django.views.decorators.cache import 
> never_cache'). For some reason, when i did this, the page started and i 
> already got the message "usuário já existe"(username already exists) and 
> still the problem i stated occurred. Is it something i am doing wrong? 
> Like, i should remover the return renders from my function after putting 
> @never_cache?
>
> On Tuesday, October 31, 2017 at 11:25:28 AM UTC-3, Matthew Pava wrote:
>
> Try using the @never_cache decorator on your login view.
>
>
> https://docs.djangoproject.com/en/1.11/topics/http/decorators/#django.views.decorators.cache.never_cache
>
>  
>
>  
>
> *From:* django...@googlegroups.com [mailto:django...@googlegroups.com] *On 
> Behalf Of *fábio andrews rocha marques
> *Sent:* Tuesday, October 31, 2017 9:15 AM
> *To:* Django users
> *Subject:* Re: do i always have to reload/return render a page to show 
> the errors? if i press go back on browser, i see screens with the error 
> message
>
>  
>
> That's a great suggestion. Sure, it will help on situations where i just 
> want the fields to be completed. But there are some fields that require a 
> little more feedback than that. Like, if a username already exists... I 
> check if it already exists using a View and checking on the database. So, 
> after the View checks if the user already exists, i have to render the page 
> again to show the error. 
>
> On Tuesday, October 31, 2017 at 8:37:05 AM UTC-3, Eric Pascu

RE: do i always have to reload/return render a page to show the errors? if i press go back on browser, i see screens with the error message

2017-10-31 Thread Matthew Pava
> to do this, i just have to put the @never_cache on my View's method, right?

Yes.

Upon further investigation of your code, I suggest looking into Django forms 
and utilizing them.  Also, you shouldn’t need to use two forms on your log-in 
view.  The submit button should go inside the log-in form.

To get back to fixing your current code, do you have an else condition that 
always returns a render?  And, yes, you need to return an HttpResponse object 
in all of your view functions, which is returned by the render function.  It 
looks like you are always populating ‘error_message,’ which is why there is 
always an error_message rendered.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of fábio andrews rocha marques
Sent: Tuesday, October 31, 2017 11:06 AM
To: Django users
Subject: Re: do i always have to reload/return render a page to show the 
errors? if i press go back on browser, i see screens with the error message

to do this, i just have to put the @never_cache on my View's method, right? 
(after importing 'from django.views.decorators.cache import never_cache'). For 
some reason, when i did this, the page started and i already got the message 
"usuário já existe"(username already exists) and still the problem i stated 
occurred. Is it something i am doing wrong? Like, i should remover the return 
renders from my function after putting @never_cache?

On Tuesday, October 31, 2017 at 11:25:28 AM UTC-3, Matthew Pava wrote:
Try using the @never_cache decorator on your login view.
https://docs.djangoproject.com/en/1.11/topics/http/decorators/#django.views.decorators.cache.never_cache


From: django...@googlegroups.com 
[mailto:django...@googlegroups.com] On Behalf Of fábio andrews 
rocha marques
Sent: Tuesday, October 31, 2017 9:15 AM
To: Django users
Subject: Re: do i always have to reload/return render a page to show the 
errors? if i press go back on browser, i see screens with the error message

That's a great suggestion. Sure, it will help on situations where i just want 
the fields to be completed. But there are some fields that require a little 
more feedback than that. Like, if a username already exists... I check if it 
already exists using a View and checking on the database. So, after the View 
checks if the user already exists, i have to render the page again to show the 
error.

On Tuesday, October 31, 2017 at 8:37:05 AM UTC-3, Eric Pascual wrote:
Hello
Sorry or I misunderstood your problem but what about using the required field 
attribute ? It will make such controls and messages be handled directly on the 
client side.
Best regards.

Eric PASCUAL

Centre Scientifique et Technique du Bâtiment
290 route des Lucioles
06560 SOPHIA ANTIPOLIS
http://www.cstb.fr



From: django...@googlegroups.com<mailto:django...@googlegroups.com> 
[django...@googlegroups.com] on behalf of fábio andrews rocha marques 
[fabioandrews...@gmail.com]
Sent: Tuesday, October 31, 2017 00:46
To: Django users
Subject: do i always have to reload/return render a page to show the errors? if 
i press go back on browser, i see screens with the error message

Let's say i have a "register a new user" View and on this page, when the user 
forgets to inform a password or a username, i show a message to him on the same 
page saying "you forgot the password". The way i do this is by doing this(on my 
View.py in a function called cadastrarprofessor):

nomeusuario = request.POST['usuario'] #username
nomesenha = request.POST['senha'] #password
nomeemail = request.POST['email'] #email

if not nomeusuario:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': False, 
'error_message': "informe um usuário", 'nomeemailcadastro':nomeemail, 
'nomesenhacadastro':nomesenha})
elif not nomesenha:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': False, 
'error_message': "informe uma senha", 'nomeemailcadastro':nomeemail, 
'nomeusuariocadastro':nomeusuario})
elif not nomeemail:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': False, 
'error_message': "informe um email", 'nomesenhacadastro':nomesenha,

'nomeusuariocadastro':nomeusuario})

And my template for this page(cadastro.html) is like this:

Cadastro

{% csrf_token %}
Usuário: 
{% if nomeusuariocadastro %}

{% else %}

{% endif %}


... (DO THE SAME TO SENHA/PASSWORD AND EMAIL)





{% csrf_token %}

{% if cadastrorealizadocomsucesso is True %}cadastro realizado com 
sucesso!{% endif %}
{% if error_message %}{{ error_message }}{% endif %}

So, every time the user forgets to mention a username or email or password in 
this screen, i use render to redirect the user to the same page but this time 
displaying a error_message. Let's say he did forget to fill the textfield with 
a username... he goes back to the same page and sees the error message. After 
that, let's say everything is right 

Re: do i always have to reload/return render a page to show the errors? if i press go back on browser, i see screens with the error message

2017-10-31 Thread fábio andrews rocha marques
to do this, i just have to put the @never_cache on my View's method, right? 
(after importing 'from django.views.decorators.cache import never_cache'). 
For some reason, when i did this, the page started and i already got the 
message "usuário já existe"(username already exists) and still the problem 
i stated occurred. Is it something i am doing wrong? Like, i should remover 
the return renders from my function after putting @never_cache?

On Tuesday, October 31, 2017 at 11:25:28 AM UTC-3, Matthew Pava wrote:
>
> Try using the @never_cache decorator on your login view.
>
>
> https://docs.djangoproject.com/en/1.11/topics/http/decorators/#django.views.decorators.cache.never_cache
>
>  
>
>  
>
> *From:* django...@googlegroups.com  [mailto:
> django...@googlegroups.com ] *On Behalf Of *fábio andrews 
> rocha marques
> *Sent:* Tuesday, October 31, 2017 9:15 AM
> *To:* Django users
> *Subject:* Re: do i always have to reload/return render a page to show 
> the errors? if i press go back on browser, i see screens with the error 
> message
>
>  
>
> That's a great suggestion. Sure, it will help on situations where i just 
> want the fields to be completed. But there are some fields that require a 
> little more feedback than that. Like, if a username already exists... I 
> check if it already exists using a View and checking on the database. So, 
> after the View checks if the user already exists, i have to render the page 
> again to show the error. 
>
> On Tuesday, October 31, 2017 at 8:37:05 AM UTC-3, Eric Pascual wrote:
>
> Hello 
> Sorry or I misunderstood your problem but what about using the required 
> field attribute ? It will make such controls and messages be handled 
> directly on the client side. 
> Best regards. 
>
> Eric PASCUAL 
>
> Centre Scientifique et Technique du Bâtiment 
> 290 route des Lucioles 
> 06560 SOPHIA ANTIPOLIS 
> http://www.cstb.fr 
>
>
>  
> From: django...@googlegroups.com [django...@googlegroups.com] on behalf 
> of fábio andrews rocha marques [fabioandrews...@gmail.com] 
> Sent: Tuesday, October 31, 2017 00:46 
> To: Django users 
> Subject: do i always have to reload/return render a page to show the 
> errors? if i press go back on browser, i see screens with the error message 
>
> Let's say i have a "register a new user" View and on this page, when the 
> user forgets to inform a password or a username, i show a message to him on 
> the same page saying "you forgot the password". The way i do this is by 
> doing this(on my View.py in a function called cadastrarprofessor): 
>
> nomeusuario = request.POST['usuario'] #username 
> nomesenha = request.POST['senha'] #password 
> nomeemail = request.POST['email'] #email 
>
> if not nomeusuario: 
> return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': 
> False, 'error_message': "informe um usuário", 
> 'nomeemailcadastro':nomeemail, 'nomesenhacadastro':nomesenha}) 
> elif not nomesenha: 
> return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': 
> False, 'error_message': "informe uma senha", 'nomeemailcadastro':nomeemail, 
> 'nomeusuariocadastro':nomeusuario}) 
> elif not nomeemail: 
> return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': 
> False, 'error_message': "informe um email", 'nomesenhacadastro':nomesenha, 
>
> 'nomeusuariocadastro':nomeusuario}) 
>
> And my template for this page(cadastro.html) is like this: 
>  
> Cadastro 
>  
> {% csrf_token %} 
> Usuário:  
> {% if nomeusuariocadastro %} 
>  nomeusuariocadastro }}> 
> {% else %} 
>  
> {% endif %} 
>
>
> ... (DO THE SAME TO SENHA/PASSWORD AND EMAIL) 
>
>  
>  
>  
>  
> {% csrf_token %} 
>  
> {% if cadastrorealizadocomsucesso is True %}cadastro realizado com 
> sucesso!{% endif %} 
> {% if error_message %}{{ error_message }}{% endif 
> %} 
>
> So, every time the user forgets to mention a username or email or password 
> in this screen, i use render to redirect the user to the same page but this 
> time displaying a error_message. Let's say he did forget to fill the 
> textfield with a username... he goes back to the same page and sees the 
> error message. After that, let's say everything is right and he finally 
> registers a new user, he sees "cadastro realizado com sucesso"(sucessfully 
> registered new user) and stays on the same page. But when he goes back a 
> page(pressing "back" on the browser), instead of going back to the page 
> before the cadastro.html, he goes back to the same page cadastro.html but 
> displaying the error message for the "you 

RE: do i always have to reload/return render a page to show the errors? if i press go back on browser, i see screens with the error message

2017-10-31 Thread Matthew Pava
Try using the @never_cache decorator on your login view.
https://docs.djangoproject.com/en/1.11/topics/http/decorators/#django.views.decorators.cache.never_cache


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of fábio andrews rocha marques
Sent: Tuesday, October 31, 2017 9:15 AM
To: Django users
Subject: Re: do i always have to reload/return render a page to show the 
errors? if i press go back on browser, i see screens with the error message

That's a great suggestion. Sure, it will help on situations where i just want 
the fields to be completed. But there are some fields that require a little 
more feedback than that. Like, if a username already exists... I check if it 
already exists using a View and checking on the database. So, after the View 
checks if the user already exists, i have to render the page again to show the 
error.

On Tuesday, October 31, 2017 at 8:37:05 AM UTC-3, Eric Pascual wrote:
Hello
Sorry or I misunderstood your problem but what about using the required field 
attribute ? It will make such controls and messages be handled directly on the 
client side.
Best regards.

Eric PASCUAL

Centre Scientifique et Technique du Bâtiment
290 route des Lucioles
06560 SOPHIA ANTIPOLIS
http://www.cstb.fr



From: django...@googlegroups.com 
[django...@googlegroups.com] on behalf of fábio andrews rocha 
marques [fabioandrews...@gmail.com]
Sent: Tuesday, October 31, 2017 00:46
To: Django users
Subject: do i always have to reload/return render a page to show the errors? if 
i press go back on browser, i see screens with the error message

Let's say i have a "register a new user" View and on this page, when the user 
forgets to inform a password or a username, i show a message to him on the same 
page saying "you forgot the password". The way i do this is by doing this(on my 
View.py in a function called cadastrarprofessor):

nomeusuario = request.POST['usuario'] #username
nomesenha = request.POST['senha'] #password
nomeemail = request.POST['email'] #email

if not nomeusuario:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': False, 
'error_message': "informe um usuário", 'nomeemailcadastro':nomeemail, 
'nomesenhacadastro':nomesenha})
elif not nomesenha:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': False, 
'error_message': "informe uma senha", 'nomeemailcadastro':nomeemail, 
'nomeusuariocadastro':nomeusuario})
elif not nomeemail:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': False, 
'error_message': "informe um email", 'nomesenhacadastro':nomesenha,

'nomeusuariocadastro':nomeusuario})

And my template for this page(cadastro.html) is like this:

Cadastro

{% csrf_token %}
Usuário: 
{% if nomeusuariocadastro %}

{% else %}

{% endif %}


... (DO THE SAME TO SENHA/PASSWORD AND EMAIL)





{% csrf_token %}

{% if cadastrorealizadocomsucesso is True %}cadastro realizado com 
sucesso!{% endif %}
{% if error_message %}{{ error_message }}{% endif %}

So, every time the user forgets to mention a username or email or password in 
this screen, i use render to redirect the user to the same page but this time 
displaying a error_message. Let's say he did forget to fill the textfield with 
a username... he goes back to the same page and sees the error message. After 
that, let's say everything is right and he finally registers a new user, he 
sees "cadastro realizado com sucesso"(sucessfully registered new user) and 
stays on the same page. But when he goes back a page(pressing "back" on the 
browser), instead of going back to the page before the cadastro.html, he goes 
back to the same page cadastro.html but displaying the error message for the 
"you forgot to mention your username". I don't want him to go back to the same 
page with error message, i want to make him go back to my main menu.
Is there a better approach to display error messages on the same page instead 
of using return render like this:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': False, 
'error_message': "informe um usuário", 
'nomeemailcadastro':nomeemail,'nomesenhacadastro':nomesenha})
?


--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django...@googlegroups.com<mailto: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/3f70cd29-9edc-4272-a27e-534ee7f1e1a2%40googlegroups.com<https://groups.google.com/d/msgid/django-users/3f70cd29-9edc-4272-a27e-534ee7f1e1a2%40googlegrou

Re: do i always have to reload/return render a page to show the errors? if i press go back on browser, i see screens with the error message

2017-10-31 Thread fábio andrews rocha marques
That's a great suggestion. Sure, it will help on situations where i just 
want the fields to be completed. But there are some fields that require a 
little more feedback than that. Like, if a username already exists... I 
check if it already exists using a View and checking on the database. So, 
after the View checks if the user already exists, i have to render the page 
again to show the error. 

On Tuesday, October 31, 2017 at 8:37:05 AM UTC-3, Eric Pascual wrote:
>
> Hello 
> Sorry or I misunderstood your problem but what about using the required 
> field attribute ? It will make such controls and messages be handled 
> directly on the client side. 
> Best regards. 
>
> Eric PASCUAL 
>
> Centre Scientifique et Technique du Bâtiment 
> 290 route des Lucioles 
> 06560 SOPHIA ANTIPOLIS 
> http://www.cstb.fr 
>
>
>  
> From: django...@googlegroups.com  [django...@googlegroups.com 
> ] on behalf of fábio andrews rocha marques [
> fabioandrews...@gmail.com ] 
> Sent: Tuesday, October 31, 2017 00:46 
> To: Django users 
> Subject: do i always have to reload/return render a page to show the 
> errors? if i press go back on browser, i see screens with the error message 
>
> Let's say i have a "register a new user" View and on this page, when the 
> user forgets to inform a password or a username, i show a message to him on 
> the same page saying "you forgot the password". The way i do this is by 
> doing this(on my View.py in a function called cadastrarprofessor): 
>
> nomeusuario = request.POST['usuario'] #username 
> nomesenha = request.POST['senha'] #password 
> nomeemail = request.POST['email'] #email 
>
> if not nomeusuario: 
> return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': 
> False, 'error_message': "informe um usuário", 
> 'nomeemailcadastro':nomeemail, 'nomesenhacadastro':nomesenha}) 
> elif not nomesenha: 
> return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': 
> False, 'error_message': "informe uma senha", 'nomeemailcadastro':nomeemail, 
> 'nomeusuariocadastro':nomeusuario}) 
> elif not nomeemail: 
> return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': 
> False, 'error_message': "informe um email", 'nomesenhacadastro':nomesenha, 
>
> 'nomeusuariocadastro':nomeusuario}) 
>
> And my template for this page(cadastro.html) is like this: 
>  
> Cadastro 
>  
> {% csrf_token %} 
> Usuário:  
> {% if nomeusuariocadastro %} 
>  nomeusuariocadastro }}> 
> {% else %} 
>  
> {% endif %} 
>
>
> ... (DO THE SAME TO SENHA/PASSWORD AND EMAIL) 
>
>  
>  
>  
>  
> {% csrf_token %} 
>  
> {% if cadastrorealizadocomsucesso is True %}cadastro realizado com 
> sucesso!{% endif %} 
> {% if error_message %}{{ error_message }}{% endif 
> %} 
>
> So, every time the user forgets to mention a username or email or password 
> in this screen, i use render to redirect the user to the same page but this 
> time displaying a error_message. Let's say he did forget to fill the 
> textfield with a username... he goes back to the same page and sees the 
> error message. After that, let's say everything is right and he finally 
> registers a new user, he sees "cadastro realizado com sucesso"(sucessfully 
> registered new user) and stays on the same page. But when he goes back a 
> page(pressing "back" on the browser), instead of going back to the page 
> before the cadastro.html, he goes back to the same page cadastro.html but 
> displaying the error message for the "you forgot to mention your username". 
> I don't want him to go back to the same page with error message, i want to 
> make him go back to my main menu. 
> Is there a better approach to display error messages on the same page 
> instead of using return render like this: 
> return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': 
> False, 'error_message': "informe um usuário", 
> 'nomeemailcadastro':nomeemail,'nomesenhacadastro':nomesenha}) 
> ? 
>
>
> -- 
> 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  django-users+unsubscr...@googlegroups.com >. 
> To post to this group, send email to django...@googlegroups.com 
> <mailto: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/3f70cd29-9edc-4272-a27e-534ee7f1e1a2%40googlegroups.com

RE: do i always have to reload/return render a page to show the errors? if i press go back on browser, i see screens with the error message

2017-10-31 Thread PASCUAL Eric
Hello
Sorry or I misunderstood your problem but what about using the required field 
attribute ? It will make such controls and messages be handled directly on the 
client side. 
Best regards. 

Eric PASCUAL

Centre Scientifique et Technique du Bâtiment
290 route des Lucioles
06560 SOPHIA ANTIPOLIS
http://www.cstb.fr



From: django-users@googlegroups.com [django-users@googlegroups.com] on behalf 
of fábio andrews rocha marques [fabioandrewsrochamarq...@gmail.com]
Sent: Tuesday, October 31, 2017 00:46
To: Django users
Subject: do i always have to reload/return render a page to show the errors? if 
i press go back on browser, i see screens with the error message

Let's say i have a "register a new user" View and on this page, when the user 
forgets to inform a password or a username, i show a message to him on the same 
page saying "you forgot the password". The way i do this is by doing this(on my 
View.py in a function called cadastrarprofessor):

nomeusuario = request.POST['usuario'] #username
nomesenha = request.POST['senha'] #password
nomeemail = request.POST['email'] #email

if not nomeusuario:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': False, 
'error_message': "informe um usuário", 'nomeemailcadastro':nomeemail, 
'nomesenhacadastro':nomesenha})
elif not nomesenha:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': False, 
'error_message': "informe uma senha", 'nomeemailcadastro':nomeemail, 
'nomeusuariocadastro':nomeusuario})
elif not nomeemail:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': False, 
'error_message': "informe um email", 'nomesenhacadastro':nomesenha, 

'nomeusuariocadastro':nomeusuario})

And my template for this page(cadastro.html) is like this:

Cadastro

{% csrf_token %}
Usuário: 
{% if nomeusuariocadastro %}

{% else %}

{% endif %}


... (DO THE SAME TO SENHA/PASSWORD AND EMAIL)





{% csrf_token %}

{% if cadastrorealizadocomsucesso is True %}cadastro realizado com 
sucesso!{% endif %}
{% if error_message %}{{ error_message }}{% endif %}

So, every time the user forgets to mention a username or email or password in 
this screen, i use render to redirect the user to the same page but this time 
displaying a error_message. Let's say he did forget to fill the textfield with 
a username... he goes back to the same page and sees the error message. After 
that, let's say everything is right and he finally registers a new user, he 
sees "cadastro realizado com sucesso"(sucessfully registered new user) and 
stays on the same page. But when he goes back a page(pressing "back" on the 
browser), instead of going back to the page before the cadastro.html, he goes 
back to the same page cadastro.html but displaying the error message for the 
"you forgot to mention your username". I don't want him to go back to the same 
page with error message, i want to make him go back to my main menu.
Is there a better approach to display error messages on the same page instead 
of using return render like this:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': False, 
'error_message': "informe um usuário", 
'nomeemailcadastro':nomeemail,'nomesenhacadastro':nomesenha})
?


--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/3f70cd29-9edc-4272-a27e-534ee7f1e1a2%40googlegroups.com<https://groups.google.com/d/msgid/django-users/3f70cd29-9edc-4272-a27e-534ee7f1e1a2%40googlegroups.com?utm_medium=email_source=footer>.
For more options, visit https://groups.google.com/d/optout.

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


do i always have to reload/return render a page to show the errors? if i press go back on browser, i see screens with the error message

2017-10-30 Thread fábio andrews rocha marques
Let's say i have a "register a new user" View and on this page, when the 
user forgets to inform a password or a username, i show a message to him on 
the same page saying "you forgot the password". The way i do this is by 
doing this(on my View.py in a function called cadastrarprofessor):

nomeusuario = request.POST['usuario'] #username
nomesenha = request.POST['senha'] #password
nomeemail = request.POST['email'] #email

if not nomeusuario:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': 
False, 'error_message': "informe um usuário", 
'nomeemailcadastro':nomeemail, 'nomesenhacadastro':nomesenha})
elif not nomesenha:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': 
False, 'error_message': "informe uma senha", 'nomeemailcadastro':nomeemail, 
'nomeusuariocadastro':nomeusuario})
elif not nomeemail:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': 
False, 'error_message': "informe um email", 'nomesenhacadastro':nomesenha, 
'nomeusuariocadastro':nomeusuario})

And my template for this page(cadastro.html) is like this:

Cadastro

{% csrf_token %}
Usuário: 
{% if nomeusuariocadastro %}

{% else %}

{% endif %}


... (DO THE SAME TO SENHA/PASSWORD AND EMAIL)





{% csrf_token %}

{% if cadastrorealizadocomsucesso is True %}cadastro realizado com 
sucesso!{% endif %}
{% if error_message %}{{ error_message }}{% endif %}

So, every time the user forgets to mention a username or email or password 
in this screen, i use render to redirect the user to the same page but this 
time displaying a error_message. Let's say he did forget to fill the 
textfield with a username... he goes back to the same page and sees the 
error message. After that, let's say everything is right and he finally 
registers a new user, he sees "cadastro realizado com sucesso"(sucessfully 
registered new user) and stays on the same page. But when he goes back a 
page(pressing "back" on the browser), instead of going back to the page 
before the cadastro.html, he goes back to the same page cadastro.html but 
displaying the error message for the "you forgot to mention your username". 
I don't want him to go back to the same page with error message, i want to 
make him go back to my main menu. 
Is there a better approach to display error messages on the same page 
instead of using return render like this:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': False,
 'error_message': "informe um usuário", 'nomeemailcadastro':nomeemail,
'nomesenhacadastro':nomesenha})
?

-- 
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/3f70cd29-9edc-4272-a27e-534ee7f1e1a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error message on 'django.urls.exceptions.NoReverseMatch'

2017-07-31 Thread ron_w_add via Django users
Hello James

Thanks for your help. That solved the problem.

Ron

>
>

-- 
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/51c4118b-c881-4e08-b083-5db2ef674702%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error message on 'django.urls.exceptions.NoReverseMatch'

2017-07-30 Thread James Schneider
On Jul 30, 2017 12:06 AM, "ron_w_add via Django users" <
django-users@googlegroups.com> wrote:

I have started writing a page to to display a photo. This page correctly
display the photo data (nb. no photo added yet) as well as the ‘Invalid
item ID’ message if an invalid value has been requested. The HTML code is
in ‘photos.html’ is as follows:




I am now trying to start testing the above function by using the following
test function in tests_views.py:


class PhotosByLocationIndexViewTests(TestCase):

 """

 testing 'def photo(requeset)'

 """

 def test_for_no_photos_in_photos(self):

   # 'photourl' is in 'wlp_app/urls.py'

   response = self.client.get(reverse('photourl'))




The above line is your issue. See below.


The ‘photourl’ name that is called by the ‘reverse’ function above is in
the urls.py:


urlpatterns = [

 url(r'^$', views.index, name='indexurl'),

 url(r'^photo/(?P[0-9]+)/$', views.photo, name='photourl')

]


Per the urls.py above, you need to provide a value for the photo_id to
reverse() as an arg or kwarg, otherwise Django has no way to know which
photo you are referring to, and therefore can't generate the URL.

See the following for proper usage of reverse() with examples.

https://docs.djangoproject.com/en/1.11/ref/urlresolvers/#reverse

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


Re: When I migrate the database, I get this get error message: django.db.migrations.exceptions.NodeNotFoundError.

2016-12-26 Thread hemanth pedhinti
Hai,
I Think Its better to delete migration files except 001_initial.py and
_init_.py and again do makemigrations.

Thank you,
P.Hemanth.

On Fri, Dec 23, 2016 at 11:42 PM, skerdi  wrote:

> I have deleted the database, migrations, .pyc files, upgraded and
> downgraded Django.
> I'm not able to fix it.
> Any suggestions, please?
>
> System check identified no issues (0 silenced).
> Unhandled exception in thread started by  0x03B51AC8>
> Traceback (most recent call last):
>   File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line
> 226, in wrapper
> fn(*args, **kwargs)
>   File "C:\Python27\lib\site-packages\django\core\
> management\commands\runserver.py", line 124, in inner_run
> self.check_migrations()
>   File "C:\Python27\lib\site-packages\django\core\management\base.py",
> line 437, in check_migrations
> executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
>   File "C:\Python27\lib\site-packages\django\db\migrations\executor.py",
> line 20, in __init__
> self.loader = MigrationLoader(self.connection)
>   File "C:\Python27\lib\site-packages\django\db\migrations\loader.py",
> line 52, in __init__
> self.build_graph()
>   File "C:\Python27\lib\site-packages\django\db\migrations\loader.py",
> line 268, in build_graph
> raise exc
> django.db.migrations.exceptions.NodeNotFoundError: Migration
> auth.0007_user_following dependencies reference nonexi
> stent parent node (u'account', u'0002_contact')
>
> --
> 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/4bc4571e-21bc-4530-85dd-ae7829b558e0%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


When I migrate the database, I get this get error message: django.db.migrations.exceptions.NodeNotFoundError.

2016-12-23 Thread skerdi
I have deleted the database, migrations, .pyc files, upgraded and 
downgraded Django.
I'm not able to fix it.
Any suggestions, please? 

System check identified no issues (0 silenced).
Unhandled exception in thread started by 
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 
226, in wrapper
fn(*args, **kwargs)
  File 
"C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", 
line 124, in inner_run
self.check_migrations()
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 
437, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
  File "C:\Python27\lib\site-packages\django\db\migrations\executor.py", 
line 20, in __init__
self.loader = MigrationLoader(self.connection)
  File "C:\Python27\lib\site-packages\django\db\migrations\loader.py", line 
52, in __init__
self.build_graph()
  File "C:\Python27\lib\site-packages\django\db\migrations\loader.py", line 
268, in build_graph
raise exc
django.db.migrations.exceptions.NodeNotFoundError: Migration 
auth.0007_user_following dependencies reference nonexi
stent parent node (u'account', u'0002_contact')

-- 
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/4bc4571e-21bc-4530-85dd-ae7829b558e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to return error message if the users call the ajax from othere than my webapp.

2016-01-20 Thread James Schneider
On Wed, Jan 20, 2016 at 1:33 AM, nullvoid  wrote:

> Hi,
>
> i am currently working on a project, in that project i written a api there
> is no user authentication stuffs anyone can access and there is some ajax
> call, when the ajax call happen my view will return a api output to the
> user. Is there any way user can call the api other than from my
> webapp(actually i did it in dev console in browser) if possible pls suggest
> some  way to avoid the ajax call from out side of the webapp.
>

CSRF protection would be your friend in this case, and would act as a
rudimentary gatekeeper to keep non-browser calls at bay. However, that
wouldn't stop someone from pulling down the web page, grabbing the CSRF
token from either the page itself, or from the session cookie, and then
using that to make calls. But if they go to that length, do you really care
at that point?

Without any sort of authentication mechanism, I'm not sure why you'd expect
to be protected from random external API calls if your site is publicly
available.

Also, what exactly are you trying to protect? Your server likely doesn't
know/care whether the API call is generated by a browser or from a CLI
command. If it's that important, implement user authentication or API key
authentication so that you know who is accessing your resources. But even
so, granted that you want them to only use the web application, any decent
programmer with enough motivation is going to figure out how to make the
calls in a programmatic fashion, since that's really all your JavaScript
AJAX calls are doing under the hood.

You didn't mention how you were developing this app, but if you are using
the Django REST Framework, both CSRF protection and authentication are
built-in and easy to implement. I'd imagine django-tastypie is similar.

TL;DR; Implement CSRF protection first in your web app, and then implement
authentication if you still aren't happy. That'll get you >95% of the way.

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


how to return error message if the users call the ajax from othere than my webapp.

2016-01-20 Thread nullvoid
Hi,

i am currently working on a project, in that project i written a api there 
is no user authentication stuffs anyone can access and there is some ajax 
call, when the ajax call happen my view will return a api output to the 
user. Is there any way user can call the api other than from my 
webapp(actually i did it in dev console in browser) if possible pls suggest 
some  way to avoid the ajax call from out side of the webapp.

-- 
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/4df16b49-095c-41fe-b4bd-352f272f5a74%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: confirm_login_allowed in subclassed authentication returns wrong error message

2015-02-22 Thread Tomáš Sekanina


Apologies, my mistake after all (as it is usually:)). I've just finally 
found out that the login function from django.contrib.auth uses my own 
template where this message is displayed whenever there is error in the 
form.

Dne úterý 17. února 2015 21:00:15 UTC+1 Tomáš Sekanina napsal(a):
>
> Hello, 
>
> I have a custom user model and I need to extend the user authentication 
> during login and found this solution: http://bit.ly/1u705o9  It would 
> work great for me and I ended up implementing this 
> <http://pastebin.com/1SVmumCs> . It works in a manner that it does not 
> let such user log in, but raises a different error message which is: 'Sorry, 
> that's not a valid username or password.'.  I tried posting this question 
> on different forums but got no answer :(. It seems really simple so I do 
> not see there a place for an error unless there is some problem with the 
> custom user model. I will be glad for your opinion at least :).
>
> Thank you in advance for any effort to solve this. 
>
>

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


Re: confirm_login_allowed in subclassed authentication returns wrong error message

2015-02-18 Thread Tomáš Sekanina
Thank you for your answer but I am not sure I understand your answer, can 
you explain why using the method described in docs does not work for this 
case? 

Dne úterý 17. února 2015 22:33:00 UTC+1 James Schneider napsal(a):
>
> You should raise the error in your custom user login form when attempting 
> to authenticate the user, not directly from the custom user model or 
> authentication backend.
>
> -James
> On Feb 17, 2015 12:20 PM, "Tomáš Sekanina" <sekanin...@gmail.com 
> > wrote:
>
>> Hello, 
>>
>> I have a custom user model and I need to extend the user authentication 
>> during login and found this solution: http://bit.ly/1u705o9  It would 
>> work great for me and I ended up implementing this 
>> <http://pastebin.com/1SVmumCs> . It works in a manner that it does not 
>> let such user log in, but raises a different error message which is: 'Sorry, 
>> that's not a valid username or password.'.  I tried posting this 
>> question on different forums but got no answer :(. It seems really simple 
>> so I do not see there a place for an error unless there is some problem 
>> with the custom user model. I will be glad for your opinion at least :).
>>
>> Thank you in advance for any effort to solve this. 
>>
>>  -- 
>> 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/49e6d5be-4a4c-411d-8476-e851ea8f3f2a%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/49e6d5be-4a4c-411d-8476-e851ea8f3f2a%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

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


Re: confirm_login_allowed in subclassed authentication returns wrong error message

2015-02-17 Thread James Schneider
You should raise the error in your custom user login form when attempting
to authenticate the user, not directly from the custom user model or
authentication backend.

-James
On Feb 17, 2015 12:20 PM, "Tomáš Sekanina" <sekanina.to...@gmail.com> wrote:

> Hello,
>
> I have a custom user model and I need to extend the user authentication
> during login and found this solution: http://bit.ly/1u705o9  It would
> work great for me and I ended up implementing this
> <http://pastebin.com/1SVmumCs> . It works in a manner that it does not
> let such user log in, but raises a different error message which is: 'Sorry,
> that's not a valid username or password.'.  I tried posting this question
> on different forums but got no answer :(. It seems really simple so I do
> not see there a place for an error unless there is some problem with the
> custom user model. I will be glad for your opinion at least :).
>
> Thank you in advance for any effort to solve this.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/49e6d5be-4a4c-411d-8476-e851ea8f3f2a%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/49e6d5be-4a4c-411d-8476-e851ea8f3f2a%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


confirm_login_allowed in subclassed authentication returns wrong error message

2015-02-17 Thread Tomáš Sekanina
Hello, 

I have a custom user model and I need to extend the user authentication 
during login and found this solution: http://bit.ly/1u705o9  It would work 
great for me and I ended up implementing this <http://pastebin.com/1SVmumCs> . 
It works in a manner that it does not let such user log in, but raises a 
different error message which is: 'Sorry, that's not a valid username or 
password.'.  I tried posting this question on different forums but got no 
answer :(. It seems really simple so I do not see there a place for an 
error unless there is some problem with the custom user model. I will be 
glad for your opinion at least :).

Thank you in advance for any effort to solve this. 

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


Re: [polls tutorial] error message not showing

2014-10-28 Thread otmeek
I completely missed that. Thank you!!

On Tuesday, 28 October 2014 20:20:14 UTC+1, Charly Román wrote:
>
> Import Choice in this file.
>
>
> 2014-10-28 13:06 GMT-06:00 otmeek <otm...@gmail.com >:
>
>> I am trying to follow part 4 of the polls app tutorial. I am new to 
>> Django and not very experienced with Python or programming in general.
>>
>> My problem is throwing an error message when "Vote" is pressed without a 
>> choice being selected.
>>
>> polls/views.py:
>> from django.shortcuts import render, get_object_or_404
>> from django.http import HttpResponse, HttpResponseRedirect
>> from django.template import RequestContext, loader
>> from django.core.urlresolvers import reverse
>>
>> from polls.models import Question
>>
>> def index(request):
>> latest_question_list = Question.objects.order_by('-pub_date')[:5]
>> template = loader.get_template('polls/index.html')
>> context = RequestContext(request, {
>> 'latest_question_list': latest_question_list,
>> })
>> return HttpResponse(template.render(context))
>>
>> def detail(request, question_id):
>> question = get_object_or_404(Question, pk=question_id)
>> return render(request, 'polls/detail.html', {'question': question})
>>
>> def results(request, question_id):
>> question = get_object_or_404(Question, pk=question_id)
>> return render(request, 'polls/results.html', {'question': question})
>>
>> def vote(request, question_id):
>> p = get_object_or_404(Question, pk=question_id)
>> try:
>> selected_choice = p.choice_set.get(pk=request.POST['choice'])
>> except (KeyError, Choice.DoesNotExist):
>> # Redisplay the question voting form.
>> return render(request, 'polls/detail.html', {
>> 'question': p,
>> 'error_message': "You didn't select a choice.",
>> })
>> else:
>> selected_choice.votes += 1
>> selected_choice.save()
>> # Always return an HttpResponseRedirect after successfully 
>> dealing
>> # with POST data. This prevents data from being posted twice if a
>> # user hits the Back button.
>> return HttpResponseRedirect(reverse('polls:results', args=(p.id
>> ,)))
>>
>> It is my understanding that when request.POST doesn't get a choice ID, it 
>> executes 'except', displaying the voting page again (detail.html) and an 
>> error message. However it simply displays "NameError global name 'Choice' 
>> is not defined" page.
>>
>> Can someone help me figure out what I'm doing 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...@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/0bf39ec4-709e-4ad8-85df-3a2aeb31c83d%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/0bf39ec4-709e-4ad8-85df-3a2aeb31c83d%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Charly Román
> Software Developer
> http://croman.mx
>  

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


Re: [polls tutorial] error message not showing

2014-10-28 Thread Charly Román
Import Choice in this file.


2014-10-28 13:06 GMT-06:00 otmeek <otm...@gmail.com>:

> I am trying to follow part 4 of the polls app tutorial. I am new to Django
> and not very experienced with Python or programming in general.
>
> My problem is throwing an error message when "Vote" is pressed without a
> choice being selected.
>
> polls/views.py:
> from django.shortcuts import render, get_object_or_404
> from django.http import HttpResponse, HttpResponseRedirect
> from django.template import RequestContext, loader
> from django.core.urlresolvers import reverse
>
> from polls.models import Question
>
> def index(request):
> latest_question_list = Question.objects.order_by('-pub_date')[:5]
> template = loader.get_template('polls/index.html')
> context = RequestContext(request, {
> 'latest_question_list': latest_question_list,
> })
> return HttpResponse(template.render(context))
>
> def detail(request, question_id):
> question = get_object_or_404(Question, pk=question_id)
> return render(request, 'polls/detail.html', {'question': question})
>
> def results(request, question_id):
> question = get_object_or_404(Question, pk=question_id)
> return render(request, 'polls/results.html', {'question': question})
>
> def vote(request, question_id):
> p = get_object_or_404(Question, pk=question_id)
> try:
> selected_choice = p.choice_set.get(pk=request.POST['choice'])
> except (KeyError, Choice.DoesNotExist):
> # Redisplay the question voting form.
> return render(request, 'polls/detail.html', {
> 'question': p,
> 'error_message': "You didn't select a choice.",
> })
> else:
> selected_choice.votes += 1
> selected_choice.save()
> # Always return an HttpResponseRedirect after successfully dealing
> # with POST data. This prevents data from being posted twice if a
> # user hits the Back button.
> return HttpResponseRedirect(reverse('polls:results', args=(p.id
> ,)))
>
> It is my understanding that when request.POST doesn't get a choice ID, it
> executes 'except', displaying the voting page again (detail.html) and an
> error message. However it simply displays "NameError global name 'Choice'
> is not defined" page.
>
> Can someone help me figure out what I'm doing 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/0bf39ec4-709e-4ad8-85df-3a2aeb31c83d%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/0bf39ec4-709e-4ad8-85df-3a2aeb31c83d%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Charly Román
Software Developer
http://croman.mx

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


[polls tutorial] error message not showing

2014-10-28 Thread otmeek
I am trying to follow part 4 of the polls app tutorial. I am new to Django 
and not very experienced with Python or programming in general.

My problem is throwing an error message when "Vote" is pressed without a 
choice being selected.

polls/views.py:
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponse, HttpResponseRedirect
from django.template import RequestContext, loader
from django.core.urlresolvers import reverse

from polls.models import Question

def index(request):
latest_question_list = Question.objects.order_by('-pub_date')[:5]
template = loader.get_template('polls/index.html')
context = RequestContext(request, {
'latest_question_list': latest_question_list,
})
return HttpResponse(template.render(context))

def detail(request, question_id):
question = get_object_or_404(Question, pk=question_id)
return render(request, 'polls/detail.html', {'question': question})

def results(request, question_id):
question = get_object_or_404(Question, pk=question_id)
return render(request, 'polls/results.html', {'question': question})

def vote(request, question_id):
p = get_object_or_404(Question, pk=question_id)
try:
selected_choice = p.choice_set.get(pk=request.POST['choice'])
except (KeyError, Choice.DoesNotExist):
# Redisplay the question voting form.
return render(request, 'polls/detail.html', {
'question': p,
'error_message': "You didn't select a choice.",
})
else:
selected_choice.votes += 1
selected_choice.save()
# Always return an HttpResponseRedirect after successfully dealing
# with POST data. This prevents data from being posted twice if a
# user hits the Back button.
return HttpResponseRedirect(reverse('polls:results', args=(p.id,)))

It is my understanding that when request.POST doesn't get a choice ID, it 
executes 'except', displaying the voting page again (detail.html) and an 
error message. However it simply displays "NameError global name 'Choice' 
is not defined" page.

Can someone help me figure out what I'm doing 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0bf39ec4-709e-4ad8-85df-3a2aeb31c83d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: python path in webpage error message not virtual environment's

2014-02-18 Thread Russell Keith-Magee
On Tue, Feb 18, 2014 at 1:11 PM, knowledge_seeker <
sanjivchristop...@gmail.com> wrote:

> I understand the importance of doing projects in virtual environments, but
> I am hitting one snag.
>
> When I have an error in django, and I get the generated webpage with an
> error message, it shows the 'normal' python path, site packages installed,
> etc. For example, I have jinja on my main installation, but not in the
> virtual environment. Yet, jinja shows up in this message as one of the site
> packages; similarly with the other python packages. Is there any way to
> show the python version (and location) and correct site-packages that are
> in the virtual environment in these error messages?
>

It sounds like you've built a virtualenv with --system-site-packages
enabled. If you've got an earlier version of virtualenv (IIRC, version 1.4
or earlier), this was the default option when you created a virtualenv.
When you construct a virtualenv in this way, it's an extension of your
system - so anything in your system PYTHONPATH will also show up in your
virtualenv.

If, on the other hand, you create your virtualenv with --no-site-packages
(which is the default on more recent versions of virtualenv), the
virtualenv is completely isolated. If you don't install a package in your
virtualenv, it won't be available.

To check what version of virtualenv you have, the usual --version flag
works; if you run --help, the description for --no-site-packages will tell
you whether it's the default or not.

As for checking where a package has come from -- if you're in a Python
shell, you can ask Python itself where it got a module. For example:

>>> import django
>>> django.__file__
'/Users/rkm/.virtualenvs/sample/lib/python2.7/site-packages/django/__init__.pyc'

tells you that I'm getting Django from the version installed in my "sample"
virtualenv.

I hope that helps.

Yours,
Russ Magee %-)

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


python path in webpage error message not virtual environment's

2014-02-17 Thread knowledge_seeker
I understand the importance of doing projects in virtual environments, but 
I am hitting one snag. 

When I have an error in django, and I get the generated webpage with an 
error message, it shows the 'normal' python path, site packages installed, 
etc. For example, I have jinja on my main installation, but not in the 
virtual environment. Yet, jinja shows up in this message as one of the site 
packages; similarly with the other python packages. Is there any way to 
show the python version (and location) and correct site-packages that are 
in the virtual environment in these error messages?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/59bfb435-e16f-47eb-90d2-55cc8ec02d0b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Display error message

2013-07-13 Thread Kakar Arunachal Service
Hi,
I have a site, that has a submit form, but one must be logged in for that.
And if the user is not logged in, it redirects it to the login page. And
this all fine. My question is, what do I do to display the error message,
"You must be logged to submit.", if the user is not logged in and tries to
submit the form, but has to display the normal login page if not.
Thank you.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: django login/registration validation error message issue

2013-03-11 Thread sri
Hi Tom,

Thanks for pointing me to docs.
I am able to display the error message now.
But because the page is being refreshed, the drop down is not visisble at 
first. When i click the register button again, then i can see the error 
message. Is there anyway i can show the registration drop down if errors 
exists.
My code now looks like below.

Views.py :-

   def register_view(request):
if request.method == 'POST':
form = UserCreationForm(data=request.POST, files=request.FILES)
if form.is_valid():
new_user = form.save()
new_user = authenticate(username=request.POST['username'],
password=request.POST['password1'])
login(request, new_user)
return HttpResponseRedirect(request.GET.get("next"))
else:
item_list = 
CoolStuff.objects.filter(show_on_website=True).order_by('-item_rank')
column_1_items_list = item_list.filter(column=ONE)
column_2_items_list = item_list.filter(column=TWO)
column_3_items_list = item_list.filter(column=THREE)
return render_to_response('homepage.html',
{'column_1_items_list': column_1_items_list,
'column_2_items_list': column_2_items_list,
 'column_3_items_list': column_3_items_list,
'register_form': form},
context_instance=RequestContext(request))
else:
return HttpResponseRedirect(reverse('coolstuff.views.homepage'))


base.html has the following for registration form :-

 
 
Register

{% csrf_token %}

  {{ register_form.non_field_errors }}

 
{% for field in register_form %}
  

  {{ field.errors }}

{{ field.label_tag }}
{{ field }}
  
{% endfor %}




   
   
  $(function() {
  // Setup drop down menu
  $('.dropdown-toggle').dropdown();
 
  // Fix input element click problem
  $('.dropdown input, .dropdown 
label').click(function(e) {
e.stopPropagation();
  });
  });
   
   


How can i make the drop down form for registration to be displayed 
automatically with errors rather than user clicking the button again. I 
think i will need to write javascript, but i am not sure how i can achieve 
it. Please suggest.

Thanks
Sreekanth

On Monday, 11 March 2013 14:36:56 UTC, Tom Evans wrote:
>
> On Mon, Mar 11, 2013 at 1:28 PM, sri <devanas...@gmail.com > 
> wrote: 
> > Hi, 
> > 
> > I am relatively new to Django and trying to create a Django application 
> > using 1.5 and created a pop up modal login and registration form using 
> > twitter bootstrap. The example i used to create the drop down 
> > login/registration form 
> > ishttp://mifsud.me/adding-dropdown-login-form-bootstraps-navbar/[1]<http://mifsud.me/adding-dropdown-login-form-bootstraps-navbar/%5B1%5D>.Now,
> >  
> > the problem i am having is that, how do i show any error messages 
> (password 
> > invalid etc) on the pop up login/registration drop down modal box. 
> > 
> > Here is my base.html file: 
> > 
> >  
> >
> >  > data-toggle="dropdown">Login 
> >  
> >  > method="post" class="form-horizontal">{% csrf_token %} 
> >  > style="margin-bottom: 15px;" type="text" name="email" size="30" /> 
> >  placeholder="Password" 
> > style="margin-bottom: 15px;" type="password" name="password" size="30" 
> /> 
> >  > value="Sign In" /> 
> >  
> >  
> >
> >
> >  > data-toggle="dropdown">Register 
> >  
> >  > method="post" class="form-horizontal" name="register_form">{% csrf_token 
> %} 
> > {{ register_form.non_field_errors }} 
> >  > style="margin-bottom: 15px;" type="text" name="email" size="30" /&

Re: django login/registration validation error message issue

2013-03-11 Thread Tom Evans
On Mon, Mar 11, 2013 at 1:28 PM, sri <devanasrika...@gmail.com> wrote:
> Hi,
>
> I am relatively new to Django and trying to create a Django application
> using 1.5 and created a pop up modal login and registration form using
> twitter bootstrap. The example i used to create the drop down
> login/registration form
> ishttp://mifsud.me/adding-dropdown-login-form-bootstraps-navbar/[1] .Now,
> the problem i am having is that, how do i show any error messages (password
> invalid etc) on the pop up login/registration drop down modal box.
>
> Here is my base.html file:
>
> 
>   
>  data-toggle="dropdown">Login
> 
>  method="post" class="form-horizontal">{% csrf_token %}
>  style="margin-bottom: 15px;" type="text" name="email" size="30" />
>  style="margin-bottom: 15px;" type="password" name="password" size="30" />
>  value="Sign In" />
> 
> 
>   
>   
>  data-toggle="dropdown">Register
> 
>  method="post" class="form-horizontal" name="register_form">{% csrf_token %}
> {{ register_form.non_field_errors }}
>  style="margin-bottom: 15px;" type="text" name="email" size="30" />
>  style="margin-bottom: 15px;" type="password" name="password1" size="30" />
>  placeholder="Password Again" style="margin-bottom: 15px;" type="password"
> name="password2" size="30" />
>  value="Register" />
> 
> 
>   
>
> And my views.py looks like below for login and registration views:
>
> def login_view(request):
>   if request.method == 'POST':
>  username = request.POST['email']
>  password = request.POST['password']
>  user = authenticate(username=username, password=password)
>  if user is not None and user.is_active:
> login(request, user)
> return HttpResponseRedirect(request.GET.get("next"))
>   else:
> return  HttpResponseRedirect(reverse('homepage'))
>
> def register_view(request):
>if request.method == 'POST':
>   form = UserCreationForm(data=request.POST, files=request.FILES)
>   if form.is_valid():
> new_user = form.save()
> new_user = authenticate(username=request.POST['username'],
> password=request.POST['password1'])
> login(request, new_user)
>  return HttpResponseRedirect(request.GET.get("next"))
>else:
>   return HttpResponseRedirect(reverse('homepage'))
>
> def homepage(request):
>form = UserCreationForm()
>return render_to_response('base.html',
> {
>  'register_form': form},
>context_instance=RequestContext(request))
>
> And my forms.py looks like below for registration:
>
>  class UserCreationForm(forms.ModelForm):
>
>password1 = forms.CharField(label='Password', widget=forms.PasswordInput)
>password2 = forms.CharField(label='Password confirmation',
> widget=forms.PasswordInput)
>
>class Meta:
> model = MyUser
> fields = ('email',)
>
>def clean_password2(self):
> # Check that the two password entries match
> password1 = self.cleaned_data.get("password1")
> password2 = self.cleaned_data.get("password2")
> if password1 and password2 and password1 != password2:
> raise forms.ValidationError("Passwords don't match")
> return password2
>
>def save(self, commit=True):
> # Save the provided password in hashed format
> user = super(UserCreationForm, self).save(commit)
> user.set_password(self.cleaned_data["password1"])
> if commit:
> user.save()
> return user
>
> Can anyone help me how i can pass the registration validation error messages
> into the drop down modal form and also the login password validation error
> messages. What i would like to do is displat the error message in the drop
> down login/registration box itself.
>
> Thanks
>

Hi Sri

Django's form objects have individual field objects, accessible in the
template. These field objects have attributes for any validation error
messages, and the form itself has an attribute for any non field
related valida

django login/registration validation error message issue

2013-03-11 Thread sri


Hi,

I am relatively new to Django and trying to create a Django application 
using 1.5 and created a pop up modal login and registration form using 
twitter bootstrap. The example i used to create the drop down 
login/registration form is
http://mifsud.me/adding-dropdown-login-form-bootstraps-navbar/[1] .Now, the 
problem i am having is that, how do i show any error messages (password 
invalid etc) on the pop up login/registration drop down modal box.

Here is my base.html file:


  
Login

{% csrf_token %}





  
  
Register

{% csrf_token %}
{{ register_form.non_field_errors }}






  

And my views.py looks like below for login and registration views:

def login_view(request):
  if request.method == 'POST':
 username = request.POST['email']
 password = request.POST['password']
 user = authenticate(username=username, password=password)
 if user is not None and user.is_active:
login(request, user)
return HttpResponseRedirect(request.GET.get("next"))
  else:
return  HttpResponseRedirect(reverse('homepage'))

def register_view(request):
   if request.method == 'POST':
  form = UserCreationForm(data=request.POST, files=request.FILES)
  if form.is_valid():
new_user = form.save()
new_user = authenticate(username=request.POST['username'],
password=request.POST['password1'])
login(request, new_user)
 return HttpResponseRedirect(request.GET.get("next"))
   else:
  return HttpResponseRedirect(reverse('homepage'))

def homepage(request):
   form = UserCreationForm()
   return render_to_response('base.html',
{
 'register_form': form},
   context_instance=RequestContext(request))

And my forms.py looks like below for registration:

 class UserCreationForm(forms.ModelForm):

   password1 = forms.CharField(label='Password', widget=forms.PasswordInput)
   password2 = forms.CharField(label='Password confirmation', 
widget=forms.PasswordInput)

   class Meta:
model = MyUser
fields = ('email',)

   def clean_password2(self):
# Check that the two password entries match
password1 = self.cleaned_data.get("password1")
password2 = self.cleaned_data.get("password2")
if password1 and password2 and password1 != password2:
raise forms.ValidationError("Passwords don't match")
return password2

   def save(self, commit=True):
# Save the provided password in hashed format
user = super(UserCreationForm, self).save(commit)
user.set_password(self.cleaned_data["password1"])
if commit:
user.save()
return user

Can anyone help me how i can pass the registration validation error 
messages into the drop down modal form and also the login password 
validation error messages. What i would like to do is displat the error 
message in the drop down login/registration box itself.

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 http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: error message on runserver locally

2012-12-15 Thread Phil Brant
ah that worked. I have apache on port 80 so I didn't see my django site, so
I just tried a different port and all my django sites work on the new port
now. I always used port 8080 before I wonder why it doesn't work anymore.
Anyway working again, thanks a million devan!


On Sat, Dec 15, 2012 at 4:25 PM, Dev  wrote:

> Run from command line:
> "python manage.py runserver"
>
> Also i guess you are getting an import error because your 'path
> environment variable' doesn't contain the path of the directory of your
> project.
>
> Sent from my iPhone
>
> On 15-Dec-2012, at 9:34 PM, Phil Brant  wrote:
>
> OK, thanks for your help anyway.
>
>
> On Sat, Dec 15, 2012 at 3:57 PM, Ramiro Morales  wrote:
>
>>
>> On Dec 15, 2012 11:30 AM, "Phil"  wrote:
>> >
>> > Hi,
>> >
>> > I had django setup and working for over a year now working with it on
>> and off. I was away for a month, came back and now whenever I run
>> "django-admin.py runserver 8080" I get the following error...
>> >
>> > ImportError: Settings cannot be imported, because environment variable
>> DJANGO_SETTINGS_MODULE is undefined.
>> >
>> > I can import django from command line(version 1.4.3), I ran
>> "django-admin.py startproject test" to try a new project. It has
>> "os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test.settings")" declared
>> in "manage.py" in the root and in "test/test/wsgi.py" it's also declared so
>> how is my DJANGO_SETTINGS_MODULE undefined?
>>
>> Hace you by chance actually upgraded Django todo 1.4.x from aún older
>> versión? Are you using Mac OS X?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> --
> Kind Regards,
> Philip Brant.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Kind Regards,
Philip Brant.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: error message on runserver locally

2012-12-15 Thread Bill Freeman
On Sat, Dec 15, 2012 at 9:30 AM, Phil  wrote:

> Hi,
>
> I had django setup and working for over a year now working with it on and
> off. I was away for a month, came back and now whenever I run
> "django-admin.py runserver 8080" I get the following error...
>

Maybe there's a way to do this, but the only thing that I use
django-admin.py for is startproject.  I haven't  found any suggestion to
use it for anything else in the documents.  All other operations, like
syncdb, runserver, I do by cd'ing into the project root (directory
containing manage.py) and running "python manage.py runserver 8080", for
example.  The cd part is important, because python adds the current
directory to sys.path (if it's not already there), and it needs to be there
to import settings, among other things.  (Running under WSGI, for example,
you will need to add this directory yourself.)

Bill

>
> ImportError: Settings cannot be imported, because environment variable
> DJANGO_SETTINGS_MODULE is undefined.
>
> I can import django from command line(version 1.4.3), I ran
> "django-admin.py startproject test" to try a new project. It has
> "os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test.settings")" declared
> in "manage.py" in the root and in "test/test/wsgi.py" it's also declared so
> how is my DJANGO_SETTINGS_MODULE undefined?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/DKnfFKq7KcQJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: error message on runserver locally

2012-12-15 Thread Dev
Run from command line:
"python manage.py runserver"

Also i guess you are getting an import error because your 'path environment 
variable' doesn't contain the path of the directory of your project.

Sent from my iPhone

On 15-Dec-2012, at 9:34 PM, Phil Brant  wrote:

> OK, thanks for your help anyway.
> 
> 
> On Sat, Dec 15, 2012 at 3:57 PM, Ramiro Morales  wrote:
> 
> On Dec 15, 2012 11:30 AM, "Phil"  wrote:
> >
> > Hi,
> >
> > I had django setup and working for over a year now working with it on and 
> > off. I was away for a month, came back and now whenever I run 
> > "django-admin.py runserver 8080" I get the following error...
> >
> > ImportError: Settings cannot be imported, because environment variable 
> > DJANGO_SETTINGS_MODULE is undefined.
> >
> > I can import django from command line(version 1.4.3), I ran 
> > "django-admin.py startproject test" to try a new project. It has 
> > "os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test.settings")" declared 
> > in "manage.py" in the root and in "test/test/wsgi.py" it's also declared so 
> > how is my DJANGO_SETTINGS_MODULE undefined?
> 
> Hace you by chance actually upgraded Django todo 1.4.x from aún older 
> versión? Are you using Mac OS X?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 
> 
> 
> -- 
> Kind Regards,
> Philip Brant.
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: error message on runserver locally

2012-12-15 Thread Phil Brant
OK, thanks for your help anyway.


On Sat, Dec 15, 2012 at 3:57 PM, Ramiro Morales  wrote:

>
> On Dec 15, 2012 11:30 AM, "Phil"  wrote:
> >
> > Hi,
> >
> > I had django setup and working for over a year now working with it on
> and off. I was away for a month, came back and now whenever I run
> "django-admin.py runserver 8080" I get the following error...
> >
> > ImportError: Settings cannot be imported, because environment variable
> DJANGO_SETTINGS_MODULE is undefined.
> >
> > I can import django from command line(version 1.4.3), I ran
> "django-admin.py startproject test" to try a new project. It has
> "os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test.settings")" declared
> in "manage.py" in the root and in "test/test/wsgi.py" it's also declared so
> how is my DJANGO_SETTINGS_MODULE undefined?
>
> Hace you by chance actually upgraded Django todo 1.4.x from aún older
> versión? Are you using Mac OS X?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Kind Regards,
Philip Brant.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: error message on runserver locally

2012-12-15 Thread Ramiro Morales
On Dec 15, 2012 11:30 AM, "Phil"  wrote:
>
> Hi,
>
> I had django setup and working for over a year now working with it on and
off. I was away for a month, came back and now whenever I run
"django-admin.py runserver 8080" I get the following error...
>
> ImportError: Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.
>
> I can import django from command line(version 1.4.3), I ran
"django-admin.py startproject test" to try a new project. It has
"os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test.settings")" declared
in "manage.py" in the root and in "test/test/wsgi.py" it's also declared so
how is my DJANGO_SETTINGS_MODULE undefined?

Hace you by chance actually upgraded Django todo 1.4.x from aún older
versión? Are you using Mac OS X?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: error message on runserver locally

2012-12-15 Thread Xavier Ordoquy
Le 15 déc. 2012 à 16:37, Phil Brant  a écrit :

> Running that in python interpreter just throws an error "Invalid Syntax"

Without stacktrace, there isn't much we can do.
There might be something wrong in your settings file.

Regards,
Xavier Ordoquy,
Linovia.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: error message on runserver locally

2012-12-15 Thread Phil Brant
Running that in python interpreter just throws an error "Invalid Syntax"


On Sat, Dec 15, 2012 at 3:29 PM, Xavier Ordoquy wrote:

>
> Sorry I should have been more explicit. You need to call the manage.py
> through the python interpreter: "python manage.py runserver" because your
> local directory isn't in your paths.
>
> Regards,
> Xavier Ordoquy,
> Linovia.
>
> Le 15 déc. 2012 à 16:14, Phil Brant  a écrit :
>
> I tried "manage.py runserver 8080" there just get "command not found".
> I've never done it that way in the past but doesn't work either.
>
>
> On Sat, Dec 15, 2012 at 3:09 PM, Xavier Ordoquy wrote:
>
>>
>> Have you tried to start them with the manage.py runserver instead of
>> django-admin ?
>>
>> Regards,
>> Xavier Ordoquy,
>> Linovia.
>>
>> Le 15 déc. 2012 à 15:38, Phil  a écrit :
>>
>> Hi Xavier, I tried a project called "boom" too and same message, plus my
>> other 3 django projects I had working previously all get the same error now.
>>
>> On Saturday, December 15, 2012 2:34:48 PM UTC, Xavier Ordoquy wrote:
>>>
>>> Hi Phil,
>>>
>>> test is a python module. Your project name conflicts with it.
>>> You should use another name for your project.
>>>
>>> Regards,
>>> Xavier Ordoquy,
>>> Linovia.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/django-users/-/kFwQlmOsSQgJ.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> --
> Kind Regards,
> Philip Brant.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Kind Regards,
Philip Brant.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: error message on runserver locally

2012-12-15 Thread Xavier Ordoquy

Sorry I should have been more explicit. You need to call the manage.py through 
the python interpreter: "python manage.py runserver" because your local 
directory isn't in your paths.

Regards,
Xavier Ordoquy,
Linovia.

Le 15 déc. 2012 à 16:14, Phil Brant  a écrit :

> I tried "manage.py runserver 8080" there just get "command not found". I've 
> never done it that way in the past but doesn't work either.
> 
> 
> On Sat, Dec 15, 2012 at 3:09 PM, Xavier Ordoquy  wrote:
> 
> Have you tried to start them with the manage.py runserver instead of 
> django-admin ?
> 
> Regards,
> Xavier Ordoquy,
> Linovia.
> 
> Le 15 déc. 2012 à 15:38, Phil  a écrit :
> 
>> Hi Xavier, I tried a project called "boom" too and same message, plus my 
>> other 3 django projects I had working previously all get the same error now.
>> 
>> On Saturday, December 15, 2012 2:34:48 PM UTC, Xavier Ordoquy wrote:
>> Hi Phil, 
>> 
>> test is a python module. Your project name conflicts with it. 
>> You should use another name for your project. 
>> 
>> Regards, 
>> Xavier Ordoquy, 
>> Linovia. 
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/kFwQlmOsSQgJ.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 
> 
> 
> -- 
> Kind Regards,
> Philip Brant.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: error message on runserver locally

2012-12-15 Thread Phil Brant
I tried "manage.py runserver 8080" there just get "command not found". I've
never done it that way in the past but doesn't work either.


On Sat, Dec 15, 2012 at 3:09 PM, Xavier Ordoquy wrote:

>
> Have you tried to start them with the manage.py runserver instead of
> django-admin ?
>
> Regards,
> Xavier Ordoquy,
> Linovia.
>
> Le 15 déc. 2012 à 15:38, Phil  a écrit :
>
> Hi Xavier, I tried a project called "boom" too and same message, plus my
> other 3 django projects I had working previously all get the same error now.
>
> On Saturday, December 15, 2012 2:34:48 PM UTC, Xavier Ordoquy wrote:
>>
>> Hi Phil,
>>
>> test is a python module. Your project name conflicts with it.
>> You should use another name for your project.
>>
>> Regards,
>> Xavier Ordoquy,
>> Linovia.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/kFwQlmOsSQgJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Kind Regards,
Philip Brant.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: error message on runserver locally

2012-12-15 Thread Xavier Ordoquy

Have you tried to start them with the manage.py runserver instead of 
django-admin ?

Regards,
Xavier Ordoquy,
Linovia.

Le 15 déc. 2012 à 15:38, Phil  a écrit :

> Hi Xavier, I tried a project called "boom" too and same message, plus my 
> other 3 django projects I had working previously all get the same error now.
> 
> On Saturday, December 15, 2012 2:34:48 PM UTC, Xavier Ordoquy wrote:
> Hi Phil, 
> 
> test is a python module. Your project name conflicts with it. 
> You should use another name for your project. 
> 
> Regards, 
> Xavier Ordoquy, 
> Linovia. 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/django-users/-/kFwQlmOsSQgJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: error message on runserver locally

2012-12-15 Thread Phil
Hi Xavier, I tried a project called "boom" too and same message, plus my 
other 3 django projects I had working previously all get the same error now.

On Saturday, December 15, 2012 2:34:48 PM UTC, Xavier Ordoquy wrote:
>
> Hi Phil, 
>
> test is a python module. Your project name conflicts with it. 
> You should use another name for your project. 
>
> Regards, 
> Xavier Ordoquy, 
> Linovia. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/kFwQlmOsSQgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: error message on runserver locally

2012-12-15 Thread Xavier Ordoquy
Hi Phil,

test is a python module. Your project name conflicts with it.
You should use another name for your project.

Regards,
Xavier Ordoquy,
Linovia.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



error message on runserver locally

2012-12-15 Thread Phil
Hi,

I had django setup and working for over a year now working with it on and 
off. I was away for a month, came back and now whenever I run 
"django-admin.py runserver 8080" I get the following error...

ImportError: Settings cannot be imported, because environment variable 
DJANGO_SETTINGS_MODULE is undefined.

I can import django from command line(version 1.4.3), I ran 
"django-admin.py startproject test" to try a new project. It has 
"os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test.settings")" declared 
in "manage.py" in the root and in "test/test/wsgi.py" it's also declared so 
how is my DJANGO_SETTINGS_MODULE undefined?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/DKnfFKq7KcQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Getting a strange error message when setting mysql database

2012-10-22 Thread alfa
I've just figured out that the password set was wrong. I previously passed 
as the root one, which was wrong. Now, it worked out of the box.


On Monday, October 22, 2012 3:35:44 PM UTC+2, alfa wrote:
>
> Hi,
>
> After setting the following: 
>
> 'ENGINE': 'django.db.backends.mysql', # postgresql_psycopg2', 
> 'mysql', 'sqlite3' or 'oracle'.
> 'NAME': 'testdb',  # Or path to database file 
> if using sqlite3.
> 'USER': 'testuser',  # Not used with sqlite3.
> 'PASSWORD': 'x',  # Not used with sqlite3.
> 'HOST': '',  # Set to empty string for 
> localhost. Not used with sqlite3.
> 'PORT': '',  # Set to empty string for 
> default. Not used with sqlite3.
>
> I got the following error:
>
>
> Unhandled exception in thread started by  of  at 0x2580710>>
> Traceback (most recent call last):
>   File 
> "/usr/local/lib/python2.6/dist-packages/django/core/management/commands/runserver.py",
>  
> line 91, in inner_run
> self.validate(display_num_errors=True)
>   File 
> "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", 
> line 266, in validate
> num_errors = get_validation_errors(s, app)
>   File 
> "/usr/local/lib/python2.6/dist-packages/django/core/management/validation.py",
>  
> line 103, in get_validation_errors
> connection.validation.validate_field(e, opts, f)
>   File 
> "/usr/local/lib/python2.6/dist-packages/django/db/backends/mysql/validation.py",
>  
> line 14, in validate_field
> db_version = self.connection.get_server_version()
>   File 
> "/usr/local/lib/python2.6/dist-packages/django/db/backends/mysql/base.py", 
> line 415, in get_server_version
> self.cursor().close()
>   File 
> "/usr/local/lib/python2.6/dist-packages/django/db/backends/__init__.py", 
> line 306, in cursor
> cursor = self.make_debug_cursor(self._cursor())
>   File 
> "/usr/local/lib/python2.6/dist-packages/django/db/backends/mysql/base.py", 
> line 387, in _cursor
> self.connection = Database.connect(**kwargs)
>   File "/usr/lib/pymodules/python2.6/MySQLdb/__init__.py", line 81, in 
> Connect
> return Connection(*args, **kwargs)
>   File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 170, in 
> __init__
> super(Connection, self).__init__(*args, **kwargs2)
> _mysql_exceptions.OperationalError: (1045, "Access denied for user 
> 'testuser'@'localhost' (using password: YES)")
>
>
> What is the culprit? 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/yLT7hGwG9-kJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Getting a strange error message when setting mysql database

2012-10-22 Thread alfa
Hi,

After setting the following: 

'ENGINE': 'django.db.backends.mysql', # postgresql_psycopg2', 
'mysql', 'sqlite3' or 'oracle'.
'NAME': 'testdb',  # Or path to database file 
if using sqlite3.
'USER': 'testuser',  # Not used with sqlite3.
'PASSWORD': 'x',  # Not used with sqlite3.
'HOST': '',  # Set to empty string for 
localhost. Not used with sqlite3.
'PORT': '',  # Set to empty string for default. 
Not used with sqlite3.

I got the following error:


Unhandled exception in thread started by >
Traceback (most recent call last):
  File 
"/usr/local/lib/python2.6/dist-packages/django/core/management/commands/runserver.py",
 
line 91, in inner_run
self.validate(display_num_errors=True)
  File 
"/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", 
line 266, in validate
num_errors = get_validation_errors(s, app)
  File 
"/usr/local/lib/python2.6/dist-packages/django/core/management/validation.py", 
line 103, in get_validation_errors
connection.validation.validate_field(e, opts, f)
  File 
"/usr/local/lib/python2.6/dist-packages/django/db/backends/mysql/validation.py",
 
line 14, in validate_field
db_version = self.connection.get_server_version()
  File 
"/usr/local/lib/python2.6/dist-packages/django/db/backends/mysql/base.py", 
line 415, in get_server_version
self.cursor().close()
  File 
"/usr/local/lib/python2.6/dist-packages/django/db/backends/__init__.py", 
line 306, in cursor
cursor = self.make_debug_cursor(self._cursor())
  File 
"/usr/local/lib/python2.6/dist-packages/django/db/backends/mysql/base.py", 
line 387, in _cursor
self.connection = Database.connect(**kwargs)
  File "/usr/lib/pymodules/python2.6/MySQLdb/__init__.py", line 81, in 
Connect
return Connection(*args, **kwargs)
  File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 170, in 
__init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (1045, "Access denied for user 
'testuser'@'localhost' (using password: YES)")


What is the culprit? 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/kD-4PM-BDJIJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Database Router result of error message

2012-07-13 Thread Thibault
Hello,

I would like to use multiple database to save model of each application of 
my project on separate database.

I have an issue with Django 1.4 on Python 2.6. I have created a Database 
Router using the official documentation but when I run the server, i have 
this error message:

django.core.exceptions.ImproperlyConfigured: Error importing database 
> router MyBeeDBRouter: "cannot import name connection"


How i can fix it please?

Here we can found my database router and an abstract of my settings.py 

dbrouter.py: http://pastebin.com/ejMXYDd9

settings.py: http://pastebin.com/QeqyF9eH

Thank you.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/q72BEkcwIkQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



ValidationError to error message

2011-12-04 Thread ?manu*
I cannot understand the following behaviour:

>>> from django.core.exceptions import ValidationError
>>> str(ValidationError('so and so'))
"[u'so and so']"
>>> str(Exception('so and so'))
'so and so'

How do I convert a ValidationError to a str for composing a human
readable message? Even if ValidationError is derived from Exception,
its conversion to str is different... what is the right way to get the
message in a ValidationError?

E.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Customizing error message in ModelForm

2011-04-15 Thread het.oosten
Yes indeed!

Thank you very much for your help.

Rob

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Customizing error message in ModelForm

2011-04-15 Thread Martin Pajuste
This should do the trick:

class PrijsvraagForm(ModelForm):
mail = forms.EmailField(error_messages={'required':'Vul aub een geldig 
Email adres in', 'invalid': 'Het email adres is niet geldig'})

class Meta:
model = Prijsvraag

def clean_code(self):
super(PrijsvraagForm, self).clean()
x = self.cleaned_data['code']
try:
y = Code.objects.all()[0]
except:
raise forms.ValidationError("Er is iets fout gegaan")
if x != y.code:
raise forms.ValidationError("De code is niet juist")
pass
return x

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Customizing error message in ModelForm

2011-04-15 Thread het.oosten
@Martin

Thank you for your reply.

I tried to do this, but I still get the default error message (the
custom error from the code field works as it should):

from django.db import models
from django.forms import ModelForm
from django import forms

class Prijsvraag(models.Model):
naam = models.CharField(max_length=60)
code = models.CharField(max_length=18)
ingeschreven = models.DateField(auto_now_add=True)
mail = models.EmailField(unique=True)
nieuwsbrief = models.BooleanField(default=1)

class PrijsvraagForm(ModelForm):
class Meta:
mail = forms.EmailField(error_messages={'required':
'Vul aub een geldig Email adres in', 'invalid': 'Het email adres is
niet geldig'})
model = Prijsvraag
def clean_code(self):
super(PrijsvraagForm, self).clean()
x = self.cleaned_data['code']
try:
y = Code.objects.all()[0]
except:
raise forms.ValidationError("Er is iets fout
gegaan")
if x != y.code:
raise forms.ValidationError("De code is niet
juist")
pass
return x


Rob

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Customizing error message in ModelForm

2011-04-15 Thread Martin Pajuste
Error messages in ModelForms work perfectly fine.

class PersonForm(forms.ModelForm):
first_name = forms.CharField(error_messages={'required': 'Please enter 
your first name!'})
class Meta:
model = Person


http://docs.djangoproject.com/en/dev/ref/forms/fields/#error-messages

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Customizing error message in ModelForm

2011-04-15 Thread het.oosten
I want to show a custom error message in a Modelform. With a normal
form I can add an error message like this:

error_messages={'required': 'Vul aub een geldig Email adres in',
'invalid': 'Het email adres is niet geldig'}

With a ModelForm this won't work. Is there a way to add a custom error
message to the ModelForm, or should i write a custom clean method?

I am using Django 1.2.3

Rob

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: English translation for error message?

2010-12-22 Thread Nick Serra
http://translate.google.com/#auto|en|%20list%20index%20out%20of%20range

On Dec 21, 6:10 pm, Bill Freeman <ke1g...@gmail.com> wrote:
> On Tue, Dec 21, 2010 at 5:53 PM, Jonathan Hayward <
>
>
>
>
>
> christos.jonathan.hayw...@gmail.com> wrote:
> > [jhayw...@cmlnxbld01 invdb]$ python manage.py shell
> > Python 2.7 (r27:82500, Dec  2 2010, 14:06:29)
> > [GCC 4.2.4] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
> > (InteractiveConsole)
> > >>> import models
> > Traceback (most recent call last):
> >   File "", line 1, in 
> >   File "/home/jhayward/invdb/models.py", line 50, in 
> >     class architecture(models.Model):
> >   File
> > "/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/django/db/model 
> > s/base.py",
> > line 48, in __new__
> >     kwargs = {"app_label": model_module.__name__.split('.')[-2]}
> > IndexError: list index out of range
>
> > What is going on in this error message?
>
> The "English" translation is "list index out of range".
>
> As to what causes it, I'd guess that model_module.__name__ has not '.' in
> it, so the split returns a list of one item, and -2 is then an illegal
> index.
>
> This would seem to be because your models.py is in the same directory as
> your manage.py (and presumably settings.py), thus your ability to try and
> import it as just "import models".  Looking at the base.py code, it really
> expects a models.py file to be in a package (an app package, whose name this
> code is trying to figure out), and fails when it is not.
>
> The fix, if all this is true, is to create a sub folder for your "app", put
> the models.py (and views.py and maybe forms.py, admin.py, app specific
> urls.py) in that folder, allong with a (probably empty) file called
> __init__.py (that's two underscores before and two after, the word init).
> The name of this folder becomes your app name, e.g.; "my_app".  Then you
> would retry your experiment by typing "import my_app.models".
>
>
>
>
>
> > It occurred after I went through and added docstrings, __str__(), and
> > __unicode__() methods; I get the same error, referring to the same class,
> > when I go through and comment out the docstring and __str__() and
> > __unicode__() methods.
>
> > What are the likely causes, and what can I do to fix this?
>
> > --
> > [image: Christos Jonathan Hayward] <http://jonathanscorner.com/>
> > Christos Jonathan Hayward, an Orthodox Christian author.
>
> > Author Bio <http://jonathanscorner.com/author/> • 
> > Books<http://cjshayward.com/>
> >  • *Email <christos.jonathan.hayw...@gmail.com>* • 
> > Facebook<http://www.facebook.com/christos.jonathan.hayward>
> >  • LinkedIn <http://www.linkedin.com/in/jonathanhayward> • 
> > Twitter<http://twitter.com/JonathansCorner>
> >  • *Web <http://jonathanscorner.com/>* • What's 
> > New?<http://jonathanscorner.com/>
> > I invite you to visit my "theology, literature, and other creative works"
> > site.
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@google 
> > groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: English translation for error message?

2010-12-21 Thread Bill Freeman
On Tue, Dec 21, 2010 at 5:53 PM, Jonathan Hayward <
christos.jonathan.hayw...@gmail.com> wrote:

> [jhayw...@cmlnxbld01 invdb]$ python manage.py shell
> Python 2.7 (r27:82500, Dec  2 2010, 14:06:29)
> [GCC 4.2.4] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
> >>> import models
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/home/jhayward/invdb/models.py", line 50, in 
> class architecture(models.Model):
>   File
> "/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/django/db/models/base.py",
> line 48, in __new__
> kwargs = {"app_label": model_module.__name__.split('.')[-2]}
> IndexError: list index out of range
> >>>
>
> What is going on in this error message?
>

The "English" translation is "list index out of range".

As to what causes it, I'd guess that model_module.__name__ has not '.' in
it, so the split returns a list of one item, and -2 is then an illegal
index.

This would seem to be because your models.py is in the same directory as
your manage.py (and presumably settings.py), thus your ability to try and
import it as just "import models".  Looking at the base.py code, it really
expects a models.py file to be in a package (an app package, whose name this
code is trying to figure out), and fails when it is not.

The fix, if all this is true, is to create a sub folder for your "app", put
the models.py (and views.py and maybe forms.py, admin.py, app specific
urls.py) in that folder, allong with a (probably empty) file called
__init__.py (that's two underscores before and two after, the word init).
The name of this folder becomes your app name, e.g.; "my_app".  Then you
would retry your experiment by typing "import my_app.models".

>
> It occurred after I went through and added docstrings, __str__(), and
> __unicode__() methods; I get the same error, referring to the same class,
> when I go through and comment out the docstring and __str__() and
> __unicode__() methods.
>
> What are the likely causes, and what can I do to fix this?
>
> --
> [image: Christos Jonathan Hayward] <http://jonathanscorner.com/>
> Christos Jonathan Hayward, an Orthodox Christian author.
>
> Author Bio <http://jonathanscorner.com/author/> • 
> Books<http://cjshayward.com/>
>  • *Email <christos.jonathan.hayw...@gmail.com>* • 
> Facebook<http://www.facebook.com/christos.jonathan.hayward>
>  • LinkedIn <http://www.linkedin.com/in/jonathanhayward> • 
> Twitter<http://twitter.com/JonathansCorner>
>  • *Web <http://jonathanscorner.com/>* • What's 
> New?<http://jonathanscorner.com/>
> I invite you to visit my "theology, literature, and other creative works"
> site.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



English translation for error message?

2010-12-21 Thread Jonathan Hayward
[jhayw...@cmlnxbld01 invdb]$ python manage.py shell
Python 2.7 (r27:82500, Dec  2 2010, 14:06:29)
[GCC 4.2.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import models
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/jhayward/invdb/models.py", line 50, in 
class architecture(models.Model):
  File
"/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/django/db/models/base.py",
line 48, in __new__
kwargs = {"app_label": model_module.__name__.split('.')[-2]}
IndexError: list index out of range
>>>

What is going on in this error message?

It occurred after I went through and added docstrings, __str__(), and
__unicode__() methods; I get the same error, referring to the same class,
when I go through and comment out the docstring and __str__() and
__unicode__() methods.

What are the likely causes, and what can I do to fix this?

-- 
[image: Christos Jonathan Hayward] <http://jonathanscorner.com/>
Christos Jonathan Hayward, an Orthodox Christian author.

Author Bio <http://jonathanscorner.com/author/> • Books<http://cjshayward.com/>
 • *Email <christos.jonathan.hayw...@gmail.com>* •
Facebook<http://www.facebook.com/christos.jonathan.hayward>
 • LinkedIn <http://www.linkedin.com/in/jonathanhayward> •
Twitter<http://twitter.com/JonathansCorner>
 • *Web <http://jonathanscorner.com/>* • What's
New?<http://jonathanscorner.com/>
I invite you to visit my "theology, literature, and other creative works"
site.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django is not work Error :Message

2010-06-07 Thread Dmitry Dulepov
Hi!

It gices you a hint:

Jagdeep Singh Malhi wrote:
> More information about this error may be available in the server error
> log.

Please, check the web server error log. You will see errors there.
Sometimes you can see them in the browser if you set DEBUG = True in your
settings.py.

-- 
Dmitry Dulepov
Twitter: http://twitter.com/dmitryd/
Web: http://dmitry-dulepov.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django is not work Error :Message

2010-06-07 Thread Jagdeep Singh Malhi
This the Error  message :

Internal Server Error

The server encountered an internal error or misconfiguration and was
unable to complete your request.

Please contact the server administrator, webmas...@localhost and
inform them of the time the error occurred, and anything you might
have done that may have caused the error.

More information about this error may be available in the server error
log.


Please help

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: field specific error message

2010-03-12 Thread Daniel Roseman
On Mar 12, 8:09 pm, Amit Sethi  wrote:
> How do you do field specific messages ... like for  a Telephone Number , if
> all characters are not digit send
> message (no invalid )  . I have tried raising forms.ValidationError like
> specified here (http://www.djangosnippets.org/snippets/337/)
>
> I have also tried changing forms.Form._errors ... it is this string that
> seems to be used
> by forms.Form._html_output to put errors in final html .. but still it does
> not work for me can some one tell me how to do the above specified thing
>
> --
> A-M-I-T S|S


http://docs.djangoproject.com/en/1.1/ref/forms/validation/#cleaning-a-specific-field-attribute
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



field specific error message

2010-03-12 Thread Amit Sethi
How do you do field specific messages ... like for  a Telephone Number , if
all characters are not digit send
message (no invalid )  . I have tried raising forms.ValidationError like
specified here (http://www.djangosnippets.org/snippets/337/)

I have also tried changing forms.Form._errors ... it is this string that
seems to be used
by forms.Form._html_output to put errors in final html .. but still it does
not work for me can some one tell me how to do the above specified thing


-- 
A-M-I-T S|S

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Error message has the wrong file path

2010-01-16 Thread Andrew Bialecki
Cool thanks, that was it.

On Sat, Jan 16, 2010 at 11:55 AM, Karen Tracey <kmtra...@gmail.com> wrote:

> On Sat, Jan 16, 2010 at 11:49 AM, Andrew Bialecki <
> andrew.biale...@gmail.com> wrote:
>
>> I'm in debug mode and the error message I'm getting sounds right but
>> the file paths are wrong.  For instance, I know the module that's
>> failing is in /foo/bar/module.py, but it says the error occurred in
>> the module /baz/module.py which definitely no longer exists.  The
>> module used to located in the directory /baz/, but isn't any more.
>> Any idea what's going on?  This is on Snow Leopard if that makes any
>> difference.  Trying to debug things is difficult when the paths don't
>> make sense.
>>
>>
> Sounds like you have stray .pyc files left over.  Try deleting all .pyc
> files and run again.
>
> Karen
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
-- 

You received this message because you are subscribed to the Google Groups "Django users" group.

To post to this group, send email to django-us...@googlegroups.com.

To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/django-users?hl=en.



Re: Error message has the wrong file path

2010-01-16 Thread Karen Tracey
On Sat, Jan 16, 2010 at 11:49 AM, Andrew Bialecki <andrew.biale...@gmail.com
> wrote:

> I'm in debug mode and the error message I'm getting sounds right but
> the file paths are wrong.  For instance, I know the module that's
> failing is in /foo/bar/module.py, but it says the error occurred in
> the module /baz/module.py which definitely no longer exists.  The
> module used to located in the directory /baz/, but isn't any more.
> Any idea what's going on?  This is on Snow Leopard if that makes any
> difference.  Trying to debug things is difficult when the paths don't
> make sense.
>
>
Sounds like you have stray .pyc files left over.  Try deleting all .pyc
files and run again.

Karen
-- 

You received this message because you are subscribed to the Google Groups "Django users" group.

To post to this group, send email to django-us...@googlegroups.com.

To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/django-users?hl=en.



Error message has the wrong file path

2010-01-16 Thread Andrew Bialecki
I'm in debug mode and the error message I'm getting sounds right but
the file paths are wrong.  For instance, I know the module that's
failing is in /foo/bar/module.py, but it says the error occurred in
the module /baz/module.py which definitely no longer exists.  The
module used to located in the directory /baz/, but isn't any more.
Any idea what's going on?  This is on Snow Leopard if that makes any
difference.  Trying to debug things is difficult when the paths don't
make sense.
-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: How to display Error Message

2010-01-05 Thread 邓超
If you use django's orm, maybe you can check their document at its website.

2010/1/6 Geobase Isoscale <isosc...@gmail.com>

> Hi all,
>
> I have a Django extension  that enables me to call predefined PostgreSQL
> functions from the database. I would like to know how to display on the
> browser the error message gotten from the database when one enters invalid
> data into the database.
>
> Many Thanks
>
> Isoscale
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Deng Chao
-- 

You received this message because you are subscribed to the Google Groups "Django users" group.

To post to this group, send email to django-us...@googlegroups.com.

To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/django-users?hl=en.



How to display Error Message

2010-01-05 Thread Geobase Isoscale
Hi all,

I have a Django extension  that enables me to call predefined PostgreSQL
functions from the database. I would like to know how to display on the
browser the error message gotten from the database when one enters invalid
data into the database.

Many Thanks

Isoscale

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Error message

2009-12-18 Thread rebus_
2009/12/18 reactosguy :
> I get this message every time I go on http://localhost:8000/ with the
> Django server running:
>
> Traceback (most recent call last):
>
>  File "C:\Python26\lib\site-packages\django\core\servers
> \basehttp.py", line 279, in run
>    self.result = application(self.environ, self.start_response)
>
>  File "C:\Python26\lib\site-packages\django\core\servers
> \basehttp.py", line 651, in __call__
>    return self.application(environ, start_response)
>
>  File "C:\Python26\lib\site-packages\django\core\handlers\wsgi.py",
> line 241, in __call__
>    response = self.get_response(request)
>
>  File "C:\Python26\lib\site-packages\django\core\handlers\base.py",
> line 122, in get_response
>    return self.handle_uncaught_exception(request, resolver,
> sys.exc_info())
>
>  File "C:\Python26\lib\site-packages\django\core\handlers\base.py",
> line 166, in handle_uncaught_exception
>    return callback(request, **param_dict)
>
>  File "C:\Python26\lib\site-packages\django\views\defaults.py", line
> 23, in server_error
>    t = loader.get_template(template_name)
>
>  File "C:\Python26\lib\site-packages\django\template\loader.py", line
> 81, in get_template
>    source, origin = find_template_source(template_name)
>
>  File "C:\Python26\lib\site-packages\django\template\loader.py", line
> 74, in find_template_source
>    raise TemplateDoesNotExist, name
>
> TemplateDoesNotExist: 500.html
>
> --

Create template with the name 500.html in your base template directory.
It tries to use 500.html on server error if you have DEBUG=False.

Davor

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Error message

2009-12-17 Thread Andres Vargas - zodman
its because you set DEBUG=False

and on your templates dir not exist the file 500.html

On Thu, Dec 17, 2009 at 7:34 PM, reactosguy  wrote:
> I get this message every time I go on http://localhost:8000/ with the
> Django server running:
>
> Traceback (most recent call last):
>
>  File "C:\Python26\lib\site-packages\django\core\servers
> \basehttp.py", line 279, in run
>    self.result = application(self.environ, self.start_response)
>
>  File "C:\Python26\lib\site-packages\django\core\servers
> \basehttp.py", line 651, in __call__
>    return self.application(environ, start_response)
>
>  File "C:\Python26\lib\site-packages\django\core\handlers\wsgi.py",
> line 241, in __call__
>    response = self.get_response(request)
>
>  File "C:\Python26\lib\site-packages\django\core\handlers\base.py",
> line 122, in get_response
>    return self.handle_uncaught_exception(request, resolver,
> sys.exc_info())
>
>  File "C:\Python26\lib\site-packages\django\core\handlers\base.py",
> line 166, in handle_uncaught_exception
>    return callback(request, **param_dict)
>
>  File "C:\Python26\lib\site-packages\django\views\defaults.py", line
> 23, in server_error
>    t = loader.get_template(template_name)
>
>  File "C:\Python26\lib\site-packages\django\template\loader.py", line
> 81, in get_template
>    source, origin = find_template_source(template_name)
>
>  File "C:\Python26\lib\site-packages\django\template\loader.py", line
> 74, in find_template_source
>    raise TemplateDoesNotExist, name
>
> TemplateDoesNotExist: 500.html
>
> --
>
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




  1   2   >