pagination of a specific context in multiple context in ListView not working in django?

2020-06-01 Thread Ali Ahammad
in django, i am trying to list some queries of several objects like user lists, 
categoies and Post list. the homepage will be contained couple of blocks or 
boxes. each box will have different query list like Post list, User List, 
category list. But only one context will have pagination and other won't and 
ofcourse the pagination will be working on Post list.

here is the views.py:

class BlogappListView(ListView):
model = Category,CustomUser
template_name = 'home.html'
context_object_name='category_list'
queryset=Category.objects.all()
paginate_by = 2

def get_context_data(self, **kwargs):
context = super(BlogappListView, self).get_context_data(**kwargs)
context['user_list']= CustomUser.objects.all()
context['post_list']=Post.objects.all()
activities=context['post_list']
return context
def get_related_activities(self,activities):
queryset=self.objects.activity_rel.all()
paginator=Paginator(queryset,2)
page=self.request.GET.get('page')
activities=paginator.get_page(page)
return(activities)
in urls.py:

urlpatterns = [
path('',BlogappListView.as_view(),name='home'),
]
in base.html, the paginate portion code:

  
  {% if is_paginated %}

{% if page_obj.has_previous %}
  
First
  
  
  Previous

{% endif %}

{% for num in page_obj.paginator.page_range %}
  {% if page_obj.number == num %}
  
{{ num 
}}
  

  {% elif num > page_obj.number|add:'-3' and num < 
page_obj.number|add:'3' %}
  
{{ num 
}}


  {% endif %}
{% endfor %}

{% if page_obj.has_next %}

  Next

  
  Last


{% endif %}

  {% endif %}

the main problem is that page number 1 is showing all the posts and also the 
second page. and category list is also truncated into 2 but the user list ok.

so how can i make it work ? is there any other way?

thank you in advance

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/695c35d0-4841-4aaf-9080-7817cbe27fa9%40googlegroups.com.


Re: Need Dashboard in Django Admin only

2020-06-01 Thread Balaji Shetty
Thank you very much for your reply and support.

I will definitely follow it.

Yes

I ma trying to help Government for Covid 19 Dashboard.


On Sunday, May 31, 2020, Derek  wrote:

> There are numerous ways to design a front-end dashboard; this a highly
> contested domain on the web!
>
> Just some examples, using Django + various other tech are:
>
> * https://www.highcharts.com/blog/tutorials/create-a-
> dashboard-using-highcharts-and-django/
> * https://dreisbach.us/articles/building-dashboards-with-django-and-d3/
> * https://morioh.com/p/88d6fc714f52
>
> I suggest you look at delivering data from the back end (your Django
> models) with Django REST Framer (rather than hand-coded JSON); its takes a
> bit of work to setup but its the most flexible going forward in terms of
> future needs. e.g.
> * https://medium.com/swlh/build-your-first-rest-api-
> with-django-rest-framework-e394e39a482c
>
> P.S. Looks like you  are trying to support work for COVID-19 - all the
> best with that!
>
>
> On Saturday, 30 May 2020 17:08:23 UTC+2, Balaji wrote:
>>
>> Hi
>>
>>
>> If I want to generate such Dashboard in Djano Admin only
>>
>> Can anyone suggest pypi package..
>>
>> Any Sample code is available on git.
>>
>> 2 situation
>>
>> 1. Only for 1 model
>>
>> 2 For 2 model connected by Foreign Key relationships
>>
>>
>>
>>
>> --
>> Mr Shetty Balaji
>> Asst. Prof.
>> IT Department
>> SGGS I
>> Nanded. My. India
>>
>> --
> You received this message because you are 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/8415ab3f-f1da-4380-b29e-499a1fc9a803%40googlegroups.com
> 
> .
>


-- 
Mr Shetty Balaji
Asst. Prof.
IT Department
SGGS I
Nanded. My. India

-- 
You received this message because you are 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/CAECSbOtkHT5yaz3edzjzB_EVLs9V64K-%3DmFesspWXDJg8T5%3DBw%40mail.gmail.com.


Re: Please help me out!!

2020-06-01 Thread Kasper Laudrup

Hi Meer,a

