how i set pagination's in django templates

2018-06-14 Thread arvind yadav
hello 
 I want set pagination in Django templates
my data format is directory 
dict = {'a': 123, 'b': 12,'c': 123, 'd': 12,'e': 123, 'f': 12,'g': 123, 
'h': 12,'i': 123, 'j': 12,'k': 123, 'l': 12,'m': 123, 'n': 12,'o': 123, 
'p': 12,}
i want only 5 key value in one 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 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/14ef4db8-ca4d-4354-b64b-cdc4c3f72fc3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Different behavior in ListVIew Vs CreateView (class based views )

2018-06-14 Thread kanishk tanwar


class SchoolListView(ListView):
template_name = 'app/List.html'
context_object_name = 'schools'
model = models.School


# i have this first class here i don't need to define attribute like


# ListView.model and ListView.template_name etc


# But---> in CreateView its a totally different story


class SchoolCreateView(CreateView):
model = models.School
fields = ['name', 'principal', 'location']
template_name = 'app/Form.html'


# here if i omit CreateView.model or CreateView.fiels or 
createView.template_name

# i got an exception which states Imporperly configured CreateView missing 
query set

# i am learning class base views from a tutorial and he is using django version 
1.10.5

# and his code works fine without using CreateView is that the issue??

# or i am doing some bad stuff kindly help

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


Re: how i set pagination's in django templates

2018-06-14 Thread Jason
https://simpleisbetterthancomplex.com/tutorial/2016/08/03/how-to-paginate-with-django.html


On Thursday, June 14, 2018 at 3:19:11 AM UTC-4, arvind yadav wrote:
>
> hello 
>  I want set pagination in Django templates
> my data format is directory 
> dict = {'a': 123, 'b': 12,'c': 123, 'd': 12,'e': 123, 'f': 12,'g': 123, 
> 'h': 12,'i': 123, 'j': 12,'k': 123, 'l': 12,'m': 123, 'n': 12,'o': 123, 
> 'p': 12,}
> i want only 5 key value in one 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 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/d81484c4-1c94-4f33-a07d-3362b95d07b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: button not responding when click but when press return key than works

2018-06-14 Thread kanishk tanwar
Yea t is missing i suggest use atom it has nice auto completion for the tags :D

-- 
You received this message because you are subscribed 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/fc6ea4ad-c16b-4584-9de4-41916f92d463%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: button not responding when click but when press return key than works

2018-06-14 Thread Asif Khan
Hi Fidel. thanks to notice such a minute mistake which I did not. Yes it is 
working now.

On Thursday, June 14, 2018 at 10:53:22 AM UTC+5, Fidel Leon wrote:
>
> If I remember correctly, the correct tag for a button is [obviously] 
> , no  (please see the missing T).
>
> El jue., 14 jun. 2018 a las 0:14, Asif Khan ( >) escribió:
>
>> No I am not using JS capturing for any kind of actions. where as my other 
>> form button are working.
>>
>> On Thursday, June 14, 2018 at 2:14:48 AM UTC+5, Asif Khan wrote:
>>>
>>> I am having amazing problem in my django template. Button does not 
>>> respond on pressing click on it. It works when I press return key. code is 
>>> following. 
>>> {% extends 'vtapp/baseapp_layout.html' %}
>>>
>>> {% block head %}
>>> Vehicle Vegilince - Customer Search
>>> {% endblock %}
>>>
>>> {% block content %}
>>> Enter Customer information
>>> 
>>> {% csrf_token %}
>>> 
>>> 
>>> 
>>>  
>>> 
>>> Search
>>> 
>>> 
>>> 
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/5f518cba-fcdc-4b2a-9f75-fad87b0e3cd0%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> -- 
> Fidel Leon
> fi...@flm.cat 
> Phone: +34 622 26 44 92
>

-- 
You received this message because you are subscribed 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/6465fda1-1cf0-4370-8074-ae24c0202370%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to include a Where clause for each query on django?

2018-06-14 Thread Fellipe Henrique
Hello..


Each model of my app, has a field named  user... so, I need to filter any
query on that model user=current_user...

I already do that, but manually for each model, on a view.. and I like to
do that directly on some where when I try to use a query, any record will
be filtered.


Can I do that? where is the best place to do that?

Thanks!

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


