django cookie cutter docker with caddy

2018-04-26 Thread venkat eswar
Hi All,

caddy env file:
Caddy
--

DOMAIN_NAME=balajidigitals.in

caddy production config

www.{$DOMAIN_NAME}  {
redir https://balajidigitals.in
}

{$DOMAIN_NAME} {
proxy / django:5000 {
header_upstream Host {host}
header_upstream X-Real-IP {remote}
header_upstream X-Forwarded-Proto {scheme}
}
log stdout
errors stdout
gzip
}

Here is the error:
caddy_1 | 2018/04/26 00:15:44 duplicate site address: balajidigitals.in


Can anyone help me on this

Thanks & Regards
Kasana Venkateswara Reddy

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


Re: Django--Making query use part of the matching name

2018-04-26 Thread shawnmhy
Thank you for your help! And yes, I think I should use regex. But could you 
please show me how to use it in my example, since I am new to django..

在 2018年4月26日星期四 UTC+1上午2:14:10,James Farris写道:
>
> I believe you want to use icontains rather than contains. It’s case 
> insensitive. 
>
> I’m not sure without using regex it’s possible to return the results based 
> on any character in any order in the search string. 
>
> On Apr 25, 2018, at 5:13 PM, shaw...@gmail.com  wrote:
>
> Hello everyone!
>
> Currently I am working on Django.
>
> I defined a 'Search' function in views.py:
>
> def search(request):
> q = request.GET.get("q")
> if q:
> ReactResul = Reactionsmeta.objects.filter(id__contains=q)
> MetaResul = Metabolites.objects.filter(id__contains=q)
> GeneResul = Genes.objects.filter(id__contains=q)
>
> else:
> # you may want to return Customer.objects.none() instead
> ReactResul= Reactionsmeta.objects.all()
> GeneResul = Genes.objects.all()
> MetaResul = Metabolites.objects.all()
> context = dict(result_1=MetaResul, q=q, result_2=ReactResul, result_3 = 
> GeneResul)
> return render(request, "Recon/search.html", context)
>
>
> And now I want to make it more powerful.
>
> If I want to search '10FTH86RSK' but I cannot remember the whole name, I 
> can just use part of the string to make query. For example, if I type 
> '10FTK', '10FTH86RSK' should be returned as result.
> In that case, '10FTK', '10F6TK' or '10FTK4' should also be returned as 
> results.
>
> So how could I achieve this function?
>
> -- 
> You received this message because you are subscribed 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/793b8999-cac4-4c2d-94cc-eabb80f4e702%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/75275cd3-84d0-45fb-a104-4cc5c224f813%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Do you know good guides to use ajax in django

2018-04-26 Thread carlos . davalos17
Im starting a social network for my school and i need to show the coments 
of my post without recharging the whole and for other things in my proyect

-- 
You received this message because you are subscribed to the Google Groups 
"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/de939dae-605d-4cf1-9a7a-e5ee48f249ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


The sending of an attachment in pdf format under django.

2018-04-26 Thread Bienvenue Emmanuel
Hello ! I hope you are well...
I am working on project of registration in a school where I must recover, 
put the information entered by the user in a template and be able to 
translate this template into pdf in the end send the generated PDF file as 
an attachment of a mail that I send back to the user. Until then the other 
processes work, but after sending the email when I consult my mailbox on my 
phone I find the mail sent with the attachment on the other hand when I 
consult my mailbox on my PC or even with a browser (even on) I can not find 
the attachment. I have never encountered this kind of hard-to-understand 
error. Help me please.

def pdf_genarete(request):

form = MyModelForm(request.POST or None)

if form.is_valid():

nom = form.cleaned_data.get("nom")
email = form.cleaned_data.get("email")
obj = MyModel.objects.create(nom=nom, email=email)
print(obj.nom)
print(obj.email)

context = {"models_instance": obj}

pdf = render_to_pdf("pdfapp/template_pdf.html", context)
filename = "mypdf_{}.pdf".format(obj.order_id)
obj.pdf.save(filename, BytesIO(pdf.content))
# print(obj.pdf.name, obj.pdf.size)

subject = "Thank you"
from_email = settings.EMAIL_HOST_USER
to_email = [obj.email]
body = "Votre inscription"

email_pdf = EmailMultiAlternatives(

subject = subject,
body =body,
from_email = from_email,
to=to_email, 
)

instance_attach = obj.pdf.read()
# print(instance.pdf.name, instance.pdf.size)
email_pdf.attach_alternative(instance_attach, "application/pdf")
# import pdb;pdb.set_trace()

email_pdf.send()

return redirect(reverse("home"))