On 01/06/2020 19.50, meera gangani wrote:

I want to mark the attendance of all the employee
So , my I’m working on hr management system .
And we have to mark the attendance of all the employee
So, we thought something new we can implement

So we find a way
1. to using MAC address otherwise IP address
2. Employee comes in building he can login into the system and click on 
the check-in button ( using longitude and latitude we find a office 
premises and then we can apply API key )


So which api key I can use?
And how to solve this problem?



You can't. However you try to implement that will be extremely 
unreliable and the client can spoof it anyway if they choose to do that.


Make the client login/employee check-in and out with some normal 
authentication mechanism. It's much easier so need to waste a lot of 
time trying to implement something that will never work anyway.


If you want to make some kind of tracking/surveillance system I'm sure 
you can do that but this is not the way to go.


Kind regards,

Kasper Laudrup

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/90c33527-fea2-a7f6-d146-20ab332620b2%40stacktrace.dk.


Please help me out!!

2020-06-01 Thread meera gangani
I want to mark the attendance of all the employee
So , my I’m working on hr management system .
And we have to mark the attendance of all the employee
So, we thought something new we can implement

So we find a way
1. to using MAC address otherwise IP address
2. Employee comes in building he can login into the system and click on the
check-in button ( using longitude and latitude we find a office premises
and then we can apply API key )

So which api key I can use?
And how to solve this problem?


Thanks in advance
-Meera

-- 
You received this message because you are 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/CANaPPPJnkcNhBK23VkrXBAM7hqU%2ByEGtQ9r6nZCGOKtbsuhfKw%40mail.gmail.com.


Re: Issue with serving angular with django

2020-06-01 Thread Andréas Kühne
Hi Sunday,

No - you don't. What collectstatic does is it collects all of the static
files to the path where they should be stored. This should be a directory
that should be served from nginx or apache or any other webserver. When you
run manage.py runserver - you run a development server that isn't geared
for production. And that is what is serving the files when "DEBUG" is set
to True.

To make it work like you want it to:
1. Install a webserver that can serve the static files.
2. Install gunicorn, uwsgi or some other wsgi server to serve the django
application.

When you have that working you will be able to look at your custom error
pages and so on.

There are many good tutorials on howto set this up - I usually look at
digitalocean - check here for example:

https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04

You can also look at the official django docs for explaining how to run
production loads:
https://docs.djangoproject.com/en/3.0/ref/django-admin/#runserver
https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/

When you get this working - serving the static files from a webserver isn't
that hard.

Regards,

Andréas


Den mån 1 juni 2020 kl 16:18 skrev Sunday Iyanu Ajayi :

> Hi Kasper,
>
> Thanks for the response.
> I serve my static file by running python manage.py collectstatic on the
> built file I get from the frontend angular guy
> *AJAYI Sunday *
> (+234) 806 771 5394
> *sunnexaj...@gmail.com *
>
>
>
> On Mon, Jun 1, 2020 at 2:55 PM Kasper Laudrup 
> wrote:
>
>> Hi Sunday,
>>
>> On 01/06/2020 15.48, Sunday Iyanu Ajayi wrote:
>> >
>> > Please What am I doing wrong? Or are there better ways of serving
>> > angular build files on django?
>> >
>>
>> You haven't described how you are currently serving static files with
>> Django. I suggest you start by reading this:
>>
>> https://docs.djangoproject.com/en/3.0/howto/static-files/deployment/
>>
>> You definitely shouldn't use DEBUG in production and you definitely
>> should serve static files with your web server of choice.
>>
>> Kind regards,
>>
>> Kasper Laudrup
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/12912d74-160c-547a-5cb5-0275432e751d%40stacktrace.dk
>> .
>>
> --
> You received this message because you are 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/CAKYSAw3vLNZ5RDLav-WuUO1kH4rn%3DF%3DcDLFdteK%2BM_4d9rR9HA%40mail.gmail.com
> 
> .
>

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


Re: django debug settings

2020-06-01 Thread Akinfolarin Stephen