RE: How to include a Where clause for each query on django?

2018-06-14 Thread Matthew Pava
Just create a custom manager and pass in the current user to it.
https://docs.djangoproject.com/en/2.0/topics/db/managers/

class MyCustomManager(models.Manager):
def with_current_user(current_user):
return self.filter(user=current_user)

In y our model:

class MyModel:
objects = MyCustomerManager()

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Fellipe Henrique
Sent: Thursday, June 14, 2018 9:09 AM
To: Django Users
Subject: How to include a Where clause for each query on django?

Hello..


Each model of my app, has a field named  user... so, I need to filter any query 
on that model user=current_user...

I already do that, but manually for each model, on a view.. and I like to do 
that directly on some where when I try to use a query, any record will be 
filtered.


Can I do that? where is the best place to do that?

Thanks!


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

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


Best way to make send email (email template with dynamic value)

2018-06-14 Thread lakshitha kumara
Hello Guys 

I would like to know best way to send email on django 2. email should have 
email template and dynamic value.

EmailMultiAlternatives or send_mail

And appreciate if good sample 


Thanks

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


A newbie server error occured

2018-06-14 Thread Piotr Trybowski
So I'm following the tutorial 
from: https://docs.djangoproject.com/en/2.1/intro/tutorial02/ and I'm stuck 
at opening the admin site.
When i run command runserver i get no error and prompt: 

"C:\Program Files\JetBrains\PyCharm 2018.1.4\bin\runnerw.exe" 
C:\Users\Username\Downloads\WinPython-64bit-3.6.2.0Qt5\python-3.6.2.amd64\python.exe
 
"C:\Program Files\JetBrains\PyCharm 
2018.1.4\helpers\pycharm\django_manage.py" runserver 
C:/Users/Username/PycharmProjects/strona2
Tracking file by folder pattern: migrations
Performing system checks...

System check identified no issues (0 silenced).
June 14, 2018 - 18:27:17
Django version 2.0.6, using settings 'strona2.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.


So everything should work propperly, but when I open the 
http://127.0.0.1:8000/admin/ i get this error:
A server error occured. Please contact the administrator.

I have tried migrating again, I have tried using different port. The 
/polls/ section works. I asked everywhere and i'm out of ideas. Thanks for 
your help.

As stated in prompt above I'm using Django 2.0.6 and python 3.6.2. Also I'm 
on windows and running everything through Pycharm. No problems up to this 
point

-- 
You received this message because you are subscribed 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/99670c95-c396-4e71-a7c6-ce904dd59d06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Problem with Twitter authetication

2018-06-14 Thread Cris Martinez
Hi:

I had a problem two days ago, I buid a web site that can authenticate with 
twitter. I'm using Django 1.8 and all worked very well, but now it crashed 
with  403 Client Error: Forbidden for url: 
https://api.twitter.com/oauth/request_token  and I don know why. I already 
changed all tokens and restart the twitter app. I have anothers codes that 
work with twitter and they still work. I suppose that is and internal error 
twitter, could someone help me?

-- 
You received this message because you are subscribed 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/ffe9ce90-417c-4952-864a-497e5b6822f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: A newbie server error occured

2018-06-14 Thread Artur Gontijo
Hi,

Did you check if you have the admin app listed in the setings.py?
INSTALLED_APPS = [
'django.contrib.admin',
'more_apps',
]

And what about your url.py? Does it have the /admin routing?
path('admin/', admin.site.urls),

On Thursday, June 14, 2018 at 2:28:41 PM UTC-3, Piotr Trybowski wrote:
>
> So I'm following the tutorial from: 
> https://docs.djangoproject.com/en/2.1/intro/tutorial02/ and I'm stuck at 
> opening the admin site.
> When i run command runserver i get no error and prompt: 
>
> "C:\Program Files\JetBrains\PyCharm 2018.1.4\bin\runnerw.exe" 
> C:\Users\Username\Downloads\WinPython-64bit-3.6.2.0Qt5\python-3.6.2.amd64\python.exe
>  
> "C:\Program Files\JetBrains\PyCharm 
> 2018.1.4\helpers\pycharm\django_manage.py" runserver 
> C:/Users/Username/PycharmProjects/strona2
> Tracking file by folder pattern: migrations
> Performing system checks...
>
> System check identified no issues (0 silenced).
> June 14, 2018 - 18:27:17
> Django version 2.0.6, using settings 'strona2.settings'
> Starting development server at http://127.0.0.1:8000/
> Quit the server with CTRL-BREAK.
>
>
> So everything should work propperly, but when I open the 
> http://127.0.0.1:8000/admin/ i get this error:
> A server error occured. Please contact the administrator.
>
> I have tried migrating again, I have tried using different port. The 
> /polls/ section works. I asked everywhere and i'm out of ideas. Thanks for 
> your help.
>
> As stated in prompt above I'm using Django 2.0.6 and python 3.6.2. Also 
> I'm on windows and running everything through Pycharm. No problems up to 
> this point
>

