PAGE INDEX HTML

2023-04-02 Thread REMY TOUITOU
Hello could someone help me to make appear the index html page in the 
application main?
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/4b687185-6fb4-4cb4-83f2-495d22c2583fn%40googlegroups.com.


ORM migration index name mismatch. Can't drop existing index.

2022-05-16 Thread Konstantin Kuchkov
Context:
In an app called "exams", I have a model named Capture which has a unique 
CharField named "uuid". I was trying to convert this field to a UUIDField 
and I was getting this error:
django.db.utils.ProgrammingError: operator class "varchar_pattern_ops" does 
not accept data type uuid

Looking at the postgres table I found this index
"exams_capture_uuid_4a3af4ea353edaa5_like" btree (uuid varchar_pattern_ops)
However, the migration was trying to drop an index by a different name
DROP INDEX IF EXISTS "exams_capture_uuid_0c20e2c2_like";
Works correctly if I add a RunSQL migration to remove the culprit.

So I'm wondering where did the other index name come from? We never mess 
with postgres schema without going through Django ORM.
Originally, the table was created in Django 1.11, and, currently, we're on 
Django 4.04. Did something change between versions that caused index naming 
to be different? I checked the initial migration with sqlmigrate and even 
that shows the new index name.

Is there a way to work around this without hardcoding index name in raw sql?

-- 
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/7e854d78-2b24-4e52-b385-239ea9b8d288n%40googlegroups.com.


Re: django.db.utils.OperationalError: index row requires 45344 bytes, maximum size is 8191

2022-04-02 Thread Antonis Christofides
=self.business).count() / DATA_PER_PAGE + 1
def __str__(self) -> int:
return self.id
*
*
*This started when I added the a class Meta with unique_together field*
*
*
# class Meta:
# unique_together = ('business', 'name')
*
*
*But after I removed it, and did makemigration, then migrated, then I started 
getting this error*

*
*
*
*
*AJAYI Sunday *
(+234) 806 771 5394
/sunnexaj...@gmail.com/



On Sat, Apr 2, 2022 at 6:49 AM Antonis Christofides 
 wrote:


Hi,

could you show the definition of your model?

Antonis Christofides
+30-6979924665 (mobile)



On 02/04/2022 00.43, Sunday Ajayi wrote:

Hi Team,


Please I am having the error below from django - postgresql:

django.db.utils.OperationalError: index row requires 45344 bytes, maximum
size is 8191


Please how can I fix it?

Regards,
*AJAYI Sunday *
(+234) 806 771 5394
/sunnexaj...@gmail.co <mailto:sunnexaj...@gmail.com>m/
-- 
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/CAKYSAw2o5TD2katq07Np2zdKs1yDMd%3D_UCnp0Ly2vMpV7h1p-w%40mail.gmail.com

<https://groups.google.com/d/msgid/django-users/CAKYSAw2o5TD2katq07Np2zdKs1yDMd%3D_UCnp0Ly2vMpV7h1p-w%40mail.gmail.com?utm_medium=email_source=footer>.
-- 
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/d65d443e-6eeb-1daf-590b-1cc29445ba59%40antonischristofides.com

<https://groups.google.com/d/msgid/django-users/d65d443e-6eeb-1daf-590b-1cc29445ba59%40antonischristofides.com?utm_medium=email_source=footer>.

--
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/CAKYSAw0DabjecG3-dQdfURhPU-N_Fs4u2V6OManQY03sq%3D37rQ%40mail.gmail.com 
<https://groups.google.com/d/msgid/django-users/CAKYSAw0DabjecG3-dQdfURhPU-N_Fs4u2V6OManQY03sq%3D37rQ%40mail.gmail.com?utm_medium=email_source=footer>.


--
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/7b1efdec-47f6-8526-ffc9-36fc7df8befa%40antonischristofides.com.


Re: django.db.utils.OperationalError: index row requires 45344 bytes, maximum size is 8191

2022-04-02 Thread Sunday Ajayi
')

*But after I removed it, and did makemigration, then migrated, then I
started getting this error*


*AJAYI Sunday *
(+234) 806 771 5394
*sunnexaj...@gmail.com *



On Sat, Apr 2, 2022 at 6:49 AM Antonis Christofides <
anto...@antonischristofides.com> wrote:

> Hi,
>
> could you show the definition of your model?
>
> Antonis Christofides
> +30-6979924665 (mobile)
>
>
>
> On 02/04/2022 00.43, Sunday Ajayi wrote:
>
> Hi Team,
>
>
> Please I am having the error below from django - postgresql:
>
> django.db.utils.OperationalError: index row requires 45344 bytes, maximum
> size is 8191
>
>
> Please how can I fix it?
>
> Regards,
> *AJAYI Sunday *
> (+234) 806 771 5394
> *sunnexaj...@gmail.co m*
> --
> 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/CAKYSAw2o5TD2katq07Np2zdKs1yDMd%3D_UCnp0Ly2vMpV7h1p-w%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAKYSAw2o5TD2katq07Np2zdKs1yDMd%3D_UCnp0Ly2vMpV7h1p-w%40mail.gmail.com?utm_medium=email_source=footer>
> .
>
> --
> 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/d65d443e-6eeb-1daf-590b-1cc29445ba59%40antonischristofides.com
> <https://groups.google.com/d/msgid/django-users/d65d443e-6eeb-1daf-590b-1cc29445ba59%40antonischristofides.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAKYSAw0DabjecG3-dQdfURhPU-N_Fs4u2V6OManQY03sq%3D37rQ%40mail.gmail.com.


Re: django.db.utils.OperationalError: index row requires 45344 bytes, maximum size is 8191

2022-04-01 Thread Antonis Christofides

Hi,

could you show the definition of your model?

Antonis Christofides
+30-6979924665 (mobile)



On 02/04/2022 00.43, Sunday Ajayi wrote:

Hi Team,


Please I am having the error below from django - postgresql:

django.db.utils.OperationalError: index row requires 45344 bytes, maximum size 
is 8191



Please how can I fix it?

Regards,
*AJAYI Sunday *
(+234) 806 771 5394
/sunnexaj...@gmail.co <mailto:sunnexaj...@gmail.com>m/
--
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/CAKYSAw2o5TD2katq07Np2zdKs1yDMd%3D_UCnp0Ly2vMpV7h1p-w%40mail.gmail.com 
<https://groups.google.com/d/msgid/django-users/CAKYSAw2o5TD2katq07Np2zdKs1yDMd%3D_UCnp0Ly2vMpV7h1p-w%40mail.gmail.com?utm_medium=email_source=footer>.


--
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/d65d443e-6eeb-1daf-590b-1cc29445ba59%40antonischristofides.com.


django.db.utils.OperationalError: index row requires 45344 bytes, maximum size is 8191

2022-04-01 Thread Sunday Ajayi
Hi Team,


Please I am having the error below from django - postgresql:

django.db.utils.OperationalError: index row requires 45344 bytes, maximum
size is 8191


Please how can I fix it?

Regards,
*AJAYI Sunday *
(+234) 806 771 5394
*sunnexaj...@gmail.co m*

-- 
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/CAKYSAw2o5TD2katq07Np2zdKs1yDMd%3D_UCnp0Ly2vMpV7h1p-w%40mail.gmail.com.


Re: List Index out of Range

2021-10-03 Thread Lalit Suthar
Adding to above 2 answers index error may also occur when your
time_frame_list or responsible_list does not have the same number of items
as your input_list. You should try bnmng' s answer also
> Which line in your code is triggering the error?

you check it with simple print statements or using a debugger in vscode, or
with ipdb.set_trace()


On Sun, 3 Oct 2021 at 05:50, Hedrick Godson's 
wrote:

> Make sure you fill all the inputs with list and also make sure that you
> provide the correct input name to request.POST.getlist() method otherwise
> it will returns empty list which will raise IndexError
>
> On Sun, 3 Oct 2021, 03:13 bnmng,  wrote:
>
>> Which line in your code is triggering the error?
>>
>> On Saturday, October 2, 2021 at 11:07:13 AM UTC-4 eugenet...@gmail.com
>> wrote:
>>
>>> Good day all,
>>>
>>> I need assistance. Am trying to save data from the below form but I am
>>> getting *list out of range* error
>>>  can someone help me to write a successful save function?
>>>
>>> here is the code I am using:
>>>
>>>
>>> def submit_work(request):
>>> if request.method != "POST":
>>> return HttpResponse("Method Not Allowed")
>>> else:
>>> pillar_id=request.POST.get("pillar")
>>> object_id=request.POST.get("objects")
>>> output_id=request.POST.get("output")
>>> activity_id=request.POST.get("activity")
>>> input_list=request.POST.getlist("input[]")
>>> time_frame_list=request.POST.getlist("timeframe[]")
>>> responsible_list=request.POST.getlist("responsible[]")
>>> j=0
>>> for inp in input_list:
>>> wf=WORKFRAMS(pillar_id=pillar_id,object_id=object_id,output_id=output_id
>>> ,activity_id=activity_id,
>>> input=inp,time_frame=time_frame_list[j],responsible=responsible_list[j])
>>> wf.save()
>>> j=j+1
>>> return HttpResponse("OK")
>>>
>>>
>>>
>>> [image: image.png]
>>>
>>> Regards,
>>>
>>> *TUYIZERE Eugene*
>>>
>>>
>>> --
>> 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/8d69a634-0a2d-42e3-994c-5e19f88a799en%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/8d69a634-0a2d-42e3-994c-5e19f88a799en%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
> --
> 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/CAJAxQD%3Dw6GmZkS%2BPJs%2BJp21Z4Mn3pDS7XbxXp%2BBhLB1Rf3k7wg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAJAxQD%3Dw6GmZkS%2BPJs%2BJp21Z4Mn3pDS7XbxXp%2BBhLB1Rf3k7wg%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAGp2JVEecPWditPgWcGWKpx%2BqPz9owKtGfU%2BOUpWbGvTgUtuAw%40mail.gmail.com.


Re: List Index out of Range

2021-10-02 Thread Hedrick Godson's
Make sure you fill all the inputs with list and also make sure that you
provide the correct input name to request.POST.getlist() method otherwise
it will returns empty list which will raise IndexError

On Sun, 3 Oct 2021, 03:13 bnmng,  wrote:

> Which line in your code is triggering the error?
>
> On Saturday, October 2, 2021 at 11:07:13 AM UTC-4 eugenet...@gmail.com
> wrote:
>
>> Good day all,
>>
>> I need assistance. Am trying to save data from the below form but I am
>> getting *list out of range* error
>>  can someone help me to write a successful save function?
>>
>> here is the code I am using:
>>
>>
>> def submit_work(request):
>> if request.method != "POST":
>> return HttpResponse("Method Not Allowed")
>> else:
>> pillar_id=request.POST.get("pillar")
>> object_id=request.POST.get("objects")
>> output_id=request.POST.get("output")
>> activity_id=request.POST.get("activity")
>> input_list=request.POST.getlist("input[]")
>> time_frame_list=request.POST.getlist("timeframe[]")
>> responsible_list=request.POST.getlist("responsible[]")
>> j=0
>> for inp in input_list:
>> wf=WORKFRAMS(pillar_id=pillar_id,object_id=object_id,output_id=output_id,
>> activity_id=activity_id,
>> input=inp,time_frame=time_frame_list[j],responsible=responsible_list[j])
>> wf.save()
>> j=j+1
>> return HttpResponse("OK")
>>
>>
>>
>> [image: image.png]
>>
>> Regards,
>>
>> *TUYIZERE Eugene*
>>
>>
>> --
> 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/8d69a634-0a2d-42e3-994c-5e19f88a799en%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/CAJAxQD%3Dw6GmZkS%2BPJs%2BJp21Z4Mn3pDS7XbxXp%2BBhLB1Rf3k7wg%40mail.gmail.com.


Re: List Index out of Range

2021-10-02 Thread bnmng
Which line in your code is triggering the error?

On Saturday, October 2, 2021 at 11:07:13 AM UTC-4 eugenet...@gmail.com 
wrote:

> Good day all,
>
> I need assistance. Am trying to save data from the below form but I am 
> getting *list out of range* error
>  can someone help me to write a successful save function?
>
> here is the code I am using:
>
>
> def submit_work(request): 
> if request.method != "POST":
> return HttpResponse("Method Not Allowed")
> else:
> pillar_id=request.POST.get("pillar")
> object_id=request.POST.get("objects")
> output_id=request.POST.get("output")
> activity_id=request.POST.get("activity")
> input_list=request.POST.getlist("input[]")
> time_frame_list=request.POST.getlist("timeframe[]")
> responsible_list=request.POST.getlist("responsible[]")
> j=0
> for inp in input_list:
> wf=WORKFRAMS(pillar_id=pillar_id,object_id=object_id,output_id=output_id,
> activity_id=activity_id,
> input=inp,time_frame=time_frame_list[j],responsible=responsible_list[j])
> wf.save()
> j=j+1
> return HttpResponse("OK")
>
>
>
> [image: image.png]
>
> Regards, 
>
> *TUYIZERE Eugene*
>
>
>

-- 
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/8d69a634-0a2d-42e3-994c-5e19f88a799en%40googlegroups.com.


List Index out of Range

2021-10-02 Thread Eugene TUYIZERE
Good day all,

I need assistance. Am trying to save data from the below form but I am
getting *list out of range* error
 can someone help me to write a successful save function?

here is the code I am using:


def submit_work(request):
if request.method != "POST":
return HttpResponse("Method Not Allowed")
else:
pillar_id=request.POST.get("pillar")
object_id=request.POST.get("objects")
output_id=request.POST.get("output")
activity_id=request.POST.get("activity")
input_list=request.POST.getlist("input[]")
time_frame_list=request.POST.getlist("timeframe[]")
responsible_list=request.POST.getlist("responsible[]")
j=0
for inp in input_list:
wf=WORKFRAMS(pillar_id=pillar_id,object_id=object_id,output_id=output_id,
activity_id=activity_id,
input=inp,time_frame=time_frame_list[j],responsible=responsible_list[j])
wf.save()
j=j+1
return HttpResponse("OK")



[image: image.png]

Regards,

*TUYIZERE Eugene*

-- 
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/CABxpZHvXVqPzsFj3mq7Z0qHCSC-zMY_vuXAj8Hv%3Dxr2SMGu8Sw%40mail.gmail.com.


Re: AttributeError: module 'polls.views' has no attribute 'index'

2021-07-26 Thread DJANGO DEVELOPER
as you mentioned that you're using django 3.2 but your urls.py file is
following the pattern of django 1.7.
use your urls.py this way : path('your polls url here', views.index,
name='index')

On Mon, Jul 26, 2021 at 6:45 PM Zain  wrote:

> Had the same issue.
>
> Solved, make sure you run each edited python file during the tutorial.
> I guess it needs to update. All I know is this fixed the issue.
>
> On Monday, April 19, 2021 at 2:07:34 AM UTC+10 avi.me...@gmail.com wrote:
>
>> I followed the same tutorial on 17th April 2021 with Python 3.9.2 and
>> Django 3.2 and have exactly the same problems as mentioned above.
>>
>> path('', views.index, name='index'),
>>
>> AttributeError: module 'polls.views' has no attribute 'index'
>>
>> any help on how can I debug this? I am a django noob
>>
>> On Wednesday, 19 April 2017 at 16:31:59 UTC+2 lce...@gmail.com wrote:
>>
>>> Thanks for your reploy.
>>>
>>> Actually I followed the tutorial exactly.
>>>
>>> My polls/views.py has:
>>>
>>> from django.http import HttpResponse
>>>
>>>
>>> def index(request):
>>> return HttpResponse("Hello, world. You're at the polls index.")
>>>
>>> My polls/urls.py has:
>>>
>>> from django.conf.urls import url
>>>
>>> from . import views
>>>
>>> urlpatterns = [
>>> url(r'^$', views.index, name='index'),
>>> ]
>>>
>>>
>>> On Wednesday, 19 April 2017 15:43:57 UTC+2, m712 - Developer wrote:
>>>
>>>> You didn't give us enough info, but I am thinking that you don't have
>>>> an index() function in your polls/views.py. Start the tutorial from the
>>>> beginning and follow it closely.
>>>> On Apr 19, 2017 4:17 PM, Billy Lin  wrote:
>>>>
>>>> I'm following the getting started tutorial 01 and running into issues
>>>> after creating the polls app. Can someone please help?
>>>>
>>>> I'm using Python 3.6.1 and Django 1.11.
>>>>
>>>> Here's the detailed trace:
>>>>
>>>> Performing system checks...
>>>> Unhandled exception in thread started by >>> check_errors..wrapper at 0x04222810>
>>>> Traceback (most recent call last):
>>>>   File
>>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py",
>>>> line
>>>> 227, in wrapper
>>>> fn(*args, **kwargs)
>>>>   File
>>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\ru
>>>> nserver.py", line 125, in inner_run
>>>> self.check(display_num_errors=True)
>>>>   File
>>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py",
>>>> l
>>>> ine 359, in check
>>>> include_deployment_checks=include_deployment_checks,
>>>>   File
>>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py",
>>>> l
>>>> ine 346, in _run_checks
>>>> return checks.run_checks(**kwargs)
>>>>   File
>>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\registry.py",
>>>> l
>>>> ine 81, in run_checks
>>>> new_errors = check(app_configs=app_configs)
>>>>   File
>>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py",
>>>> line
>>>> 16, in check_url_config
>>>> return check_resolver(resolver)
>>>>   File
>>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py",
>>>> line
>>>> 26, in check_resolver
>>>> return check_method()
>>>>   File
>>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py",
>>>> line 25
>>>> 4, in check
>>>> for pattern in self.url_patterns:
>>>>   File
>>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py",
>>>> line
>>>> 35, in __get__
>>>> res = instance.__dict__[self.na

Re: AttributeError: module 'polls.views' has no attribute 'index'

2021-07-26 Thread Zain
Had the same issue. 

Solved, make sure you run each edited python file during the tutorial. 
I guess it needs to update. All I know is this fixed the issue.

On Monday, April 19, 2021 at 2:07:34 AM UTC+10 avi.me...@gmail.com wrote:

> I followed the same tutorial on 17th April 2021 with Python 3.9.2 and 
> Django 3.2 and have exactly the same problems as mentioned above.
>
> path('', views.index, name='index'),
>
> AttributeError: module 'polls.views' has no attribute 'index'
>
> any help on how can I debug this? I am a django noob
>
> On Wednesday, 19 April 2017 at 16:31:59 UTC+2 lce...@gmail.com wrote:
>
>> Thanks for your reploy.
>>
>> Actually I followed the tutorial exactly.
>>
>> My polls/views.py has:
>>
>> from django.http import HttpResponse
>>
>>
>> def index(request):
>> return HttpResponse("Hello, world. You're at the polls index.")
>>
>> My polls/urls.py has:
>>
>> from django.conf.urls import url
>>
>> from . import views
>>
>> urlpatterns = [
>> url(r'^$', views.index, name='index'),
>> ]
>>
>>
>> On Wednesday, 19 April 2017 15:43:57 UTC+2, m712 - Developer wrote:
>>
>>> You didn't give us enough info, but I am thinking that you don't have an 
>>> index() function in your polls/views.py. Start the tutorial from the 
>>> beginning and follow it closely.
>>> On Apr 19, 2017 4:17 PM, Billy Lin  wrote:
>>>
>>> I'm following the getting started tutorial 01 and running into issues 
>>> after creating the polls app. Can someone please help?
>>>
>>> I'm using Python 3.6.1 and Django 1.11.
>>>
>>> Here's the detailed trace:
>>>
>>> Performing system checks...
>>> Unhandled exception in thread started by >> check_errors..wrapper at 0x04222810>
>>> Traceback (most recent call last):
>>>   File 
>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py",
>>>  
>>> line
>>> 227, in wrapper
>>> fn(*args, **kwargs)
>>>   File 
>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\ru
>>> nserver.py", line 125, in inner_run
>>> self.check(display_num_errors=True)
>>>   File 
>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py",
>>>  
>>> l
>>> ine 359, in check
>>> include_deployment_checks=include_deployment_checks,
>>>   File 
>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py",
>>>  
>>> l
>>> ine 346, in _run_checks
>>> return checks.run_checks(**kwargs)
>>>   File 
>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\registry.py",
>>>  
>>> l
>>> ine 81, in run_checks
>>> new_errors = check(app_configs=app_configs)
>>>   File 
>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py",
>>>  
>>> line
>>> 16, in check_url_config
>>> return check_resolver(resolver)
>>>   File 
>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py",
>>>  
>>> line
>>> 26, in check_resolver
>>> return check_method()
>>>   File 
>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py",
>>>  
>>> line 25
>>> 4, in check
>>> for pattern in self.url_patterns:
>>>   File 
>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py",
>>>  
>>> line
>>> 35, in __get__
>>> res = instance.__dict__[self.name] = self.func(instance)
>>>   File 
>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py",
>>>  
>>> line 40
>>> 5, in url_patterns
>>> patterns = getattr(self.urlconf_module, "urlpatterns", 
>>> self.urlconf_module)
>>>   File 
>>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py",

Re: AttributeError: module 'polls.views' has no attribute 'index'

2021-04-22 Thread David Nugent
On Mon, Apr 19, 2021 at 2:07 AM Avi Mehenwal  wrote:

> I followed the same tutorial on 17th April 2021 with Python 3.9.2 and
> Django 3.2 and have exactly the same problems as mentioned above.
>
> path('', views.index, name='index'),
> AttributeError: module 'polls.views' has no attribute 'index'
>
> any help on how can I debug this? I am a django noob
>

We all started out that way.

>From the error message, assuming views it is defined as:

from . import views

or, maybe

from polls import views

it means that python cannot find the function index() in the views module.

Regards

-- 
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/CAE5VhgUckZZtR%2BVBmW6ungOQ8uBowyE%2BSLG%3DVg%3DuqZVZmw275w%40mail.gmail.com.


Re: AttributeError: module 'polls.views' has no attribute 'index'

2021-04-18 Thread Avi Mehenwal
I followed the same tutorial on 17th April 2021 with Python 3.9.2 and 
Django 3.2 and have exactly the same problems as mentioned above.

path('', views.index, name='index'),
AttributeError: module 'polls.views' has no attribute 'index'

any help on how can I debug this? I am a django noob

On Wednesday, 19 April 2017 at 16:31:59 UTC+2 lce...@gmail.com wrote:

> Thanks for your reploy.
>
> Actually I followed the tutorial exactly.
>
> My polls/views.py has:
>
> from django.http import HttpResponse
>
>
> def index(request):
> return HttpResponse("Hello, world. You're at the polls index.")
>
> My polls/urls.py has:
>
> from django.conf.urls import url
>
> from . import views
>
> urlpatterns = [
> url(r'^$', views.index, name='index'),
> ]
>
>
> On Wednesday, 19 April 2017 15:43:57 UTC+2, m712 - Developer wrote:
>
>> You didn't give us enough info, but I am thinking that you don't have an 
>> index() function in your polls/views.py. Start the tutorial from the 
>> beginning and follow it closely.
>> On Apr 19, 2017 4:17 PM, Billy Lin  wrote:
>>
>> I'm following the getting started tutorial 01 and running into issues 
>> after creating the polls app. Can someone please help?
>>
>> I'm using Python 3.6.1 and Django 1.11.
>>
>> Here's the detailed trace:
>>
>> Performing system checks...
>> Unhandled exception in thread started by > check_errors..wrapper at 0x04222810>
>> Traceback (most recent call last):
>>   File 
>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py",
>>  
>> line
>> 227, in wrapper
>> fn(*args, **kwargs)
>>   File 
>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\ru
>> nserver.py", line 125, in inner_run
>> self.check(display_num_errors=True)
>>   File 
>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py",
>>  
>> l
>> ine 359, in check
>> include_deployment_checks=include_deployment_checks,
>>   File 
>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py",
>>  
>> l
>> ine 346, in _run_checks
>> return checks.run_checks(**kwargs)
>>   File 
>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\registry.py",
>>  
>> l
>> ine 81, in run_checks
>> new_errors = check(app_configs=app_configs)
>>   File 
>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py",
>>  
>> line
>> 16, in check_url_config
>> return check_resolver(resolver)
>>   File 
>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py",
>>  
>> line
>> 26, in check_resolver
>> return check_method()
>>   File 
>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py",
>>  
>> line 25
>> 4, in check
>> for pattern in self.url_patterns:
>>   File 
>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py",
>>  
>> line
>> 35, in __get__
>> res = instance.__dict__[self.name] = self.func(instance)
>>   File 
>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py",
>>  
>> line 40
>> 5, in url_patterns
>> patterns = getattr(self.urlconf_module, "urlpatterns", 
>> self.urlconf_module)
>>   File 
>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py",
>>  
>> line
>> 35, in __get__
>> res = instance.__dict__[self.name] = self.func(instance)
>>   File 
>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py",
>>  
>> line 39
>> 8, in urlconf_module
>> return import_module(self.urlconf_name)
>>   File 
>> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py",
>>  
>> line 126, in import_modu
>> le
>> return _bootstrap._gcd_import(name[level:], package, level)
>>   File "", line 978, in _gcd_import
>>

Re: can't find index

2020-07-21 Thread Ralph Barhydt
Superb answer.  To the point, relevant and accurate.  Very helpful.  I 
don't understand the intent of the other two answers.  Chastising? Thank 
you Liu Zheng...

On Saturday, July 18, 2020 at 6:48:18 AM UTC-7, Liu Zheng wrote:
>
> I believe you were following the official tutorial on Django's website, 
> and has created a view function called "index" in "polls" app, which was 
> wired to "/polls" url. All the codes were exactly the same as provided in 
> the tutorial. The mistake you made was when you opened the browser and 
> typed "http://localhost:8000/index;. You shouldn't view "/index". It's 
> the name of the view function, not the name of the end point. As you can 
> see on the error page, you provided views at "polls/" and "admin/". So you 
> just go to "http://localhost:8000/polls; and will see your page there.
>
> On Saturday, July 18, 2020 at 5:21:25 AM UTC+8, Ralph Barhydt wrote:
>>
>>
>> I have done the first part of the tutorial many times and suddenly, doing 
>> it one more time, I get this message.  I am in the right directory and I 
>> have checked the code in urls.py many time as well.  What is going on?
>>
>>
>>
>>
>>
>> ```
>> Page not found (404)
>> Request Method: GET
>> Request URL: http://localhost:8000/index
>>
>> Using the URLconf defined in rbsite.urls, Django tried these URL 
>> patterns, in this order:
>>
>>1. polls/
>>2. admin/
>>
>> The current path, index, didn't match any of these.
>>
>> You're seeing this error because you have DEBUG = True in your Django 
>> settings file. Change that to False, and Django will display a standard 
>> 404 page.
>>
>> ```
>>
>

-- 
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/29aea367-987c-4ebe-a3f3-6c4008d11126o%40googlegroups.com.


Re: can't find index

2020-07-18 Thread Liu Zheng
I believe you were following the official tutorial on Django's website, and 
has created a view function called "index" in "polls" app, which was wired 
to "/polls" url. All the codes were exactly the same as provided in the 
tutorial. The mistake you made was when you opened the browser and typed 
"http://localhost:8000/index;. You shouldn't view "/index". It's the name 
of the view function, not the name of the end point. As you can see on the 
error page, you provided views at "polls/" and "admin/". So you just go to 
"http://localhost:8000/polls; and will see your page there.

On Saturday, July 18, 2020 at 5:21:25 AM UTC+8, Ralph Barhydt wrote:
>
>
> I have done the first part of the tutorial many times and suddenly, doing 
> it one more time, I get this message.  I am in the right directory and I 
> have checked the code in urls.py many time as well.  What is going on?
>
>
>
>
>
> ```
> Page not found (404)
> Request Method: GET
> Request URL: http://localhost:8000/index
>
> Using the URLconf defined in rbsite.urls, Django tried these URL 
> patterns, in this order:
>
>1. polls/
>2. admin/
>
> The current path, index, didn't match any of these.
>
> You're seeing this error because you have DEBUG = True in your Django 
> settings file. Change that to False, and Django will display a standard 
> 404 page.
>
> ```
>

-- 
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/fedc1637-3f79-43ce-a47e-f7b7e3531451o%40googlegroups.com.


can't find index

2020-07-17 Thread Exactly musty
Look at the error closely, as it says it all, in your project url django cant 
find the path index,its a url problem, check it if you got it well spelt

-- 
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/4a6dcc29-d023-40f1-ae44-3f90820037eeo%40googlegroups.com.


Re: can't find index

2020-07-17 Thread Kelvin Sajere
The error is as it is.. Django can't find a path /index

On Fri, Jul 17, 2020, 10:22 PM Ralph Barhydt  wrote:

>
> I have done the first part of the tutorial many times and suddenly, doing
> it one more time, I get this message.  I am in the right directory and I
> have checked the code in urls.py many time as well.  What is going on?
>
>
>
>
>
> ```
> Page not found (404)
> Request Method: GET
> Request URL: http://localhost:8000/index
>
> Using the URLconf defined in rbsite.urls, Django tried these URL
> patterns, in this order:
>
>    1. polls/
>2. admin/
>
> The current path, index, didn't match any of these.
>
> You're seeing this error because you have DEBUG = True in your Django
> settings file. Change that to False, and Django will display a standard
> 404 page.
>
> ```
>
> --
> 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/2dae82ab-5b00-43fb-a05e-8ed2b0d79848o%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/2dae82ab-5b00-43fb-a05e-8ed2b0d79848o%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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/CADYqDX117KYdjT%3DKeJWiCXUqnD2fe-H8hDszZc6UWW2DMBw6EA%40mail.gmail.com.


can't find index

2020-07-17 Thread Ralph Barhydt

I have done the first part of the tutorial many times and suddenly, doing 
it one more time, I get this message.  I am in the right directory and I 
have checked the code in urls.py many time as well.  What is going on?





```
Page not found (404)
Request Method: GET
Request URL: http://localhost:8000/index

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

   1. polls/
   2. admin/

The current path, index, didn't match any of these.

You're seeing this error because you have DEBUG = True in your Django 
settings file. Change that to False, and Django will display a standard 404 
page.

```

-- 
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/2dae82ab-5b00-43fb-a05e-8ed2b0d79848o%40googlegroups.com.


Looking for a solution? Calculating index/offset of a particular record?

2020-05-27 Thread Benjamin Schollnick
I’m trying to optimize a few different things.

I am looking to try to change this into a more database driven routine, instead 
of having to iterate through each and every record.  While not time consuming 
(overall), I would like to try to make it a bit cleaner…

Effectively I am calculating which record the user is actually looking at in 
the gallery.  The UUID is based into the view, and the view then has to figure 
out it’s image XX out of YYY.

 for counter, data in enumerate(catalog_qs, start=1):
 if str(data.uuid) == e_uuid:
 context["page"] = counter
 break

I generalized it to this:

def return_offset_uuid(sorder, fpath, tuuid):
"""
Fetch specific database values only from the database
"""
entries = 
index_data.objects.exclude(ignore=True).exclude(delete_pending=True).filter(
fqpndirectory=fpath.lower().strip()).order_by(*SORT_MATRIX[sorder])
tpk = entries.filter(uuid=tuuid.strip())[0].pk
count = entries.filter(pk__lte=tpk).count() - 1
#answer = user.answer_set.filter(question=question).get()
# return user.answer_set.filter(pk__lte=answer.pk).count() - 1
return count


Which *seemed* to work, except it didn’t.  Yes, I got results:

>>> return_offset_uuid(0, album, "c0543ce7-d156-430d-b08a-5f7379b6e246")# 1
1
>>> return_offset_uuid(0, album, "519f5b9c-e4f4-44e1-aa82-f36aed98e6a9")# 31
4905
>>> return_offset_uuid(0, album, "754fcb51-c3ad-417d-b317-b86305597ae9")# 61
5044
>>> return_offset_uuid(0, album, "b85f18e0-aa17-4192-9c0f-a363d82fa127")# 91
81
>>> return_offset_uuid(0, album, "fe750266-5fb6-467a-929e-c752fa2091ac")  # 
>>> 121
108
>>> return_offset_uuid(0, album, "51d5ea79-1859-402b-85ff-ae3b2adf7173")  # 
>>> 5535
4885

Looking at it, entry “.jpg” is added, it’ll have a larger PK than “ZZZ.jpg” 
which was added two months ago.

Is there a better way to do this?  I’ll keep the for loop if I have to…

- Benjamin


-- 
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/9D43C117-B6EF-4CAD-897C-725C02C67129%40schollnick.net.


Re: self.foreign_related_fields[0] IndexError: tuple index out of range

2019-11-26 Thread Integr@te System
;>>>>> class User(AbstractBaseUser):
>>>>>>>>>> orgid   = models.ForeignKey(Organization, max_length=6, 
>>>>>>>>>> on_delete=models.CASCADE)
>>>>>>>>>> username= models.CharField(primary_key=True, max_length=50)
>>>>>>>>>> email   = models.EmailField(max_length=255, unique=True, 
>>>>>>>>>> null=False, blank=False)
>>>>>>>>>> admin   = models.BooleanField(default=False)
>>>>>>>>>> staff   = models.BooleanField(default=False)
>>>>>>>>>> active  = models.BooleanField(default=True)
>>>>>>>>>> date_joined = models.DateTimeField(auto_now_add=True)
>>>>>>>>>>
>>>>>>>>>> objects = UserManager()
>>>>>>>>>>
>>>>>>>>>> USERNAME_FIELD = "username"
>>>>>>>>>> # REQUIRED_FIELDS must contain all required fields on your User 
>>>>>>>>>> model,
>>>>>>>>>> # but should not contain the USERNAME_FIELD or password as these 
>>>>>>>>>> fields will always be prompted for.
>>>>>>>>>> REQUIRED_FIELDS = ['orgid','email']
>>>>>>>>>>
>>>>>>>>>> class Meta:
>>>>>>>>>> app_label = "user"
>>>>>>>>>> db_table = "user"
>>>>>>>>>>
>>>>>>>>>> def __str__(self):
>>>>>>>>>> return self.username
>>>>>>>>>>
>>>>>>>>>> def get_full_name(self):
>>>>>>>>>> return self.username
>>>>>>>>>>
>>>>>>>>>> def get_short_name(self):
>>>>>>>>>> return self.username
>>>>>>>>>>
>>>>>>>>>> # this methods are require to login super user from admin panel
>>>>>>>>>> def has_perm(self, perm, obj=None):
>>>>>>>>>> return self.is_staff
>>>>>>>>>>
>>>>>>>>>> # this methods are require to login super user from admin panel
>>>>>>>>>> def has_module_perms(self, app_label):
>>>>>>>>>> return self.is_staff
>>>>>>>>>>
>>>>>>>>>> @property
>>>>>>>>>> def is_admin(self):
>>>>>>>>>> return self.admin
>>>>>>>>>>
>>>>>>>>>> @property
>>>>>>>>>> def is_staff(self):
>>>>>>>>>> return self.staff
>>>>>>>>>>
>>>>>>>>>> @property
>>>>>>>>>> def is_active(self):
>>>>>>>>>> return self.active
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> When I create migrations it creates:
>>>>>>>>>>
>>>>>>>>>> from django.db import migrations, models
>>>>>>>>>> import django.db.models.deletion
>>>>>>>>>> import user.models
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> class Migration(migrations.Migration):
>>>>>>>>>>
>>>>>>>>>> initial = True
>>>>>>>>>>
>>>>>>>>>> dependencies = [
>>>>>>>>>> ('organization', '0001_initial'),
>>>>>>>>>> ]
>>>>>>>>>>
>>>>>>>>>> operations = [
>>>>>>>>>> migrations.CreateModel(
>>>>>>>>>> name='User',
>>>>>>>>>> fields=[
>>>>>>>>>> ('password', models.CharField(max_length=128, 
>>>>>>>>>> verbose_name='password')),
>>>>>>>>>> ('last_login', models.DateTimeField(blank=True, 
>>>>>>>>>> null=

Re: self.foreign_related_fields[0] IndexError: tuple index out of range

2019-11-26 Thread Raja Sekar Sambath
;>>>>>>> # REQUIRED_FIELDS must contain all required fields on your User model,
>>>>>>>>> # but should not contain the USERNAME_FIELD or password as these 
>>>>>>>>> fields will always be prompted for.
>>>>>>>>> REQUIRED_FIELDS = ['orgid','email']
>>>>>>>>>
>>>>>>>>> class Meta:
>>>>>>>>> app_label = "user"
>>>>>>>>> db_table = "user"
>>>>>>>>>
>>>>>>>>> def __str__(self):
>>>>>>>>> return self.username
>>>>>>>>>
>>>>>>>>> def get_full_name(self):
>>>>>>>>> return self.username
>>>>>>>>>
>>>>>>>>> def get_short_name(self):
>>>>>>>>> return self.username
>>>>>>>>>
>>>>>>>>> # this methods are require to login super user from admin panel
>>>>>>>>> def has_perm(self, perm, obj=None):
>>>>>>>>> return self.is_staff
>>>>>>>>>
>>>>>>>>> # this methods are require to login super user from admin panel
>>>>>>>>> def has_module_perms(self, app_label):
>>>>>>>>> return self.is_staff
>>>>>>>>>
>>>>>>>>> @property
>>>>>>>>> def is_admin(self):
>>>>>>>>> return self.admin
>>>>>>>>>
>>>>>>>>> @property
>>>>>>>>> def is_staff(self):
>>>>>>>>> return self.staff
>>>>>>>>>
>>>>>>>>> @property
>>>>>>>>> def is_active(self):
>>>>>>>>> return self.active
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> When I create migrations it creates:
>>>>>>>>>
>>>>>>>>> from django.db import migrations, models
>>>>>>>>> import django.db.models.deletion
>>>>>>>>> import user.models
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> class Migration(migrations.Migration):
>>>>>>>>>
>>>>>>>>> initial = True
>>>>>>>>>
>>>>>>>>> dependencies = [
>>>>>>>>> ('organization', '0001_initial'),
>>>>>>>>> ]
>>>>>>>>>
>>>>>>>>> operations = [
>>>>>>>>> migrations.CreateModel(
>>>>>>>>> name='User',
>>>>>>>>> fields=[
>>>>>>>>> ('password', models.CharField(max_length=128, 
>>>>>>>>> verbose_name='password')),
>>>>>>>>> ('last_login', models.DateTimeField(blank=True, 
>>>>>>>>> null=True, verbose_name='last login')),
>>>>>>>>> ('username', models.CharField(max_length=50, 
>>>>>>>>> primary_key=True, serialize=False)),
>>>>>>>>> ('email', models.EmailField(max_length=255, unique=True)),
>>>>>>>>> ('admin', models.BooleanField(default=False)),
>>>>>>>>> ('staff', models.BooleanField(default=False)),
>>>>>>>>> ('active', models.BooleanField(default=True)),
>>>>>>>>> ('date_joined', models.DateTimeField(auto_now_add=True)),
>>>>>>>>> ('orgid', models.ForeignKey(max_length=6, 
>>>>>>>>> on_delete=django.db.models.deletion.CASCADE, 
>>>>>>>>> to='organization.Organization')),
>>>>>>>>> ],
>>>>>>>>> options={
>>>>>>>>> 'db_table': 'user',
>>>>>>>>> },
>>>>>>>>> managers=[
>>>>>>>>> ('objects', user.models.UserManager()),
>>>>>>>>> ]

Re: self.foreign_related_fields[0] IndexError: tuple index out of range

2019-11-26 Thread Ahmad Saki
f.username
>>>>>>>>
>>>>>>>> # this methods are require to login super user from admin panel
>>>>>>>> def has_perm(self, perm, obj=None):
>>>>>>>> return self.is_staff
>>>>>>>>
>>>>>>>> # this methods are require to login super user from admin panel
>>>>>>>> def has_module_perms(self, app_label):
>>>>>>>> return self.is_staff
>>>>>>>>
>>>>>>>> @property
>>>>>>>> def is_admin(self):
>>>>>>>> return self.admin
>>>>>>>>
>>>>>>>> @property
>>>>>>>> def is_staff(self):
>>>>>>>> return self.staff
>>>>>>>>
>>>>>>>> @property
>>>>>>>> def is_active(self):
>>>>>>>> return self.active
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> When I create migrations it creates:
>>>>>>>>
>>>>>>>> from django.db import migrations, models
>>>>>>>> import django.db.models.deletion
>>>>>>>> import user.models
>>>>>>>>
>>>>>>>>
>>>>>>>> class Migration(migrations.Migration):
>>>>>>>>
>>>>>>>> initial = True
>>>>>>>>
>>>>>>>> dependencies = [
>>>>>>>> ('organization', '0001_initial'),
>>>>>>>> ]
>>>>>>>>
>>>>>>>> operations = [
>>>>>>>> migrations.CreateModel(
>>>>>>>> name='User',
>>>>>>>> fields=[
>>>>>>>> ('password', models.CharField(max_length=128, 
>>>>>>>> verbose_name='password')),
>>>>>>>> ('last_login', models.DateTimeField(blank=True, null=True, 
>>>>>>>> verbose_name='last login')),
>>>>>>>> ('username', models.CharField(max_length=50, 
>>>>>>>> primary_key=True, serialize=False)),
>>>>>>>> ('email', models.EmailField(max_length=255, unique=True)),
>>>>>>>> ('admin', models.BooleanField(default=False)),
>>>>>>>> ('staff', models.BooleanField(default=False)),
>>>>>>>> ('active', models.BooleanField(default=True)),
>>>>>>>> ('date_joined', models.DateTimeField(auto_now_add=True)),
>>>>>>>> ('orgid', models.ForeignKey(max_length=6, 
>>>>>>>> on_delete=django.db.models.deletion.CASCADE, 
>>>>>>>> to='organization.Organization')),
>>>>>>>> ],
>>>>>>>> options={
>>>>>>>> 'db_table': 'user',
>>>>>>>> },
>>>>>>>> managers=[
>>>>>>>> ('objects', user.models.UserManager()),
>>>>>>>> ],
>>>>>>>> ),
>>>>>>>> ]
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> But when I want to migrate it gives me an error below. Please help 
>>>>>>>> me anyone..
>>>>>>>>
>>>>>>>> Operations to perform:
>>>>>>>>   Apply all migrations: admin, auth, contenttypes, organization, 
>>>>>>>> sessions, user
>>>>>>>> Running migrations:
>>>>>>>>   Applying admin.0004_auto_20191118_2315...Traceback (most recent call 
>>>>>>>> last):
>>>>>>>>   File "manage.py", line 21, in 
>>>>>>>> main()
>>>>>>>>   File "manage.py", line 17, in main
>>>>>>>> execute_from_command_line(sys.argv)
>>>>>>>>   File 
>>>>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\__init__.py",
>>>>>>>>  line 381, in execute

Re: self.foreign_related_fields[0] IndexError: tuple index out of range

2019-11-26 Thread Integr@te System
hen I create migrations it creates:
>>>>>>>
>>>>>>> from django.db import migrations, models
>>>>>>> import django.db.models.deletion
>>>>>>> import user.models
>>>>>>>
>>>>>>>
>>>>>>> class Migration(migrations.Migration):
>>>>>>>
>>>>>>> initial = True
>>>>>>>
>>>>>>> dependencies = [
>>>>>>> ('organization', '0001_initial'),
>>>>>>> ]
>>>>>>>
>>>>>>> operations = [
>>>>>>> migrations.CreateModel(
>>>>>>> name='User',
>>>>>>> fields=[
>>>>>>> ('password', models.CharField(max_length=128, 
>>>>>>> verbose_name='password')),
>>>>>>> ('last_login', models.DateTimeField(blank=True, null=True, 
>>>>>>> verbose_name='last login')),
>>>>>>> ('username', models.CharField(max_length=50, 
>>>>>>> primary_key=True, serialize=False)),
>>>>>>> ('email', models.EmailField(max_length=255, unique=True)),
>>>>>>> ('admin', models.BooleanField(default=False)),
>>>>>>> ('staff', models.BooleanField(default=False)),
>>>>>>> ('active', models.BooleanField(default=True)),
>>>>>>> ('date_joined', models.DateTimeField(auto_now_add=True)),
>>>>>>> ('orgid', models.ForeignKey(max_length=6, 
>>>>>>> on_delete=django.db.models.deletion.CASCADE, 
>>>>>>> to='organization.Organization')),
>>>>>>> ],
>>>>>>> options={
>>>>>>> 'db_table': 'user',
>>>>>>> },
>>>>>>> managers=[
>>>>>>> ('objects', user.models.UserManager()),
>>>>>>> ],
>>>>>>> ),
>>>>>>> ]
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> But when I want to migrate it gives me an error below. Please help
>>>>>>> me anyone..
>>>>>>>
>>>>>>> Operations to perform:
>>>>>>>   Apply all migrations: admin, auth, contenttypes, organization, 
>>>>>>> sessions, user
>>>>>>> Running migrations:
>>>>>>>   Applying admin.0004_auto_20191118_2315...Traceback (most recent call 
>>>>>>> last):
>>>>>>>   File "manage.py", line 21, in 
>>>>>>> main()
>>>>>>>   File "manage.py", line 17, in main
>>>>>>> execute_from_command_line(sys.argv)
>>>>>>>   File 
>>>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\__init__.py",
>>>>>>>  line 381, in execute_from_command_line
>>>>>>> utility.execute()
>>>>>>>   File 
>>>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\__init__.py",
>>>>>>>  line 375, in execute
>>>>>>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>>>>>>   File 
>>>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py",
>>>>>>>  line 323, in run_from_argv
>>>>>>> self.execute(*args, **cmd_options)
>>>>>>>   File 
>>>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py",
>>>>>>>  line 364, in execute
>>>>>>> output = self.handle(*args, **options)
>>>>>>>   File 
>>>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py",
>>>>>>>  line 83, in wrapped
>>>>>>> res = handle_func(*args, **kwargs)
>>>>>>>   File 
>>>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32

Re: self.foreign_related_fields[0] IndexError: tuple index out of range

2019-11-26 Thread Ahmad Saki
teTimeField(blank=True, null=True, 
>>>>>> verbose_name='last login')),
>>>>>> ('username', models.CharField(max_length=50, 
>>>>>> primary_key=True, serialize=False)),
>>>>>> ('email', models.EmailField(max_length=255, unique=True)),
>>>>>> ('admin', models.BooleanField(default=False)),
>>>>>> ('staff', models.BooleanField(default=False)),
>>>>>> ('active', models.BooleanField(default=True)),
>>>>>> ('date_joined', models.DateTimeField(auto_now_add=True)),
>>>>>> ('orgid', models.ForeignKey(max_length=6, 
>>>>>> on_delete=django.db.models.deletion.CASCADE, 
>>>>>> to='organization.Organization')),
>>>>>> ],
>>>>>> options={
>>>>>> 'db_table': 'user',
>>>>>> },
>>>>>> managers=[
>>>>>> ('objects', user.models.UserManager()),
>>>>>> ],
>>>>>> ),
>>>>>> ]
>>>>>>
>>>>>>
>>>>>>
>>>>>> But when I want to migrate it gives me an error below. Please help me 
>>>>>> anyone..
>>>>>>
>>>>>> Operations to perform:
>>>>>>   Apply all migrations: admin, auth, contenttypes, organization, 
>>>>>> sessions, user
>>>>>> Running migrations:
>>>>>>   Applying admin.0004_auto_20191118_2315...Traceback (most recent call 
>>>>>> last):
>>>>>>   File "manage.py", line 21, in 
>>>>>> main()
>>>>>>   File "manage.py", line 17, in main
>>>>>> execute_from_command_line(sys.argv)
>>>>>>   File 
>>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\__init__.py",
>>>>>>  line 381, in execute_from_command_line
>>>>>> utility.execute()
>>>>>>   File 
>>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\__init__.py",
>>>>>>  line 375, in execute
>>>>>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>>>>>   File 
>>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py",
>>>>>>  line 323, in run_from_argv
>>>>>> self.execute(*args, **cmd_options)
>>>>>>   File 
>>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py",
>>>>>>  line 364, in execute
>>>>>> output = self.handle(*args, **options)
>>>>>>   File 
>>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py",
>>>>>>  line 83, in wrapped
>>>>>> res = handle_func(*args, **kwargs)
>>>>>>   File 
>>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\commands\migrate.py",
>>>>>>  line 234, in handle
>>>>>> fake_initial=fake_initial,
>>>>>>   File 
>>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\executor.py",
>>>>>>  line 117, in migrate
>>>>>> state = self._migrate_all_forwards(state, plan, full_plan, 
>>>>>> fake=fake, fake_initial=fake_initial)
>>>>>>   File 
>>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\executor.py",
>>>>>>  line 147, in _migrate_all_forwards
>>>>>> state = self.apply_migration(state, migration, fake=fake, 
>>>>>> fake_initial=fake_initial)
>>>>>>   File 
>>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\executor.py",
>>>>>>  line 245, in apply_migration
>>>>>> state = migration.apply(state, schema_editor)
>>>>>>   File 
>>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\migration.py",
>>>>>>  line 124, in apply
>>>>>> operation.database_forwards(self.app_label, schema_editor, 
>>>>>> old_state, project_state)
>>>>>>   File 
>>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\operations\fields.py",
>>>>>>  line 249, in database_forwards
>>>>>> schema_editor.alter_field(from_model, from_field, to_field)
>>>>>>   File 
>>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\backends\base\schema.py",
>>>>>>  line 507, in alter_field
>>>>>> new_db_params = new_field.db_parameters(connection=self.connection)
>>>>>>   File 
>>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\fields\related.py",
>>>>>>  line 966, in db_parameters
>>>>>> return {"type": self.db_type(connection), "check": 
>>>>>> self.db_check(connection)}
>>>>>>   File 
>>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\fields\related.py",
>>>>>>  line 963, in db_type
>>>>>> return self.target_field.rel_db_type(connection=connection)
>>>>>>   File 
>>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\fields\related.py",
>>>>>>  line 878, in target_field
>>>>>> return self.foreign_related_fields[0]
>>>>>> IndexError: tuple index out of range
>>>>>>
>>>>>>
>>>>>>
>>>>>> -- 
>>>>>> 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 view this discussion on the web visit 
>>>>>> https://groups.google.com/d/msgid/django-users/7f038f19-7430-4d4b-8dc3-efad352d7bc8%40googlegroups.com
>>>>>>  
>>>>>> <https://groups.google.com/d/msgid/django-users/7f038f19-7430-4d4b-8dc3-efad352d7bc8%40googlegroups.com?utm_medium=email_source=footer>
>>>>>> .
>>>>>>
>>>>> -- 
>>>> 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 view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/django-users/2c8f88c6-5021-4113-84ee-ac0d53001e1a%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/django-users/2c8f88c6-5021-4113-84ee-ac0d53001e1a%40googlegroups.com?utm_medium=email_source=footer>
>>>> .
>>>>
>>> -- 
>> 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 view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/84f02bae-7119-4066-a3d3-3dfc8b8c5973%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/84f02bae-7119-4066-a3d3-3dfc8b8c5973%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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/1c7a93a2-7eb8-4b9d-9928-aa14f86065a8%40googlegroups.com.


Re: self.foreign_related_fields[0] IndexError: tuple index out of range

2019-11-26 Thread Integr@te System
t;>>>> ('objects', user.models.UserManager()),
>>>>> ],
>>>>> ),
>>>>> ]
>>>>>
>>>>>
>>>>>
>>>>> But when I want to migrate it gives me an error below. Please help me
>>>>> anyone..
>>>>>
>>>>> Operations to perform:
>>>>>   Apply all migrations: admin, auth, contenttypes, organization, 
>>>>> sessions, user
>>>>> Running migrations:
>>>>>   Applying admin.0004_auto_20191118_2315...Traceback (most recent call 
>>>>> last):
>>>>>   File "manage.py", line 21, in 
>>>>> main()
>>>>>   File "manage.py", line 17, in main
>>>>> execute_from_command_line(sys.argv)
>>>>>   File 
>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\__init__.py",
>>>>>  line 381, in execute_from_command_line
>>>>> utility.execute()
>>>>>   File 
>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\__init__.py",
>>>>>  line 375, in execute
>>>>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>>>>   File 
>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py",
>>>>>  line 323, in run_from_argv
>>>>> self.execute(*args, **cmd_options)
>>>>>   File 
>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py",
>>>>>  line 364, in execute
>>>>> output = self.handle(*args, **options)
>>>>>   File 
>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py",
>>>>>  line 83, in wrapped
>>>>> res = handle_func(*args, **kwargs)
>>>>>   File 
>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\commands\migrate.py",
>>>>>  line 234, in handle
>>>>> fake_initial=fake_initial,
>>>>>   File 
>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\executor.py",
>>>>>  line 117, in migrate
>>>>> state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, 
>>>>> fake_initial=fake_initial)
>>>>>   File 
>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\executor.py",
>>>>>  line 147, in _migrate_all_forwards
>>>>> state = self.apply_migration(state, migration, fake=fake, 
>>>>> fake_initial=fake_initial)
>>>>>   File 
>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\executor.py",
>>>>>  line 245, in apply_migration
>>>>> state = migration.apply(state, schema_editor)
>>>>>   File 
>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\migration.py",
>>>>>  line 124, in apply
>>>>> operation.database_forwards(self.app_label, schema_editor, old_state, 
>>>>> project_state)
>>>>>   File 
>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\operations\fields.py",
>>>>>  line 249, in database_forwards
>>>>> schema_editor.alter_field(from_model, from_field, to_field)
>>>>>   File 
>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\backends\base\schema.py",
>>>>>  line 507, in alter_field
>>>>> new_db_params = new_field.db_parameters(connection=self.connection)
>>>>>   File 
>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\fields\related.py",
>>>>>  line 966, in db_parameters
>>>>> return {"type": self.db_type(connection), "check": 
>>>>> self.db_check(connection)}
>>>>>   File 
>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\fields\related.py",
>>>>>  line 963, in db_type
>>>>> return self.target_field.rel_db_type(connection=connection)
>>>>>   File 
>>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\fields\related.py",
>>>>>  line 878, in target_field
>>>>> return self.foreign_related_fields[0]
>>>>> IndexError: tuple index out of range
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> 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 view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/django-users/7f038f19-7430-4d4b-8dc3-efad352d7bc8%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/django-users/7f038f19-7430-4d4b-8dc3-efad352d7bc8%40googlegroups.com?utm_medium=email_source=footer>
>>>>> .
>>>>>
>>>> --
>>> 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 view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/2c8f88c6-5021-4113-84ee-ac0d53001e1a%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/2c8f88c6-5021-4113-84ee-ac0d53001e1a%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>> --
> 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/84f02bae-7119-4066-a3d3-3dfc8b8c5973%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/84f02bae-7119-4066-a3d3-3dfc8b8c5973%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAP5HUWrF81bJ%2BVvJthZ5CRE8iNLtUxJvU80x%3DeTD7pWDN1P59w%40mail.gmail.com.


Re: self.foreign_related_fields[0] IndexError: tuple index out of range

2019-11-26 Thread Ahmad Saki
utility.execute()
>>>>   File 
>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\__init__.py",
>>>>  line 375, in execute
>>>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>>>   File 
>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py",
>>>>  line 323, in run_from_argv
>>>> self.execute(*args, **cmd_options)
>>>>   File 
>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py",
>>>>  line 364, in execute
>>>> output = self.handle(*args, **options)
>>>>   File 
>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py",
>>>>  line 83, in wrapped
>>>> res = handle_func(*args, **kwargs)
>>>>   File 
>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\commands\migrate.py",
>>>>  line 234, in handle
>>>> fake_initial=fake_initial,
>>>>   File 
>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\executor.py",
>>>>  line 117, in migrate
>>>> state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, 
>>>> fake_initial=fake_initial)
>>>>   File 
>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\executor.py",
>>>>  line 147, in _migrate_all_forwards
>>>> state = self.apply_migration(state, migration, fake=fake, 
>>>> fake_initial=fake_initial)
>>>>   File 
>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\executor.py",
>>>>  line 245, in apply_migration
>>>> state = migration.apply(state, schema_editor)
>>>>   File 
>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\migration.py",
>>>>  line 124, in apply
>>>> operation.database_forwards(self.app_label, schema_editor, old_state, 
>>>> project_state)
>>>>   File 
>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\operations\fields.py",
>>>>  line 249, in database_forwards
>>>> schema_editor.alter_field(from_model, from_field, to_field)
>>>>   File 
>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\backends\base\schema.py",
>>>>  line 507, in alter_field
>>>> new_db_params = new_field.db_parameters(connection=self.connection)
>>>>   File 
>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\fields\related.py",
>>>>  line 966, in db_parameters
>>>> return {"type": self.db_type(connection), "check": 
>>>> self.db_check(connection)}
>>>>   File 
>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\fields\related.py",
>>>>  line 963, in db_type
>>>> return self.target_field.rel_db_type(connection=connection)
>>>>   File 
>>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\fields\related.py",
>>>>  line 878, in target_field
>>>> return self.foreign_related_fields[0]
>>>> IndexError: tuple index out of range
>>>>
>>>>
>>>>
>>>> -- 
>>>> 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 view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/django-users/7f038f19-7430-4d4b-8dc3-efad352d7bc8%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/django-users/7f038f19-7430-4d4b-8dc3-efad352d7bc8%40googlegroups.com?utm_medium=email_source=footer>
>>>> .
>>>>
>>> -- 
>> 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 view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/2c8f88c6-5021-4113-84ee-ac0d53001e1a%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/2c8f88c6-5021-4113-84ee-ac0d53001e1a%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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/84f02bae-7119-4066-a3d3-3dfc8b8c5973%40googlegroups.com.


Re: self.foreign_related_fields[0] IndexError: tuple index out of range

