Re: UPLOAD STATIC FILES

2023-05-29 Thread sum abiut
in your setting make sure you have
STATIC_URL = '/static/'

then in your template
you load static at the top of your htmi file like this.
{% load static %}
to load any static files like css. do something like this
{% static './cssfile.css'%}

Then run the command. python manage.py collectstatic


On Tue, May 30, 2023 at 3:05 PM SHUBHAM KUMAR 
wrote:

> you should add STATIC_DIR =[
>
> 'BASE'/ 'static'
>
> ]
> to your project settings
>
> On Mon, 29 May, 2023, 9:21 pm Music Fm,  wrote:
>
>> Load static
>>
>> Open a folder call it static then open another file within the static
>> forder.
>>
>> Now type {load static/custom.css }on the html file it will see the static
>> that has the css and javascript file
>>
>> On Mon, May 29, 2023, 4:31 PM Obiorah Callistus 
>> wrote:
>>
>>> please how can i display .css and .js files in my template
>>>
>>> --
>>> 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/5a2ceeec-20f1-46aa-98b9-717c9965b82dn%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/CAEXS5w%2B5m5ASCFR0YL%3Dt7CPWk%3DM__UVtTtHfLyJ1xcBZzFaEXw%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/CAA8iRFd7-sv1c4oPmP9Xt99aRzUVSUw4p8Via8nBN4wOLwoHbw%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/CAPCf-y5z2HzLXNn6BJZf%2BeDDBJvrDRmyjQweEFkhFEcrDH%3D3fg%40mail.gmail.com.


Re: Django date time picker

2023-05-29 Thread sum abiut
You can use model forms and do something like this:
1) create your model. for instance
class DatePickerModel(models.Model):
start_date = models.DateTimeField()
end_date = models.DateTimeField()
2) create your form
  # setup date picker start
class DateInput(forms.DateInput):
input_type = 'date'


class DatePickerForm(forms.ModelForm):
class Meta:
model = DatePickerModel
widgets = {'date': forms.DateInput(attrs={'class': 'datepicker'})}
fields = ['start_date', 'end_date']
widgets = {
'start_date': DateInput(), 'end_date': DateInput()
}
error_messages = {
'start_date': {'required': ''},
'end_date': {'required': ''}
}

3) in your html
 
{% csrf_token %}
{{ form.as_p }}
submit


On Tue, May 30, 2023 at 4:20 AM Bhuvnesh Sharma 
wrote:

> You can also use
> https://github.com/monim67/django-bootstrap-datepicker-plus
>
> It is really good and easy to integrate.
>
> On Mon, May 29, 2023, 10:48 PM Larry Martell 
> wrote:
>
>> On Mon, May 29, 2023 at 1:14 PM Thomas Mutavi 
>> wrote:
>> >
>> > Hello, how  can i implement a form with several date fields which have
>> date and time picker in django?
>>
>> You can use the jQuery UI datetimepicker.
>>
>> --
>> 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/CACwCsY72xpH90NiaJMQCWeziz%3DqPZcnDPZewBVt3BHMSjVcowQ%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/CA%2BZJHEoFJ%2Bgys1kEqO7bL%3D%2BxS-KiSnp_fdZzX79qGDi9ZND9hA%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/CAPCf-y4_gx5vJ%2ByAyW232Fq-Y0-ZYhcCamNDDqc0AT-a5s16Kw%40mail.gmail.com.


Re: DateTime widget in default CreateView form

2021-10-07 Thread sum abiut
You can use modelform.

in your form.py you can do something like this

# setup date picker start
class DateInput(forms.DateInput):
input_type = 'date'


class Formname(forms.ModelForm):
 class Meta:
 model= yourmodel
 fields = ('datefield')
 widgets ={'datefield': DateInput() }






On Fri, Oct 8, 2021 at 11:01 AM Anil Felipe Duggirala <
anilduggir...@fastmail.fm> wrote:

> hello,
> I have tried to find an answer to this question online, with no clear
> response.
> I have created a simple class based CreateView for a model that has a
> DateTime attribute.
> Simply rendering the form using the {{ form.as_p }} tag in the template
> associated to the aforementioned view does not give me a DateTime widget in
> the form.
>
> What is the easiest way or most standard way to achieve this?
> I have read something about ModelForm, should I use that? Would that
> automatically give me a widget in the rendered HTML?
>
> I would also like to know, how would I render that form using crispy
> forms?
>
> Thanks very much for your help.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c101be88-2409-4a12-b97b-1af7aa30048c%40www.fastmail.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/CAPCf-y5-jm1Q0SL0-HpCs%3DSyfFYDHqx_BBxBDs%3DGxjDY9gPJ5Q%40mail.gmail.com.


Re: Defining a custom email backend

2021-09-22 Thread sum abiut
You can create your own connection and then pass to send_mail()

connection = get_connection(host=my_host,
port=my_port,
username=my_username,
password=my_password,
use_tls=my_use_tls)

send_mail('subject', 'test message', 'from_email', ['to'],
connection=connection)


On Thu, Sep 23, 2021 at 4:40 PM Sujata Aghor 
wrote:

> *settings.py : *
> DEFAULT_FROM_EMAIL = '*'
> EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
> EMAIL_HOST = 'smtp.gmail.com'
> EMAIL_USE_TLS = True
> EMAIL_PORT = ***
> EMAIL_HOST_USER = '*"
> EMAIL_HOST_PASSWORD = '***"
>
>
> *script.py :*
>
> from_email = DEFAULT_FROM_EMAIL
> vars_dict = dict(tasks=usr_tasks,
>  reminder=reminder,
>  reseller=reseller,
>  logo=logo,
>  host=host,
>  )
>
> # get values: r_email and r_pass specific to this reseller
> r_obj = Reseller.objects.get(id=rid)
> r_email = r_obj.remail if r_obj.remail else None
> r_pass = r_obj.rpass if r_obj.rpass else None
>
> html_message = loader.render_to_string(
> template,vars_dict)
>
> if subject and message and from_email:
> print("Sending mail to %s"%recipient)
> try:
> if r_email and r_pass:
>
> send_mail(subject,message,from_email,recipient,fail_silently=True,
> EMAIL_HOST_USER=r_email,
> EMAIL_HOST_PASSWORD=r_pass, html_message=html_message)
> else:
>
> send_mail(subject,message,from_email,recipient,fail_silently=True,html_message=html_message)
> except Exception as e:
> print(e)
> else:
> print("Mail sent successfully!")
>
>
> -
> Roughly this is my code.
> in line -
> send_mail(subject,message,from_email,recipient,fail_silently=True,
> EMAIL_HOST_USER=r_email,
> EMAIL_HOST_PASSWORD=r_pass, html_message=html_message)
> its giving me error - send_mail() got an unexpected keyword argument
> 'EMAIL_HOST_USER'
>
> Can you suggest anything about this ?
> Thanks
>
>
> On Thu, Sep 23, 2021 at 10:57 AM sum abiut  wrote:
>
>> If you don't mind sharing your code here.
>>
>> cheers,
>>
>> On Thu, Sep 23, 2021 at 4:17 PM Sujata Aghor 
>> wrote:
>>
>>> Hello Everyone,
>>> I want to use different values of - EMAIL_HOST_USER &
>>> EMAIL_HOST_PASSWORD for each of my users. I will take those values from
>>> database and not from settings.py
>>>
>>> In django documentation I can see only a single paragraph about defining
>>> a custom email backend, which is not giving me enough ideas.
>>>
>>> If I Try to change value of EMAIL_HOST_USER in script, it gives me below
>>> error -
>>> send_mail() got an unexpected keyword argument 'EMAIL_HOST_USER'
>>> How to change these two values in a script?
>>> Can anyone help here please.
>>>
>>>
>>> --
>>>
>>> Thanks & Regards!
>>> Sujata S. Aghor
>>>
>>> --
>>> 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/CAJCP8KC9Acj36VhnY1UqnpFtVb_xGLkZgmZJgPyugdhmH2QvOQ%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAJCP8KC9Acj36VhnY1UqnpFtVb_xGLkZgmZJgPyugdhmH2QvOQ%40mail.gmail.com?utm_medium=email_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/CAPCf-y7FU4Emm28oKcZD09gwA78kzPAzN56XbynNHMrUDBAvMA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAPCf-y7FU4Emm28oKcZD09gwA78kzPAzN56XbynNHMrUDBAvMA%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
>

Re: Defining a custom email backend

2021-09-22 Thread sum abiut
If you don't mind sharing your code here.

cheers,

On Thu, Sep 23, 2021 at 4:17 PM Sujata Aghor 
wrote:

> Hello Everyone,
> I want to use different values of - EMAIL_HOST_USER & EMAIL_HOST_PASSWORD
> for each of my users. I will take those values from database and not from
> settings.py
>
> In django documentation I can see only a single paragraph about defining a
> custom email backend, which is not giving me enough ideas.
>
> If I Try to change value of EMAIL_HOST_USER in script, it gives me below
> error -
> send_mail() got an unexpected keyword argument 'EMAIL_HOST_USER'
> How to change these two values in a script?
> Can anyone help here please.
>
>
> --
>
> Thanks & Regards!
> Sujata S. Aghor
>
> --
> 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/CAJCP8KC9Acj36VhnY1UqnpFtVb_xGLkZgmZJgPyugdhmH2QvOQ%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/CAPCf-y7FU4Emm28oKcZD09gwA78kzPAzN56XbynNHMrUDBAvMA%40mail.gmail.com.


iterate over query set

2021-07-26 Thread sum abiut
I am trying to get the values of the userid by iterating through the
queryset. However not all the values are displayed. I am not sure why I am
not getting all the values when I iterate through it.

users - Users.objects.filter(depid=get_department[0].depid)
print(users) #when i test it here it pring all the values
#however it only prints one value when i loop through it below. i want to
be able to print all the #values
for a in users:
  print(a)# this only print value for the first user

-- 
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/CAPCf-y65WJVjZC2PA4tz3ZubOtP5CjLtdHegiThhRnK8W5hSiw%40mail.gmail.com.


Re: connection to an existing legacy database

2021-07-20 Thread sum abiut
It was simplet fix. department was set to managed =True, i set that to
False  and it fixed the problem.

Cheers

On Wed, Jul 21, 2021 at 1:43 AM Divyesh Khamele  wrote:

>
> If you have any doubt I’ll provide you all the solutions (Dm for paid work)
> On Tue, 20 Jul 2021 at 5:29 AM, sum abiut  wrote:
>
>> I am trying to connect Django to an existing legacy database but I got
>> this error message. I only get the message why I try to migrate. I follow
>> the guide from the Django documentation
>> <https://docs.djangoproject.com/en/3.2/howto/legacy-databases/>.
>> error message:
>> django.db.utils.ProgrammingError: ('42S01', "[42S01] [Microsoft][ODBC
>> Driver 17 for SQL Server][SQL Server]There is already an object named
>> 'Department' in the database. (2714) (SQLExecDirectW)")
>>
>>
>> --
>> 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/CAPCf-y68HNmO3yzkgLhhoY18Tav7U6KE-YxXRvcPOXVc1__6FA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAPCf-y68HNmO3yzkgLhhoY18Tav7U6KE-YxXRvcPOXVc1__6FA%40mail.gmail.com?utm_medium=email_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/CAOcoDQX0Bio_2wcQ%2BCCvZZwfuX3h8bhjOc%2BGXqNN292bG_K9dw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAOcoDQX0Bio_2wcQ%2BCCvZZwfuX3h8bhjOc%2BGXqNN292bG_K9dw%40mail.gmail.com?utm_medium=email_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/CAPCf-y5aY7yfe%3DZXmmOywAqftb7s46EMo-qyeD9%3D8MmzBj6pyg%40mail.gmail.com.


connection to an existing legacy database

2021-07-19 Thread sum abiut
I am trying to connect Django to an existing legacy database but I got this
error message. I only get the message why I try to migrate. I follow the
guide from the Django documentation
.
error message:
django.db.utils.ProgrammingError: ('42S01', "[42S01] [Microsoft][ODBC
Driver 17 for SQL Server][SQL Server]There is already an object named
'Department' in the database. (2714) (SQLExecDirectW)")

-- 
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/CAPCf-y68HNmO3yzkgLhhoY18Tav7U6KE-YxXRvcPOXVc1__6FA%40mail.gmail.com.


Re: counting the same words within a song added by a user using Django

2021-07-11 Thread sum abiut
I might not fully understand your question. Can you show me what you have
done? show us your models and what you want to achieve.



On Fri, Jul 9, 2021 at 4:57 PM DJANGO DEVELOPER 
wrote:

> sum it is giving me error of TextField is not iterable
>
> On Wed, Jul 7, 2021 at 5:30 AM DJANGO DEVELOPER 
> wrote:
>
>> so will it run smoothly?
>> I mean there is no filter function there so will it filter a specific
>> field and will give me count for the words?
>>
>> On Tue, Jul 6, 2021 at 9:40 PM sum abiut  wrote:
>>
>>> You can to something like this
>>>
>>> def count_songs(request):
>>> #get the field that you want to count the words in it
>>> field_name = model._meta.get_field('your_field)
>>>
>>> word_count =Counter(field_name)
>>>
>>> for key, value in word_count.items():
>>>
>>>   key = key
>>>
>>>   value=value
>>>
>>> context={
>>>
>>> 'key':key,
>>>
>>> 'value':value,
>>> }
>>>
>>> return render(request, 'template.html', context)
>>>
>>>
>>>
>>> On Tue, Jul 6, 2021 at 7:09 PM lalit suthar 
>>> wrote:
>>>
>>>> cool :D
>>>>
>>>> On Tuesday, 6 July 2021 at 10:25:06 UTC+5:30 abubak...@gmail.com wrote:
>>>>
>>>>> I found this as well. and I think  I want the result this way.
>>>>>
>>>>> On Tue, Jul 6, 2021 at 9:21 AM Lalit Suthar 
>>>>> wrote:
>>>>>
>>>>>> [image: Screen Shot 2021-07-06 at 9.50.12 AM.png]
>>>>>> Counter works with words also
>>>>>>
>>>>>> nice one Simon Charette learned something new :)
>>>>>>
>>>>>> On Tue, 6 Jul 2021 at 07:56, DJANGO DEVELOPER 
>>>>>> wrote:
>>>>>>
>>>>>>> thanks Simon but I am not using postgresql. I am using sqlite3
>>>>>>> database. so I want a global solution, that work in all the databases.
>>>>>>>
>>>>>>> On Tue, Jul 6, 2021 at 1:54 AM Simon Charette 
>>>>>>> wrote:
>>>>>>>
>>>>>>>> If you're using a PostgreSQL you might want to look at using a tsvector
>>>>>>>> column instead which will ignore stop words (the, or, of, ...) and map
>>>>>>>> lexemes to their number of occurrence and position in the
>>>>>>>> lyrics[0]. Assuming you were to index this column you'd be able to
>>>>>>>> efficiently query it for existence of a particular lexeme or multiple 
>>>>>>>> of
>>>>>>>> them.
>>>>>>>>
>>>>>>>> You could then a union of all a user's song lyrics tsvector and
>>>>>>>> even apply weights based on their listening frequency or their favorite
>>>>>>>> songs.
>>>>>>>>
>>>>>>>> Cheers,
>>>>>>>> Simon
>>>>>>>>
>>>>>>>> [0]
>>>>>>>> https://stackoverflow.com/questions/25445670/retrieving-position-and-number-of-lexem-occurrences-from-tsvector
>>>>>>>> Le lundi 5 juillet 2021 à 13:51:48 UTC-4, abubak...@gmail.com a
>>>>>>>> écrit :
>>>>>>>>
>>>>>>>>> Thank you Lalit bhai.
>>>>>>>>> it seems to be a solution.
>>>>>>>>> but what if I want to get the result for each single word rather
>>>>>>>>> than single letter?
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Mon, Jul 5, 2021 at 5:43 PM Lalit Suthar 
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>> https://www.guru99.com/python-counter-collections-example.html
>>>>>>>>>> Counter can be helpful for this situation
>>>>>>>>>>
>>>>>>>>>> On Mon, 5 Jul 2021 at 17:07, DJANGO DEVELOPER <
>>>>>>>>>> abubak...@gmail.com> wrote:
>>>>>>>>>>
>>>>>>>>>>> Hi there.
>>>>>>>>>>> I am developing a project based on adding songs to the user's
>>>>>>>>>>> library and to the home page

Re: Role based Authentication

2021-07-07 Thread sum abiut
>From the admin site you can create different groups and then assign
specific users to specific groups.
then  filter users' roles based on the specific group that you have
assigned them to.



On Thu, Jul 8, 2021 at 3:53 AM Lalit Suthar 
wrote:

> you can extend User model and have a role field in default User model
>
> https://simpleisbetterthancomplex.com/tutorial/2016/07/22/how-to-extend-django-user-model.html
>
> On Wed, 7 Jul 2021 at 20:47, Avi shah  wrote:
>
>> https://github.com/Avishah123/Multi-user-auth1
>>
>> On Wed, Jul 7, 2021 at 8:16 PM DJANGO DEVELOPER 
>> wrote:
>>
>>> f
>>>
>>> On Wed, Jul 7, 2021 at 7:07 PM LokRaj Kumar Vuppu <
>>> lokrajkumarvu...@gmail.com> wrote:
>>>
 How to assign a role to user when registered into our application.

 --
 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/21f87894-278b-4705-83cb-9a426ea85ee7n%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/CAKPY9pn6SGzjAsfTpoMJPeXBn0XSyNcW-ko8rJ%2BUH-WksRr-oA%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/CALa7AFOCSQ-cr1pkBTVzDmZvH7b2%3DEb7TPcjHK%2BkhaonuwL%2BRQ%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/CAGp2JVEvTHTGsdFbrk5w_b%2B_h9T4u0rnL4R-Zr2TWBt12PyhYA%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/CAPCf-y6tk1KO50uJg5d94HfGAfiYXfcDJd3fL-UPF8HWO3Q7qw%40mail.gmail.com.


Re: counting the same words within a song added by a user using Django

2021-07-06 Thread sum abiut
You can to something like this

def count_songs(request):
#get the field that you want to count the words in it
field_name = model._meta.get_field('your_field)

word_count =Counter(field_name)

for key, value in word_count.items():

  key = key

  value=value

context={

'key':key,

'value':value,
}

return render(request, 'template.html', context)



On Tue, Jul 6, 2021 at 7:09 PM lalit suthar 
wrote:

> cool :D
>
> On Tuesday, 6 July 2021 at 10:25:06 UTC+5:30 abubak...@gmail.com wrote:
>
>> I found this as well. and I think  I want the result this way.
>>
>> On Tue, Jul 6, 2021 at 9:21 AM Lalit Suthar  wrote:
>>
>>> [image: Screen Shot 2021-07-06 at 9.50.12 AM.png]
>>> Counter works with words also
>>>
>>> nice one Simon Charette learned something new :)
>>>
>>> On Tue, 6 Jul 2021 at 07:56, DJANGO DEVELOPER 
>>> wrote:
>>>
 thanks Simon but I am not using postgresql. I am using sqlite3
 database. so I want a global solution, that work in all the databases.

 On Tue, Jul 6, 2021 at 1:54 AM Simon Charette 
 wrote:

> If you're using a PostgreSQL you might want to look at using a tsvector
> column instead which will ignore stop words (the, or, of, ...) and map
> lexemes to their number of occurrence and position in the lyrics[0].
> Assuming you were to index this column you'd be able to efficiently query
> it for existence of a particular lexeme or multiple of them.
>
> You could then a union of all a user's song lyrics tsvector and even
> apply weights based on their listening frequency or their favorite songs.
>
> Cheers,
> Simon
>
> [0]
> https://stackoverflow.com/questions/25445670/retrieving-position-and-number-of-lexem-occurrences-from-tsvector
> Le lundi 5 juillet 2021 à 13:51:48 UTC-4, abubak...@gmail.com a
> écrit :
>
>> Thank you Lalit bhai.
>> it seems to be a solution.
>> but what if I want to get the result for each single word rather than
>> single letter?
>>
>>
>> On Mon, Jul 5, 2021 at 5:43 PM Lalit Suthar 
>> wrote:
>>
>>> https://www.guru99.com/python-counter-collections-example.html
>>> Counter can be helpful for this situation
>>>
>>> On Mon, 5 Jul 2021 at 17:07, DJANGO DEVELOPER 
>>> wrote:
>>>
 Hi there.
 I am developing a project based on adding songs to the user's
 library and to the home page.
 other users can also purchase the songs like wise people do
 shopping on eCommerce stores.
 *Problem:(Question)*
 The problem that I want to discuss here is that when a user adds a
 sing through django forms, and now that song is added to the user's
 personal library.
 now what I want to do is :


 *When the lyrics of a song are added as a record to the "Song"
 table, the individual words in that song should be added to a 2nd table
 with their frequency of usage within that song (so the words need to be
 counted and a signal needs to be created).Also, when a user adds the 
 song
 to his/her personal library, all of the words from the song and their
 frequencies within that song should be added to another table and
 associated with that user.*

 how to count same word within a song?

 can anyone help me here?
 your help would be appreciated.

 --
 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/bc7bc37b-6f26-465c-b330-d275ab86b76an%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...@googlegroups.com.