On Tuesday, June 2, 2020 at 6:51:33 AM UTC+14, Alba wrote:
>
> I need to change the settings to debug = false but  when I enter 
> *server_name* 
> .
> webfaction.com, I  get an error "server IP address could not be found." 
> How can I solve this?
>
can i see your settings.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c698c773-c18d-4b28-a871-72ca3f885520%40googlegroups.com.


Re: django debug settings

2020-06-01 Thread Akinfolarin Stephen
can i see your settings.py


On Tue, Jun 2, 2020 at 6:51 AM Alba  wrote:

> I need to change the settings to debug = false but  when I enter
> *server_name*
> .
> webfaction.com, I  get an error "server IP address could not be found."
> How can I solve this?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f2b75f58-e769-4277-b84d-974474d005c4%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/CAFujGLy_x-KJ%3DegLL9r9w5_Q5YF9wFjhXhL-orzQYC3eU8m3qA%40mail.gmail.com.


Re: Django Pagination

2020-06-01 Thread maninder singh Kumar
I think there might be a way around, below is the code modified for views.py

@login_required
def home_view(request):
"""Display all the post of friends and own posts on the dashboard"""
posts = Post.objects.order_by('-date_posted')
media: MEDIA_URL
# 'post':Post.objects.filter(Q(author=request.user) |
Q(author__from_user=request.user) |
Q(author__to_user=request.user)).order_by('-date_posted'),
paginator = Paginator(posts, 2)
page_number = request.GET.get('page')
try:
page_obj = paginator.page('page')
except PageNotAnInteger:
page_obj = paginator.page(1)
except EmptyPage:
page_obj = paginator.page(paginator.num_pages)
return render(request, 'post/home.html',{'page_obj': page_obj})

I think this might work !

regards
willy


On Mon, Jun 1, 2020 at 7:48 PM Akshat Zala  wrote:

> Dear Sir,
>
> it shows all the text on all the pages.
>
> if there are total 5 posts, then it  shows all the 5 posts on all the
> pages.
>
> Thanks,
>
> Akshat Zala
>
> On Saturday, 30 May 2020 20:54:35 UTC+5:30, maninder singh Kumar wrote:
>>
>> Views.py looks fine !
>>
>> regards
>> willy
>>
>>
>> On Sat, May 30, 2020 at 7:22 PM Akshat Zala  wrote:
>>
>>> Hello,
>>>
>>> I am finding it difficult to paginate through all the posts
>>>
>>> My views.py :
>>>
>>> @login_required
>>> def home_view(request):
>>> """Display all the post of friends and own posts on the dashboard"""
>>> posts = Post.objects.all().order_by('-date_posted')
>>> media: MEDIA_URL
>>> # 'post':Post.objects.filter(Q(author=request.user) |
>>> Q(author__from_user=request.user) |
>>> Q(author__to_user=request.user)).order_by('-date_posted'),
>>> paginator = Paginator(posts, 2)
>>> page_number = request.GET.get('page')
>>> page_obj = paginator.get_page(page_number)
>>> return render(request, 'post/home.html',{'page_obj': page_obj})
>>>
>>>
>>> and in template post/home.html:
>>>
>>> {% if is_paginated %}
>>> {% if page_obj.has_previous %}
>>> First
>>> arrow_left
>>> 
>>> {% endif %}
>>> {% for num in page_obj.paginator.page_range %}
>>> {% if page_obj.number == num %}
>>> {{ num }}
>>> {% elif num > page_obj.number|add:'-4' and num < page_obj.number|add:'4'
>>> %}
>>> {{ num }}
>>> 
>>> {% endif %}
>>> {% endfor %}
>>> {% if page_obj.has_next %}
>>> arrow_right
>>> Last
>>> {% endif %}
>>>
>>>
>>> Thanks
>>>
>>> Akshat Zala
>>>
>>> --
>>> You received this message because you are 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/87c3f0db-3088-448c-b3c7-14450e8c2f5d%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/c775d687-0773-4d09-86be-35e6f2cd55d2%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/CABOHK3T5A8JT%2BOe-Tt%3DAw4ZOff%2BwVWXO4EXMbkKtTUz2Y2spZg%40mail.gmail.com.


Multiple checkboxes are not working,it is showing selected choice isn't a valid choice.