2019-11-26 Thread Integr@te System
ation(migrations.Migration):
>>>
>>> initial = True
>>>
>>> dependencies = [
>>> ('organization', '0001_initial'),
>>> ]
>>>
>>> operations = [
>>> migrations.CreateModel(
>>> name='User',
>>> fields=[
>>> ('password', models.CharField(max_length=128, 
>>> verbose_name='password')),
>>> ('last_login', models.DateTimeField(blank=True, null=True, 
>>> verbose_name='last login')),
>>> ('username', models.CharField(max_length=50, primary_key=True, 
>>> serialize=False)),
>>> ('email', models.EmailField(max_length=255, unique=True)),
>>> ('admin', models.BooleanField(default=False)),
>>> ('staff', models.BooleanField(default=False)),
>>> ('active', models.BooleanField(default=True)),
>>> ('date_joined', models.DateTimeField(auto_now_add=True)),
>>> ('orgid', models.ForeignKey(max_length=6, 
>>> on_delete=django.db.models.deletion.CASCADE, 
>>> to='organization.Organization')),
>>> ],
>>> options={
>>> 'db_table': 'user',
>>> },
>>> managers=[
>>> ('objects', user.models.UserManager()),
>>> ],
>>> ),
>>> ]
>>>
>>>
>>>
>>> But when I want to migrate it gives me an error below. Please help me
>>> anyone..
>>>
>>> Operations to perform:
>>>   Apply all migrations: admin, auth, contenttypes, organization, sessions, 
>>> user
>>> Running migrations:
>>>   Applying admin.0004_auto_20191118_2315...Traceback (most recent call 
>>> last):
>>>   File "manage.py", line 21, in 
>>> main()
>>>   File "manage.py", line 17, in main
>>> execute_from_command_line(sys.argv)
>>>   File 
>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\__init__.py",
>>>  line 381, in execute_from_command_line
>>> utility.execute()
>>>   File 
>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\__init__.py",
>>>  line 375, in execute
>>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>>   File 
>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py",
>>>  line 323, in run_from_argv
>>> self.execute(*args, **cmd_options)
>>>   File 
>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py",
>>>  line 364, in execute
>>> output = self.handle(*args, **options)
>>>   File 
>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py",
>>>  line 83, in wrapped
>>> res = handle_func(*args, **kwargs)
>>>   File 
>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\commands\migrate.py",
>>>  line 234, in handle
>>> fake_initial=fake_initial,
>>>   File 
>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\executor.py",
>>>  line 117, in migrate
>>> state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, 
>>> fake_initial=fake_initial)
>>>   File 
>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\executor.py",
>>>  line 147, in _migrate_all_forwards
>>> state = self.apply_migration(state, migration, fake=fake, 
>>> fake_initial=fake_initial)
>>>   File 
>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\executor.py",
>>>  line 245, in apply_migration
>>> state = migration.apply(state, schema_editor)
>>>   File 
>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\migration.py",
>>>  line 124, in apply
>>> operation.database_forwards(self.app_label, schema_editor, old_state, 
>>> project_state)
>>>   File 
>>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\oper

Re: self.foreign_related_fields[0] IndexError: tuple index out of range

2019-11-26 Thread Ahmad Saki
False)),
>> ('email', models.EmailField(max_length=255, unique=True)),
>> ('admin', models.BooleanField(default=False)),
>> ('staff', models.BooleanField(default=False)),
>> ('active', models.BooleanField(default=True)),
>> ('date_joined', models.DateTimeField(auto_now_add=True)),
>> ('orgid', models.ForeignKey(max_length=6, 
>> on_delete=django.db.models.deletion.CASCADE, 
>> to='organization.Organization')),
>> ],
>> options={
>> 'db_table': 'user',
>> },
>> managers=[
>> ('objects', user.models.UserManager()),
>> ],
>> ),
>> ]
>>
>>
>>
>> But when I want to migrate it gives me an error below. Please help me 
>> anyone..
>>
>> Operations to perform:
>>   Apply all migrations: admin, auth, contenttypes, organization, sessions, 
>> user
>> Running migrations:
>>   Applying admin.0004_auto_20191118_2315...Traceback (most recent call last):
>>   File "manage.py", line 21, in 
>> main()
>>   File "manage.py", line 17, in main
>> execute_from_command_line(sys.argv)
>>   File 
>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\__init__.py",
>>  line 381, in execute_from_command_line
>> utility.execute()
>>   File 
>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\__init__.py",
>>  line 375, in execute
>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>   File 
>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py",
>>  line 323, in run_from_argv
>> self.execute(*args, **cmd_options)
>>   File 
>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py",
>>  line 364, in execute
>> output = self.handle(*args, **options)
>>   File 
>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py",
>>  line 83, in wrapped
>> res = handle_func(*args, **kwargs)
>>   File 
>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\commands\migrate.py",
>>  line 234, in handle
>> fake_initial=fake_initial,
>>   File 
>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\executor.py",
>>  line 117, in migrate
>> state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, 
>> fake_initial=fake_initial)
>>   File 
>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\executor.py",
>>  line 147, in _migrate_all_forwards
>> state = self.apply_migration(state, migration, fake=fake, 
>> fake_initial=fake_initial)
>>   File 
>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\executor.py",
>>  line 245, in apply_migration
>> state = migration.apply(state, schema_editor)
>>   File 
>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\migration.py",
>>  line 124, in apply
>> operation.database_forwards(self.app_label, schema_editor, old_state, 
>> project_state)
>>   File 
>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\operations\fields.py",
>>  line 249, in database_forwards
>> schema_editor.alter_field(from_model, from_field, to_field)
>>   File 
>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\backends\base\schema.py",
>>  line 507, in alter_field
>> new_db_params = new_field.db_parameters(connection=self.connection)
>>   File 
>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\fields\related.py",
>>  line 966, in db_parameters
>> return {"type": self.db_type(connection), "check": 
>> self.db_check(connection)}
>>   File 
>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\fields\related.py",
>>  line 963, in db_type
>> return self.target_field.rel_db_type(connection=connection)
>>   File 
>> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\fields\related.py",
>>  line 878, in target_field
>> return self.foreign_related_fields[0]
>> IndexError: tuple index out of range
>>
>>
>>
>> -- 
>> 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 view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/7f038f19-7430-4d4b-8dc3-efad352d7bc8%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/7f038f19-7430-4d4b-8dc3-efad352d7bc8%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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/2c8f88c6-5021-4113-84ee-ac0d53001e1a%40googlegroups.com.


Re: self.foreign_related_fields[0] IndexError: tuple index out of range

2019-11-25 Thread Integr@te System
p me
> anyone..
>
> Operations to perform:
>   Apply all migrations: admin, auth, contenttypes, organization, sessions, 
> user
> Running migrations:
>   Applying admin.0004_auto_20191118_2315...Traceback (most recent call last):
>   File "manage.py", line 21, in 
> main()
>   File "manage.py", line 17, in main
> execute_from_command_line(sys.argv)
>   File 
> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\__init__.py",
>  line 381, in execute_from_command_line
> utility.execute()
>   File 
> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\__init__.py",
>  line 375, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File 
> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py",
>  line 323, in run_from_argv
> self.execute(*args, **cmd_options)
>   File 
> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py",
>  line 364, in execute
> output = self.handle(*args, **options)
>   File 
> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py",
>  line 83, in wrapped
> res = handle_func(*args, **kwargs)
>   File 
> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\commands\migrate.py",
>  line 234, in handle
> fake_initial=fake_initial,
>   File 
> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\executor.py",
>  line 117, in migrate
> state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, 
> fake_initial=fake_initial)
>   File 
> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\executor.py",
>  line 147, in _migrate_all_forwards
> state = self.apply_migration(state, migration, fake=fake, 
> fake_initial=fake_initial)
>   File 
> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\executor.py",
>  line 245, in apply_migration
> state = migration.apply(state, schema_editor)
>   File 
> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\migration.py",
>  line 124, in apply
> operation.database_forwards(self.app_label, schema_editor, old_state, 
> project_state)
>   File 
> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\operations\fields.py",
>  line 249, in database_forwards
> schema_editor.alter_field(from_model, from_field, to_field)
>   File 
> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\backends\base\schema.py",
>  line 507, in alter_field
> new_db_params = new_field.db_parameters(connection=self.connection)
>   File 
> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\fields\related.py",
>  line 966, in db_parameters
> return {"type": self.db_type(connection), "check": 
> self.db_check(connection)}
>   File 
> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\fields\related.py",
>  line 963, in db_type
> return self.target_field.rel_db_type(connection=connection)
>   File 
> "C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\fields\related.py",
>  line 878, in target_field
> return self.foreign_related_fields[0]
> IndexError: tuple index out of range
>
>
>
> --
> 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/7f038f19-7430-4d4b-8dc3-efad352d7bc8%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/7f038f19-7430-4d4b-8dc3-efad352d7bc8%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAP5HUWqEwunG5RYm_96d0J5TDNw3tTBAoXu97K652wq2aF%2B4Yw%40mail.gmail.com.


self.foreign_related_fields[0] IndexError: tuple index out of range

2019-11-25 Thread Ahmad Saki
rograms\Python\Python37-32\lib\site-packages\django\core\management\base.py",
 line 323, in run_from_argv
self.execute(*args, **cmd_options)
  File 
"C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py",
 line 364, in execute
output = self.handle(*args, **options)
  File 
"C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py",
 line 83, in wrapped
res = handle_func(*args, **kwargs)
  File 
"C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\commands\migrate.py",
 line 234, in handle
fake_initial=fake_initial,
  File 
"C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\executor.py",
 line 117, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, 
fake_initial=fake_initial)
  File 
"C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\executor.py",
 line 147, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, 
fake_initial=fake_initial)
  File 
"C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\executor.py",
 line 245, in apply_migration
state = migration.apply(state, schema_editor)
  File 
"C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\migration.py",
 line 124, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, 
project_state)
  File 
"C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\migrations\operations\fields.py",
 line 249, in database_forwards
schema_editor.alter_field(from_model, from_field, to_field)
  File 
"C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\backends\base\schema.py",
 line 507, in alter_field
new_db_params = new_field.db_parameters(connection=self.connection)
  File 
"C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\fields\related.py",
 line 966, in db_parameters
return {"type": self.db_type(connection), "check": 
self.db_check(connection)}
  File 
"C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\fields\related.py",
 line 963, in db_type
return self.target_field.rel_db_type(connection=connection)
  File 
"C:\Users\ZAB-SAKI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\fields\related.py",
 line 878, in target_field
return self.foreign_related_fields[0]
IndexError: tuple index out of range



-- 
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/7f038f19-7430-4d4b-8dc3-efad352d7bc8%40googlegroups.com.


"http://127.0.0.1:8000/help/" Show me still 'index page' instead of 'help page'

2019-10-10 Thread Parvez Khan Pathan
NB :i'm new to learn django... as well student and stuck in Template Tag 
task (Sorry if i asked silly question).

-- 
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/a17e2a68-64a6-4476-b621-2b010213b76d%40googlegroups.com.


db.sqlite3
Description: Binary data
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proThree.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)


if __name__ == '__main__':
main()
from django.contrib import admin

# Register your models here.
from django.apps import AppConfig


class AppthreeConfig(AppConfig):
name = 'appThree'
from django.db import models

# Create your models here.
from django.test import TestCase

# Create your tests here.
from django.urls import path
from appThree import views

urlpatterns = [
path('',views.index,name='index'),
path('',views.help,name='help'),
]
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def index(request):
myDict = {'heading':"this is heading tag"}
return render(request,'appThree/index.html',context=myDict)