>>>
>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAGp2JVHuos6d4%3D-_S%3DR-q8hq48Yzf%3D-xgmPziKEA2a3DYXAzbg%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...@googlegroups.com.
> To view this discussion on the web visit
> 

Re: hello i need a help

2021-07-05 Thread sum abiut
The error message is very clear send_mass_mail only expect  4 values but
you are passing in more than four.
You should only pass in four values.

datatuple = (
('f_subject', 'f_message','f_email',
['mygm...@gmail.com']),
# second person
('f_subject', 'f_message','f_email',
['sec...@gmail.com'])
)


send_mass_mail(datatuple)


refer to the documentations



On Tue, Jul 6, 2021 at 3:14 AM Richard Dushime 
wrote:

> i am getting this error down  when trying to submit  my form data to email
> {{ ValueError at /contact
>
> too many values to unpack (expected 4)
>
> Request Method: POST
> Request URL: http://localhost:8000/contact
> Django Version: 3.2.4
> Exception Type: ValueError
> Exception Value:
>
> too many values to unpack (expected 4)
>
> Exception Location:
> C:\Users\RDM\Envs\env\lib\site-packages\django\core\mail\__init__.py,
> line 83, in 
> Python Executable: C:\Users\RDM\Envs\env\Scripts\python.exe
> Python Version: 3.9.6
> Python Path:
>
> ['C:\\Users\\RDM\\Desktop\\Web\\KVC\\KVC',
>  'c:\\users\\rdm\\appdata\\local\\programs\\python\\python39\\python39.zip',
>  'c:\\users\\rdm\\appdata\\local\\programs\\python\\python39\\DLLs',
>  'c:\\users\\rdm\\appdata\\local\\programs\\python\\python39\\lib',
>  'c:\\users\\rdm\\appdata\\local\\programs\\python\\python39',
>  'C:\\Users\\RDM\\Envs\\env',
>  'C:\\Users\\RDM\\Envs\\env\\lib\\site-packages']
>
>
>
> Mon, 05 Jul 2021 15:04:30 +00
> }}}
>
>
> my settings
> EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
> EMAIL_HOST = 'smtp.gmail.com'
> EMAIL_PORT = '587'
> EMAIL_HOST_USER = 'myacco...@gmail.com'
> EMAIL_HOST_PASSWORD = 'almxfemqayldytab'
> EMAIL_USE_TLS = True
>
> here is my views.py
>
> def contact(request):
> if request.method == 'POST':
> f_name = request.POST['name']
> f_email = request.POST['email']
> f_subject = request.POST['subject']
> f_message = request.POST['message']
>
> # send mail function
> datatuple = (
> ('f_name','f_subject', 'f_message','f_email',
> ['mygm...@gmail.com']),
> # second person
> ('f_name','f_subject', 'f_message','f_email',
> ['sec...@gmail.com'])
> )
> send_mass_mail(datatuple)
>
> if send_mass_mail(datatuple):
> messages.info(request,'thank you for contacting us')
> return redirect('contact')
> else:
> messages.info(request, 'try again sorry for inconveniency')
> return redirect('contact')
> else:
> messages.info(request, 'try again sorry for inconveniency')
> return redirect('contact')
>
>
>
>
> here down urls.py
>
> path("contact", views.contact, name="contact"),
>
> then my form html
>
>
>   "php-email-form" data-aos="fade-left">
>   {% csrf_token %}
>   
> 
>"name" placeholder="Your Name" data-rule="minlen:4" data-msg=
> "Please enter at least 4 chars" />
>   
> 
> 
>="email" placeholder="Your Email" data-rule="email" data-msg=
> "Please enter a valid email" />
>   
> 
>   
>   
>  "subject" placeholder="Subject" data-rule="minlen:4" data-msg=
> "Please enter at least 8 chars of subject" />
> 
>   
>   
>  data-rule="required" data-msg="Please write something for us" placeholder=
> "Message">
> 
>   
>   
> {% for fmessage in messages %}
> {{fmessage}}
> {% endfor %}
>   
>   
> Send Message
> 
>
>   
>
>
>
>
>
>
>
>
>
> --
> 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/CAJCm56LAbJHrbNFworRZsuD-hP5Gok6wH%2BvQw1NgQuwAJ9_S4w%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/CAPCf-y5CENT4WAmjvd2SJaLy5t8rTv_kncYn0o%3DD7uX8hjporA%40mail.gmail.com.


Re: user profile in Django

2021-06-27 Thread sum abiut
You can use the user model, do something like that

class user_register(models.Model):
  user = models.OneToOneField(User,on_delete=models.CASCADE)
  join_date = models.DateTimeField(default=timezone.now)

To view the user profile, you can do something like this.

def user_profile(request, username):
user = User.objects.get(username=username)
context = {
   "user": user
}


return render(request, 'profile.html', context)

profile.html

{{user.username}}
{{user.first_name}}


On Mon, Jun 28, 2021 at 2:43 AM Samir Areh  wrote:

> Hello
> I'm new to django. i want to create a user profile. I want to know the
> best way to do this. 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/f84c5af2-12f1-41d3-9002-f0bc96f0371fn%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/CAPCf-y6cWAGpoS8GsxjZuAFQ2tp8aJy0Qj-38YvqHGdm3vEeYg%40mail.gmail.com.


Re: Help

2021-06-27 Thread sum abiut
You have to be more clear on what you are working on. provide the code that
you are having trouble with in order to get the appropriate assistance.
You might want to take a look at this.
https://django-hitcount.readthedocs.io/en/latest/#

On Mon, Jun 28, 2021 at 5:54 AM ola neat  wrote:

> Halo django devs,
> I'm working on a drf api to return hit count on my site & I've  got no
> idea how to archive that, can anyone help?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHLKn7320WTv4hjN4dUv4pcjH53z-G4NT%2BrEhuLb6aBcZahYYg%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/CAPCf-y5k3RVH33pp6BXz_nP_o1gwA4edt3%2B2v8VtoYP8cR321w%40mail.gmail.com.


error save to model on a onto many relationship

2021-06-10 Thread sum abiut
I am running to some issue saving to models in a one to make relationship.
The error is described Here

. I would appreciate it if you could point me in the right direction.

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/CAPCf-y75suZFDQ-kje6bGw7DDvZziFn7hF%3D4oC%2BpnT9id%3Dn2Eg%40mail.gmail.com.


Re: Help!!!

2020-11-29 Thread sum abiut
Run these commands

Python manage.py makemigrations
Python manage.py migrate

On Mon, 30 Nov 2020, 07:40 Kelvin Sajere,  wrote:

> I haven’t actually used repl.it, so I can’t really tell you what’s
> happening. I basically just do things by creating a project, then using
> manage.py to create apps for my project. But the unapplied migrations are
> migrations that your project needs to be able to run. These are models that
> come with django, like your user models and if you have installed any
> external apps.
>
> On Sun, Nov 29, 2020 at 14:44 Agripreneur Updates <
> ogunladestephe...@gmail.com> wrote:
>
>> HI, I'm new to django, I downloaded a youtube tutorial for django for
>> beginners. The tutor used repl.it platform to create the django and then
>> click on run to start the server. But following the same step, when I
>> clicked on run I got the error message "You have 18 unapplied
>> migration(s)". I observed that the sub folders created in the tutor's
>> django template includes: main, pychache, migration, static, templates
>> while in my own case, a single file was created namely mysite. attached
>> here is the creenshot. I will be glad if you can help.
>> 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/940f323c-31bc-4c43-889a-a2e0dace749bn%40googlegroups.com
>> 
>> .
>>
> --
> KeLLs
>
> --
> 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/CADYqDX3gHHY-ng2_qi1FnCQ0JZb5xXTQMjEuD8xeCsrb-bDH4w%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/CAPCf-y6tiLdfuy-XojRfuMnquZqzmOG7h3oW-Jc%2BgVsh_Wx03A%40mail.gmail.com.


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

2020-07-09 Thread sum abiut
you need to pass the instance of the requisition id to your form before you
can save it.
You can try this:
 myrequistion=requistion.objects.get(id=requistion_id)
form=RequistiondetailForm(request.POST, inctance= myrequistion)
if form.is_valid()
form.save()

On Fri, Jul 10, 2020 at 3:14 PM Ashutosh Mishra 
wrote:

> 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
> 
> .
>

-- 
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/CAPCf-y6NRoTqDSewBrBgycg2sVVwecs0-hF0mqzH2eD16uooPQ%40mail.gmail.com.


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

2020-07-06 Thread sum abiut
You can try this export data to excel file

Sum,

On Mon, Jul 6, 2020 at 7:00 PM Ashutosh Mishra 
wrote:

> 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
> 
> .
>

-- 
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/CAPCf-y6tSDOTUDfWWQV652E6yY7M2FRgJuKA4vnc4nPme_j1Bw%40mail.gmail.com.


send_mail creating a hyperlink

2020-01-22 Thread sum abiut
Hi,
How do I create a hyperlink on the body of the email so that when the user
receives the email they can click the link to access the website?
For example, on the
send_mail( subject, click here to access the site, to_address)

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/CAPCf-y4HSiFHUwn-Z8U%2BWDf33i0T%2BaUkNCzRiYH-HLdfUcT%3DpQ%40mail.gmail.com.


email api

2020-01-05 Thread sum abiut
Is there any other email API out there that I can use to send email in
django other than sengrid?

-- 
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/CAPCf-y7O3LWHCfjxyiPZPaLYyPeJTrVaj3%3D_xDpLrOR0U9D5LA%40mail.gmail.com.


Re: get user that is member of two different group

2020-01-02 Thread sum abiut
Thanks, heaps Stephen. Exactly what I needed.


On Fri, Jan 3, 2020 at 1:05 PM Stephen J. Butler 
wrote:

> I don't think that's what the he asked for. It will return users who are
> members of either test1 OR test2, but I read the question as returning
> users who are members of both test1 AND test2. I think the proper query
> would be:
>
> User.objects.filter(groups__name='test1').filter(groups__name='test2')
>
> That does two joins to the groups table and filters the first on 'test1'
> and the second on 'test2'.
>
> On Thu, Jan 2, 2020 at 2:34 AM Lunga Baliwe  wrote:
>
>> Hi there,
>> maybe you can use  something like
>> User.objects.filter(groups__name__in=['test1', 'test2']).
>> Also check https://docs.djangoproject.com/en/3.0/ref/models/querysets/#in for
>> examples of using __in
>>
>> On Thu, Jan 2, 2020 at 6:49 AM sum abiut  wrote:
>>
>>> Hi,
>>> I have two separate groups, for example, test1, and test2. I want to get
>>> a user that is a member of group test1 and group test2.
>>>
>>> I've try User.objects.filter(groups__name='test1') to get users of
>>> group test1. not sure how to check if a user belongs to group test1 and is
>>> also belong to group test2
>>>
>>> --
>>> 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/CAPCf-y6F2rbgG1%3DgK4QX8FDKDq61b8mVdvtrtv5LwQQmfwhY3g%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAPCf-y6F2rbgG1%3DgK4QX8FDKDq61b8mVdvtrtv5LwQQmfwhY3g%40mail.gmail.com?utm_medium=email_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/CANDnEWeuXRnMqCiS8co%3DhifuUhC8NrYo8e1j8Y_EVF6r1sBwew%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CANDnEWeuXRnMqCiS8co%3DhifuUhC8NrYo8e1j8Y_EVF6r1sBwew%40mail.gmail.com?utm_medium=email_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/CAD4ANxXLwZ9WgbMGfNWOSA%2BeUP7FxFHDgkpwUBVcmqH8gaGK8g%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAD4ANxXLwZ9WgbMGfNWOSA%2BeUP7FxFHDgkpwUBVcmqH8gaGK8g%40mail.gmail.com?utm_medium=email_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/CAPCf-y7G7TdXaEWCvtwFh-i4EHZUPY_TkGuQjivcF8_WYANthQ%40mail.gmail.com.


Re: get user that is member of two different group

2020-01-02 Thread sum abiut
Thanks

On Thu, Jan 2, 2020 at 9:35 PM Lunga Baliwe  wrote:

> Hi there,
> maybe you can use  something like
> User.objects.filter(groups__name__in=['test1', 'test2']).
> Also check https://docs.djangoproject.com/en/3.0/ref/models/querysets/#in for
> examples of using __in
>
> On Thu, Jan 2, 2020 at 6:49 AM sum abiut  wrote:
>
>> Hi,
>> I have two separate groups, for example, test1, and test2. I want to get
>> a user that is a member of group test1 and group test2.
>>
>> I've try User.objects.filter(groups__name='test1') to get users of  group
>> test1. not sure how to check if a user belongs to group test1 and is also
>> belong to group test2
>>
>> --
>> 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/CAPCf-y6F2rbgG1%3DgK4QX8FDKDq61b8mVdvtrtv5LwQQmfwhY3g%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAPCf-y6F2rbgG1%3DgK4QX8FDKDq61b8mVdvtrtv5LwQQmfwhY3g%40mail.gmail.com?utm_medium=email_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/CANDnEWeuXRnMqCiS8co%3DhifuUhC8NrYo8e1j8Y_EVF6r1sBwew%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CANDnEWeuXRnMqCiS8co%3DhifuUhC8NrYo8e1j8Y_EVF6r1sBwew%40mail.gmail.com?utm_medium=email_source=footer>
> .
>


-- 



*Security Blog : Security Tips <http://mysecuritytips.wordpress.com/>  |
Programming  Blog: Programming <http://mrcoderguide.wordpress.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/CAPCf-y5S-q2R4W5zmFEuSJ2S5ENr4tcpUuiDWrWrLUPEb%3DWUBg%40mail.gmail.com.


get user that is member of two different group

2020-01-01 Thread sum abiut
Hi,
I have two separate groups, for example, test1, and test2. I want to get a
user that is a member of group test1 and group test2.

I've try User.objects.filter(groups__name='test1') to get users of  group
test1. not sure how to check if a user belongs to group test1 and is also
belong to group test2

-- 
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/CAPCf-y6F2rbgG1%3DgK4QX8FDKDq61b8mVdvtrtv5LwQQmfwhY3g%40mail.gmail.com.


change page title of password reset form

2020-01-01 Thread sum abiut
How do you change the default page header of the password reset form? I did
something like below but the default page still doesn't change.

admin.site.site_header = "testing"

[image: image.png]

-- 
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/CAPCf-y67K__Bi6f%3DOYgm9u2wozDWs2QDG3kqwTwoNk%3D4uyKK0g%40mail.gmail.com.


Re: Feeding a stored procedure (MySQL) into Django_Tables2 table

2019-12-24 Thread sum abiut
Can you show us your models.

On Wed, 25 Dec 2019, 08:03 Gregory Vaks,  wrote:

> Hello all,
>
> I am using Django-Tables2 for front-end in my app as it nicely fits my
> requirement for displaying information.
>
> My issue is that I need to display information from multiple models (MySQL
> tables) in one screen/template.  There is a stored procedure that gets all
> the information that I need and I tested out calling it which works fine
> but there is no documentation on how to feed this data into a table.
>
> The Django-Tables2 seems to use a table struct which gets data from fields
> that can be specified based off the model you declare while in my case I am
> not using just one model so this method will not work for me.  I have tried
> different methods and searching for better documentation or if anyone had
> this issue before but found nothing...
>
> Can someone please advise if there is an easy way for me to do this or an
> alternate route I may need to take?
>
> --
> 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/ab8b0bfc-7d47-4b6c-9047-17fd1e008db5%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/CAPCf-y5%3DSc5HTrEQ1r9H_Y1P_d7Z5YLLOmPwiRcgEV_EJnaGLw%40mail.gmail.com.


ModelChoiceField get selected value

2019-12-02 Thread sum abiut
How do I get the value of a selected model choice field? I have a model
that has a field 'user' as a foreignKey and I am trying to figure out how
to get the value of a user that was selected.
I have a form that looks like below,
[image: image.png]

class update_entitlement_form(forms.ModelForm):
class Meta:
model = month_and_year
fields = ['user', 'Month', 'Year']

class month_and_year(models.Model):
user = models.ForeignKey(User, default='', on_delete=models.CASCADE)
Month = models.CharField(max_length=100, default="", null=True)
Year = models.CharField(max_length=100, default='')

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

-- 
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/CAPCf-y6qcXvcxEqfapFF2NLBJ7r5bEwKCzL3Nj%2B5SmTTBWsaKg%40mail.gmail.com.


Re:

2019-11-26 Thread sum abiut
Check your url, you are passing a primary key in the edit_profile function
but you are not indicating that in your url.


On Mon, 25 Nov 2019, 05:50 Paras Jain,  wrote:

> its showing error like this:
> TypeError at /edit_profile/
>
> edit_profile() missing 1 required positional argument: 'pk'
>
> views.py:
> def edit_profile(request, pk):
> post = get_object_or_404(User, pk=pk)
> if request.method == "POST":
> form = EditProfileForm(request.POST, instance=post)
> if form.is_valid():
> post = form.save(commit=False)
> post.save()
> return redirect('company/detail.html', pk=post.pk)
> else:
> return render(request,'company/edit_profile.html')
>
>
> def detail(request,pk):
> details = get_object_or_404(User, pk=pk) #it will create object
> return render(request, 'company/detail.html',{'details':details})
>
>
> urls.py:
>
> from django.urls import path
> from django.conf.urls import  url
> #from .views import HomePageView
> from .import views
>
> urlpatterns=[
> path('', views.home, name='company-home'),
> path('register/', views.register, name='company-register'),
> path('detail/', views.detail, name='company-detail'),
> path('login/', views.login, name='company-login'),
> path('add/', views.add, name='company-add'),
> path('edit_profile/', views.edit_profile, name='company-edit'),
>
>
> ]
>
>
> --
> 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/CAMtmBS9%2B50Ms6HepVL692bjMP8oO9qYY49xWJDHyFUP8AJJgiQ%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/CAPCf-y47Zkh-bcQ6cazsfB0%3DhFahxKrc4LkAzv-_a6tfSJnV9Q%40mail.gmail.com.


Re: Django update field in many to many relationship

2019-02-14 Thread sum abiut
Thanks,
The Leave_current_balance is from Leave_Balance model which why i haven't
included it. I am not sure how to fix that.
Sum
On Fri, Feb 15, 2019 at 12:42 PM Simon Charette 
wrote:

> Your DirectorForm model form doesn't include 'Leave_current_balance' in
> it's Meta.fields
> hence no form field is generated for it.
>
> Cheers,
> Simon
>
> Le jeudi 14 février 2019 17:50:21 UTC-5, suabiut a écrit :
>>
>> Hi,
>>
>> I have two models many to many relationships, I am trying to update the
>> field using a form. when a leave is submitted the director is notified by
>> email. the director can login to the system to approve the leave using the
>> form. once the leave is approved, I want to adjust the
>> Leave_current_balance field  which in on the LeaveBalance model
>>
>> class LeaveBalance(models.Model):
>> 
>> user=models.OneToOneField(User,on_delete=models.CASCADE,primary_key=True,)
>> Leave_current_balance= models.FloatField(null=True, blank=True, 
>> default=None)
>> Year=models.CharField(max_length=100,default='')
>> def __unicode__(self):
>>  return  self.Year
>>
>>
>> class NewLeave(models.Model):
>>  user=models.ForeignKey(User,default='',on_delete=models.CASCADE)
>>  leave_balance=models.ManyToManyField(Leave_Balance)
>> leave=(
>> ('annual','annual'),
>> ('sick','sick'),
>>
>>  )
>>
>>  
>> Leave_type=models.CharField(max_length=100,choices=leave,blank=False,default='')
>>
>> Total_working_days=models.FloatField(null=True,  blank=False)
>> DirAuth=(
>> ('Pending','Pending'),
>> ('Approved','Approved'),
>> ('Rejected','Rejected'),
>> )
>>
>>  
>> Director_Authorization_Status=models.CharField(max_length=100,choices=DirAuth,default='Pending',blank=False)
>>  Date_Authorized=models.DateField(null=True,blank=False)
>>  
>> Authorized_by_Director=models.CharField(max_length=100,default='',blank=False)
>>
>> def __unicode__(self):
>> return  self.Leave_type
>>
>>
>>
>>
>> class DirectorForm(forms.ModelForm):
>> class Meta:
>> model=NewLeave
>> 
>> fields=('Director_Authorization_Status','Authorized_by_Director','Date_Authorized',)
>> widgets={
>> 'Date_Authorized':DateInput()
>> }
>>
>>
>>
>> This function throw the error: u'Leave_current_balance'
>>
>> def unitDirectorForm(request,id):
>>
>> if request.method=='POST':
>>
>> getstaffid=NewLeave.objects.get(id=id)
>> form = DirectorForm(request.POST, instance=getstaffid)
>> if form.is_valid():
>> getstaffid = form.save(commit=False)
>> getstaffid.save()
>>
>> total_days = getstaffid.Total_working_days
>> current_balance = 
>> getstaffid.user.leave_balance.Leave_current_balance
>> diff_balance = current_balance - total_days
>> current_balance = diff_balance
>> current_balance=form.fields['Leave_current_balance']
>> current_balance.save()
>> getstaffid.leave_balance.add(current_balance)
>>
>> return HttpResponse('You have successfuly Authorise the leave')
>>
>> else:
>> #getstaffid=NewLeave.objects.get(id=id)
>> form=DirectorForm()
>> #c_balance=Leave_Balance.objects.get()
>> balance_form = leavebbalanceForm()
>>
>> return render(request,'managerauthorisedform.html',{'form':form})
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a03bfa6f-f5c8-4f7c-a1de-ba961c4009c0%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Django update field in many to many relationship

