Re: Static files is not loading while deploying the project to AWS ec2

2022-11-05 Thread Ashutosh Mishra
Did you tried, python manage.py collectstatic?

On Sat, 5 Nov, 2022, 1:05 pm Nishant Sagar,  wrote:

> Hi all,
>
> I deployed the django project to AWS ec2 instance using nginx and gunicorn
> but the static file is not loading at all.
>
> Can someone suggest where did I do wrong?
>
> Note - I've not created Profile before deploying
>
> Here is my settings.py file
> STATIC_URL = 'static/'
> STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
> STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),)
>
> Project URl - http://54.242.38.208/
> Github- https://github.com/Nishant-Sagar/BaskinSolar
>
> Thank you for your help,
> Nishant
>
>
>
>
>
>
>
> --
> 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/CANNtL-K_ntgKNAYUd8DHe8wa4bGwHO5da%3DypJfAVN%3DJHj9uCmQ%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/CAGDmY64P1vrziiG_%3DX0pMb3YS%2BWv2BqZLLkix2gY%2B4cL3YRsEA%40mail.gmail.com.


Re: Static files is not loading while deploying the project to AWS ec2

2022-11-05 Thread Ashutosh Mishra
I had faced same problem but collectstatic worked for me,,

On Sat, 5 Nov, 2022, 1:15 pm Nishant Sagar,  wrote:

> Hi Ashutosh,
>
> Yeah I tried that as well, still not working.
>
> On Sat, 5 Nov 2022 at 1:10 PM, Ashutosh Mishra <
> ashutoshmishra...@gmail.com> wrote:
>
>> Did you tried, python manage.py collectstatic?
>>
>> On Sat, 5 Nov, 2022, 1:05 pm Nishant Sagar, 
>> wrote:
>>
>>> Hi all,
>>>
>>> I deployed the django project to AWS ec2 instance using nginx and
>>> gunicorn but the static file is not loading at all.
>>>
>>> Can someone suggest where did I do wrong?
>>>
>>> Note - I've not created Profile before deploying
>>>
>>> Here is my settings.py file
>>> STATIC_URL = 'static/'
>>> STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
>>> STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),)
>>>
>>> Project URl - http://54.242.38.208/
>>> Github- https://github.com/Nishant-Sagar/BaskinSolar
>>>
>>> Thank you for your help,
>>> Nishant
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> --
>>> 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/CANNtL-K_ntgKNAYUd8DHe8wa4bGwHO5da%3DypJfAVN%3DJHj9uCmQ%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CANNtL-K_ntgKNAYUd8DHe8wa4bGwHO5da%3DypJfAVN%3DJHj9uCmQ%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/CAGDmY64P1vrziiG_%3DX0pMb3YS%2BWv2BqZLLkix2gY%2B4cL3YRsEA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAGDmY64P1vrziiG_%3DX0pMb3YS%2BWv2BqZLLkix2gY%2B4cL3YRsEA%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/CANNtL-J6HWZ%3DPk7iYx4nxk%2BYZ_9HXSMQY2kt-FiBa6fDQz2vrA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CANNtL-J6HWZ%3DPk7iYx4nxk%2BYZ_9HXSMQY2kt-FiBa6fDQz2vrA%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/CAGDmY66usVHG3O7VOU%2B4b%3Dr6TrKRZVNe1RM5ZEOjBAciZs8biw%40mail.gmail.com.


Unable to export images from django model to excel sheet

2020-07-04 Thread Ashutosh Mishra
I have posted on stack overflow.I want export images from django model to excel 
sheet.while doing I am just getting the root media address on excel sheet not 
image.
Please help ,it's urgent.

https://stackoverflow.com/questions/62695531/unable-to-export-images-from-django-model-to-excel-sheet-using-xlwt

-- 
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/b421efaa-4ba6-4bf6-bd09-e7ee8ad7cfdao%40googlegroups.com.


How to get data from django model to the excel sheet.

2020-07-05 Thread Ashutosh Mishra
I want to get the data from the django model contans(name,age,photo) on a 
excel sheet.
How can i do that.

-- 
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/b9ad3b60-2c0a-43dc-bdc6-6a67f8a88826n%40googlegroups.com.


Re: How to get data from django model to the excel sheet.

