Re: HTML code not being read

2020-03-30 Thread Luqman Shofuleji
The problem might not be from the HTML template but the View.
All the HTML elements within your for loop will not display if there are no
records to loop through in "comments"

On Mon, Mar 30, 2020, 3:14 PM Jeff Waters  wrote:

> Hi
>
> I have written some code that allows users of a website to comment on
> photos in a picture gallery, using a form. However, when I test the code,
> no comments are displayed.
>
> It would appear that Django is not processing the following code (from my
> HTML file for the photo gallery), given that 'Comment by' is not displayed
> on screen:
>
> {% for comment in comments %}
> 
> 
> Comment by {{ comment.user }}
> 
> {{ comment.created_on }}
> 
> 
> {{ comment.body | linebreaks }}
> 
> {% endfor %}
>
> Does anyone have any suggestions as to how I can fix this, please?
>
> Thank you.
>
> Jeff
>
> --
> 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/4666d2ec-e4d8-492d-8203-03dfecd29d6a%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/CAHyB84rnKyBKR8rZbV2zij5QfK0FyA9F6DWCRo2v01QD48T%3DDQ%40mail.gmail.com.


Re: HTML code not being read

2020-03-30 Thread Luqman Shofuleji
What you passed to the context in your views.py is 'comment', but you are
looping through 'comments' in the template

On Mon, Mar 30, 2020, 3:52 PM Jeff Waters  wrote:

> Hi
>
> Thanks for getting back to me.
>
> This is from my views.py:
>
> @login_required
> def add_comment(request, image_id):
> new_comment = None
> template_name = 'add_comment.html'
> image = get_object_or_404(Picture, id=image_id)
> comment = image.comment.filter(active=True)
> new_comment = None
> # Comment posted
> if request.method == 'POST':
> comment_form = CommentForm(data=request.POST)
> if comment_form.is_valid():
> # Create Comment object and don't save to database yet
> new_comment = comment_form.save(commit=False)
> # Assign the current post to the comment
> new_comment.post = post
> # Save the comment to the database
> new_comment.save()
> else:
> comment_form = CommentForm()
>
> context = {'comment_form': comment_form, 'image': image,'comment':
> comment, 'new_comment': new_comment,'comment_form': comment_form}
>
> return render(request, template_name, context)
>
> Does that look correct to you?
>
> Jeff
>
> --
> 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/7f92c0a3-07cc-4b33-ba37-e32bc24c5386%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/CAHyB84o4GGgDBEPSo0wNFd1F%3DK9dXk3MzVjRFm%2BrmBtYOq%2BBZQ%40mail.gmail.com.


Re: HTML code not being read

2020-03-30 Thread Luqman Shofuleji
Let's see your url.py

On Mon, Mar 30, 2020, 10:03 PM Jeff Waters  wrote:

> I've modified my code a bit to try (unsuccessfully!) to get this working.
>
> My views.py is now as follows:
>
> @login_required
> def add_comment(request, image_id):
> new_comment = None
> template_name = 'add_comment.html'
> image = get_object_or_404(Picture, id=image_id)
> comment = image.comments.filter(active=True)
> new_comment = None
> # Comment posted
> if request.method == 'POST':
> comment_form = CommentForm(request.POST)
> if comment_form.is_valid():
> # Create Comment object and don't save to database yet
> new_comment = comment_form.save(commit=False)
> # Assign the current post to the comment
> new_comment.post = post
> # Save the comment to the database
> new_comment.save()
> else:
> comment_form = CommentForm()
>
> context = {'image': image,'comment': comment, 'new_comment':
> new_comment,'comment_form': comment_form}
>
> return render(request, template_name, context)
>
> My html code for the gallery is now:
>
> comments
> {% if not comments %}
> No comments
> {% endif %}
> {% for comment in comment %}
> 
> 
> Comment by {{ comment.user }}
> 
> {{ comment.created_on }}
> 
> 
> {{ comment.body | linebreaks }}
> 
> {% endfor %}
>
> The problem I now have is that I now get the following error message:
> Reverse for 'add_comment' with arguments '('',)' not found. 1 pattern(s)
> tried: ['add_comment/(?P[0-9]+)$']
>
> Any suggestions would be much appreciated.
>
> Thanks
>
> Jeff
>
> --
> 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/e2212e12-d379-4bcb-8c96-eff4c89c5245%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/CAHyB84rnc11SOpJJvwtyzoWkf%3D77jBjzKNctBeN3S%3D9ipKRa%3Dg%40mail.gmail.com.


