After uploading image is not displaying in production server.

2021-05-31 Thread Salima Begum
Hi all,
In my project after depl;oying into production server When i have uploaded
images it saves into media folder but not displaying image in template. As
well as when we go to the admin site and to display an image when I click
on the url of the image it is throwing an error like. url not found.

But in the media folder the image is saved and when I double click on that
image is opened. and when i upload an image from the admin site, the image
is displayed in a template.

Actually in development server uploading displaying images is working good.
After deploying into the production server I have this issue. Please help
me to solve this issue.

**settings.py**
```
# managing media
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
```

Project urls.py

```
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
```

Thanks
~Salima

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


Custom Text filter field in django admin site.

2021-05-31 Thread Ayush Bisht
# admin.py

class InputFilter(admin.SimpleListFilter):
template = 'patient/input_filter.html'

def lookups(self, request, model_admin):
# Dummy, required to show the filter.
return ((),)

class PatientProfilePastDataFilter(InputFilter):
parameter_name = 'patient'
title = _('Past Record')

def lookups(self, request, model_admin):
return ( (),)

def queryset(self, request, queryset):   
return queryset.filter(admitted_on__lte = request.GET.get("from") , 
admitted_on__gte  
 = request.GET.get("to")  )

# patient/input_filter.html
{% load i18n %} 

{% blocktrans with filter_title=title %} By {{ filter_title }} {% 
endblocktrans %}


{% with choices.0 as all_choice %}








filter
{% if not all_choice.selected %}
x {% trans 
'Remove' %}
{% endif %}


{% endwith %}



 # 
.


I want to add a custom text filter in django admin site... with 2 input 
fields. Is there a way to do this.. if so then please suggest me,  how can 
I add a custom text field in filter section.

Also, Thanks for the  respond on previous query... 

-- 
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/2dc28aa3-90d0-422f-8d9c-4b5f5b6fb7f6n%40googlegroups.com.


how to input list [] dynamic in python

2021-05-31 Thread paidjoo indo
hello i having question, because i still learn python for me, so can help
me
the question is

how about if input like in below
1 ) input: 3 , return [1, 2, 3]

2) input: 2, return [2, 4, 3]

3) input: 6, return [3, 6, 6, 4, 5, 6]

4) input: 1, return [4, 6, 6, 4, 5, 6]

5) input: 1, return [5, 6, 6, 4, 5, 6]

thanks in advance

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


Re: how to input list [] dynamic in python

2021-05-31 Thread paidjoo indo
how about if input like in below
1 ) input: 3 , return [1, 2, 3]
then continue dynamic
2) input: 2, return [2, 4, 3]
  then continue dynamic
3) input: 6, return [3, 6, 6, 4, 5, 6]
  then continue dynamic
4) input: 1, return [4, 6, 6, 4, 5, 6]
  then continue dynamic
5) input: 1, return [5, 6, 6, 4, 5, 6]

thanks


Pada tanggal Sen, 31 Mei 2021 pukul 18.20 paidjoo indo 
menulis:

> hello i having question, because i still learn python for me, so can help
> me
> the question is
>
> how about if input like in below
> 1 ) input: 3 , return [1, 2, 3]
>
> 2) input: 2, return [2, 4, 3]
>
> 3) input: 6, return [3, 6, 6, 4, 5, 6]
>
> 4) input: 1, return [4, 6, 6, 4, 5, 6]
>
> 5) input: 1, return [5, 6, 6, 4, 5, 6]
>
> thanks in advance
>

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


Re: PayPal Integration

2021-05-31 Thread Eric 247ERICPOINTCOM
Thank you Sharif, I have integrated successfully with paypal after going
through the paypal developer docs, and tested it with sandbox.paypal and it
is working great.

However I would like your help, to now be able to submit  the form
automatically after making the payment with paypal. I have tried adding
type="submit"  to the paypal button but that doesn't work.  How can I do
that?

*Kind Regards*

*Eric Bawakuno | Computer Engineer | +27795639700| +27 815152254
| eric...@gmail.com   | **Address**: 29 Rochester Road,
Observatory | Cape Town, South Africa | 7925*
f



On Wed, May 19, 2021 at 7:26 PM Eric 247ERICPOINTCOM 
wrote:

> Thank you Sharif. Let me do that, I will come back to the conversation
> after
>
> *Kind Regards*
>
> *Eric Bawakuno | Computer Engineer | +27795639700| +27 815152254
> | eric...@gmail.com   | **Address**: 29 Rochester
> Road, Observatory | Cape Town, South Africa | 7925*
> f
>
>
>
> On Wed, May 19, 2021 at 4:23 PM Sharif Mehedi 
> wrote:
>
>> First you need to have OAuth 2 on your server. look for PYPI packages
>> that has OAuth for paypal.
>> the follow this: https://developer.paypal.com/docs/api/overview/
>> On Wednesday, May 19, 2021, 5:30:43 PM GMT+6, Eric 247ERICPOINTCOM <
>> eric...@gmail.com> wrote:
>>
>>
>> Hi
>>
>> I would like to integrate PayPal with my project in Django I have gone
>> through a couple of tutorials but I still dont understand how to do it. I
>> am new to Django but I have got a project am working on which charges per
>> post on the website.
>>
>> When a post is created it will be charged I want to add PayPal to the
>> post button, so that when one pays the post is created automatically there
>> after.
>>
>> How can I do this.
>>
>> Here is my template for create_post:
>>
>> {% extends "feed/layout.html" %} {% load static %} {% load
>> crispy_forms_tags %}
>> {% block searchform %}
>> > class="form-inline my-2 my-lg-0 ml-5"
>> action="{% url 'search_posts' %}"
>> method="get"
>> >
>> 
>> 
>> Search
>> 
>> 
>> {% endblock searchform %} {% block content %}
>> 
>> 
>> 
>> 
>> 
>> 
>> Post
>> 
>> {% csrf_token %}
>> 
>> 
>> {{ form|crispy }}
>> 
>> 
>> > class="btn btn-lg btn-primary btn-block text-uppercase"
>> type="submit"
>> >
>> Post> >
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>
>> {% endblock content %} {% block jsfiles %}{% endblock jsfiles %}
>>
>> --
>> 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/46c1c5ea-d198-440f-8538-6d4955b237a8n%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/13750508.255604.1621434160035%40mail.yahoo.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/CAFgqToXO%2BoG5aKxOfD05XxixDyrPC9guQ%2B7gPHrakDSRPuzLaA%40mail.gmail.com.