def help(request):
helpDict = {'help':"Help Page"}
return render(request,'appThree/help.html',context=helpDict)
"""
Django settings for proThree project.

Generated by 'django-admin startproject' using Django 2.2.3.

For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATE_DIR = os.path.join(BASE_DIR,"templates")

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '7-3+$cka1hnzkn_6!%bx$qfus68zb%bxp_s@6_d3bmm%ky+'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'appThree'
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'proThree.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [TEMPLATE_DIR,],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'proThree.wsgi.application'


# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases

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


# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


# Internationalization
# https://docs.djangoproject.com/en/2

Re: How to create complex gin index in postgres db using django

2018-08-29 Thread Jason
you need to make a migration to apply the index.

https://www.endpoint.com/blog/2016/09/17/executing-custom-sql-in-django-migration

something like 

class Migration(migrations.Migration):

dependencies = [
('blog', '0001_initial'),
]

operations = [
migrations.RunSQL(
"CREATE INDEX pgweb_idx ON pgweb USING GIN 
(to_tsvector('english', title || ' ' || body));",
)
]

On Wednesday, August 29, 2018 at 7:16:15 AM UTC-4, Максим Родин wrote:
>
> Hello,
> I'm trying to make the text search index like this:
>
> https://www.postgresql.org/docs/current/static/textsearch-tables.html#TEXTSEARCH-TABLES-INDEX
> :
> "CREATE INDEX pgweb_idx ON pgweb USING GIN (to_tsvector('english', title 
> || ' ' || body));"
>
> I cannot imagine how to do it in django
> Here is my table:
>
> from django.contrib.postgres.indexes import GinIndex
> from django.contrib.postgres.search import SearchQuery
> from django.contrib.postgres.search import SearchVector
> import django.contrib.postgres.search as pg_search
>
>
> class Request(models.Model):
>
> open_date = models.DateTimeField(verbose_name='Creation Date',
>  blank=True)
> close_date = models.DateTimeField(verbose_name='Closing Date',
>   blank=True,
>   null=True,
>   )
>
>
> def in_work_time(self):
> return timezone.now() - self.open_date
>
>
> def set_open_time(self):
> self.open_date = timezone.now()
>
>
> subject = models.CharField(max_length=500,
>verbose_name='Request subject')
> author = models.CharField(max_length=500,
>   verbose_name='Request author')
> content = models.TextField(verbose_name='Request content')
> engineer = models.ForeignKey(User, on_delete=models.PROTECT,
>  blank=True,
>  verbose_name='Engineer assigned')
> priority = models.IntegerField(default=10,
>verbose_name='Priority')
>
>
> def __str__(self):
> return self.subject
>
>
> And here are my thoughts how it could look like.
> (It doesn't work):
>
> en_sv = pg_search.SearchVectorField(SearchVector(
> 'subject', 'content', config='english'), null=True)
> ru_sv = pg_search.SearchVectorField(SearchVector(
> 'subject', 'content', config='russian'), null=True)
>
>
> class Meta:
> indexes = [
> GinIndex(fields=['ru_sv'],
>  fastupdate=False, name='gin_search_ru_idx'),
> GinIndex(fields=['en_sv'],
>  fastupdate=False, name='gin_search_en_idx'),
>  ]
>
>
> Any thoughts?
>
>

-- 
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/101662a8-770b-4b39-8185-015c2f236656%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to create complex gin index in postgres db using django

2018-08-29 Thread Максим Родин
Hello,
I'm trying to make the text search index like this:
https://www.postgresql.org/docs/current/static/textsearch-tables.html#TEXTSEARCH-TABLES-INDEX:
"CREATE INDEX pgweb_idx ON pgweb USING GIN (to_tsvector('english', title || 
' ' || body));"

I cannot imagine how to do it in django
Here is my table:

from django.contrib.postgres.indexes import GinIndex
from django.contrib.postgres.search import SearchQuery
from django.contrib.postgres.search import SearchVector
import django.contrib.postgres.search as pg_search


class Request(models.Model):

open_date = models.DateTimeField(verbose_name='Creation Date',
 blank=True)
close_date = models.DateTimeField(verbose_name='Closing Date',
  blank=True,
  null=True,
  )


def in_work_time(self):
return timezone.now() - self.open_date


def set_open_time(self):
self.open_date = timezone.now()


subject = models.CharField(max_length=500,
   verbose_name='Request subject')
author = models.CharField(max_length=500,
  verbose_name='Request author')
content = models.TextField(verbose_name='Request content')
engineer = models.ForeignKey(User, on_delete=models.PROTECT,
 blank=True,
 verbose_name='Engineer assigned')
priority = models.IntegerField(default=10,
   verbose_name='Priority')


def __str__(self):
return self.subject


And here are my thoughts how it could look like.
(It doesn't work):

en_sv = pg_search.SearchVectorField(SearchVector(
'subject', 'content', config='english'), null=True)
ru_sv = pg_search.SearchVectorField(SearchVector(
'subject', 'content', config='russian'), null=True)


class Meta:
indexes = [
GinIndex(fields=['ru_sv'],
 fastupdate=False, name='gin_search_ru_idx'),
GinIndex(fields=['en_sv'],
 fastupdate=False, name='gin_search_en_idx'),
 ]


Any thoughts?

-- 
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/03077eeb-93bb-4991-a24b-f00fcaff0835%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to programmatically get the index name of a model field on a migration of django 1.8

2018-07-02 Thread Michal Petrucha
On Fri, Jun 29, 2018 at 11:25:16AM -0300, Fabio C. Barrionuevo da Luz wrote:
> Hello, I need to delete an index created automatically by Django, from a
> third-party application and my own django apps, for later I recreate the
> index optimized way.
> 
> this django application is used in several companies.
> so I need to distribute these improvements via django migration.
> 
> 
> I'm using raw sql in a RunPython migration, to delete and create the
> optimized index.
> 
> in django 1.8, there is a deterministic way to I previously know what the
> index name is generated for a given model field or django has a python
> function/method to get this information?

I'm not sure if the names are generated in a predictable way, but my
gut says they probably aren't – at least not in general, maybe for
certain specific DB backends, they will be. (As far as I can see, in
the base backend implementation, Django introspects existing indices
in the database, and finds the name that way.)

If the index is created with db_index=True, unique=true,
index_together, or unique_together, you might be able to get away with
a migration with two operations:
1. delete the index with an AlterField, AlterUniqueTogether, or
   AlterIndexTogether operation, and then
2. use SeparateDatabaseAndState, and in `state_operations`, you undo
   the effect of the previous operation, while in
   `database_operations`, you'd execute your custom SQL to create the
   optimized index.

Another option might be to use a RunPython operation, in which you use
the schema_editor passed in to drop the index with its alter_field,
alter_unique_together, or alter_index_together methods, and then run
your custom SQL. If changing the options of models or fields is not
enough, then you might have to get your hands dirty, and figure out
the name of the index with editor._constraint_names, but then you are
entering private API territory, and things might break on you after
upgrading Django.

Yet another alternative might be to upgrade to a version of Django
that's not past EOL, and use the more explicit support for indices
introduced in 1.11, but I have no idea how much easier it would make
to solve your problem. (You should consider upgrading regardless,
though.)

Good luck,

Michal

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


signature.asc
Description: Digital signature


how to programmatically get the index name of a model field on a migration of django 1.8

2018-06-29 Thread Fabio C. Barrionuevo da Luz
Hello, I need to delete an index created automatically by Django, from a
third-party application and my own django apps, for later I recreate the
index optimized way.

this django application is used in several companies.
so I need to distribute these improvements via django migration.


I'm using raw sql in a RunPython migration, to delete and create the
optimized index.

in django 1.8, there is a deterministic way to I previously know what the
index name is generated for a given model field or django has a python
function/method to get this information?



-- 
Fábio C. Barrionuevo da Luz
Palmas - Tocantins - Brasil - América do Sul

http://pythonclub.com.br/

Blog colaborativo sobre Python e tecnologias Relacionadas, mantido
totalmente no https://github.com/pythonclub/pythonclub.github.io .

Todos são livres para publicar. É só fazer fork, escrever sua postagem e
mandar o pull-request. Leia mais sobre como publicar em README.md e
contributing.md.
Regra básica de postagem:
"Você" acha interessante? É útil para "você"? Pode ser utilizado com Python
ou é útil para quem usa Python? Está esperando o que? Publica logo, que
estou louco para ler...

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


Re: Error on execute migration (create index) when set db_name with quoted string

2017-12-02 Thread Carlos Leite
Thanks again Simon

Ticket created  https://code.djangoproject.com/ticket/28876


-
Cadu Leite
| Twitter | Medium Blog | Google + |
| @cadu_leite <https://twitter.com/cadu_leite> | @cadu_leite
<https://medium.com/@cadu_leite> | +CarlosLeite
<https://plus.google.com/u/0/+CarlosLeite> |

http://people.python.org.br/

On Wed, Nov 29, 2017 at 3:59 PM, Carlos Leite <cadu...@gmail.com> wrote:

>
> Sure,
> its great to help the project.
> thanks for your attention.
>
> tonight (brazil) I will prepare the ticket.
>
> cheers
>
>
> -
> Cadu Leite
> | Twitter | Medium Blog | Google + |
> | @cadu_leite <https://twitter.com/cadu_leite> | @cadu_leite
> <https://medium.com/@cadu_leite> | +CarlosLeite
> <https://plus.google.com/u/0/+CarlosLeite> |
>
> http://people.python.org.br/
>
> On Tue, Nov 28, 2017 at 6:30 PM, Simon Charette <charett...@gmail.com>
> wrote:
>
>> Hello Carlos,
>>
>> Thank you for taking the time to reproduce the issue against the upcoming
>> 1.11 release.
>>
>> It looks like `Index` class doesn't use the same name generation logic as
>> the schema editor for some reason[0] so it will be have to be adjusted in
>> a similar way.
>>
>> Could you file a new ticket[1] referencing this thread and detailing the
>> issue
>> you are encoutering? It should be eligible for a backport since this is a
>> bug
>> in a newly introduced feature.
>>
>
>
>
>
>>
>> Until a 1.11.x version fixing the issue is released you can work around
>> the
>> issue by defining an Index(name)[2] manually.
>>
>> Cheers,
>> Simon
>>
>> [0] https://github.com/django/django/blob/89db4293d406136268
>> 33860de28e8ccdd413/django/db/models/indexes.py#L96-L122
>> [1] https://code.djangoproject.com/newticket
>> [2] https://docs.djangoproject.com/en/1.11/ref/models/indexes/#name
>>
>>
>> Le mardi 28 novembre 2017 09:01:06 UTC-5, Carlos Leite a écrit :
>>
>>>
>>> Testing the pacth for ticket/28792 at [1]
>>> with Python 2.7, Django 1.11
>>> to test badly formed  double quoted db_table name
>>>
>>> db_table = '"tbl_litle_name"',
>>>
>>> [1] https://code.djangoproject.com/ticket/28792
>>>
>>>
>>>
>>> Django Branch 1.11
>>> --
>>>
>>> I've aplied this commit
>>>
>>> $pip install -e git+https://github.com/django/
>>> django.git@a35ab95ed#egg=django
>>>
>>>
>>>
>>> Migration Initial
>>> -
>>>
>>> # -*- coding: utf-8 -*-
>>> # Generated by Django 1.11.8.dev20171115030630 on 2017-11-28 13:44
>>> from __future__ import unicode_literals
>>>
>>> from django.db import migrations, models
>>> import django.db.models.deletion
>>>
>>>
>>> class Migration(migrations.Migration):
>>>
>>> initial = True
>>>
>>> dependencies = [
>>> ]
>>>
>>> operations = [
>>> migrations.CreateModel(
>>> name='Author',
>>> fields=[
>>> ('id', models.AutoField(auto_created=True,
>>> primary_key=True, serialize=False, verbose_name='ID')),
>>> ('name', models.CharField(max_length=50,
>>> verbose_name='author name')),
>>> ],
>>> options={
>>> 'ordering': ['name'],
>>> 'get_latest_by': 'name',
>>> 'verbose_name': 'Author',
>>> 'verbose_name_plural': 'Authors',
>>> },
>>> ),
>>> migrations.CreateModel(
>>> name='Book',
>>> fields=[
>>> ('id', models.AutoField(auto_created=True,
>>> primary_key=True, serialize=False, verbose_name='ID')),
>>> ('name', models.CharField(help_text="book's name",
>>> max_length=50, verbose_name='book name')),
>>> ('isbn_10', models.CharField(blank=True,
>>> db_column='old_isbn_number', db_index=True, help_text='international
>>> standart book number (old length 10)', max_length=10, null=True)),
>>> ('isbn_13', models.CharField(blank=True, db_index=True,
>>> help_text='int

Re: Error on execute migration (create index) when set db_name with quoted string

2017-11-29 Thread Carlos Leite
Sure,
its great to help the project.
thanks for your attention.

tonight (brazil) I will prepare the ticket.

cheers


-
Cadu Leite
| Twitter | Medium Blog | Google + |
| @cadu_leite <https://twitter.com/cadu_leite> | @cadu_leite
<https://medium.com/@cadu_leite> | +CarlosLeite
<https://plus.google.com/u/0/+CarlosLeite> |

http://people.python.org.br/

On Tue, Nov 28, 2017 at 6:30 PM, Simon Charette <charett...@gmail.com>
wrote:

> Hello Carlos,
>
> Thank you for taking the time to reproduce the issue against the upcoming
> 1.11 release.
>
> It looks like `Index` class doesn't use the same name generation logic as
> the schema editor for some reason[0] so it will be have to be adjusted in
> a similar way.
>
> Could you file a new ticket[1] referencing this thread and detailing the
> issue
> you are encoutering? It should be eligible for a backport since this is a
> bug
> in a newly introduced feature.
>




>
> Until a 1.11.x version fixing the issue is released you can work around the
> issue by defining an Index(name)[2] manually.
>
> Cheers,
> Simon
>
> [0] https://github.com/django/django/blob/89db4293d40613626833860de2
> 8e8ccdd413/django/db/models/indexes.py#L96-L122
> [1] https://code.djangoproject.com/newticket
> [2] https://docs.djangoproject.com/en/1.11/ref/models/indexes/#name
>
>
> Le mardi 28 novembre 2017 09:01:06 UTC-5, Carlos Leite a écrit :
>
>>
>> Testing the pacth for ticket/28792 at [1]
>> with Python 2.7, Django 1.11
>> to test badly formed  double quoted db_table name
>>
>> db_table = '"tbl_litle_name"',
>>
>> [1] https://code.djangoproject.com/ticket/28792
>>
>>
>>
>> Django Branch 1.11
>> --
>>
>> I've aplied this commit
>>
>> $pip install -e git+https://github.com/django/
>> django.git@a35ab95ed#egg=django
>>
>>
>>
>> Migration Initial
>> -
>>
>> # -*- coding: utf-8 -*-
>> # Generated by Django 1.11.8.dev20171115030630 on 2017-11-28 13:44
>> from __future__ import unicode_literals
>>
>> from django.db import migrations, models
>> import django.db.models.deletion
>>
>>
>> class Migration(migrations.Migration):
>>
>> initial = True
>>
>> dependencies = [
>> ]
>>
>> operations = [
>> migrations.CreateModel(
>> name='Author',
>> fields=[
>> ('id', models.AutoField(auto_created=True,
>> primary_key=True, serialize=False, verbose_name='ID')),
>> ('name', models.CharField(max_length=50,
>> verbose_name='author name')),
>> ],
>> options={
>> 'ordering': ['name'],
>> 'get_latest_by': 'name',
>> 'verbose_name': 'Author',
>> 'verbose_name_plural': 'Authors',
>> },
>> ),
>> migrations.CreateModel(
>> name='Book',
>> fields=[
>> ('id', models.AutoField(auto_created=True,
>> primary_key=True, serialize=False, verbose_name='ID')),
>> ('name', models.CharField(help_text="book's name",
>> max_length=50, verbose_name='book name')),
>> ('isbn_10', models.CharField(blank=True,
>> db_column='old_isbn_number', db_index=True, help_text='international
>> standart book number (old length 10)', max_length=10, null=True)),
>> ('isbn_13', models.CharField(blank=True, db_index=True,
>> help_text='international standart book number (after 2007 jan 01)',
>> max_length=13, unique=True)),
>> ('language', models.CharField(blank=True,
>> choices=[('PORTUGUESE_BRAZIL', 'Portugu\xeas Brasil'), ('PORTUGUES',
>> 'Portugu\xeas'), ('ENGLISH', 'English'), ('FRANCE', 'France'), ('ESPANISH',
>> 'Espa\xf1ol')], help_text='edition length', max_length=5, null=True)),
>> ],
>> options={
>> 'ordering': ['name'],
>> 'get_latest_by': 'name',
>> 'verbose_name': 'book',
>> 'verbose_name_plural': 'books',
>> },
>> ),
>> migrations.CreateModel(
>> name='Publisher',
>>     fields=[
>> ('id', models.AutoField(auto_created=True,
>> primary_key=True, serialize=False, verbose_name='ID')),
>> ('name', models.CharField(max_len

Re: Error on execute migration (create index) when set db_name with quoted string

2017-11-28 Thread Simon Charette
Hello Carlos,

Thank you for taking the time to reproduce the issue against the upcoming
1.11 release.

It looks like `Index` class doesn't use the same name generation logic as
the schema editor for some reason[0] so it will be have to be adjusted in
a similar way.

Could you file a new ticket[1] referencing this thread and detailing the 
issue
you are encoutering? It should be eligible for a backport since this is a 
bug
in a newly introduced feature.

Until a 1.11.x version fixing the issue is released you can work around the
issue by defining an Index(name)[2] manually.

Cheers,
Simon

[0] 
https://github.com/django/django/blob/89db4293d40613626833860de28e8ccdd413/django/db/models/indexes.py#L96-L122
[1] https://code.djangoproject.com/newticket
[2] https://docs.djangoproject.com/en/1.11/ref/models/indexes/#name

Le mardi 28 novembre 2017 09:01:06 UTC-5, Carlos Leite a écrit :
>
>
> Testing the pacth for ticket/28792 at [1]
> with Python 2.7, Django 1.11
> to test badly formed  double quoted db_table name
>
> db_table = '"tbl_litle_name"',
>
> [1] https://code.djangoproject.com/ticket/28792
>
>
>
> Django Branch 1.11
> --
>
> I've aplied this commit 
>
> $pip install -e git+
> https://github.com/django/django.git@a35ab95ed#egg=django
>
>
>
> Migration Initial
> -
>
> # -*- coding: utf-8 -*-
> # Generated by Django 1.11.8.dev20171115030630 on 2017-11-28 13:44
> from __future__ import unicode_literals
>
> from django.db import migrations, models
> import django.db.models.deletion
>
>
> class Migration(migrations.Migration):
>
> initial = True
>
> dependencies = [
> ]
>
> operations = [
> migrations.CreateModel(
> name='Author',
> fields=[
> ('id', models.AutoField(auto_created=True, 
> primary_key=True, serialize=False, verbose_name='ID')),
> ('name', models.CharField(max_length=50, 
> verbose_name='author name')),
> ],
> options={
> 'ordering': ['name'],
> 'get_latest_by': 'name',
> 'verbose_name': 'Author',
> 'verbose_name_plural': 'Authors',
> },
> ),
> migrations.CreateModel(
> name='Book',
> fields=[
> ('id', models.AutoField(auto_created=True, 
> primary_key=True, serialize=False, verbose_name='ID')),
> ('name', models.CharField(help_text="book's name", 
> max_length=50, verbose_name='book name')),
> ('isbn_10', models.CharField(blank=True, 
> db_column='old_isbn_number', db_index=True, help_text='international 
> standart book number (old length 10)', max_length=10, null=True)),
> ('isbn_13', models.CharField(blank=True, db_index=True, 
> help_text='international standart book number (after 2007 jan 01)', 
> max_length=13, unique=True)),
> ('language', models.CharField(blank=True, 
> choices=[('PORTUGUESE_BRAZIL', 'Portugu\xeas Brasil'), ('PORTUGUES', 
> 'Portugu\xeas'), ('ENGLISH', 'English'), ('FRANCE', 'France'), ('ESPANISH', 
> 'Espa\xf1ol')], help_text='edition length', max_length=5, null=True)),
> ],
> options={
> 'ordering': ['name'],
> 'get_latest_by': 'name',
> 'verbose_name': 'book',
> 'verbose_name_plural': 'books',
> },
> ),
> migrations.CreateModel(
> name='Publisher',
> fields=[
> ('id', models.AutoField(auto_created=True, 
> primary_key=True, serialize=False, verbose_name='ID')),
> ('name', models.CharField(max_length=50, 
> verbose_name='publisher name')),
> ],
> options={
> 'get_latest_by': 'name',
>     'ordering': ['name'],
> 'verbose_name_plural': 'Publishers',
> 'db_table': '"tbl_litle_name"',
> 'verbose_name': 'Publiser',
> },
> ),
> migrations.AddIndex(
> model_name='publisher',
> index=models.Index(fields=['name'], 
> name='"tbl_litle__name_408be5_idx'),
> ),
> migrations.AddField(
> model_name='book',
> name='author',
> field=models.ManyToManyField(blank=True, help_text="author's 
> name", null=True, to='testapp.Author'),
> ),
> migrations.AddField(
> model_name='book',
> name='publisher',
> field=models.ForeignKey(blank=True, null=True, 

Re: Error on execute migration (create index) when set db_name with quoted string

2017-11-28 Thread Carlos Leite
Testing the pacth for ticket/28792 at [1]
with Python 2.7, Django 1.11
to test badly formed  double quoted db_table name

db_table = '"tbl_litle_name"',

[1] https://code.djangoproject.com/ticket/28792



Django Branch 1.11
--

I've aplied this commit

$pip install -e git+
https://github.com/django/django.git@a35ab95ed#egg=django



Migration Initial
-

# -*- coding: utf-8 -*-
# Generated by Django 1.11.8.dev20171115030630 on 2017-11-28 13:44
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Author',
fields=[
('id', models.AutoField(auto_created=True,
primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50,
verbose_name='author name')),
],
options={
'ordering': ['name'],
'get_latest_by': 'name',
'verbose_name': 'Author',
'verbose_name_plural': 'Authors',
},
),
migrations.CreateModel(
name='Book',
fields=[
('id', models.AutoField(auto_created=True,
primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text="book's name",
max_length=50, verbose_name='book name')),
('isbn_10', models.CharField(blank=True,
db_column='old_isbn_number', db_index=True, help_text='international
standart book number (old length 10)', max_length=10, null=True)),
('isbn_13', models.CharField(blank=True, db_index=True,
help_text='international standart book number (after 2007 jan 01)',
max_length=13, unique=True)),
('language', models.CharField(blank=True,
choices=[('PORTUGUESE_BRAZIL', 'Portugu\xeas Brasil'), ('PORTUGUES',
'Portugu\xeas'), ('ENGLISH', 'English'), ('FRANCE', 'France'), ('ESPANISH',
'Espa\xf1ol')], help_text='edition length', max_length=5, null=True)),
],
options={
'ordering': ['name'],
'get_latest_by': 'name',
'verbose_name': 'book',
'verbose_name_plural': 'books',
},
),
migrations.CreateModel(
name='Publisher',
fields=[
('id', models.AutoField(auto_created=True,
primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50,
verbose_name='publisher name')),
],
options={
'get_latest_by': 'name',
'ordering': ['name'],
'verbose_name_plural': 'Publishers',
'db_table': '"tbl_litle_name"',
'verbose_name': 'Publiser',
},
),
migrations.AddIndex(
model_name='publisher',
index=models.Index(fields=['name'],
name='"tbl_litle__name_408be5_idx'),
),
migrations.AddField(
model_name='book',
name='author',
field=models.ManyToManyField(blank=True, help_text="author's
name", null=True, to='testapp.Author'),
),
migrations.AddField(
model_name='book',
name='publisher',
field=models.ForeignKey(blank=True, null=True,
on_delete=django.db.models.deletion.CASCADE, to='testapp.Publisher'),
),
migrations.AddIndex(
    model_name='author',
index=models.Index(fields=['name'],
name='testapp_aut_name_02c4bc_idx'),
),
]



The model changed
-

class Publisher(models.Model):
"""
Book's Author - author is a Book's model supplement.
"""
name = models.CharField(verbose_name='publisher name', max_length=50,
null=False)

class Meta:
db_table = '"tbl_litle_name"'
get_latest_by = "name"
ordering = ['name', ]
verbose_name = 'Publiser'
verbose_name_plural = 'Publishers'
indexes = [
models.Index(fields=['name', ]),
]

def __unicode__(self):
return self.name


Generated Migration
---

# -*- coding: utf-8 -*-
# Generated by Django 1.11.8.dev20171115030630 on 2017-11-28 13:36
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
]

 #  ...  deleted for sanity

migrations.CreateModel(
name='Publisher',
fields=[
('id', models.AutoField(auto_created=True,
primary_key=True, serialize=False, verbose_name='ID')),
('name', mode

Re: Error on execute migration (create index) when set db_name with quoted string

2017-11-28 Thread Carlos Leite
Can I use double quoted names with others SGDBs , PostgreSQL ?
or it is specific for Oracle ...

by the way the patch didint work. Its another problem Is not a metter of
"." namespaced name.
 Its about if I can or not use '"tb_custom_name"'  double quoted string  =
' " " '

if I can use that (' " " ') for any database engine, I believe its a bug
...
and even changed the migration manually, the same error occur when create
an INDEX (at my example) ...

so, the error is at the method that generates the db_name string passed for
the ORM to create tables and constraints.




-
Cadu Leite
| Twitter | Medium Blog | Google + |
| @cadu_leite <https://twitter.com/cadu_leite> | @cadu_leite
<https://medium.com/@cadu_leite> | +CarlosLeite
<https://plus.google.com/u/0/+CarlosLeite> |

http://people.python.org.br/

On Tue, Nov 28, 2017 at 9:25 AM, Carlos Leite <cadu...@gmail.com> wrote:

> Thanks Simon,
>
> I tryied to find some issue related but found nothing.
>
> The ticket #28792 seems exactly the case ...
>
> I'll take a couple of hours (at work), but I'll try that patch
> and regenarate the migrations.
>
> thanks again.
>
> -
> Cadu Leite
> | Twitter | Medium Blog | Google + |
> | @cadu_leite <https://twitter.com/cadu_leite> | @cadu_leite
> <https://medium.com/@cadu_leite> | +CarlosLeite
> <https://plus.google.com/u/0/+CarlosLeite> |
>
> http://people.python.org.br/
>
> On Tue, Nov 28, 2017 at 4:14 AM, Simon Charette <charett...@gmail.com>
> wrote:
>
>> Hey Carlos,
>>
>> I believe the trailing quote truncation issue might be solved in the yet
>> to be released
>> 1.11.8[0][1] version.
>>
>> Could you confirm whether or not it's the case? You'll have to regenerate
>> your migration.
>>
>> Best,
>> Simon
>>
>> [0] https://github.com/django/django/commit/a35ab95ed4eec5c62fa1
>> 9bdc69ecfe0eff3e1fca
>> [1] https://code.djangoproject.com/ticket/28792
>>
>>
>> Le lundi 27 novembre 2017 23:24:59 UTC-5, Carlos Leite a écrit :
>>>
>>> ooops
>>>
>>>
>>> in the migration 0007 the index name seems badly formed
>>>
>>> ```python
>>>...
>>> migrations.AddIndex(
>>> model_name='publisher',
>>> index=models.Index(fields=['name'], name='"big_name-w_name_cd0539_idx'),
>>>  # <<<<<<<  there is a " in plus. and its never closed.
>>> ),
>>> ```
>>>
>>> On Tuesday, November 28, 2017 at 2:01:56 AM UTC-2, Carlos Leite wrote:
>>>>
>>>> I was making some introspections on meta attributes from a Model class
>>>> jsut to check what changes when we set some attributes on Meta class
>>>> and etc...
>>>>
>>>>
>>>> TO check the Meta.db_name
>>>> I read the docs and saw that I could use quoted strings as told ..
>>>>
>>>>
>>>> "
>>>> ... o prevent such transformations, use a quoted name as the value for
>>>> db_table:
>>>>
>>>> > db_table = '"name_left_in_lowercase"'
>>>>
>>>>  Such quoted names can also be used with Django’s other supported
>>>> database backends; except for Oracle, however, the quotes have no effect.
>>>> See the Oracle notes
>>>> <https://docs.djangoproject.com/en/1.8/ref/databases/#oracle-notes>
>>>> for more details.
>>>> "
>>>> at https://docs.djangoproject.com/en/1.8/ref/models/options/#db-table
>>>>
>>>>
>>>> Well, when I tried to *migrate* I got the error, during the index
>>>> creation, described below.
>>>> Is it a bug ? or I miss soething ?
>>>> I just tried to set a custom name for a table, with quotes and hyphens
>>>> 8P
>>>>
>>>>
>>>> '"big_name-with-hyphen-left_in_lowercase"'
>>>>
>>>> the error hapends when PostgreSQL tries to create an index and Django
>>>> named with part of the tables name.
>>>>
>>>>
>>>> ### The Model Class
>>>>
>>>>
>>>> class Publisher(models.Model):
>>>> """
>>>> Book's Author - author is a Book's model supplement.
>>>> """
>>>> name = models.CharField(verbose_name='publisher n

Re: Error on execute migration (create index) when set db_name with quoted string

2017-11-28 Thread Carlos Leite
Thanks Simon,

I tryied to find some issue related but found nothing.

The ticket #28792 seems exactly the case ...

I'll take a couple of hours (at work), but I'll try that patch
and regenarate the migrations.

thanks again.

-
Cadu Leite
| Twitter | Medium Blog | Google + |
| @cadu_leite <https://twitter.com/cadu_leite> | @cadu_leite
<https://medium.com/@cadu_leite> | +CarlosLeite
<https://plus.google.com/u/0/+CarlosLeite> |

http://people.python.org.br/

On Tue, Nov 28, 2017 at 4:14 AM, Simon Charette <charett...@gmail.com>
wrote:

> Hey Carlos,
>
> I believe the trailing quote truncation issue might be solved in the yet
> to be released
> 1.11.8[0][1] version.
>
> Could you confirm whether or not it's the case? You'll have to regenerate
> your migration.
>
> Best,
> Simon
>
> [0] https://github.com/django/django/commit/a35ab95ed4eec5c62fa19bdc69ecfe
> 0eff3e1fca
> [1] https://code.djangoproject.com/ticket/28792
>
>
> Le lundi 27 novembre 2017 23:24:59 UTC-5, Carlos Leite a écrit :
>>
>> ooops
>>
>>
>> in the migration 0007 the index name seems badly formed
>>
>> ```python
>>...
>> migrations.AddIndex(
>> model_name='publisher',
>> index=models.Index(fields=['name'], name='"big_name-w_name_cd0539_idx'),
>>  # <<<<<<<  there is a " in plus. and its never closed.
>> ),
>> ```
>>
>> On Tuesday, November 28, 2017 at 2:01:56 AM UTC-2, Carlos Leite wrote:
>>>
>>> I was making some introspections on meta attributes from a Model class
>>> jsut to check what changes when we set some attributes on Meta class and
>>> etc...
>>>
>>>
>>> TO check the Meta.db_name
>>> I read the docs and saw that I could use quoted strings as told ..
>>>
>>>
>>> "
>>> ... o prevent such transformations, use a quoted name as the value for
>>> db_table:
>>>
>>> > db_table = '"name_left_in_lowercase"'
>>>
>>>  Such quoted names can also be used with Django’s other supported
>>> database backends; except for Oracle, however, the quotes have no effect.
>>> See the Oracle notes
>>> <https://docs.djangoproject.com/en/1.8/ref/databases/#oracle-notes> for
>>> more details.
>>> "
>>> at https://docs.djangoproject.com/en/1.8/ref/models/options/#db-table
>>>
>>>
>>> Well, when I tried to *migrate* I got the error, during the index
>>> creation, described below.
>>> Is it a bug ? or I miss soething ?
>>> I just tried to set a custom name for a table, with quotes and hyphens 8P
>>>
>>>
>>> '"big_name-with-hyphen-left_in_lowercase"'
>>>
>>> the error hapends when PostgreSQL tries to create an index and Django
>>> named with part of the tables name.
>>>
>>>
>>> ### The Model Class
>>>
>>>
>>> class Publisher(models.Model):
>>> """
>>> Book's Author - author is a Book's model supplement.
>>> """
>>> name = models.CharField(verbose_name='publisher name', max_length=50,
>>> null=False)
>>>
>>>
>>> class Meta:
>>> db_table = '"big_name-with-hyphen-left_in_lowercase"'
>>> get_latest_by = "name"
>>> ordering = ['name', ]
>>> verbose_name = 'Publiser'
>>> verbose_name_plural = 'Publishers'
>>> indexes = [
>>> models.Index(fields=['name', ]),
>>> ]
>>>
>>>
>>>
>>>
>>> ### The Migration 0007
>>>
>>>
>>> # -*- coding: utf-8 -*-
>>> # Generated by Django 1.11 on 2017-11-28 03:15
>>> from __future__ import unicode_literals
>>>
>>>
>>> from django.db import migrations, models
>>>
>>>
>>>
>>>
>>> class Migration(migrations.Migration):
>>>
>>>
>>> dependencies = [
>>> ('testapp', '0006_auto_20171127_1927'),
>>> ]
>>>
>>>
>>> operations = [
>>> migrations.RemoveIndex(
>>> model_name='publisher',
>>> name='testapp_pub_name_88e073_idx',
>>> ),
>>> migrations.AddIndex(
>>> model_name='publisher',
>>> index=models.Index(fields=['name'], name='"big_name-w_name_cd0539_idx'),
>>> ),
>>> migrations.AlterModelTable(
>>> name='publisher',
>>> table='"b

Re: Error on execute migration (create index) when set db_name with quoted string

2017-11-27 Thread Simon Charette
Hey Carlos,

I believe the trailing quote truncation issue might be solved in the yet to 
be released
1.11.8[0][1] version.

Could you confirm whether or not it's the case? You'll have to regenerate 
your migration.

Best,
Simon

[0] 
https://github.com/django/django/commit/a35ab95ed4eec5c62fa19bdc69ecfe0eff3e1fca
[1] https://code.djangoproject.com/ticket/28792

Le lundi 27 novembre 2017 23:24:59 UTC-5, Carlos Leite a écrit :
>
> ooops 
>
>
> in the migration 0007 the index name seems badly formed 
>
> ```python 
>...
> migrations.AddIndex(
> model_name='publisher',
> index=models.Index(fields=['name'], 
> name='"big_name-w_name_cd0539_idx'),   # <<<<<<<  there is a " in plus. and 
> its never closed. 
> ),
> ```
>
> On Tuesday, November 28, 2017 at 2:01:56 AM UTC-2, Carlos Leite wrote:
>>
>> I was making some introspections on meta attributes from a Model class
>> jsut to check what changes when we set some attributes on Meta class and 
>> etc...
>>
>>
>> TO check the Meta.db_name
>> I read the docs and saw that I could use quoted strings as told ..
>>
>>
>> "
>> ... o prevent such transformations, use a quoted name as the value for 
>> db_table:
>>
>> > db_table = '"name_left_in_lowercase"' 
>>
>>  Such quoted names can also be used with Django’s other supported 
>> database backends; except for Oracle, however, the quotes have no effect. 
>> See the Oracle notes 
>> <https://docs.djangoproject.com/en/1.8/ref/databases/#oracle-notes> for 
>> more details.
>> "
>> at https://docs.djangoproject.com/en/1.8/ref/models/options/#db-table
>>
>>
>> Well, when I tried to *migrate* I got the error, during the index 
>> creation, described below.
>> Is it a bug ? or I miss soething ?
>> I just tried to set a custom name for a table, with quotes and hyphens 8P
>>
>>
>> '"big_name-with-hyphen-left_in_lowercase"'
>>
>> the error hapends when PostgreSQL tries to create an index and Django 
>> named with part of the tables name. 
>>
>>
>> ### The Model Class
>>
>>
>> class Publisher(models.Model):
>> """
>> Book's Author - author is a Book's model supplement.
>> """
>> name = models.CharField(verbose_name='publisher name', max_length=50, 
>> null=False)
>>
>>
>> class Meta:
>> db_table = '"big_name-with-hyphen-left_in_lowercase"'
>> get_latest_by = "name"
>> ordering = ['name', ]
>> verbose_name = 'Publiser'
>> verbose_name_plural = 'Publishers'
>> indexes = [
>> models.Index(fields=['name', ]),
>> ]
>>
>>
>>
>>
>> ### The Migration 0007
>>
>>
>> # -*- coding: utf-8 -*-
>> # Generated by Django 1.11 on 2017-11-28 03:15
>> from __future__ import unicode_literals
>>
>>
>> from django.db import migrations, models
>>
>>
>>
>>
>> class Migration(migrations.Migration):
>>
>>
>> dependencies = [
>> ('testapp', '0006_auto_20171127_1927'),
>> ]
>>
>>
>> operations = [
>> migrations.RemoveIndex(
>> model_name='publisher',
>> name='testapp_pub_name_88e073_idx',
>> ),
>> migrations.AddIndex(
>> model_name='publisher',
>> index=models.Index(fields=['name'], name='"big_name-w_name_cd0539_idx'),
>> ),
>> migrations.AlterModelTable(
>> name='publisher',
>> table='"big_name-with-hyphen-left_in_lowercase"',
>> ),
>> ]
>>
>>
>>
>>
>> ### traceback
>>
>>
>> $python manage.py makemigrations
>> System check identified some issues:
>>
>>
>> Migrations for 'testapp':
>> testproject/testapp/migrations/0007_auto_20171128_0315.py
>> - Remove index testapp_pub_name_88e073_idx from publisher
>> - Create index "big_name-w_name_cd0539_idx on field(s) name of model 
>> publisher
>> - Rename table for publisher to "big_name-with-hyphen-left_in_lowercase"
>> (dj_datadictionary) 
>> 20171125.Sat01:15:52cadu>/Volumes/p10G/prj/dj_datadictionary_testproject/testproject>
>>
>>
>>
>>
>> $python manage.py migrate
>> System check identified some issues:
>>
>>
>> Operations to perform:
>> Apply all migrations: admin, auth, contenttypes, sessions, testapp
>> Running migrations:
>> Applying testapp.0007_auto_20171128_0315...Traceback (most recent call 
>> last):
>> File "manage.p

Re: Error on execute migration (create index) when set db_name with quoted string

2017-11-27 Thread Carlos Leite
ooops 


in the migration 0007 the index name seems badly formed 

```python 
   ...
migrations.AddIndex(
model_name='publisher',
index=models.Index(fields=['name'], 
name='"big_name-w_name_cd0539_idx'),   # <<<<<<<  there is a " in plus. and 
its never closed. 
),
```

On Tuesday, November 28, 2017 at 2:01:56 AM UTC-2, Carlos Leite wrote:
>
> I was making some introspections on meta attributes from a Model class
> jsut to check what changes when we set some attributes on Meta class and 
> etc...
>
>
> TO check the Meta.db_name
> I read the docs and saw that I could use quoted strings as told ..
>
>
> "
> ... o prevent such transformations, use a quoted name as the value for 
> db_table:
>
> > db_table = '"name_left_in_lowercase"' 
>
>  Such quoted names can also be used with Django’s other supported database 
> backends; except for Oracle, however, the quotes have no effect. See the 
> Oracle 
> notes <https://docs.djangoproject.com/en/1.8/ref/databases/#oracle-notes> 
> for more details.
> "
> at https://docs.djangoproject.com/en/1.8/ref/models/options/#db-table
>
>
> Well, when I tried to *migrate* I got the error, during the index 
> creation, described below.
> Is it a bug ? or I miss soething ?
> I just tried to set a custom name for a table, with quotes and hyphens 8P
>
>
> '"big_name-with-hyphen-left_in_lowercase"'
>
> the error hapends when PostgreSQL tries to create an index and Django 
> named with part of the tables name. 
>
>
> ### The Model Class
>
>
> class Publisher(models.Model):
> """
> Book's Author - author is a Book's model supplement.
> """
> name = models.CharField(verbose_name='publisher name', max_length=50, 
> null=False)
>
>
> class Meta:
> db_table = '"big_name-with-hyphen-left_in_lowercase"'
> get_latest_by = "name"
> ordering = ['name', ]
> verbose_name = 'Publiser'
> verbose_name_plural = 'Publishers'
> indexes = [
> models.Index(fields=['name', ]),
> ]
>
>
>
>
> ### The Migration 0007
>
>
> # -*- coding: utf-8 -*-
> # Generated by Django 1.11 on 2017-11-28 03:15
> from __future__ import unicode_literals
>
>
> from django.db import migrations, models
>
>
>
>
> class Migration(migrations.Migration):
>
>
> dependencies = [
> ('testapp', '0006_auto_20171127_1927'),
> ]
>
>
> operations = [
> migrations.RemoveIndex(
> model_name='publisher',
> name='testapp_pub_name_88e073_idx',
> ),
> migrations.AddIndex(
> model_name='publisher',
> index=models.Index(fields=['name'], name='"big_name-w_name_cd0539_idx'),
> ),
> migrations.AlterModelTable(
> name='publisher',
> table='"big_name-with-hyphen-left_in_lowercase"',
> ),
> ]
>
>
>
>
> ### traceback
>
>
> $python manage.py makemigrations
> System check identified some issues:
>
>
> Migrations for 'testapp':
> testproject/testapp/migrations/0007_auto_20171128_0315.py
> - Remove index testapp_pub_name_88e073_idx from publisher
> - Create index "big_name-w_name_cd0539_idx on field(s) name of model 
> publisher
> - Rename table for publisher to "big_name-with-hyphen-left_in_lowercase"
> (dj_datadictionary) 
> 20171125.Sat01:15:52cadu>/Volumes/p10G/prj/dj_datadictionary_testproject/testproject>
>
>
>
>
> $python manage.py migrate
> System check identified some issues:
>
>
> Operations to perform:
> Apply all migrations: admin, auth, contenttypes, sessions, testapp
> Running migrations:
> Applying testapp.0007_auto_20171128_0315...Traceback (most recent call 
> last):
> File "manage.py", line 22, in 
> execute_from_command_line(sys.argv)
> File 
> "/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site-packages/django/core/management/__init__.py",
>  
> line 363, in execute_from_command_line
> utility.execute()
> File 
> "/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site-packages/django/core/management/__init__.py",
>  
> line 355, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
> File 
> "/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site-packages/django/core/management/base.py",
>  
> line 283, in run_from_argv
> self.execute(*args, **cmd_options)
> File 
> "/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site-packages/django/core/management/base.py",
>  
> line 330, in execute
> output = self.handle(*args, **options)
> File 
> "/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site-packages/django/core/management/commands/migrate.py",
>

Error on execute migration (create index) when set db_name with quoted string

2017-11-27 Thread Carlos Leite
I was making some introspections on meta attributes from a Model class
jsut to check what changes when we set some attributes on Meta class and 
etc...


TO check the Meta.db_name
I read the docs and saw that I could use quoted strings as told ..


"
... o prevent such transformations, use a quoted name as the value for 
db_table:

> db_table = '"name_left_in_lowercase"' 

 Such quoted names can also be used with Django’s other supported database 
backends; except for Oracle, however, the quotes have no effect. See the Oracle 
notes <https://docs.djangoproject.com/en/1.8/ref/databases/#oracle-notes> 
for more details.
"
at https://docs.djangoproject.com/en/1.8/ref/models/options/#db-table


Well, when I tried to *migrate* I got the error, during the index creation, 
described below.
Is it a bug ? or I miss soething ?
I just tried to set a custom name for a table, with quotes and hyphens 8P


'"big_name-with-hyphen-left_in_lowercase"'

the error hapends when PostgreSQL tries to create an index and Django named 
with part of the tables name. 


### The Model Class


class Publisher(models.Model):
"""
Book's Author - author is a Book's model supplement.
"""
name = models.CharField(verbose_name='publisher name', max_length=50, 
null=False)


class Meta:
db_table = '"big_name-with-hyphen-left_in_lowercase"'
get_latest_by = "name"
ordering = ['name', ]
verbose_name = 'Publiser'
verbose_name_plural = 'Publishers'
indexes = [
models.Index(fields=['name', ]),
]




### The Migration 0007


# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-11-28 03:15
from __future__ import unicode_literals


from django.db import migrations, models




class Migration(migrations.Migration):


dependencies = [
('testapp', '0006_auto_20171127_1927'),
]


operations = [
migrations.RemoveIndex(
model_name='publisher',
name='testapp_pub_name_88e073_idx',
),
migrations.AddIndex(
model_name='publisher',
index=models.Index(fields=['name'], name='"big_name-w_name_cd0539_idx'),
),
migrations.AlterModelTable(
name='publisher',
table='"big_name-with-hyphen-left_in_lowercase"',
),
]




### traceback


$python manage.py makemigrations
System check identified some issues:


Migrations for 'testapp':
testproject/testapp/migrations/0007_auto_20171128_0315.py
- Remove index testapp_pub_name_88e073_idx from publisher
- Create index "big_name-w_name_cd0539_idx on field(s) name of model 
publisher
- Rename table for publisher to "big_name-with-hyphen-left_in_lowercase"
(dj_datadictionary) 
20171125.Sat01:15:52cadu>/Volumes/p10G/prj/dj_datadictionary_testproject/testproject>




$python manage.py migrate
System check identified some issues:


Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions, testapp
Running migrations:
Applying testapp.0007_auto_20171128_0315...Traceback (most recent call 
last):
File "manage.py", line 22, in 
execute_from_command_line(sys.argv)
File 
"/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site-packages/django/core/management/__init__.py",
 
line 363, in execute_from_command_line
utility.execute()
File 
"/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site-packages/django/core/management/__init__.py",
 
line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File 
"/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site-packages/django/core/management/base.py",
 
line 283, in run_from_argv
self.execute(*args, **cmd_options)
File 
"/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site-packages/django/core/management/base.py",
 
line 330, in execute
output = self.handle(*args, **options)
File 
"/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site-packages/django/core/management/commands/migrate.py",
 
line 204, in handle
fake_initial=fake_initial,
File 
"/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site-packages/django/db/migrations/executor.py",
 
line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, 
fake_initial=fake_initial)
File 
"/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site-packages/django/db/migrations/executor.py",
 
line 145, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, 
fake_initial=fake_initial)
File 
"/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site-packages/django/db/migrations/executor.py",
 
line 244, in apply_migration
state = migration.apply(state, schema_editor)
File 
"/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site-packages/django/db/migrations/migration.py",
 
line 129, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, 
project_state)
File 
"/Users/cadu/Envs/dj_datadictionary/lib/python2.7/site-packages/django/db/migrations/operations/models.py",
 
line 785, in database_forwards
schema

Re: django.urls.exceptions.NoReverseMatch: Reverse for 'index' not found. 'index' is not a valid view function or pattern name.

2017-09-28 Thread James Schneider
On Sep 27, 2017 8:59 PM, "harsh sharma" <harshsharma199...@gmail.com> wrote:

i m a noob in django And i dont know why i am getting this error

my views.py file:

from django.shortcuts import render,render_to_response
from django.http import HttpResponse
from all.models import ALL
from django.template import RequestContext
# Create your views here.
def home(request):
return render(request, 'index.html', {'ne': ne})


def technology(request):
return HttpResponse('hello')

def index(request):
assert isinstance(request , HttpResponse)

return render(request, 'index.html') .

my url file

url(r'^$', all.views.index),
url(r'^technology', all.views.index),
url(r'^index$', all.views.home),
url(r'^admin/', admin.site.urls),
]


None of the code you posted would have triggered such an error.

What is contained in the template that is being rendered when the error is
shown?

My guess is that you have something like {% url 'index' %} inside of your
template, but you don't have any URL patterns named 'index' shown.

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


django.urls.exceptions.NoReverseMatch: Reverse for 'index' not found. 'index' is not a valid view function or pattern name.

2017-09-27 Thread harsh sharma
i m a noob in django And i dont know why i am getting this error

my views.py file:

from django.shortcuts import render,render_to_response
from django.http import HttpResponse
from all.models import ALL
from django.template import RequestContext
# Create your views here.
def home(request):
return render(request, 'index.html', {'ne': ne})


def technology(request):
return HttpResponse('hello')

def index(request):
assert isinstance(request , HttpResponse)

return render(request, 'index.html') . 

my url file

url(r'^$', all.views.index),
url(r'^technology', all.views.index),
url(r'^index$', all.views.home),
url(r'^admin/', admin.site.urls),
]

-- 
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/41876d02-56e0-48c8-8722-17fc08ed32f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Channels error : (index):173 Disconnected from chat socket websocketbridge.js:118 WebSocket connection to 'ws://www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: Unexp

2017-05-19 Thread djangorobert
THis is the new error that im getting after fixing my redis configuration 
in the settings.py 

WebSocket connection to 'ws://openchat.us:24711/' failed: WebSocket is 
closed before the connection is established.


On Thursday, May 18, 2017 at 2:08:05 PM UTC-5, djangorobert wrote:
>
>
> <https://lh3.googleusercontent.com/-2PFC_4eUlH0/WR3xENBP3xI/AP4/d552fmpgbgI0JGhQdOl7LLJItQCDC5UDQCLcB/s1600/websocketerror2.GIF>
>
>
> <https://lh3.googleusercontent.com/-VD_L4lkOpMA/WR3w_KUDTmI/AP0/pQy37FT8H68UZhrDT7x5Zf2Y9eHRLF5bgCLcB/s1600/websocketerror3.GIF>
>
>
> On Wednesday, May 17, 2017 at 3:59:47 PM UTC-5, djangorobert wrote:
>>
>> currently getting this error : 
>> WebSocket connection to 'ws://www.openchat.us/chat/stream/' failed: 
>> Error during WebSocket handshake: Unexpected response code: 404
>> connect @ websocketbridge.js:118
>> (index):174 Disconnected from chat socket
>>
>> On Tuesday, May 16, 2017 at 11:31:19 PM UTC-5, djangorobert wrote:
>>>
>>> thanks ya that seemed to help a little now im running into a new error: 
>>>
>>> WebSocket connection to 'ws://www.openchat.us/griper' failed: WebSocket 
>>> is closed before the connection is established.
>>> (index):173 Disconnected from chat socket
>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>> www.openchat.us/griper' failed: Error during WebSocket handshake: 
>>> Unexpected response code: 403
>>> connect @ websocketbridge.js:118
>>> (index):173 Disconnected from chat socket
>>>
>>> hmmm :)
>>>
>>> On Tuesday, May 16, 2017 at 8:26:18 PM UTC-5, Dylan Reinhold wrote:
>>>>
>>>> Sorry sounds like you will need to configure somting in your webfaction 
>>>> controll panel.
>>>>
>>>> Here is another person with same issue, they said it fixed it for them.
>>>> https://github.com/django/channels/issues/445
>>>>
>>>> On Tue, May 16, 2017 at 5:46 PM, djangorobert <djangoc...@gmail.com> 
>>>> wrote:
>>>>
>>>>> hi Dylan Im usingWebfaction Im kind of new to django channels 
>>>>> my website is www.openchat.us 
>>>>>
>>>>> do you mean redisserver ?
>>>>>
>>>>> or are you refering to the commands python mange.py runserver or 
>>>>> runworkder? because with those commancds im kind of confused when ussing 
>>>>> webfaction 
>>>>> im using putty to enter the commands to my webfaction account
>>>>>
>>>>> On Tuesday, May 16, 2017 at 5:49:04 PM UTC-5, Dylan Reinhold wrote:
>>>>>>
>>>>>> How are you running the web server?
>>>>>> Looks like your web socket traffic is not being set to daphene. 
>>>>>> Probably hitting the regular django listener and its returning a 404.
>>>>>>
>>>>>> Dylan
>>>>>>
>>>>>> On Tue, May 16, 2017 at 3:39 PM, djangorobert <djangoc...@gmail.com> 
>>>>>> wrote:
>>>>>>
>>>>>>> working on the Django channels example : multi chat on Github 
>>>>>>> but am getting this error
>>>>>>>
>>>>>>>
>>>>>>> (index):173 Disconnected from chat socket
>>>>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>>>>> www.openchat.us/chat/stream/' failed: Error during WebSocket 
>>>>>>> handshake: Unexpected response code: 404
>>>>>>> connect @ websocketbridge.js:118
>>>>>>> (index):173 Disconnected from chat socket
>>>>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>>>>> www.openchat.us/chat/stream/' failed: Error during WebSocket 
>>>>>>> handshake: Unexpected response code: 404
>>>>>>> connect @ websocketbridge.js:118
>>>>>>> (index):173 Disconnected from chat socket
>>>>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>>>>> www.openchat.us/chat/stream/' failed: Error during WebSocket 
>>>>>>> handshake: Unexpected response code: 404
>>>>>>> connect @ websocketbridge.js:118
>>>>>>> (index):173 Disconnected from chat socket
>>>>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>>>>> www.openchat.us/chat/stream/' failed: Error during WebSocket 
>>>>

Re: Django Channels error : (index):173 Disconnected from chat socket websocketbridge.js:118 WebSocket connection to 'ws://www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: Unexp

2017-05-18 Thread djangorobert


<https://lh3.googleusercontent.com/-2PFC_4eUlH0/WR3xENBP3xI/AP4/d552fmpgbgI0JGhQdOl7LLJItQCDC5UDQCLcB/s1600/websocketerror2.GIF>

<https://lh3.googleusercontent.com/-VD_L4lkOpMA/WR3w_KUDTmI/AP0/pQy37FT8H68UZhrDT7x5Zf2Y9eHRLF5bgCLcB/s1600/websocketerror3.GIF>


On Wednesday, May 17, 2017 at 3:59:47 PM UTC-5, djangorobert wrote:
>
> currently getting this error : 
> WebSocket connection to 'ws://www.openchat.us/chat/stream/' failed: Error 
> during WebSocket handshake: Unexpected response code: 404
> connect @ websocketbridge.js:118
> (index):174 Disconnected from chat socket
>
> On Tuesday, May 16, 2017 at 11:31:19 PM UTC-5, djangorobert wrote:
>>
>> thanks ya that seemed to help a little now im running into a new error: 
>>
>> WebSocket connection to 'ws://www.openchat.us/griper' failed: WebSocket 
>> is closed before the connection is established.
>> (index):173 Disconnected from chat socket
>> websocketbridge.js:118 WebSocket connection to 'ws://
>> www.openchat.us/griper' failed: Error during WebSocket handshake: 
>> Unexpected response code: 403
>> connect @ websocketbridge.js:118
>> (index):173 Disconnected from chat socket
>>
>> hmmm :)
>>
>> On Tuesday, May 16, 2017 at 8:26:18 PM UTC-5, Dylan Reinhold wrote:
>>>
>>> Sorry sounds like you will need to configure somting in your webfaction 
>>> controll panel.
>>>
>>> Here is another person with same issue, they said it fixed it for them.
>>> https://github.com/django/channels/issues/445
>>>
>>> On Tue, May 16, 2017 at 5:46 PM, djangorobert <djangoc...@gmail.com> 
>>> wrote:
>>>
>>>> hi Dylan Im usingWebfaction Im kind of new to django channels 
>>>> my website is www.openchat.us 
>>>>
>>>> do you mean redisserver ?
>>>>
>>>> or are you refering to the commands python mange.py runserver or 
>>>> runworkder? because with those commancds im kind of confused when ussing 
>>>> webfaction 
>>>> im using putty to enter the commands to my webfaction account
>>>>
>>>> On Tuesday, May 16, 2017 at 5:49:04 PM UTC-5, Dylan Reinhold wrote:
>>>>>
>>>>> How are you running the web server?
>>>>> Looks like your web socket traffic is not being set to daphene. 
>>>>> Probably hitting the regular django listener and its returning a 404.
>>>>>
>>>>> Dylan
>>>>>
>>>>> On Tue, May 16, 2017 at 3:39 PM, djangorobert <djangoc...@gmail.com> 
>>>>> wrote:
>>>>>
>>>>>> working on the Django channels example : multi chat on Github 
>>>>>> but am getting this error
>>>>>>
>>>>>>
>>>>>> (index):173 Disconnected from chat socket
>>>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>>>> www.openchat.us/chat/stream/' failed: Error during WebSocket 
>>>>>> handshake: Unexpected response code: 404
>>>>>> connect @ websocketbridge.js:118
>>>>>> (index):173 Disconnected from chat socket
>>>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>>>> www.openchat.us/chat/stream/' failed: Error during WebSocket 
>>>>>> handshake: Unexpected response code: 404
>>>>>> connect @ websocketbridge.js:118
>>>>>> (index):173 Disconnected from chat socket
>>>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>>>> www.openchat.us/chat/stream/' failed: Error during WebSocket 
>>>>>> handshake: Unexpected response code: 404
>>>>>> connect @ websocketbridge.js:118
>>>>>> (index):173 Disconnected from chat socket
>>>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>>>> www.openchat.us/chat/stream/' failed: Error during WebSocket 
>>>>>> handshake: Unexpected response code: 404
>>>>>> connect @ websocketbridge.js:118
>>>>>> (index):173 Disconnected from chat socket
>>>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>>>> www.openchat.us/chat/stream/' failed: Error during WebSocket 
>>>>>> handshake: Unexpected response code: 404
>>>>>> connect @ websocketbridge.js:118
>>>>>> (index):173 Disconnected from chat socket
>>>>>> websocketbridge.js:118 WebSocket connection to 'ws

Re: Django Channels error : et connection to 'ws://www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: Unexpected response code: 404 connect @ websocketbridge.js:118 (index):174 Di

2017-05-18 Thread djangorobert


<https://lh3.googleusercontent.com/-kLcQrYchX48/WR3uFRq7hcI/APY/gTA2RQyIjZEjQoCgNgQOgFowAbqmR68QACLcB/s1600/websocketerror2.GIF>
here is what i am seeing in the bash command line after entering the 
command: daphne -p 27411 myproject.asgi:channel_layer

<https://lh3.googleusercontent.com/-Th9yIibIxLo/WR3uln_tHUI/APc/N5LYPRhXjtckXMymyVVciyQRkGkNW1ybwCLcB/s1600/websocketerror3.GIF>
and in the google tools i see this error: 

On Thursday, May 18, 2017 at 10:22:07 AM UTC-5, djangorobert wrote:
>
> not quite sure what im doing wrong with the django channels multichat 
> example 
>
> but seem to be getting this error:  connection to 'ws://
> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: 
> Unexpected response code: 404
> connect @ websocketbridge.js:118
> (index):174 Disconnected from chat socket
>
>
>
> the command i use is daphne -p 26358 myproject.asgi:channel_layer
>
> one question i do have is once i enter this command do i have to do it 
> again in the future what i mean is is this command like a python manage.py 
> runserver command that needs to be done to run everytime or is it a command 
> that is entered once. 
> One more thing I am using a webfaction account. 
> thanks
> IF anyone else has been through this error or problem before please 
> respond your feedback is appreciated. 
>

-- 
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/d555a089-7811-4a9d-9d1b-ecd5669f71e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Channels error : et connection to 'ws://www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: Unexpected response code: 404 connect @ websocketbridge.js:118 (index):174 Di

2017-05-18 Thread djangorobert


<https://lh3.googleusercontent.com/-3HTDh7NVtHA/WR3tZD9dn9I/APU/ls3qaOsHFu0KP_U0hhYD-ZCHJ60D5Y3CQCLcB/s1600/websocketerror.GIF>

here is the error that i am seeing after i enter the command daphne -p 
27411 myproject.asgi:channel_layer 
<https://lh3.googleusercontent.com/-3HTDh7NVtHA/WR3tZD9dn9I/APU/ls3qaOsHFu0KP_U0hhYD-ZCHJ60D5Y3CQCLcB/s1600/websocketerror.GIF>


On Thursday, May 18, 2017 at 10:22:07 AM UTC-5, djangorobert wrote:
>
> not quite sure what im doing wrong with the django channels multichat 
> example 
>
> but seem to be getting this error:  connection to 'ws://
> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: 
> Unexpected response code: 404
> connect @ websocketbridge.js:118
> (index):174 Disconnected from chat socket
>
>
>
> the command i use is daphne -p 26358 myproject.asgi:channel_layer
>
> one question i do have is once i enter this command do i have to do it 
> again in the future what i mean is is this command like a python manage.py 
> runserver command that needs to be done to run everytime or is it a command 
> that is entered once. 
> One more thing I am using a webfaction account. 
> thanks
> IF anyone else has been through this error or problem before please 
> respond your feedback is appreciated. 
>

-- 
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/637030a2-d3a6-4fa2-a8b4-01065042262e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Channels error : et connection to 'ws://www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: Unexpected response code: 404 connect @ websocketbridge.js:118 (index):174 Discon

2017-05-18 Thread djangorobert
not quite sure what im doing wrong with the django channels multichat 
example 

but seem to be getting this error:  connection to 
'ws://www.openchat.us/chat/stream/' failed: Error during WebSocket 
handshake: Unexpected response code: 404
connect @ websocketbridge.js:118
(index):174 Disconnected from chat socket



the command i use is daphne -p 26358 myproject.asgi:channel_layer

one question i do have is once i enter this command do i have to do it 
again in the future what i mean is is this command like a python manage.py 
runserver command that needs to be done to run everytime or is it a command 
that is entered once. 
One more thing I am using a webfaction account. 
thanks
IF anyone else has been through this error or problem before please respond 
your feedback is appreciated. 

-- 
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/01c38a9a-39ae-446b-9740-2d4c469552df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Channels error : (index):173 Disconnected from chat socket websocketbridge.js:118 WebSocket connection to 'ws://www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: Unexp

2017-05-17 Thread djangorobert
currently getting this error : 
WebSocket connection to 'ws://www.openchat.us/chat/stream/' failed: Error 
during WebSocket handshake: Unexpected response code: 404
connect @ websocketbridge.js:118
(index):174 Disconnected from chat socket

On Tuesday, May 16, 2017 at 11:31:19 PM UTC-5, djangorobert wrote:
>
> thanks ya that seemed to help a little now im running into a new error: 
>
> WebSocket connection to 'ws://www.openchat.us/griper' failed: WebSocket 
> is closed before the connection is established.
> (index):173 Disconnected from chat socket
> websocketbridge.js:118 WebSocket connection to 'ws://
> www.openchat.us/griper' failed: Error during WebSocket handshake: 
> Unexpected response code: 403
> connect @ websocketbridge.js:118
> (index):173 Disconnected from chat socket
>
> hmmm :)
>
> On Tuesday, May 16, 2017 at 8:26:18 PM UTC-5, Dylan Reinhold wrote:
>>
>> Sorry sounds like you will need to configure somting in your webfaction 
>> controll panel.
>>
>> Here is another person with same issue, they said it fixed it for them.
>> https://github.com/django/channels/issues/445
>>
>> On Tue, May 16, 2017 at 5:46 PM, djangorobert <djangoc...@gmail.com> 
>> wrote:
>>
>>> hi Dylan Im usingWebfaction Im kind of new to django channels 
>>> my website is www.openchat.us 
>>>
>>> do you mean redisserver ?
>>>
>>> or are you refering to the commands python mange.py runserver or 
>>> runworkder? because with those commancds im kind of confused when ussing 
>>> webfaction 
>>> im using putty to enter the commands to my webfaction account
>>>
>>> On Tuesday, May 16, 2017 at 5:49:04 PM UTC-5, Dylan Reinhold wrote:
>>>>
>>>> How are you running the web server?
>>>> Looks like your web socket traffic is not being set to daphene. 
>>>> Probably hitting the regular django listener and its returning a 404.
>>>>
>>>> Dylan
>>>>
>>>> On Tue, May 16, 2017 at 3:39 PM, djangorobert <djangoc...@gmail.com> 
>>>> wrote:
>>>>
>>>>> working on the Django channels example : multi chat on Github 
>>>>> but am getting this error
>>>>>
>>>>>
>>>>> (index):173 Disconnected from chat socket
>>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>>> www.openchat.us/chat/stream/' failed: Error during WebSocket 
>>>>> handshake: Unexpected response code: 404
>>>>> connect @ websocketbridge.js:118
>>>>> (index):173 Disconnected from chat socket
>>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>>> www.openchat.us/chat/stream/' failed: Error during WebSocket 
>>>>> handshake: Unexpected response code: 404
>>>>> connect @ websocketbridge.js:118
>>>>> (index):173 Disconnected from chat socket
>>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>>> www.openchat.us/chat/stream/' failed: Error during WebSocket 
>>>>> handshake: Unexpected response code: 404
>>>>> connect @ websocketbridge.js:118
>>>>> (index):173 Disconnected from chat socket
>>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>>> www.openchat.us/chat/stream/' failed: Error during WebSocket 
>>>>> handshake: Unexpected response code: 404
>>>>> connect @ websocketbridge.js:118
>>>>> (index):173 Disconnected from chat socket
>>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>>> www.openchat.us/chat/stream/' failed: Error during WebSocket 
>>>>> handshake: Unexpected response code: 404
>>>>> connect @ websocketbridge.js:118
>>>>> (index):173 Disconnected from chat socket
>>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>>> www.openchat.us/chat/stream/' failed: Error during WebSocket 
>>>>> handshake: Unexpected response code: 404
>>>>> connect @ websocketbridge.js:118
>>>>> (index):173 Disconnected from chat socket
>>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>>> www.openchat.us/chat/stream/' failed: Error during WebSocket 
>>>>> handshake: Unexpected response code: 404
>>>>> connect @ websocketbridge.js:118
>>>>> (index):173 Disconnected from chat socket
>>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>>> www.openchat.us/

Re: Django Channels error : (index):173 Disconnected from chat socket websocketbridge.js:118 WebSocket connection to 'ws://www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: Unexp

2017-05-16 Thread djangorobert
thanks ya that seemed to help a little now im running into a new error: 

WebSocket connection to 'ws://www.openchat.us/griper' failed: WebSocket is 
closed before the connection is established.
(index):173 Disconnected from chat socket
websocketbridge.js:118 WebSocket connection to 
'ws://www.openchat.us/griper' failed: Error during WebSocket handshake: 
Unexpected response code: 403
connect @ websocketbridge.js:118
(index):173 Disconnected from chat socket

hmmm :)

On Tuesday, May 16, 2017 at 8:26:18 PM UTC-5, Dylan Reinhold wrote:
>
> Sorry sounds like you will need to configure somting in your webfaction 
> controll panel.
>
> Here is another person with same issue, they said it fixed it for them.
> https://github.com/django/channels/issues/445
>
> On Tue, May 16, 2017 at 5:46 PM, djangorobert <djangoc...@gmail.com 
> > wrote:
>
>> hi Dylan Im usingWebfaction Im kind of new to django channels 
>> my website is www.openchat.us 
>>
>> do you mean redisserver ?
>>
>> or are you refering to the commands python mange.py runserver or 
>> runworkder? because with those commancds im kind of confused when ussing 
>> webfaction 
>> im using putty to enter the commands to my webfaction account
>>
>> On Tuesday, May 16, 2017 at 5:49:04 PM UTC-5, Dylan Reinhold wrote:
>>>
>>> How are you running the web server?
>>> Looks like your web socket traffic is not being set to daphene. Probably 
>>> hitting the regular django listener and its returning a 404.
>>>
>>> Dylan
>>>
>>> On Tue, May 16, 2017 at 3:39 PM, djangorobert <djangoc...@gmail.com> 
>>> wrote:
>>>
>>>> working on the Django channels example : multi chat on Github 
>>>> but am getting this error
>>>>
>>>>
>>>> (index):173 Disconnected from chat socket
>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>> www.openchat.us/chat/stream/' failed: Error during WebSocket 
>>>> handshake: Unexpected response code: 404
>>>> connect @ websocketbridge.js:118
>>>> (index):173 Disconnected from chat socket
>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>> www.openchat.us/chat/stream/' failed: Error during WebSocket 
>>>> handshake: Unexpected response code: 404
>>>> connect @ websocketbridge.js:118
>>>> (index):173 Disconnected from chat socket
>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>> www.openchat.us/chat/stream/' failed: Error during WebSocket 
>>>> handshake: Unexpected response code: 404
>>>> connect @ websocketbridge.js:118
>>>> (index):173 Disconnected from chat socket
>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>> www.openchat.us/chat/stream/' failed: Error during WebSocket 
>>>> handshake: Unexpected response code: 404
>>>> connect @ websocketbridge.js:118
>>>> (index):173 Disconnected from chat socket
>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>> www.openchat.us/chat/stream/' failed: Error during WebSocket 
>>>> handshake: Unexpected response code: 404
>>>> connect @ websocketbridge.js:118
>>>> (index):173 Disconnected from chat socket
>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>> www.openchat.us/chat/stream/' failed: Error during WebSocket 
>>>> handshake: Unexpected response code: 404
>>>> connect @ websocketbridge.js:118
>>>> (index):173 Disconnected from chat socket
>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>> www.openchat.us/chat/stream/' failed: Error during WebSocket 
>>>> handshake: Unexpected response code: 404
>>>> connect @ websocketbridge.js:118
>>>> (index):173 Disconnected from chat socket
>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>> www.openchat.us/chat/stream/' failed: Error during WebSocket 
>>>> handshake: Unexpected response code: 404
>>>> connect @ websocketbridge.js:118
>>>> (index):173 Disconnected from chat socket
>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>> www.openchat.us/chat/stream/' failed: Error during WebSocket 
>>>> handshake: Unexpected response code: 404
>>>> connect @ websocketbridge.js:118
>>>> (index):173 Disconnected from chat socket
>>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>>> www.openchat.us/chat/stream/' failed: Error during WebSock

Re: Django Channels error : (index):173 Disconnected from chat socket websocketbridge.js:118 WebSocket connection to 'ws://www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: Unexp

2017-05-16 Thread Dylan Reinhold
Sorry sounds like you will need to configure somting in your webfaction
controll panel.

Here is another person with same issue, they said it fixed it for them.
https://github.com/django/channels/issues/445

On Tue, May 16, 2017 at 5:46 PM, djangorobert <djangocharm2...@gmail.com>
wrote:

> hi Dylan Im usingWebfaction Im kind of new to django channels
> my website is www.openchat.us
>
> do you mean redisserver ?
>
> or are you refering to the commands python mange.py runserver or
> runworkder? because with those commancds im kind of confused when ussing
> webfaction
> im using putty to enter the commands to my webfaction account
>
> On Tuesday, May 16, 2017 at 5:49:04 PM UTC-5, Dylan Reinhold wrote:
>>
>> How are you running the web server?
>> Looks like your web socket traffic is not being set to daphene. Probably
>> hitting the regular django listener and its returning a 404.
>>
>> Dylan
>>
>> On Tue, May 16, 2017 at 3:39 PM, djangorobert <djangoc...@gmail.com>
>> wrote:
>>
>>> working on the Django channels example : multi chat on Github
>>> but am getting this error
>>>
>>>
>>> (index):173 Disconnected from chat socket
>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake:
>>> Unexpected response code: 404
>>> connect @ websocketbridge.js:118
>>> (index):173 Disconnected from chat socket
>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake:
>>> Unexpected response code: 404
>>> connect @ websocketbridge.js:118
>>> (index):173 Disconnected from chat socket
>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake:
>>> Unexpected response code: 404
>>> connect @ websocketbridge.js:118
>>> (index):173 Disconnected from chat socket
>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake:
>>> Unexpected response code: 404
>>> connect @ websocketbridge.js:118
>>> (index):173 Disconnected from chat socket
>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake:
>>> Unexpected response code: 404
>>> connect @ websocketbridge.js:118
>>> (index):173 Disconnected from chat socket
>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake:
>>> Unexpected response code: 404
>>> connect @ websocketbridge.js:118
>>> (index):173 Disconnected from chat socket
>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake:
>>> Unexpected response code: 404
>>> connect @ websocketbridge.js:118
>>> (index):173 Disconnected from chat socket
>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake:
>>> Unexpected response code: 404
>>> connect @ websocketbridge.js:118
>>> (index):173 Disconnected from chat socket
>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake:
>>> Unexpected response code: 404
>>> connect @ websocketbridge.js:118
>>> (index):173 Disconnected from chat socket
>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake:
>>> Unexpected response code: 404
>>> connect @ websocketbridge.js:118
>>> (index):173 Disconnected from chat socket
>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake:
>>> Unexpected response code: 404
>>> connect @ websocketbridge.js:118
>>> 2(index):173 Disconnected from chat socket
>>> 2websocketbridge.js:118 WebSocket connection to 'ws://
>>> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake:
>>> Unexpected response code: 404
>>> connect @ websocketbridge.js:118
>>> (index):173 Disconnected from chat socket
>>> websocketbridge.js:118 WebSocket connection to 'ws://
>>> www.openchat.us/chat/stream/' failed: Error during WebSocket hand

Re: Django Channels error : (index):173 Disconnected from chat socket websocketbridge.js:118 WebSocket connection to 'ws://www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: Unexp

2017-05-16 Thread djangorobert
hi Dylan Im usingWebfaction Im kind of new to django channels 
my website is www.openchat.us 

do you mean redisserver ?

or are you refering to the commands python mange.py runserver or 
runworkder? because with those commancds im kind of confused when ussing 
webfaction 
im using putty to enter the commands to my webfaction account

On Tuesday, May 16, 2017 at 5:49:04 PM UTC-5, Dylan Reinhold wrote:
>
> How are you running the web server?
> Looks like your web socket traffic is not being set to daphene. Probably 
> hitting the regular django listener and its returning a 404.
>
> Dylan
>
> On Tue, May 16, 2017 at 3:39 PM, djangorobert <djangoc...@gmail.com 
> > wrote:
>
>> working on the Django channels example : multi chat on Github 
>> but am getting this error
>>
>>
>> (index):173 Disconnected from chat socket
>> websocketbridge.js:118 WebSocket connection to 'ws://
>> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: 
>> Unexpected response code: 404
>> connect @ websocketbridge.js:118
>> (index):173 Disconnected from chat socket
>> websocketbridge.js:118 WebSocket connection to 'ws://
>> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: 
>> Unexpected response code: 404
>> connect @ websocketbridge.js:118
>> (index):173 Disconnected from chat socket
>> websocketbridge.js:118 WebSocket connection to 'ws://
>> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: 
>> Unexpected response code: 404
>> connect @ websocketbridge.js:118
>> (index):173 Disconnected from chat socket
>> websocketbridge.js:118 WebSocket connection to 'ws://
>> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: 
>> Unexpected response code: 404
>> connect @ websocketbridge.js:118
>> (index):173 Disconnected from chat socket
>> websocketbridge.js:118 WebSocket connection to 'ws://
>> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: 
>> Unexpected response code: 404
>> connect @ websocketbridge.js:118
>> (index):173 Disconnected from chat socket
>> websocketbridge.js:118 WebSocket connection to 'ws://
>> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: 
>> Unexpected response code: 404
>> connect @ websocketbridge.js:118
>> (index):173 Disconnected from chat socket
>> websocketbridge.js:118 WebSocket connection to 'ws://
>> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: 
>> Unexpected response code: 404
>> connect @ websocketbridge.js:118
>> (index):173 Disconnected from chat socket
>> websocketbridge.js:118 WebSocket connection to 'ws://
>> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: 
>> Unexpected response code: 404
>> connect @ websocketbridge.js:118
>> (index):173 Disconnected from chat socket
>> websocketbridge.js:118 WebSocket connection to 'ws://
>> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: 
>> Unexpected response code: 404
>> connect @ websocketbridge.js:118
>> (index):173 Disconnected from chat socket
>> websocketbridge.js:118 WebSocket connection to 'ws://
>> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: 
>> Unexpected response code: 404
>> connect @ websocketbridge.js:118
>> (index):173 Disconnected from chat socket
>> websocketbridge.js:118 WebSocket connection to 'ws://
>> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: 
>> Unexpected response code: 404
>> connect @ websocketbridge.js:118
>> 2(index):173 Disconnected from chat socket
>> 2websocketbridge.js:118 WebSocket connection to 'ws://
>> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: 
>> Unexpected response code: 404
>> connect @ websocketbridge.js:118
>> (index):173 Disconnected from chat socket
>> websocketbridge.js:118 WebSocket connection to 'ws://
>> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: 
>> Unexpected response code: 404
>> connect @ websocketbridge.js:118
>> (index):173 Disconnected from chat socket
>> websocketbridge.js:118 WebSocket connection to 'ws://
>> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: 
>> Unexpected response code: 404
>> connect @ websocketbridge.js:118
>> (index):173 Disconnected from chat socket
>> (index):1 WebSocket connection to 'ws://www.openchat.us/chat/stream/' 
>> failed: WebSocket is closed before the connection is established.
>> 2(index):173 Disconnected from chat socket
>> (index)

Re: Django Channels error : (index):173 Disconnected from chat socket websocketbridge.js:118 WebSocket connection to 'ws://www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: Unexp

2017-05-16 Thread Dylan Reinhold
How are you running the web server?
Looks like your web socket traffic is not being set to daphene. Probably
hitting the regular django listener and its returning a 404.

Dylan

On Tue, May 16, 2017 at 3:39 PM, djangorobert <djangocharm2...@gmail.com>
wrote:

> working on the Django channels example : multi chat on Github
> but am getting this error
>
>
> (index):173 Disconnected from chat socket
> websocketbridge.js:118 WebSocket connection to 'ws://www.openchat.us/chat/
> stream/' failed: Error during WebSocket handshake: Unexpected response
> code: 404
> connect @ websocketbridge.js:118
> (index):173 Disconnected from chat socket
> websocketbridge.js:118 WebSocket connection to 'ws://www.openchat.us/chat/
> stream/' failed: Error during WebSocket handshake: Unexpected response
> code: 404
> connect @ websocketbridge.js:118
> (index):173 Disconnected from chat socket
> websocketbridge.js:118 WebSocket connection to 'ws://www.openchat.us/chat/
> stream/' failed: Error during WebSocket handshake: Unexpected response
> code: 404
> connect @ websocketbridge.js:118
> (index):173 Disconnected from chat socket
> websocketbridge.js:118 WebSocket connection to 'ws://www.openchat.us/chat/
> stream/' failed: Error during WebSocket handshake: Unexpected response
> code: 404
> connect @ websocketbridge.js:118
> (index):173 Disconnected from chat socket
> websocketbridge.js:118 WebSocket connection to 'ws://www.openchat.us/chat/
> stream/' failed: Error during WebSocket handshake: Unexpected response
> code: 404
> connect @ websocketbridge.js:118
> (index):173 Disconnected from chat socket
> websocketbridge.js:118 WebSocket connection to 'ws://www.openchat.us/chat/
> stream/' failed: Error during WebSocket handshake: Unexpected response
> code: 404
> connect @ websocketbridge.js:118
> (index):173 Disconnected from chat socket
> websocketbridge.js:118 WebSocket connection to 'ws://www.openchat.us/chat/
> stream/' failed: Error during WebSocket handshake: Unexpected response
> code: 404
> connect @ websocketbridge.js:118
> (index):173 Disconnected from chat socket
> websocketbridge.js:118 WebSocket connection to 'ws://www.openchat.us/chat/
> stream/' failed: Error during WebSocket handshake: Unexpected response
> code: 404
> connect @ websocketbridge.js:118
> (index):173 Disconnected from chat socket
> websocketbridge.js:118 WebSocket connection to 'ws://www.openchat.us/chat/
> stream/' failed: Error during WebSocket handshake: Unexpected response
> code: 404
> connect @ websocketbridge.js:118
> (index):173 Disconnected from chat socket
> websocketbridge.js:118 WebSocket connection to 'ws://www.openchat.us/chat/
> stream/' failed: Error during WebSocket handshake: Unexpected response
> code: 404
> connect @ websocketbridge.js:118
> (index):173 Disconnected from chat socket
> websocketbridge.js:118 WebSocket connection to 'ws://www.openchat.us/chat/
> stream/' failed: Error during WebSocket handshake: Unexpected response
> code: 404
> connect @ websocketbridge.js:118
> 2(index):173 Disconnected from chat socket
> 2websocketbridge.js:118 WebSocket connection to 'ws://
> www.openchat.us/chat/stream/' failed: Error during WebSocket handshake:
> Unexpected response code: 404
> connect @ websocketbridge.js:118
> (index):173 Disconnected from chat socket
> websocketbridge.js:118 WebSocket connection to 'ws://www.openchat.us/chat/
> stream/' failed: Error during WebSocket handshake: Unexpected response
> code: 404
> connect @ websocketbridge.js:118
> (index):173 Disconnected from chat socket
> websocketbridge.js:118 WebSocket connection to 'ws://www.openchat.us/chat/
> stream/' failed: Error during WebSocket handshake: Unexpected response
> code: 404
> connect @ websocketbridge.js:118
> (index):173 Disconnected from chat socket
> (index):1 WebSocket connection to 'ws://www.openchat.us/chat/stream/'
> failed: WebSocket is closed before the connection is established.
> 2(index):173 Disconnected from chat socket
> (index):1 WebSocket connection to 'ws://www.openchat.us/chat/stream/'
> failed: WebSocket is closed before the connection is established.
> websocketbridge.js:118 WebSocket connection to 'ws://www.openchat.us/chat/
> stream/' failed: Error during WebSocket handshake: Unexpected response
> code: 404
> connect @ websocketbridge.js:118
> (index):173 Disconnected from chat socket
> websocketbridge.js:118 WebSocket connection to 'ws://www.openchat.us/chat/
> stream/' failed: Error during WebSocket handshake: Unexpected response
> code: 404
> connect @ websocketbridge.js:118
> (index):173 Disconnected from chat socket
> websocketbridge.js:118 WebSocket connection to 'ws://www.openchat.us/chat/
> stream/' failed: Error during WebSocket handshake: 

Re: how to show image with index in python as context variable

2017-04-26 Thread Dartos
Hi,

If you're using the django template language, use a dot instead of [].

Try this: {{ item.0.image.url }}

For {{ foo.bar }}, the django template language tries the following:

foo[bar]# dict lookup
foo.bar# property
foo[int(bar)]# index lookup
foo.bar()# callable

Reference for django 1.11:
https://github.com/django/django/blob/1.11/django/template/base.py#L869

Regards,
Dartos

On Tuesday, April 25, 2017 at 7:07:08 AM UTC-4, Shamaila Moazzam wrote:
>
> hi,
>
> i am trying to display a set of images with the use of index.
> here is the code:
>  
>  {% for item in product.productimage_set.all %}
> 
>  style="height:100px;widht:50px"/>
>   
>
>  {% endfor %}
>
>  
>
> the above code is displaying a set of images for one product .right.
> i want to display it like {{ item[0].image.url }}
> how can i do that ?
>
> regards.
> shamaila
>

-- 
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/47e2daf0-9d5d-4297-b2ef-42cd9692bf7b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


how to show image with index in python as context variable

2017-04-25 Thread Shamaila Moazzam
hi,

i am trying to display a set of images with the use of index.
here is the code:
 
 {% for item in product.productimage_set.all %}


  
   
 {% endfor %}

 

the above code is displaying a set of images for one product .right.
i want to display it like {{ item[0].image.url }}
how can i do that ?

regards.
shamaila

-- 
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/51fd8360-f106-4cc2-bde0-9756e690a926%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: AttributeError: module 'polls.views' has no attribute 'index'

2017-04-19 Thread Billy Lin
Thanks for your reploy.

Actually I followed the tutorial exactly.

My polls/views.py has:

from django.http import HttpResponse


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

My polls/urls.py has:

from django.conf.urls import url

from . import views

urlpatterns = [
url(r'^$', views.index, name='index'),
]


On Wednesday, 19 April 2017 15:43:57 UTC+2, m712 - Developer wrote:

> You didn't give us enough info, but I am thinking that you don't have an 
> index() function in your polls/views.py. Start the tutorial from the 
> beginning and follow it closely.
> On Apr 19, 2017 4:17 PM, Billy Lin <lce...@gmail.com > wrote:
>
> I'm following the getting started tutorial 01 and running into issues 
> after creating the polls app. Can someone please help?
>
> I'm using Python 3.6.1 and Django 1.11.
>
> Here's the detailed trace:
>
> Performing system checks...
> Unhandled exception in thread started by  check_errors..wrapper at 0x04222810>
> Traceback (most recent call last):
>   File 
> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py",
>  
> line
> 227, in wrapper
> fn(*args, **kwargs)
>   File 
> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\ru
> nserver.py", line 125, in inner_run
> self.check(display_num_errors=True)
>   File 
> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py",
>  
> l
> ine 359, in check
> include_deployment_checks=include_deployment_checks,
>   File 
> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py",
>  
> l
> ine 346, in _run_checks
> return checks.run_checks(**kwargs)
>   File 
> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\registry.py",
>  
> l
> ine 81, in run_checks
> new_errors = check(app_configs=app_configs)
>   File 
> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py",
>  
> line
> 16, in check_url_config
> return check_resolver(resolver)
>   File 
> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py",
>  
> line
> 26, in check_resolver
> return check_method()
>   File 
> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py",
>  
> line 25
> 4, in check
> for pattern in self.url_patterns:
>   File 
> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py",
>  
> line
> 35, in __get__
> res = instance.__dict__[self.name] = self.func(instance)
>   File 
> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py",
>  
> line 40
> 5, in url_patterns
> patterns = getattr(self.urlconf_module, "urlpatterns", 
> self.urlconf_module)
>   File 
> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py",
>  
> line
> 35, in __get__
> res = instance.__dict__[self.name] = self.func(instance)
>   File 
> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py",
>  
> line 39
> 8, in urlconf_module
> return import_module(self.urlconf_name)
>   File 
> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py",
>  
> line 126, in import_modu
> le
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 978, in _gcd_import
>   File "", line 961, in _find_and_load
>   File "", line 950, in 
> _find_and_load_unlocked
>   File "", line 655, in _load_unlocked
>   File "", line 678, in exec_module
>   File "", line 205, in 
> _call_with_frames_removed
>   File "C:\Users\cephalin\Repos\django\mysite\mysite\urls.py", line 20, in 
> 
> url(r'^polls/', include('polls.urls')),
>   File 
> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\conf\urls\__init__.py",
>  
> lin
> e 50, in include
> urlconf_module = import_module(urlconf_module)
>   File 
> "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py",
>  
> line 126, in import_modu
> le
> ret

Re: AttributeError: module 'polls.views' has no attribute 'index'

2017-04-19 Thread m712 - Developer
You didn't give us enough info, but I am thinking that you don't have an index() function in your polls/views.py. Start the tutorial from the beginning and follow it closely.
On Apr 19, 2017 4:17 PM, Billy Lin <lcep...@gmail.com> wrote:I'm following the getting started tutorial 01 and running into issues after creating the polls app. Can someone please help?I'm using Python 3.6.1 and Django 1.11.Here's the detailed trace:Performing system checks...Unhandled exception in thread started by .wrapper at 0x04222810>Traceback (most recent call last):  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py", line227, in wrapper    fn(*args, **kwargs)  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\runserver.py", line 125, in inner_run    self.check(display_num_errors=True)  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py", line 359, in check    include_deployment_checks=include_deployment_checks,  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py", line 346, in _run_checks    return checks.run_checks(**kwargs)  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\registry.py", line 81, in run_checks    new_errors = check(app_configs=app_configs)  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py", line16, in check_url_config    return check_resolver(resolver)  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py", line26, in check_resolver    return check_method()  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py", line 254, in check    for pattern in self.url_patterns:  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py", line35, in __get__    res = instance.__dict__[self.name] = self.func(instance)  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py", line 405, in url_patterns    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py", line35, in __get__    res = instance.__dict__[self.name] = self.func(instance)  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py", line 398, in urlconf_module    return import_module(self.urlconf_name)  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module    return _bootstrap._gcd_import(name[level:], package, level)  File "", line 978, in _gcd_import  File "", line 961, in _find_and_load  File "", line 950, in _find_and_load_unlocked  File "", line 655, in _load_unlocked  File "", line 678, in exec_module  File "", line 205, in _call_with_frames_removed  File "C:\Users\cephalin\Repos\django\mysite\mysite\urls.py", line 20, in     url(r'^polls/', include('polls.urls')),  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\conf\urls\__init__.py", line 50, in include    urlconf_module = import_module(urlconf_module)  File "C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module    return _bootstrap._gcd_import(name[level:], package, level)  File "", line 978, in _gcd_import  File "", line 961, in _find_and_load  File "", line 950, in _find_and_load_unlocked  File "", line 655, in _load_unlocked  File "", line 678, in exec_module  File "", line 205, in _call_with_frames_removed  File "C:\Users\cephalin\Repos\django\mysite\polls\urls.py", line 6, in     url(r'^$', views.index, name='index'),AttributeError: module 'polls.views' has no attribute 'index'



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





AttributeError: module 'polls.views' has no attribute 'index'

2017-04-19 Thread Billy Lin
I'm following the getting started tutorial 01 and running into issues after 
creating the polls app. Can someone please help?

I'm using Python 3.6.1 and Django 1.11.

Here's the detailed trace:

Performing system checks...
Unhandled exception in thread started by .wrapper at 0x04222810>
Traceback (most recent call last):
  File 
"C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py",
 
line
227, in wrapper
fn(*args, **kwargs)
  File 
"C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\ru
nserver.py", line 125, in inner_run
self.check(display_num_errors=True)
  File 
"C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py",
 
l
ine 359, in check
include_deployment_checks=include_deployment_checks,
  File 
"C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py",
 
l
ine 346, in _run_checks
return checks.run_checks(**kwargs)
  File 
"C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\registry.py",
 
l
ine 81, in run_checks
new_errors = check(app_configs=app_configs)
  File 
"C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py",
 
line
16, in check_url_config
return check_resolver(resolver)
  File 
"C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py",
 
line
26, in check_resolver
return check_method()
  File 
"C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py",
 
line 25
4, in check
for pattern in self.url_patterns:
  File 
"C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py",
 
line
35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
  File 
"C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py",
 
line 40
5, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", 
self.urlconf_module)
  File 
"C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py",
 
line
35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
  File 
"C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py",
 
line 39
8, in urlconf_module
return import_module(self.urlconf_name)
  File 
"C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py",
 
line 126, in import_modu
le
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 978, in _gcd_import
  File "", line 961, in _find_and_load
  File "", line 950, in _find_and_load_unlocked
  File "", line 655, in _load_unlocked
  File "", line 678, in exec_module
  File "", line 205, in 
_call_with_frames_removed
  File "C:\Users\cephalin\Repos\django\mysite\mysite\urls.py", line 20, in 

url(r'^polls/', include('polls.urls')),
  File 
"C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\conf\urls\__init__.py",
 
lin
e 50, in include
urlconf_module = import_module(urlconf_module)
  File 
"C:\Users\cephalin\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py",
 
line 126, in import_modu
le
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 978, in _gcd_import
  File "", line 961, in _find_and_load
  File "", line 950, in _find_and_load_unlocked
  File "", line 655, in _load_unlocked
  File "", line 678, in exec_module
  File "", line 205, in 
_call_with_frames_removed
  File "C:\Users\cephalin\Repos\django\mysite\polls\urls.py", line 6, in 

url(r'^$', views.index, name='index'),
AttributeError: module 'polls.views' has no attribute 'index'

-- 
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/b77a1a74-b07f-4277-98da-23b46ca7d2e4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Force a model to appear on admin's index page depending on the request

2016-04-13 Thread Olivier Dalang
Hi !

Is it possible to force a model to appear on the admin index page depending
on the request ?

I'm asking because I did override the has_change_permission() method of the
ModelAdmin, so that the user can be allowed to change some instances
(chosen via a ManyToMany relationship between the user and the instances).

So, the idea is (in pseudocode):

if user.has_permission( change_permission ):
he can manage all the instances -> display the model in the admin
else:
if user.allowed_instances.count()>0:
he can manage some instances -> display the model in the admin
else:
he cannot manage any instances -> do not display the model in the
admin

Thanks !!

Olivier

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


Re: AttributeError: 'module' object has no attribute 'index'

2016-03-13 Thread James Schneider
On Mar 13, 2016 11:42 AM, "kashif Nawaz" <danishn...@gmail.com> wrote:
>
> I read the documentation of Django i followed till page 17 then I have
got an error
> i do exactly the same as the tutorials in docs
> please help me
>

>   File "", line 321, in
_call_with_frames_removed
>   File "/home/kashif/Desktop/mysite/mysite/polls/urls.py", line 5, in

> url(r'^$', views.index, name ='index'),
> AttributeError: 'module' object has no attribute 'index'
>
>

What does your urls.py look like? Did you do something like 'import
myapp.views'? Do you have a function called index in you views.py?

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


AttributeError: 'module' object has no attribute 'index'

2016-03-13 Thread kashif Nawaz
I read the documentation of Django i followed till page 17 then I have got 
an error 
i do exactly the same as the tutorials in docs
please help me





Unhandled exception in thread started by .wrapper at 0x7fb70bdb3510>
Traceback (most recent call last):
  File 
"/home/kashif/Desktop/mysite/lib/python3.4/site-packages/django/utils/autoreload.py",
 
line 226, in wrapper
fn(*args, **kwargs)
  File 
"/home/kashif/Desktop/mysite/lib/python3.4/site-packages/django/core/management/commands/runserver.py",
 
line 116, in inner_run
self.check(display_num_errors=True)
  File 
"/home/kashif/Desktop/mysite/lib/python3.4/site-packages/django/core/management/base.py",
 
line 426, in check
include_deployment_checks=include_deployment_checks,
  File 
"/home/kashif/Desktop/mysite/lib/python3.4/site-packages/django/core/checks/registry.py",
 
line 75, in run_checks
new_errors = check(app_configs=app_configs)
  File 
"/home/kashif/Desktop/mysite/lib/python3.4/site-packages/django/core/checks/urls.py",
 
line 13, in check_url_config
return check_resolver(resolver)
  File 
"/home/kashif/Desktop/mysite/lib/python3.4/site-packages/django/core/checks/urls.py",
 
line 23, in check_resolver
for pattern in resolver.url_patterns:
  File 
"/home/kashif/Desktop/mysite/lib/python3.4/site-packages/django/utils/functional.py",
 
line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
  File 
"/home/kashif/Desktop/mysite/lib/python3.4/site-packages/django/core/urlresolvers.py",
 
line 417, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", 
self.urlconf_module)
  File 
"/home/kashif/Desktop/mysite/lib/python3.4/site-packages/django/utils/functional.py",
 
line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
  File 
"/home/kashif/Desktop/mysite/lib/python3.4/site-packages/django/core/urlresolvers.py",
 
line 410, in urlconf_module
return import_module(self.urlconf_name)
  File "/home/kashif/Desktop/mysite/lib/python3.4/importlib/__init__.py", 
line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 2254, in _gcd_import
  File "", line 2237, in _find_and_load
  File "", line 2226, in 
_find_and_load_unlocked
  File "", line 1200, in _load_unlocked
  File "", line 1129, in _exec
  File "", line 1471, in exec_module
  File "", line 321, in 
_call_with_frames_removed
  File "/home/kashif/Desktop/mysite/mysite/mysite/urls.py", line 20, in 

url(r'^polls/', include('polls.urls')),
  File 
"/home/kashif/Desktop/mysite/lib/python3.4/site-packages/django/conf/urls/__init__.py",
 
line 52, in include
urlconf_module = import_module(urlconf_module)
  File "/home/kashif/Desktop/mysite/lib/python3.4/importlib/__init__.py", 
line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 2254, in _gcd_import
  File "", line 2237, in _find_and_load
  File "", line 2226, in 
_find_and_load_unlocked
  File "", line 1200, in _load_unlocked
  File "", line 1129, in _exec
  File "", line 1471, in exec_module
  File "", line 321, in 
_call_with_frames_removed
  File "/home/kashif/Desktop/mysite/mysite/polls/urls.py", line 5, in 

url(r'^$', views.index, name ='index'),
AttributeError: 'module' object has no attribute 'index'

-- 
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/7482b442-9953-4e9f-aea8-52da6af92eb3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Custom Templates in Django Sitemaps Index

2015-11-06 Thread Andreas Dickow
See my new tutorial on Custom Templates in Django Sitemaps:
https://biz-factory.de/django-sitemap-index-tutorial/

-- 
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/ce701ceb-4634-46fb-b492-0f2b91dcf94f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


UnicodeError while searching in haystack/whoosh index

2015-04-28 Thread Florian Schweikert
Hi,

I'm working on an django-cms 3.0.13/py2.7 page atm and came across an
weird behaviour using haystack with whoosh.

When using rebuild_index everything works fine.
But using update_index afterwards leads to an UnicodeDecodeError when
searching for a page with umlauts.
Error thrown in "whoosh/reading.py | expand_prefix"

Assuming I interpret the rebuild and update command code correct,
rebuild just calls update after clean. So why does it work with rebuild
but not with update?

I'm using an adapted version of search_indexes.py example of the
django-cms project.[1]

Any ideas/solutions?

Many thanks,
Florian

[1] http://fpaste.org/216170/30221364/

-- 
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/553F738A.8080204%40ist-total.org.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: OpenPGP digital signature


Index(View) rendering template instead of view

2015-02-24 Thread Brad Rice
So I have a RedirectView.as_view() going to a page in an app called web.

In the app web this is my view:

class Index(View):

def get(self, request, *args, **kwargs):
return HttpResponse('Hello, World!')

However, instead of showing that, when I get redirected to the app it shows 
my base template and index template even though I have not specified them 
in my Index view. It appears my url is not hitting the view.

Here is my urls.py in web: 

from django.conf.urls import *
import os
from .views import Index, gallery

urlpatterns = patterns('',
url(r'^$', Index.as_view(), name='index'),
url(r'^gallery', gallery, name='gallery'),
)

Here is the website: www.lodiharrisvillehistorical.org

notice it going to /web but not echoing out Hello, World!

also notice gallery is working and finding the view.

Why is it not picking up the Index view and instead displaying a template 
with no context?

-- 
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/fc79434f-bf1a-4549-9708-0d5cf40439d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Show a model on the admin list index page

2014-10-07 Thread Andrea
I think I've found the problem.

In my Django version I have in `contrib/admin/sites.py` line 371:

has_module_perms = user.has_module_perms(app_label)

Here it is instead:

https://github.com/django/django/blob/master/django/contrib/admin/sites.py
line 383:
has_module_perms = model_admin.has_module_permission(request)

I was probably reading the dev documentation of something that's not in
Django 1.7 but will be in Django 1.8.

https://github.com/django/django/commit/504c89e8008c557a1e83c45535b549f77a3503b2

Thanks!
Andrea

2014-10-07 11:54 GMT+02:00 Daniel Rus Morales <m...@danir.us>:

> I think it’s clear to me what you are trying to do. By overriding those
> methods in BarAdmin you go down that line (bypass the django admin
> permission system), but to get the app listed in the admin index page you
> would have to actually rewrite the view function. This view function makes
> an explicit verification on the add/change/delete permissions for the
> logged in user and app Foo, and as long as your users don’t have them
> granted for such app they can’t see it listed.
>
> Going back to my concern on overriding the permissions system, have you
> considered getting the functionality by providing your staff users with
> permissions at app Foo configuration time? That way your users would get
> access and you would write less code. You would create a group and would
> assign permissions to the group. At AppConfig.ready() you could assign your
> users to the new group, and thus grant them access.
>
> Best,
> Daniel
>
>
> On 07 Oct 2014, at 11:25, Andrea <andrea.g...@gmail.com> wrote:
>
> Dear Daniel,
>
> thank you for your answer.
> I think I was not clear enough in explaining my problem. I will try to
> rephrase the problem, please tell me if from the first message this point
> was clear or seemed different.
>
> I do want that the user is able to add or change some objects. My goal is
> to bypass the django admin permission system, and overriding
> "has_*_permission" methods seemed the correct option.
>
> The following example is correlated but a bit simpler. Let's suppose I
> grant the access to all the users to the admin panel (is_staff=True for
> each user).
>
> Now I want them to be able to add an instance of Bar model.
>
> class BarAdmin(admin.ModelAdmin):
> def has_add_permission(self, request):
> return True
>
> def has_module_permission(self, request):
> return True
>
> In my opinion that should do the trick, in fact the link to add a new
> instance is enabled, but it's not shown in the admin index page (and that's
> my problem).
> What I do not want to do is to specifically assign the `foo.add_bar`
> permission under the `permissions` section in the user profile for each
> user.
>
> Thanks for your time spent in tackling this issue.
>
> Andrea
>
> 2014-10-07 11:01 GMT+02:00 Daniel Rus Morales <m...@danir.us>:
>
>> Hi Andrea,
>>
>> I answer below in between lines.
>>
>> On 07 Oct 2014, at 08:53, Andrea <andrea.g...@gmail.com> wrote:
>>
>> Let's suppose I have a Foo app with a Bar model with a owner field. I
>> want a user to be able to edit all the instances for which obj.owner ==
>> request.user.
>>
>> The model appears correctly in the admin panel for superusers and for
>> users for which I have explicitly assigned the permission change_bar or
>> add_bar, as explained here
>> <https://docs.djangoproject.com/en/dev/topics/auth/default/#topic-authorization>
>> :
>>
>> Assuming you have an application with an app_label foo and a model named
>> Bar, to test for basic permissions you should use:
>>
>> add: user.has_perm('foo.add_bar')
>> change: user.has_perm('foo.change_bar')
>> delete: user.has_perm('foo.delete_bar')
>>
>> How can I show the model Bar in the admin index list without explicitly
>> assigning foo.change_bar or foo.add_bar to the user?
>>
>>
>> You can’t. The admin interface of Django assumes that when a user has
>> access to the administrative interface of an App-Model it’s not to act as a
>> mere passive consumer with read-only access but rather as an active admin
>> over the content (add, change, delete). An administrator who does only
>> inspect or supervise the content doesn’t fit in the sort of administrator
>> that the Django administration app allows. It’s like allowing an
>> administrator who actually does not administer.
>>
>> So far I tried the following, expecting the Bar model to appear in the
>> index list page, but it didn't work.
>>
>> class BarAdmin(admin.ModelAdmin):
>> def get_queryset(self, req

Re: Show a model on the admin list index page

2014-10-07 Thread Daniel Rus Morales
I think it’s clear to me what you are trying to do. By overriding those methods 
in BarAdmin you go down that line (bypass the django admin permission system), 
but to get the app listed in the admin index page you would have to actually 
rewrite the view function. This view function makes an explicit verification on 
the add/change/delete permissions for the logged in user and app Foo, and as 
long as your users don’t have them granted for such app they can’t see it 
listed.

Going back to my concern on overriding the permissions system, have you 
considered getting the functionality by providing your staff users with 
permissions at app Foo configuration time? That way your users would get access 
and you would write less code. You would create a group and would assign 
permissions to the group. At AppConfig.ready() you could assign your users to 
the new group, and thus grant them access.

Best,
Daniel


On 07 Oct 2014, at 11:25, Andrea <andrea.g...@gmail.com> wrote:

> Dear Daniel,
> 
> thank you for your answer.
> I think I was not clear enough in explaining my problem. I will try to 
> rephrase the problem, please tell me if from the first message this point was 
> clear or seemed different.
> 
> I do want that the user is able to add or change some objects. My goal is to 
> bypass the django admin permission system, and overriding "has_*_permission" 
> methods seemed the correct option.
> 
> The following example is correlated but a bit simpler. Let's suppose I grant 
> the access to all the users to the admin panel (is_staff=True for each user).
> 
> Now I want them to be able to add an instance of Bar model.
> 
> class BarAdmin(admin.ModelAdmin):
> def has_add_permission(self, request):
> return True
> def has_module_permission(self, request):
> return True
> In my opinion that should do the trick, in fact the link to add a new 
> instance is enabled, but it's not shown in the admin index page (and that's 
> my problem).
> What I do not want to do is to specifically assign the `foo.add_bar` 
> permission under the `permissions` section in the user profile for each user.
> 
> Thanks for your time spent in tackling this issue.
> 
> Andrea
> 
> 2014-10-07 11:01 GMT+02:00 Daniel Rus Morales <m...@danir.us>:
> Hi Andrea,
> 
> I answer below in between lines.
> 
> On 07 Oct 2014, at 08:53, Andrea <andrea.g...@gmail.com> wrote:
> 
>> Let's suppose I have a Foo app with a Bar model with a owner field. I want a 
>> user to be able to edit all the instances for which obj.owner == 
>> request.user.
>> 
>> The model appears correctly in the admin panel for superusers and for users 
>> for which I have explicitly assigned the permission change_bar or add_bar, 
>> as explained here:
>> 
>> Assuming you have an application with an app_label foo and a model named 
>> Bar, to test for basic permissions you should use:
>> 
>> add: user.has_perm('foo.add_bar')
>> change: user.has_perm('foo.change_bar')
>> delete: user.has_perm('foo.delete_bar')
>> How can I show the model Bar in the admin index list without explicitly 
>> assigning foo.change_bar or foo.add_bar to the user?
>> 
>> 
> 
> You can’t. The admin interface of Django assumes that when a user has access 
> to the administrative interface of an App-Model it’s not to act as a mere 
> passive consumer with read-only access but rather as an active admin over the 
> content (add, change, delete). An administrator who does only inspect or 
> supervise the content doesn’t fit in the sort of administrator that the 
> Django administration app allows. It’s like allowing an administrator who 
> actually does not administer. 
> 
>> So far I tried the following, expecting the Bar model to appear in the index 
>> list page, but it didn't work.
>> 
>> class BarAdmin(admin.ModelAdmin):
>> def get_queryset(self, request):
>> qs = super(BarAdmin, self).get_queryset(request)
>> if request.user.is_superuser:
>> return qs
>> return qs.filter(owner=request.user)
>> 
>> def has_add_permission(self, request):
>> return True
>> 
>> def has_change_permission(self, request, obj=None):
>> if obj is None:
>> return True
>> if obj.owner == request.user:
>> return True
>> return False
>> 
>> def has_delete_permission(self, request, obj=None):
>> if obj is None:
>> return True
>> if obj.owner == request.user:
>> return True
>> return False
>> 
>> def has_modul

Re: Show a model on the admin list index page

2014-10-07 Thread Andrea
Dear Daniel,

I want to answer to an issue you raised in your previous message.

The Bar model doesn’t appear in the App index list page because the view
> function in charge first verifies whether the user has any of the
> add/change/delete permissions granted for such App, and given that your
> user doesn’t have them the App Foo is not listed.
>

This is the point I don't understand. I granted the user the add permission
for the model, overriding the "has_add_permission" method for the admin
model. In fact the add link can be manually reached and works properly.
Which is the function in charge of checking for which models the user has
permissions in the admin index page? I could override that one as well, as
I did for the model with "has_add_permission".

Thanks,
Andrea

-- 
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/CAAPQ7Y1%3D6pTaHDgwU8vSiP_cT4%3Dcs641xTZ4oFju-hfdCAgD0g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Show a model on the admin list index page

2014-10-07 Thread Andrea
Dear Daniel,

thank you for your answer.
I think I was not clear enough in explaining my problem. I will try to
rephrase the problem, please tell me if from the first message this point
was clear or seemed different.

I do want that the user is able to add or change some objects. My goal is
to bypass the django admin permission system, and overriding
"has_*_permission" methods seemed the correct option.

The following example is correlated but a bit simpler. Let's suppose I
grant the access to all the users to the admin panel (is_staff=True for
each user).

Now I want them to be able to add an instance of Bar model.

class BarAdmin(admin.ModelAdmin):
def has_add_permission(self, request):
return True

def has_module_permission(self, request):
return True

In my opinion that should do the trick, in fact the link to add a new
instance is enabled, but it's not shown in the admin index page (and that's
my problem).
What I do not want to do is to specifically assign the `foo.add_bar`
permission under the `permissions` section in the user profile for each
user.

Thanks for your time spent in tackling this issue.

Andrea

2014-10-07 11:01 GMT+02:00 Daniel Rus Morales <m...@danir.us>:

> Hi Andrea,
>
> I answer below in between lines.
>
> On 07 Oct 2014, at 08:53, Andrea <andrea.g...@gmail.com> wrote:
>
> Let's suppose I have a Foo app with a Bar model with a owner field. I
> want a user to be able to edit all the instances for which obj.owner ==
> request.user.
>
> The model appears correctly in the admin panel for superusers and for
> users for which I have explicitly assigned the permission change_bar or
> add_bar, as explained here
> <https://docs.djangoproject.com/en/dev/topics/auth/default/#topic-authorization>
> :
>
> Assuming you have an application with an app_label foo and a model named
> Bar, to test for basic permissions you should use:
>
> add: user.has_perm('foo.add_bar')
> change: user.has_perm('foo.change_bar')
> delete: user.has_perm('foo.delete_bar')
>
> How can I show the model Bar in the admin index list without explicitly
> assigning foo.change_bar or foo.add_bar to the user?
>
>
> You can’t. The admin interface of Django assumes that when a user has
> access to the administrative interface of an App-Model it’s not to act as a
> mere passive consumer with read-only access but rather as an active admin
> over the content (add, change, delete). An administrator who does only
> inspect or supervise the content doesn’t fit in the sort of administrator
> that the Django administration app allows. It’s like allowing an
> administrator who actually does not administer.
>
> So far I tried the following, expecting the Bar model to appear in the
> index list page, but it didn't work.
>
> class BarAdmin(admin.ModelAdmin):
> def get_queryset(self, request):
> qs = super(BarAdmin, self).get_queryset(request)
> if request.user.is_superuser:
> return qs
> return qs.filter(owner=request.user)
>
> def has_add_permission(self, request):
> return True
>
> def has_change_permission(self, request, obj=None):
> if obj is None:
> return True
> if obj.owner == request.user:
> return True
> return False
>
> def has_delete_permission(self, request, obj=None):
> if obj is None:
> return True
> if obj.owner == request.user:
> return True
> return False
>
> def has_module_permission(self, request):
> return True
>
> Accessing the link admin/foo/bar/ works correctly for every user and
> returns the list of Bar instances for which obj.owner == request.user.
> admin/foo/bar/add allows the user to add a new object correctly. These
> links are although not displayed in the admin index page: which is the
> function that triggers the appearance of the model in the index page?
> admin/foo/ returns 403 Forbidden.
>
>
> Uhm… this looks strange to me. So you don’t want to provide the user with
> add/change/delete permissions but you are faking them.
>
> The Bar model doesn’t appear in the App index list page because the view
> function in charge first verifies whether the user has any of the
> add/change/delete permissions granted for such App, and given that your
> user doesn’t have them the App Foo is not listed. In other words, you would
> have to override the index admin view too (in
> django.contrib.admin.sites.py), which I don’t recommend. Think that by
> overriding the way permissions are handled in the admin interface you might
> end up giving change access to regular users that shouldn’t have access at
> all.
>
> My recommendation here is to crea

Re: Show a model on the admin list index page

2014-10-07 Thread Daniel Rus Morales
Hi Andrea,

I answer below in between lines.

On 07 Oct 2014, at 08:53, Andrea <andrea.g...@gmail.com> wrote:

> Let's suppose I have a Foo app with a Bar model with a owner field. I want a 
> user to be able to edit all the instances for which obj.owner == request.user.
> 
> The model appears correctly in the admin panel for superusers and for users 
> for which I have explicitly assigned the permission change_bar or add_bar, as 
> explained here:
> 
> Assuming you have an application with an app_label foo and a model named Bar, 
> to test for basic permissions you should use:
> 
> add: user.has_perm('foo.add_bar')
> change: user.has_perm('foo.change_bar')
> delete: user.has_perm('foo.delete_bar')
> How can I show the model Bar in the admin index list without explicitly 
> assigning foo.change_bar or foo.add_bar to the user?
> 
> 

You can’t. The admin interface of Django assumes that when a user has access to 
the administrative interface of an App-Model it’s not to act as a mere passive 
consumer with read-only access but rather as an active admin over the content 
(add, change, delete). An administrator who does only inspect or supervise the 
content doesn’t fit in the sort of administrator that the Django administration 
app allows. It’s like allowing an administrator who actually does not 
administer. 

> So far I tried the following, expecting the Bar model to appear in the index 
> list page, but it didn't work.
> 
> class BarAdmin(admin.ModelAdmin):
> def get_queryset(self, request):
> qs = super(BarAdmin, self).get_queryset(request)
> if request.user.is_superuser:
> return qs
> return qs.filter(owner=request.user)
> 
> def has_add_permission(self, request):
> return True
> 
> def has_change_permission(self, request, obj=None):
> if obj is None:
> return True
> if obj.owner == request.user:
> return True
> return False
> 
> def has_delete_permission(self, request, obj=None):
> if obj is None:
> return True
> if obj.owner == request.user:
> return True
> return False
> 
> def has_module_permission(self, request):
> return True
> Accessing the link admin/foo/bar/ works correctly for every user and returns 
> the list of Bar instances for which obj.owner == request.user. 
> admin/foo/bar/add allows the user to add a new object correctly. These links 
> are although not displayed in the admin index page: which is the function 
> that triggers the appearance of the model in the index page? admin/foo/ 
> returns 403 Forbidden.
> 

Uhm… this looks strange to me. So you don’t want to provide the user with 
add/change/delete permissions but you are faking them. 

The Bar model doesn’t appear in the App index list page because the view 
function in charge first verifies whether the user has any of the 
add/change/delete permissions granted for such App, and given that your user 
doesn’t have them the App Foo is not listed. In other words, you would have to 
override the index admin view too (in django.contrib.admin.sites.py), which I 
don’t recommend. Think that by overriding the way permissions are handled in 
the admin interface you might end up giving change access to regular users that 
shouldn’t have access at all. 

My recommendation here is to create your own supervising interface for Foo, 
with its own URLs, to provide the readonly functionality your target users 
needs. Those users might not probably fall in the category of admins. I’m 
thinking in maybe managers who need to see what’s going on but doesn’t have to 
have write access.

Does this answer your questions?

> I'm using Django 1.7
> 
> Thanks,
> 
> Andrea
> 
> 

Cheers,
Daniel



signature.asc
Description: Message signed with OpenPGP using GPGMail


Show a model on the admin list index page

2014-10-07 Thread Andrea
Let's suppose I have a Foo app with a Bar model with a owner field. I want
a user to be able to edit all the instances for which obj.owner ==
request.user.

The model appears correctly in the admin panel for superusers and for users
for which I have explicitly assigned the permission change_bar or add_bar,
as explained here
<https://docs.djangoproject.com/en/dev/topics/auth/default/#topic-authorization>
:

Assuming you have an application with an app_label foo and a model named
Bar, to test for basic permissions you should use:

add: user.has_perm('foo.add_bar')
change: user.has_perm('foo.change_bar')
delete: user.has_perm('foo.delete_bar')

 How can I show the model Bar in the admin index list without explicitly
assigning foo.change_bar or foo.add_bar to the user?

So far I tried the following, expecting the Bar model to appear in the
index list page, but it didn't work.

class BarAdmin(admin.ModelAdmin):
def get_queryset(self, request):
qs = super(BarAdmin, self).get_queryset(request)
if request.user.is_superuser:
return qs
return qs.filter(owner=request.user)

def has_add_permission(self, request):
return True

def has_change_permission(self, request, obj=None):
if obj is None:
return True
if obj.owner == request.user:
return True
return False

def has_delete_permission(self, request, obj=None):
if obj is None:
return True
if obj.owner == request.user:
return True
return False

def has_module_permission(self, request):
return True

Accessing the link admin/foo/bar/ works correctly for every user and
returns the list of Bar instances for which obj.owner == request.user.
admin/foo/bar/add allows the user to add a new object correctly. These
links are although not displayed in the admin index page: which is the
function that triggers the appearance of the model in the index page?
admin/foo/ returns 403 Forbidden.

I'm using Django 1.7

Thanks,

Andrea

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


Column type and index not support by Django ORM - best way to alter/add them

2014-05-26 Thread graeme
I need to do the the following to Postgres tables for Django models:

1) Add a functional index
2) Have a bigserial primary key and a bigint foreign key point to it.

Given that I only want this on a single install, is there any reason not to 
just do it directly? I have found code snippets with "AutoBigInt" fields, 
but only one claims to support South and non mention Django migrations. I 
have not found anything to help with adding the index.

The best I can come up with is to directly alter the column type, and do 
the same to add the index, and write a migration to do that later IF we 
ever need more than one install - otherwise its more work that way.

Given that the primary key and the foreign keys pointing to it are unlikely 
to ever change, can I also guess that this is not likely to cause problems 
with migrations (South and the new Djnago ones in 1.7 when we upgrade) that 
change other fields of the model?

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


two views in one page(index)

2013-09-14 Thread Akhil Dangore
  hello friend 
i am using pinax(django) for my project in that it contains two 
views(signupview/loginview) and having diferent url "account/signup" & 
"account/login" 
so when i am calling two url in one page(index.html).it's overwritting each 
other forms.

plz provide some solution on it .

-- 
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 IndexError: list index out of range

2013-08-24 Thread Oleg Gorjajnov
Yes, this is typo. But I don't see there no edit button

суббота, 24 августа 2013 г., 20:52:45 UTC+4 пользователь WongoBongo написал:
>
> Can you change the name of this file from
>
> newweb/polls/__init.py__
>
> to
>
> newweb/polls/__init__.py
>
> That file name is not right.
>
> K
>
>
>
> On Saturday, August 24, 2013 8:02:38 AM UTC-7, Oleg Gorjajnov wrote:
>>
>> I'm new to Django. 
>>
>>
>> newweb/
>>   manage.py
>>   newweb/
>> __init__.py
>> settings.py
>> urls.py
>> wsgi.py
>>   polls/
>> __init.py__
>> admin.py
>> models.py
>> tests.py
>>
>>
>>

-- 
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 IndexError: list index out of range

2013-08-24 Thread Kelvin Wong
Can you change the name of this file from

newweb/polls/__init.py__

to

newweb/polls/__init__.py

That file name is not right.

K



On Saturday, August 24, 2013 8:02:38 AM UTC-7, Oleg Gorjajnov wrote:
>
> I'm new to Django. 
>
>
> newweb/
>   manage.py
>   newweb/
> __init__.py
> settings.py
> urls.py
> wsgi.py
>   polls/
> __init.py__
> admin.py
> models.py
> tests.py
>
>
>

-- 
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 IndexError: list index out of range

2013-08-24 Thread Oleg Gorjajnov
No, I have no problems with manage.py runserver or syncdb. Just now tried 
build this code in PyCharm and got the same error

суббота, 24 августа 2013 г., 19:42:04 UTC+4 пользователь tom написал:
>
>
> On 24 Aug 2013, at 16:02, Oleg Gorjajnov  
> wrote:
>
> And this is *not my case*. 
>
> So what's wrong with that? It must work well without *meta* classes.
>
>
> Do you get any problems when you do manage.py runserver or syncdb? I think 
> your problem stems from trying to build within Sublime Text.
>

-- 
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 IndexError: list index out of range

2013-08-24 Thread Thomas Scrace

On 24 Aug 2013, at 16:02, Oleg Gorjajnov  wrote:

> And this is not my case. 
> 
> So what's wrong with that? It must work well without meta classes.
> 

Do you get any problems when you do manage.py runserver or syncdb? I think your 
problem stems from trying to build within Sublime Text.

-- 
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.


Django IndexError: list index out of range

2013-08-24 Thread Oleg Gorjajnov
I'm new to Django. 
Now I'm learning Django, using Writing your first Django 
app<https://docs.djangoproject.com/en/dev/intro/tutorial01/> (version 
1.5.2) tutorial.
I'm a *Windows 7 * and *Sublime Text 2* user. 

Following this tutorial, I created a project called *newweb* 
in*C:\DjangoProjects
*.
And then in the *newweb* project I created an app called *polls*.
So, now I have the following directory structure:

newweb/
  manage.py
  newweb/
__init__.py
settings.py
urls.py
wsgi.py
  polls/
__init.py__
admin.py
models.py
tests.py



   - In the *models.py* file I have the following code:
   

from django.db import models

class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')

class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)


   - When I build this code in Sublime Text 2 I get this error message:
   
  Traceback (most recent call last):
  File "C:\DjangoProjects\newweb\polls\models.py", line 3, in 
class Poll(models.Model):
  File "C:\python27\lib\site-packages\django\db\models\base.py", line 93, 
in __new__
kwargs = {"app_label": model_module.__name__.split('.')[-2]}
IndexError: list index out of range


   - What to do?

I have read that to prevent this problem I have to add a *meta* class to 
each of my classes (*and it works for me*).
*But *in the Django documentation I read the following:

If a model exists *outside* of the standard locations (models.py or a 
models package in an app), the model must define which app it is part of.

And this is *not my case*. 

So what's wrong with that? It must work well without *meta* classes.


CONFIGURATION

   - I have added the *polls* app to* INSTALLED_APPS* in the *settings.py*file.
   - I synced the database (sqlite3), using *manage.py syncdb*
   - And what I have on my *PYTHONPATH*:


[' ',
 'C:\\python27\\lib\\site-packages\\distribute-0.6.49-py2.7.egg',
 'C:\\python27\\lib\\site-packages\\pip-1.4.1-py2.7.egg',
 'C:\\DjangoProjects\\newweb',
 'C:\\Windows\\system32\\python27.zip',
 'C:\\python27\\DLLs',
 'C:\\python27\\lib',
 'C:\\python27\\lib\\plat-win',
 'C:\\python27\\lib\\lib-tk',
 'C:\\python27',
 'C:\\python27\\lib\\site-packages']

Also, I will say anything you ask.

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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: NoReverseMatch at /accounts/login/ Reverse for 'index' with arguments '()' and keyword arguments '{}' not found.

2013-05-11 Thread Hu Shizhi
Thanks Raharu. It works.

Best,

Tian

On Saturday, May 11, 2013 10:12:37 PM UTC+8, Raharu Haruha wrote:
>
> there is no pattern named "index" (name="index") so, no reverse match
> also, if you planned to work with django in future, i suggest you to use 
> new-style url template tag like so:
>
> {% load url form future %}
> ...
> {% url 'index' %}
> ...
>
> On Saturday, May 11, 2013 5:14:02 AM UTC+4, Hu Shizhi wrote:
>>
>> My urls.py:
>>
>> from django.conf.urls import patterns, include, url
>> # from django.contrib.auth import login, logout   
>>
>>
>> # Uncomment the next two lines to enable the admin:   
>>
>> from django.contrib import admin
>> admin.autodiscover()
>>
>> urlpatterns = patterns('',
>> # url(r'^$', 'patient.views.home', name='home'), 
>> 
>> url(r'^accounts/', include('registration.backends.default.urls')),
>> # url(r'^register/$', 'patient.views.register'), 
>> 
>> #   url(r'^login/$', 'login', name='login'), 
>> 
>> # url(r'^logout/$', 'logout'),   
>> 
>> # url(r'^patient/', include('patient.urls')), 
>>
>>
>> # Uncomment the admin/doc line below to enable admin documentation:   
>>
>> # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), 
>> 
>>
>> # Uncomment the next line to enable the admin:   
>> 
>> url(r'^admin/', include(admin.site.urls)),
>> )
>>
>> On Friday, May 10, 2013 11:22:08 PM UTC+8, C. Kirby wrote:
>>>
>>> Do you have a urls.py file? To used the url tag with a name you need to 
>>> have a defined url with that name, example:
>>>
>>> urlpatterns = patterns('',
>>> url(r'^$', 'app.views.index', name="index"),
>>> )
>>>
>>> On Friday, May 10, 2013 9:38:27 AM UTC-5, Hu Shizhi wrote:
>>>>
>>>> Hi,
>>>>
>>>> I am new to Django and am using django-registration and followed the 
>>>> quickstart.rst document and get the following. Could anyone kindly help?
>>>>
>>>> Thanks,
>>>>
>>>> Tian
>>>>
>>>> NoReverseMatch at /accounts/login/
>>>>
>>>> Reverse for 'index' with arguments '()' and keyword arguments '{}' not 
>>>> found.
>>>>
>>>> Request Method:GETRequest URL:http://127.0.0.1:8000/accounts/login/Django 
>>>> Version:1.4Exception Type:NoReverseMatchException Value:
>>>>
>>>> Reverse for 'index' with arguments '()' and keyword arguments '{}' not 
>>>> found.
>>>>
>>>> Exception 
>>>> Location:/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/django/template/defaulttags.py
>>>>  
>>>> in render, line 424Python Executable:
>>>> /Users/apple/.virtualenvs/health/bin/pythonPython Version:2.7.1Python 
>>>> Path:
>>>>
>>>> ['/Users/apple/projects/misc/health',
>>>>  
>>>> '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg',
>>>>  
>>>> '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg',
>>>>  
>>>> '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/redis-2.7.3-py2.7.egg',
>>>>  
>>>> '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/readline-6.2.4.1-py2.7-macosx-10.7-intel.egg',
>>>>  '/Users/apple/.virtualenvs/health/lib/python27.zip',
>>>>  '/Users/apple/.virtualenvs/health/lib/python2.7',
>>>>  '/Users/apple/.virtualenvs/health/lib/python2.7/plat-darwin',
>>>>  '/Users/apple/.virtualenvs/health/lib/python2.7/plat-mac',
>&

Re: NoReverseMatch at /accounts/login/ Reverse for 'index' with arguments '()' and keyword arguments '{}' not found.

2013-05-11 Thread Raharu Haruha
there is no pattern named "index" (name="index") so, no reverse match
also, if you planned to work with django in future, i suggest you to use 
new-style url template tag like so:

{% load url form future %}
...
{% url 'index' %}
...

On Saturday, May 11, 2013 5:14:02 AM UTC+4, Hu Shizhi wrote:
>
> My urls.py:
>
> from django.conf.urls import patterns, include, url
> # from django.contrib.auth import login, logout   
>
>
> # Uncomment the next two lines to enable the admin:   
>
> from django.contrib import admin
> admin.autodiscover()
>
> urlpatterns = patterns('',
> # url(r'^$', 'patient.views.home', name='home'),   
>   
> url(r'^accounts/', include('registration.backends.default.urls')),
> # url(r'^register/$', 'patient.views.register'),   
>   
> #   url(r'^login/$', 'login', name='login'),   
>   
> # url(r'^logout/$', 'logout'), 
>   
> # url(r'^patient/', include('patient.urls')), 
>
>
> # Uncomment the admin/doc line below to enable admin documentation:   
>
> # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),   
>   
>
> # Uncomment the next line to enable the admin: 
>   
> url(r'^admin/', include(admin.site.urls)),
> )
>
> On Friday, May 10, 2013 11:22:08 PM UTC+8, C. Kirby wrote:
>>
>> Do you have a urls.py file? To used the url tag with a name you need to 
>> have a defined url with that name, example:
>>
>> urlpatterns = patterns('',
>> url(r'^$', 'app.views.index', name="index"),
>> )
>>
>> On Friday, May 10, 2013 9:38:27 AM UTC-5, Hu Shizhi wrote:
>>>
>>> Hi,
>>>
>>> I am new to Django and am using django-registration and followed the 
>>> quickstart.rst document and get the following. Could anyone kindly help?
>>>
>>> Thanks,
>>>
>>> Tian
>>>
>>> NoReverseMatch at /accounts/login/
>>>
>>> Reverse for 'index' with arguments '()' and keyword arguments '{}' not 
>>> found.
>>>
>>> Request Method:GETRequest URL:http://127.0.0.1:8000/accounts/login/Django 
>>> Version:1.4Exception Type:NoReverseMatchException Value:
>>>
>>> Reverse for 'index' with arguments '()' and keyword arguments '{}' not 
>>> found.
>>>
>>> Exception 
>>> Location:/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/django/template/defaulttags.py
>>>  
>>> in render, line 424Python Executable:
>>> /Users/apple/.virtualenvs/health/bin/pythonPython Version:2.7.1Python 
>>> Path:
>>>
>>> ['/Users/apple/projects/misc/health',
>>>  
>>> '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg',
>>>  
>>> '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg',
>>>  
>>> '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/redis-2.7.3-py2.7.egg',
>>>  
>>> '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/readline-6.2.4.1-py2.7-macosx-10.7-intel.egg',
>>>  '/Users/apple/.virtualenvs/health/lib/python27.zip',
>>>  '/Users/apple/.virtualenvs/health/lib/python2.7',
>>>  '/Users/apple/.virtualenvs/health/lib/python2.7/plat-darwin',
>>>  '/Users/apple/.virtualenvs/health/lib/python2.7/plat-mac',
>>>  
>>> '/Users/apple/.virtualenvs/health/lib/python2.7/plat-mac/lib-scriptpackages',
>>>  '/Users/apple/.virtualenvs/health/Extras/lib/python',
>>>  '/Users/apple/.virtualenvs/health/lib/python2.7/lib-tk',
>>>  '/Users/apple/.virtualenvs/health/lib/python2.7/lib-old',
>>>  '/Users/apple/.virtualenvs/health/lib/python2.7/lib-dynload',
>>>  '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
>>>  
>>> '

Re: NoReverseMatch at /accounts/login/ Reverse for 'index' with arguments '()' and keyword arguments '{}' not found.

2013-05-10 Thread Hu Shizhi
My urls.py:

from django.conf.urls import patterns, include, url
# from django.contrib.auth import login, logout 
 

# Uncomment the next two lines to enable the admin: 
 
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
# url(r'^$', 'patient.views.home', name='home'),   
  
url(r'^accounts/', include('registration.backends.default.urls')),
# url(r'^register/$', 'patient.views.register'),   
  
#   url(r'^login/$', 'login', name='login'),   
  
# url(r'^logout/$', 'logout'), 
  
# url(r'^patient/', include('patient.urls')),   
 

# Uncomment the admin/doc line below to enable admin documentation: 
 
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),   
  

# Uncomment the next line to enable the admin: 
  
url(r'^admin/', include(admin.site.urls)),
)

On Friday, May 10, 2013 11:22:08 PM UTC+8, C. Kirby wrote:
>
> Do you have a urls.py file? To used the url tag with a name you need to 
> have a defined url with that name, example:
>
> urlpatterns = patterns('',
> url(r'^$', 'app.views.index', name="index"),
> )
>
> On Friday, May 10, 2013 9:38:27 AM UTC-5, Hu Shizhi wrote:
>>
>> Hi,
>>
>> I am new to Django and am using django-registration and followed the 
>> quickstart.rst document and get the following. Could anyone kindly help?
>>
>> Thanks,
>>
>> Tian
>>
>> NoReverseMatch at /accounts/login/
>>
>> Reverse for 'index' with arguments '()' and keyword arguments '{}' not found.
>>
>> Request Method:GETRequest URL:http://127.0.0.1:8000/accounts/login/Django 
>> Version:1.4Exception Type:NoReverseMatchException Value:
>>
>> Reverse for 'index' with arguments '()' and keyword arguments '{}' not found.
>>
>> Exception 
>> Location:/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/django/template/defaulttags.py
>>  
>> in render, line 424Python Executable:
>> /Users/apple/.virtualenvs/health/bin/pythonPython Version:2.7.1Python 
>> Path:
>>
>> ['/Users/apple/projects/misc/health',
>>  
>> '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg',
>>  
>> '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg',
>>  
>> '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/redis-2.7.3-py2.7.egg',
>>  
>> '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/readline-6.2.4.1-py2.7-macosx-10.7-intel.egg',
>>  '/Users/apple/.virtualenvs/health/lib/python27.zip',
>>  '/Users/apple/.virtualenvs/health/lib/python2.7',
>>  '/Users/apple/.virtualenvs/health/lib/python2.7/plat-darwin',
>>  '/Users/apple/.virtualenvs/health/lib/python2.7/plat-mac',
>>  
>> '/Users/apple/.virtualenvs/health/lib/python2.7/plat-mac/lib-scriptpackages',
>>  '/Users/apple/.virtualenvs/health/Extras/lib/python',
>>  '/Users/apple/.virtualenvs/health/lib/python2.7/lib-tk',
>>  '/Users/apple/.virtualenvs/health/lib/python2.7/lib-old',
>>  '/Users/apple/.virtualenvs/health/lib/python2.7/lib-dynload',
>>  '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
>>  
>> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
>>  
>> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
>>  
>> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
>>  
>> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
>>  '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages',
>>  '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/PIL']
>>
>> Server time:Fri, 10 May 2013 22:29:17 +0800
>> Error during template rendering
>>
>> In template /Users/apple/projects/misc/

Re: NoReverseMatch at /accounts/login/ Reverse for 'index' with arguments '()' and keyword arguments '{}' not found.

2013-05-10 Thread C. Kirby
Do you have a urls.py file? To used the url tag with a name you need to 
have a defined url with that name, example:

urlpatterns = patterns('',
url(r'^$', 'app.views.index', name="index"),
)

On Friday, May 10, 2013 9:38:27 AM UTC-5, Hu Shizhi wrote:
>
> Hi,
>
> I am new to Django and am using django-registration and followed the 
> quickstart.rst document and get the following. Could anyone kindly help?
>
> Thanks,
>
> Tian
>
> NoReverseMatch at /accounts/login/
>
> Reverse for 'index' with arguments '()' and keyword arguments '{}' not found.
>
> Request Method:GETRequest URL:http://127.0.0.1:8000/accounts/login/Django 
> Version:1.4Exception Type:NoReverseMatchException Value:
>
> Reverse for 'index' with arguments '()' and keyword arguments '{}' not found.
>
> Exception 
> Location:/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/django/template/defaulttags.py
>  
> in render, line 424Python Executable:
> /Users/apple/.virtualenvs/health/bin/pythonPython Version:2.7.1Python 
> Path:
>
> ['/Users/apple/projects/misc/health',
>  
> '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg',
>  
> '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg',
>  
> '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/redis-2.7.3-py2.7.egg',
>  
> '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/readline-6.2.4.1-py2.7-macosx-10.7-intel.egg',
>  '/Users/apple/.virtualenvs/health/lib/python27.zip',
>  '/Users/apple/.virtualenvs/health/lib/python2.7',
>  '/Users/apple/.virtualenvs/health/lib/python2.7/plat-darwin',
>  '/Users/apple/.virtualenvs/health/lib/python2.7/plat-mac',
>  '/Users/apple/.virtualenvs/health/lib/python2.7/plat-mac/lib-scriptpackages',
>  '/Users/apple/.virtualenvs/health/Extras/lib/python',
>  '/Users/apple/.virtualenvs/health/lib/python2.7/lib-tk',
>  '/Users/apple/.virtualenvs/health/lib/python2.7/lib-old',
>  '/Users/apple/.virtualenvs/health/lib/python2.7/lib-dynload',
>  '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
>  '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages',
>  '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/PIL']
>
> Server time:Fri, 10 May 2013 22:29:17 +0800
> Error during template rendering
>
> In template /Users/apple/projects/misc/health/patient/templates/base.html, 
> error at line *14*
> Reverse for 'index' with arguments '()' and keyword arguments '{}' not 
> found.4http://www.w3.org/1999/xhtml; xml:lang="en" 
> lang="en"> 5 6 7  8{% 
> block title %}User test{% endblock %} 
> 9 10 11 12  13 {% block header %} 14  href="{% url index %}">{% trans "Home" %} | 15 16 {% if 
> user.is_authenticated %} 17 {% trans "Logged in" %}: {{ user.username }} 
> 18 ({% trans "Log out" %} | 19  href="{% url auth_password_change %}">{% trans "Change password" %}) 
> 20 {% else %} 21 {% trans "Log in" %} 
> 22 {% endif %} 23  24 {% endblock %} 
>

-- 
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.




NoReverseMatch at /accounts/login/ Reverse for 'index' with arguments '()' and keyword arguments '{}' not found.

2013-05-10 Thread Hu Shizhi
Hi,

I am new to Django and am using django-registration and followed the 
quickstart.rst document and get the following. Could anyone kindly help?

Thanks,

Tian

NoReverseMatch at /accounts/login/

Reverse for 'index' with arguments '()' and keyword arguments '{}' not found.

Request Method:GETRequest URL:http://127.0.0.1:8000/accounts/login/Django 
Version:1.4Exception Type:NoReverseMatchException Value:

Reverse for 'index' with arguments '()' and keyword arguments '{}' not found.

Exception 
Location:/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/django/template/defaulttags.py
 
in render, line 424Python Executable:
/Users/apple/.virtualenvs/health/bin/pythonPython Version:2.7.1Python Path:

['/Users/apple/projects/misc/health',
 
'/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg',
 
'/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg',
 
'/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/redis-2.7.3-py2.7.egg',
 
'/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/readline-6.2.4.1-py2.7-macosx-10.7-intel.egg',
 '/Users/apple/.virtualenvs/health/lib/python27.zip',
 '/Users/apple/.virtualenvs/health/lib/python2.7',
 '/Users/apple/.virtualenvs/health/lib/python2.7/plat-darwin',
 '/Users/apple/.virtualenvs/health/lib/python2.7/plat-mac',
 '/Users/apple/.virtualenvs/health/lib/python2.7/plat-mac/lib-scriptpackages',
 '/Users/apple/.virtualenvs/health/Extras/lib/python',
 '/Users/apple/.virtualenvs/health/lib/python2.7/lib-tk',
 '/Users/apple/.virtualenvs/health/lib/python2.7/lib-old',
 '/Users/apple/.virtualenvs/health/lib/python2.7/lib-dynload',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
 '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages',
 '/Users/apple/.virtualenvs/health/lib/python2.7/site-packages/PIL']

Server time:Fri, 10 May 2013 22:29:17 +0800
Error during template rendering

In template /Users/apple/projects/misc/health/patient/templates/base.html, 
error at line *14*
Reverse for 'index' with arguments '()' and keyword arguments '{}' not 
found.4http://www.w3.org/1999/xhtml; xml:lang="en" lang="en"> 5 
6 7  8 {% block 
title %}User test{% endblock %} 9 10 11 12  13 {% block header %} 14 {% trans 
"Home" %} | 15 16 {% if user.is_authenticated %} 17 {% trans "Logged 
in" %}: {{ user.username }} 18 ({% trans 
"Log out" %} | 19 {% trans 
"Change password" %}) 20 {% else %} 21 {% trans "Log in" %} 22 {% endif %} 23  24 {% endblock %} 

-- 
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: Hey! I'm recieving an index error when trying to import models, and I can't figure out why.

2013-04-01 Thread Bill Freeman
Stick a print statement between lines 91 and 92 to show you
model_module.__name__ .
(or use pdb if you're comfortable with it).  My best guess is that the
split() is returning a
list of one item.  That is, that there is no '.' in model_module.__name__
.  Thus an index
of -2 failss: there is no penultimate item.

At least for the time when it gets the exception.  That is, you may get
many lines printed,
but the last one before the exception won't have a '.'


On Mon, Apr 1, 2013 at 1:48 PM, C Alaric Moore <alaricmeis...@gmail.com>wrote:

> I just tried this and still have the same error. I also might add that I'm
> using a mac with an updated os. I also hear that it could be an issue of
> line breaks, but can't find any /n's or /r's in any of the code anyway. I
> might just be looking in the wrong places, too.
>
>
> On Sunday, March 31, 2013 9:33:21 PM UTC-7, jondbaker wrote:
>
>> When importing Python modules, you don't need to include the '.py' file
>> extension. So,
>> from models.py import UUID
>> ...needs to be:
>> from models import UUID
>>
>> Hope this helps,
>> Jonathan
>>
>>
>> On Sun, Mar 31, 2013 at 10:27 PM, C Alaric Moore <alaric...@gmail.com>wrote:
>>
>>> Hello,
>>>
>>> I am incredibly new to Django, as-of-today new, so forgive me if I've
>>> missed something really obvious.
>>>
>>> I've been going through the tutorial and did so mostly-successfully and
>>> decided to redo it with my own code.
>>>
>>> Everything was going fine until I decided that it would be a good idea
>>> to type from models.py import UUID, Students into the shell. With this I
>>> received the following error:
>>>
>>> /Library/Frameworks/Python.**framework/Versions/7.3/lib/**
>>> python2.7/site-packages/**django/db/models/base.pyc in __new__(cls,
>>> name, bases, attrs)
>>>  90 # For 'django.contrib.sites.models', this would be
>>> 'sites'.
>>>
>>>  91 model_module = sys.modules[new_class.__**module__]
>>> ---> 92 kwargs = {"app_label": model_module.__name__.split('.
>>> **')[-2]}
>>>  93 else:
>>>  94 kwargs = {}
>>>
>>> IndexError: list index out of range
>>>
>>> I went onto stackoverflow and found some people had similar issues a
>>> year ago, and suggested that a person delete the pyc files, which I did. It
>>> was also suggested that you make DEBUGGING = False, or True or whatever is
>>> opposite. I did this, too, only to find the same error.
>>>
>>> I did some other things too, all to no avail... all the same error. I
>>> even checked to make sure I was saving edited files, TWICE. Still, same
>>> error.
>>>
>>> With this, I ask for your help o' wise ones.
>>>
>>> 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...@**googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>>
>>> Visit this group at 
>>> http://groups.google.com/**group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
>>> .
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>> .
>>>
>>>
>>>
>>
>>
>>
>> --
>> Jonathan D. Baker
>> Developer
>> http://jonathandbaker.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 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.
>
>
>

-- 
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: Hey! I'm recieving an index error when trying to import models, and I can't figure out why.

2013-04-01 Thread C Alaric Moore
I just tried this and still have the same error. I also might add that I'm 
using a mac with an updated os. I also hear that it could be an issue of 
line breaks, but can't find any /n's or /r's in any of the code anyway. I 
might just be looking in the wrong places, too. 

On Sunday, March 31, 2013 9:33:21 PM UTC-7, jondbaker wrote:
>
> When importing Python modules, you don't need to include the '.py' file 
> extension. So,
> from models.py import UUID
> ...needs to be:
> from models import UUID
>
> Hope this helps,
> Jonathan
>
>
> On Sun, Mar 31, 2013 at 10:27 PM, C Alaric Moore 
> <alaric...@gmail.com
> > wrote:
>
>> Hello, 
>>
>> I am incredibly new to Django, as-of-today new, so forgive me if I've 
>> missed something really obvious. 
>>
>> I've been going through the tutorial and did so mostly-successfully and 
>> decided to redo it with my own code. 
>>
>> Everything was going fine until I decided that it would be a good idea to 
>> type from models.py import UUID, Students into the shell. With this I 
>> received the following error: 
>>
>> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/django/db/models/base.pyc
>>  
>> in __new__(cls, name, bases, attrs)
>>  90 # For 'django.contrib.sites.models', this would be 
>> 'sites'.
>>
>>  91 model_module = sys.modules[new_class.__module__]
>> ---> 92 kwargs = {"app_label": 
>> model_module.__name__.split('.')[-2]}
>>  93 else:
>>  94 kwargs = {}
>>
>> IndexError: list index out of range
>>
>> I went onto stackoverflow and found some people had similar issues a year 
>> ago, and suggested that a person delete the pyc files, which I did. It was 
>> also suggested that you make DEBUGGING = False, or True or whatever is 
>> opposite. I did this, too, only to find the same error. 
>>
>> I did some other things too, all to no avail... all the same error. I 
>> even checked to make sure I was saving edited files, TWICE. Still, same 
>> error. 
>>
>> With this, I ask for your help o' wise ones. 
>>
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@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.
>>  
>>  
>>
>
>
>
> -- 
> Jonathan D. Baker
> Developer
> http://jonathandbaker.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 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: Hey! I'm recieving an index error when trying to import models, and I can't figure out why.

2013-03-31 Thread Jonathan Baker
When importing Python modules, you don't need to include the '.py' file
extension. So,
from models.py import UUID
...needs to be:
from models import UUID

Hope this helps,
Jonathan


On Sun, Mar 31, 2013 at 10:27 PM, C Alaric Moore <alaricmeis...@gmail.com>wrote:

> Hello,
>
> I am incredibly new to Django, as-of-today new, so forgive me if I've
> missed something really obvious.
>
> I've been going through the tutorial and did so mostly-successfully and
> decided to redo it with my own code.
>
> Everything was going fine until I decided that it would be a good idea to
> type from models.py import UUID, Students into the shell. With this I
> received the following error:
>
> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/django/db/models/base.pyc
> in __new__(cls, name, bases, attrs)
>  90 # For 'django.contrib.sites.models', this would be
> 'sites'.
>
>  91 model_module = sys.modules[new_class.__module__]
> ---> 92 kwargs = {"app_label":
> model_module.__name__.split('.')[-2]}
>  93 else:
>  94 kwargs = {}
>
> IndexError: list index out of range
>
> I went onto stackoverflow and found some people had similar issues a year
> ago, and suggested that a person delete the pyc files, which I did. It was
> also suggested that you make DEBUGGING = False, or True or whatever is
> opposite. I did this, too, only to find the same error.
>
> I did some other things too, all to no avail... all the same error. I even
> checked to make sure I was saving edited files, TWICE. Still, same error.
>
> With this, I ask for your help o' wise ones.
>
> 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.
>
>
>



-- 
Jonathan D. Baker
Developer
http://jonathandbaker.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 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.




Hey! I'm recieving an index error when trying to import models, and I can't figure out why.

2013-03-31 Thread C Alaric Moore
Hello, 

I am incredibly new to Django, as-of-today new, so forgive me if I've 
missed something really obvious. 

I've been going through the tutorial and did so mostly-successfully and 
decided to redo it with my own code. 

Everything was going fine until I decided that it would be a good idea to 
type from models.py import UUID, Students into the shell. With this I 
received the following error: 

/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/django/db/models/base.pyc
 
in __new__(cls, name, bases, attrs)
 90 # For 'django.contrib.sites.models', this would be 
'sites'.

 91 model_module = sys.modules[new_class.__module__]
---> 92 kwargs = {"app_label": 
model_module.__name__.split('.')[-2]}
 93 else:
 94 kwargs = {}

IndexError: list index out of range

I went onto stackoverflow and found some people had similar issues a year 
ago, and suggested that a person delete the pyc files, which I did. It was 
also suggested that you make DEBUGGING = False, or True or whatever is 
opposite. I did this, too, only to find the same error. 

I did some other things too, all to no avail... all the same error. I even 
checked to make sure I was saving edited files, TWICE. Still, same error. 

With this, I ask for your help o' wise ones. 

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.




Sitemaps: Individual index file for each sitemap file

2013-03-12 Thread rosy
I have different sitemaps for different app and i want index files for each 
and also sitemaps should be compressed.
For this am using django app "django-static-sitemaps 1.5.1". The problem 
is, it generates only one index file for all sitemaps but i want to make 
individual index files for each sitemap. Is there any other app or any 
other way to do this ?

In sitemaps.py, i have :

sitemaps = { 'movie': MovieSitemap,'news': NewsSitemap,}
class MovieSitemap(Sitemap):
changefreq = "daily"
priority = 0.9

def items(self):
return Movie.active.all()

def lastmod(self, obj):
return obj.modified_date
class NewsSitemap(Sitemap):
 changefreq = "daily"
 priority = 0.9

 def items(self):
return News.active.all().order_by('-created_date')

 def lastmod(self, obj):
return obj.modified_date


Now I would like one index file for sitemap-movie.xml and one for 
sitemap-news.xml

-- 
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: Changing the index page

2012-10-29 Thread Rodrigo Morgado
Helllo Sorin,

Thank you for the fix, really works to me too. I don't know why django
broke admin view without changes by me.

May i ask you one thing?. What really do static and get_static_prefix?.

Thank you

2012/10/28 Sorin Popa <sorin...@gmail.com>

> Hello,.. obviously my answer comes late, but - as I am now learning Django
> and I ran into the same issue, here's my post - may be helpful for anyone
> getting in the same trouble.
>
> I am following the tutorial for Django 1.3.
> On my Ubuntu 12.10 I have installed with Synaptic Django 1.4.1, but I
> believe I already had a Django 1.3.3 before... now the result is... in my
> command-line django-admin tells me the version is 1.3.3.
>
> But I am pretty convinced that something mixed up, and that's how this
> trouble came...
>
> Solution to "fix" your copy of index.html from the tutorial part 2:
> - replace: {% load i18n admin_static %} *with* {% load i18n static %}
> - replace: href="{% static "admin/css/dashboard.css" %}" *with* href="{%
> get_static_prefix %}admin/css/dashboard.css"
>
>
> I hope this helps!
> Sorin
>
> miercuri, 11 ianuarie 2012, 04:51:07 UTC+1, kalyan boga a scris:
>>
>> Hi,
>>
>> I was working on tutorial 2 and i tried to change the layout of index
>> page. Copied the index.html template to my template folder under admin and
>> changed the contents to suit the site. The second line errors out :
>> {% load i18n admin_static %}
>>
>> The error on the page reads :
>> TemplateSyntaxError at /admin/
>>
>> 'admin_static' is not a valid tag library: Template library admin_static not 
>> found, tried 
>> django.templatetags.admin_**static,django.contrib.admin.**templatetags.admin_static
>>
>>
>>
>> What did i miss ?
>>
>  --
> 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/-/NcMX0qVYXTcJ.
> 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.
>



-- 
   Rodrigo Morgad*o*
Tel: (56 2) 246 3220
Cel: (56 9) 5 333 8041
  www.ewok.cl

This email and any files transmitted with it are confidential and intended
solely for the recipient named. If you have received this email in error
please notify the sender immediately. Any disclosure, copying, or
distribution of this message, or taking of any action based on it, is
strictly prohibited. Failure to respect this prohibition may constitute a
breach of law.

Este mail y cualquier archivo enviado adjunto son confidenciales y
destinados solo a la utilización del individuo o entidad a la que van
dirigidos. Sí usted ha recibido este mail por error, Favor bórrelo y
notifique al remitente. Se prohíbe cualquier uso, copia o distribución de
este mensaje o sus adjuntos. El no respetar esta prohibición puede
constituir una infracción a la ley.

-- 
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: Changing the index page

2012-10-28 Thread Sorin Popa
Hello,.. obviously my answer comes late, but - as I am now learning Django 
and I ran into the same issue, here's my post - may be helpful for anyone 
getting in the same trouble.

I am following the tutorial for Django 1.3.
On my Ubuntu 12.10 I have installed with Synaptic Django 1.4.1, but I 
believe I already had a Django 1.3.3 before... now the result is... in my 
command-line django-admin tells me the version is 1.3.3.

But I am pretty convinced that something mixed up, and that's how this 
trouble came...

Solution to "fix" your copy of index.html from the tutorial part 2:
- replace: {% load i18n admin_static %} *with* {% load i18n static %}
- replace: href="{% static "admin/css/dashboard.css" %}" *with* href="{% 
get_static_prefix %}admin/css/dashboard.css"


I hope this helps!
Sorin

miercuri, 11 ianuarie 2012, 04:51:07 UTC+1, kalyan boga a scris:
>
> Hi,
>
> I was working on tutorial 2 and i tried to change the layout of index 
> page. Copied the index.html template to my template folder under admin and 
> changed the contents to suit the site. The second line errors out :  
> {% load i18n admin_static %}
>
> The error on the page reads :
> TemplateSyntaxError at /admin/ 
>
> 'admin_static' is not a valid tag library: Template library admin_static not 
> found, tried 
> django.templatetags.admin_static,django.contrib.admin.templatetags.admin_static
>
>
>
> What did i miss ?
>

-- 
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/-/NcMX0qVYXTcJ.
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: Postgresql Index & expensive queries [n00bie alert]

2012-10-20 Thread Christophe Pettus

On Oct 20, 2012, at 11:34 PM, Barry Morrison wrote:

> Looking further at Postgresql, what's interesting.  Is it creates an 'id' 
> column and appends '_id' to what is assumed to be the id field (if none is 
> specified).  
> 
> Also, it appears the magic may have already created the indexes:

It's not actually PostgreSQL that's creating those.  That's Django's standard 
behavior.

1. It automatically creates an id column for any model that lacks an explicit 
primary key.
2. It automatically adds an index to foreign key models (for text fields, you 
get both the standard one and the varchar_pattern_ops one, which is technically 
no longer required).

--
-- Christophe Pettus
   x...@thebuild.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-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: Postgresql Index & expensive queries [n00bie alert]

2012-10-20 Thread Barry Morrison
Looking further at Postgresql, what's interesting.  Is it creates an 'id' 
column and appends '_id' to what is assumed to be the id field (if none is 
specified).  

Also, it appears the magic may have already created the indexes:

django_db=# \d press_page
   Table "public.press_page"
   Column   |  Type  |
Modifiers
++-
 id | integer| not null default 
nextval('press_page_id_seq'::regclass)
 article_id | character varying(255) | not null
 page   | character varying(100) | 
 pgnumber   | smallint   | not null
Indexes:
"press_page_pkey" PRIMARY KEY, btree (id)
"press_page_article_id" btree (article_id)
"press_page_article_id_like" btree (article_id varchar_pattern_ops)
Check constraints:
"press_page_pgnumber_check" CHECK (pgnumber >= 0)
Foreign-key constraints:
"press_page_article_id_fkey" FOREIGN KEY (article_id) REFERENCES 
press_article(publication) DEFERRABLE INITIALLY DEFERRED


On Friday, October 19, 2012 8:16:25 PM UTC-7, Barry Morrison wrote:
>
> I've got a pretty expensive query...Wondering if I can't speed things up 
> in regards to Postgresql. 
>
> Here is the model: [1] http://dpaste.org/JmEeQ/
>
> Here is the sql statement: [2] http://dpaste.org/GbfAJ/
>
> Here is the template: [3] http://dpaste.org/vxRs4/
>
> Here is the 'guts' of the view: [4] http://dpaste.org/w0b2z/
>
> Total Postgresql/SQL n00b, so this may be a stupid statement. I'm 
> wondering if an index on '"press_page"."article_id"' wouldn't speed things 
> up a bit? 
>
> In dev, I don't have the amount of data that exists in production, so I 
> can't easily/realistically recreate this scenario. 
>
> FWIW, I'm running:
>
>- Django 12.04
>- Postgresql 9.1.5
>- Django 1.4.1
>
> I'm using memcache on the view to cache it, it helped take page load down 
> significantly, but I was wondering if there wasn't something I could do 
> from the DB side of things since I know it's this query that is taking the 
> page so long to load. 
>
> Thanks! 
>  

-- 
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/-/_3B-jlev3KsJ.
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: Postgresql Index & expensive queries [n00bie alert]

2012-10-20 Thread Barry Morrison
Here is what exists in Dev re: Query Plan from debug toolbar:

QUERY PLAN   Sort (cost=8.28..8.28 rows=1 width=740)Sort Key: pgnumber
-> Index Scan using press_page_article_id_like on press_page 
(cost=0.00..8.27 rows=1 width=740)    Index Cond: ((article_id)::text = 
'Test'::text)

On Friday, October 19, 2012 10:26:01 PM UTC-7, Sam Lai wrote:
>
> On 20 October 2012 14:16, Barry Morrison <bdmor...@gmail.com > 
> wrote: 
> > I've got a pretty expensive query...Wondering if I can't speed things up 
> in 
> > regards to Postgresql. 
> > 
> > Here is the model: [1] http://dpaste.org/JmEeQ/ 
> > 
> > Here is the sql statement: [2] http://dpaste.org/GbfAJ/ 
> > 
> > Here is the template: [3] http://dpaste.org/vxRs4/ 
> > 
> > Here is the 'guts' of the view: [4] http://dpaste.org/w0b2z/ 
> > 
> > Total Postgresql/SQL n00b, so this may be a stupid statement. I'm 
> wondering 
> > if an index on '"press_page"."article_id"' wouldn't speed things up a 
> bit? 
>
> Are you using the django-debug-toolbar? If not, consider using it - 
> once installed, visit that page in your browser, open up the toolbar, 
> select SQL queries, find the offending query (processing times are 
> shown), and click the Explain link. That will tell you what PostgreSQL 
> is doing, and how performance can be improved. 
>
> Alternately, fire up a terminal and launch the psql database shell. 
> Type in the query ([2]) but prefix it with the word EXPLAIN. This will 
> tell you what PostgreSQL is doing to process that query. If you see 
> Seq Scan in there, consider adding the index. Remember to run the SQL 
> statement - ANALYZE press_page - after you create the index so it can 
> update the internal statistics that it uses to decide how to process a 
> query. 
>
> You can also do this within the PGadmin application if that makes things 
> easier. 
>
> > In dev, I don't have the amount of data that exists in production, so I 
> > can't easily/realistically recreate this scenario. 
>
> You really need to have a good subset (considering both the number of 
> records, and the distribution of values within each record) if it is 
> not possible to have a copy of the production database. PostgreSQL 
> performs analysis on the data itself and uses those statistics to 
> decide how to process the query (whether to use an index, scan 
> sequentially etc.). If you dev database is not a good representation, 
> then the results you'll see with your dev database, and hence your 
> improvements, may have no effect or a negative effect in production. 
>
> I do believe having an index on press_page.article_id is a good idea 
> though. Also, are you really showing every article in that view? 
> Consider using a limit so you're not retrieving all the records, only 
> to use the first 10. The pagination features in Django may be useful 
> here. Finally, an index on press_page.pgnumber may also be worth 
> considering so PostgreSQL may be able to avoid the sorting step (an 
> index of the default type is sorted by the field in ascending order). 
>
> > FWIW, I'm running: 
> > 
> > Django 12.04 
> > Postgresql 9.1.5 
> > Django 1.4.1 
> > 
> > I'm using memcache on the view to cache it, it helped take page load 
> down 
> > significantly, but I was wondering if there wasn't something I could do 
> from 
> > the DB side of things since I know it's this query that is taking the 
> page 
> > so long to load. 
> > 
> > Thanks! 
> > 
> > -- 
> > 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/-/U92OjnMgEggJ. 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > To unsubscribe from this group, send email to 
> > django-users...@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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/vAyxjov5qK8J.
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: Postgresql Index & expensive queries [n00bie alert]

2012-10-20 Thread Barry Morrison
prefetch-related is awesome!  Thank you for that.

Thanks!

Barry

On Fri, Oct 19, 2012 at 11:54 PM, Xavier Ordoquy <xordo...@linovia.com>wrote:

> Hi,
>
> As Samuel said, the first step is to install Django Debug Toolbar to see
> what's going on with your queries.
> Then you'll probably be interested in
> https://docs.djangoproject.com/en/1.4/ref/models/querysets/#prefetch-related
>
> Regards,
> Xavier Ordoquy,
> Linovia.
>
> Le 20 oct. 2012 à 05:16, Barry Morrison <bdmorri...@gmail.com> a écrit :
>
> I've got a pretty expensive query...Wondering if I can't speed things up
> in regards to Postgresql.
>
> Here is the model: [1] http://dpaste.org/JmEeQ/
>
> Here is the sql statement: [2] http://dpaste.org/GbfAJ/
>
> Here is the template: [3] http://dpaste.org/vxRs4/
>
> Here is the 'guts' of the view: [4] http://dpaste.org/w0b2z/
>
> Total Postgresql/SQL n00b, so this may be a stupid statement. I'm
> wondering if an index on '"press_page"."article_id"' wouldn't speed things
> up a bit?
>
> In dev, I don't have the amount of data that exists in production, so I
> can't easily/realistically recreate this scenario.
>
> FWIW, I'm running:
>
>- Django 12.04
>- Postgresql 9.1.5
>- Django 1.4.1
>
> I'm using memcache on the view to cache it, it helped take page load down
> significantly, but I was wondering if there wasn't something I could do
> from the DB side of things since I know it's this query that is taking the
> page so long to load.
>
> Thanks!
>
> --
> 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/-/U92OjnMgEggJ.
> 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.
>

-- 
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: Postgresql Index & expensive queries [n00bie alert]

2012-10-20 Thread Barry Morrison
I am using Django Debug Toolbar locally for development.  That is where I
copied & pasted the SQL from.

Even if I had a complete set of data for postgresql, my local machine is an
8-core, 16GB of RAM, with solid state hard drives.  A LOT different than my
2CPU/1GB RAM/spindle disk VPS.

I guess what I need to do is clone my VPS off, firewall the crap out of it
and run Django Debug Toolbar on that...giving me a more accurate idea of
what's going on.

Thanks for the response.

On Fri, Oct 19, 2012 at 10:25 PM, Sam Lai <samuel@gmail.com> wrote:

> On 20 October 2012 14:16, Barry Morrison <bdmorri...@gmail.com> wrote:
> > I've got a pretty expensive query...Wondering if I can't speed things up
> in
> > regards to Postgresql.
> >
> > Here is the model: [1] http://dpaste.org/JmEeQ/
> >
> > Here is the sql statement: [2] http://dpaste.org/GbfAJ/
> >
> > Here is the template: [3] http://dpaste.org/vxRs4/
> >
> > Here is the 'guts' of the view: [4] http://dpaste.org/w0b2z/
> >
> > Total Postgresql/SQL n00b, so this may be a stupid statement. I'm
> wondering
> > if an index on '"press_page"."article_id"' wouldn't speed things up a
> bit?
>
> Are you using the django-debug-toolbar? If not, consider using it -
> once installed, visit that page in your browser, open up the toolbar,
> select SQL queries, find the offending query (processing times are
> shown), and click the Explain link. That will tell you what PostgreSQL
> is doing, and how performance can be improved.
>
> Alternately, fire up a terminal and launch the psql database shell.
> Type in the query ([2]) but prefix it with the word EXPLAIN. This will
> tell you what PostgreSQL is doing to process that query. If you see
> Seq Scan in there, consider adding the index. Remember to run the SQL
> statement - ANALYZE press_page - after you create the index so it can
> update the internal statistics that it uses to decide how to process a
> query.
>
> You can also do this within the PGadmin application if that makes things
> easier.
>
> > In dev, I don't have the amount of data that exists in production, so I
> > can't easily/realistically recreate this scenario.
>
> You really need to have a good subset (considering both the number of
> records, and the distribution of values within each record) if it is
> not possible to have a copy of the production database. PostgreSQL
> performs analysis on the data itself and uses those statistics to
> decide how to process the query (whether to use an index, scan
> sequentially etc.). If you dev database is not a good representation,
> then the results you'll see with your dev database, and hence your
> improvements, may have no effect or a negative effect in production.
>
> I do believe having an index on press_page.article_id is a good idea
> though. Also, are you really showing every article in that view?
> Consider using a limit so you're not retrieving all the records, only
> to use the first 10. The pagination features in Django may be useful
> here. Finally, an index on press_page.pgnumber may also be worth
> considering so PostgreSQL may be able to avoid the sorting step (an
> index of the default type is sorted by the field in ascending order).
>
> > FWIW, I'm running:
> >
> > Django 12.04
> > Postgresql 9.1.5
> > Django 1.4.1
> >
> > I'm using memcache on the view to cache it, it helped take page load down
> > significantly, but I was wondering if there wasn't something I could do
> from
> > the DB side of things since I know it's this query that is taking the
> page
> > so long to load.
> >
> > Thanks!
> >
> > --
> > 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/-/U92OjnMgEggJ.
> > 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.
>
>

-- 
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: Postgresql Index & expensive queries [n00bie alert]

2012-10-20 Thread Xavier Ordoquy
Hi,

As Samuel said, the first step is to install Django Debug Toolbar to see what's 
going on with your queries.
Then you'll probably be interested in 
https://docs.djangoproject.com/en/1.4/ref/models/querysets/#prefetch-related

Regards,
Xavier Ordoquy,
Linovia.

Le 20 oct. 2012 à 05:16, Barry Morrison <bdmorri...@gmail.com> a écrit :

> I've got a pretty expensive query...Wondering if I can't speed things up in 
> regards to Postgresql.
> 
> Here is the model: [1] http://dpaste.org/JmEeQ/
> 
> Here is the sql statement: [2] http://dpaste.org/GbfAJ/
> 
> Here is the template: [3] http://dpaste.org/vxRs4/
> 
> Here is the 'guts' of the view: [4] http://dpaste.org/w0b2z/
> 
> Total Postgresql/SQL n00b, so this may be a stupid statement. I'm wondering 
> if an index on '"press_page"."article_id"' wouldn't speed things up a bit?
> 
> In dev, I don't have the amount of data that exists in production, so I can't 
> easily/realistically recreate this scenario.
> 
> FWIW, I'm running:
> 
> Django 12.04
> Postgresql 9.1.5
> Django 1.4.1
> I'm using memcache on the view to cache it, it helped take page load down 
> significantly, but I was wondering if there wasn't something I could do from 
> the DB side of things since I know it's this query that is taking the page so 
> long to load.
> 
> Thanks!
> 
> 
> -- 
> 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/-/U92OjnMgEggJ.
> 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: Postgresql Index & expensive queries [n00bie alert]

2012-10-19 Thread Sam Lai
On 20 October 2012 14:16, Barry Morrison <bdmorri...@gmail.com> wrote:
> I've got a pretty expensive query...Wondering if I can't speed things up in
> regards to Postgresql.
>
> Here is the model: [1] http://dpaste.org/JmEeQ/
>
> Here is the sql statement: [2] http://dpaste.org/GbfAJ/
>
> Here is the template: [3] http://dpaste.org/vxRs4/
>
> Here is the 'guts' of the view: [4] http://dpaste.org/w0b2z/
>
> Total Postgresql/SQL n00b, so this may be a stupid statement. I'm wondering
> if an index on '"press_page"."article_id"' wouldn't speed things up a bit?

Are you using the django-debug-toolbar? If not, consider using it -
once installed, visit that page in your browser, open up the toolbar,
select SQL queries, find the offending query (processing times are
shown), and click the Explain link. That will tell you what PostgreSQL
is doing, and how performance can be improved.

Alternately, fire up a terminal and launch the psql database shell.
Type in the query ([2]) but prefix it with the word EXPLAIN. This will
tell you what PostgreSQL is doing to process that query. If you see
Seq Scan in there, consider adding the index. Remember to run the SQL
statement - ANALYZE press_page - after you create the index so it can
update the internal statistics that it uses to decide how to process a
query.

You can also do this within the PGadmin application if that makes things easier.

> In dev, I don't have the amount of data that exists in production, so I
> can't easily/realistically recreate this scenario.

You really need to have a good subset (considering both the number of
records, and the distribution of values within each record) if it is
not possible to have a copy of the production database. PostgreSQL
performs analysis on the data itself and uses those statistics to
decide how to process the query (whether to use an index, scan
sequentially etc.). If you dev database is not a good representation,
then the results you'll see with your dev database, and hence your
improvements, may have no effect or a negative effect in production.

I do believe having an index on press_page.article_id is a good idea
though. Also, are you really showing every article in that view?
Consider using a limit so you're not retrieving all the records, only
to use the first 10. The pagination features in Django may be useful
here. Finally, an index on press_page.pgnumber may also be worth
considering so PostgreSQL may be able to avoid the sorting step (an
index of the default type is sorted by the field in ascending order).

> FWIW, I'm running:
>
> Django 12.04
> Postgresql 9.1.5
> Django 1.4.1
>
> I'm using memcache on the view to cache it, it helped take page load down
> significantly, but I was wondering if there wasn't something I could do from
> the DB side of things since I know it's this query that is taking the page
> so long to load.
>
> Thanks!
>
> --
> 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/-/U92OjnMgEggJ.
> 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.



  1   2   3   4   >