Re: Working with forms

2020-04-04 Thread Luqman Shofuleji
In def Namev_view under views.py, include form in the return parameter and
see if that resolves the issue

return render(request, 'namev.html', {'form':form})



On Sat, Apr 4, 2020, 1:35 AM Ifeanyi Chielo 
wrote:

> Hello,I developed a form with a single field, but this form displays only
> the submit button at the browser as shown in the image below. Please how
> can I correct this and also  save the field to the MySQL table.  My code is
> also shown below
>
> [image: django form.png]
>
> View.py
>
> from django.http import HttpResponseRedirect
>
> from django.shortcuts import render
>
> from .models import Namerec
>
> from .forms import NameForm
>
> from django.views.generic import TemplateView
>
>
>
> def HomePageView (request, *args, **kwargs):
>
>  return render(request,"home.html", {})
>
> def Namev_view (request):
>
> if request.method == 'POST':
>
> form = NameForm (request.POST)
>
> if NameForm.is_valid():
>
> NameForm.save()
>
> context = {
>
> 'form': form
>
> }
>
> return render(request, 'namev.html', {})
>
> form.py
>
> from .models import Namerec
>
> from django import forms
>
> class NameForm(forms.Form):
>
> your_name = forms.CharField(label='Your name', max_length=100)
>
> template (namev.htlm)
>
> 
>
> {% csrf_token %}
>
> {{ form  }}
>
> 
>
> 
>
>
>
>
>
> Model.py
>
> from django.db import models
>
> class Namerec(models.Model):
>
> your_name = models.CharField(max_length=30)
>
>
>
> --
> 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/f50577dd-d5c0-4478-8993-7bab533f24f9%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/CAHyB84rUTDyiba%2B%2Bvk%3DJFuRN7CPBPTpso2JvyBc28Q4gG-faYg%40mail.gmail.com.


Re: Working with forms

2020-04-04 Thread Luqman Shofuleji
Okay, now the new error is that is not seeing that 'form' for the get
request,
you need to also add  form = NameForm () before the if statement "if
request.method == 'POST' " to handle the page get request.



On Sat, Apr 4, 2020, 12:33 PM Ifeanyi Chielo 
wrote:

> Thanks a lot,
> I did as you said and I encountered the error message below:
> UnboundLocalError at /namev/
>
> local variable 'form' referenced before assignment
>
> Request Method: GET
> Request URL: http://localhost:8000/namev/
> Django Version: 2.1.5
> Exception Type: UnboundLocalError
> Exception Value:
>
> local variable 'form' referenced before assignment
>
> Exception Location: C:\Users\IFEANYI CHIELO\divinecrownapp\pages\views.py
> in Namev_view, line 42
> Python Executable: C:\Users\IFEANYI
> CHIELO\AppData\Local\Programs\Python\Python37\python.exe
> Python Version: 3.7.2
> Python Path:
>
> ['C:\\Users\\IFEANYI CHIELO\\divinecrownapp',
>  'C:\\Users\\IFEANYI '
>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
>  'C:\\Users\\IFEANYI 
> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
>  'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib',
>  'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37',
>  'C:\\Users\\IFEANYI '
>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages']
>
> Server time: Sat, 4 Apr 2020 11:27:07 +
> Dr. Chielo C. Ifeanyi
> Chief Programmer,
> Head Webometrics Section
> ICT Unit, UNN
> 08032366433, 08154804230
> ifeanyi.chi...@unn.edu.ng
> http://www.unn.edu.ng/users/ifeanyichielo <http://www.unn.edu.ng>
>
>
>
> On Sat, Apr 4, 2020 at 10:09 AM Luqman Shofuleji 
> wrote:
>
>> In def Namev_view under views.py, include form in the return parameter
>> and see if that resolves the issue
>>
>> return render(request, 'namev.html', {'form':form})
>>
>>
>>
>> On Sat, Apr 4, 2020, 1:35 AM Ifeanyi Chielo 
>> wrote:
>>
>>> Hello,I developed a form with a single field, but this form displays
>>> only the submit button at the browser as shown in the image below. Please
>>> how can I correct this and also  save the field to the MySQL table.  My
>>> code is also shown below
>>>
>>> [image: django form.png]
>>>
>>> View.py
>>>
>>> from django.http import HttpResponseRedirect
>>>
>>> from django.shortcuts import render
>>>
>>> from .models import Namerec
>>>
>>> from .forms import NameForm
>>>
>>> from django.views.generic import TemplateView
>>>
>>>
>>>
>>> def HomePageView (request, *args, **kwargs):
>>>
>>>  return render(request,"home.html", {})
>>>
>>> def Namev_view (request):
>>>
>>> if request.method == 'POST':
>>>
>>> form = NameForm (request.POST)
>>>
>>> if NameForm.is_valid():
>>>
>>> NameForm.save()
>>>
>>> context = {
>>>
>>> 'form': form
>>>
>>> }
>>>
>>> return render(request, 'namev.html', {})
>>>
>>> form.py
>>>
>>> from .models import Namerec
>>>
>>> from django import forms
>>>
>>> class NameForm(forms.Form):
>>>
>>> your_name = forms.CharField(label='Your name', max_length=100)
>>>
>>> template (namev.htlm)
>>>
>>> 
>>>
>>> {% csrf_token %}
>>>
>>> {{ form  }}
>>>
>>> 
>>>
>>> 
>>>
>>>
>>>
>>>
>>>
>>> Model.py
>>>
>>> from django.db import models
>>>
>>> class Namerec(models.Model):
>>>
>>> your_name = models.CharField(max_length=30)
>>>
>>>
>>>
>>> --
>>> 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/f50577dd-d5c0-4478-8993-7bab533f24f9%40googlegroups

Re: I am building an open source School Management System

2020-05-08 Thread Luqman Shofuleji
Hi,

I've just forked the repository on your github account.

On Wed, May 6, 2020 at 4:21 PM Sherif Adigun  wrote:

> Thanks. Checked. Good job. I think I've got more features than you.
>
> Latest commits now have authentications
>
> On Tuesday, May 5, 2020 at 9:37:26 PM UTC+1, Sherif Adigun wrote:
>>
>> I am currently building an open source school Management System on django
>> and it's currently available on GitHub.
>>
>> https://github.com/adigunsherif/Django-School-Management-System
>>
>> I need contributors and collaboration.
>>
>> Feel free to fork me on GitHub, send a message and let's build a solution
>>
>> --
> 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/06798eec-0e61-4149-9315-9d95cf7aec65%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/CAHyB84ps0YCQz72SYbXKHcj_BYQiuOXQVHGNQpag8vHT4FA2dA%40mail.gmail.com.


Re: Django select list

2020-05-25 Thread Luqman Shofuleji
Yes that's possible since you are using Ajax. It should be something like
this:

$.ajax({
url: '{% url "" %}',
data: {
'x': ,
},
dataType: 'json',
success: function (data) {
if (data.added_item) {
item = data.added_item
$("#selectListID").append(item);

}
}
});





On Mon, May 25, 2020, 4:12 PM Sherif Adigun  wrote:

> I have a form which has a select field (your color). In front of the
> select field, I have a button that produces a popup which allows users to
> create new color before they submit. I am submitting that color form via
> Ajax. After adding a new color to the database, the popup closes.
> I want the newly added color to show in the select list without reloading
> the page.
>
> Is this possible?
>
> --
> 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/9f176d90-93e3-40f8-b02f-4d27b6b55a75%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/CAHyB84oZYZPeaokwWduQDJsnVXxSE4HYumAMGw1%3DgmVTPgyhWA%40mail.gmail.com.


Re: Django select list

2020-05-25 Thread Luqman Shofuleji
Little adjustment,


$.ajax({
url: '{% url "" %}',
data: {
'x': ,
},
dataType: 'json',
success: function (data) {
if (data.added_item) {
item = ""
 + data.added_item + "";
$("#selectListID").append(item);
}
    }
});



On Mon, May 25, 2020 at 7:56 PM Luqman Shofuleji 
wrote:

> Yes that's possible since you are using Ajax. It should be something like
> this:
>
> $.ajax({
> url: '{% url "" %}',
> data: {
> 'x': ,
> },
> dataType: 'json',
> success: function (data) {
> if (data.added_item) {
> item = data.added_item
> $("#selectListID").append(item);
>
> }
> }
> });
>
>
>
>
>
> On Mon, May 25, 2020, 4:12 PM Sherif Adigun 
> wrote:
>
>> I have a form which has a select field (your color). In front of the
>> select field, I have a button that produces a popup which allows users to
>> create new color before they submit. I am submitting that color form via
>> Ajax. After adding a new color to the database, the popup closes.
>> I want the newly added color to show in the select list without reloading
>> the page.
>>
>> Is this possible?
>>
>> --
>> 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/9f176d90-93e3-40f8-b02f-4d27b6b55a75%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/CAHyB84pUQW48GvSL%2BHdQ3hzVRW9Bh4a6wtA0Tprz0bPkHXns_A%40mail.gmail.com.


Re: Issue with CRUD Operation

2020-05-26 Thread Luqman Shofuleji
Hi,

Please also attach the code of your list template where the delete is been
executed.

On Mon, May 25, 2020 at 1:39 AM Ifeanyi Chielo 
wrote:

> Hello,
> I performed a CRUD operation and every thing is working well except two
> things
> 1. my insert form does not clear the text boxes after saving a record
> 2. my delete operation renders an error page after deleting a record with
> a message ''DoesNotExist at /delete/3/" or "AttributeError at /delete/6/"
> example of the error messages are  shown below. i also attached view.py,
> model.py and template file
>
> DoesNotExist at /delete/3/
>
> Soapprod matching query does not exist.
>
> *Request Method:*
>
> POST
>
> *Request URL:*
>
> http://localhost:8000/delete/3/
>
> *Django Version:*
>
> 2.1.5
>
> *Exception Type:*
>
> DoesNotExist
>
> *Exception Value:*
>
> Soapprod matching query does not exist.
>
> *Exception Location:*
>
> C:\Users\IFEANYI
> CHIELO\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\query.py
> in get, line 399
>
> *Python Executable:*
>
> C:\Users\IFEANYI CHIELO\AppData\Local\Programs\Python\Python37\python.exe
>
> *Python Version:*
>
> 3.7.2
>
> *Python Path:*
>
> ['C:\\Users\\IFEANYI CHIELO\\divinecrown',
>
>  'C:\\Users\\IFEANYI '
>
>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
>
>  'C:\\Users\\IFEANYI
> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
>
>  'C:\\Users\\IFEANYI
> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib',
>
>  'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37',
>
>  'C:\\Users\\IFEANYI '
>
>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages']
>
> *Server time:*
>
> Mon, 25 May 2020 00:03:25 +
>
>
> or
>
>
> AttributeError at /delete/6/
>
> 'str' object has no attribute 'get'
>
> *Request Method:*
>
> POST
>
> *Request URL:*
>
> http://localhost:8000/delete/6/
>
> *Django Version:*
>
> 2.1.5
>
> *Exception Type:*
>
> AttributeError
>
> *Exception Value:*
>
> 'str' object has no attribute 'get'
>
> *Exception Location:*
>
> C:\Users\IFEANYI
> CHIELO\AppData\Local\Programs\Python\Python37\lib\site-packages\django\middleware\clickjacking.py
> in process_response, line 26
>
> *Python Executable:*
>
> C:\Users\IFEANYI CHIELO\AppData\Local\Programs\Python\Python37\python.exe
>
> *Python Version:*
>
> 3.7.2
>
> *Python Path:*
>
> ['C:\\Users\\IFEANYI CHIELO\\divinecrown',
>
>  'C:\\Users\\IFEANYI '
>
>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
>
>  'C:\\Users\\IFEANYI
> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
>
>  'C:\\Users\\IFEANYI
> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib',
>
>  'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37',
>
>  'C:\\Users\\IFEANYI '
>
>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages']
>
> *Server time:*
>
> Mon, 25 May 2020 00:09:23 +
>
> --
> 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/b43b280d-ab19-4620-8544-133c897396f0%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/CAHyB84pa3CX7c08v1vsomx5Xvau%2B1NYYx8X-2eSO9j_2vHyikA%40mail.gmail.com.


Re: Issue with CRUD Operation

2020-05-26 Thread Luqman Shofuleji
To clear your form after submit, just re-assign an empty form object after
the form.save(). See below

def soapprod_form (request, id=0):
if request.method == "GET":
if id == 0:
form = SoapprodForm()
else:
soapprod = Soapprod.objects.get(pk=id)
form = SoapprodForm (instance=soapprod)
return render(request, "soapprod_form.html", {'form': form})
else:
if id == 0:
form = SoapprodForm(request.POST)
else:
soapprod = Soapprod.objects.get(pk=id)
form = SoapprodForm(request.POST,instance= soapprod)
if form.is_valid():
form.save()
form = SoapprodForm()
return render(request, "soapprod_form.html", {'form': form})

On Tue, May 26, 2020 at 8:07 AM Luqman Shofuleji 
wrote:

> Hi,
>
> Please also attach the code of your list template where the delete is been
> executed.
>
> On Mon, May 25, 2020 at 1:39 AM Ifeanyi Chielo 
> wrote:
>
>> Hello,
>> I performed a CRUD operation and every thing is working well except two
>> things
>> 1. my insert form does not clear the text boxes after saving a record
>> 2. my delete operation renders an error page after deleting a record with
>> a message ''DoesNotExist at /delete/3/" or "AttributeError at
>> /delete/6/"
>> example of the error messages are  shown below. i also attached view.py,
>> model.py and template file
>>
>> DoesNotExist at /delete/3/
>>
>> Soapprod matching query does not exist.
>>
>> *Request Method:*
>>
>> POST
>>
>> *Request URL:*
>>
>> http://localhost:8000/delete/3/
>>
>> *Django Version:*
>>
>> 2.1.5
>>
>> *Exception Type:*
>>
>> DoesNotExist
>>
>> *Exception Value:*
>>
>> Soapprod matching query does not exist.
>>
>> *Exception Location:*
>>
>> C:\Users\IFEANYI
>> CHIELO\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\query.py
>> in get, line 399
>>
>> *Python Executable:*
>>
>> C:\Users\IFEANYI CHIELO\AppData\Local\Programs\Python\Python37\python.exe
>>
>> *Python Version:*
>>
>> 3.7.2
>>
>> *Python Path:*
>>
>> ['C:\\Users\\IFEANYI CHIELO\\divinecrown',
>>
>>  'C:\\Users\\IFEANYI '
>>
>>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
>>
>>  'C:\\Users\\IFEANYI
>> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
>>
>>  'C:\\Users\\IFEANYI
>> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib',
>>
>>  'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37',
>>
>>  'C:\\Users\\IFEANYI '
>>
>>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages']
>>
>> *Server time:*
>>
>> Mon, 25 May 2020 00:03:25 +
>>
>>
>> or
>>
>>
>> AttributeError at /delete/6/
>>
>> 'str' object has no attribute 'get'
>>
>> *Request Method:*
>>
>> POST
>>
>> *Request URL:*
>>
>> http://localhost:8000/delete/6/
>>
>> *Django Version:*
>>
>> 2.1.5
>>
>> *Exception Type:*
>>
>> AttributeError
>>
>> *Exception Value:*
>>
>> 'str' object has no attribute 'get'
>>
>> *Exception Location:*
>>
>> C:\Users\IFEANYI
>> CHIELO\AppData\Local\Programs\Python\Python37\lib\site-packages\django\middleware\clickjacking.py
>> in process_response, line 26
>>
>> *Python Executable:*
>>
>> C:\Users\IFEANYI CHIELO\AppData\Local\Programs\Python\Python37\python.exe
>>
>> *Python Version:*
>>
>> 3.7.2
>>
>> *Python Path:*
>>
>> ['C:\\Users\\IFEANYI CHIELO\\divinecrown',
>>
>>  'C:\\Users\\IFEANYI '
>>
>>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\python37.zip',
>>
>>  'C:\\Users\\IFEANYI
>> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
>>
>>  'C:\\Users\\IFEANYI
>> CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib',
>>
>>  'C:\\Users\\IFEANYI CHIELO\\AppData\\Local\\Programs\\Python\\Python37',
>>
>>  'C:\\Users\\IFEANYI '
>>
>>  'CHIELO\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages']
>>
>> *Server time:*
>>
>> Mon, 25 May 2020 00:09:23 +
>>
>> --
>> 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/b43b280d-ab19-4620-8544-133c897396f0%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/b43b280d-ab19-4620-8544-133c897396f0%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/CAHyB84qbzBMJM7VmPSvvVrMy5QW0ku1mmBVY4RdDrZxjYYdu0w%40mail.gmail.com.


Re: list cycle in template

2019-10-09 Thread Luqman Shofuleji
Sorry little mistake there:

Then in your template:
  
{% for a in mylist %}
  {{ a }}
{% endfor %}
  

On Wed, Oct 9, 2019 at 2:27 PM Luqman Shofuleji 
wrote:

> 1) you forgot to include  {% endfor %} in you template
>
> 2) I believe in your view all you actually need is:
> mylist = ['aa','bb']
> return render({'mylist':mylist})
>
> Then in your template:
>   
> {% for a in mylist %}
>   {{ mylist }}
> {% endfor %}
>   
>
>
>
>
>
>
>
> On Wed, Oct 9, 2019 at 9:17 AM Luca Bertolotti <
> luca72.bertolo...@gmail.com> wrote:
>
>> Hello in the view a hve a list
>> mylist = ['aa','bb']
>> n = range(len(mylist))
>>
>> return render({'mylist':mylist,'n':n,.})
>>
>> in the template i do this:
>>
>> {% for a in n %} {{ mylist.a }}
>>
>> it never show nothing, but if i do:
>>
>> {% for a in n %} {{ mylist.0 }}
>> it show 'aa'
>>
>> Where is the mistake?
>>
>> 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/af0a2286-6bf9-4b9e-9a77-626ae5309ee6%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/af0a2286-6bf9-4b9e-9a77-626ae5309ee6%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/CAHyB84oU7rQNRgX5fQ47YPOkF-R1Z-0%3DYMY6qf6%2BLF6ht0D5eA%40mail.gmail.com.


Re: list cycle in template

2019-10-09 Thread Luqman Shofuleji
1) you forgot to include  {% endfor %} in you template

2) I believe in your view all you actually need is:
mylist = ['aa','bb']
return render({'mylist':mylist})