Re: PayPal Integration

2021-05-31 Thread Sharif Mehedi
Glad to be of help.
It'd be easier for me to help you if I had a sneak peek at your code snippet, 
with which you are trying to do that.
Sharif
   On Monday, May 31, 2021, 5:56:44 PM GMT+6, Eric 247ERICPOINTCOM 
 wrote:  
 
 Thank you Sharif, I have integrated successfully with paypal after going 
through the paypal developer docs, and tested it with sandbox.paypal and it is 
working great.
However I would like your help, to now be able to submit  the form 
automatically after making the payment with paypal. I have tried adding 
type="submit"  to the paypal button but that doesn't work.  How can I do that?
  
Kind Regards

Eric Bawakuno | Computer Engineer | +27795639700| +27 815152254 | 
eric...@gmail.com  | Address: 29 Rochester Road, Observatory | Cape Town, South 
Africa | 7925f





On Wed, May 19, 2021 at 7:26 PM Eric 247ERICPOINTCOM  wrote:

Thank you Sharif. Let me do that, I will come back to the conversation after
  
Kind Regards

Eric Bawakuno | Computer Engineer | +27795639700| +27 815152254 | 
eric...@gmail.com  | Address: 29 Rochester Road, Observatory | Cape Town, South 
Africa | 7925f





On Wed, May 19, 2021 at 4:23 PM Sharif Mehedi  wrote:

 First you need to have OAuth 2 on your server. look for PYPI packages that has 
OAuth for paypal.the follow this: 
https://developer.paypal.com/docs/api/overview/On Wednesday, May 19, 2021, 
5:30:43 PM GMT+6, Eric 247ERICPOINTCOM  wrote:  
 
 Hi
I would like to integrate PayPal with my project in Django I have gone through 
a couple of tutorials but I still dont understand how to do it. I am new to 
Django but I have got a project am working on which charges per post on the 
website.
When a post is created it will be charged I want to add PayPal to the post 
button, so that when one pays the post is created automatically there after.
How can I do this.
Here is my template for create_post:
{% extends "feed/layout.html" %} {% load static %} {% load crispy_forms_tags %}
{% block searchform %}

 
 
 Search
 

{% endblock searchform %} {% block content %}


 
 
 
 
 Post
 
 {% csrf_token %}
 
 
 {{ form|crispy }}
 
 
 
 Post
 
 
 
 
 
 


{% endblock content %} {% block jsfiles %}{% endblock jsfiles %}


-- 
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/46c1c5ea-d198-440f-8538-6d4955b237a8n%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/13750508.255604.1621434160035%40mail.yahoo.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/CAFgqToXO%2BoG5aKxOfD05XxixDyrPC9guQ%2B7gPHrakDSRPuzLaA%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/1362915566.1915479.1622464587686%40mail.yahoo.com.


Re: how to input list [] dynamic in python

2021-05-31 Thread Derek
This does look a programming exercise in a class...  if you ask these 
questions in future, be warned people here will probably ask to see your 
attempt at writing code first (otherwise you are not really learning to be 
a programmer).

But, OK, it seemed interesting to me,so here is one approach:

def elementswise_left_join(l1, l2):

"""https://www.w3resource.com/python-exercises/list/python-data-type-list-exercise-155.php""";
f_len = len(l1) - (len(l2) - 1)
for i in range(0, len(l2), 1):
if f_len - i > len(l1):
break
else:
l1[i] = l1[i] + l2[i]
return l1


def get_array(n):
if n == 1:
return [1,]
r = [x for x in range(1, n + 1)]
return r


curr = []
valid = True
while valid:
num = input("Enter number: ")
if num:
new = get_array(int(num))
if len(new) > len(curr):
curr = elementswise_left_join(new, curr)
else:
curr = elementswise_left_join(curr, new)
print(curr)
else:
valid = False



On Monday, 31 May 2021 at 13:34:51 UTC+2 leoa...@gmail.com wrote:

> how about if input like in below
> 1 ) input: 3 , return [1, 2, 3]
> then continue dynamic
>
> 2) input: 2, return [2, 4, 3]
>   then continue dynamic  
>
> 3) input: 6, return [3, 6, 6, 4, 5, 6]
>   then continue dynamic  
>
> 4) input: 1, return [4, 6, 6, 4, 5, 6]
>   then continue dynamic  
>
> 5) input: 1, return [5, 6, 6, 4, 5, 6]
>
> thanks
>
>
> Pada tanggal Sen, 31 Mei 2021 pukul 18.20 paidjoo indo  
> menulis:
>
>> hello i having question, because i still learn python for me, so can help 
>> me 
>> the question is
>>
>> how about if input like in below
>> 1 ) input: 3 , return [1, 2, 3]
>>
>> 2) input: 2, return [2, 4, 3]
>>
>> 3) input: 6, return [3, 6, 6, 4, 5, 6]
>>
>> 4) input: 1, return [4, 6, 6, 4, 5, 6]
>>
>> 5) input: 1, return [5, 6, 6, 4, 5, 6]
>>
>> thanks in advance
>>
>

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


Re: Filtering fields in http response data from http request url ?

2021-05-31 Thread Sam Chaffy
Using django rest framework, create a serializer class and specify the
right field you want to display at the end.

Please check this link

https://www.django-rest-framework.org/api-guide/serializers/


