Re: compute model field by related field

2019-04-20 Thread Derek
That should just require a basic if/then logic test; "get" the correct Club 
object, update the win/loss field and save the Club. Repeat for both Clubs.

On Thursday, 18 April 2019 14:09:41 UTC+2, omar ahmed wrote:
>
> thank you for response , derek
> but how can i increment 'win' 'lost' or 'draw' Club fields by 'winner' 
> Match field
>
> On Wednesday, April 17, 2019 at 3:26:22 PM UTC+2, Derek wrote:
>>
>> 1. Add a "winner" field to your Match
>> 2. Implement a post_save  signal for the Match model that updates the 
>> "won" or "lost" fields for each Club in the match (simple if/then logic 
>> based on winner).
>>
>> PS I think the default values for "won" and "lost" for a Club should be 
>> "0" and not "1".
>>
>> On Tuesday, 16 April 2019 20:19:34 UTC+2, omar ahmed wrote:
>>>
>>> hello ... i have two models "Club" class and "Match" class and it has 
>>> foreign key to Club
>>> now i want to increment "won" field (or draw or lost) in "Club" class by 
>>> "score_local" and "score_visitor" in "Match" class ..
>>> how can i do this
>>> class Club(models.Model):
>>> name = models.CharField(max_length=100)
>>> won = models.IntegerField(default=1)
>>> draw = models.IntegerField(default=1)
>>> lost = models.IntegerField()
>>> goal_for = models.IntegerField()
>>> goal_against = models.IntegerField()
>>>
>>>
>>> class Match(models.Model):
>>> play_date = models.DateTimeField('play date')
>>> club_visitor = models.ForeignKey(Club, on_delete=models.CASCADE, 
>>> related_name='match_club_visitor')
>>> club_local = models.ForeignKey(Club, on_delete=models.CASCADE, 
>>> related_name='match_club_local')
>>> score_visitor = models.IntegerField()
>>> score_local = models.IntegerField()
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"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/964943b5-1fcb-4324-97bf-3b964af23e36%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to provide function calling event for button in django html templates ?

2019-04-20 Thread Mayur Bagul
Hello Community,

i'm facing one problem. Scenario is such that i have one template 
login.html in Django Project, inside this file i have wrote html code for 
login purpose.

what i want that once user click on Log-In Button it should call function ( 
onclick using Javascript cant use in Django) which will check password and 
username.
if username and password is Correct then it will go to next page which is 
main page else it will return prompt or alert 'Wrong Credentials".

but im not getting how i can do this in Django ?

So guys Please help me out of this issue.

Thanking you,
Mayur Bagul.

-- 
You received this message because you are subscribed to the Google Groups 
"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/0fd23be8-b2d7-437e-b3e7-05c1f5bcdf4e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: I'm going to ask you an editor in django.

2019-04-20 Thread Derek
You are better off integrating with a third-party app e.g.
https://wopi.readthedocs.io/en/latest/overview.html


On Thursday, 18 April 2019 17:17:19 UTC+2, bang wrote:
>
> I would like to add editor function in django 
> and call up stored document( word, pdf, excel), edit and save. Is 
> there a way?
> Something like an Apache POI in Java.
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/6df37064-b351-4aae-8ca2-bfed5ae0f382%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to provide function calling event for button in django html templates ?

2019-04-20 Thread Gil Obradors
Hi!

If you want you can re-use django.contrib.auth package
Here one tutorial:
https://wsvincent.com/django-user-authentication-tutorial-login-and-logout/

Otherwise, you can do a POST to a URL, and this url (url.py) call a
function ( views.py)

Good luck!




Missatge de Mayur Bagul  del dia ds., 20 d’abr.
2019 a les 9:17:

> Hello Community,
>
> i'm facing one problem. Scenario is such that i have one template
> login.html in Django Project, inside this file i have wrote html code for
> login purpose.
>
> what i want that once user click on Log-In Button it should call function
> ( onclick using Javascript cant use in Django) which will check password
> and username.
> if username and password is Correct then it will go to next page which is
> main page else it will return prompt or alert 'Wrong Credentials".
>
> but im not getting how i can do this in Django ?
>
> So guys Please help me out of this issue.
>
> Thanking you,
> Mayur Bagul.
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/0fd23be8-b2d7-437e-b3e7-05c1f5bcdf4e%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/CAK-JoTTfycKS-RKGgmHRHza7rNrDM%2B6Ni6yea5H-%2BC7-v4EM2g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to provide function calling event for button in django html templates ?