Then in your template:
  
{% for a in mylist %}
  {{ mylist }}
{% endfor %}
  







On Wed, Oct 9, 2019 at 9:17 AM Luca Bertolotti 
wrote:

> Hello in the view a hve a list
> mylist = ['aa','bb']
> n = range(len(mylist))
>
> return render({'mylist':mylist,'n':n,.})
>
> in the template i do this:
>
> {% for a in n %} {{ mylist.a }}
>
> it never show nothing, but if i do:
>
> {% for a in n %} {{ mylist.0 }}
> it show 'aa'
>
> Where is the mistake?
>
> 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/af0a2286-6bf9-4b9e-9a77-626ae5309ee6%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/CAHyB84pPtNxB1iPuOiKBi_nuk1syze5zeB2KraERdOPoh5yriA%40mail.gmail.com.


Re: How to write raw SQL or ORM for Count

2019-12-02 Thread Luqman Shofuleji
You need to do some little reading about Django aggregation
https://docs.djangoproject.com/en/2.2/topics/db/aggregation/#topics-db-aggregation


Example
from django.db.models import Max, Count, Sum
Publisher.objects.values('name').annotate(*dcount*=Count('name'))

As seen above you can apply similar method to get Max, Sum and others


On Mon, Dec 2, 2019 at 2:43 PM xiaopeng luo  wrote:

> I am new to django ORM, I want query something like this:
>
> input:
> AAAfemale1
> AAAfemale2
> BBBmale   1
> BBBmale   3
> AAAmale   2
>
>
>
> output
> AAAfemale3
> AAAmale   2
> BBBmale   4
>
>
> Sorry, my english is not good. Thanks for everyone 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/a297dc1f-6821-4bba-b04c-e8ce271b5a8d%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/CAHyB84qihZj5mVNnL2C-BmE%3D2RAdsvVoOYfrfiH04BaPQ%3D5E2Q%40mail.gmail.com.


Re: Can I perform calculations directly in django tags/filters?

2019-12-18 Thread Luqman Shofuleji
Try using django-mathfilters.

https://pypi.org/project/django-mathfilters/

On Wed, Dec 18, 2019, 11:55 PM Adeotun Adegbaju 
wrote:

> you should indicate which files codes should be added to
>
> On Tuesday, November 18, 2008 at 11:21:09 PM UTC+1, Daniel Roseman wrote:
>>
>> On Nov 18, 7:55 pm, jago  wrote:
>> > I am thinking about something like {{  (width - 5) *12  }}  ?
>>
>> No. You can add or subtract using the 'add' filter:
>> {{ width:add:"-5" }}
>> but anything else will require a custom template tag or filter.
>> Luckily, these are extremely easy to write:
>>
>> @register.filter
>> def multiply(value, arg}
>> return int(value) * int(arg)
>>
>> {{ width|multiply:12 }}
>>
>> You'll want to add error checking and so on of course, but that's the
>> idea.
>>
>> --
>> DR.
>
> --
> 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/3b901f38-024c-47b6-9794-c116b6d9913c%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/CAHyB84oAnfmwOqZOu5gqhyGE%2BFa0Z49Nj2WRNCfide-5v2vaaw%40mail.gmail.com.