On Sun, May 30, 2021 at 10:03 PM Mottaz Hegaze  wrote:

> Using Django Rest Framework , you can alter the output by overriting
> function to_represent in serializer.
>
> On Mon, 31 May 2021, 1:26 am Adaeit Telle, 
> wrote:
>
>> Hi Django Developers,
>> Json response from the django server is huge as the data fields contained
>> are of big size.
>> So, can I restrict the *fields* required in the response data from the
>> *HTTP Request Url* ?
>> Is there a generic param, which can be used ?
>>
>> Just like QuerySet, can we have "ValueSet" to restrict the fields(or
>> columns) in the json response data ?
>>
>> Regards,
>> Adaeit
>>
>> --
>> 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/f274b86b-e3fb-483b-802e-857362087619n%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/CAHV4E-dB0%3DHha6HgCoG4igdBbyyjPbQMO3rjkZBPaHH6_Kwscw%40mail.gmail.com
> 
> .
>
-- 
Oussama Chafiqui

-- 
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/CAPvcp%2BUVnw%2BncKDhkOA2dma%3Dd9bw%3DAtgjNy6cCcPZAxnZBVmOA%40mail.gmail.com.


os module import error

2021-05-31 Thread James Ndubuisi
Good afternoon.
It seems on creating the Django project using django-admin startproject
command , the os module isn't imported by default, causing an error.

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


Re: os module import error

2021-05-31 Thread Antonis Christofides

Hi!

Could you show exactly which command(s) you are running, and the exact error 
message?


Regards,

Antonis Christofides
+30-6979924665 (mobile)

On 31/05/2021 17.57, James Ndubuisi wrote:

Good afternoon.
It seems on creating the Django project using django-admin startproject 
command , the os module isn't imported by default, causing an error.

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an 
email to django-users+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK4ckVVeaT75CAPQWZeD6q6ewraHmaRH07W_6JQRemX6QV%2BXNA%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/cf967d61-ef98-0cdc-8f39-991641ba5728%40antonischristofides.com.


Re: os module import error

2021-05-31 Thread Avi shah
you could just add "import os" in settings.py file

On Mon, May 31, 2021 at 8:32 PM James Ndubuisi 
wrote:

> Good afternoon.
> It seems on creating the Django project using django-admin startproject
> command , the os module isn't imported by default, causing an error.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAK4ckVVeaT75CAPQWZeD6q6ewraHmaRH07W_6JQRemX6QV%2BXNA%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/CALa7AFPHGEsvpgdaUDpefw1nmVp_c56n95quZUFF_Q-ur0rX%2Bg%40mail.gmail.com.


Re: CSS not linking with HTML

2021-05-31 Thread sukhy gill
I deleted my project and will start project again from begining and then
will let you know the progress.
Regards

On Sun, May 30, 2021, 16:48 Mehdi Ismail  you want to mention (provide screenshot) of the error?
>
> On Sunday, 30 May 2021 at 09:14:22 UTC+5:30 sukhy.g...@gmail.com wrote:
>
>> Getting error while using using command python manage.py collectstatic
>> Regarda
>>
>> On Sat, May 29, 2021, 21:23 Mehdi Ismail >
>>> python manage.py collectstatic
>>>
>>>
>>> try that... and update
>>> On Saturday, 29 May 2021 at 20:44:48 UTC+5:30 sukhy.g...@gmail.com
>>> wrote:
>>>
 Project Folder ➡️static ➡️css➡️style.css➡️

 On Sat, May 29, 2021, 19:16 Fabiano Leite >>>
>
> Where is located your 'css/style.css';
> Em sábado, 29 de maio de 2021 às 10:04:50 UTC-3, sukhy.g...@gmail.com
> escreveu:
>
>> No dear
>>
>> On Sat, May 29, 2021, 18:29 Chelsea Fan > wrote:
>>
>>> Is it working now?
>>>
>>> On Sat, 29 May 2021, 3:40 pm lalit suthar, 
>>> wrote:
>>>
 read this https://docs.djangoproject.com/en/2.2/intro/tutorial06/
 and check how you are giving paths. Also after loading the page on your
 browser go to "View Page Source" and click on the CSS file link and 
 check
 if the file is opening or not.

 On Saturday, 29 May 2021 at 17:57:21 UTC+5:30 sukhy.g...@gmail.com
 wrote:

> Yes Sir,There was no mistake in code. Code problem was only in
> mail content actually code was correct as instruction given by Aniket 
> Sir
>
> Regards
>
>
> On Sat, May 29, 2021, 13:14 lalit suthar  wrote:
>
>> have you checked Aniket's answer?
>>
>> On Saturday, 29 May 2021 at 11:09:07 UTC+5:30
>> sukhy.g...@gmail.com wrote:
>>
>>> Done Sir, but not working
>>>
>>> On Sat, May 29, 2021, 10:50 Venu Gopal >> wrote:
>>>
 In Firefox  Goto Preferences ---> Choose Privacy and
 Security ---> scroll down until you get cookies and site data --> 
 clear data
 Chrome  Goto Settings ---> Choose Privacy and Security --->
 select cookies and other site data --> select see all cookies and 
 site data
 --> Remove all

 On Sat, May 29, 2021 at 9:50 AM sukhy gill <
 sukhy.g...@gmail.com> wrote:

> @Venu Gopal
>
> No Sir, I don't know, how to do this.
>
> May I know Sir, how to do the same?
>
> Regards
>
> On Sat, May 29, 2021, 09:41 Venu Gopal  wrote:
>
>> Hi, Have you tried deleting existing cache and cookies in the
>> browser?
>>
>> On Sat, May 29, 2021 at 12:08 AM sukhy gill <
>> sukhy.g...@gmail.com> wrote:
>>
>>> Dear Frnds
>>> I am unable to  link CSS with HTML
>>> HTML working but CSS not working inside the .html file with
>>> the help of LINK in  tag
>>>
>>> I am using thefollowings:-
>>> Setting.py -  STATICFILES_DIRS=[os.path.join(BASE_DIR,
>>> 'static'),]
>>> HTML- {% load static %}
>>> >> To unsubscribe from this group and stop receiving emails
>>> from it, send an email to django-users...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/3ca2aba0-a58f-4298-b248-16c51bdf90a6n%40googlegroups.com
>>> 
>>> .
>>>
>> --
>> You received this message because you are subscribed to a
>> topic in the Google Groups "Django users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/django-users/qGMoFXNAgww/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, send an
>> email to django-users...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAOhYkiyqw8k5zCL1XZo9U%2BY9_JR57p55xf-%3DtFf6Fa4HVskPSw%40mail.gmail.com
>> 
>> .
>>
> --
> You received this message because you are subscribed to the
> Google Groups "Django users" group.
> To unsubscr

Re: CSS not linking with HTML

2021-05-31 Thread Chelsea Fan
Good luck 

On Mon, 31 May 2021, 6:31 pm sukhy gill,  wrote:

> I deleted my project and will start project again from begining and then
> will let you know the progress.
> Regards
>
> On Sun, May 30, 2021, 16:48 Mehdi Ismail 
>> you want to mention (provide screenshot) of the error?
>>
>> On Sunday, 30 May 2021 at 09:14:22 UTC+5:30 sukhy.g...@gmail.com wrote:
>>
>>> Getting error while using using command python manage.py collectstatic
>>> Regarda
>>>
>>> On Sat, May 29, 2021, 21:23 Mehdi Ismail >>
 python manage.py collectstatic


 try that... and update
 On Saturday, 29 May 2021 at 20:44:48 UTC+5:30 sukhy.g...@gmail.com
 wrote:

> Project Folder ➡️static ➡️css➡️style.css➡️
>
> On Sat, May 29, 2021, 19:16 Fabiano Leite  wrote:
>
>>
>> Where is located your 'css/style.css';
>> Em sábado, 29 de maio de 2021 às 10:04:50 UTC-3, sukhy.g...@gmail.com
>> escreveu:
>>
>>> No dear
>>>
>>> On Sat, May 29, 2021, 18:29 Chelsea Fan >> wrote:
>>>
 Is it working now?

 On Sat, 29 May 2021, 3:40 pm lalit suthar, 
 wrote:

> read this https://docs.djangoproject.com/en/2.2/intro/tutorial06/
> and check how you are giving paths. Also after loading the page on 
> your
> browser go to "View Page Source" and click on the CSS file link and 
> check
> if the file is opening or not.
>
> On Saturday, 29 May 2021 at 17:57:21 UTC+5:30 sukhy.g...@gmail.com
> wrote:
>
>> Yes Sir,There was no mistake in code. Code problem was only in
>> mail content actually code was correct as instruction given by 
>> Aniket Sir
>>
>> Regards
>>
>>
>> On Sat, May 29, 2021, 13:14 lalit suthar > wrote:
>>
>>> have you checked Aniket's answer?
>>>
>>> On Saturday, 29 May 2021 at 11:09:07 UTC+5:30
>>> sukhy.g...@gmail.com wrote:
>>>
 Done Sir, but not working

 On Sat, May 29, 2021, 10:50 Venu Gopal >>> wrote:

> In Firefox  Goto Preferences ---> Choose Privacy and
> Security ---> scroll down until you get cookies and site data --> 
> clear data
> Chrome  Goto Settings ---> Choose Privacy and Security
> ---> select cookies and other site data --> select see all 
> cookies and site
> data --> Remove all
>
> On Sat, May 29, 2021 at 9:50 AM sukhy gill <
> sukhy.g...@gmail.com> wrote:
>
>> @Venu Gopal
>>
>> No Sir, I don't know, how to do this.
>>
>> May I know Sir, how to do the same?
>>
>> Regards
>>
>> On Sat, May 29, 2021, 09:41 Venu Gopal > wrote:
>>
>>> Hi, Have you tried deleting existing cache and cookies in
>>> the browser?
>>>
>>> On Sat, May 29, 2021 at 12:08 AM sukhy gill <
>>> sukhy.g...@gmail.com> wrote:
>>>
 Dear Frnds
 I am unable to  link CSS with HTML
 HTML working but CSS not working inside the .html file with
 the help of LINK in  tag

 I am using thefollowings:-
 Setting.py -  STATICFILES_DIRS=[os.path.join(BASE_DIR,
 'static'),]
 HTML- {% load static %}
 >>> To unsubscribe from this group and stop receiving emails
 from it, send an email to django-users...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/3ca2aba0-a58f-4298-b248-16c51bdf90a6n%40googlegroups.com
 
 .

>>> --
>>> You received this message because you are subscribed to a
>>> topic in the Google Groups "Django users" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/d/topic/django-users/qGMoFXNAgww/unsubscribe
>>> .
>>> To unsubscribe from this group and all its topics, send an
>>> email to django-users...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAOhYkiyqw8k5zCL1XZo9U%2BY9_JR57p55xf-%3DtFf6Fa4HVskPSw%40mail.gmail.com
>>> 

Re: CSS not linking with HTML

2021-05-31 Thread sukhy gill
Thanku so much all of you for your valuable guidance to me 🙏🙏🙏🙂🙂

On Mon, May 31, 2021, 21:07 Chelsea Fan  Good luck 
>
> On Mon, 31 May 2021, 6:31 pm sukhy gill,  wrote:
>
>> I deleted my project and will start project again from begining and then
>> will let you know the progress.
>> Regards
>>
>> On Sun, May 30, 2021, 16:48 Mehdi Ismail >
>>> you want to mention (provide screenshot) of the error?
>>>
>>> On Sunday, 30 May 2021 at 09:14:22 UTC+5:30 sukhy.g...@gmail.com wrote:
>>>
 Getting error while using using command python manage.py collectstatic
 Regarda

 On Sat, May 29, 2021, 21:23 Mehdi Ismail >>>