2020-07-06 Thread Ashutosh Mishra
What if I have an image field too,how to do that

-- 
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/9bf3cc78-00bd-4a8f-a6b7-90344f0bded7o%40googlegroups.com.


Re: How to get data from django model to the excel sheet.

2020-07-06 Thread Ashutosh Mishra
But It is for js,react,angular, how can I place that in django project
On Jul 6, 2020 1:54 PM, "Damanjeet Singh"  wrote:

> Please see handsontable.com.
>
> I have been using it for my project.
>
> On Mon, Jul 6, 2020 at 9:06 AM Ashutosh Mishra <
> ashutoshmishra...@gmail.com> wrote:
>
>> What if I have an image field too,how to do that
>>
>> --
>> 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/9bf3cc78-00bd-4a8f-a6b7-90344f0bded7o%
>> 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/CAGLHGi5_9zX%2BLkywRH9GB_hKLJTBRRjmGBw1aCrYSW5WGOj-6Q%
> 40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAGLHGi5_9zX%2BLkywRH9GB_hKLJTBRRjmGBw1aCrYSW5WGOj-6Q%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/CAGDmY671qKxoEUL%3DjEWQ7Xso4Opn74W3jh3dtD2Zy9jgvEpjtw%40mail.gmail.com.


How to get data from django model to excel sheet using openpyxl including images.

2020-07-09 Thread Ashutosh Mishra
I am creating an api to get data and images from django model to excel 
sheet ,how can i do that,someone please 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fff2b0b5-e4d9-423c-ac8d-b1ccc26c2109n%40googlegroups.com.


Re: Not null constraint error when adding a child record .

2020-07-09 Thread Ashutosh Mishra
That is a data base related error,this happens when you have already 
inserted data to a field of a model then try to manipulate that model 
again.If you know how to handle database then delete that or,delete this 
whole database and start again.


On Thursday, July 9, 2020 at 3:49:21 PM UTC+5:30 ronald.kamu...@gmail.com 
wrote:

> Greetings members.
>
> I am a learner and trying to create an app where staff members can submit 
> online requests for field allowances.
>
> Here my major models.
> class requistion(models.Model):
> made_by=models.ForeignKey(employee,on_delete=models.CASCADE)
> date_made=models.DateTimeField(auto_now_add=True)
> purpose=models.TextField(verbose_name='Purpose')
> objects = models.Manager()
> class Meta:
> verbose_name_plural='requistion'
> def __str__ (self):
> return self.purpose
> class requistiondetail(models.Model):
> requistionid=models.ForeignKey(requistion,on_delete=models.CASCADE)
> emp_name=models.ForeignKey(employee,on_delete=models.CASCADE)
> detail_type=models.ForeignKey(requistiondetailtype,on_delete=models.
> CASCADE)
> period_claimed=models.ForeignKey(period,on_delete=models.CASCADE)
> ndays=models.IntegerField(default=0,verbose_name="Number of days")
> startdate=models.DateField(null=True)
> enddate=models.DateField(null=True)
> rate=models.FloatField(default=0.0,verbose_name='Allowances Rate')
> amount=models.FloatField(default=0.0,verbose_name='Amount')
> objects = models.Manager()
> class Meta:
> verbose_name_plural='requistiondetails'
> I can add the parent record successfully and have them listed in a table 
> as per image below.
>
> [image: list.png]
>
> I want to add the details by clicking on the add details button.
> Here is the view code for adding the details
>
> def add_details(request,requistion_id):
> myrequistion=requistion.objects.get(id=requistion_id)
> if request.method !='POST':
> # if no data submitted ,create a blank form
> form=RequistiondetailForm()
> else:
> # post data submitted
> form=RequistiondetailForm(data=request.POST)  
> if form.is_valid():
> details=form.save(commit=False)
> #print(myrequistion.pk)
> details.requistion=myrequistion
> print(type(myrequistion))
> details.save() 
> return  redirect('requistions:requistion_get',pk=requistion_id
> )
> 
> #display a blank or invalid form
> context={'requistion':myrequistion,'form': form}
> return render(request,'requistions/requistion_detail_add.html',context
> )
> Here is the html form for rendering the detail record and it is done 
> perfectly.
>
> {% extends 'requistions/base.html'%}
> {% block content %}
> 
>  {{
> requistion.purpose}}
> 
>
>
>  Add Requistion Details 
>  "POST">
> {% csrf_token %}
> {{ form.as_p}}
>  Add Line 
>
>
> 
>
>
> {% endblock content %}
>
> [image: form.png]
>
> Problem is when, i click submit button, i get the error below:
> NOT NULL constraint failed: requistions_requistiondetail.requistionid_id
>
> I have added the print statement in the add_details view and the requestid 
> parameter is properly passed to the method.
> Why is it not saved to the model?
> Any thing i am not doing right?
>
>
>
>