2020-06-01 Thread learn code
Hello,
I'm working on a application form it has multiple checkboxes,when I submit 
the form it is showing selected choice isn't a valid choice.
If anyone knows how to use checkboxes in ModelForm plz help me.

Models.py
class Application(models.Model):
STATE_CHOICES =( 
("1","Alabama"),("2","Alaska"),("3","Arizona"),("4","Arkansas"),("5",
"California"),("6","Colorado"),
("7","Connecticut"),("8","Delaware"),("9","Florida"),("10","Georgia"),(
"11","Hawaii"),("12","Idaho"),
("13","Illinois"),("14","Indiana"),("15","Iowa"),("16","Kansas"),("17",
"Kentucky"),("18","Louisiana"),
("19","Maine"),("20","Maryland"),("21","Massachusetts"),("22","Michigan"
),("23","Minnesota"),("24","Mississippi"),
("25","Missouri"),("26","Montana"),("27","Nebraska"),("28","Nevada"),(
"29","New Hampshire"),("30","New Jersey"),
("31","New Mexico"),("32","New York"),("33","North Carolina"),("34",
"North Dakota"),("35","Ohio"),
("36","Oklahoma"),("37","Oregon"),("38","Pennsylvania"),("39",
"Rhode Island"),("40","South Carolina"),
("41","South Dakota"),("42","Tennessee"),("43","Texas"),("44","Utah"),(
"45","Vermont"),("46","Virginia"),
("47","Washington"),("48","West Virginia"),("49","Wisconsin"),("50",
"Wyoming"),
) 

GENDER_CHOICES=(
 ('male','Male'),
 ('female','Female'),
)
k=(
('yes','Yes'),
('no','No'),
)
degree=(
('yes','Yes'),
('no','No'),
)
classroom=(
('yes','Yes'),
('no','No'),
)
genres1=(
   ('classical','Classical'),
   ('rock','Rock'),
   ('musical Theater','Musical Theater'),
   ('country','country'),
   ('blues','Blues'),
   ('christian Contemporary','Christian Contemporary'),
   ('gospel','Gospel'),
   ('other','Other'),
)

languages1=(
('english','English'),
('spanish','Spanish'),
('german','German'),
('chinese','Chinese'),
('hindi','Hindi'),
('french','French'),
('russian','Russian'),
('turkish','Turkish'),
)
firstname=models.CharField(max_length=50)
lastname=models.CharField(max_length=50)
Email=models.EmailField()
phonenumber=models.CharField(max_length=15)
password = models.CharField(max_length=100)
confirm_password=models.CharField(max_length=100)
address1 = models.CharField(max_length=100)
address2 = models.CharField(max_length=100)
state = models.CharField(max_length=100,choices=STATE_CHOICES)
city = models.CharField(max_length=100)
zipcode=models.CharField(max_length=15)
DOB=models.DateField()
Gender=models.CharField(max_length=50,choices=GENDER_CHOICES)
k=models.CharField(max_length=50,choices=k)
degree=models.CharField(max_length=50,choices=degree)
classroom=models.CharField(max_length=50,choices=classroom)
genres=models.CharField(max_length=50, choices=genres1)
languages=models.CharField(max_length=50, choices=languages1)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
application_field = models.SlugField(max_length = 200)


def __str__(self):
return self.firstname



..

Views.py
from django.shortcuts import render,redirect, get_object_or_404
from onlinetutors.models import Category,tutors
from .forms import application
from .models import Application

Create your views here.

def registration(request):
if request.method == 'POST':
form=application(request.POST)
if form.is_valid():
form.save()
print("Hello")
firstname=form.cleaned_data['firstname']

lastname=form.cleaned_data['lastname']
Email=form.cleaned_data['Email']
phonenumber=form.cleaned_data['phonenumber']
password = form.cleaned_data['password']
confirm_password=form.cleaned_data['confirm_password']
address1 = form.cleaned_data['address1']
address2 = form.cleaned_data['address2']
state = form.cleaned_data['state']
city =form.cleaned_data['city']
zipcode=form.cleaned_data['zipcode']
DOB=form.cleaned_data['DOB']
Gender=form.cleaned_data['Gender']
k=form.cleaned_data['k']
degree=form.cleaned_data['degree']
classroom=form.cleaned_data['classroom']
genres=form.cleaned_data['genres']
languages=form.cleaned_data['languages']
form=Application(firstname=firstname,lastname=lastname,Email
= Email,phonenumber=phonenumber,
password=password,address1=address1,address2=address2, state
= state,city=city,zipcode=zipcode,
DOB=DOB,Gender=Gender,k=k,degree=degree,classroom=classroom,
languages=languages,genres=genres)
   