2019-04-20 Thread Mayur Bagul
hello gil,

thanks for tutorial link i will check it out that one. 
As you gave solution of calling a function via view i did so but it didnt 
worked and another thing i dint understand is about post i thought it didnt 
support in django.

can you please provide me little code your talking about post method?  it 
will be helpful.

thanking you.

On Saturday, April 20, 2019 at 12:52:32 PM UTC+5:30, Gil Obradors wrote:
>
> Hi!
>
> If you want you can re-use django.contrib.auth package
> Here one tutorial: 
> https://wsvincent.com/django-user-authentication-tutorial-login-and-logout/
>
> Otherwise, you can do a POST to a URL, and this url (url.py) call a 
> function ( views.py)
>
> Good luck!
>
>
>
>
> Missatge de Mayur Bagul > del dia ds., 
> 20 d’abr. 2019 a les 9:17:
>
>> Hello Community,
>>
>> i'm facing one problem. Scenario is such that i have one template 
>> login.html in Django Project, inside this file i have wrote html code for 
>> login purpose.
>>
>> what i want that once user click on Log-In Button it should call function 
>> ( onclick using Javascript cant use in Django) which will check password 
>> and username.
>> if username and password is Correct then it will go to next page which is 
>> main page else it will return prompt or alert 'Wrong Credentials".
>>
>> but im not getting how i can do this in Django ?
>>
>> So guys Please help me out of this issue.
>>
>> Thanking you,
>> Mayur Bagul.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django...@googlegroups.com .
>> To 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/0fd23be8-b2d7-437e-b3e7-05c1f5bcdf4e%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/9986adf9-9f54-4728-892c-361c3cdedd1b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to provide function calling event for button in django html templates ?

2019-04-20 Thread Gil Obradors
Before continuing with this, read some about http methods like :
https://www.tutorialspoint.com/http/http_methods.htm

Yes, it's suported.

one example function playing with post requests:

def form(request):
form = facturaForm
if request.method == 'POST':
print(request.POST)
return render(request, 'demanoaltaform.html', {'form' : form})


Missatge de Mayur Bagul  del dia ds., 20 d’abr.
2019 a les 9:31:

> hello gil,
>
> thanks for tutorial link i will check it out that one.
> As you gave solution of calling a function via view i did so but it didnt
> worked and another thing i dint understand is about post i thought it didnt
> support in django.
>
> can you please provide me little code your talking about post method?  it
> will be helpful.
>
> thanking you.
>
> On Saturday, April 20, 2019 at 12:52:32 PM UTC+5:30, Gil Obradors wrote:
>>
>> Hi!
>>
>> If you want you can re-use django.contrib.auth package
>> Here one tutorial:
>> https://wsvincent.com/django-user-authentication-tutorial-login-and-logout/
>>
>> Otherwise, you can do a POST to a URL, and this url (url.py) call a
>> function ( views.py)
>>
>> Good luck!
>>
>>
>>
>>
>> Missatge de Mayur Bagul  del dia ds., 20 d’abr. 2019
>> a les 9:17:
>>
>>> Hello Community,
>>>
>>> i'm facing one problem. Scenario is such that i have one template
>>> login.html in Django Project, inside this file i have wrote html code for
>>> login purpose.
>>>
>>> what i want that once user click on Log-In Button it should call
>>> function ( onclick using Javascript cant use in Django) which will check
>>> password and username.
>>> if username and password is Correct then it will go to next page which
>>> is main page else it will return prompt or alert 'Wrong Credentials".
>>>
>>> but im not getting how i can do this in Django ?
>>>
>>> So guys Please help me out of this issue.
>>>
>>> Thanking you,
>>> Mayur Bagul.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django...@googlegroups.com.
>>> To 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/0fd23be8-b2d7-437e-b3e7-05c1f5bcdf4e%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/9986adf9-9f54-4728-892c-361c3cdedd1b%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/CAK-JoTSpGyYU%3DNO_5_Gd%3Dc4qJ05kg8YkzPW9q%3DgGdc73jmAsvw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why my email goes to spam?