> python manage.py collectstatic
>
>
> try that... and update
> On Saturday, 29 May 2021 at 20:44:48 UTC+5:30 sukhy.g...@gmail.com
> wrote:
>
>> Project Folder ➡️static ➡️css➡️style.css➡️
>>
>> On Sat, May 29, 2021, 19:16 Fabiano Leite > wrote:
>>
>>>
>>> Where is located your 'css/style.css';
>>> Em sábado, 29 de maio de 2021 às 10:04:50 UTC-3,
>>> sukhy.g...@gmail.com escreveu:
>>>
 No dear

 On Sat, May 29, 2021, 18:29 Chelsea Fan >>> wrote:

> Is it working now?
>
> On Sat, 29 May 2021, 3:40 pm lalit suthar, 
> wrote:
>
>> read this https://docs.djangoproject.com/en/2.2/intro/tutorial06/
>> and check how you are giving paths. Also after loading the page on 
>> your
>> browser go to "View Page Source" and click on the CSS file link and 
>> check
>> if the file is opening or not.
>>
>> On Saturday, 29 May 2021 at 17:57:21 UTC+5:30
>> sukhy.g...@gmail.com wrote:
>>
>>> Yes Sir,There was no mistake in code. Code problem was only in
>>> mail content actually code was correct as instruction given by 
>>> Aniket Sir
>>>
>>> Regards
>>>
>>>
>>> On Sat, May 29, 2021, 13:14 lalit suthar >> wrote:
>>>
 have you checked Aniket's answer?

 On Saturday, 29 May 2021 at 11:09:07 UTC+5:30
 sukhy.g...@gmail.com wrote:

> Done Sir, but not working
>
> On Sat, May 29, 2021, 10:50 Venu Gopal  wrote:
>
>> In Firefox  Goto Preferences ---> Choose Privacy and
>> Security ---> scroll down until you get cookies and site data 
>> --> clear data
>> Chrome  Goto Settings ---> Choose Privacy and Security
>> ---> select cookies and other site data --> select see all 
>> cookies and site
>> data --> Remove all
>>
>> On Sat, May 29, 2021 at 9:50 AM sukhy gill <
>> sukhy.g...@gmail.com> wrote:
>>
>>> @Venu Gopal
>>>
>>> No Sir, I don't know, how to do this.
>>>
>>> May I know Sir, how to do the same?
>>>
>>> Regards
>>>
>>> On Sat, May 29, 2021, 09:41 Venu Gopal >> wrote:
>>>
 Hi, Have you tried deleting existing cache and cookies in
 the browser?

 On Sat, May 29, 2021 at 12:08 AM sukhy gill <
 sukhy.g...@gmail.com> wrote:

> Dear Frnds
> I am unable to  link CSS with HTML
> HTML working but CSS not working inside the .html file
> with the help of LINK in  tag
>
> I am using thefollowings:-
> Setting.py -  STATICFILES_DIRS=[os.path.join(BASE_DIR,
> 'static'),]
> HTML- {% load static %}
>  To unsubscribe from this group and stop receiving emails
> from it, send an email to django-users...@googlegroups.com
> .
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/3ca2aba0-a58f-4298-b248-16c51bdf90a6n%40googlegroups.com
> 
> .
>
 --
 You received this message because you are subscribed to a
 topic in the Google Groups "Django users" group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/django-users/qGMoFXNAgww/unsubscribe
 .
 To unsubscribe from this group and all its topics, send an
 email to django-users...@googlegroups.com.
 To view this discussion on the web visit
 https://group

IntegrityError at /userapp/detail/ NOT NULL constraint failed: userapp_profile.babyinfo_id

2021-05-31 Thread Hugh Frost
Hii all,
I hv been struck in last 4 days please fix this error , i'm new to django

-- 
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/c753a468-0b45-4266-9094-213719986069n%40googlegroups.com.
from django.db import models
from django.urls import reverse
from django.contrib.auth.models import User

from PIL import Image
# from package.models import Package
# from .models import BabyInfo,Profile
# from user_profile.models import BabyInfo
# Create your models here.
class UserOTP(models.Model):
	user = models.ForeignKey(User, on_delete = models.CASCADE)
	time_st = models.DateTimeField(auto_now = True)
	otp = models.SmallIntegerField()

def upload_profile_to(instance,filename):
	return f'profile_picture/{instance}/{filename}'

class BabyInfo(models.Model):
	MALE = 'male'
	FEMALE = 'female'
	BOTH = 'both'
	GENDER = (
('MALE','Male'),
('FEMALE','Female'),
('BOTH','both'),
)

	Y='yes'
	N='no'
	CHOICES = (
('Y', 'Yes'),
('N', 'No'),
)
	born_status = models.CharField(max_length=1, choices=CHOICES)
	gender = models.CharField(max_length=10, choices=GENDER, verbose_name="gender")
	story_name = models.CharField(max_length=100)
	baby_date = models.DateField()
	profile_pic = models.ImageField(upload_to = upload_profile_to, default = 'defaults/profile_pic.jpg')
	# package=models.ForeignKey(Package,on_delete=models.CASCADE)
	created = models.DateTimeField(verbose_name=('Created'),auto_now_add=True)
	updated = models.DateTimeField(verbose_name=('Updated'),auto_now=True)

	class Meta:
		verbose_name = ('BabyInfo')
		verbose_name_plural = ('BabyInfos')
		ordering = ['-created']

	def __str__(self):
		return self.story_name