return render(request, "pdfapp/formulaire.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/b48bb711-2e89-4cd0-8440-ee7812830b1a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


EDX Ginkgo - (login_and_register.hmtl)

2018-04-26 Thread Sergen Ucar
Hello guys, 

I just wanna ask you, how can I do "login_and_register.html" is a modal. 
When I click "login", I don't wanna change my page. I just wanna open modal 
for login and sign up. Please help me about this problems. If you are using 
edx-ginkgo for improve yourself,  you can see what I am gonna talk. In 
there, we have some pages connect with each other. (views.py - url.py - 
login.underscore - register.underscore) I just want to do modal for that. 
Please help me . In the url for example login -> you can see urlpatterns+= 
url(r'^login', student_account.login_register_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/19797d57-3fad-48f3-9f67-3c48fcd27f8b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Do you know good guides to use ajax in django

2018-04-26 Thread Avraham Serour
I suggest taking a look at http://intercoolerjs.org


On Thu, Apr 26, 2018 at 7:36 AM,  wrote:

> Im starting a social network for my school and i need to show the coments
> of my post without recharging the whole and for other things in my proyect
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/de939dae-605d-4cf1-9a7a-e5ee48f249ed%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/CAFWa6tJL4DykA-54hXLEuzi9q1Fz_XHzbX7b9BbrtfYRS9dUcQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Crazy Idea: OOP for "Hyperlink"

2018-04-26 Thread guettli
I would like to keep both things separated:

- Attributes for URLs
- Access without login

What do you think?

Regards,
  Thomas


Am Mittwoch, 25. April 2018 14:04:22 UTC+2 schrieb TonyF-UK:
>
> Interestingly, I am thinking on something similar too - having a 
> report/notifications/actions view that have an auto generated URL. The 
> idea (on my concept) is that by getting this unique URL via email, a 
> user can access the report/action without needing to actually login - 
> the fact that a user accesses the url is authenticaton - it could 
> optionally require a password, since the userid is effectively part of 
> the URL 
>
> My thoughts : 
>
> Either a specific 
>
> A Notification/Report Model where one of the fields will be the 
> unique URL id 
>  An incoming URL with the right path would search for the 
> notification model with the extracted URL id 
>  My views would search my models for the incoming Id, and 
> confirm expected users, permissions etc. 
>  I would only have one view that needs this so my specific 
> solution would be highly specific 
>
>
> Or a  generic solution 
>
> A model for URLs and that model can have a one to one or one to one 
> to many relationship with other models; clearly this relationship is 
> dynamic so - I see this : 
>
> In the Model : 
>
> from hrefgeneric.models import HRefModel 
>
> class Notification(models.Model) 
>  href = models.OneToOne(HRefModel, ...) 
>  ... 
>
> In the views 
>
> from hrefgeneric.views import HRefRequiredMixin 
>
> class NotificationView(HRefRequiredMixin, View): 
>  class HREFRequired: 
>  login_url = '/login/' 
>  redirect_field_name='redirect_to' 
>  user_name_field = 'username' 
>
>   def get(self, HRef): 
>  # HRef is now the HRef instance relevant to the 
> incoming request (not just any text extracted from the URL 
>pass 
> def post(self, HRef): 
>  # HRef is now the HRef instance relevant to the 
> incoming request (not just any text extracted from the URL 
>pass 
>
>
> If login_url is set to anything truthy, then the mixin will enforce 
> some form of authentication form, with 'user_name_field' set to the 
> expected user name of the HRef (assuming the expected user on the 
> HRef is not None). 
>
> For the generic solution it would be great if there a decorator for 
> non class based views which does something similar. 
>
>  The HRef instance needs the following fields 
>
>  field_name =  # The name of any URL field that 
> this HREF should be matched on 
>  field_value =  # The value that the above field 
> should have for this HREF 
>  user =  # The user that is allowed to 
> access this HREF - can be None 
>  group =  # The permission Group that the 
> user - can be None 
>  permission =  # One or more permissions that 
> the user - can be None 
>
>  On creation, field_name & field_value must be set 
>
>  Example: 
>a pattern like this : 
> path('/notification/', my_view) 
>
>and a href instance : 
>  HRef(field_name='id', field_value='aabbccddeeff') 
>
>   would match against an incoming path of 
>  http://host/notification/aabbccddeeff 
>
>  It might be that we need to match multiple fields on a url - not 
> sure how we do this. 
>
> I would happily contribute to an Django appropriate plugin etc - it 
> seems like there is a lot of commonality between the use cases. 
>
> -- 
> Anthony Flury 
> email : *anthon...@btinternet.com * 
> Twitter : *@TonyFlury * 
>
>
> On 25/04/18 09:30, guettli wrote: 
> > Thank Adrien for sharing your knowledge. 
> > 
> > Our use cases have some parts that are common and some 
> > parts that are distinct. 
> > 
> > You want actions, I want static attributes. 
> > 
> > You define them on the model. 
> > 
> > I use URLs. In my case sometimes there is a 1:1 relationship between 
> > URL and model, 
> > but sometimes not. 
> > 
> > In my use case I have reports. I want a report to have a preview html 
> > snippet. 
> > 
> > There are N reports (N URLs) for one model. 
> > 
> > But I think there are more common things than distinct things. 
> > 
> > One URL can have N attributes. 
> > 
> > Some are actions, some static ones. 
> > 
> > Where these attributes come from is a different topic. 
> > 
> > If the URL  represents a model, the attributes (in your case 
> > "actions") of the model 
> > can be propagated up to the URL. 
> > 
> > I  hope you undestand what I wrote. If not, then tell me. 
> > 
> > Up to now these are just basic thoughts. I won't do a

Re: Crazy Idea: OOP for "Hyperlink"

2018-04-26 Thread guettli


Am Mittwoch, 25. April 2018 17:29:36 UTC+2 schrieb Jani Tiainen:
>
> Hi.
>
> Most probably you get there by creating custom template tag and bunch of 
> other code.
>
> It would be easier to grasp your idea if you have some kind of an 
> implementation to reference.
>
> Or is there something that stops you from proceeding?
>
>
Yes, there is something that stops me: work, family, friends, tennis, 
sleeping. With other words "time".

Nevertheless, even if I had time, I would do asking, talking and thinking 
for some days before taking the keyboard :-)

Regards,
  Thomas

-- 
You received this message because you are subscribed to the Google Groups 
"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/b5c3f2db-f664-4855-a63c-349fb04d398f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: Crazy Idea: OOP for "Hyperlink"

2018-04-26 Thread Matthew Pava
I’ve been thinking about your idea, and I wonder if there could instead be some 
kind of widget for URL objects (or views).

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of guettli
Sent: Thursday, April 26, 2018 8:34 AM
To: Django users
Subject: Re: Crazy Idea: OOP for "Hyperlink"



Am Mittwoch, 25. April 2018 17:29:36 UTC+2 schrieb Jani Tiainen:
Hi.

Most probably you get there by creating custom template tag and bunch of other 
code.

It would be easier to grasp your idea if you have some kind of an 
implementation to reference.

Or is there something that stops you from proceeding?


Yes, there is something that stops me: work, family, friends, tennis, sleeping. 
With other words "time".

Nevertheless, even if I had time, I would do asking, talking and thinking for 
some days before taking the keyboard :-)

Regards,
  Thomas
--
You received this message because you are subscribed to the Google Groups 
"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/b5c3f2db-f664-4855-a63c-349fb04d398f%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/612379414d7f4cf7a2c8aa1185decab9%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Re: Django--Making query use part of the matching name

2018-04-26 Thread James Farris
Try using filter(id__regex=r'\w’)

I’m not sure if this will give you the exact results your looking for, but 
worth a shot. 


Sent from my mobile device

> On Apr 26, 2018, at 2:31 AM, shawn...@gmail.com wrote:
> 
> Thank you for your help! And yes, I think I should use regex. But could you 
> please show me how to use it in my example, since I am new to django..
> 
> 在 2018年4月26日星期四 UTC+1上午2:14:10,James Farris写道:
>> 
>> I believe you want to use icontains rather than contains. It’s case 
>> insensitive. 
>> 
>> I’m not sure without using regex it’s possible to return the results based 
>> on any character in any order in the search string. 
>> 
>>> On Apr 25, 2018, at 5:13 PM, shaw...@gmail.com wrote:
>>> 
>>> Hello everyone!
>>> 
>>> Currently I am working on Django.
>>> 
>>> I defined a 'Search' function in views.py:
>>> 
>>> def search(request):
>>> q = request.GET.get("q")
>>> if q:
>>> ReactResul = Reactionsmeta.objects.filter(id__contains=q)
>>> MetaResul = Metabolites.objects.filter(id__contains=q)
>>> GeneResul = Genes.objects.filter(id__contains=q)
>>> 
>>> else:
>>> # you may want to return Customer.objects.none() instead
>>> ReactResul= Reactionsmeta.objects.all()
>>> GeneResul = Genes.objects.all()
>>> MetaResul = Metabolites.objects.all()
>>> context = dict(result_1=MetaResul, q=q, result_2=ReactResul, result_3 = 
>>> GeneResul)
>>> return render(request, "Recon/search.html", context)
>>> 
>>> And now I want to make it more powerful.
>>> 
>>> If I want to search '10FTH86RSK' but I cannot remember the whole name, I 
>>> can just use part of the string to make query. For example, if I type 
>>> '10FTK', '10FTH86RSK' should be returned as result.
>>> In that case, '10FTK', '10F6TK' or '10FTK4' should also be returned as 
>>> results.
>>> 
>>> So how could I achieve this function?
>>> -- 
>>> You received this message because you are subscribed 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/793b8999-cac4-4c2d-94cc-eabb80f4e702%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/75275cd3-84d0-45fb-a104-4cc5c224f813%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/9F2E0677-FD8C-446B-83DA-8119D6D3705C%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django--Making query use part of the matching name

2018-04-26 Thread shawnmhy
But how about my query string? I am using 'q' as the search term

在 2018年4月26日星期四 UTC下午3:19:15,James Farris写道:
>
> Try using filter(id__regex=r'\w’)
>
> I’m not sure if this will give you the exact results your looking for, but 
> worth a shot. 
>
>
> Sent from my mobile device
>
> On Apr 26, 2018, at 2:31 AM, shaw...@gmail.com  wrote:
>
> Thank you for your help! And yes, I think I should use regex. But could 
> you please show me how to use it in my example, since I am new to django..
>
> 在 2018年4月26日星期四 UTC+1上午2:14:10,James Farris写道:
>>
>> I believe you want to use icontains rather than contains. It’s case 
>> insensitive. 
>>
>> I’m not sure without using regex it’s possible to return the results 
>> based on any character in any order in the search string. 
>>
>> On Apr 25, 2018, at 5:13 PM, shaw...@gmail.com wrote:
>>
>> Hello everyone!
>>
>> Currently I am working on Django.
>>
>> I defined a 'Search' function in views.py:
>>
>> def search(request):
>> q = request.GET.get("q")
>> if q:
>> ReactResul = Reactionsmeta.objects.filter(id__contains=q)
>> MetaResul = Metabolites.objects.filter(id__contains=q)
>> GeneResul = Genes.objects.filter(id__contains=q)
>>
>> else:
>> # you may want to return Customer.objects.none() instead
>> ReactResul= Reactionsmeta.objects.all()
>> GeneResul = Genes.objects.all()
>> MetaResul = Metabolites.objects.all()
>> context = dict(result_1=MetaResul, q=q, result_2=ReactResul, result_3 = 
>> GeneResul)
>> return render(request, "Recon/search.html", context)
>>
>>
>> And now I want to make it more powerful.
>>
>> If I want to search '10FTH86RSK' but I cannot remember the whole name, I 
>> can just use part of the string to make query. For example, if I type 
>> '10FTK', '10FTH86RSK' should be returned as result.
>> In that case, '10FTK', '10F6TK' or '10FTK4' should also be returned as 
>> results.
>>
>> So how could I achieve this function?
>>
>> -- 
>> You received this message because you are subscribed 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/793b8999-cac4-4c2d-94cc-eabb80f4e702%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...@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/75275cd3-84d0-45fb-a104-4cc5c224f813%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/be5f1894-4618-42c0-9882-6e135e21c6a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


help me formset

2018-04-26 Thread Bob White
hello.

i have an issue.

i want to render formset as table then add row (form) using a modal. then
in table should show just data instead of input. as vb we can use a modal
to add row to table

have you ever done this before?

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


Re: Django - Angular 4 Serializer for inserting Parent and child Models using single JSON post

2018-04-26 Thread Serge Kalimunda
Hey dear, how to get out of the group conference? plz help

On Mon, Apr 9, 2018 at 3:22 PM, Nathan Sivathanu <
nathan.sivathanupil...@gmail.com> wrote:

> My requirement - I have two models TravelReq and TravelReqDetails as below
>
> class TravelReq(models.Model):
> empid= models.CharField(max_length=7)
> startdate= models.DateField()
> enddate= models.DateField()
> remarks= models.CharField(max_length=30)
> missionname= models.CharField(max_length=30)
> def __str__(self):
> return str(self.id)
> class TravelReqDetails(models.Model):
>  travelReqID = models.ForeignKey(TravelReq ,related_name  = 'req_details' 
> , on_delete=models.CASCADE );
>  travelDate= models.DateField()
>  lfrom = models.CharField(max_length=30)
>  to= models.CharField(max_length=30)
>  remarks = models.CharField(max_length=30)
> def __str__(self):
> return str(self.id)
>
> My serailizer
>
> from  .models import TravelReq ,TravelReqDetailsfrom rest_framework import 
> serializers
> class TravelReqSerializer(serializers.ModelSerializer):
> class Meta:
> model = TravelReq
> fields = ('empid' , 'startdate' ,   'enddate' , 'remarks' , 
> 'missionname' ,'req_details')code here
>
> My view
>
> from .models import TravelReq from rest_framework import viewsetsfrom 
> .serializers import TravelReqSerializer
>
> class TravelReqViewSet(viewsets.ModelViewSet):
> """
> API endpoint that allows users to be viewed or edited.
> """
> queryset = TravelReq.objects.all()
> serializer_class = TravelReqSerializer
>
> *From Angular I will be receiving below JSON as POST / PUT request . What
> is the best way to insert the master(TravelReq) and child records
> (TravelReqDetails) from a single serializer. please advice. If this is not
> the best approach ,please suggest a better / standard approach*
>
> [
> {
> "empid": "32432",
> "startdate": "2017-11-16",
> "enddate": "2018-03-17",
> "remarks": "asd",
> "missionname": "asd",
> "req_details": [
> {
> "id": 1,
> "travelDate": "2017-07-18",
> "lfrom": "indiaemarks",
> "to": "pakistan",
> "remarks": "r",
> "travelReqID": <>
> },
> {
> "id": 2,
> "travelDate": "2018-04-02",
> "lfrom": "pakistan",
> "to": "india",
> "remarks": "rerutn remarks",
> "travelReqID":  <>
> }
> ]
> },
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/816ab639-a82d-451a-9868-58ef057205b8%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/CADrCSzDnAJ65tVvLokAL3do8XEz6BSX94bXj6CTKLk%2BM2A5zfw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Do you know good guides to use ajax in django

2018-04-26 Thread CARLOS EDUARDO DAVALOS CORNEJO
thanks for you answer y wiil read the documentation


2018-04-26 4:42 GMT-07:00 Avraham Serour :

> I suggest taking a look at http://intercoolerjs.org
>
>
> On Thu, Apr 26, 2018 at 7:36 AM, 
> wrote:
>
>> Im starting a social network for my school and i need to show the coments
>> of my post without recharging the whole and for other things in my proyect
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "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/de939dae-605d-4cf1-9a7a-e5ee48f249ed%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/CAFWa6tJL4DykA-54hXLEuzi9q1Fz_
> XHzbX7b9BbrtfYRS9dUcQ%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/CABDbarq1sfYO-qr8k%2BL1uqo%3Dx1nGLqhpV%3Di1hrDhC%3DTXaH4uwQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Creating users represented by two models in OneToOne relation

2018-04-26 Thread quentin . agren
Hi,
This quesion is related to the common pattern 

 
of representing a siteuser (henceforth referred to as "member"), by two 
models that have aone-to-one relation:
1. A builtin `contrib.auth.models.User' model, used for authentication,  
 that holds credentials and basic information.
2. An application specific `Profile' model with additional personal  
 information, such as language for example. `Profile.user' is a  
 `OneToOneField' pointing to `auth.User'
My questions relate to the creation of such members, for which theresponsible 
view must populate and save two model instances with thesubmitted form data.
• What approaches would you recommend to implement the member creation  
form?• How could generic class-based views be efficiently leveraged to 
handle  member creation?
I briefly present my current solution below, with its limitations.
1. Form: a `ModelForm' associated to the `User' model, with extra fields  
 corresponding to the profile information.

class MemberForm(ModelForm):
# These fields map to those on the Profile model
# One for brevity here, but think of many more in practice
language = forms.CharField(
max_length=3,
widget=forms.Select(choices=Profile.LANGUAGES)
)


class Meta:
model = User
fields = ['first_name', 'last_name', 'email']

1. View: a `CreateView' subclass associated to the `User' model,  
 overriding the `form_valid()' method in which the `Profile' model is  
 populated by hand from the form's `cleaned_data' extra fields.

class MemberCreate(CreateView):
form_class = PanelMemberForm

def form_valid(self, form):
language = form.cleaned_data['language']
with transaction.atomic():
user = form.save()
Profile(user=user, language=language).save()
return HttpResponseRedirect(self.get_success_url())



The obvious limitation I see to this approach is that when fields areadded 
or modified on the `Profile' model, both the form and the viewmust be 
carfully updated. I suspect this will not be very easilymaintained code 
when the `Profile' model grows…
Thanks in advance for any insights you might share (and for having readthus 
far)
Quentin





-- 
You received this message because you are subscribed to the Google Groups 
"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/2fac50f2-6a23-4a1d-97a7-98ca388892ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.