2019-04-20 Thread Kasper Laudrup

Hi Gil and Mohammad,

On 20/04/2019 08.55, Gil Obradors wrote:

May be DKIM isn't correctly configured?

Authentication-Results:mx.google.com  ;
dkim=fail header.i=@myaa.ir    header.s=2019 
header.b=Q8G8809R;




That would be my best bet as well. I would think a false DKIM header 
would be even more suspicious than not having set up DKIM at all, but 
again, that's up for the mail server (in this case Google) to decide.


The mail server at mail.myaa.ir seems to be fairly reasonably 
configured, although it does miss stuff like a valid reverse DNS entry, 
but that's not a big issue.


I would probably contact myaa.ir to figure out why they haven't 
configured DKIM correctly (or whatever the DKIM issue is).


Kind regards,

Kasper Laudrup

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To 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/3dca79a7-8d61-a02a-be19-4f6e97f91322%40stacktrace.dk.
For more options, visit https://groups.google.com/d/optout.


Re: How to provide function calling event for button in django html templates ?

2019-04-20 Thread Jani Tiainen
Hi,

I also suggest that take a look at Django Girls tutorial. It does pretty
good job at describing web basics and django same time.

https://tutorial.djangogirls.org/en/



On Sat, Apr 20, 2019 at 10:17 AM Mayur Bagul  wrote:

> Hello Community,
>
> i'm facing one problem. Scenario is such that i have one template
> login.html in Django Project, inside this file i have wrote html code for
> login purpose.
>
> what i want that once user click on Log-In Button it should call function
> ( onclick using Javascript cant use in Django) which will check password
> and username.
> if username and password is Correct then it will go to next page which is
> main page else it will return prompt or alert 'Wrong Credentials".
>
> but im not getting how i can do this in Django ?
>
> So guys Please help me out of this issue.
>
> Thanking you,
> Mayur Bagul.
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/0fd23be8-b2d7-437e-b3e7-05c1f5bcdf4e%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Jani Tiainen
Software wizard

https://blog.jani.tiainen.cc/

Always open for short term jobs or contracts to work with Django.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To 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/CAHn91ofPJ80DzUyJEO%3DqfLuE4emRMoQ_CH-0hAqBi2vyaSunFA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ReportLab or Xhtml2pdf Please can any one guide me to convert the rendered in html to pdf

2019-04-20 Thread Iuli Hardt


Em sexta-feira, 19 de abril de 2019 15:10:31 UTC-3, Irfan Khan escreveu:
>
> hi,
> i stucked in converting the pdf file from html
> can an one suggest me even any other possibility instead of using python 
> library 
>
>
Try to use weasyprint, put css in the pdf html using ... "style page to print here" 

google "DJANGO WASYPRINT"
https://www.bedjango.com/blog/how-generate-pdf-django-weasyprint/

-- 
You received this message because you are subscribed to the Google Groups 
"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/2ba60ea6-fd7f-4970-95f0-571bb9b30633%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django - always getting False in form.is_valid()

2019-04-20 Thread Sipum Mishra
Hi Vineeth,

please find below is the output ->



On Fri, 19 Apr 2019 at 19:04, vineeth sagar 
wrote:

> can you please post, request.POST output?
>
> On Fri, 19 Apr 2019, 16:34 Sipum Mishra,  wrote:
>
>> Hi All,
>>
>> I am always getting - form.is_valid returning False. kindly check where I
>> am doing wrong.
>> please find below code.
>>
>>
>> views.py
>> ---
>> def home(request):
>>
>> if request.method == 'POST':
>> form = ListForm(request.POST or None)
>> print(form.is_valid(), "-->",request.POST['Item'])
>> print(form.errors)
>> print(form)
>> if form.is_valid():
>> form.save()
>> all_items = List.objects.all
>> messages.success(request, ('Item has been Added to the List!'))
>> return render(request,'home.html', {'all_items' : all_items})
>> else:
>> print("deba-->",request.POST)
>> return HttpResponse("Form is invalid!")
>> else:
>> all_items = List.objects.all
>> return render(request,'home.html', {'all_items' : all_items})
>>
>> -
>> form.py
>> -
>>
>> class ListForm(forms.ModelForm):
>> class Meta:
>> model = List
>> fields = ["item", "completed"]
>>
>>
>> 
>> model.py
>> -
>>
>> class List(models.Model):
>> item = models.CharField(max_length=200)
>> completed = models.BooleanField(default=False)
>>
>>
>> def __str__(self):
>> return self.item + '|' + str(self.completed)
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "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/4ca5e82d-f34b-4ab4-8f82-5be0dcdebecc%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/CAMMZq8OxVOJ8cF%3DFTNriHjBXKvdv29in-gOB-M-ia86L_ntSQw%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/CAGHZBzxon22bfLUUud8tMFxyxQ36bJxZKu2yhvObPMFwbQmVpQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django - always getting False in form.is_valid()

2019-04-20 Thread Sipum Mishra
Hi Vineeth,

when I am trying to add 'add testing' through html form for todo list app
getting this above form.is_valid() always False.

On Sat, 20 Apr 2019 at 23:02, Sipum Mishra  wrote:

> Hi Vineeth,
>
> please find below is the output ->
>
>  ['8V0Or1mvx2gtOa5fuYsdmAJ1o7SpGOcbSYulW0WMACHbrBhn8tOI0SO1z65MzXGx'],
> 'Item': ['add tesing']}>
>
> On Fri, 19 Apr 2019 at 19:04, vineeth sagar 
> wrote:
>
>> can you please post, request.POST output?
>>
>> On Fri, 19 Apr 2019, 16:34 Sipum Mishra,  wrote:
>>
>>> Hi All,
>>>
>>> I am always getting - form.is_valid returning False. kindly check where
>>> I am doing wrong.
>>> please find below code.
>>>
>>>
>>> views.py
>>> ---
>>> def home(request):
>>>
>>> if request.method == 'POST':
>>> form = ListForm(request.POST or None)
>>> print(form.is_valid(), "-->",request.POST['Item'])
>>> print(form.errors)
>>> print(form)
>>> if form.is_valid():
>>> form.save()
>>> all_items = List.objects.all
>>> messages.success(request, ('Item has been Added to the List!'))
>>> return render(request,'home.html', {'all_items' : all_items})
>>> else:
>>> print("deba-->",request.POST)
>>> return HttpResponse("Form is invalid!")
>>> else:
>>> all_items = List.objects.all
>>> return render(request,'home.html', {'all_items' : all_items})
>>>
>>> -
>>> form.py
>>> -
>>>
>>> class ListForm(forms.ModelForm):
>>> class Meta:
>>> model = List
>>> fields = ["item", "completed"]
>>>
>>>
>>> 
>>> model.py
>>> -
>>>
>>> class List(models.Model):
>>> item = models.CharField(max_length=200)
>>> completed = models.BooleanField(default=False)
>>>
>>>
>>> def __str__(self):
>>> return self.item + '|' + str(self.completed)
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "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/4ca5e82d-f34b-4ab4-8f82-5be0dcdebecc%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/CAMMZq8OxVOJ8cF%3DFTNriHjBXKvdv29in-gOB-M-ia86L_ntSQw%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/CAGHZBzwVAQOBoksQFVhUgBpC0bJyL4ZeahDHpKfxLpT6Z833TQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Storing HTML in DB using DJANGO

2019-04-20 Thread Sipum Mishra
Hi friends,

I want to store a html in database using python and need to retrieve that 
html and convert that in to PDF.
can u plz suggest me how to store that HTML in DB ?

-- 
You received this message because you are subscribed to the Google Groups 
"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/f301b675-6587-434e-b25d-87de9d9fef10%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django - always getting False in form.is_valid()

2019-04-20 Thread John Bagiliko
Drop the html codes here please. Let one try it actually. It's difficult to
debug like this.

On Sat, Apr 20, 2019, 5:35 PM Sipum Mishra  wrote:

> Hi Vineeth,
>
> when I am trying to add 'add testing' through html form for todo list app
> getting this above form.is_valid() always False.
>
> On Sat, 20 Apr 2019 at 23:02, Sipum Mishra  wrote:
>
>> Hi Vineeth,
>>
>> please find below is the output ->
>>
>> > ['8V0Or1mvx2gtOa5fuYsdmAJ1o7SpGOcbSYulW0WMACHbrBhn8tOI0SO1z65MzXGx'],
>> 'Item': ['add tesing']}>
>>
>> On Fri, 19 Apr 2019 at 19:04, vineeth sagar 
>> wrote:
>>
>>> can you please post, request.POST output?
>>>
>>> On Fri, 19 Apr 2019, 16:34 Sipum Mishra,  wrote:
>>>
 Hi All,

 I am always getting - form.is_valid returning False. kindly check where
 I am doing wrong.
 please find below code.


 views.py
 ---
 def home(request):

 if request.method == 'POST':
 form = ListForm(request.POST or None)
 print(form.is_valid(), "-->",request.POST['Item'])
 print(form.errors)
 print(form)
 if form.is_valid():
 form.save()
 all_items = List.objects.all
 messages.success(request, ('Item has been Added to the List!'))
 return render(request,'home.html', {'all_items' : all_items})
 else:
 print("deba-->",request.POST)
 return HttpResponse("Form is invalid!")
 else:
 all_items = List.objects.all
 return render(request,'home.html', {'all_items' : all_items})

 -
 form.py
 -

 class ListForm(forms.ModelForm):
 class Meta:
 model = List
 fields = ["item", "completed"]


 
 model.py
 -

 class List(models.Model):
 item = models.CharField(max_length=200)
 completed = models.BooleanField(default=False)


 def __str__(self):
 return self.item + '|' + str(self.completed)

 --
 You received this message because you are subscribed to the Google
 Groups "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/4ca5e82d-f34b-4ab4-8f82-5be0dcdebecc%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/CAMMZq8OxVOJ8cF%3DFTNriHjBXKvdv29in-gOB-M-ia86L_ntSQw%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/CAGHZBzwVAQOBoksQFVhUgBpC0bJyL4ZeahDHpKfxLpT6Z833TQ%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/CAC26BE36LumBC4uGcwJDFNBX-wOyBzjH57uKY9dxQ_G0tGNbDA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why my email goes to spam?

2019-04-20 Thread 'Rumah Ilmu Indonesia' via Django users
On Thu, Apr 18, 2019 at 3:06 PM Mohammad Etemaddar <
mohammad.etemad...@gmail.com> wrote:

> Hello. I'm working on a bussiness website. I send invitation and also
> confirm emails by django-allauth.
> Invitation and allauth emails go to spam box.
> I don't know what is the problem?
> How can I prevent emails going to spam?
>
>
>
 You can find your problem here : http://www.mail-tester.com/

Send your email to a generated address there. And then analyze it.

Or you can use https://mxtoolbox.com/

Most of problem (DKIM, SPF, DMARC) should be setting in DNS record, not
django-related. For DKIM, you should know about your MTA. For most of LINUX
distribution that use postfix, you can generate it with open-dkim. And then
put it on your DNS configuration

Regard,
Reza Ervani

-- 
You received this message because you are subscribed to the Google Groups 
"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-JRee%2B49J1WR2vyb_Wci-C%2BvbXd2fwApaDhQuau68X73Hogw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Advanced permissions and role creation

2019-04-20 Thread Joel Mathew
I have an application for a hospital. There, I should be able to assign
different roles like Doctor, Nurse, Attender, Auxillary Nurse, Pharmacist,
Store Manager etc, each of would be having specific access to seperate
areas (views), with some having restricted access. In addition, there are
other hospitals who would be having no access to another hospital's
records. All of these permissions should be customisable, and I should be
able to create additional roles and permission groups for specific areas
later (from within the application itself, in production). What would be
the best solution to use? Is there a middleware which works well. I don't
want to roll my own if I will be reinventing the wheel.

Currently my application has no use permissions. But access to specific
hospitals is being restricted by a model whoch stores hospital name, and
user name.
Sincerely yours,

 Joel G Mathew