-- 
You received this message because you are subscribed 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/c0a73843-0527-4378-9826-4633879990d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Problems with list_filter and date_hierarchy in django2.05

2018-06-14 Thread Mark Phillips
I have two related models, Document and DocumentMetaData, and two separate
ModelAdmins (DocumentAdmin, DocumentMetaDataAdmin) where I can't seem to
get list_filter or date_hierarchy to work. All the other aspects of the
admins work.

When I say list_filter or date_hierarchy don't work, I mean they display
the right data on the admin page (filters on the right, date breadcrumbs on
the top), but when I select either a filter or a date in the date hierarchy
(the drill down works properly), they don't change the list of items in the
admin page. They don't do the filtering part of their job, they just look
pretty on the admin page. ;)

I am not sure how to debug this, as there are no error messages on the
console. How would you suggest I debug this?

Thanks!

Mark

class Document(Model):
document_id = models.AutoField(primary_key=True)

# Document states
PRIVATE = 1
PENDING = 200
PUBLISHED = 300
DOCUMENT_STATE = (
(PRIVATE, 'private'),
(PENDING, 'pending'),
(PUBLISHED, 'published'),
)
document_state = models.IntegerField(choices=DOCUMENT_STATE,
default=PRIVATE, verbose_name="state")

# Document types
documentType_id = models.ForeignKey(DocumentType,
on_delete=models.CASCADE, verbose_name="document type", )