form.save()
return redirect("/thankyou/")
else:
form=application()
return render(request,"registration.html",{"form":form})


django debug settings

2020-06-01 Thread Alba
I need to change the settings to debug = false but  when I enter 
*server_name* 
.webfaction.com,
 
I  get an error "server IP address could not be found." How can I solve 
this?

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


Re: Can you please help me

2020-06-01 Thread Ayush Gupta
On Mon, Jun 1, 2020, 7:02 PM Ogunsanya Opeyemi 
wrote:

> How do i upload images using pillow in django and my database engine is
> mysql. I am trying to view my uploaded image but i can't find 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c828130d-009c-447a-a9ae-c2d49da15ae0%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/CAEp4O7V8co_C220waPQ2UJ3HP0bPC42jHDm1A8mTkAsppQ3V3g%40mail.gmail.com.


Re: Issue with serving angular with django

2020-06-01 Thread Sunday Iyanu Ajayi
Hi Kasper,

Thanks for the response.
I serve my static file by running python manage.py collectstatic on the
built file I get from the frontend angular guy
*AJAYI Sunday *
(+234) 806 771 5394
*sunnexaj...@gmail.com *



On Mon, Jun 1, 2020 at 2:55 PM Kasper Laudrup  wrote:

> Hi Sunday,
>
> On 01/06/2020 15.48, Sunday Iyanu Ajayi wrote:
> >
> > Please What am I doing wrong? Or are there better ways of serving
> > angular build files on django?
> >
>
> You haven't described how you are currently serving static files with
> Django. I suggest you start by reading this:
>
> https://docs.djangoproject.com/en/3.0/howto/static-files/deployment/
>
> You definitely shouldn't use DEBUG in production and you definitely
> should serve static files with your web server of choice.
>
> Kind regards,
>
> Kasper Laudrup
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/12912d74-160c-547a-5cb5-0275432e751d%40stacktrace.dk
> .
>

-- 
You received this message because you are 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/CAKYSAw3vLNZ5RDLav-WuUO1kH4rn%3DF%3DcDLFdteK%2BM_4d9rR9HA%40mail.gmail.com.


Re: Django Pagination

2020-06-01 Thread Akshat Zala
Dear Sir,

it shows all the text on all the pages.

if there are total 5 posts, then it  shows all the 5 posts on all the pages.

Thanks,

Akshat Zala

On Saturday, 30 May 2020 20:54:35 UTC+5:30, maninder singh Kumar wrote:
>
> Views.py looks fine !
>
> regards
> willy
>
>
> On Sat, May 30, 2020 at 7:22 PM Akshat Zala  > wrote:
>
>> Hello,
>>
>> I am finding it difficult to paginate through all the posts
>>
>> My views.py :
>>
>> @login_required
>> def home_view(request):
>> """Display all the post of friends and own posts on the dashboard"""
>> posts = Post.objects.all().order_by('-date_posted')
>> media: MEDIA_URL
>> # 'post':Post.objects.filter(Q(author=request.user) | 
>> Q(author__from_user=request.user) | 
>> Q(author__to_user=request.user)).order_by('-date_posted'),
>> paginator = Paginator(posts, 2) 
>> page_number = request.GET.get('page')
>> page_obj = paginator.get_page(page_number)
>> return render(request, 'post/home.html',{'page_obj': page_obj})
>>
>>
>> and in template post/home.html:
>>
>> {% if is_paginated %}
>> {% if page_obj.has_previous %}
>> First
>> arrow_left
>> 
>> {% endif %}
>> {% for num in page_obj.paginator.page_range %}
>> {% if page_obj.number == num %}
>> {{ num }}
>> {% elif num > page_obj.number|add:'-4' and num < page_obj.number|add:'4' 
>> %}
>> {{ num }}
>> {% endif %}
>> {% endfor %}
>> {% if page_obj.has_next %}
>> arrow_right
>> Last
>> {% endif %}
>>
>>
>> Thanks
>>
>> Akshat Zala
>>
>> -- 
>> You received this message because you are 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/87c3f0db-3088-448c-b3c7-14450e8c2f5d%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/c775d687-0773-4d09-86be-35e6f2cd55d2%40googlegroups.com.