-- 
You received this message because you are subscribed to the Google Groups 
"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/CAA%3Diw_9BrOEh4Ss3X0g_EnaFyp1XTXij5DoZvva_XxwKVzXsGQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Advanced permissions and role creation

2019-04-20 Thread Sithembewena L. Dube
For roles and permissions management, I would stick with Django's Auth
application (django.contrib.auth).

It sounds like you ought to read up on how to design and build a
multi-tenancy SaaS project in Django. I cannot recommend any one resource,
so you'll have to do some searching and see what fits the bill for you.

Kind regards,
Sithu


*Sent with Shift
*

On Sun, Apr 21, 2019 at 4:12 AM Joel Mathew  wrote:

> I have an application for a hospital. There, I should be able to assign
> different roles like Doctor, Nurse, Attender, Auxillary Nurse, Pharmacist,
> Store Manager etc, each of would be having specific access to seperate
> areas (views), with some having restricted access. In addition, there are
> other hospitals who would be having no access to another hospital's
> records. All of these permissions should be customisable, and I should be
> able to create additional roles and permission groups for specific areas
> later (from within the application itself, in production). What would be
> the best solution to use? Is there a middleware which works well. I don't
> want to roll my own if I will be reinventing the wheel.
>
> Currently my application has no use permissions. But access to specific
> hospitals is being restricted by a model whoch stores hospital name, and
> user name.
> Sincerely yours,
>
>  Joel G Mathew
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/CAA%3Diw_9BrOEh4Ss3X0g_EnaFyp1XTXij5DoZvva_XxwKVzXsGQ%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/CAH-SnCDB5J%2BzRABDUNCOJFAe8q-xG5UVVkR40E5ZLh%2BDg%2BBPJg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Advanced permissions and role creation

2019-04-20 Thread Mike Dewhirst

On 21/04/2019 12:11 pm, Joel Mathew wrote:
I have an application for a hospital. There, I should be able to 
assign different roles like Doctor, Nurse, Attender, Auxillary Nurse, 
Pharmacist, Store Manager etc, each of would be having specific access 
to seperate areas (views), with some having restricted access. In 
addition, there are other hospitals who would be having no access to 
another hospital's records. All of these permissions should be 
customisable, and I should be able to create additional roles and 
permission groups for specific areas later (from within the 
application itself, in production). What would be the best solution to 
use? Is there a middleware which works well. I don't want to roll my 
own if I will be reinventing the wheel.

Joel

I use Django Admin and contrib.auth. The Admin lets a superuser add a 
new auth.group (ie., a role) and assign specific (other) model(s) 
editing rights to it. Then users can be given membership of certain groups.


I control access to corporate data by assigning a one-to-one 
relationship between any user and their particular company. Where a user 
needs access to data across more than one company I force them to have 
separate logins related one each to those companies. Companies need to 
know they control access to their own data. Only consultants (perhaps 
agency nurses in your scenario) need multiple logins. The Admin lets you 
modify the queryset of records to filter out everying except the data 
that user is entitled to see.


There are also mechanisms to show permitted data read-write or readonly 
depending on role membership. I did my own for Django 1.11 but I notice 
a later version seems to have specific read-only permissions assignable 
to auth.groups. Not absolutely sure about that. I'm sticking with 1.11 
for a little while yet.


My roles are
    admin
    author
    authority
    consumer
    editor
    manager

And in my common.utils I have ...

def is_member(user, name):
    return user.groups.filter(name=name).exists()   # or user.is_superuser

def is_admin(user, name='admin'):
    return is_member(user, name)

def is_author(user, name='author'):
    return is_member(user, name)

def is_authority(user, name='authority'):
    return is_member(user, name)

def is_consumer(user, name='consumer'):
    return is_member(user, name)

def is_editor(user, name='editor'):
    return is_member(user, name)

def is_manager(user, name='manager'):
    return is_member(user, name)



Currently my application has no use permissions. But access to 
specific hospitals is being restricted by a model whoch stores 
hospital name, and user name.


I have a specific company model for company info and a user.userprofile 
model which links a user to a company. I'm not using a custom user model 
in this project but I doubt I would have done it much differently if I had.


hth

Mike



Sincerely yours,

 Joel G Mathew