class Profile(models.Model):
	user = models.OneToOneField(User, on_delete = models.CASCADE,)
	profile_pic = models.ImageField(upload_to = upload_profile_to, null=True)
	# cover_image = models.ImageField(upload_to = 'upload_cover_to', null = True, default= 'defaults/cover_image.jpg')
	name=models.CharField(max_length=250)
	mail_id=models.EmailField()
	relationship=models.CharField(max_length=100)
	phone_no=models.IntegerField()
	is_lead_user=models.BooleanField(('Is LEAD USER'),help_text='button to toggle employee lead and aditional',default=False)
	babyinfo=models.ForeignKey(BabyInfo,on_delete=models.CASCADE,null=True)
	created = models.DateTimeField(verbose_name=('Created'),auto_now_add=True,null=True)
	updated = models.DateTimeField(verbose_name=('Updated'),auto_now=True,null=True)

	class Meta:
		verbose_name = ('Profile')
		verbose_name_plural = ('Profiles')
		ordering = ['-created']

	def __str__(self):
		return self.mail_id

	def save(self, *args, **kwargs):
		super().save(*args, **kwargs)

		img = Image.open(self.profile_pic.path)
		if img.height > 300 or img.width > 300:
			output_size = (300, 300)
			img.thumbnail(output_size)
			img.save(self.profile_pic.path)

		img2 = Image.open(self.cover_image.path)
		if img2.height > 500 or img2.width > 500:
			output_size = (500, 500)
			img2.thumbnail(output_size)
			img2.save(self.cover_image.path)
from django.shortcuts import render
from django.shortcuts import redirect
from django.urls import reverse
from django.shortcuts import get_object_or_404
from django.http import HttpResponseRedirect, HttpResponse
from django import forms
# Create your views here.
# from .forms import Profile
from userapp.models import BabyInfo,Profile,UserOTP
from userapp.forms import BabyForm1,BabyForm2


from django.contrib import messages
import random
from .forms import SignUpForm
from django.contrib.auth.models import User
from django.core.mail import send_mail
from django.conf import settings
from django.http import HttpResponse, Http404, JsonResponse
from django.contrib.auth.forms import AuthenticationForm, PasswordChangeForm
from django.contrib.auth import authenticate, login
from django.contrib.auth.decorators import login_required
from django.views.decorators.csrf import csrf_exempt
from django.core import serializers
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger


def page(request):
return render(request,'userapp_temp/landing_page.html')

def home(request):
return render(request,'userapp_temp/home.html',)

# def index(request):
# return render(request, 'userapp_temp/index.html', {'title':'index'})

# def login(request):
# return render(request,'userapp_temp/login.html')
#
# def register(request):
# return render(request,'userapp_temp/signup.html')

def profile(request):
return render(request,'userapp_temp/profile.html')


#(BABY_PROFILE)#
def detail(request):
if request.method == 'POST':
baby_form1 = BabyForm1(data=request.POST)
  

Re: CSS not linking with HTML

2021-05-31 Thread Chelsea Fan
You are welcome))

On Mon, 31 May 2021, 6:44 pm sukhy gill,  wrote:

> Thanku so much all of you for your valuable guidance to me 🙏🙏🙏🙂🙂
>
> On Mon, May 31, 2021, 21:07 Chelsea Fan  wrote:
>
>> Good luck 
>>
>> On Mon, 31 May 2021, 6:31 pm sukhy gill, 
>> wrote:
>>
>>> I deleted my project and will start project again from begining and then
>>> will let you know the progress.
>>> Regards
>>>
>>> On Sun, May 30, 2021, 16:48 Mehdi Ismail >>
 you want to mention (provide screenshot) of the error?

 On Sunday, 30 May 2021 at 09:14:22 UTC+5:30 sukhy.g...@gmail.com wrote:

> Getting error while using using command python manage.py collectstatic
> Regarda
>
> On Sat, May 29, 2021, 21:23 Mehdi Ismail 
>> python manage.py collectstatic
>>
>>
>> try that... and update
>> On Saturday, 29 May 2021 at 20:44:48 UTC+5:30 sukhy.g...@gmail.com
>> wrote:
>>
>>> Project Folder ➡️static ➡️css➡️style.css➡️
>>>
>>> On Sat, May 29, 2021, 19:16 Fabiano Leite >> wrote:
>>>

 Where is located your 'css/style.css';
 Em sábado, 29 de maio de 2021 às 10:04:50 UTC-3,
 sukhy.g...@gmail.com escreveu:

> No dear
>
> On Sat, May 29, 2021, 18:29 Chelsea Fan  wrote:
>
>> Is it working now?
>>
>> On Sat, 29 May 2021, 3:40 pm lalit suthar, 
>> wrote:
>>
>>> read this
>>> https://docs.djangoproject.com/en/2.2/intro/tutorial06/ and
>>> check how you are giving paths. Also after loading the page on your 
>>> browser
>>> go to "View Page Source" and click on the CSS file link and check 
>>> if the
>>> file is opening or not.
>>>
>>> On Saturday, 29 May 2021 at 17:57:21 UTC+5:30
>>> sukhy.g...@gmail.com wrote:
>>>
 Yes Sir,There was no mistake in code. Code problem was only in
 mail content actually code was correct as instruction given by 
 Aniket Sir

 Regards


 On Sat, May 29, 2021, 13:14 lalit suthar >>> wrote:

> have you checked Aniket's answer?
>
> On Saturday, 29 May 2021 at 11:09:07 UTC+5:30
> sukhy.g...@gmail.com wrote:
>
>> Done Sir, but not working
>>
>> On Sat, May 29, 2021, 10:50 Venu Gopal > wrote:
>>
>>> In Firefox  Goto Preferences ---> Choose Privacy and
>>> Security ---> scroll down until you get cookies and site data 
>>> --> clear data
>>> Chrome  Goto Settings ---> Choose Privacy and Security
>>> ---> select cookies and other site data --> select see all 
>>> cookies and site
>>> data --> Remove all
>>>
>>> On Sat, May 29, 2021 at 9:50 AM sukhy gill <
>>> sukhy.g...@gmail.com> wrote:
>>>
 @Venu Gopal

 No Sir, I don't know, how to do this.

 May I know Sir, how to do the same?

 Regards

 On Sat, May 29, 2021, 09:41 Venu Gopal <
 reachme...@gmail.com wrote:

> Hi, Have you tried deleting existing cache and cookies in
> the browser?
>
> On Sat, May 29, 2021 at 12:08 AM sukhy gill <
> sukhy.g...@gmail.com> wrote:
>
>> Dear Frnds
>> I am unable to  link CSS with HTML
>> HTML working but CSS not working inside the .html file
>> with the help of LINK in  tag
>>
>> I am using thefollowings:-
>> Setting.py -  STATICFILES_DIRS=[os.path.join(BASE_DIR,
>> 'static'),]
>> HTML- {% load static %}
>> > To unsubscribe from this group and stop receiving emails
>> from it, send an email to
>> django-users...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/3ca2aba0-a58f-4298-b248-16c51bdf90a6n%40googlegroups.com
>> 
>> .
>>
> --
> You received this message because you are subscribed to a
> topic in the Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/qGMoFXNAgww/unsub

Re: IntegrityError at /userapp/detail/ NOT NULL constraint failed: userapp_profile.babyinfo_id

2021-05-31 Thread Kasper Laudrup
On 31/05/2021 18.46, Hugh Frost wrote:
> Hii all,
> I hv been struck in last 4 days please fix this error , i'm new to django
>

Instead of telling people how many days you've spent trying to fix the
error, try spend some time on explaining what you've spent the days on
doing and what you're trying to achieve.

That will greatly improve your chances of getting help.

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/c753a468-0b45-4266-9094-213719986069n%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/e46ce62f-e92a-8efa-c49e-11c8036af6ff%40stacktrace.dk.


OpenPGP_signature
Description: OpenPGP digital signature


Re: IntegrityError at /userapp/detail/ NOT NULL constraint failed: userapp_profile.babyinfo_id

2021-05-31 Thread Hugh Frost
Hey bro,
i try to combine  two model forms in single view django views  
but i dnt knw how to work with this please check my below code and help me!

On Monday, May 31, 2021 at 11:15:29 PM UTC+5:30 Kasper Laudrup wrote:

> On 31/05/2021 18.46, Hugh Frost wrote:
> > Hii all,
> > I hv been struck in last 4 days please fix this error , i'm new to django
> >
>
> Instead of telling people how many days you've spent trying to fix the
> error, try spend some time on explaining what you've spent the days on
> doing and what you're trying to achieve.
>
> That will greatly improve your chances of getting help.
>
> 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...@googlegroups.com
> > .
> > To view this discussion on the web visit
> > 
> https://groups.google.com/d/msgid/django-users/c753a468-0b45-4266-9094-213719986069n%40googlegroups.com
> > <
> https://groups.google.com/d/msgid/django-users/c753a468-0b45-4266-9094-213719986069n%40googlegroups.com?utm_medium=email&utm_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/3c8e630f-103b-4612-9cb8-955950953a7bn%40googlegroups.com.


Re: Help with a huge database query.

2021-05-31 Thread 'odrzen' via Django users
If I use the values() or values_list() the request in database has a long 
waiting time and some time I also got a MemoryError (because 4GB RAM is not 
enough).
My examples:

Apple.objects.select_related('Orange').filter(state='fresh').values_list(
# Fields I don't want:
'field1',
'field2',
'field3'
# . ,
'field37'
)

( yes I want 37 different values ).

I also try with .only() with very nice response time, but in the end I will get 
all the fields. For example:
temp = Apple.objects.select_related('Orange').filter(state='fresh').only(
'field1',
'field2',
'field3' )

temp_json = serializers.serialize('json', temp)
return HttpResponse(temp_json, content_type='application/json')

it returns me all the fields! Not only the 'field2', 'field2' and 'field3'.
Could you explain me why ?

Finally, I also tried to run a query with raw() but the response time is 
disappointing.

‐‐‐ Original Message ‐‐‐
On Friday, May 28, 2021 2:13 AM, David Nugent  wrote:

> I think a better approach to using QuerySet.defer() is to use .values() 
> instead, explicitly specifying which fields you need to export.
>
> Just FYI rest_framework handles this out of the box and provides an API to 
> specify not only which fields to export but filters as well.
>
> Regards
> /d
>
> On Fri, May 28, 2021 at 8:10 AM 'odrzen' via Django users 
>  wrote:
>
>> Hello Django community o/
>>
>> I want to create a API call in order to get all data from a specific model ( 
>> table ) - but I want to exclude-remove only specific fields from this.
>> So, I try to find a right way to execute this difficult and "heavy" 
>> query/request with a efficient way.
>> This is what I have achieved so far:
>>
>> ```
>> #from django.http import HttpResponse, HttpResponseRedirect, JsonResponse
>> #from django.core import serializers
>> from apples.models import Apple
>> from oranges.models import Orange
>>
>> published_fruits = 
>> Apple.objects.select_related('Orange').filter(state='published').defer(
>> # Fields I don't want:
>> 'field1',
>> 'field2',
>> 'field3'
>> )
>>
>> So, I have the following results:
>> [
>> {
>> "model": "apples.apple",
>> "pk": "5326t236-8415-48f4-89e5-1789vc9of442",
>> "fields": {
>> "id": "apple-type1",
>> "name": "Brazil",
>> ".": "",
>> "exports ": []
>> }
>> },
>> { ... }
>> {
>> "model": "apples.apple",
>> "pk": "6435673472-fret2-523t-523t-d41159t23432213",
>> "fields": {
>> "id": "apple-type2",
>> "name": "India",
>> ".": "",
>> "exports ": []
>> }
>> }
>> ]
>> ```
>>
>> My proble is :
>> 1. The fields who I don't want (exclude), finally I got it.
>> 2. I want to directly pass all this response to a JSON http output for the 
>> users and I have it with the following way:
>> ```
>> json_response = serializers.serialize('json', published_fruits)
>> return HttpResponse(json_response, content_type='application/json')
>> ```
>> I get all the respone in JSON, but ( as you can see above ) with the 
>> following stracture:
>> ```
>> {
>> "model": "apples.apple",
>> "pk": "6435673472-fret2-523t-523t-d41159t23432213",
>> "fields": {
>> "id": "apple-type2",
>> "name": "India",
>> ".": "",
>> "exports ": []
>> }
>> }
>> ```
>>
>> Please, could you help me to avoid the following part from each record :
>> ```
>> "model": "apples.apple",
>> "pk": "6435673472-fret2-523t-523t-d41159t23432213",
>> "fields": {
>> ```
>> from the JSON ?
>>
>> Thank you very much 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/MvvGE0gJ6x5v1Geo7zgnHdB8TLr79HKJwubqhQzrOKUSB3Q4oHPeWCctdFmOAJ74PbqQ9gHkg44hKVrPqp9BFiZ7Bn7E-LzM30aNrbhcf7s%3D%40protonmail.com](https://groups.google.com/d/msgid/django-users/MvvGE0gJ6x5v1Geo7zgnHdB8TLr79HKJwubqhQzrOKUSB3Q4oHPeWCctdFmOAJ74PbqQ9gHkg44hKVrPqp9BFiZ7Bn7E-LzM30aNrbhcf7s%3D%40protonmail.com?utm_medium=email&utm_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/CAE5VhgX04DNGPHS%2BgpC7UdT2Kwj40%2BZ6UqKckSQ0G8RL5mHb0A%40mail.gmail.com](https://groups.google.com/d/msgid/django-users/CAE5VhgX04DNGPHS%2BgpC7UdT2Kwj40%2BZ6UqKckSQ0G8RL5mHb0A%40mail.gmail.com?utm_medium=email&utm_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/mlI7MqIhUI

Using jsonb_array_elements with querysets

2021-05-31 Thread Jameel A.
I’m trying to use the jsonb_array_elements Postgres function with querysets 
but I am running into issues.

I defined a custom Func as:

class JsonbArrayElements(Func):
function = 'jsonb_array_elements'

While this does seem to result in proper sql when used in an annotation, 
the issue comes when I try to filter on the new field. Postgres doesn’t 
allow you to use the new field in a where clause without using a subquery 
first.

The query that I am trying to write is equivalent to:

select *
from (
select id, jsonb_array_elements(json_data->'some_array') as elem
from foo as foo1
union
select id, jsonb_array_elements(json_data->'other_array') as elem
from foo as foo2
) as foo_w_elems
where (elem->>'subfield')::int in (
select id
from bar
where expires_at >= CURRENT_TIMESTAMP
)

Unfortunately, even with Django’s subquery support, I have been unable to 
get a query to add the where clause to the results of a subquery.

My issue seems related to https://code.djangoproject.com/ticket/24462, but 
was curious if there is a way to use and filter jsonb_array_elements 
results in Django today without using raw sql?

I’m also investigating using the low-level query API directly, but have run 
into some issues so far.

-- 
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/68017f88-bbcc-43be-96ae-c7a3cd802d0an%40googlegroups.com.


How does django-admin work?

2021-05-31 Thread J Lee
I'm new to Django, and I've just been dazzled by the magic of Django. My 
main question is how does Django add django-admin to my path automatically 
and how does django-admin startproject create my files?

It may be wy over my head, but I welcome any and all response. I would 
like to learn from this. 

Thank you.

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


SVG widget for the Admin

2021-05-31 Thread Mike Dewhirst
I collect the svg source for an image from a public API and store it in 
a models.TextField. I have no difficulty displaying it in a normal view 
and my own template. Nothing special, it just emerges. I don't even need 
a 'safe' filter.


However, I really want to display such images in the Admin. At this 
stage all it displays is the svg source.


What is the correct way to make the image appear in the Admin?

Do I need a special field inheriting from TextField? Do I need a special 
widget? Is there a way to mark admin field values as safe?


Thanks for any hints

Mike

--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.


--
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/b8ec5d1f-950f-c3cf-2490-e52e75035660%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Re: How does django-admin work?

2021-05-31 Thread Thomas Lockhart
Welcome to Django!

Django does not add django-admin to your path. Rather, when Django is installed 
it (sometimes) happens to be installed into a place which is already in your 
path. Otherwise, you need to add it to your path or use a packaging system such 
as anaconda which helps do that for you.

startproject simply copies a set of files to your directories, filling in a few 
details and changing the file names to match what you want to create since you 
give it the name of your new project.

hth

- Tom

> On May 31, 2021, at 5:43 PM, J Lee  wrote:
> 
> I'm new to Django, and I've just been dazzled by the magic of Django. My main 
> question is how does Django add django-admin to my path automatically and how 
> does django-admin startproject create my files?
> 
> It may be wy over my head, but I welcome any and all response. I would 
> like to learn from this. 
> 
> Thank you.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/5b022968-ac51-4e49-873d-f9a3b7b88ba4n%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/8834A390-1F46-4405-826D-E7A3A1DCE384%40gmail.com.


Inlined hierarchy models in django admin site.

2021-05-31 Thread Ayush Bisht
class Patient(models.Model):
 patient_id = models.CharField(max_length=60)


class PatientVaccineStatus(models.Model):
  patient = models.ForeignKey(Patient, 
related_name="patient_vaccine_status")

class Vaccine(models.Model)
 vaccine = models.ForeignKey(PatientVaccineStatus, 
related_name="vaccine_status")
 
..

Is there any way to merged all the tables in a single table of patient.

I successfully merge, PatientVaccineStatus table with Patient table, but 
Vaccine's table is not merging with the Patient. 

how can this hierarchy be merged in a single table.

-- 
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/57aac480-cb53-4fbe-a3bd-8766cd7a5b82n%40googlegroups.com.