-- 
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/bd5cf1b1-4b86-46d1-af7e-2f493818a59an%40googlegroups.com.


Re: How to get data from django model to excel sheet using openpyxl including images.

2020-07-10 Thread Ashutosh Mishra
i have created an api through which i can download the excel file with all 
fields except images.I am posting my models and views

models.py

class Task(models.Model):

Id=models.IntegerField()
Name=models.CharField(max_length=50,null=False,blank=True)
Image1=models.FileField(blank=True, default="",
upload_to="media/images",null=True)
Image2=models.FileField(blank=True, default="",
upload_to="media/images",null=True)
Date=models.DateField(null=True,blank=True)
def __str__(self):
return str(self.Name)

views.py
class TaskViewSet(viewsets.ViewSet):

def list(self,request):
try:
queryset=Task.objects.all()
response = HttpResponse(content_type='application/ms-excel')
#response=HttpResponse(content_type='application/ms-excel')

#response['Content-Disposition'] = 'attachment; filename="users.xls'
response['Content-Disposition']='attachment; filename="users.xls"'

wb=openpyxl.Workbook()
ws=wb.active

row_num=0
columns=['Id','Name','Image1','Image2','Date']

for col_num in range(len(columns)):
c = ws.cell(row=row_num + 1, column=col_num + 1)
c.value = columns[col_num]
for obj in queryset:
row_num+=1
row = [
obj.Id,
obj.Name,
obj.Image1.url,
obj.Image2.url,
str(obj.Date),
]
print(type(row))

for col_num in range(len(row)):
c = ws.cell(row=row_num + 1, column=col_num + 1)
c.value = row[col_num]

wb.save(response)
return response
except Exception as error:
traceback.print_exc()
return Response({"message": str(error), "success": False}, 
status=status.HTTP_200_OK)


On Friday, July 10, 2020 at 5:48:36 PM UTC+5:30 ajoeiam wrote:

> On Thu, Jul 9, 2020 at 10:02 PM Ashutosh Mishra  
> wrote:
>
>> I am creating an api to get data and images from django model to excel 
>> sheet ,how can i do that,someone please help me.  
>>
>>
>> What have you tried so far?
>
> Regards 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c1092b58-9d91-4d9c-8654-54df883c5172n%40googlegroups.com.


Re: How to get data from django model to excel sheet using openpyxl including images.

2020-07-10 Thread Ashutosh Mishra
I am doing that using openpyxl
But not getting the image in excel sheet

https://stackoverflow.com/questions/62695531/cannot-convert-fieldfile-jpg-to-excel-django

See this

On Fri, Jul 10, 2020, 7:15 PM Vishesh Mangla 
wrote:

> Api’s are better suited for Django rest framework.
>
>
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows 10
>
>
>
> *From: *Ashutosh Mishra 
> *Sent: *10 July 2020 18:30
> *To: *Django users 
> *Subject: *Re: How to get data from django model to excel sheet using
> openpyxl including images.
>
>
>
> i have created an api through which i can download the excel file with all
> fields except images.I am posting my models and views
>
>
>
> models.py
>
>
>
> class Task(models.Model):
>
>
>
> Id=models.IntegerField()
>
> Name=models.CharField(max_length=50,null=False,blank=True)
>
> Image1=models.FileField(blank=True, default="",
>
> upload_to="media/images",null=True)
>
> Image2=models.FileField(blank=True, default="",
>
> upload_to="media/images",null=True)
>
> Date=models.DateField(null=True,blank=True)
>
> def __str__(self):
>
> return str(self.Name)
>
>
>
> views.py
>
> class TaskViewSet(viewsets.ViewSet):
>
>
>
> def list(self,request):
>
> try:
>
> queryset=Task.objects.all()
>
> response = HttpResponse(content_type='application/ms-excel')
>
> #response=HttpResponse(content_type='application/ms-excel')
>
>
>
> #response['Content-Disposition'] = 'attachment; filename="users.xls'
>
> response['Content-Disposition']='attachment; filename="users.xls"'
>
>
>
> wb=openpyxl.Workbook()
>
> ws=wb.active
>
>
>
> row_num=0
>
> columns=['Id','Name','Image1','Image2','Date']
>
>
>
> for col_num in range(len(columns)):
>
> c = ws.cell(row=row_num + 1, column=col_num + 1)
>
> c.value = columns[col_num]
>
> for obj in queryset:
>
> row_num+=1
>
> row = [
>
> obj.Id,
>
> obj.Name,
>
> obj.Image1.url,
>
> obj.Image2.url,
>
> str(obj.Date),
>
> ]
>
> print(type(row))
>
>
>
> for col_num in range(len(row)):
>
> c = ws.cell(row=row_num + 1, column=col_num + 1)
>
> c.value = row[col_num]
>
>
>
> wb.save(response)
>
> return response
>
> except Exception as error:
>
> traceback.print_exc()
>
> return Response({"message": str(error), "success": False},
> status=status.HTTP_200_OK)
>
>
>
>
>
> On Friday, July 10, 2020 at 5:48:36 PM UTC+5:30 ajoeiam wrote:
>
> On Thu, Jul 9, 2020 at 10:02 PM Ashutosh Mishra 
> wrote:
>
> I am creating an api to get data and images from django model to excel
> sheet ,how can i do that,someone please help me.
>
>
>
> What have you tried so far?
>
>
>
> Regards
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c1092b58-9d91-4d9c-8654-54df883c5172n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/c1092b58-9d91-4d9c-8654-54df883c5172n%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/80F9CD37-925E-4CB1-A03D-743C8F10EDB4%40hxcore.ol
> <https://groups.google.com/d/msgid/django-users/80F9CD37-925E-4CB1-A03D-743C8F10EDB4%40hxcore.ol?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/CAGDmY67kWhDN1bn%2BWtTcLxCj-QfmzG2F77b-2Hpbo9ouths1Gg%40mail.gmail.com.


Re: Python-django project

2020-07-20 Thread Ashutosh Mishra
interested


On Tue, Jul 21, 2020 at 8:40 AM learn code  wrote:

> Hi everyone,
>
> I am learning python and django, like to work on the projects to improve
> more.If any one interested to join with me to work on the projects,plz send
> me a email.
>
> --
> 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/e7116e9b-9458-4f49-a638-135c4b5874e0o%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/CAGDmY64fpNcib63n4wdsMP83cN%2BxUXT96tmEyH%2BENc0NFx8XZA%40mail.gmail.com.


Get Personal and maching Horoscope

2020-07-22 Thread Ashutosh Mishra
I want to create api's to get personal horoscope and the matching horoscope 
by providing
date of birth for girl and boy,some one plz guide how  can we do 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/76f166af-28e2-4c9e-b847-528773f55e31n%40googlegroups.com.


Re: collaborate to do a project for beginners

2020-08-12 Thread Ashutosh Mishra
hlhie i am intrested in doing project
add me
Ashutosh
9717336958

On Mon, 10 Aug, 2020, 5:12 PM narendra thapa, 
wrote:

> hello everyone,I'm a beginner in django. I want to learn django by
> implementing . If their is someone who wants to collaborate to do a project
> and learn django please let me know.
>
>
>
>
>
>
>
> Regards,
> Narendra Thapa
> Cheers ;)
>
> --
> 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/CAEtntjVh%2B9MxWr-GzQ-wAm3O6vREeebMdcSc7skAGXWmRuz%3D_g%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/CAGDmY66WLrMEOVaQSdbX5yF%2Bxdg3vm9c9%2B-zEznCCDBQvZu96w%40mail.gmail.com.


Re: Check this out guys

2020-09-16 Thread Ashutosh Mishra
That's really cool buddy

On Wed 16 Sep, 2020, 13:12 712189512,  wrote:

> Hi guys i have build this  *https://connectdjango.com
> * platform with django and i want you to check
> it out,you can post your questions there and and also post some tutorials
> too,let's all connect and keep on djangoing.Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAL-5MpUAbK%2BEZxt_qJo9jrsFqf0p%3DS3-JPXoMHv3X1jWDXY5NQ%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/CAGDmY66ec0B9gi_eFkq%2Bde80ZK32hV4jXa%3DPr_veA3NP%3Ds9t6w%40mail.gmail.com.


Diffrence between two

2020-10-28 Thread Ashutosh Mishra
for i in grocery:
if i.store_type=="Alcohol" or "Both":(1)
if i.store_type=="Alcohol" or i.store_type=="Both":(2)

can anyone tell me the diffrence between two statements,I am getting two 
diffrent results

-- 
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/3d26d63e-e725-4074-bbd1-db05e87e402an%40googlegroups.com.


Re: Diffrence between two

2020-10-28 Thread Ashutosh Mishra
thanks

On Wednesday, October 28, 2020 at 5:07:13 PM UTC+5:30 
andrea...@hypercode.se wrote:

> for i in grocery:
> if i.store_type=="Alcohol" or "Both":(1)
> This line checks if  i.store_type is "Alcohol" or if the string "Both" is 
> Truthy - which it is because it is not '' or None - this if statement will 
> always be True.
>
> if i.store_type=="Alcohol" or i.store_type=="Both":(2)
> This line checks if the i.store_type is 'Alcohol' or if the i.store_type 
> is 'Both'. This if statement will only be true if the store_type is 
> 'Alcohol' or 'Both'.
>
> Regards,
>
> Andréas
>
> Den ons 28 okt. 2020 kl 12:30 skrev Ashutosh Mishra  >:
>
>> for i in grocery:
>> if i.store_type=="Alcohol" or "Both":(1)
>> if i.store_type=="Alcohol" or i.store_type=="Both":(2)
>>
>> can anyone tell me the diffrence between two statements,I am getting two 
>> diffrent results
>>
>> -- 
>> 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/3d26d63e-e725-4074-bbd1-db05e87e402an%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/3d26d63e-e725-4074-bbd1-db05e87e402an%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/6a107a11-599d-42ca-9976-f6467cdc2701n%40googlegroups.com.


Re: Fetching data from database

2020-10-28 Thread Ashutosh Mishra
You have go through the django docs,
In django request.method.POST is used to inser data
And Model.objecs.all() this is the way how you fetch data,
You need to study docs

On Thu 29 Oct, 2020, 00:13 Kiran Bangde,  wrote:

> Hi everyone,
>
> Iam stuck at a point ...I want to fetch a data from a database , where
> data should be insert manually , plz help me how to do that how to fire a
> queries in DB and how to use primary key and foreign key over here.
> Please help me ,Iam new to Django .
>
> 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/CAH3w0pg60HpYHzta5hjHTw7NaiBbuh7Q1uOfG%2BkZnRAGgQLOYA%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/CAGDmY67kC6HnvvgE_2xEQVEum7oR%2BRyP9_TNvXEF5i0eOqXa0w%40mail.gmail.com.


How to access using foreing key

2020-10-30 Thread Ashutosh Mishra
class User(models.Model):
name=models.CharField(max_length=50,blank=True,null=True)
latitude = models.CharField('Latitude', max_length=30, blank=True, 
null=True)
longitude = models.CharField('Longitude', max_length=30, blank=True, 
null=True)
location = models.PointField(blank=True, null=True)

def __str__(self):
return str(self.name)

class Restaurant(models.Model):
restaurant_name=models.CharField(max_length=50,blank=True,null=True)
latitude = models.CharField('Latitude', max_length=30, blank=True, 
null=True)
longitude = models.CharField('Longitude', max_length=30, blank=True, 
null=True)
location = models.PointField(blank=True, null=True)

def __str__(self):
return str(self.restaurant_name)


class RestaurantRating(models.Model):
user = 
models.ForeignKey(User,on_delete=models.CASCADE,null=True,related_name="customer_rating")
restaurant = models.ForeignKey(Restaurant, on_delete=models.CASCADE, 
null=True, related_name="rating_restaurant")
rating = models.FloatField()

def __str__(self):
return str(self.user)

How can i filter the restaurants whose rating is 
5,Restaurant.objects.filter()

-- 
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/cdaa9adf-5b4e-4de7-9c9d-f9e875e17acbn%40googlegroups.com.