--
You received this message because you are subscribed to the Google 
Groups "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/CAA%3Diw_9BrOEh4Ss3X0g_EnaFyp1XTXij5DoZvva_XxwKVzXsGQ%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/4944ebe7-53c0-c2ab-9993-d2c52c99056e%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Django How to write Customized Query ( Display Information Departmentwise)

2019-04-20 Thread Gourav Chawla
First of all, use appropriate model fields for linking objects. For example 
users should be a foreign key to your(or Django's) user table.

Then whenever you want to show data on any interface to any user, just filter 
content/rows by user department.

Something like:

T1.objects.filter(user=current_user, department=current_user.department)

-- 
You received this message because you are subscribed to the Google Groups 
"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/a4484706-2f3a-488c-a28c-41f78e2f42ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django How to write Customized Query ( Display Information Departmentwise)

2019-04-20 Thread Sithembewena L. Dube
Your model fields are not cased correctly.

https://stackoverflow.com/questions/8908760/should-i-use-camel-case-or-underscores-in-python


Kind regards,
Sithu


*Sent with Shift
*

On Fri, Apr 19, 2019 at 6:23 PM Balaji Shetty 
wrote:

> HI
>
> My models.py
>
>
> class T1(models.Model):
> CaseNumber = models.TextField(blank=True,null=True)
> UserCurrent = models.TextField(blank=True,null=True,default='user1')
> UserCurrentDepartment = models.TextField(blank=True,null=True)
>
> def __str__(self):
> return '%s %s' % (self.CaseNumber , self.UserCurrentDepartment )
>
> 
>  Assume Record in MODELS T1  to be entered by respectuve user are
> (
> *  I will create System User U1, U2 and U3 for IT,CS and MECH Department
> only. *
> *)*
> CaseNumber  -- UserCurrent  --UserCurrentDepartment
>  11 - U1 - *iT*
>
> * 12 - U1 - IT*
>
> *13 - U1 - IT*
>
>  21 - U2 - *CS*
> * 22 - U2 - CS*
>
> *23 - U2- CS*
>
>  31 - U3 - *MECH*
>
> * 32 - U3 - MECH *
> *33 - U3 - MECH*
> *--*
>
>
> *when I run the Project by creating One Superuser*
>
> *http://127.0.0.1:8000/admin/appname/t1/
> *
>
> * i get all records of all Users and all Departments.*
> *I will create three user of Name U1,U2 and U3 of IT,CS and MECH
> Department and ask them to do CRUD Operation. I want the output in
> following way use rwise.*
>
>
> *When User U1 do the login in Admin Panel, He should get only his
> Department Records -IT, not other department*
>
> CaseNumber--   UserCurrent  --  UserCurrentDepartment
>  11 - U1 - *iT*
>
> * 12 - U1 - IT*
>
> *13 - U1 - IT*
> *--*
>
> *When User U2 do the login in Admin Panel, He should get only his
> Department Records - CS,, not other department*
>
>
> CaseNumber--   UserCurrent  --  UserCurrentDepartment
>  21 - U2 - *CS*
> * 22 - U2 - CS*
>
> *23 - U2- CS*
> *--*
>
> *When User U3 do the login in Admin Panel, He should get only his
> Department Records - MECH, , not other department*
>
>
> CaseNumber--   UserCurrent  --  UserCurrentDepartment
>  31 - U3 - *MECH*
>
> * 32 - U3 - MECH *
> *33 - U3 - MECH*
> *--*
>
> *When I create superuser, he has access to all user data.*
>
> *But other users U1, U2 and U3 have also access of other users Data.*
>
>
> *So My query is how can i accomplish this Constraint.*
>
> --.
>
> How can i write a customized query so that Admin panel should display only
> particular Department as per respective user Deparement.-
>
>
> *Mr. Shetty Balaji S.Asst. ProfessorDepartment of Information Technology,*
> *SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.India*
> *Official: bsshe...@sggs.ac.in  *
> *  Mobile: +91-9270696267*
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/CAECSbOtiHTPCprTj9w168rHksoUf2TKsju-yQHZvJLw14eZ9Ag%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/CAH-SnCCSuqweF_hfSCUXR6p3O3WsHrNEWLcShe%2BdQx6tkYEkmA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.