# Document fields
#title = models.CharField('title', max_length=description)
#200 = models.TextField('description')
created = models.DateTimeField(editable=False, verbose_name="date
created")
updated = models.DateTimeField(editable=False, verbose_name="last
update")
storage_file_name = models.FileField('File name',
upload_to=unique_file_path)
thumb_storage = models.FileField(editable=False,)
original_file_name = models.CharField(editable=False, max_length=200)
computed_sha256 = models.CharField(editable=False, max_length=64)

.rest of code left out for sake of brevity..

class DocumentAdmin(admin.ModelAdmin):
form = DocumentForm
list_display = ('get_document_type', 'document_state', 'get_title',
'get_decade', 'original_file_name', 'created', 'storage_file_name',
'get_thumb', )
ordering = ('created',)
readonly_fields = ('get_thumb', )
search_fields = ('original_file_name',)
list_filter = ('updated', 'created', 'documentType_id',
'document_state', )
date_hierarchy = 'created'

.rest of code left out for sake of brevity..

class DocumentMetaData(Model):
documentMetaData_id = models.AutoField(primary_key=True)
document_id = models.ForeignKey(Document, on_delete=models.CASCADE,
verbose_name="document file name")
metadata = JSONField(blank=True)

.rest of code left out for sake of brevity..

class DocumentMetaDataAdmin(admin.ModelAdmin):
form = DocumentMetaDataForm
list_display = ('get_document_name', 'document_id', 'metadata',
'get_image_1',  )
#ordering = ('created',)
readonly_fields = ('get_document_name', 'get_image_1', 'get_image_2', )
search_fields = ('document_id__original_file_name',)
list_filter = ('document_id', )
ordering = ('document_id__created',)
date_hierarchy = 'document_id__created'

.rest of code left out for sake of brevity..

-- 
You received this message because you are subscribed 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/CAEqej2OP%3DFCyPj5DuLaM3SBMb_ShUEvMLUMNz%3DgmVJYcp7wzZQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problems with list_filter and date_hierarchy in django2.05

2018-06-14 Thread Mark Phillips
After some further investigation, the generated by the date_hierarchy for
the DocumentAdmin is, for example,
http://localhost:8098/admin/memorabilia/document/?created__day=25&created__month=5&created__year=2018.
There are documents with a created date of May 25, 2018. However, the
Document field created is a DateTime field, so the time is also part of the
field. I also have USE_TZ = True in settings.py, and I updated mysql to use
time zones as outlined in the django docs (
https://docs.djangoproject.com/en/2.0/ref/databases/#mysql-time-zone-definitions
and https://dev.mysql.com/doc/refman/8.0/en/mysql-tzinfo-to-sql.html).

I am not sure of the time zone issue is a red herring or not. Anyone have a
suggestion on how to debug the problem?

Thanks!

Mark

On Thu, Jun 14, 2018 at 2:02 PM, Mark Phillips 
wrote:

> I have two related models, Document and DocumentMetaData, and two separate
> ModelAdmins (DocumentAdmin, DocumentMetaDataAdmin) where I can't seem to
> get list_filter or date_hierarchy to work. All the other aspects of the
> admins work.
>
> When I say list_filter or date_hierarchy don't work, I mean they display
> the right data on the admin page (filters on the right, date breadcrumbs on
> the top), but when I select either a filter or a date in the date hierarchy
> (the drill down works properly), they don't change the list of items in the
> admin page. They don't do the filtering part of their job, they just look
> pretty on the admin page. ;)
>
> I am not sure how to debug this, as there are no error messages on the
> console. How would you suggest I debug this?
>
> Thanks!
>
> Mark
>
> class Document(Model):
> document_id = models.AutoField(primary_key=True)
>
> # Document states
> PRIVATE = 1
> PENDING = 200
> PUBLISHED = 300
> DOCUMENT_STATE = (
> (PRIVATE, 'private'),
> (PENDING, 'pending'),
> (PUBLISHED, 'published'),
> )
> document_state = models.IntegerField(choices=DOCUMENT_STATE,
> default=PRIVATE, verbose_name="state")
>
> # Document types
> documentType_id = models.ForeignKey(DocumentType,
> on_delete=models.CASCADE, verbose_name="document type", )
>
> # Document fields
> #title = models.CharField('title', max_length=description)
> #200 = models.TextField('description')
> created = models.DateTimeField(editable=False, verbose_name="date
> created")
> updated = models.DateTimeField(editable=False, verbose_name="last
> update")
> storage_file_name = models.FileField('File name',
> upload_to=unique_file_path)
> thumb_storage = models.FileField(editable=False,)
> original_file_name = models.CharField(editable=False, max_length=200)
> computed_sha256 = models.CharField(editable=False, max_length=64)
>
> .rest of code left out for sake of brevity..
>
> class DocumentAdmin(admin.ModelAdmin):
> form = DocumentForm
> list_display = ('get_document_type', 'document_state', 'get_title',
> 'get_decade', 'original_file_name', 'created', 'storage_file_name',
> 'get_thumb', )
> ordering = ('created',)
> readonly_fields = ('get_thumb', )
> search_fields = ('original_file_name',)
> list_filter = ('updated', 'created', 'documentType_id',
> 'document_state', )
> date_hierarchy = 'created'
>
> .rest of code left out for sake of brevity..
>
> class DocumentMetaData(Model):
> documentMetaData_id = models.AutoField(primary_key=True)
> document_id = models.ForeignKey(Document, on_delete=models.CASCADE,
> verbose_name="document file name")
> metadata = JSONField(blank=True)
>
> .rest of code left out for sake of brevity..
>
> class DocumentMetaDataAdmin(admin.ModelAdmin):
> form = DocumentMetaDataForm
> list_display = ('get_document_name', 'document_id', 'metadata',
> 'get_image_1',  )
> #ordering = ('created',)
> readonly_fields = ('get_document_name', 'get_image_1', 'get_image_2', )
> search_fields = ('document_id__original_file_name',)
> list_filter = ('document_id', )
> ordering = ('document_id__created',)
> date_hierarchy = 'document_id__created'
>
> .rest of code left out for sake of brevity..
>
>

-- 
You received this message because you are subscribed 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/CAEqej2PuN2GYd4hhaBR-bZ687NJZ8MFW6YT3ERfcd%3DdF%2BSR-4Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.