Re: Issue with serving angular with django

2020-06-01 Thread Chetan Ganji
You should use nginx to serve angular n static files and gunicorn for python

Below tuts might help you.

https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04

Look for a tutorial without docker.
https://medium.com/bb-tutorials-and-thoughts/how-to-serve-angular-application-with-nginx-and-docker-3af45be5b854


On Mon, Jun 1, 2020, 7:25 PM Kasper Laudrup  wrote:

> Hi Sunday,
>
> On 01/06/2020 15.48, Sunday Iyanu Ajayi wrote:
> >
> > Please What am I doing wrong? Or are there better ways of serving
> > angular build files on django?
> >
>
> You haven't described how you are currently serving static files with
> Django. I suggest you start by reading this:
>
> https://docs.djangoproject.com/en/3.0/howto/static-files/deployment/
>
> You definitely shouldn't use DEBUG in production and you definitely
> should serve static files with your web server of choice.
>
> Kind regards,
>
> Kasper Laudrup
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/12912d74-160c-547a-5cb5-0275432e751d%40stacktrace.dk
> .
>

-- 
You received this message because you are 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/CAMKMUju7Sjt7Hn2qvJQrZCUKbCJ-83RBFMpkZ7s6gjsZNnuPDg%40mail.gmail.com.


Re: Can you please help me

2020-06-01 Thread Kasper Laudrup

Hi Ogunsanya,

On 01/06/2020 15.30, Ogunsanya Opeyemi wrote:
How do i upload images using pillow in django and my database engine is 
mysql. I am trying to view my uploaded image but i can't find it.




This might be relevant:

https://www.geeksforgeeks.org/python-uploading-images-in-django/

But of course, without knowing what you have done or seen any of your 
code it is very hard to help you.


Kind regards,

Kasper Laudrup


--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to django-users+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c828130d-009c-447a-a9ae-c2d49da15ae0%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/cb1b7c41-5547-09ec-8752-5759d76dcac7%40stacktrace.dk.


Re: Issue with serving angular with django

2020-06-01 Thread Kasper Laudrup

Hi Sunday,

On 01/06/2020 15.48, Sunday Iyanu Ajayi wrote:


Please What am I doing wrong? Or are there better ways of serving 
angular build files on django?




You haven't described how you are currently serving static files with 
Django. I suggest you start by reading this:


https://docs.djangoproject.com/en/3.0/howto/static-files/deployment/

You definitely shouldn't use DEBUG in production and you definitely 
should serve static files with your web server of choice.


Kind regards,

Kasper Laudrup

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/12912d74-160c-547a-5cb5-0275432e751d%40stacktrace.dk.


Issue with serving angular with django

2020-06-01 Thread Sunday Iyanu Ajayi
Hi guys,

I am working on a project which is made up of an angular and a django part.

- The frontend dev develops the frontend, makes a build and forwards to me

- I get the build and serve it using python manage.py collectstatic

But my challenge is that
 1. It only works when debug is set to True
 2. If debug is set to True, I am unable to set or customize my  error
pages ( it shows django error messages with some vital information that
makes my site vulnerable.

Please What am I doing wrong? Or are there better ways of serving angular
build files on django?

Thank you.

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

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


Can you please help me

2020-06-01 Thread Ogunsanya Opeyemi
How do i upload images using pillow in django and my database engine is 
mysql. I am trying to view my uploaded image but i can't find 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c828130d-009c-447a-a9ae-c2d49da15ae0%40googlegroups.com.


Payment methods

2020-06-01 Thread muazzem_ hossain
How to add few payment methods to django-oscar 

.

-- 
You received this message because you are 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/2e19467c-94e0-44ae-9b5f-035cab1f808b%40googlegroups.com.