2019-02-14 Thread sum abiut
TraceBack:


Request Method: POST
Request URL: http://127.0.0.1:8000/unitDirectorForm/25/

Django Version: 1.11.18
Python Version: 2.7.15
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'mathfilters',
 'profilepage']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback:

File 
"/root./virtualenvs/eleave/local/lib/python2.7/site-packages/django/core/handlers/exception.py"
in inner
  41. response = get_response(request)

File 
"/root./virtualenvs/eleave/local/lib/python2.7/site-packages/django/core/handlers/base.py"
in _get_response
  187. response =
self.process_exception_by_middleware(e, request)

File 
"/root./virtualenvs/eleave/local/lib/python2.7/site-packages/django/core/handlers/base.py"
in _get_response
  185. response = wrapped_callback(request,
*callback_args, **callback_kwargs)

File "/var/www/projects/eleave/profilepage/views.py" in unitDirectorForm
  179. current_balance=form.fields['Leave_current_balance']

Exception Type: KeyError at /unitDirectorForm/25/
Exception Value: u'Leave_current_balance



On Fri, Feb 15, 2019 at 11:49 AM sum abiut  wrote:

> Hi,
>
> I have two models many to many relationships, I am trying to update the
> field using a form. when a leave is submitted the director is notified by
> email. the director can login to the system to approve the leave using the
> form. once the leave is approved, I want to adjust the
> Leave_current_balance field  which in on the LeaveBalance model
>
> class LeaveBalance(models.Model):
> user=models.OneToOneField(User,on_delete=models.CASCADE,primary_key=True,)
> Leave_current_balance= models.FloatField(null=True, blank=True, 
> default=None)
> Year=models.CharField(max_length=100,default='')
> def __unicode__(self):
>  return  self.Year
>
>
> class NewLeave(models.Model):
>   user=models.ForeignKey(User,default='',on_delete=models.CASCADE)
>   leave_balance=models.ManyToManyField(Leave_Balance)
> leave=(
> ('annual','annual'),
> ('sick','sick'),
>
>   )
>
>   
> Leave_type=models.CharField(max_length=100,choices=leave,blank=False,default='')
>
> Total_working_days=models.FloatField(null=True,  blank=False)
> DirAuth=(
> ('Pending','Pending'),
> ('Approved','Approved'),
> ('Rejected','Rejected'),
> )
>
>   
> Director_Authorization_Status=models.CharField(max_length=100,choices=DirAuth,default='Pending',blank=False)
>   Date_Authorized=models.DateField(null=True,blank=False)
>   
> Authorized_by_Director=models.CharField(max_length=100,default='',blank=False)
>
> def __unicode__(self):
> return  self.Leave_type
>
>
>
>
> class DirectorForm(forms.ModelForm):
> class Meta:
> model=NewLeave
> 
> fields=('Director_Authorization_Status','Authorized_by_Director','Date_Authorized',)
> widgets={
> 'Date_Authorized':DateInput()
> }
>
>
>
> This function throw the error: u'Leave_current_balance'
>
> def unitDirectorForm(request,id):
>
> if request.method=='POST':
>
> getstaffid=NewLeave.objects.get(id=id)
> form = DirectorForm(request.POST, instance=getstaffid)
> if form.is_valid():
> getstaffid = form.save(commit=False)
> getstaffid.save()
>
> total_days = getstaffid.Total_working_days
> current_balance = 
> getstaffid.user.leave_balance.Leave_current_balance
> diff_balance = current_balance - total_days
> current_balance = diff_balance
> current_balance=form.fields['Leave_current_balance']
> current_balance.save()
> getstaffid.leave_balance.add(current_balance)
>
> return HttpResponse('You have successfuly Authorise the leave')
>
> else:
> #getstaffid=NewLeave.objects.get(id=id)
> form=DirectorForm()
> #c_balance=Leave_Balance.objects.get()
> balance_form = leavebbalanceForm()
>
> return render(request,'managerauthorisedform.html',{'form':form})
>
>

-- 
You received this message because you

Django update field in many to many relationship

2019-02-14 Thread sum abiut
Hi,

I have two models many to many relationships, I am trying to update the
field using a form. when a leave is submitted the director is notified by
email. the director can login to the system to approve the leave using the
form. once the leave is approved, I want to adjust the
Leave_current_balance field  which in on the LeaveBalance model

class LeaveBalance(models.Model):
user=models.OneToOneField(User,on_delete=models.CASCADE,primary_key=True,)
Leave_current_balance= models.FloatField(null=True, blank=True,
default=None)
Year=models.CharField(max_length=100,default='')
def __unicode__(self):
 return  self.Year


class NewLeave(models.Model):
user=models.ForeignKey(User,default='',on_delete=models.CASCADE)
leave_balance=models.ManyToManyField(Leave_Balance)
leave=(
('annual','annual'),
('sick','sick'),

)


Leave_type=models.CharField(max_length=100,choices=leave,blank=False,default='')

Total_working_days=models.FloatField(null=True,  blank=False)
DirAuth=(
('Pending','Pending'),
('Approved','Approved'),
('Rejected','Rejected'),
)


Director_Authorization_Status=models.CharField(max_length=100,choices=DirAuth,default='Pending',blank=False)
Date_Authorized=models.DateField(null=True,blank=False)

Authorized_by_Director=models.CharField(max_length=100,default='',blank=False)

def __unicode__(self):
return  self.Leave_type




class DirectorForm(forms.ModelForm):
class Meta:
model=NewLeave

fields=('Director_Authorization_Status','Authorized_by_Director','Date_Authorized',)
widgets={
'Date_Authorized':DateInput()
}



This function throw the error: u'Leave_current_balance'

def unitDirectorForm(request,id):

if request.method=='POST':

getstaffid=NewLeave.objects.get(id=id)
form = DirectorForm(request.POST, instance=getstaffid)
if form.is_valid():
getstaffid = form.save(commit=False)
getstaffid.save()

total_days = getstaffid.Total_working_days
current_balance =
getstaffid.user.leave_balance.Leave_current_balance
diff_balance = current_balance - total_days
current_balance = diff_balance
current_balance=form.fields['Leave_current_balance']
current_balance.save()
getstaffid.leave_balance.add(current_balance)

return HttpResponse('You have successfuly Authorise the leave')

else:
#getstaffid=NewLeave.objects.get(id=id)
form=DirectorForm()
#c_balance=Leave_Balance.objects.get()
balance_form = leavebbalanceForm()

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

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


django joining two models

2019-01-31 Thread sum abiut
Hi,
i have three models LeaveBalance, NewLeave and User. I want to pull date
from NewLeave and User, basically displaying the data of users that have
apply for a leave. I had difficulty figuring out how to accomplish this. my
views and model are below.

The view is throwing an errror:


Cannot resolve keyword 'newleave_set' into field. Choices are:
date_joined, email, first_name, groups, id, is_active, is_staff,
is_superuser, last_login, last_name, leave_balance, logentry,
newleave, password, profile, user_permissions, username

Exception Location:
/root./virtualenvs/eleave/local/lib/python2.7/site-packages/django/db/models/sql/query.py
in names_to_path, line 1352
Python Executable: /root./virtualenvs/eleave/bin/python



views.py
def Allleaves(request):
allleave=User.objects.filter(newleave_set__isnull=False).distinct()
return render(request,'allleave.html',locals())



models.py
class Leave_Balance(models.Model):

user=models.OneToOneField(User,on_delete=models.CASCADE,primary_key=True,)
Monthly_entitlement=models.FloatField(null=True, blank=True,
default=None)
Monthly_consumption=models.FloatField(null=True, blank=True,
default=None)
Leave_current_balance= models.FloatField(null=True, blank=True,
default=None)
leave_encashment= models.FloatField(null=True, blank=True, default=None)
Year=models.CharField(max_length=100,default='')
def __unicode__(self):
 return  self.Year



class NewLeave(models.Model):
user=models.ForeignKey(User,default='',on_delete=models.CASCADE)
leave_balance=models.ManyToManyField(Leave_Balance)
leave=(
('annual','annual'),
('sick','sick'),

)
Leave_type=models.CharField(max_length=100,choices=leave,blank=False,default='')
dp=(
('test','test'),
('test1','test1'),

)
 department=models.CharField(max_length=100,choices=dp,blank=False,default='')
Start_Date=models.DateField(null=True, blank=False)
End_Date=models.DateField(null=True, blank=False)
Total_working_days=models.FloatField(null=True, blank=False)
Reason=models.TextField(max_length=1000,null=True, blank=False)

def __unicode__(self):
 return  self.Leave_type

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


Re: Connecting Sql server to Django

2018-10-14 Thread sum abiut
You can try sqlalchemy
https://docs.sqlalchemy.org/en/latest/dialects/mssql.html#module-sqlalchemy.dialects.mssql.pymssql


using the pymssql driver, you can do something like this

from sqlalchemy import create_engine

def connect(request):
engine=create_engine('mssql+pymssql://username:password@hostname /db')
connection=engine.connect()

hope this helps.


On Fri, Oct 12, 2018 at 3:26 PM Rakhee Menon 
wrote:

>
>
> Hi Everyone,
>
> In my project I want to connect SQL Server 2014 with django, I tried with
> the given link,
>
>https://django-mssql.readthedocs.io/en/latest/quickstart.html
>
> but it shows some error like,
>
> import pythoncom
> ImportError: No module named 'pythoncom''
>
> When I goggled the error it says download pywin32 but I didn't get any
> file or link to download .Please could anyone help me out with this issue.
>
> Thanks in Advance
> Rakhee
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b1fe3c06-4e5e-45f7-b675-d4751b94337f%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Using Django admin datepicker in a custom form

2018-06-26 Thread sum abiut
I am trying to use a django admin datepicker in a custom form. it is
displaying alright but the year only begin in 2018 but no later than 2018.
Please assist, below is my form.py

#my form.py
from django.forms.extras.widgets import SelectDateWidgetclass
ContactForm(forms.ModelForm):
class Meta:
model =contacts
fields =
('First_Name','Middle_Name','Last_Name','Date_of_Birth','Gender','Island','Province','Date_of_Baptism','Congregation','Status','Comments',)

widgets = {'Date_of_Birth':
SelectDateWidget(),'Date_of_Baptism':SelectDateWidget()}

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


Re: django display a row vale

2018-06-26 Thread sum abiut
Thanks,
Here is my view.py and it works for me

def display_data(request,id):
selected_objects = minutes.objects.filter(pk__in=id)
return render(request,'test.html',locals())

cheers,

On Wed, Jun 27, 2018 at 8:15 AM, Ryan Nowakowski 
wrote:

> On Tue, Jun 26, 2018 at 04:33:41PM +1100, sum abiut wrote:
> > Hi,
> > i need some assistance, i have a table and want to be able to only
> display
> > the values of a particular row when ever the particular row is selected.
> >
> > please point me to right direction.
> >
>
> I assume you're talking about an HTML table and not a database table
> here.  If you wanted to do this with no javascript you could make each
> table row a link to the current page with some query parameters that
> filter the data down to just that row.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/20180626211521.GT14746%40fattuba.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


django display a row vale

2018-06-25 Thread sum abiut
Hi,
i need some assistance, i have a table and want to be able to only display
the values of a particular row when ever the particular row is selected.

please point me to right direction.

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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y5Y_P3G%2BkrPetmC8-Qm__ZThNmRBQL_%3DhGYGANOjfdY%2BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


balance brought forward

2018-05-24 Thread sum abiut
Hi,
I am working on an accounting app and i needed direction on how to go about
calculating the balance brought for a particular day.

What i want to accomplish is being able to display the balance brought
forward when the user select a date. i want to be able to display the
transaction that happen in a particular date and the balance brought
forward from the previous day.

currently i just sum up all the transaction that was done in and then minus
the total sum to get the opening balance.

However when ever there is a movement in the account  the brought forward
balance on different dates also change.

dailytransaction =Sum(dailytransactions)

openingbalance=totalsum

balancebroughforward=openingbalance-dailytransaction

how to i keep the balance brought forward for each day unchange whenever
there is movement on an account each day.

cheer,

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


Re: serving admin files in Apache

2018-05-03 Thread sum abiut
Thanks,
i've try that but still doesn't solve the problem

On Fri, May 4, 2018 at 11:51 AM, James Farris <jamesafar...@gmail.com>
wrote:

> Did you run
> $ python manage.py collectstatic in your project folder on the server that
> is running Apache?
>
> This add all css, js, and images to the static root folder you specified
> in settings.py
>
> On Thu, May 3, 2018 at 4:40 PM sum abiut <suab...@gmail.com> wrote:
>
>> Hi,
>> I have recently setup my django app with Apache. The app files are serve
>> alright but, however when i access the admin page it looks all over the
>> place. Please advise how to i serve the admin files in Apache.
>>
>> 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 post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/
>> msgid/django-users/CAPCf-y5%2BVkkGo%2BDGHfX2o6Q54Gdfoo_
>> AxNvTcuZEkOziAH2V1A%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAPCf-y5%2BVkkGo%2BDGHfX2o6Q54Gdfoo_AxNvTcuZEkOziAH2V1A%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAE-E-_1AaYs5HYKxddZ1bf0YQ%3DbE4gvex2-ePSNB43SjNZtfmg%
> 40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAE-E-_1AaYs5HYKxddZ1bf0YQ%3DbE4gvex2-ePSNB43SjNZtfmg%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


serving admin files in Apache

2018-05-03 Thread sum abiut
Hi,
I have recently setup my django app with Apache. The app files are serve
alright but, however when i access the admin page it looks all over the
place. Please advise how to i serve the admin files in Apache.

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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y5%2BVkkGo%2BDGHfX2o6Q54Gdfoo_AxNvTcuZEkOziAH2V1A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


convert range of date from julian to gregorian date

2018-04-25 Thread sum abiut
Hi ,
I am trying to convert a range of date from julian to gregorian date

here is what i have try
stmt=stmt.where(and_(rate.columns.journal_ctrl_num==fund.columns.journal_ctrl_num,fund.columns.account_code==selected_acc,rate.columns.date_entered.between(convert,convert1)))
result_proxy=connection.execute(stmt).fetchall()
for a in result_proxy:
test=datetime.date.fromordinal(int(a.date_entered))

the two date ranges  are (convert and convert1)

but when i pass test parameter  to the template it only display the start
date which is convert. I was wondering how to pass to date range to the
date_applied in  test=datetime.date.fromordinal(int(a.date_entered))

i know from sql its done like this
rate.columns.date_entered.between(convert,convert1)




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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y4ZN8VgUQSbF90QE20ec7Qg5qbof8mnwYEQGTmEawkELw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: displaying gregorian date in template

2018-04-24 Thread sum abiut
i want to do something like

datetime.date.fromordinal(int(date_applied))

to convert date from julian to gregorian date, just wondering it this can
be done in template?

On Wed, Apr 25, 2018 at 1:56 PM, sum abiut <suab...@gmail.com> wrote:

> Current i have a for loop
> 
> 
> Date
> 
> {% for a in results %}
>
> {{a.date_applied}}
>
> {%endfor%)
> 
>
> currently the date is in julian date. i wan to convert the date to
> gregorian date. Is there a way to do that in the template.
>
> On Wed, Apr 25, 2018 at 1:50 PM, sum abiut <suab...@gmail.com> wrote:
>
>> I have a function that query the db and extract and display data on a
>> template
>>
>>
>> def bydate_display(request):
>> if "selectdate" in request.POST and "selectdate1" in request.POST and
>> "selectaccount" in request.POST:
>> selected_date = request.POST["selectdate"]
>> selected_date1 = request.POST["selectdate1"]
>> selected_acc = request.POST["selectaccount"]
>> if selected_date==selected_date and
>> selected_date1==selected_date1 and selected_acc==selected_acc:
>> convert=datetime.datetime.strptime(selected_date,
>> "%Y-%m-%d").toordinal()
>> convert1=datetime.datetime.strptime(selected_date1,
>> "%Y-%m-%d").toordinal()
>> engine=create_engine('mssql+pymssql://username:password@serve
>> /db')
>> connection=engine.connect()
>> metadata=MetaData()
>> fund=Table('gltrxdet',metadata,autoload=True,autoload_with=
>> engine)
>> rate=Table('gltrx_all',metadata,autoload=True,autoload_with=
>> engine)
>>
>> stmt=select([fund.columns.account_code,fund.columns.descript
>> ion,fund.columns.nat_balance,fund.columns.rate_type_home,
>> rate.columns.date_applied,rate.columns.date_entered,
>> fund.columns.journal_ctrl_num,rate.columns.journal_ctrl_num])
>> stmt=stmt.where(and_(rate.columns.journal_ctrl_num==fund.
>> columns.journal_ctrl_num,fund.columns.account_code==selected
>> _acc,rate.columns.date_applied.between(convert,convert1)))
>> results=connection.execute(stmt).fetchall()
>>
>>
>> return render(request,'bydatedisplay.html',locals())
>>
>>
>
>
> --
>

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


Re: displaying gregorian date in template

2018-04-24 Thread sum abiut
Current i have a for loop


Date

{% for a in results %}

{{a.date_applied}}

{%endfor%)


currently the date is in julian date. i wan to convert the date to
gregorian date. Is there a way to do that in the template.

On Wed, Apr 25, 2018 at 1:50 PM, sum abiut <suab...@gmail.com> wrote:

> I have a function that query the db and extract and display data on a
> template
>
>
> def bydate_display(request):
> if "selectdate" in request.POST and "selectdate1" in request.POST and
> "selectaccount" in request.POST:
> selected_date = request.POST["selectdate"]
> selected_date1 = request.POST["selectdate1"]
> selected_acc = request.POST["selectaccount"]
> if selected_date==selected_date and selected_date1==selected_date1
> and selected_acc==selected_acc:
> convert=datetime.datetime.strptime(selected_date,
> "%Y-%m-%d").toordinal()
> convert1=datetime.datetime.strptime(selected_date1,
> "%Y-%m-%d").toordinal()
> engine=create_engine('mssql+pymssql://username:password@serve
> /db')
> connection=engine.connect()
> metadata=MetaData()
> fund=Table('gltrxdet',metadata,autoload=True,
> autoload_with=engine)
> rate=Table('gltrx_all',metadata,autoload=True,
> autoload_with=engine)
>
> stmt=select([fund.columns.account_code,fund.columns.
> description,fund.columns.nat_balance,fund.columns.rate_
> type_home,rate.columns.date_applied,rate.columns.date_
> entered,fund.columns.journal_ctrl_num,rate.columns.journal_ctrl_num])
> stmt=stmt.where(and_(rate.columns.journal_ctrl_num==
> fund.columns.journal_ctrl_num,fund.columns.account_code==
> selected_acc,rate.columns.date_applied.between(convert,convert1)))
> results=connection.execute(stmt).fetchall()
>
>
> return render(request,'bydatedisplay.html',locals())
>
>


-- 
__
 | Sum Abiut |

*Security Blog : Security Tips <http://mysecuritytips.wordpress.com/>  |
Programming  Blog: Programming <http://mrcoderguide.wordpress.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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y71cq3H8XvzAcUp4ndthjwtq4ZGQkmzMcf44rLvpeqmgQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


displaying gregorian date in template

2018-04-24 Thread sum abiut
I have a function that query the db and extract and display data on a
template


def bydate_display(request):
if "selectdate" in request.POST and "selectdate1" in request.POST and
"selectaccount" in request.POST:
selected_date = request.POST["selectdate"]
selected_date1 = request.POST["selectdate1"]
selected_acc = request.POST["selectaccount"]
if selected_date==selected_date and selected_date1==selected_date1
and selected_acc==selected_acc:
convert=datetime.datetime.strptime(selected_date,
"%Y-%m-%d").toordinal()
convert1=datetime.datetime.strptime(selected_date1,
"%Y-%m-%d").toordinal()
engine=create_engine('mssql+pymssql://username:password@serve
/db')
connection=engine.connect()
metadata=MetaData()

fund=Table('gltrxdet',metadata,autoload=True,autoload_with=engine)

rate=Table('gltrx_all',metadata,autoload=True,autoload_with=engine)


stmt=select([fund.columns.account_code,fund.columns.description,fund.columns.nat_balance,fund.columns.rate_type_home,rate.columns.date_applied,rate.columns.date_entered,fund.columns.journal_ctrl_num,rate.columns.journal_ctrl_num])

stmt=stmt.where(and_(rate.columns.journal_ctrl_num==fund.columns.journal_ctrl_num,fund.columns.account_code==selected_acc,rate.columns.date_applied.between(convert,convert1)))
results=connection.execute(stmt).fetchall()


return render(request,'bydatedisplay.html',locals())

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


Re: Python Sqlalchemy filter by date range

2018-04-24 Thread sum abiut
Thanks heaps Larry

On Tue, Apr 24, 2018 at 10:40 PM, Larry Martell <larry.mart...@gmail.com>
wrote:

> I think you are looking for the range function
>
> https://docs.djangoproject.com/en/dev/ref/models/querysets/#range
>
>
> On Mon, Apr 23, 2018 at 11:54 PM sum abiut <suab...@gmail.com> wrote:
>
>> I have two date picker fields that i want the users to select from date
>> to end date. and i want to display data between the two dates that was
>> selected. From example form date: 2/14/2018 to date:3/15/2018. when the
>> function is called i want to extract and display data between this two
>> dates.
>>
>> i just need some help with the query to accomplish that.
>>
>> I am using sqlalchemy to pull data from an mssql
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CACwCsY5DoJr5wHprbwbv50GuQL6coyErMUMP1-_8qiqwf%3DVAOQ%
> 40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CACwCsY5DoJr5wHprbwbv50GuQL6coyErMUMP1-_8qiqwf%3DVAOQ%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Python Sqlalchemy filter by date range

2018-04-23 Thread sum abiut
I have two date picker fields that i want the users to select from date to
end date. and i want to display data between the two dates that was
selected. From example form date: 2/14/2018 to date:3/15/2018. when the
function is called i want to extract and display data between this two
dates.

i just need some help with the query to accomplish that.

I am using sqlalchemy to pull data from an mssql db

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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y5k%2BzWJS0Wtyh9-%3Dh8yu%3DTjLUiVV7scW69GrW3sDaZZPA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: export sql query to excel

2018-04-16 Thread sum abiut
Thanks guys it took me a while and a lot of research, finally get it to
work.

my view.py

import pandas as pd
from django.http import HttpResponse
try:
from io import BytesIO as IO # for modern python
except ImportError:
from StringIO import StringIO as IO # for legacy python

def download_excel(request):
if "selectdate" in request.POST:
if "selectaccount" in request.POST:
selected_date = request.POST["selectdate"]
selected_acc = request.POST["selectaccount"]
if selected_date==selected_date:
if selected_acc==selected_acc:
convert=datetime.datetime.strptime(selected_date,
"%Y-%m-%d").toordinal()

engine=create_engine('mssql+pymssql://username:password@servername /db')


metadata=MetaData(connection)

fund=Table('gltrxdet',metadata,autoload=True,autoload_with=engine)

rate=Table('gltrx_all',metadata,autoload=True,autoload_with=engine)

stmt=select([fund.columns.account_code,fund.columns.description,fund.columns.nat_balance,rate.columns.date_applied,fund.columns.journal_ctrl_num,rate.columns.journal_ctrl_num])

stmt=stmt.where(and_(rate.columns.journal_ctrl_num==fund.columns.journal_ctrl_num,fund.columns.account_code==selected_acc,rate.columns.date_applied==convert))
results=connection.execute(stmt)

sio = StringIO()
df = pd.DataFrame(data=list(results),
columns=results.keys())

dowload excel file##
excel_file = IO()
xlwriter = pd.ExcelWriter(excel_file, engine='xlsxwriter')
df.to_excel(xlwriter, 'sheetname')
xlwriter.save()
xlwriter.close()
excel_file.seek(0)

response = HttpResponse(excel_file.read(),
content_type='application/ms-excel
vnd.openxmlformats-officedocument.spreadsheetml.sheet')
# set the file name in the Content-Disposition header
response['Content-Disposition'] = 'attachment;
filename=myfile.xls'
return response











On Tue, Apr 17, 2018 at 1:40 PM, Gerardo Palazuelos Guerrero <
gerardo.palazue...@gmail.com> wrote:

> hi,
> I don´t have this github, so let me try to show you what I do.
> Sorry if I´m not applying best practices, but this is working on my side;
> I run this manually from cmd in Windows 10 (no django on this).
>
> Content of my requirements.txt:
> et-xmlfile==1.0.1
> jdcal==1.3
> openpyxl==2.5.1
> pyodbc==4.0.22
>
>
>
> This is something optional I did. I extracted my database connection from
> the simple py file:
> import pyodbc
>
> class connection:
> conn = None
>
> def get_connection(self):
> self.conn = pyodbc.connect(
> r'DRIVER={ODBC Driver 13 for SQL Server};'
> r'SERVER=;'
> r'DATABASE=;'
> r'UID=;'
> r'PWD= )
>
> return self.conn
>
>
>
> This is my routine to generate excel file:
> from mssqlconnection import connection
> import sys
> import openpyxl
> import os
> import calendar
> import time
> import datetime
> import smtplib
> import base64
>
> cursor = connection().get_connection().cursor()
>
>
> query_to_execute = """
> the SQL query goes here
> """
>
> def run_query(start_date, end_date):
>
> # executing the query, also I´m passing parameters to my query (dates)
> cursor.execute(query_to_execute, (start_date, end_date))
>
> # load columns into a list
> columns = [column[0] for column in cursor.description]
> #print(columns)
>
> dir_path = os.path.dirname(os.path.realpath(__file__))
> print("file to be saved in following directory: %s" % dir_path)
>
> os.chdir(dir_path)
> wb = openpyxl.Workbook()
> sheet = wb["Sheet"] # default sheet to be renamed
>
> new_sheet_name = "CustomSheetName"
> sheet.title = new_sheet_name
>
> rows = cursor.fetchall()
> tmpRows = 1
> tmpColumns = 0
>
> # save the columns names on first row
> for column in columns:
> tmpColumns += 1
> sheet.cell(row = tmpRows, column = tmpColumns).value = column
>
> # save rows, iterate over each and every row
> # this process is fast, for my surprise
> for row in rows:
> tmpRows += 1
> tmpColumns = 0
> for column in columns:
> tmpColumns += 1
> sheet.cell(row = tmpRows, column = tmpColumns).value = str(getattr
> (row,column))
>
> excel_file_name = "myfilenamegoeshere.xlsx"
>
> full_path = "%s\\%s" % (dir_path, excel_file_name)
>
> wb.save(excel_file_name)
> cursor.close()
>
> write_log("excel file created with the following filename: %s" %
> excel_file_name)
>
>
> After Excel file is generated, I´m sending it by em

Re: export sql query to excel

2018-04-16 Thread sum abiut
Thanks Larry,
How to i pass my query parameter to the xlsxwriter.

Cheers



On Tue, Apr 17, 2018 at 1:42 AM, Larry Martell <larry.mart...@gmail.com>
wrote:

> I use xlsxwriter and I do it like this:
>
> output = io.BytesIO()
> workbook = xlsxwriter.Workbook(output, {'in_memory': True})
> # write file
> output.seek(0)
> response = HttpResponse(output.read(),
> content_type='application/ms-excel')
> response['Content-Disposition'] = "attachment; filename=%s" %
> xls_name
> return response
>
> On Mon, Apr 16, 2018 at 2:05 AM, sum abiut <suab...@gmail.com> wrote:
> > my code actually worked. I thought it was going to save the excel file to
> > 'C:\excel' folder so i was looking for the file in the folder but i
> couldn't
> > find the excel file. The excel file was actually exported to my django
> > project folder instead.
> >
> > How to i allow the end user to be able to download the file to their
> desktop
> > instead of exporting it to the server itself
> >
> >
> >
> > On Mon, Apr 16, 2018 at 3:27 PM, sum abiut <suab...@gmail.com> wrote:
> >>
> >> I wrote a function to export sql query to an excel file, but some how
> the
> >> excel file wasn't created when the function was call. appreciate any
> >> assistances
> >>
> >> here is my view.py
> >>
> >> def download_excel(request):
> >> if "selectdate" in request.POST:
> >> if "selectaccount" in request.POST:
> >> selected_date = request.POST["selectdate"]
> >> selected_acc = request.POST["selectaccount"]
> >> if selected_date==selected_date:
> >> if selected_acc==selected_acc:
> >> convert=datetime.datetime.strptime(selected_date,
> >> "%Y-%m-%d").toordinal()
> >>
> >> engine=create_engine('mssql+pymssql://username:password@servername
> /db')
> >> connection = engine.connect()
> >> metadata=MetaData()
> >>
> >> fund=Table('gltrxdet',metadata,autoload=True,autoload_with=engine)
> >>
> >> rate=Table('gltrx_all',metadata,autoload=True,autoload_with=engine)
> >>
> >> stmt=select([fund.columns.account_code,fund.columns.
> description,fund.columns.nat_balance,fund.columns.rate_
> type_home,rate.columns.date_applied,rate.columns.date_
> entered,fund.columns.journal_ctrl_num,rate.columns.journal_ctrl_num])
> >>
> >> stmt=stmt.where(and_(rate.columns.journal_ctrl_num==
> fund.columns.journal_ctrl_num,fund.columns.account_code==
> selected_acc,rate.columns.date_entered==convert))
> >>
> >> df = pd.read_sql(stmt,connection)
> >>
> >> writer = pd.ExcelWriter('C:\excel\export.xls')
> >> df.to_excel(writer, sheet_name ='bar')
> >> writer.save()
> >>
> >>
> >
> >
> >
> > --
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to django-users+unsubscr...@googlegroups.com.
> > To post to this group, send email to django-users@googlegroups.com.
> > Visit this group at https://groups.google.com/group/django-users.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/django-users/CAPCf-
> y75oSOhthBTv8JjhCjEoZHy1_TC7dn%3DKwG%3D8GGqjwPA3Q%40mail.gmail.com.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CACwCsY5O0pfHkkXCd430fe6nO%2B0pJgedqtkXoMovropRUnqfUg%
> 40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: export sql query to excel

2018-04-16 Thread sum abiut
Thanks Larry,
I haven't actually try xlsxwriter before so i find some difficulties
understanding your code. Do you mind explaining the code, i will definitely
have a read on the documentation.

cheers


On Tue, Apr 17, 2018 at 1:42 AM, Larry Martell <larry.mart...@gmail.com>
wrote:

> I use xlsxwriter and I do it like this:
>
> output = io.BytesIO()
> workbook = xlsxwriter.Workbook(output, {'in_memory': True})
> # write file
> output.seek(0)
> response = HttpResponse(output.read(),
> content_type='application/ms-excel')
> response['Content-Disposition'] = "attachment; filename=%s" %
> xls_name
> return response
>
> On Mon, Apr 16, 2018 at 2:05 AM, sum abiut <suab...@gmail.com> wrote:
> > my code actually worked. I thought it was going to save the excel file to
> > 'C:\excel' folder so i was looking for the file in the folder but i
> couldn't
> > find the excel file. The excel file was actually exported to my django
> > project folder instead.
> >
> > How to i allow the end user to be able to download the file to their
> desktop
> > instead of exporting it to the server itself
> >
> >
> >
> > On Mon, Apr 16, 2018 at 3:27 PM, sum abiut <suab...@gmail.com> wrote:
> >>
> >> I wrote a function to export sql query to an excel file, but some how
> the
> >> excel file wasn't created when the function was call. appreciate any
> >> assistances
> >>
> >> here is my view.py
> >>
> >> def download_excel(request):
> >> if "selectdate" in request.POST:
> >> if "selectaccount" in request.POST:
> >> selected_date = request.POST["selectdate"]
> >> selected_acc = request.POST["selectaccount"]
> >> if selected_date==selected_date:
> >> if selected_acc==selected_acc:
> >> convert=datetime.datetime.strptime(selected_date,
> >> "%Y-%m-%d").toordinal()
> >>
> >> engine=create_engine('mssql+pymssql://username:password@servername
> /db')
> >> connection = engine.connect()
> >> metadata=MetaData()
> >>
> >> fund=Table('gltrxdet',metadata,autoload=True,autoload_with=engine)
> >>
> >> rate=Table('gltrx_all',metadata,autoload=True,autoload_with=engine)
> >>
> >> stmt=select([fund.columns.account_code,fund.columns.
> description,fund.columns.nat_balance,fund.columns.rate_
> type_home,rate.columns.date_applied,rate.columns.date_
> entered,fund.columns.journal_ctrl_num,rate.columns.journal_ctrl_num])
> >>
> >> stmt=stmt.where(and_(rate.columns.journal_ctrl_num==
> fund.columns.journal_ctrl_num,fund.columns.account_code==
> selected_acc,rate.columns.date_entered==convert))
> >>
> >> df = pd.read_sql(stmt,connection)
> >>
> >> writer = pd.ExcelWriter('C:\excel\export.xls')
> >> df.to_excel(writer, sheet_name ='bar')
> >> writer.save()
> >>
> >>
> >
> >
> >
> > --
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to django-users+unsubscr...@googlegroups.com.
> > To post to this group, send email to django-users@googlegroups.com.
> > Visit this group at https://groups.google.com/group/django-users.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/django-users/CAPCf-
> y75oSOhthBTv8JjhCjEoZHy1_TC7dn%3DKwG%3D8GGqjwPA3Q%40mail.gmail.com.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CACwCsY5O0pfHkkXCd430fe6nO%2B0pJgedqtkXoMovropRUnqfUg%
> 40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: export sql query to excel

2018-04-16 Thread sum abiut
my code actually worked. I thought it was going to save the excel file to
'C:\excel' folder so i was looking for the file in the folder but i
couldn't find the excel file. The excel file was actually exported to my
django project folder instead.

How to i allow the end user to be able to download the file to their
desktop instead of exporting it to the server itself


On Mon, Apr 16, 2018 at 3:27 PM, sum abiut <suab...@gmail.com> wrote:

> I wrote a function to export sql query to an excel file, but some how the
> excel file wasn't created when the function was call. appreciate any
> assistances
>
> here is my view.py
>
> def download_excel(request):
> if "selectdate" in request.POST:
> if "selectaccount" in request.POST:
> selected_date = request.POST["selectdate"]
> selected_acc = request.POST["selectaccount"]
> if selected_date==selected_date:
> if selected_acc==selected_acc:
> convert=datetime.datetime.strptime(selected_date, 
> "%Y-%m-%d").toordinal()
> 
> engine=create_engine('mssql+pymssql://username:password@servername /db')
> connection = engine.connect()
> metadata=MetaData()
> 
> fund=Table('gltrxdet',metadata,autoload=True,autoload_with=engine)
> 
> rate=Table('gltrx_all',metadata,autoload=True,autoload_with=engine)
> 
> stmt=select([fund.columns.account_code,fund.columns.description,fund.columns.nat_balance,fund.columns.rate_type_home,rate.columns.date_applied,rate.columns.date_entered,fund.columns.journal_ctrl_num,rate.columns.journal_ctrl_num])
> 
> stmt=stmt.where(and_(rate.columns.journal_ctrl_num==fund.columns.journal_ctrl_num,fund.columns.account_code==selected_acc,rate.columns.date_entered==convert))
>
> df = pd.read_sql(stmt,connection)
>
> writer = pd.ExcelWriter('C:\excel\export.xls')
> df.to_excel(writer, sheet_name ='bar')
> writer.save()
>
>
>


--

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


export sql query to excel

2018-04-15 Thread sum abiut
I wrote a function to export sql query to an excel file, but some how the
excel file wasn't created when the function was call. appreciate any
assistances

here is my view.py

def download_excel(request):
if "selectdate" in request.POST:
if "selectaccount" in request.POST:
selected_date = request.POST["selectdate"]
selected_acc = request.POST["selectaccount"]
if selected_date==selected_date:
if selected_acc==selected_acc:
convert=datetime.datetime.strptime(selected_date,
"%Y-%m-%d").toordinal()

engine=create_engine('mssql+pymssql://username:password@servername
/db')
connection = engine.connect()
metadata=MetaData()

fund=Table('gltrxdet',metadata,autoload=True,autoload_with=engine)

rate=Table('gltrx_all',metadata,autoload=True,autoload_with=engine)

stmt=select([fund.columns.account_code,fund.columns.description,fund.columns.nat_balance,fund.columns.rate_type_home,rate.columns.date_applied,rate.columns.date_entered,fund.columns.journal_ctrl_num,rate.columns.journal_ctrl_num])

stmt=stmt.where(and_(rate.columns.journal_ctrl_num==fund.columns.journal_ctrl_num,fund.columns.account_code==selected_acc,rate.columns.date_entered==convert))

df = pd.read_sql(stmt,connection)

writer = pd.ExcelWriter('C:\excel\export.xls')
df.to_excel(writer, sheet_name ='bar')
writer.save()

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


Re: survey form

2018-03-26 Thread sum abiut
i have build an app that allow the admin to add survey title, question and
choices. I needed assistance display all the questions and answer in front
end to allow the users to take the survey. can i do that with a form.
needed  directions.

my models.py

class Survey(models.Model):
title = models.CharField(max_length = 200,blank=True)
def __unicode__(self):
return self.title

class Question(models.Model):

question_text=models.CharField(max_length=100,blank=True)
Survey_Title =
models.ForeignKey(Survey,on_delete=models.CASCADE,default="")
def __unicode__(self):
return self.question_text




class answer(models.Model):

question=models.ForeignKey(Question,on_delete=models.CASCADE)
answer_text=models.CharField(max_length=200,blank=True,default="")
option=(
('Yes','Yes'),
('No','No'),

)

Selection_an_Option=models.CharField(max_length=100,choices=option,blank=True,default="")
def __unicode__(self):
return self.answer_text


class SurveyAnswer(models.Model):
orig_survey = models.ForeignKey(Survey,on_delete=models.CASCADE)

class QuestionAnswer(models.Model):
answer = models.ForeignKey(answer,on_delete=models.CASCADE)
survey_answer = models.ForeignKey(SurveyAnswer,on_delete=models.CASCADE)


Cheers



On Wed, Mar 21, 2018 at 5:02 PM, sum abiut <suab...@gmail.com> wrote:

> Thanks heaps Mike.
>
>
> On Wed, Mar 21, 2018 at 3:21 PM, Mike Dewhirst <mi...@dewhirst.com.au>
> wrote:
>
>> On 21/03/2018 1:17 PM, sum abiut wrote:
>>
>>> Hi,
>>> I am planning to build a survey app that allow the administator to add
>>> new questioner and the question to be answer by the users.But i am having
>>> trouble figuring how to get started. Just wondering if i need to have two
>>> models one for the answes and another model to store the questions. I need
>>> some directions.
>>>
>>
>> The official Django tutorial builds a poll app. I could be wrong but that
>> sounds like exactly what you want.
>>
>> https://docs.djangoproject.com/en/2.0/intro/tutorial01/
>>
>>
>>
>>> 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 >> django-users+unsubscr...@googlegroups.com>.
>>> To post to this group, send email to django-users@googlegroups.com
>>> <mailto:django-users@googlegroups.com>.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/django-users/CAPCf-y5uR9m%3Diu7XdJEJAg%2B4Oj9EpCVrZg2_ip
>>> zrSbBUuaYPGg%40mail.gmail.com <https://groups.google.com/d/m
>>> sgid/django-users/CAPCf-y5uR9m%3Diu7XdJEJAg%2B4Oj9EpCVrZg2_i
>>> pzrSbBUuaYPGg%40mail.gmail.com?utm_medium=email_source=footer>.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>
>

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


Re: survey form

2018-03-21 Thread sum abiut
Thanks heaps Mike.


On Wed, Mar 21, 2018 at 3:21 PM, Mike Dewhirst <mi...@dewhirst.com.au>
wrote:

> On 21/03/2018 1:17 PM, sum abiut wrote:
>
>> Hi,
>> I am planning to build a survey app that allow the administator to add
>> new questioner and the question to be answer by the users.But i am having
>> trouble figuring how to get started. Just wondering if i need to have two
>> models one for the answes and another model to store the questions. I need
>> some directions.
>>
>
> The official Django tutorial builds a poll app. I could be wrong but that
> sounds like exactly what you want.
>
> https://docs.djangoproject.com/en/2.0/intro/tutorial01/
>
>
>
>> 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 > django-users+unsubscr...@googlegroups.com>.
>> To post to this group, send email to django-users@googlegroups.com
>> <mailto:django-users@googlegroups.com>.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/CAPCf-y5uR9m%3Diu7XdJEJAg%2B4Oj9EpCVrZg2_
>> ipzrSbBUuaYPGg%40mail.gmail.com <https://groups.google.com/d/m
>> sgid/django-users/CAPCf-y5uR9m%3Diu7XdJEJAg%2B4Oj9EpCVrZg2_
>> ipzrSbBUuaYPGg%40mail.gmail.com?utm_medium=email_source=footer>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>


-- 
__
 | Sum Abiut |

*Security Blog : Security Tips <http://mysecuritytips.wordpress.com/>  |
Programming  Blog: Programming <http://mrcoderguide.wordpress.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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y7OOybJ0tHJTYtNrYTibgh1Lz20mWDdDiKVOjj5fGzqvQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


survey form

2018-03-20 Thread sum abiut
Hi,
I am planning to build a survey app that allow the administator to add new
questioner and the question to be answer by the users.But i am having
trouble figuring how to get started. Just wondering if i need to have two
models one for the answes and another model to store the questions. I need
some directions.

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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y5uR9m%3Diu7XdJEJAg%2B4Oj9EpCVrZg2_ipzrSbBUuaYPGg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: import file from view.py

2018-03-14 Thread sum abiut
Thanks,
i manage to resolve that by creating a function on the conf.py file which
connect to the db, then call that function from view.py


conf.py

from sqlalchemy import*
def connect():
engine=create_engine('mssql+pymssql://userbame:password@host /db')
connection=engine.connect()
return engine,connection

view.py
from userprofile.conf import *

engine,connection=connect()


On Wed, Mar 14, 2018 at 11:26 PM, Mahesh M J <ammasm...@gmail.com> wrote:

> Hi,
> You can try to create a Python module and write a parser there and set the
> variables. You can import that file in views.py and use it for getting the
> relevant values. Hope this helps.
>
> Thanks,
> Mahesh.
>
> On Tue, Mar 13, 2018 at 21:06 sum abiut <suab...@gmail.com> wrote:
>
>> I have a conf file containing the parameter of hostmane,db,usernam,pass,
>> db
>>
>> i want to import that file from view.py and use parameter from the conf
>> file to connect to a db.
>>
>> i did something this from appname.conf import but it doesn't seem to
>> work, appreciate any assistance.
>>
>> 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 post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/
>> msgid/django-users/CAPCf-y5Og0o5yb_e%3D6ggLjS%
>> 2BOtDyZFUoqe_9KYZLbC1w72g7MA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAPCf-y5Og0o5yb_e%3D6ggLjS%2BOtDyZFUoqe_9KYZLbC1w72g7MA%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> Mahesh M.J
> Bioinformatics Consultant
> Novartis Pharmaceuticals
> 1 Health Plaza, East Hanover
> <https://maps.google.com/?q=1+Health+Plaza,+East+Hanover+New+Jersey-07039=gmail=g>
> New Jersey-07039
> <https://maps.google.com/?q=1+Health+Plaza,+East+Hanover+New+Jersey-07039=gmail=g>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAHJ%2BPuSW1eb4t2bPvgnN8L_LAAt862wwYHCEjamhDRX3cW%2BR%
> 2Bg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAHJ%2BPuSW1eb4t2bPvgnN8L_LAAt862wwYHCEjamhDRX3cW%2BR%2Bg%40mail.gmail.com?utm_medium=email_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


import file from view.py

2018-03-13 Thread sum abiut
I have a conf file containing the parameter of hostmane,db,usernam,pass, db

i want to import that file from view.py and use parameter from the conf
file to connect to a db.

i did something this from appname.conf import but it doesn't seem to work,
appreciate any assistance.

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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y5Og0o5yb_e%3D6ggLjS%2BOtDyZFUoqe_9KYZLbC1w72g7MA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django mathfiters

2018-02-28 Thread sum abiut
Thanks Peter.

cheers,

On Wed, Feb 28, 2018 at 5:05 PM, Peter of the Norse <rahmc...@radio1190.org>
wrote:

> I would do
> {% with a=42 c=b.value|default_if_none:0}
>
> - Peter of the Norse
>
> On Feb 21, 2018, at 3:47 PM, Matthew Pava <matthew.p...@iss.com> wrote:
>
> And how are you checking if it’s None?  I would do it like this:
>
> {% if c %}
>
> {{ a|add:c }}
>
> {% else %}
>
>   {{ a }}
>
> {% endif %}
>
>
>
> *From:* django-users@googlegroups.com [mailto:django-users@
> googlegroups.com <django-users@googlegroups.com>] *On Behalf Of *sum abiut
> *Sent:* Wednesday, February 21, 2018 4:43 PM
> *To:* django-users@googlegroups.com
> *Subject:* Re: django mathfiters
>
>
>
> Thanks for your response. Yes the value was actually None. how to i
> display 42  instead of not displaying anything at all. I have try using the
> if statement to check for the value of c if its None i just display the
> value of a, and if is not None i add the values. But still its displaying
> nothing.
>
>
>
> Thanks
>
>
>
> On Thu, Feb 22, 2018 at 9:15 AM, Matthew Pava <matthew.p...@iss.com>
> wrote:
>
> Check the value of b.value.  Make sure it isn’t None.
>
>
>
> *From:* django-users@googlegroups.com [mailto:django-users@
> googlegroups.com] *On Behalf Of *sum abiut
> *Sent:* Wednesday, February 21, 2018 4:06 PM
> *To:* django-users@googlegroups.com
> *Subject:* django mathfiters
>
>
>
>
>
> Hi,
>
> How to you a zero in mathfilter
>
> for example, if the value of c is zero the total is not display. instead
> of displaying 42 it display nothing.
>
>
>
> {%for b in pay%}
>
> {% with a=42 c=b.value%}
>
>  {{ a|add:c }}
>
> {% endwith %}
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/8C4DDEF6-9168-4181-B5DD-8E37AB487685%40Radio1190.org
> <https://groups.google.com/d/msgid/django-users/8C4DDEF6-9168-4181-B5DD-8E37AB487685%40Radio1190.org?utm_medium=email_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



--

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


Re: template parse error

2018-02-22 Thread sum abiut
Thanks heaps Daniel,
it was the spaces

On Thu, Feb 22, 2018 at 10:57 PM, Daniel Roseman 
wrote:

> On Thursday, 22 February 2018 06:16:32 UTC, suabiut wrote:
>>
>> Could not parse the remainder: '=="1"' from 'selected_value=="1"'
>>
>>
>> i got the above error  when passing the select value. I have no clue what
>> i am missing. please assist
>> {%if selected_value=="1"%}
>>
>>
>>
>>
>> Cheers,
>>
>
> You need spaces - the template language is not Python, and its parser is
> fairly basic.
>
> {% if selected_value == "1" %}
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/e6befa94-3c19-4ff5-b65d-4aa912f160e0%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



--

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


template parse error

2018-02-21 Thread sum abiut
Could not parse the remainder: '=="1"' from 'selected_value=="1"'


i got the above error  when passing the select value. I have no clue what i
am missing. please assist
{%if selected_value=="1"%}




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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y4z-tyC-zkmA%3Ds90EMDTEj17%2BGJOZN1QPhBit1pJoChZA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django mathfiters

2018-02-21 Thread sum abiut
Thanks heaps.

On Thu, Feb 22, 2018 at 9:47 AM, Matthew Pava <matthew.p...@iss.com> wrote:

> And how are you checking if it’s None?  I would do it like this:
>
> {% if c %}
>
> {{ a|add:c }}
>
> {% else %}
>
>   {{ a }}
>
> {% endif %}
>
>
>
> *From:* django-users@googlegroups.com [mailto:django-users@
> googlegroups.com] *On Behalf Of *sum abiut
> *Sent:* Wednesday, February 21, 2018 4:43 PM
> *To:* django-users@googlegroups.com
> *Subject:* Re: django mathfiters
>
>
>
> Thanks for your response. Yes the value was actually None. how to i
> display 42  instead of not displaying anything at all. I have try using the
> if statement to check for the value of c if its None i just display the
> value of a, and if is not None i add the values. But still its displaying
> nothing.
>
>
>
> Thanks
>
>
>
> On Thu, Feb 22, 2018 at 9:15 AM, Matthew Pava <matthew.p...@iss.com>
> wrote:
>
> Check the value of b.value.  Make sure it isn’t None.
>
>
>
> *From:* django-users@googlegroups.com [mailto:django-users@
> googlegroups.com] *On Behalf Of *sum abiut
> *Sent:* Wednesday, February 21, 2018 4:06 PM
> *To:* django-users@googlegroups.com
> *Subject:* django mathfiters
>
>
>
>
>
> Hi,
>
> How to you a zero in mathfilter
>
> for example, if the value of c is zero the total is not display. instead
> of displaying 42 it display nothing.
>
>
>
> {%for b in pay%}
>
> {% with a=42 c=b.value%}
>
>  {{ a|add:c }}
>
> {% endwith %}
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAPCf-y5F9bP8AVU2qXhXjMPhK4kwHBfWza2
> WL7j424VUkAgCRg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAPCf-y5F9bP8AVU2qXhXjMPhK4kwHBfWza2WL7j424VUkAgCRg%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/a975b53b163440e990433832734b598f%40ISS1.ISS.LOCAL
> <https://groups.google.com/d/msgid/django-users/a975b53b163440e990433832734b598f%40ISS1.ISS.LOCAL?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAPCf-y4%3D_cMyrBTU177Pqkd74GUzqurAyYsmHWL
> -CtakR6r%3DMA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAPCf-y4%3D_cMyrBTU177Pqkd74GUzqurAyYsmHWL-CtakR6r%3DMA%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/c5abd85a850a4aceb48beb2cb078159b%40ISS1.ISS.LOCAL
> <https://groups.google.com/d/msgid/django-users/c5abd85a850a4aceb48beb2cb078159b%40ISS1.ISS.LOCAL?utm_medium=email_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



--

-- 
You received this message because you are subscribed to the Google Groups 
"Dja

Re: django mathfiters

2018-02-21 Thread sum abiut
Thanks for your response. Yes the value was actually None. how to i display
42  instead of not displaying anything at all. I have try using the if
statement to check for the value of c if its None i just display the value
of a, and if is not None i add the values. But still its displaying
nothing.

Thanks

On Thu, Feb 22, 2018 at 9:15 AM, Matthew Pava <matthew.p...@iss.com> wrote:

> Check the value of b.value.  Make sure it isn’t None.
>
>
>
> *From:* django-users@googlegroups.com [mailto:django-users@
> googlegroups.com] *On Behalf Of *sum abiut
> *Sent:* Wednesday, February 21, 2018 4:06 PM
> *To:* django-users@googlegroups.com
> *Subject:* django mathfiters
>
>
>
>
>
> Hi,
>
> How to you a zero in mathfilter
>
> for example, if the value of c is zero the total is not display. instead
> of displaying 42 it display nothing.
>
>
>
> {%for b in pay%}
>
> {% with a=42 c=b.value%}
>
>  {{ a|add:c }}
>
> {% endwith %}
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAPCf-y5F9bP8AVU2qXhXjMPhK4kwHBfWza2
> WL7j424VUkAgCRg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAPCf-y5F9bP8AVU2qXhXjMPhK4kwHBfWza2WL7j424VUkAgCRg%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/a975b53b163440e990433832734b598f%40ISS1.ISS.LOCAL
> <https://groups.google.com/d/msgid/django-users/a975b53b163440e990433832734b598f%40ISS1.ISS.LOCAL?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



--

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


django mathfiters

2018-02-21 Thread sum abiut
Hi,
How to you a zero in mathfilter
for example, if the value of c is zero the total is not display. instead of
displaying 42 it display nothing.

{%for b in pay%}

{% with a=42 c=b.value%}
 {{ a|add:c }}
{% endwith %}

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


Re: modelform selection options

2018-02-17 Thread sum abiut
Ok now i have written my view,py

def payhistory(request):
paynum=selection.objects.all()
num=request.POST.get('dropdown')
if request.method=='GET':
form=paynumberform()
else:
select=selection.objects.get(num=num)
#do someting
return render(request,'displaypayhistory.html',locals())

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


and my template 'payhistory.html

{%csrf_token%}
  
Pay Number:
  

  {%for paynum in paynum%}

  {{paynum.num}}
  {%endfor%}







  



i manage to load the form, but the drop down list elements are not showing.


cheers,



On Fri, Feb 16, 2018 at 11:00 AM, sum abiut <suab...@gmail.com> wrote:

> I have a model.py
> class selection(models.Model):
> select=(
> (A','A'),
> ('B','B'),
> ('C','C'),
>
>
> )
>
> options=models.CharField(max_length=7,choices=select)
>
>
> and form.py
>
> class order(forms.ModelForm):
> class Meta:
> model=selection
> fields=('Pay_options,)
>
>
> I want to write a view.py that check the form for the choice that is
> selected but i don't know how to get started. for example if a user select
> option A, i want to perform some query. I want to know how to check for the
> options that are selected before i can performing a query. Appreciate any
> assistances.
>
> 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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y74TkxU925m6V3hqh6c0U8NmaKjoKt4fwXADOuXFVPtqQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


modelform selection options

2018-02-15 Thread sum abiut
I have a model.py
class selection(models.Model):
select=(
(A','A'),
('B','B'),
('C','C'),


)

options=models.CharField(max_length=7,choices=select)


and form.py

class order(forms.ModelForm):
class Meta:
model=selection
fields=('Pay_options,)


I want to write a view.py that check the form for the choice that is
selected but i don't know how to get started. for example if a user select
option A, i want to perform some query. I want to know how to check for the
options that are selected before i can performing a query. Appreciate any
assistances.

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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y5UoHSSK0pPMwuzSyStwgj9fpmPF%3DLRaKFbfNZuQbTfAQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I move a project from one computer to another?

2018-02-12 Thread sum abiut
It depends on where you want to house your app.if you need to house your
app on the new machine. Just pip install from your requirements.txt file,
then copy your django project to your new machine.

On 13/02/2018 11:10 AM, "Tom Tanner"  wrote:

> I have a Django project that I want to work on with another computer. Do I
> need to backup my current project's Postgres database and restore it on the
> other computer's Postgres database to get my project up and running there?
> Or is there a Django way to 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/b5ab2022-4fd1-4f8f-bb40-d4194bbf397f%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: How to fetch data from sql server and display on django web pages

2018-02-12 Thread sum abiut
You may want to check out sqlalchemy they provide a pretty good
documentation on what you are aftering
http://docs.sqlalchemy.org/en/latest/dialects/mssql.html

>From you view you can defile a function like so.

view.py

from sqlalchemy import*
from django.shortcuts import render

def connectto_db(request):
engine=create_engine('mssql+pymssql://username:password@servername
/Ddabname')
connection=engine.connect()
metadata=MetaData()


table=Table('tablename',metadata,autoload=True,autoload_with=engine)
stmt='SELECT * FROM table'
results=connection.execute(stmt).fetchall()
return render(request,'template.html',locals())


then  you can pass the results to your template.html

Hope this helps.

Cheers

On Sun, Feb 11, 2018 at 4:37 PM, Amit Kadivar 
wrote:

> Please Help me.
> How to fetch data from sql server and display them on django web pages
> through nginx web server..
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/b5577524-e67d-465f-bb49-e54bca92c88b%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



--

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


modelform not loading from template

2018-02-08 Thread sum abiut
Hi,
i have a hard time figuring out why this form in not loaded on the
template. There is no error but the form is not loading. Please advise what
i am missing here.

view.py

def addcontact(request):
if request.method=='POST':
form =ContactForm(request.POST)
if form.is_valid():
form.save()
return HttpResponse('Success')
else:
form =ContactForm()
return render(request,'addcontact.html',{'form':form})

form.py

class ContactForm(forms.ModelForm):
class Meta:
model =contacts
fields = ('First_Name', 'Last_Name', 'Department','Extension')


addcontact.html


  {% csrf_token %}

  {{ form }}
  Submit


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


Re: import eror views

2018-02-05 Thread sum abiut
shows us your url.py

On Tue, Feb 6, 2018 at 12:11 AM, sarvit sarvit 
wrote:

> hello
> please help for dibog
> Traceback (most recent call last):
>   File "c:\Users\saeid\Desktop\sade\env\Post\Post\urls.py", line 20, in
> 
> from . import views
> ImportError: cannot import name 'views'
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/a019be7f-1240-4f31-8655-b36c758a709a%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



--

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


Re: view user profile access restriction

2018-01-29 Thread sum abiut
Thanks heaps , I noticed that.

On 29/01/2018 8:28 PM, "Daniel Roseman"  wrote:

On Monday, 29 January 2018 05:57:55 UTC, suabiut wrote:
>
> I manage to fixed it. I have created two instances (profile_info and info)
> in my view, i use the first instance to access the information from my
> Profile model and the second instance to access th User model. I also set
> the *AUTH_PROFILE_MODULE = 'Profile' in my settings.py.*
>
>
The first part is fine, but AUTH_PROFILE_MODEL hasn't done anything since
Django 1.7 - there's no point in setting it.
-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/
msgid/django-users/dccb20d9-fe7f-47e5-a1f6-333f2087e4d6%40googlegroups.com

.

For more options, visit https://groups.google.com/d/optout.

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


Re: view user profile access restriction

2018-01-28 Thread sum abiut
I manage to fixed it. I have created two instances (profile_info and info)
in my view, i use the first instance to access the information from my
Profile model and the second instance to access th User model. I also set
the *AUTH_PROFILE_MODULE = 'Profile' in my settings.py.*

*my updated view.py*


def loggin(request):

if request.user.is_authenticated:
profile_info=request.user.profile
info=request.user
return render(request,'dashboard.html',locals())


cheers,



On Mon, Jan 29, 2018 at 3:17 PM, sum abiut <suab...@gmail.com> wrote:

> Thanks heaps that worked. But then how to i retrieve the rest of the
> profile info from the second table? i have a one-to-one relationship. i
> mange to extract data from the user table which is first name, last name,
> email. but i am having difficulty figuring out accessing information from
> the second table (Profile)
>
> view.py
>
> ef loggin(request):
> username=None
> if request.user.is_authenticated:
> info=request.user
> return render(request,'dashboard.html',locals())
>
>
>
>
> my model.py
>
> class Profile(models.Model):
> user=models.OneToOneField(User, on_delete=models.CASCADE)
> bio=models.TextField(default='',blank=True)
> sex=(
> ('Male','Male'),
> ('Female','Female'),
>
> )
>
> Gender=models.CharField(max_length=100,choices=sex,blank=
> True,default='')
> Phone=models.CharField(max_length=20,blank=True,default='')
> island=models.CharField(max_length=100,blank=True,default='')
> city=models.CharField(max_length=100,blank=True,default='')
> country=models.CharField(max_length=100,blank=True,default='')
> organization=models.CharField(max_length=100,blank=True,default='')
>
>
> account_number=models.CharField(max_length=100,blank=True,default='')
> bank_phone=models.CharField(max_length=100,blank=True,default='')
>
>
> def create_profile(sender, **kwargs):
> user = kwargs["instance"]
> if kwargs["created"]:
> user_profile = Profile(user=user)
> user_profile.save()
> post_save.connect(create_profile, sender=User)
>
>
>
>
>
>
>
>
>
> On Mon, Jan 29, 2018 at 1:02 PM, Dylan Reinhold <dreinh...@gmail.com>
> wrote:
>
>> There are a bunch of ways to do it.
>> Show us your view, if it's a function based view, just do your select on
>> (username=request.user)
>>
>> Dylan
>>
>> On Sun, Jan 28, 2018 at 4:59 PM, sum abiut <suab...@gmail.com> wrote:
>>
>>> Hi,
>>> i have a django app that i want the users to be able to view only their
>>> user profile once they have login. currently any user that login is able to
>>> view other users profile as well. Appreciate is you could point me to the
>>> right direction.
>>>
>>> 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 post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/django-users/CAPCf-y7ZZx0BfQe0jwZu8-h%2Bo7nU%3DZYg%3Dgr2
>>> nxYeU%2BjskVTCtw%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAPCf-y7ZZx0BfQe0jwZu8-h%2Bo7nU%3DZYg%3Dgr2nxYeU%2BjskVTCtw%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/CAHtg44CnQo8DtMunvmR5StuFD3vw5y0dk8dJqXM46m
>> tDuaxR_w%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAHtg44CnQo8DtMunvmR5StuFD3vw5y0dk8dJqXM46mtDuaxR_w%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
>

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


Re: view user profile access restriction

2018-01-28 Thread sum abiut
Thanks heaps that worked. But then how to i retrieve the rest of the
profile info from the second table? i have a one-to-one relationship. i
mange to extract data from the user table which is first name, last name,
email. but i am having difficulty figuring out accessing information from
the second table (Profile)

view.py

ef loggin(request):
username=None
if request.user.is_authenticated:
info=request.user
return render(request,'dashboard.html',locals())




my model.py

class Profile(models.Model):
user=models.OneToOneField(User, on_delete=models.CASCADE)
bio=models.TextField(default='',blank=True)
sex=(
('Male','Male'),
('Female','Female'),

)


Gender=models.CharField(max_length=100,choices=sex,blank=True,default='')
Phone=models.CharField(max_length=20,blank=True,default='')
island=models.CharField(max_length=100,blank=True,default='')
city=models.CharField(max_length=100,blank=True,default='')
country=models.CharField(max_length=100,blank=True,default='')
organization=models.CharField(max_length=100,blank=True,default='')


account_number=models.CharField(max_length=100,blank=True,default='')
bank_phone=models.CharField(max_length=100,blank=True,default='')


def create_profile(sender, **kwargs):
user = kwargs["instance"]
if kwargs["created"]:
user_profile = Profile(user=user)
user_profile.save()
post_save.connect(create_profile, sender=User)








On Mon, Jan 29, 2018 at 1:02 PM, Dylan Reinhold <dreinh...@gmail.com> wrote:

> There are a bunch of ways to do it.
> Show us your view, if it's a function based view, just do your select on
> (username=request.user)
>
> Dylan
>
> On Sun, Jan 28, 2018 at 4:59 PM, sum abiut <suab...@gmail.com> wrote:
>
>> Hi,
>> i have a django app that i want the users to be able to view only their
>> user profile once they have login. currently any user that login is able to
>> view other users profile as well. Appreciate is you could point me to the
>> right direction.
>>
>> 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 post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/CAPCf-y7ZZx0BfQe0jwZu8-h%2Bo7nU%3DZYg%
>> 3Dgr2nxYeU%2BjskVTCtw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAPCf-y7ZZx0BfQe0jwZu8-h%2Bo7nU%3DZYg%3Dgr2nxYeU%2BjskVTCtw%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAHtg44CnQo8DtMunvmR5StuFD3vw5
> y0dk8dJqXM46mtDuaxR_w%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAHtg44CnQo8DtMunvmR5StuFD3vw5y0dk8dJqXM46mtDuaxR_w%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


view user profile access restriction

2018-01-28 Thread sum abiut
Hi,
i have a django app that i want the users to be able to view only their
user profile once they have login. currently any user that login is able to
view other users profile as well. Appreciate is you could point me to the
right direction.

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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y7ZZx0BfQe0jwZu8-h%2Bo7nU%3DZYg%3Dgr2nxYeU%2BjskVTCtw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: url issues

2018-01-28 Thread sum abiut
Thanks heaps manage to fix it.



On Fri, Jan 26, 2018 at 6:34 PM,  wrote:

> def login(request):
> return render(request,'login.html')
>
> On Friday, January 26, 2018 at 6:33:07 AM UTC+5:30, suabiut wrote:
>>
>> Hi,
>> i am having some issues with my url pattern. i can't seem to figure out
>> the problem. i am running django 1.11.
>>
>> i have an app name userprofile which automatically create user profiles
>> on user creation. I have create a login template to allow users to login in
>> before i can direct them to update their profile but i cannot seem to
>> access the login page.
>>
>> i get this below error
>>
>> [image: Inline image 1]
>>
>> view.py
>> def login(request):
>> return render(request,'login.html')
>>
>>
>>
>> urls.py
>> from django.conf.urls import url
>> from django.contrib import admin
>>
>> from . import views
>>
>>
>> urlpatterns = [
>> url(r'^$',views.login,name='login'),
>>
>> #url('', views.edit_user),
>> url(r'success/$', views.success),
>>
>> ]
>>
>>
>> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/636f672a-7ab9-4853-892b-374e1b16f461%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: django-payslip

2018-01-22 Thread sum abiut
Thanks for response. Manage to load the page this time.

Cheers

On Mon, Jan 22, 2018 at 3:59 PM, Ramiro Morales <cra...@gmail.com> wrote:

> The detailed error page is giving you all the information you need to
> diagnose the issue.
>
> It tells you you have two paths defined in your URL map: /admin/ and
> /payslip/ as per their respective documentation. So far so good.
>
> But you are accessing / with your browser. Hence the 404 error. Try
> accessing /payslip/
>
> Best regards,
>
> On Jan 22, 2018 12:29 AM, "sum abiut" <suab...@gmail.com> wrote:
>
> Hi,
> Has anyone from list have any experience with django-payslip before. I
> follow direction from https://pypi.python.org/pypi/django-payslip/0.2.2
>
> But i got the error below trying to load the page. Please advise
>
> [image: Inline image 1]
>
> cheer,
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/ms
> gid/django-users/CAPCf-y7qm3AVp5dizF-QqG39dW0OpbJuc783rnW8Ln
> HHG4Wwfw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAPCf-y7qm3AVp5dizF-QqG39dW0OpbJuc783rnW8LnHHG4Wwfw%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAO7PdF-06Q%2BtVwgp0we%3DOKR6RGyaU33kU_LeXLr8TbUia3G-
> Xw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAO7PdF-06Q%2BtVwgp0we%3DOKR6RGyaU33kU_LeXLr8TbUia3G-Xw%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


django-payslip

2018-01-21 Thread sum abiut
Hi,
Has anyone from list have any experience with django-payslip before. I
follow direction from https://pypi.python.org/pypi/django-payslip/0.2.2

But i got the error below trying to load the page. Please advise

[image: Inline image 1]

cheer,

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


Re: How do I exactly change from SQLite to MySQL ?

2018-01-14 Thread sum abiut
You can install mysql on your local machine and then later migrate your db
to Heroku, will be much easy.

On Mon, Jan 15, 2018 at 1:09 AM, Daniel Cîrstea 
wrote:

>  Hello. I am new to Django and I am trying to use it for my bachelor
> thesis. Thing is, I want to use MySQL insted of SQLite. How do I exactly do
> it.. I can't find a step-by-step tutorial on the internet.
> Also, I want to deploy project later on Heroku. Can I work on SQLite on
> local machine and then is possible to change to MySQL on Heroku ? In any
> case, I want to know how to do both, if possible. 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/a7decab1-334e-4f04-a6e9-6ad7bc2cd78b%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re:

2017-12-11 Thread sum abiut
You may also want to try django-oscar out.

https://github.com/django-oscar/django-oscar

cheers,

On Sun, Dec 10, 2017 at 6:46 AM, Etienne Robillard 
wrote:

> Hi Chaitanya,
>
> If you're not afraid of getting your hands dirty by playing with
> django-hotsauce, you could try django-livestore, a fork of the Satchmo
> framework.
> See: https://bitbucket.org/tkadm30/livestore
>
> Best regards,
>
> Etienne
>
>
> Le 2017-12-09 à 14:33, chaitanya goud a écrit :
>
> Hey I would like to know about
> Where to download a e-commerce website in django and how run it
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CA%2BkSnu5ytKSOhk_kqGzUFs4UjXd17HpkcwsmzF_Ckq8%
> 2BL-Qz-Q%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> Etienne Robillardtkadm30@yandex.comhttps://www.isotopesoftware.ca/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/39853fdf-8529-5d10-2faa-2770f4b20e98%40yandex.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



--

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


Re: Django select filter

2017-09-12 Thread sum abiut
I am trying to understand this code. Can someone explain where the
current_org came from

code taken from stackoverflow
<https://stackoverflow.com/questions/8389880/django-select-option-in-template>

{% for org in organisation %}
   
   {{org.name|capfirst}}
   {% endfor %}



cheers


On Wed, Sep 13, 2017 at 12:14 PM, ADEWALE ADISA <solixzsys...@gmail.com>
wrote:

> you can make it interesting by using ajax to post the selected month to
> your view which u ve already written to accept the month variable. use the
> variable to filter the necessary queryset in your view, then return the
> response in json format. you can now collect it from your ajax response,
> use javascript to dynamically update your table.
> On Sep 13, 2017 12:43 AM, "sum abiut" <suab...@gmail.com> wrote:
>
>> Hi,
>> I am working on an app which has a dropdown/select option which contain
>> months of the year. What i want to accomplished is when the user click on
>> the drop down and select a particular  month of the year the app should
>> display a table filter by that particular   selected month.
>>
>>
>> Please point me to the right direction to get me started.
>>
>> cheer
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/CAPCf-y5JQoekZfW%3DymeNJHyXQj6ExJHweENW2gAf
>> QiBhnXg6%3DA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAPCf-y5JQoekZfW%3DymeNJHyXQj6ExJHweENW2gAfQiBhnXg6%3DA%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAMGzuy_crJPMm%2Bh8DyhGHAc5AqtseM6e5PMp55BYyb
> fP1X7L6w%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAMGzuy_crJPMm%2Bh8DyhGHAc5AqtseM6e5PMp55BYybfP1X7L6w%40mail.gmail.com?utm_medium=email_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Django select filter

2017-09-12 Thread sum abiut
Hi,
I am working on an app which has a dropdown/select option which contain
months of the year. What i want to accomplished is when the user click on
the drop down and select a particular  month of the year the app should
display a table filter by that particular   selected month.


Please point me to the right direction to get me started.

cheer

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


Re: django filter

2017-08-29 Thread sum abiut
I did that but the approved leave is still showing on the table.

Cheers

On Tue, Aug 29, 2017 at 2:44 PM, sum abiut <suab...@gmail.com> wrote:

> Thanks heaps Muhammad.
> Sum
>
> On Tue, Aug 29, 2017 at 10:13 AM, Muhammad M <mwebbi...@gmail.com> wrote:
>
>> Hi Sum,
>>
>> Add an "approved" field of type BooleanField ( ) to your Leave model.
>>
>> So, something like this should work:
>>
>> In app/models.py:
>>
>> class Leave (models.Model):
>> #other fields go here...
>> approved = models.BooleanField ( )
>>
>> In app/views.py, handle the query like this:
>>  unapproved_leaves = Leave.objects.filter (approved=False)
>>
>> Then, do with the returned queryset as you wish.
>>
>> Best of luck.
>>
>> Sincerely,
>> Muhammad
>>
>> On Aug 28, 2017 7:06 PM, "sum abiut" <suab...@gmail.com> wrote:
>>
>>> Hi all,
>>> i am working on an eleave system where staff apply for annual leave and
>>> their leave manager approved the leave online.
>>>
>>> currently i have a table that shows all the leave for each department.
>>> what i want to accomplished is to only show the leave that are not yet
>>> approved on the table. Any leave that have been approved should not be
>>> showing on the table.
>>>
>>> Please point me to the right direction.
>>>
>>>
>>> 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 post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/django-users/CAPCf-y6f6%3DWtOW%3DQNW%3DD59gWtAmc3avZ4s3j
>>> HA09Pgj6C4yXEQ%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAPCf-y6f6%3DWtOW%3DQNW%3DD59gWtAmc3avZ4s3jHA09Pgj6C4yXEQ%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/CAJOFuZzTnxOAnmNUBPJP3A3w5ud%2BUYa9W1ZTaTbi
>> TNHnoF1f7A%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAJOFuZzTnxOAnmNUBPJP3A3w5ud%2BUYa9W1ZTaTbiTNHnoF1f7A%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
>



--

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


Re: django filter

2017-08-28 Thread sum abiut
Thanks heaps Muhammad.
Sum

On Tue, Aug 29, 2017 at 10:13 AM, Muhammad M <mwebbi...@gmail.com> wrote:

> Hi Sum,
>
> Add an "approved" field of type BooleanField ( ) to your Leave model.
>
> So, something like this should work:
>
> In app/models.py:
>
> class Leave (models.Model):
> #other fields go here...
> approved = models.BooleanField ( )
>
> In app/views.py, handle the query like this:
>  unapproved_leaves = Leave.objects.filter (approved=False)
>
> Then, do with the returned queryset as you wish.
>
> Best of luck.
>
> Sincerely,
> Muhammad
>
> On Aug 28, 2017 7:06 PM, "sum abiut" <suab...@gmail.com> wrote:
>
>> Hi all,
>> i am working on an eleave system where staff apply for annual leave and
>> their leave manager approved the leave online.
>>
>> currently i have a table that shows all the leave for each department.
>> what i want to accomplished is to only show the leave that are not yet
>> approved on the table. Any leave that have been approved should not be
>> showing on the table.
>>
>> Please point me to the right direction.
>>
>>
>> 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 post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/CAPCf-y6f6%3DWtOW%3DQNW%3DD59gWtAmc3avZ4s3j
>> HA09Pgj6C4yXEQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAPCf-y6f6%3DWtOW%3DQNW%3DD59gWtAmc3avZ4s3jHA09Pgj6C4yXEQ%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAJOFuZzTnxOAnmNUBPJP3A3w5ud%2BUYa9W1ZTaTbiTNHnoF1f7A%
> 40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAJOFuZzTnxOAnmNUBPJP3A3w5ud%2BUYa9W1ZTaTbiTNHnoF1f7A%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



--

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


django filter

2017-08-28 Thread sum abiut
Hi all,
i am working on an eleave system where staff apply for annual leave and
their leave manager approved the leave online.

currently i have a table that shows all the leave for each department. what
i want to accomplished is to only show the leave that are not yet approved
on the table. Any leave that have been approved should not be showing on
the table.

Please point me to the right direction.


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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y6f6%3DWtOW%3DQNW%3DD59gWtAmc3avZ4s3jHA09Pgj6C4yXEQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Math filter

2017-07-18 Thread sum abiut
Hi,
needed direction maths filters on django templates. for example how to you
perform this on a template.

a*b +b*c

i did  a|mul:b|add:b|mul:cbut got a wrong answer. Please point me
to right direction.

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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y648sfPwKJWLmRtcx6tfC_PZP6RP6PjUvCmzRKVfOH%3DSg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


replacing existing file with new uploaded file

2017-07-11 Thread sum abiut
Hi all,
need some directions, i need direction replacing file with newly uploaded
file. The upload function is working but i want to replace a file every
time i upload a new one.


my model.py

class uploadfile(models.Model):
description = models.CharField(max_length=255, blank=True)
Select_File=models.FileField(upload_to='/var/www/projects/webapp/media')
uploaded_at =models.DateTimeField(auto_now_add=True)


my view.py

def uploadfunc(request):
if request.method=='POST':
form =uploadfileform(request.POST,request.FILES)
if form.is_valid():
form.save()
return render_to_response('upload_successful.html')
else:
form=uploadfileform()
return render(request, 'upload.html',{'form':form})

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


[no subject]

2017-06-26 Thread sum abiut
Hi all,
I have this function where i i use mssqlalchmy to to fetch data from a
mssql database. I am fetching data from a column but what i am interested
in, is just to get a data from last field/row on that column.

is there are way to get that done from template?. this what i have done
from the template.html but i am getting an error : could not parse the
remainder '[-1]'



template.html


  


   GL Rate




{%for a in results%}



  {{a.buy_rate[-1]}}

  

{%endfor%}



view.py
def rate(request):
engine=create_engine('mssql+pymssql://username:passwprd@localhost
/database')
connection=engine.connect()
metadata=MetaData()
funds=Table('mccurtdt',metadata,autoload=True,autoload_with=engine)

stmt=select([funds.columns.buy_rate])

stmt=stmt.where(and_(funds.columns.rate_type=='MID',funds.columns.from_currency=='AUD',))
results=connection.execute(stmt).fetchall()
return render_to_response('rate.html',locals())

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


passing data to template

2017-06-15 Thread sum abiut
Is it possible to pass data from two different django functions to a one
template in a single for loop?

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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y4nSH-WQUcR4sCzy6OSg9q_dVTpEbf2%2BrDmUF-fmgRrJA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


display a field from last updated row

2017-06-15 Thread sum abiut
Hi,
i am having trouble trying to figure this out. I have a table something as
below. i want to write an sqlalchemy that query the table and then display
the email address from the row that was last updated. Please point me to
the right direction to help me accomplished that.





fname lname email phone
tom jon t...@mail.com 555
James peter t...@mail.com 555
john kas t...@mail.com 555
tom jon t...@mail.com 555

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


Re: passing data to template

2017-06-14 Thread sum abiut
Hi Mike,
Thank heaps for direction. Appreciate your help.

Cheers,

On Thu, Jun 15, 2017 at 1:52 PM, Mike Dewhirst <mi...@dewhirst.com.au>
wrote:

> On 15/06/2017 12:07 PM, sum abiut wrote:
>
>> I try to perform a division on the tuple but i am getting an error. I
>> have added another column call Gl rate. i try to perform the division lin
>> {{a.1/a.0}}but im geting an error. not sure what i am doing
>> wrong here.
>>
>> You are asking the template to perform division. There doesn't seem to be
> a "divide" filter.
>
> I don't know what the experts will advise but you might have to write one
> yourself. https://docs.djangoproject.com/en/1.10/howto/custom-template
> -tags/
>
> However, I believe the accepted wisdom is that computation in the template
> is more expensive than in the view. Hence I would likely do it there in
> ordinary Python and pass a straight result to the template.
>
> That said, you might also consider https://pypi.python.org/pypi/d
> jango-mathfilters
>
>
>
>>
>> 
>>   
>> 
>>   Net Balance
>>   Post Date
>>GL rate
>>
>> 
>> 
>> {%for a in results%}
>> 
>> {{a.0}}
>>   {{a.1}}
>> {{a.1/a.0}}
>> 
>> {%endfor%}
>> 
>>
>>
>>
>>
>> On Thu, Jun 15, 2017 at 8:47 AM, sum abiut <suab...@gmail.com > suab...@gmail.com>> wrote:
>>
>> Thanks heaps. appreciate your help, pointing me to right direction.
>>
>>
>>
>>
>> On Thu, Jun 15, 2017 at 5:28 AM, ludovic coues <cou...@gmail.com
>> <mailto:cou...@gmail.com>> wrote:
>>
>> 
>> 
>> 
>> Net Balance
>> Post Date
>> 
>> 
>> {%for a in results%}
>> 
>> {{a.0}}
>> {{a.1}}
>> 
>> {%endfor%}
>>     
>>
>> `{{results|pprint}}` is pretty clear. You have a list of
>> tuple. Tuples have no named member so a.nat_balance return a
>> None value.
>> {{ a.0 }} in your django template is the equivalent of a[0] in
>> python.
>>
>> If you want dict-like object, your problem is with SQLalchemy,
>> not django
>>
>> 2017-06-14 5:16 GMT+02:00 sum abiut <suab...@gmail.com
>> <mailto:suab...@gmail.com>>:
>>
>> Yes,
>> on the database it spelt nat_balance
>>
>>
>> On Wed, Jun 14, 2017 at 9:16 AM, Simon McConnell
>> <simonmcconn...@gmail.com
>> <mailto:simonmcconn...@gmail.com>> wrote:
>>
>> {{a.nat_balance}}
>>
>> sure it shouldn't be spelt
>>
>> {{a.net_balance}}
>>
>> ?
>>
>> On Wednesday, 14 June 2017 06:57:30 UTC+10, suabiut
>> wrote:
>>
>> Hi ludovic,
>> Thanks for your response.
>> when i did what you say it print out the date and
>> sum in an array. Date still in Julian date but i
>> don't worry about the date now just want to have
>> the sum display nicely in my template
>>
>> [(733011, 28397.54), (733030, 5136.79), (733044,
>> 35.89), (733048, 0.0), (733049, 0.0), (733077,
>> 6313.83), (733084, 6370.96), (733091, 150.0),
>> (733104, -500.0), (733107, 0.0), (733108, 500.0),
>> (733133, 5967.62), (733154, 7054.0), (733164,
>> 0.0), (733174, 5698.18), (733195, 0.0), (733212,
>> 5469.15), (733224, 0.0), (733255, 4887.2),
>> (733265, -7.0), (733286, 0.0), (733316, 0.0),
>> (733342, -119.78), (733349, 0.0),
>> (733377, 0.0), (733409, 0.0), (733422, -241.0),
>> (733426, 241.0), (733440, 0.0), (733468, 0.0),
>> (733498, 0.0), (733531, 0.0), (733559, 0.0),
>> (733582, 104.59), (733589, 0.0), (733622, 0.0),
>> (733651, 0.0), (733671, 3315.0), (733681, 0.0),
>> (733713, 0.0), (733742, 0.0), (733772, -83.89),
>> (733776, 0.0), (733777, 0.0), (733804, 0.0),
>> (733832, 0.0), (733863, 0.0), (7

Re: passing data to template

2017-06-14 Thread sum abiut
I try to perform a division on the tuple but i am getting an error. I have
added another column call Gl rate. i try to perform the division lin
{{a.1/a.0}} but im geting an error. not sure what i am doing wrong
here.




  

  Net Balance
  Post Date
   GL rate



{%for a in results%}

  {{a.0}}
  {{a.1}}
  {{a.1/a.0}}

{%endfor%}





On Thu, Jun 15, 2017 at 8:47 AM, sum abiut <suab...@gmail.com> wrote:

> Thanks heaps. appreciate your help, pointing me to right direction.
>
>
>
>
> On Thu, Jun 15, 2017 at 5:28 AM, ludovic coues <cou...@gmail.com> wrote:
>
>> 
>>   
>> 
>>   Net Balance
>>   Post Date
>> 
>> 
>> {%for a in results%}
>> 
>>   {{a.0}}
>>   {{a.1}}
>> 
>> {%endfor%}
>> 
>>
>> `{{results|pprint}}` is pretty clear. You have a list of tuple. Tuples
>> have no named member so a.nat_balance return a None value.
>> {{ a.0 }} in your django template is the equivalent of a[0] in python.
>>
>> If you want dict-like object, your problem is with SQLalchemy, not django
>>
>> 2017-06-14 5:16 GMT+02:00 sum abiut <suab...@gmail.com>:
>>
>>> Yes,
>>> on the database it spelt nat_balance
>>>
>>>
>>> On Wed, Jun 14, 2017 at 9:16 AM, Simon McConnell <
>>> simonmcconn...@gmail.com> wrote:
>>>
>>>> {{a.nat_balance}}
>>>>
>>>> sure it shouldn't be spelt
>>>>
>>>> {{a.net_balance}}
>>>>
>>>> ?
>>>>
>>>> On Wednesday, 14 June 2017 06:57:30 UTC+10, suabiut wrote:
>>>>>
>>>>> Hi ludovic,
>>>>> Thanks for your response.
>>>>> when i did what you say it print out the date and sum in an array.
>>>>> Date still in Julian date but i don't worry about the date now just want 
>>>>> to
>>>>> have the sum display nicely in my template
>>>>>
>>>>> [(733011, 28397.54), (733030, 5136.79), (733044, 35.89), (733048,
>>>>> 0.0), (733049, 0.0), (733077, 6313.83), (733084, 6370.96), (733091, 
>>>>> 150.0),
>>>>> (733104, -500.0), (733107, 0.0), (733108, 500.0), (733133, 5967.62),
>>>>> (733154, 7054.0), (733164, 0.0), (733174, 5698.18), (733195, 0.0), 
>>>>> (733212,
>>>>> 5469.15), (733224, 0.0), (733255, 4887.2), (733265, -7.0), (733286,
>>>>> 0.0), (733316, 0.0), (733342, -119.78), (733349, 0.0), 
>>>>> (733377,
>>>>> 0.0), (733409, 0.0), (733422, -241.0), (733426, 241.0), (733440, 0.0),
>>>>> (733468, 0.0), (733498, 0.0), (733531, 0.0), (733559, 0.0), (733582,
>>>>> 104.59), (733589, 0.0), (733622, 0.0), (733651, 0.0), (733671, 3315.0),
>>>>> (733681, 0.0), (733713, 0.0), (733742, 0.0), (733772, -83.89), (733776,
>>>>> 0.0), (733777, 0.0), (733804, 0.0), (733832, 0.0), (733863, 0.0), (733895,
>>>>> 0.0), (733924, 0.0), (733948, 4.33), (733954, 0.0), (733986, 0.0), 
>>>>> (734016,
>>>>> 0.0), (734046, 0.0), (734053, 0.0), (734077, 0.0), (734107, 0.0), (734137,
>>>>> -35.65), (734169, 0.0), (734197, 0.0), (734228, 0.0), (734260, 0.0),
>>>>> (734289, 0.0), (734319, 0.0), (734350, 0.0), (734381, 0.0), (734413, 0.0),
>>>>> (734442, 0.0), (734472, 0.0), (734501, -31.383), (734505, 
>>>>> 0.0),
>>>>> (734534, 0.0), (734563, 0.0), (734595, 0.0), (734625, 0.0), (734655, 0.0),
>>>>> (734686, 0.0), (734716, 0.0), (734749, 0.0), (734777, 0.0), (734808, 0.0),
>>>>> (734840, 0.0), (734868, 0.0), (734900, 0.0), (734931, 0.0), (734960, 0.0),
>>>>> (734990, 3455.0), (735022, 1030.0), (735050, -2099.0), (735081, 460.0),
>>>>> (735113, -102.0), (735142, -980.0), (735173, 1538.9), (735204, 920.0),
>>>>> (735231, -500.0), (735233, 0.0), (735267, -1000.0), (735295, -1150.0),
>>>>> (735325, -250.0), (735355, 0.0), (735386, -560.69), (735415, 570.0),
>>>>> (735446, 0.0), (735477, -300.0), (735507, -205.709998), (735540,
>>>>> 1600.0), (735569, -1040.0), (735598, -1404.31), (735614, 8.62), (735631,
>>>>> 0.0), (735649, 0.0), (735659, 0.0), (735689, 5.0), (735722, 0.0), (735750,
>>>>> 135.0), (735780, 770.0), (735813, 265.0), (735842, -1165.0), (735872,
>>>>> 30.0), (735904, -55.0), (735933, 4.29), (735967, 1105.0), (735968, 0.0),
>>>>> (735990, 4.32), (735995, 0.0), (736024, 0.0), (736055, 0.0), (736087,
>>>>> -1000.0), (736116, 0.0), (7

Re: passing data to template

2017-06-14 Thread sum abiut
Thanks heaps. appreciate your help, pointing me to right direction.



On Thu, Jun 15, 2017 at 5:28 AM, ludovic coues <cou...@gmail.com> wrote:

> 
>   
> 
>   Net Balance
>   Post Date
> 
> 
> {%for a in results%}
> 
>   {{a.0}}
>   {{a.1}}
> 
> {%endfor%}
> 
>
> `{{results|pprint}}` is pretty clear. You have a list of tuple. Tuples
> have no named member so a.nat_balance return a None value.
> {{ a.0 }} in your django template is the equivalent of a[0] in python.
>
> If you want dict-like object, your problem is with SQLalchemy, not django
>
> 2017-06-14 5:16 GMT+02:00 sum abiut <suab...@gmail.com>:
>
>> Yes,
>> on the database it spelt nat_balance
>>
>>
>> On Wed, Jun 14, 2017 at 9:16 AM, Simon McConnell <
>> simonmcconn...@gmail.com> wrote:
>>
>>> {{a.nat_balance}}
>>>
>>> sure it shouldn't be spelt
>>>
>>> {{a.net_balance}}
>>>
>>> ?
>>>
>>> On Wednesday, 14 June 2017 06:57:30 UTC+10, suabiut wrote:
>>>>
>>>> Hi ludovic,
>>>> Thanks for your response.
>>>> when i did what you say it print out the date and sum in an array. Date
>>>> still in Julian date but i don't worry about the date now just want to have
>>>> the sum display nicely in my template
>>>>
>>>> [(733011, 28397.54), (733030, 5136.79), (733044, 35.89), (733048, 0.0),
>>>> (733049, 0.0), (733077, 6313.83), (733084, 6370.96), (733091, 150.0),
>>>> (733104, -500.0), (733107, 0.0), (733108, 500.0), (733133, 5967.62),
>>>> (733154, 7054.0), (733164, 0.0), (733174, 5698.18), (733195, 0.0), (733212,
>>>> 5469.15), (733224, 0.0), (733255, 4887.2), (733265, -7.0), (733286,
>>>> 0.0), (733316, 0.0), (733342, -119.78), (733349, 0.0), (733377,
>>>> 0.0), (733409, 0.0), (733422, -241.0), (733426, 241.0), (733440, 0.0),
>>>> (733468, 0.0), (733498, 0.0), (733531, 0.0), (733559, 0.0), (733582,
>>>> 104.59), (733589, 0.0), (733622, 0.0), (733651, 0.0), (733671, 3315.0),
>>>> (733681, 0.0), (733713, 0.0), (733742, 0.0), (733772, -83.89), (733776,
>>>> 0.0), (733777, 0.0), (733804, 0.0), (733832, 0.0), (733863, 0.0), (733895,
>>>> 0.0), (733924, 0.0), (733948, 4.33), (733954, 0.0), (733986, 0.0), (734016,
>>>> 0.0), (734046, 0.0), (734053, 0.0), (734077, 0.0), (734107, 0.0), (734137,
>>>> -35.65), (734169, 0.0), (734197, 0.0), (734228, 0.0), (734260, 0.0),
>>>> (734289, 0.0), (734319, 0.0), (734350, 0.0), (734381, 0.0), (734413, 0.0),
>>>> (734442, 0.0), (734472, 0.0), (734501, -31.383), (734505, 0.0),
>>>> (734534, 0.0), (734563, 0.0), (734595, 0.0), (734625, 0.0), (734655, 0.0),
>>>> (734686, 0.0), (734716, 0.0), (734749, 0.0), (734777, 0.0), (734808, 0.0),
>>>> (734840, 0.0), (734868, 0.0), (734900, 0.0), (734931, 0.0), (734960, 0.0),
>>>> (734990, 3455.0), (735022, 1030.0), (735050, -2099.0), (735081, 460.0),
>>>> (735113, -102.0), (735142, -980.0), (735173, 1538.9), (735204, 920.0),
>>>> (735231, -500.0), (735233, 0.0), (735267, -1000.0), (735295, -1150.0),
>>>> (735325, -250.0), (735355, 0.0), (735386, -560.69), (735415, 570.0),
>>>> (735446, 0.0), (735477, -300.0), (735507, -205.709998), (735540,
>>>> 1600.0), (735569, -1040.0), (735598, -1404.31), (735614, 8.62), (735631,
>>>> 0.0), (735649, 0.0), (735659, 0.0), (735689, 5.0), (735722, 0.0), (735750,
>>>> 135.0), (735780, 770.0), (735813, 265.0), (735842, -1165.0), (735872,
>>>> 30.0), (735904, -55.0), (735933, 4.29), (735967, 1105.0), (735968, 0.0),
>>>> (735990, 4.32), (735995, 0.0), (736024, 0.0), (736055, 0.0), (736087,
>>>> -1000.0), (736116, 0.0), (736146, 0.0), (736178, 0.0), (736208, 185.0),
>>>> (736240, -285.68), (736269, 0.0), (736299, 0.0), (736332, 44.32), (736361,
>>>> 0.0), (736389, 0.0), (736422, 0.0), (736451, -40.0), (736481, 0.0)]
>>>>
>>>>
>>>> On Tue, Jun 13, 2017 at 5:33 PM, ludovic coues <cou...@gmail.com>
>>>> wrote:
>>>>
>>>>> Try `{{ results | pprint }}` in your template.
>>>>>
>>>>> That will not solve your problems but that will give you a lot more
>>>>> information about what data have been passed to your template.
>>>>>
>>>>> On 13 Jun 2017 6:53 am, "sum abiut" <sua...@gmail.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>> I need some help, i am using

Re: passing data to template

2017-06-13 Thread sum abiut
Yes,
on the database it spelt nat_balance

On Wed, Jun 14, 2017 at 9:16 AM, Simon McConnell <simonmcconn...@gmail.com>
wrote:

> {{a.nat_balance}}
>
> sure it shouldn't be spelt
>
> {{a.net_balance}}
>
> ?
>
> On Wednesday, 14 June 2017 06:57:30 UTC+10, suabiut wrote:
>>
>> Hi ludovic,
>> Thanks for your response.
>> when i did what you say it print out the date and sum in an array. Date
>> still in Julian date but i don't worry about the date now just want to have
>> the sum display nicely in my template
>>
>> [(733011, 28397.54), (733030, 5136.79), (733044, 35.89), (733048, 0.0),
>> (733049, 0.0), (733077, 6313.83), (733084, 6370.96), (733091, 150.0),
>> (733104, -500.0), (733107, 0.0), (733108, 500.0), (733133, 5967.62),
>> (733154, 7054.0), (733164, 0.0), (733174, 5698.18), (733195, 0.0), (733212,
>> 5469.15), (733224, 0.0), (733255, 4887.2), (733265, -7.0), (733286,
>> 0.0), (733316, 0.0), (733342, -119.78), (733349, 0.0), (733377,
>> 0.0), (733409, 0.0), (733422, -241.0), (733426, 241.0), (733440, 0.0),
>> (733468, 0.0), (733498, 0.0), (733531, 0.0), (733559, 0.0), (733582,
>> 104.59), (733589, 0.0), (733622, 0.0), (733651, 0.0), (733671, 3315.0),
>> (733681, 0.0), (733713, 0.0), (733742, 0.0), (733772, -83.89), (733776,
>> 0.0), (733777, 0.0), (733804, 0.0), (733832, 0.0), (733863, 0.0), (733895,
>> 0.0), (733924, 0.0), (733948, 4.33), (733954, 0.0), (733986, 0.0), (734016,
>> 0.0), (734046, 0.0), (734053, 0.0), (734077, 0.0), (734107, 0.0), (734137,
>> -35.65), (734169, 0.0), (734197, 0.0), (734228, 0.0), (734260, 0.0),
>> (734289, 0.0), (734319, 0.0), (734350, 0.0), (734381, 0.0), (734413, 0.0),
>> (734442, 0.0), (734472, 0.0), (734501, -31.383), (734505, 0.0),
>> (734534, 0.0), (734563, 0.0), (734595, 0.0), (734625, 0.0), (734655, 0.0),
>> (734686, 0.0), (734716, 0.0), (734749, 0.0), (734777, 0.0), (734808, 0.0),
>> (734840, 0.0), (734868, 0.0), (734900, 0.0), (734931, 0.0), (734960, 0.0),
>> (734990, 3455.0), (735022, 1030.0), (735050, -2099.0), (735081, 460.0),
>> (735113, -102.0), (735142, -980.0), (735173, 1538.9), (735204, 920.0),
>> (735231, -500.0), (735233, 0.0), (735267, -1000.0), (735295, -1150.0),
>> (735325, -250.0), (735355, 0.0), (735386, -560.69), (735415, 570.0),
>> (735446, 0.0), (735477, -300.0), (735507, -205.709998), (735540,
>> 1600.0), (735569, -1040.0), (735598, -1404.31), (735614, 8.62), (735631,
>> 0.0), (735649, 0.0), (735659, 0.0), (735689, 5.0), (735722, 0.0), (735750,
>> 135.0), (735780, 770.0), (735813, 265.0), (735842, -1165.0), (735872,
>> 30.0), (735904, -55.0), (735933, 4.29), (735967, 1105.0), (735968, 0.0),
>> (735990, 4.32), (735995, 0.0), (736024, 0.0), (736055, 0.0), (736087,
>> -1000.0), (736116, 0.0), (736146, 0.0), (736178, 0.0), (736208, 185.0),
>> (736240, -285.68), (736269, 0.0), (736299, 0.0), (736332, 44.32), (736361,
>> 0.0), (736389, 0.0), (736422, 0.0), (736451, -40.0), (736481, 0.0)]
>>
>>
>> On Tue, Jun 13, 2017 at 5:33 PM, ludovic coues <cou...@gmail.com> wrote:
>>
>>> Try `{{ results | pprint }}` in your template.
>>>
>>> That will not solve your problems but that will give you a lot more
>>> information about what data have been passed to your template.
>>>
>>> On 13 Jun 2017 6:53 am, "sum abiut" <sua...@gmail.com> wrote:
>>>
>>>> Hi,
>>>> I need some help, i am using Django as my web framework and sqlalchemy
>>>> to query my database. When i pass data template its not showing on the
>>>> template. can someone point me to the right direction.
>>>>
>>>> The post date is loaded on the template but the Net Balance is not
>>>> loaded. Don't know what i am doing wrong here.
>>>>
>>>> below is my view.py and template
>>>>
>>>>
>>>> view.py
>>>>
>>>> def SUMCORP(request):
>>>> engine=create_engine('mssql+pymssql://username:pass@servername
>>>> /RBVData')
>>>> connection=engine.connect()
>>>> metadata=MetaData()
>>>> fund=Table('gltrxdet',metadata,autoload=True,autoload_with=engine)
>>>> stmt=select([fund.columns.date_posted,func.sum(fund.columns.
>>>> nat_balance)])
>>>> stmt = stmt.where(fund.columns.account_code=='002CORP')
>>>> stmt=stmt.group_by(fund.columns.date_posted)
>>>> results=connection.execute(stmt).fetchall()
>>>> return render_to_response('fundmanager_sum.html',locals())
>>>>
>>>

Re: passing data to template

2017-06-13 Thread sum abiut
Hi ludovic,
Thanks for your response.
when i did what you say it print out the date and sum in an array. Date
still in Julian date but i don't worry about the date now just want to have
the sum display nicely in my template

[(733011, 28397.54), (733030, 5136.79), (733044, 35.89), (733048, 0.0),
(733049, 0.0), (733077, 6313.83), (733084, 6370.96), (733091, 150.0),
(733104, -500.0), (733107, 0.0), (733108, 500.0), (733133, 5967.62),
(733154, 7054.0), (733164, 0.0), (733174, 5698.18), (733195, 0.0), (733212,
5469.15), (733224, 0.0), (733255, 4887.2), (733265, -7.0), (733286,
0.0), (733316, 0.0), (733342, -119.78), (733349, 0.0), (733377,
0.0), (733409, 0.0), (733422, -241.0), (733426, 241.0), (733440, 0.0),
(733468, 0.0), (733498, 0.0), (733531, 0.0), (733559, 0.0), (733582,
104.59), (733589, 0.0), (733622, 0.0), (733651, 0.0), (733671, 3315.0),
(733681, 0.0), (733713, 0.0), (733742, 0.0), (733772, -83.89), (733776,
0.0), (733777, 0.0), (733804, 0.0), (733832, 0.0), (733863, 0.0), (733895,
0.0), (733924, 0.0), (733948, 4.33), (733954, 0.0), (733986, 0.0), (734016,
0.0), (734046, 0.0), (734053, 0.0), (734077, 0.0), (734107, 0.0), (734137,
-35.65), (734169, 0.0), (734197, 0.0), (734228, 0.0), (734260, 0.0),
(734289, 0.0), (734319, 0.0), (734350, 0.0), (734381, 0.0), (734413, 0.0),
(734442, 0.0), (734472, 0.0), (734501, -31.383), (734505, 0.0),
(734534, 0.0), (734563, 0.0), (734595, 0.0), (734625, 0.0), (734655, 0.0),
(734686, 0.0), (734716, 0.0), (734749, 0.0), (734777, 0.0), (734808, 0.0),
(734840, 0.0), (734868, 0.0), (734900, 0.0), (734931, 0.0), (734960, 0.0),
(734990, 3455.0), (735022, 1030.0), (735050, -2099.0), (735081, 460.0),
(735113, -102.0), (735142, -980.0), (735173, 1538.9), (735204, 920.0),
(735231, -500.0), (735233, 0.0), (735267, -1000.0), (735295, -1150.0),
(735325, -250.0), (735355, 0.0), (735386, -560.69), (735415, 570.0),
(735446, 0.0), (735477, -300.0), (735507, -205.709998), (735540,
1600.0), (735569, -1040.0), (735598, -1404.31), (735614, 8.62), (735631,
0.0), (735649, 0.0), (735659, 0.0), (735689, 5.0), (735722, 0.0), (735750,
135.0), (735780, 770.0), (735813, 265.0), (735842, -1165.0), (735872,
30.0), (735904, -55.0), (735933, 4.29), (735967, 1105.0), (735968, 0.0),
(735990, 4.32), (735995, 0.0), (736024, 0.0), (736055, 0.0), (736087,
-1000.0), (736116, 0.0), (736146, 0.0), (736178, 0.0), (736208, 185.0),
(736240, -285.68), (736269, 0.0), (736299, 0.0), (736332, 44.32), (736361,
0.0), (736389, 0.0), (736422, 0.0), (736451, -40.0), (736481, 0.0)]


On Tue, Jun 13, 2017 at 5:33 PM, ludovic coues <cou...@gmail.com> wrote:

> Try `{{ results | pprint }}` in your template.
>
> That will not solve your problems but that will give you a lot more
> information about what data have been passed to your template.
>
> On 13 Jun 2017 6:53 am, "sum abiut" <suab...@gmail.com> wrote:
>
>> Hi,
>> I need some help, i am using Django as my web framework and sqlalchemy to
>> query my database. When i pass data template its not showing on the
>> template. can someone point me to the right direction.
>>
>> The post date is loaded on the template but the Net Balance is not
>> loaded. Don't know what i am doing wrong here.
>>
>> below is my view.py and template
>>
>>
>> view.py
>>
>> def SUMCORP(request):
>> engine=create_engine('mssql+pymssql://username:pass@servername
>> /RBVData')
>> connection=engine.connect()
>> metadata=MetaData()
>> fund=Table('gltrxdet',metadata,autoload=True,autoload_with=engine)
>> stmt=select([fund.columns.date_posted,func.sum(fund.columns.
>> nat_balance)])
>> stmt = stmt.where(fund.columns.account_code=='002CORP')
>> stmt=stmt.group_by(fund.columns.date_posted)
>> results=connection.execute(stmt).fetchall()
>> return render_to_response('fundmanager_sum.html',locals())
>>
>>
>> template.html
>>
>> 
>>   
>> 
>>
>>   Net Balance
>>   Post Date
>> 
>>
>> 
>> {%for a in results%}
>>
>> 
>>
>> {{a.nat_balance}}
>> {{a.date_posted}}
>>
>>   
>>
>> {%endfor%}
>> 
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/CAPCf-y7tGoLm2hxPaQpBrrm_j0VJvTF1UvE%3D-
>> vQgbjh%3DzCxEMg%40mail.g

passing data to template

2017-06-12 Thread sum abiut
Hi,
I need some help, i am using Django as my web framework and sqlalchemy to
query my database. When i pass data template its not showing on the
template. can someone point me to the right direction.

The post date is loaded on the template but the Net Balance is not loaded.
Don't know what i am doing wrong here.

below is my view.py and template


view.py

def SUMCORP(request):
engine=create_engine('mssql+pymssql://username:pass@servername
/RBVData')
connection=engine.connect()
metadata=MetaData()
fund=Table('gltrxdet',metadata,autoload=True,autoload_with=engine)

stmt=select([fund.columns.date_posted,func.sum(fund.columns.nat_balance)])
stmt = stmt.where(fund.columns.account_code=='002CORP')
stmt=stmt.group_by(fund.columns.date_posted)
results=connection.execute(stmt).fetchall()
return render_to_response('fundmanager_sum.html',locals())


template.html


  


  Net Balance
  Post Date



{%for a in results%}



{{a.nat_balance}}
{{a.date_posted}}

  

{%endfor%}


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


Re: template drop down menu

2017-06-06 Thread sum abiut
Thanks heaps for your response. I will have a look into it.

Cheers,

On Wed, Jun 7, 2017 at 9:22 AM, Bernd Wechner <bernd.wech...@gmail.com>
wrote:

> If you want a sample for a javascript postback when drop down changes I
> have one here:
>
> https://github.com/bernd-wechner/CoGs/blob/master/
> Leaderboards/templates/CoGs/view_leaderboards.html
>
> It's attached to the select "selNames" which you can trace to the Django
> view "ajax_Leaderboards" in:
>
> https://github.com/bernd-wechner/CoGs/blob/master/Leaderboards/views.py
>
> if you're patient.
>
> Might be easier to find some simple tutorials than wade through my code,
> but hey, it's there to look at if you want to see a working demo (almost,
> that site isn't live yet so can't point you at it running alas).
>
> Regards,
>
> Bernd.
>
> sum abiut wrote:
>
> Thanks heaps for your response. It really clear things up and help me get
> started.
>
> Cheers,
>
>
>
> On Wed, Jun 7, 2017 at 5:05 AM, ludovic coues <cou...@gmail.com> wrote:
>
> The short answer to "how can I know what option is selected before
> doing the queyr" is "you cannot know".
>
> Here is a quick drawing of your timeline
>
> request to your server -> process view (where you do db request) ->
> process template -> send request back to user -> user select an option
>
> At no point you can go backward in this schema. The trick is to do it
> again.
>
> The easy solution is to put the select in a form with a submit button
> named "search" or "filter". The first time you show the page, you
> display an empty or full list. When your user submit the form, you
> know which option they have selected.
>
>
> If you involve javascript, you can make it as complex as you want.
> First solution is to force a form submission as soon as the value of
> the select change. Next solution is to not reload the whole page but
> do an ajax call. That ajax request can either return the whole list as
> a fragment of HTML to replace the previous list or some formatted
> data, as JSON for example that you can use to replace the data in the
> list. Last solution would be to not use the server for the filtering.
> Send everything to the user and use javascript to filter the data
> according to the value of the select. With no request to your server,
> data will be updated really fast. That solution work really well for
> small to medium amount of data.
>
> 2017-06-06 7:40 GMT+02:00 sum abiut <suab...@gmail.com>:
> > Hi,
> > need some directions, i need to query the my database and display the
> result
> > of the query in the table. to do that i want to use a drop down menu and
> get
> > the users to select options from the drop menu on the template.
> >
> > for example if a user select a word from the drop down menu i want to
> filter
> > and query the database base on the option that is selected and then
> display
> > the result.
> >
> > I am confuse on the template side. on the template side how to i know if
> a
> > user select a particular option from the drop down before so that i can
> > perform query base on option that was selected from the template and
> display
> > query result base on the respective word that was select.
> >
> > 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 post to this group, send email to django-users@googlegroups.com.
> > Visit this group at https://groups.google.com/group/django-users.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/django-users/CAPCf-y5ZZdhw
> V-D71SVQ-50dQDFbhNP7KtBZMR0x7NiBVVQh9A%40mail.gmail.com.
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
>
> Cordialement, Ludovic Coues
> +33 6 14 87 43 42
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/ms
> gid/django-users/CAEuG%2BTbxgksBG-JL%3DgCKEXPaq4%2BO1VbLoJjN
> o6S1FgYTTP1Qsw%40mail.gmail.com.
> For more options, visit https://

Re: template drop down menu

2017-06-06 Thread sum abiut
Thanks heaps for your response. It really clear things up and help me get
started.

Cheers,



On Wed, Jun 7, 2017 at 5:05 AM, ludovic coues <cou...@gmail.com> wrote:

> The short answer to "how can I know what option is selected before
> doing the queyr" is "you cannot know".
>
> Here is a quick drawing of your timeline
>
> request to your server -> process view (where you do db request) ->
> process template -> send request back to user -> user select an option
>
> At no point you can go backward in this schema. The trick is to do it
> again.
>
> The easy solution is to put the select in a form with a submit button
> named "search" or "filter". The first time you show the page, you
> display an empty or full list. When your user submit the form, you
> know which option they have selected.
>
>
> If you involve javascript, you can make it as complex as you want.
> First solution is to force a form submission as soon as the value of
> the select change. Next solution is to not reload the whole page but
> do an ajax call. That ajax request can either return the whole list as
> a fragment of HTML to replace the previous list or some formatted
> data, as JSON for example that you can use to replace the data in the
> list. Last solution would be to not use the server for the filtering.
> Send everything to the user and use javascript to filter the data
> according to the value of the select. With no request to your server,
> data will be updated really fast. That solution work really well for
> small to medium amount of data.
>
> 2017-06-06 7:40 GMT+02:00 sum abiut <suab...@gmail.com>:
> > Hi,
> > need some directions, i need to query the my database and display the
> result
> > of the query in the table. to do that i want to use a drop down menu and
> get
> > the users to select options from the drop menu on the template.
> >
> > for example if a user select a word from the drop down menu i want to
> filter
> > and query the database base on the option that is selected and then
> display
> > the result.
> >
> > I am confuse on the template side. on the template side how to i know if
> a
> > user select a particular option from the drop down before so that i can
> > perform query base on option that was selected from the template and
> display
> > query result base on the respective word that was select.
> >
> > 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 post to this group, send email to django-users@googlegroups.com.
> > Visit this group at https://groups.google.com/group/django-users.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/django-users/CAPCf-y5ZZdhwV-D71SVQ-
> 50dQDFbhNP7KtBZMR0x7NiBVVQh9A%40mail.gmail.com.
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
>
> Cordialement, Ludovic Coues
> +33 6 14 87 43 42
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAEuG%2BTbxgksBG-JL%3DgCKEXPaq4%
> 2BO1VbLoJjNo6S1FgYTTP1Qsw%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


template drop down menu

2017-06-05 Thread sum abiut
Hi,
need some directions, i need to query the my database and display the
result of the query in the table. to do that i want to use a drop down menu
and get the users to select options from the drop menu on the template.

for example if a user select a word from the drop down menu i want to
filter and query the database base on the option that is selected and then
display the result.

I am confuse on the template side. on the template side how to i know if a
user select a particular option from the drop down before so that i can
perform query base on option that was selected from the template and
display query result base on the respective word that was select.

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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y5ZZdhwV-D71SVQ-50dQDFbhNP7KtBZMR0x7NiBVVQh9A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


julian date to normal date conversion

2017-06-05 Thread sum abiut
i am using python,and django as my web framework. I use  sqlalchemy to
connect to  MSSQL data that is running Epicor database. Epicor is using
julian

* date. How to you convert julian date to normal date*


*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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y6pKd2JM3BTjzpat-u2gDm8xs7Xr8Q_0SEmw1czDVcGJw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


django 1.11 login user

2017-05-04 Thread sum abiut
Hi,
 i have try to login user using the guide from
https://docs.djangoproject.com/en/1.11/topics/auth/default/

but get an error. Can someone advise what i am doin wrong here



he is my view.py

#Authentication user
def login(request):
username=request.POST['username']
password=request.POST['password']
user=authenticate(request,username=username,password=password)
if user is not None:
login(request,user)
#Redirect to dashboard page
return render(request,'dashboard.html')
else:
# return invalid login message
return HttpResponse( 'You have enter a wrong password or username
please again')



Error message:


Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/login/

Django Version: 1.11
Python Version: 2.7.12
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'fundmanager']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback:

File
"/root/.virtualenvs/benchmark/local/lib/python2.7/site-packages/django/core/handlers/exception.py"
in inner
  41. response = get_response(request)

File
"/root/.virtualenvs/benchmark/local/lib/python2.7/site-packages/django/core/handlers/base.py"
in _get_response
  187. response = self.process_exception_by_middleware(e,
request)

File
"/root/.virtualenvs/benchmark/local/lib/python2.7/site-packages/django/core/handlers/base.py"
in _get_response
  185. response = wrapped_callback(request, *callback_args,
**callback_kwargs)

File "/var/www/projects/benchmark/fundmanager/views.py" in login
  22. username=request.POST['username']

File
"/root/.virtualenvs/benchmark/local/lib/python2.7/site-packages/django/utils/datastructures.py"
in __getitem__
  85. raise MultiValueDictKeyError(repr(key))

Exception Type: MultiValueDictKeyError at /login/
Exception Value: "u'username'"

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


Re: send email with django

2017-04-19 Thread sum abiut
Have you install the sendgrid backend?

what is the error message you are getting


On Thu, Apr 20, 2017 at 8:48 AM, shahab emami  wrote:

> but that doesn't work for me too.
>
> i sign up in sendgrid and this is my new settings.py
>
> EMAIL_HOST = 'smtp.sendgrid.net'
> EMAIL_HOST_USER = 'my_account'
> EMAIL_HOST_PASSWORD = 'mypassword'
> EMAIL_PORT = 587
> EMAIL_USE_TLS = True
>
> not on localhost and not on heroku
>
>
> On Thursday, April 20, 2017 at 1:38:53 AM UTC+4:30, suabiut wrote:
>>
>> I am also using sendgrid it works very well.
>>
>> On Thu, Apr 20, 2017 at 6:56 AM, shahab emami  wrote:
>>
>>> but it's free for 30 days. what i have to do after 30 days?
>>>
>>> On Wednesday, April 19, 2017 at 6:18:38 PM UTC+4:30, Thiago Luiz Parolin
>>> wrote:

 i am using sendgrid for send emails...the free service works very well
 for me...there is a paid version too..
 sendgrid can be integrated into django

 https://sendgrid.com/docs/Integrate/Frameworks/django.html




 2017-04-19 8:46 GMT-03:00 Carl :

> As a counter-perspective, we have this working with a paid G Suite
> (formerly Google Apps) account. *Important* We had to register the IP
> address of our server with G Suite. This Google support document outlines
> the process:
>   SMTP relay: Route outgoing non-Gmail messages through Google
>   https://support.google.com/a/answer/2956491?hl=en
>
> In terms of Django, our settings.py file has the following relevant
> settings:
>
> # To have error messages auto-sent via email:
> SERVER_EMAIL = 'myn...@mypaid-gmail.com'
> ADMINS = [('MyWebServer', 'myn...@mypaid-gmail.com'),]
>
> EMAIL_USE_TLS = True
> EMAIL_HOST = 'smtp-relay.gmail.com'
> EMAIL_PORT = 587
> EMAIL_HOST_USER = ''
> EMAIL_HOST_PASSWORD = ''
> DEFAULT_FROM_EMAIL = 'myn...@mypaid-gmail.com'
> DEFAULT_TO_EMAIL = 'myn...@mypaid-gmail.com'
>
> Hope this helps!
>
>  Original Message 
> Subject: Re: send email with django
> Local Time: April 19, 2017 7:00 AM
> UTC Time: April 19, 2017 11:00 AM
> From: red...@gmail.com
> To: django...@googlegroups.com
>
>
> Also, don't fail silently it would be helpful to see actual error that
> happens...
>
> On 19.04.2017 00:25, shahab emami wrote:
>
> hello
>
> i want to send email using django. i used to send email with pour
> python before but now i can't do that in django.
>
> i have search about this and i have seen some tutorials on youtube  in
> last two days but i cant do this .
>
> this is in my settings.py :
>
> EMAIL_USE_TLS = True
> EMAIL_HOST = 'smtp.gmail.com'
> EMAIL_HOST_USER = 'my_g...@gmail.com'
> EMAIL_HOST_PASSWORD= 'my_password'
> EMAIL_PORT = 587
>
> and this is my send email:
>
> from django.core.mail import send_mail
> def click(request):
> send_mail(
> 'shahab',
> 'Here is the message.',
> 'my_g...@gmail.com',
> ['shaha...@yahoo.com'],
> fail_silently=True
> )
> return HttpResponseRedirect('index')
>
> but it doesn't work.
>
> I am running this code on localhost. but i doesn't work on heroku too.
> i changed allow less secure app to on in my gmail account and
> i went to this page too and  i clicked on continue :
> https://accounts.google.com/DisplayUnlockCaptcha
>
> can anybody tell me:
> what am i missing ?
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/65e0ab09-ff5a
> -4ed5-89d6-e5e0991b9ea0%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> Jani Tiainen
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> 

Re: send email with django

2017-04-19 Thread sum abiut
I am also using sendgrid it works very well.

On Thu, Apr 20, 2017 at 6:56 AM, shahab emami  wrote:

> but it's free for 30 days. what i have to do after 30 days?
>
> On Wednesday, April 19, 2017 at 6:18:38 PM UTC+4:30, Thiago Luiz Parolin
> wrote:
>>
>> i am using sendgrid for send emails...the free service works very well
>> for me...there is a paid version too..
>> sendgrid can be integrated into django
>>
>> https://sendgrid.com/docs/Integrate/Frameworks/django.html
>>
>>
>>
>>
>> 2017-04-19 8:46 GMT-03:00 Carl :
>>
>>> As a counter-perspective, we have this working with a paid G Suite
>>> (formerly Google Apps) account. *Important* We had to register the IP
>>> address of our server with G Suite. This Google support document outlines
>>> the process:
>>>   SMTP relay: Route outgoing non-Gmail messages through Google
>>>   https://support.google.com/a/answer/2956491?hl=en
>>>
>>> In terms of Django, our settings.py file has the following relevant
>>> settings:
>>>
>>> # To have error messages auto-sent via email:
>>> SERVER_EMAIL = 'myn...@mypaid-gmail.com'
>>> ADMINS = [('MyWebServer', 'myn...@mypaid-gmail.com'),]
>>>
>>> EMAIL_USE_TLS = True
>>> EMAIL_HOST = 'smtp-relay.gmail.com'
>>> EMAIL_PORT = 587
>>> EMAIL_HOST_USER = ''
>>> EMAIL_HOST_PASSWORD = ''
>>> DEFAULT_FROM_EMAIL = 'myn...@mypaid-gmail.com'
>>> DEFAULT_TO_EMAIL = 'myn...@mypaid-gmail.com'
>>>
>>> Hope this helps!
>>>
>>>  Original Message 
>>> Subject: Re: send email with django
>>> Local Time: April 19, 2017 7:00 AM
>>> UTC Time: April 19, 2017 11:00 AM
>>> From: red...@gmail.com
>>> To: django...@googlegroups.com
>>>
>>>
>>> Also, don't fail silently it would be helpful to see actual error that
>>> happens...
>>>
>>> On 19.04.2017 00:25, shahab emami wrote:
>>>
>>> hello
>>>
>>> i want to send email using django. i used to send email with pour python
>>> before but now i can't do that in django.
>>>
>>> i have search about this and i have seen some tutorials on youtube  in
>>> last two days but i cant do this .
>>>
>>> this is in my settings.py :
>>>
>>> EMAIL_USE_TLS = True
>>> EMAIL_HOST = 'smtp.gmail.com'
>>> EMAIL_HOST_USER = 'my_g...@gmail.com'
>>> EMAIL_HOST_PASSWORD= 'my_password'
>>> EMAIL_PORT = 587
>>>
>>> and this is my send email:
>>>
>>> from django.core.mail import send_mail
>>> def click(request):
>>> send_mail(
>>> 'shahab',
>>> 'Here is the message.',
>>> 'my_g...@gmail.com',
>>> ['shaha...@yahoo.com'],
>>> fail_silently=True
>>> )
>>> return HttpResponseRedirect('index')
>>>
>>> but it doesn't work.
>>>
>>> I am running this code on localhost. but i doesn't work on heroku too.
>>> i changed allow less secure app to on in my gmail account and
>>> i went to this page too and  i clicked on continue :
>>> https://accounts.google.com/DisplayUnlockCaptcha
>>>
>>> can anybody tell me:
>>> what am i missing ?
>>>
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/django-users/65e0ab09-ff5a-4ed5-89d6-e5e0991b9ea0%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>>> --
>>> Jani Tiainen
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/django-users/6a7f0307-4144-b649-cdc8-8e679e89ceca%40gmail.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/django-users/1ZSWqeCcOU2qCnLKSrDLkDiH9XND1svarKZef71AehQ
>>> 

Re: python django fields and row calculation

2017-04-05 Thread sum abiut
Thanks heaps this should get me started

On Wed, Apr 5, 2017 at 2:42 PM, Lachlan Musicman <data...@gmail.com> wrote:

> Well, if it's on the user model as a function, then it will happen as soon
> as you call it.
>
> If they can have mulitple applications in process, then you will need to
> program your function(s) to account for that.
>
> As they say "there's more than one way to do it".
>
> You could add a "remaining days" var to the user model and store the info
> in there secretly.
> You could get the function to programmatically work through the
> applications for the user in the order in which they have been received?
> ...
>
> cheers
> L.
>
>
> --
> The most dangerous phrase in the language is, "We've always done it this
> way."
>
> - Grace Hopper
>
> On 5 April 2017 at 13:21, sum abiut <suab...@gmail.com> wrote:
>
>> Thank for taking your time to respond. my problem is automating that, for
>> example when a user apply for a leave i want the system to calculate and
>> update the total balance automatically. But Since a user can apply for a
>> leave more that once which mean a user can have more that one record of
>> leave application on the database. My problem is having to figure out when
>> was the last time that the user has launch his/her leave application so
>> that i can minus num_days from the that total balance.
>>
>>
>> thanks
>>
>>
>>
>> On Wed, Apr 5, 2017 at 12:20 PM, Lachlan Musicman <data...@gmail.com>
>> wrote:
>>
>>> Depends on your models, but write a small function that returns the
>>> balance?
>>>
>>> def balance(self):
>>> return self.entitlement - self.num_days
>>>
>>>
>>> (for instance)
>>>
>>> L.
>>>
>>> --
>>> The most dangerous phrase in the language is, "We've always done it this
>>> way."
>>>
>>> - Grace Hopper
>>>
>>> On 5 April 2017 at 10:49, sum abiut <suab...@gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> I am working on an leave management system and I am having a some
>>>> difficulties trying to figure out how to accomplished this scenario.
>>>>
>>>> for example i have a table of.
>>>>
>>>> when a user apply for a leave i want to get the previous
>>>> total_leave_balance of the applicant and minus his/her current num_days and
>>>> assign the result to be the total_leave_balance. Please advise what would
>>>> be the best way to approach this.
>>>>
>>>>
>>>> *username* *first_name* *second_name* *num_days* *leave_entitlement*
>>>> *beginning_bal* *Total_leave_balance*
>>>> jtom james tom 3 12 23 20
>>>> tjohn tom john 2 2 5 7
>>>> atom anna tom 3 21 2
>>>>
>>>> jtom james tom 3 4 2
>>>>
>>>> atom anna tom 3 3 5
>>>>
>>>>
>>>>
>>>> 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 post to this group, send email to django-users@googlegroups.com.
>>>> Visit this group at https://groups.google.com/group/django-users.
>>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>>> gid/django-users/CAPCf-y562uvxRwTf0iFnT6Lcos8_nd3FD5u%3D7MVV
>>>> p2yN4qAcDA%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/django-users/CAPCf-y562uvxRwTf0iFnT6Lcos8_nd3FD5u%3D7MVVp2yN4qAcDA%40mail.gmail.com?utm_medium=email_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/django-users/CAGBeqiN6th0dJWHTN0R--sehmD0B--DzbzUV6a5mX

Re: python django fields and row calculation

2017-04-04 Thread sum abiut
Thank for taking your time to respond. my problem is automating that, for
example when a user apply for a leave i want the system to calculate and
update the total balance automatically. But Since a user can apply for a
leave more that once which mean a user can have more that one record of
leave application on the database. My problem is having to figure out when
was the last time that the user has launch his/her leave application so
that i can minus num_days from the that total balance.


thanks



On Wed, Apr 5, 2017 at 12:20 PM, Lachlan Musicman <data...@gmail.com> wrote:

> Depends on your models, but write a small function that returns the
> balance?
>
> def balance(self):
> return self.entitlement - self.num_days
>
>
> (for instance)
>
> L.
>
> --
> The most dangerous phrase in the language is, "We've always done it this
> way."
>
> - Grace Hopper
>
> On 5 April 2017 at 10:49, sum abiut <suab...@gmail.com> wrote:
>
>> Hi,
>>
>> I am working on an leave management system and I am having a some
>> difficulties trying to figure out how to accomplished this scenario.
>>
>> for example i have a table of.
>>
>> when a user apply for a leave i want to get the previous
>> total_leave_balance of the applicant and minus his/her current num_days and
>> assign the result to be the total_leave_balance. Please advise what would
>> be the best way to approach this.
>>
>>
>> *username* *first_name* *second_name* *num_days* *leave_entitlement*
>> *beginning_bal* *Total_leave_balance*
>> jtom james tom 3 12 23 20
>> tjohn tom john 2 2 5 7
>> atom anna tom 3 21 2
>>
>> jtom james tom 3 4 2
>>
>> atom anna tom 3 3 5
>>
>>
>>
>> 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 post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/CAPCf-y562uvxRwTf0iFnT6Lcos8_nd3FD5u%
>> 3D7MVVp2yN4qAcDA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAPCf-y562uvxRwTf0iFnT6Lcos8_nd3FD5u%3D7MVVp2yN4qAcDA%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAGBeqiN6th0dJWHTN0R--sehmD0B-
> -DzbzUV6a5mXOLfz_5MHg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAGBeqiN6th0dJWHTN0R--sehmD0B--DzbzUV6a5mXOLfz_5MHg%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


  1   2   >