Re: MULTIPLE IMAGES UPLOAD FOR A POST

2018-11-22 Thread mazz ahmed
https://django-filer.readthedocs.io/en/latest/

On Thu, Nov 22, 2018 at 12:49 PM Pacôme Avahouin 
wrote:

> Please help me. I am new to Django, cannot undertsand the following. I
> have subclass of CreateView for creating a post. I'm creating a rental site
> project where people can post their apart and attach files (images) to it.
> One should have possibility to attach as many images as he wants to ONE
> form. I have found in Internet a decision that I need to use 2 models - 1
> model for post + 1 separate model for images. Is it so?
>
> Post form is created and handled in my views.py by sublass of CreateView.
> Now how to connect new separate model for images with my CreateView ? And
> save all images to the current Post Form?
>
> Thanks in advance
>
> 
> models.py
>
> class Post(models.Model):
> post_author = models.ForeignKey(settings.AUTH_USER_MODEL,
> on_delete=models.CASCADE)
> post_title = models.CharField(_('Title'),max_length=200, null=True,
> blank=False)
> post_type = models.CharField(_('Type'),max_length=18,
> choices=post_type_list, default='appart')
> post_content = models.TextField(_('Your post description'),blank=True)
> post_created_date = models.DateTimeField(default=timezone.now,
> help_text=_('Post creation date and time.'),)
> post_published_date = models.DateTimeField(null=True, blank=True,
> help_text=_('Post publication date and time.'),)
>
> def get_absolute_url(self):
> return reverse("posts:post_details", kwargs={'pk':self.pk
> ,'post_type':self.post_type})
>
>
> class Post_Gallery(models.Model):
> post = models.ForeignKey(Post, on_delete=models.CASCADE)
> current_hour = datetime.datetime.now()
> images = models.ImageField(_('Upload some
> pictures'),upload_to='uploads/%Y/%m/%d/{}'.format(current_hour.hour),
> max_length=100, null=True, blank=True)
>
> def __unicode__(self):
> return self.images.url
>
> ..
> forms.py
>
> class NewPostForm(forms.ModelForm):
>
> class Meta:
> model = Post
>
> fields = [
> 'post_title','post_type','post_content',
> ]
>
> class GalleryForm(forms.ModelForm):
>
> class Meta:
> model = Post_Gallery
>
> fields = ['images',]
>
> def __init__(self, *args, **kwargs):
> super().__init__(*args, **kwargs)
> self.fields['images'].widget.attrs.update({'multiple': True,
> 'accept': 'image/jpg,image/jpeg,image/png,image/gif',} )
>
> .
> actual views.py
>
>
> class NewPostView(CreateView):
> form_class = NewPostForm
> template_name = 'posts/submit-post.html'
> model = Post
>
> @method_decorator(login_required)
> def dispatch(self, *args, **kwargs):
> return super().dispatch(*args, **kwargs)
>
> def form_valid(self, form):
> form.instance.post_author = self.request.user
> return super().form_valid(form)
>
> def get(self, request):
> form_class = self.get_form_class()
> form = self.get_form(form_class)
> return render(self.request, 'posts/submit-post.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/d72587c0-0c40-4bea-84f4-0e1b30900387%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/CABuXbh8CEN6PrMib%3DJ%2BkQ8d8K4P1sjrgBF%3D3TzS7VgpHbfrKPQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: please i need assistance with mine css file .Mine base.html file failed to load my style.css.

2018-11-22 Thread Mohan Goud
If u r using pycharm free version. It doesn't support css files. kindly
check that

On Wed, Nov 21, 2018 at 10:34 PM Yavin Aalto Arba 
wrote:

> It might help to create a link to the static file and then check the error
> upon reaching the url. I also recommend using the django debugging tool
> bar!
>
> Otherwise,  it could really help if u were to share the location of the
> file in the project as well as the static url and other static related
> settings from settings.py
>
> On Wed, Nov 21, 2018, 5:23 PM Babatunde Akinyanmi  wrote:
>
>> Hi.
>>
>> You haven't given us any useful information for assisting you. You will
>> get more replies if you say what you have done, show what your settings
>> look like, tell if your are using the development server, stuff like that.
>>
>> Welcome to the django community
>>
>> On Wed, 21 Nov 2018, 16:06 Obodoma Uzondu Vincent, 
>> wrote:
>>
>>> base.html file
>>>
>>> https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css";
>>> integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
>>> crossorigin="anonymous">
>>> https://code.jquery.com/jquery-3.3.1.slim.min.js";
>>> integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
>>> crossorigin="anonymous">
>>> https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js";
>>> integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
>>> crossorigin="anonymous">
>>> https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js";
>>> integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
>>> crossorigin="anonymous">
>>> {% load static %}
>>> 
>>> 
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "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/CACsKspnJ1iQMBnBn%2BKovaFBxzVFKA1GyEpKERFhcxvWSFTamEQ%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/CA%2BWjgXNy70-%2BquRPTLpAwnY9Rnc4Cm-n8NEuwMYLgDhzX%3D5%3DjA%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/CA%2B%2Be-ZWsNKgzYc8hcOCguT4vpnrmsbgnt7JwNdRG3f9PSQv1qA%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/CAB29Dkk1QEpd5B6qgDWd21idWuj4hg1pqBKf_3HeEKxPyz6aoA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: difference between class based view and function based view

2018-11-22 Thread Andréas Kühne
Great write up! :-)

And you are totally right - I tend to think of the CBV's and GCBV's in the
same thought - and use them interchangeably, because I NEVER use FV

Regards

Andréas


Den ons 21 nov. 2018 kl 21:39 skrev Andrew Pinkham :

> Django developers talk about three kinds of views:
>
> - function views (FV)
> - class-based views (CBV)
> - generic class-based views (GCBV)
>
> People do not make always make the difference between CBV and GCBV, which
> is unfortunate, as they serve different purposes (naming things is hard).
> When Andréas states earlier in this thread that "(CBV) use a lot of
> defaults for populating your templates, forms and views" that is not 100%
> precise. He means GCBV---which provide default (generic) behavior---not CBV.
>
> Let's break it down. Below is an example of a FV.
>
> from django.http import HttpResponse
> from django.views.decorators.http import (
> require_http_methods
> )
>
> # below is equivalent to require_safe decorator
> @require_http_methods(["GET", "HEAD"])
> def hello_world(request):
> """Demonstrate HTTP Request/Response"""
> return HttpResponse("Hello World")
>
> Below is an example of an equivalent CBV.
>
> from django.http import HttpResponse
> from django.views import View
>
>class HelloWorld(View):
>  """Demonstrate HTTP Request/Response"""
>
> def get(self, request):
> """Handle GET HTTP method"""
> return HttpResponse("Hello World")
>
> Formally, a CBV is any class that inherits from View. The only difference
> between the two views above is that the View class being inherited will
> give you automatic handling of HTTP OPTIONS.
>
> Stated otherwise: FV and CBV are *equivalent* with the exception of
> automatic OPTIONS handling in CBV.
>
> GCBV are simply CBV that have been given behavior. For example, instead of
> programming a view that shows a template with model data, you can instead
> inherit a DetailView, and customize it by setting class variables and by
> overriding methods. For more about that, I recommend looking at
> https://ccbv.co.uk .
>
> So, when should you use a FV, CBV, or GCBV?
>
> If you are building a view that a GCBV provides behavior for, save
> yourself time and use it! It's easy to add or slightly modify GCBV
> behavior, but difficult to remove behavior. The moment you're thinking
> about removing something a GCBV does, stick to a function or CBV.
>
> So then, for choosing between FV or CBV: Do you need to handle multiple
> HTTP methods? Is there shared behavior between how the resource is handled
> by those HTTP methods? If yes, a CBV can help organize that logic and avoid
> duplicate code.
>
> However, if you have a simple view (typically only one or two HTTP methods
> must be handled), then a FV will serve you fine (remember the view
> decorators!).
>
> If you're not sure, start with a FV, and then switch to a CBV or GCBV if
> appropriate (as complexity goes up or when you realize you can use a GCBV).
>
> Hope that helps,
> Andrew
> https://jambonsw.com
> https://django-unleashed.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/C2853144-5CA1-4FAD-ACDF-C487AE8CE47E%40andrewsforge.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/CAK4qSCdZFD0CuaJNxHbn%2BRtS8e2fD4-NxDAn%3D-31n9DgHCRaGQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


email

2018-11-22 Thread Tushar Nadkar
i have email id of multiple user , so how can i send mail after 3 days when
he click a button .or checkout button in 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/CAAHYEvMrV2x2TOwL1NmDrJAxpxVSFU%2BkiyeaWPdYhF09SfzPTg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: difference between class based view and function based view

2018-11-22 Thread Carsten Fuchs

Hi Andrew,

many thanks for your clear and detailed explanation!

Having used Django for several years, FVs are still my favorite approach 
over CBVs and GCBVs. In the past, I made several starts with CBVs, but 
never found or understood why CBVs and GCBVs seem to be in many people's 
center of attention.


FVs are not only the most simple of the three, but they also have the 
virtue of emphasizing the basic generic HTML web functionality and the 
way how forms work: The three logical paths that form processing can 
take are clearly shown in e.g. this (modified) example from 
https://django-book.readthedocs.io/en/latest/chapter07.html


def contact(request):
if request.method == 'POST':
form = ContactForm(request.POST)
if form.is_valid():
# success, now use form.cleaned_data
return HttpResponseRedirect('/contact/thanks/')
else:
form = ContactForm()

# We get here both for GET requests and POST requests
# with invalid forms.
return render(request, 'contact_form.html', {'form': form})

When I was new to Django (and in fact new to serious web development), 
understanding this concept, as step by step explained in the above 
mentioned chapter, was one of the key insights for me.


CBV and GCBV obscure this imho fundamental concept. Personally, I've 
never found the CBV's help with DRY outweigh the clarity of FVs. With 
all the attention and efforts that are spent on making getting started 
with Django easier for beginners, I was really surprised when even the 
official Django tutorials were changed from FVs to CBVs.


I write this email to thank you for your explanation, but also to add 
the above thoughts, which I have long been pondering but never found a 
place to write down.  ;-)


Best regards,
Carsten


Am 21.11.18 um 21:39 schrieb Andrew Pinkham:

Django developers talk about three kinds of views:

- function views (FV)
- class-based views (CBV)
- generic class-based views (GCBV)

People do not make always make the difference between CBV and GCBV, which is unfortunate, 
as they serve different purposes (naming things is hard). When Andréas states earlier in 
this thread that "(CBV) use a lot of defaults for populating your templates, forms 
and views" that is not 100% precise. He means GCBV---which provide default (generic) 
behavior---not CBV.

Let's break it down. Below is an example of a FV.

 from django.http import HttpResponse
 from django.views.decorators.http import (
 require_http_methods
 )

 # below is equivalent to require_safe decorator
 @require_http_methods(["GET", "HEAD"])
 def hello_world(request):
 """Demonstrate HTTP Request/Response"""
 return HttpResponse("Hello World")

Below is an example of an equivalent CBV.
  
 from django.http import HttpResponse

 from django.views import View
  
class HelloWorld(View):

  """Demonstrate HTTP Request/Response"""

 def get(self, request):
 """Handle GET HTTP method"""
 return HttpResponse("Hello World")

Formally, a CBV is any class that inherits from View. The only difference 
between the two views above is that the View class being inherited will give 
you automatic handling of HTTP OPTIONS.

Stated otherwise: FV and CBV are *equivalent* with the exception of automatic 
OPTIONS handling in CBV.

GCBV are simply CBV that have been given behavior. For example, instead of 
programming a view that shows a template with model data, you can instead 
inherit a DetailView, and customize it by setting class variables and by 
overriding methods. For more about that, I recommend looking at 
https://ccbv.co.uk .

So, when should you use a FV, CBV, or GCBV?

If you are building a view that a GCBV provides behavior for, save yourself 
time and use it! It's easy to add or slightly modify GCBV behavior, but 
difficult to remove behavior. The moment you're thinking about removing 
something a GCBV does, stick to a function or CBV.

So then, for choosing between FV or CBV: Do you need to handle multiple HTTP 
methods? Is there shared behavior between how the resource is handled by those 
HTTP methods? If yes, a CBV can help organize that logic and avoid duplicate 
code.

However, if you have a simple view (typically only one or two HTTP methods must 
be handled), then a FV will serve you fine (remember the view decorators!).

If you're not sure, start with a FV, and then switch to a CBV or GCBV if 
appropriate (as complexity goes up or when you realize you can use a GCBV).

Hope that helps,
Andrew
https://jambonsw.com
https://django-unleashed.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://gro

Re: MULTIPLE IMAGES UPLOAD FOR A POST

2018-11-22 Thread Pacôme Avahouin
Thank you mazz ahmed for your answer, but i still don't see how to use that 
with my forms.py and views.py?

Le jeudi 22 novembre 2018 10:49:02 UTC+3, Pacôme Avahouin a écrit :
>
> Please help me. I am new to Django, cannot undertsand the following. I 
> have subclass of CreateView for creating a post. I'm creating a rental site 
> project where people can post their apart and attach files (images) to it. 
> One should have possibility to attach as many images as he wants to ONE 
> form. I have found in Internet a decision that I need to use 2 models - 1 
> model for post + 1 separate model for images. Is it so?
>
> Post form is created and handled in my views.py by sublass of CreateView. 
> Now how to connect new separate model for images with my CreateView ? And 
> save all images to the current Post Form?
>
> Thanks in advance
>
> 
> models.py
>
> class Post(models.Model):
> post_author = models.ForeignKey(settings.AUTH_USER_MODEL, 
> on_delete=models.CASCADE)
> post_title = models.CharField(_('Title'),max_length=200, null=True, 
> blank=False)
> post_type = models.CharField(_('Type'),max_length=18, 
> choices=post_type_list, default='appart')
> post_content = models.TextField(_('Your post description'),blank=True)
> post_created_date = models.DateTimeField(default=timezone.now, 
> help_text=_('Post creation date and time.'),)
> post_published_date = models.DateTimeField(null=True, blank=True, 
> help_text=_('Post publication date and time.'),)
> 
> def get_absolute_url(self):
> return reverse("posts:post_details", kwargs={'pk':self.pk
> ,'post_type':self.post_type})
>
>
> class Post_Gallery(models.Model):
> post = models.ForeignKey(Post, on_delete=models.CASCADE)
> current_hour = datetime.datetime.now()
> images = models.ImageField(_('Upload some 
> pictures'),upload_to='uploads/%Y/%m/%d/{}'.format(current_hour.hour), 
> max_length=100, null=True, blank=True)
>
> def __unicode__(self):
> return self.images.url
>
> ..
> forms.py
>
> class NewPostForm(forms.ModelForm):
>
> class Meta:
> model = Post
>
> fields = [
> 'post_title','post_type','post_content',
> ]
>
> class GalleryForm(forms.ModelForm):
>
> class Meta:
> model = Post_Gallery
>
> fields = ['images',]
>
> def __init__(self, *args, **kwargs):
> super().__init__(*args, **kwargs)
> self.fields['images'].widget.attrs.update({'multiple': True, 
> 'accept': 'image/jpg,image/jpeg,image/png,image/gif',} )
>
> .
> actual views.py
>
>
> class NewPostView(CreateView):
> form_class = NewPostForm
> template_name = 'posts/submit-post.html'
> model = Post
>
> @method_decorator(login_required)
> def dispatch(self, *args, **kwargs):
> return super().dispatch(*args, **kwargs)
>
> def form_valid(self, form):
> form.instance.post_author = self.request.user
> return super().form_valid(form)
>
> def get(self, request):
> form_class = self.get_form_class()
> form = self.get_form(form_class)
> return render(self.request, 'posts/submit-post.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/3c82ddd5-9f92-4f10-804a-6d337618899f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: difference between class based view and function based view

2018-11-22 Thread Yavin Aalto Arba
I have to +1 Carstens answer.

 In short, I too find CB views to be too "magical".

=)

On Thu, 22 Nov 2018 at 11:53, Carsten Fuchs  wrote:

> Hi Andrew,
>
> many thanks for your clear and detailed explanation!
>
> Having used Django for several years, FVs are still my favorite approach
> over CBVs and GCBVs. In the past, I made several starts with CBVs, but
> never found or understood why CBVs and GCBVs seem to be in many people's
> center of attention.
>
> FVs are not only the most simple of the three, but they also have the
> virtue of emphasizing the basic generic HTML web functionality and the
> way how forms work: The three logical paths that form processing can
> take are clearly shown in e.g. this (modified) example from
> https://django-book.readthedocs.io/en/latest/chapter07.html
>
> def contact(request):
>  if request.method == 'POST':
>  form = ContactForm(request.POST)
>  if form.is_valid():
>  # success, now use form.cleaned_data
>  return HttpResponseRedirect('/contact/thanks/')
>  else:
>  form = ContactForm()
>
>  # We get here both for GET requests and POST requests
>  # with invalid forms.
>  return render(request, 'contact_form.html', {'form': form})
>
> When I was new to Django (and in fact new to serious web development),
> understanding this concept, as step by step explained in the above
> mentioned chapter, was one of the key insights for me.
>
> CBV and GCBV obscure this imho fundamental concept. Personally, I've
> never found the CBV's help with DRY outweigh the clarity of FVs. With
> all the attention and efforts that are spent on making getting started
> with Django easier for beginners, I was really surprised when even the
> official Django tutorials were changed from FVs to CBVs.
>
> I write this email to thank you for your explanation, but also to add
> the above thoughts, which I have long been pondering but never found a
> place to write down.  ;-)
>
> Best regards,
> Carsten
>
>
> Am 21.11.18 um 21:39 schrieb Andrew Pinkham:
> > Django developers talk about three kinds of views:
> >
> >   - function views (FV)
> >   - class-based views (CBV)
> >   - generic class-based views (GCBV)
> >
> > People do not make always make the difference between CBV and GCBV,
> which is unfortunate, as they serve different purposes (naming things is
> hard). When Andréas states earlier in this thread that "(CBV) use a lot of
> defaults for populating your templates, forms and views" that is not 100%
> precise. He means GCBV---which provide default (generic) behavior---not CBV.
> >
> > Let's break it down. Below is an example of a FV.
> >
> >  from django.http import HttpResponse
> >  from django.views.decorators.http import (
> >  require_http_methods
> >  )
> >
> >  # below is equivalent to require_safe decorator
> >  @require_http_methods(["GET", "HEAD"])
> >  def hello_world(request):
> >  """Demonstrate HTTP Request/Response"""
> >  return HttpResponse("Hello World")
> >
> > Below is an example of an equivalent CBV.
> >
> >  from django.http import HttpResponse
> >  from django.views import View
> >
> > class HelloWorld(View):
> >   """Demonstrate HTTP Request/Response"""
> >
> >  def get(self, request):
> >  """Handle GET HTTP method"""
> >  return HttpResponse("Hello World")
> >
> > Formally, a CBV is any class that inherits from View. The only
> difference between the two views above is that the View class being
> inherited will give you automatic handling of HTTP OPTIONS.
> >
> > Stated otherwise: FV and CBV are *equivalent* with the exception of
> automatic OPTIONS handling in CBV.
> >
> > GCBV are simply CBV that have been given behavior. For example, instead
> of programming a view that shows a template with model data, you can
> instead inherit a DetailView, and customize it by setting class variables
> and by overriding methods. For more about that, I recommend looking at
> https://ccbv.co.uk .
> >
> > So, when should you use a FV, CBV, or GCBV?
> >
> > If you are building a view that a GCBV provides behavior for, save
> yourself time and use it! It's easy to add or slightly modify GCBV
> behavior, but difficult to remove behavior. The moment you're thinking
> about removing something a GCBV does, stick to a function or CBV.
> >
> > So then, for choosing between FV or CBV: Do you need to handle multiple
> HTTP methods? Is there shared behavior between how the resource is handled
> by those HTTP methods? If yes, a CBV can help organize that logic and avoid
> duplicate code.
> >
> > However, if you have a simple view (typically only one or two HTTP
> methods must be handled), then a FV will serve you fine (remember the view
> decorators!).
> >
> > If you're not sure, start with a FV, and then switch to a CBV or GCBV if
> appropriate (as complexity goes up or when you realize you can use a GCBV).
> >
> > 

Re: difference between class based view and function based view

2018-11-22 Thread Jason
Interesting, because I'm the entire opposite because I find myself 
rewriting lots of code when using FBVs compared to (G)CBVs.  And then if 
one thing changes, that often precipitates a much larger PR than if I were 
using equivalent classes.  There's no magic involved in them, just regular 
object oriented inheritance at play.  That said, sites like Classy CBV 
 help a great deal in understanding the background of 
what exactly goes in CBVs.


-- 
You received this message because you are subscribed to the Google Groups 
"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/ca59ee9c-d5bd-4149-9ab5-add5252ab63e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Working with kronos

2018-11-22 Thread Jason
https://github.com/jgorset/django-kronos/tree/v1.0#register-tasks-with-cron

sounds like you need to run a register management command first.

-- 
You received this message because you are subscribed to the Google Groups 
"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/bc4a5948-8e8d-45c8-8a7c-522e482680bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: email

2018-11-22 Thread Yavin Aalto Arba
https://docs.python.org/3/library/sched.html ?

On Thu, 22 Nov 2018 at 11:29, Tushar Nadkar 
wrote:

> i have email id of multiple user , so how can i send mail after 3 days
> when he click a button .or checkout button in 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/CAAHYEvMrV2x2TOwL1NmDrJAxpxVSFU%2BkiyeaWPdYhF09SfzPTg%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/CA%2B%2Be-ZXVnHnatnY%3DhKvHLLkwY9oJZXTBxxhBSD9QXiC%2BZE%2Bqmg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using Django Channels to subscribe to a Redis channel

2018-11-22 Thread Nasir Shadravan
Thanks Yyavin, the problem is that in my management command I don't have
access to `self` to send it. Is it possible to get access to a consumer
from outside or how should my data producer relay the messages to channel
in an async way?

On Wed, Nov 21, 2018 at 8:46 PM Yavin Aalto Arba 
wrote:

> try with  self.channel_layer.group_send ?
>
> On Wed, 21 Nov 2018 at 19:44, Nasir Sh  wrote:
>
>> Thanks Andrew this helps me as well. There is a missing piece I don't
>> understand yet. In my management command, then I probably will have to use 
>> `async_to_sync(channel_layer.group_send)`
>> to send the message to consumers (right?). The only problem is that
>> whenever I use async_to_sync it creates a new connection to redis every
>> single time. I now use channels_redis v2.3.1 and in this version I don't
>> get excessive connections but still it opens a new connection on every
>> send. I was wondering if that is intentional or not in a sync context and
>> if so, how can it be solved.
>>
>> Thanks again for your great work
>>
>> On Wednesday, February 22, 2017 at 7:55:33 PM UTC+1, Andrew Godwin wrote:
>>>
>>> Hi Jochen,
>>>
>>> Your problem is that if you want to listen to the pubsub channel you
>>> will need a dedicated process to do so, as you can't just poll something
>>> like that. Given that restriction, you're going to have to write something
>>> like a management command that opens a connection to Redis and listens for
>>> messages, and then whenever it gets one, sends the message onto a channel
>>> in the Django channel system.
>>>
>>> You can send to channels from anywhere, so it's just a basic listener
>>> with one line of channel send added. You're likely to want some sort of
>>> logic on these messages, I suspect, so I would send onto a single custom
>>> channel and then, now your messages are in the evented channel system, you
>>> can then write a consumer for that channel and tie it into the routing and
>>> handle any distribution/storage there.
>>>
>>> This keeps the body of your logic inside the Django consumer code, and
>>> the management command nice and simple - it just needs to send onto a
>>> custom channel and not worry about what to do with that data, you can hook
>>> that up later. If you have fields in the message you split out into
>>> different dictionary keys, you can even use the Channels routing options on
>>> those fields - so, for example, you could route everything with a certain
>>> task name to one consumer, and everything else to a catch-all consumer.
>>>
>>> Andrew
>>>
>>> On Wed, Feb 22, 2017 at 6:55 AM, Jochen Breuer  wrote:
>>>
 Hi!

 I'm not entirely sure where to start and I hope you can help me. I'm
 using SaltStack to execute tasks on minions. The results of those jobs
 (that's the term used in Salt) are then published to a job cache. In this
 case its a Redis server (Redis Pubsub). Now I would like to subscribe to a
 specific Redis channel, where the job results are published, with my Django
 (Channels) application. Every time a job result is pushed, I'd also like to
 push a message to a channel in Django.

 Where to begin? Do I need to write a new protocol server or just a
 custom channel? Even after reading the docs I'm still lacking overview.
 Perhaps someone can push me into the right direction. Thanks!

 Jochen

 --
 You received this message because you are subscribed 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/c933a5b5-7b72-4d7d-985a-a311c0f16b26%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/800a3278-ba4b-402d-b8ee-341b999879ba%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 un

Re: Using Django Channels to subscribe to a Redis channel

2018-11-22 Thread Nasir Sh
Thanks Yyavin, the problem is that in my management command I don't have 
access to `self` to send it. Is it possible to get access to a consumer 
from outside or how should my data producer relay the messages to channel 
in an async way?

On Wednesday, November 21, 2018 at 8:47:07 PM UTC+1, Yavin Aalto Arba wrote:
>
> try with  self.channel_layer.group_send ?
>
> On Wed, 21 Nov 2018 at 19:44, Nasir Sh > 
> wrote:
>
>> Thanks Andrew this helps me as well. There is a missing piece I don't 
>> understand yet. In my management command, then I probably will have to use 
>> `async_to_sync(channel_layer.group_send)` 
>> to send the message to consumers (right?). The only problem is that 
>> whenever I use async_to_sync it creates a new connection to redis every 
>> single time. I now use channels_redis v2.3.1 and in this version I don't 
>> get excessive connections but still it opens a new connection on every 
>> send. I was wondering if that is intentional or not in a sync context and 
>> if so, how can it be solved.
>>
>> Thanks again for your great work
>>
>> On Wednesday, February 22, 2017 at 7:55:33 PM UTC+1, Andrew Godwin wrote:
>>>
>>> Hi Jochen,
>>>
>>> Your problem is that if you want to listen to the pubsub channel you 
>>> will need a dedicated process to do so, as you can't just poll something 
>>> like that. Given that restriction, you're going to have to write something 
>>> like a management command that opens a connection to Redis and listens for 
>>> messages, and then whenever it gets one, sends the message onto a channel 
>>> in the Django channel system.
>>>
>>> You can send to channels from anywhere, so it's just a basic listener 
>>> with one line of channel send added. You're likely to want some sort of 
>>> logic on these messages, I suspect, so I would send onto a single custom 
>>> channel and then, now your messages are in the evented channel system, you 
>>> can then write a consumer for that channel and tie it into the routing and 
>>> handle any distribution/storage there.
>>>
>>> This keeps the body of your logic inside the Django consumer code, and 
>>> the management command nice and simple - it just needs to send onto a 
>>> custom channel and not worry about what to do with that data, you can hook 
>>> that up later. If you have fields in the message you split out into 
>>> different dictionary keys, you can even use the Channels routing options on 
>>> those fields - so, for example, you could route everything with a certain 
>>> task name to one consumer, and everything else to a catch-all consumer.
>>>
>>> Andrew
>>>
>>> On Wed, Feb 22, 2017 at 6:55 AM, Jochen Breuer  wrote:
>>>
 Hi!

 I'm not entirely sure where to start and I hope you can help me. I'm 
 using SaltStack to execute tasks on minions. The results of those jobs 
 (that's the term used in Salt) are then published to a job cache. In this 
 case its a Redis server (Redis Pubsub). Now I would like to subscribe to a 
 specific Redis channel, where the job results are published, with my 
 Django 
 (Channels) application. Every time a job result is pushed, I'd also like 
 to 
 push a message to a channel in Django.

 Where to begin? Do I need to write a new protocol server or just a 
 custom channel? Even after reading the docs I'm still lacking overview. 
 Perhaps someone can push me into the right direction. Thanks!

 Jochen

 -- 
 You received this message because you are subscribed 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/c933a5b5-7b72-4d7d-985a-a311c0f16b26%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/800a3278-ba4b-402d-b8ee-341b999879ba%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this me

Re: mail sending

2018-11-22 Thread Hari
Please check below link.It may help you..Basically you need to set up
celery.

https://stackoverflow.com/questions/9982486/django-sending-email-x-days-later

On Thu, Nov 22, 2018, 12:23 PM Tushar Nadkar 
wrote:

> when a button is clicked , i want to send specific mail after 3 days ? how
> can i do that in 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/CAAHYEvMUPoT%2BivTkPx%2BekvksnVWo%3DiByAt48iQX8m-HjTSQMTw%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/CAMqzjWBkvXi5-RM%3DqNQCF8bBYmUOTJgo0BMaLEkUBwqwa6Gzvw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using Django Channels to subscribe to a Redis channel

2018-11-22 Thread Yavin Aalto Arba
You need to set up the consumer to perform this task.

cf. https://github.com/justdjango/justchat/blob/master/src/chat/consumers.py

this corresponds to the following video tutorial which might be useful to
you:
https://www.youtube.com/watch?v=Wv5jlmJs2sU

On Thu, 22 Nov 2018 at 15:34, Nasir Sh  wrote:

> Thanks Yyavin, the problem is that in my management command I don't have
> access to `self` to send it. Is it possible to get access to a consumer
> from outside or how should my data producer relay the messages to channel
> in an async way?
>
> On Wednesday, November 21, 2018 at 8:47:07 PM UTC+1, Yavin Aalto Arba
> wrote:
>>
>> try with  self.channel_layer.group_send ?
>>
>> On Wed, 21 Nov 2018 at 19:44, Nasir Sh  wrote:
>>
>>> Thanks Andrew this helps me as well. There is a missing piece I don't
>>> understand yet. In my management command, then I probably will have to use 
>>> `async_to_sync(channel_layer.group_send)`
>>> to send the message to consumers (right?). The only problem is that
>>> whenever I use async_to_sync it creates a new connection to redis every
>>> single time. I now use channels_redis v2.3.1 and in this version I don't
>>> get excessive connections but still it opens a new connection on every
>>> send. I was wondering if that is intentional or not in a sync context and
>>> if so, how can it be solved.
>>>
>>> Thanks again for your great work
>>>
>>> On Wednesday, February 22, 2017 at 7:55:33 PM UTC+1, Andrew Godwin wrote:

 Hi Jochen,

 Your problem is that if you want to listen to the pubsub channel you
 will need a dedicated process to do so, as you can't just poll something
 like that. Given that restriction, you're going to have to write something
 like a management command that opens a connection to Redis and listens for
 messages, and then whenever it gets one, sends the message onto a channel
 in the Django channel system.

 You can send to channels from anywhere, so it's just a basic listener
 with one line of channel send added. You're likely to want some sort of
 logic on these messages, I suspect, so I would send onto a single custom
 channel and then, now your messages are in the evented channel system, you
 can then write a consumer for that channel and tie it into the routing and
 handle any distribution/storage there.

 This keeps the body of your logic inside the Django consumer code, and
 the management command nice and simple - it just needs to send onto a
 custom channel and not worry about what to do with that data, you can hook
 that up later. If you have fields in the message you split out into
 different dictionary keys, you can even use the Channels routing options on
 those fields - so, for example, you could route everything with a certain
 task name to one consumer, and everything else to a catch-all consumer.

 Andrew

 On Wed, Feb 22, 2017 at 6:55 AM, Jochen Breuer 
 wrote:

> Hi!
>
> I'm not entirely sure where to start and I hope you can help me. I'm
> using SaltStack to execute tasks on minions. The results of those jobs
> (that's the term used in Salt) are then published to a job cache. In this
> case its a Redis server (Redis Pubsub). Now I would like to subscribe to a
> specific Redis channel, where the job results are published, with my 
> Django
> (Channels) application. Every time a job result is pushed, I'd also like 
> to
> push a message to a channel in Django.
>
> Where to begin? Do I need to write a new protocol server or just a
> custom channel? Even after reading the docs I'm still lacking overview.
> Perhaps someone can push me into the right direction. Thanks!
>
> Jochen
>
> --
> You received this message because you are subscribed 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/c933a5b5-7b72-4d7d-985a-a311c0f16b26%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
>

Re: Working with kronos

2018-11-22 Thread Joel Mathew
I understood the documentation to mean that either we can create management
commands and register with cronos, or create cron.py.
Sincerely yours,

 Joel G Mathew



On Thu, 22 Nov 2018 at 18:42, Jason  wrote:

> https://github.com/jgorset/django-kronos/tree/v1.0#register-tasks-with-cron
>
> sounds like you need to run a register management command first.
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/bc4a5948-8e8d-45c8-8a7c-522e482680bc%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/CAA%3Diw_9XHEiRgkzG_16jz-CXB%2BE5fQ_PjYOMn6F1evbDEGEXaQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


how to send data from form site page

2018-11-22 Thread Gear Crew
how to send data from form site page that has html form to model without 
using form model because I want to use HTML elements instead of elements in 
form model

-- 
You received this message because you are subscribed to the Google Groups 
"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/3d21f7db-8fa4-416b-b5ca-f0f111425100%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: mail sending

2018-11-22 Thread Jani Tiainen
Hi.

Essentially you need to record the time you want your mail to be sent and
then you need some kind of background worker to check (periodically) if
there are any mails to be sent.

Celery is one tool that can do that.

I personally use simple cron job that uses django management command to
achieve same stuff (sending emails asynchronously).

Tushar Nadkar  kirjoitti to 22. marrask. 2018
klo 8.53:

> when a button is clicked , i want to send specific mail after 3 days ? how
> can i do that in 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/CAAHYEvMUPoT%2BivTkPx%2BekvksnVWo%3DiByAt48iQX8m-HjTSQMTw%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/CAHn91ocf3eFL7QMiXj0Mspg4zDCovE0VGaJ8-onEaRdsq02TXA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to send data from form site page

2018-11-22 Thread Jani Tiainen
Hi.

I've really hard time to understand what you want to achieve. Could you
please give an example what you're after?

Gear Crew  kirjoitti to 22. marrask. 2018
klo 16.48:

> how to send data from form site page that has html form to model without
> using form model because I want to use HTML elements instead of elements in
> form model
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/3d21f7db-8fa4-416b-b5ca-f0f111425100%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/CAHn91od6RXu_Tq9Q2VCZwnzCxRKvB%2B_b%3DFPdPEDURmJpyi%3DOVA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to send data from form site page

2018-11-22 Thread Gear Crew
I want to edit style for form model like changing in default HTML tags 

On Thursday, 22 November 2018 16:53:54 UTC+2, Jani Tiainen wrote:
>
> Hi.
>
> I've really hard time to understand what you want to achieve. Could you 
> please give an example what you're after?
>
> Gear Crew > kirjoitti to 22. 
> marrask. 2018 klo 16.48:
>
>> how to send data from form site page that has html form to model without 
>> using form model because I want to use HTML elements instead of elements in 
>> form model
>>
>> -- 
>> You received this message because you are subscribed 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/3d21f7db-8fa4-416b-b5ca-f0f111425100%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/44e60fc3-3f20-46cc-a400-0385c3c1b038%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


unable to create modelform object in views

2018-11-22 Thread shiva kumar
views file

from django.core.mail import send_mail
from django.http import HttpResponse
# Create your views here.
from django.shortcuts import render,redirect
from django.urls import include
import datetime
from .forms import loginform,modelform
def hidemelogin(request):
if request.method == 'POST':
form=loginform(request.POST)
if form.is_valid():
subject = form.cleaned_data['your_name']
message = form.cleaned_data['message']
sender = form.cleaned_data['sender']
cc_myself = form.cleaned_data['cc_myself']
recipients = ['rk3545...@gmail.com']
if cc_myself:
recipients.append(sender)
print(subject, message,sender, cc_myself,recipients)
print(type(form))
return redirect('/hideme/blog/')
else :
form=loginform()
form1=modelform()
return render(request,'login.html',{'form':form,'form1':form1})
def hidemehtml(request):
print("shiva")
return render(request,'index.html',{})


model file

from django.db import models
class BlogPost(models.Model):
id=models.AutoField(primary_key=True)
yourname=models.CharField(max_length=20)
content=models.TextField(null=True,blank=True)
ccself=models.BooleanField(default=True)
sender=models.EmailField(blank=False)
def __str__(self):
return self.yourname
# Create your models here.


form file

from django import forms
from .models import BlogPost
class loginform(forms.Form):
your_name=forms.CharField(label='enter your name', max_length=100)
message = forms.CharField(widget=forms.Textarea)
sender = forms.EmailField()
cc_myself = forms.BooleanField(required=False)

class modelform(forms.ModelForm):
class meta:
model = BlogPost
fields=[
"id","name","message","sender","carbon copy"
]

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


Re: unable to create modelform object in views

2018-11-22 Thread Thiago Oliveira
what was the except is generator ?

Em qui, 22 de nov de 2018 às 13:38, shiva kumar <
kannamshivakumar...@gmail.com> escreveu:

> views file
>
> from django.core.mail import send_mail
> from django.http import HttpResponse
> # Create your views here.
> from django.shortcuts import render,redirect
> from django.urls import include
> import datetime
> from .forms import loginform,modelform
> def hidemelogin(request):
> if request.method == 'POST':
> form=loginform(request.POST)
> if form.is_valid():
> subject = form.cleaned_data['your_name']
> message = form.cleaned_data['message']
> sender = form.cleaned_data['sender']
> cc_myself = form.cleaned_data['cc_myself']
> recipients = ['rk3545...@gmail.com']
> if cc_myself:
> recipients.append(sender)
> print(subject, message,sender, cc_myself,recipients)
> print(type(form))
> return redirect('/hideme/blog/')
> else :
> form=loginform()
> form1=modelform()
> return render(request,'login.html',{'form':form,'form1':form1})
> def hidemehtml(request):
> print("shiva")
> return render(request,'index.html',{})
>
>
> model file
>
> from django.db import models
> class BlogPost(models.Model):
> id=models.AutoField(primary_key=True)
> yourname=models.CharField(max_length=20)
> content=models.TextField(null=True,blank=True)
> ccself=models.BooleanField(default=True)
> sender=models.EmailField(blank=False)
> def __str__(self):
> return self.yourname
> # Create your models here.
>
>
> form file
>
> from django import forms
> from .models import BlogPost
> class loginform(forms.Form):
> your_name=forms.CharField(label='enter your name', max_length=100)
> message = forms.CharField(widget=forms.Textarea)
> sender = forms.EmailField()
> cc_myself = forms.BooleanField(required=False)
>
> class modelform(forms.ModelForm):
> class meta:
> model = BlogPost
> fields=[
> "id","name","message","sender","carbon copy"
> ]
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/CAMsYeuEwMsSZH6R27idvNm5yrokMo8qkQ1xOd19BpdwXW3%2BM%2Bw%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/CAGXgVz5naFivvBfAbYo15E1gFWhJ8VRXEoAO_3comZHUGkBMcA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to send data from form site page

2018-11-22 Thread Thiago Oliveira
I don't know if i understand,

but if you make html html  and put tag name with same name that form
field...  you can get the information

like  from = MyForm(request.POST)

because, the tag name always  send to back-end with the value of field



Em qui, 22 de nov de 2018 às 13:19, Gear Crew 
escreveu:

> I want to edit style for form model like changing in default HTML tags
>
> On Thursday, 22 November 2018 16:53:54 UTC+2, Jani Tiainen wrote:
>>
>> Hi.
>>
>> I've really hard time to understand what you want to achieve. Could you
>> please give an example what you're after?
>>
>> Gear Crew  kirjoitti to 22. marrask. 2018 klo
>> 16.48:
>>
>>> how to send data from form site page that has html form to model without
>>> using form model because I want to use HTML elements instead of elements in
>>> form model
>>>
>>> --
>>> You received this message because you are subscribed 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/3d21f7db-8fa4-416b-b5ca-f0f111425100%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/44e60fc3-3f20-46cc-a400-0385c3c1b038%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/CAGXgVz494PBDcDCPRTqDpvmzF%2Bvb0MvnqSoGgwmGoJXHbD4_vg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Is Django and DjangoRestAPI's the correct framework for my project?

2018-11-22 Thread Andy Gardner
I am new to Django, Python and Rest API's and have been learning it over 
the last few weeks with a view to generating REST API's to control an 
engine process.

Currently I have an engine process running in the background, and a python 
based test harness, which takes JSON encoded requests containing the 
command and the data parameters. I currently use a simple command line to 
write the JSON encoded requests and I get back JSON encoded replies, eg. I 
send a login request to the backend process and I get a session id back 
from it, which then has to be passed in subsequent engine requests.

I have worked my way through William S Vincent's books for a beginner's 
guide to Django and the follow-up Rest API's and I can see how quick and 
useful the Django framework is for mocking up web pages and all the work 
behind it to display, but it seems that all the examples are database based 
and displaying of the contents all self-contained, which is not what I want 
to do.

I want to be able to create an API that sends requests to my test harness 
(eventually this will be replaced with a proper middleware process but 
doing the same sort of thing) and handles the replies. I was thinking along 
the lines of creating an app per CLI call (ie. command request to test 
harness), so I do not see any need for an underlying database or storage of 
data as the API will eventually be used by an existing GUI that I will be 
supplying the API's to. Neither can I really use the Django login framework 
and authentication as I need to interact with the login mechanism with the 
backend process ie the backend process needs to hold information on any 
requests to create users and when those users login supply session id - the 
backend process needs to work for many users in parallel).

So my question is, is Django the right framework for what I want to do, or 
should I be looking at a different framework, can I write Rest API's that 
send JSON encoded command and parameter data requests and get back JSON 
encoded responses from my engine process? If the answer to the last 
question is yes, can someone give me an example on how I write that using 
Django ie. do I not bother with a model, but just serialize a set of fields 
to represent the command and the data parameters for that request the app 
represents? Instead of using framework .as_view() functions etc do I write 
my own messaging function or does the framework actually have something 
already to do this kind of thing?

Thanks in advance for answers/suggestions etc?

Andy

-- 





CONFIDENTIALITY NOTICE: This e-mail transmission and/or any 
attachments may contain confidential information belonging to the sender. 
Any unauthorised interception of this transmission is illegal under the 
law. If you have received this transmission in error, please promptly 
notify the sender by reply e-mail, and then destroy all copies of the 
transmission.

-- 
You received this message because you are subscribed to the Google Groups 
"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/14cea50a-dd1c-4746-9547-7a71a2e146e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to send data from form site page

2018-11-22 Thread Jani Tiainen
Hi,

If I understood correctly you want to render form with plain HTML. That is
completely possible and it's not even hard.

You just can do  and it will work

Only important thing is to match "some_field_name" with field name in the
django form. You still should Django form in a view to do very important
thing that it's actually meant for - to validate and coerce user input in
correct form. Also you might want to render field and form errors (forms do
provide simple accessors for them) from the form itself. As well as
initial/current values so you don't show empty form everytime for user for
example when your form fails to validate.





On Thu, Nov 22, 2018 at 5:19 PM Gear Crew 
wrote:

> I want to edit style for form model like changing in default HTML tags
>
> On Thursday, 22 November 2018 16:53:54 UTC+2, Jani Tiainen wrote:
>>
>> Hi.
>>
>> I've really hard time to understand what you want to achieve. Could you
>> please give an example what you're after?
>>
>> Gear Crew  kirjoitti to 22. marrask. 2018 klo
>> 16.48:
>>
>>> how to send data from form site page that has html form to model without
>>> using form model because I want to use HTML elements instead of elements in
>>> form model
>>>
>>> --
>>> You received this message because you are subscribed 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/3d21f7db-8fa4-416b-b5ca-f0f111425100%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/44e60fc3-3f20-46cc-a400-0385c3c1b038%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient 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/CAHn91od5GwOhSDeEMQvV-WJq41drw-DBDnrvViFnbV7vHVLtNQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is Django and DjangoRestAPI's the correct framework for my project?

2018-11-22 Thread TimT Vogt
What problem are you trying to solve?
What reason do You use djanfo now for?

And what do You want with the json?
Stored? Displayed? Or put trough as other apps might use the data?
Tim


Verstuurd vanaf mijn iPhone

> Op 22 nov. 2018 om 16:40 heeft Andy Gardner  het 
> volgende geschreven:
> 
> I am new to Django, Python and Rest API's and have been learning it over the 
> last few weeks with a view to generating REST API's to control an engine 
> process.
> 
> Currently I have an engine process running in the background, and a python 
> based test harness, which takes JSON encoded requests containing the command 
> and the data parameters. I currently use a simple command line to write the 
> JSON encoded requests and I get back JSON encoded replies, eg. I send a login 
> request to the backend process and I get a session id back from it, which 
> then has to be passed in subsequent engine requests.
> 
> I have worked my way through William S Vincent's books for a beginner's guide 
> to Django and the follow-up Rest API's and I can see how quick and useful the 
> Django framework is for mocking up web pages and all the work behind it to 
> display, but it seems that all the examples are database based and displaying 
> of the contents all self-contained, which is not what I want to do.
> 
> I want to be able to create an API that sends requests to my test harness 
> (eventually this will be replaced with a proper middleware process but doing 
> the same sort of thing) and handles the replies. I was thinking along the 
> lines of creating an app per CLI call (ie. command request to test harness), 
> so I do not see any need for an underlying database or storage of data as the 
> API will eventually be used by an existing GUI that I will be supplying the 
> API's to. Neither can I really use the Django login framework and 
> authentication as I need to interact with the login mechanism with the 
> backend process ie the backend process needs to hold information on any 
> requests to create users and when those users login supply session id - the 
> backend process needs to work for many users in parallel).
> 
> So my question is, is Django the right framework for what I want to do, or 
> should I be looking at a different framework, can I write Rest API's that 
> send JSON encoded command and parameter data requests and get back JSON 
> encoded responses from my engine process? If the answer to the last question 
> is yes, can someone give me an example on how I write that using Django ie. 
> do I not bother with a model, but just serialize a set of fields to represent 
> the command and the data parameters for that request the app represents? 
> Instead of using framework .as_view() functions etc do I write my own 
> messaging function or does the framework actually have something already to 
> do this kind of thing?
> 
> Thanks in advance for answers/suggestions etc?
> 
> Andy
> 
> 
> CONFIDENTIALITY NOTICE: This e-mail transmission and/or any attachments may 
> contain confidential information belonging to the sender. Any unauthorised 
> interception of this transmission is illegal under the law. If you have 
> received this transmission in error, please promptly notify the sender by 
> reply e-mail, and then destroy all copies of the transmission.
> -- 
> You received this message because you are subscribed to the Google Groups 
> "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/14cea50a-dd1c-4746-9547-7a71a2e146e0%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/DAFB1075-24FA-4F83-8DAE-BEA9CAAB70FE%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is Django and DjangoRestAPI's the correct framework for my project?

2018-11-22 Thread Andy Gardner
Essentially I want to end up with a set of API's that will send a JSON 
encoded request along with data parameters to a middleware process and pass 
out the returning JSON encoded replies, either as a single string or a set 
of extracted data parameters. I have about 50+ CLI calls to represent in 
this way, so I was thinking of representing each call eg. create_user, 
login, logout, delete_user, run_emulation, change this emulation parameter 
etc, with an app or single api call. It doesn't have to be using the Django 
framework - if there is a more appropriate one that will allow me to 
produce a set of Restful API's to complete this, then I am open to 
suggestions on that front as well - it just so happens I started with 
Django and why I'm querying whether it's the right way to go, and if so, 
how do I implement it (presumably I don't need to create a model, but I 
probably need to set up a view and a serializer?)

Andy

On Thursday, 22 November 2018 17:06:12 UTC, Tim Vogt wrote:
>
> What problem are you trying to solve?
> What reason do You use djanfo now for?
>
> And what do You want with the json?
> Stored? Displayed? Or put trough as other apps might use the data?
> Tim
>
>
> Verstuurd vanaf mijn iPhone
>
> Op 22 nov. 2018 om 16:40 heeft Andy Gardner  > het volgende geschreven:
>
> I am new to Django, Python and Rest API's and have been learning it over 
> the last few weeks with a view to generating REST API's to control an 
> engine process.
>
> Currently I have an engine process running in the background, and a python 
> based test harness, which takes JSON encoded requests containing the 
> command and the data parameters. I currently use a simple command line to 
> write the JSON encoded requests and I get back JSON encoded replies, eg. I 
> send a login request to the backend process and I get a session id back 
> from it, which then has to be passed in subsequent engine requests.
>
> I have worked my way through William S Vincent's books for a beginner's 
> guide to Django and the follow-up Rest API's and I can see how quick and 
> useful the Django framework is for mocking up web pages and all the work 
> behind it to display, but it seems that all the examples are database based 
> and displaying of the contents all self-contained, which is not what I want 
> to do.
>
> I want to be able to create an API that sends requests to my test harness 
> (eventually this will be replaced with a proper middleware process but 
> doing the same sort of thing) and handles the replies. I was thinking along 
> the lines of creating an app per CLI call (ie. command request to test 
> harness), so I do not see any need for an underlying database or storage of 
> data as the API will eventually be used by an existing GUI that I will be 
> supplying the API's to. Neither can I really use the Django login framework 
> and authentication as I need to interact with the login mechanism with the 
> backend process ie the backend process needs to hold information on any 
> requests to create users and when those users login supply session id - the 
> backend process needs to work for many users in parallel).
>
> So my question is, is Django the right framework for what I want to do, or 
> should I be looking at a different framework, can I write Rest API's that 
> send JSON encoded command and parameter data requests and get back JSON 
> encoded responses from my engine process? If the answer to the last 
> question is yes, can someone give me an example on how I write that using 
> Django ie. do I not bother with a model, but just serialize a set of fields 
> to represent the command and the data parameters for that request the app 
> represents? Instead of using framework .as_view() functions etc do I write 
> my own messaging function or does the framework actually have something 
> already to do this kind of thing?
>
> Thanks in advance for answers/suggestions etc?
>
> Andy
>
>
> CONFIDENTIALITY NOTICE: This e-mail transmission and/or any attachments 
> may contain confidential information belonging to the sender. Any
>  unauthorised interception of this transmission is illegal under the law. 
> If you have received this transmission in error, please promptly notify the 
> sender by reply e-mail, and then destroy all copies of the transmission.
>
> -- 
> You received this message because you are subscribed 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/14cea50a-dd1c-4746-9547-7a71a2e146e0%40googlegroups.com
>  
> 
> .
> For more

How to fix TypeError: __init__() missing 1 required positional argument: 'on_delete'

2018-11-22 Thread Abba Haruna
from django.db import models

class Food(models.Model):
name = models.CharField(max_length=30)
picture = models.ImageField(upload_to='images/', null=True)
def __unicode__(self):
return self.name
class Town(models.Model):
name = models.CharField(max_length=30)

def __unicode__(self):
return self.name
class Restaurant(models.Model):
name = models.CharField(max_length=100)
desc = models.CharField(max_length=100)
menu = models.CharField(max_length=100)
web = models.CharField(max_length=100)
phone = models.CharField(max_length=40)
address = models.CharField(max_length=100)
post_code = models.CharField(max_length=20)
picture = models.ImageField(upload_to='images/', null=True)
map = models.ImageField(upload_to='images/', null=True)
gmap_url = models.CharField(max_length=200, null=True)
food = models.ForeignKey(Food)
town = models.ForeignKey(Town)
STARS = ((1,'one'),
(2,'two'),
(3,'three'),
(4,'four'),)
votes = models.IntegerField(choices=STARS, default=4)
def __unicode__(self):
return self.name
def __str__(self):

-- 
You received this message because you are subscribed to the Google Groups 
"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/de6ad3df-e330-43e1-875a-58895e245851%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to fix TypeError: __init__() missing 1 required positional argument: 'on_delete'

2018-11-22 Thread vineeth sagar
For a foreign keys you have to specify an on_delete attribute,

food=models.ForiegnKey(Food,on_delete=models.CASCADE)

If a row in the parent table(food for example) is deleted this will cause
the row/s that refers to that particular food item in your Restraunt model
be deleted.

on_delete can be given other options as SET_NULL,DO_NOTHING. Refer the docs
they are extensive on this topic.

On Nov 23, 2018 1:20 AM, "Abba Haruna"  wrote:

> from django.db import models
>
> class Food(models.Model):
> name = models.CharField(max_length=30)
> picture = models.ImageField(upload_to='images/', null=True)
> def __unicode__(self):
> return self.name
> class Town(models.Model):
> name = models.CharField(max_length=30)
>
> def __unicode__(self):
> return self.name
> class Restaurant(models.Model):
> name = models.CharField(max_length=100)
> desc = models.CharField(max_length=100)
> menu = models.CharField(max_length=100)
> web = models.CharField(max_length=100)
> phone = models.CharField(max_length=40)
> address = models.CharField(max_length=100)
> post_code = models.CharField(max_length=20)
> picture = models.ImageField(upload_to='images/', null=True)
> map = models.ImageField(upload_to='images/', null=True)
> gmap_url = models.CharField(max_length=200, null=True)
> food = models.ForeignKey(Food)
> town = models.ForeignKey(Town)
> STARS = ((1,'one'),
> (2,'two'),
> (3,'three'),
> (4,'four'),)
> votes = models.IntegerField(choices=STARS, default=4)
> def __unicode__(self):
> return self.name
> def __str__(self):
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/de6ad3df-e330-43e1-875a-58895e245851%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/CAMMZq8OuObyCbPXrwb47uSozX3sk7RXPiHaJnZxV%3Dk6SPjYpuA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is Django and DjangoRestAPI's the correct framework for my project?

2018-11-22 Thread Ryan Nowakowski
Django can definitely do what you want.  It just sounds like you won't
be using very many of it's built-in features.

- Ryan

On Thu, Nov 22, 2018 at 07:40:55AM -0800, Andy Gardner wrote:
> I am new to Django, Python and Rest API's and have been learning it over 
> the last few weeks with a view to generating REST API's to control an 
> engine process.
> 
> Currently I have an engine process running in the background, and a python 
> based test harness, which takes JSON encoded requests containing the 
> command and the data parameters. I currently use a simple command line to 
> write the JSON encoded requests and I get back JSON encoded replies, eg. I 
> send a login request to the backend process and I get a session id back 
> from it, which then has to be passed in subsequent engine requests.
> 
> I have worked my way through William S Vincent's books for a beginner's 
> guide to Django and the follow-up Rest API's and I can see how quick and 
> useful the Django framework is for mocking up web pages and all the work 
> behind it to display, but it seems that all the examples are database based 
> and displaying of the contents all self-contained, which is not what I want 
> to do.
> 
> I want to be able to create an API that sends requests to my test harness 
> (eventually this will be replaced with a proper middleware process but 
> doing the same sort of thing) and handles the replies. I was thinking along 
> the lines of creating an app per CLI call (ie. command request to test 
> harness), so I do not see any need for an underlying database or storage of 
> data as the API will eventually be used by an existing GUI that I will be 
> supplying the API's to. Neither can I really use the Django login framework 
> and authentication as I need to interact with the login mechanism with the 
> backend process ie the backend process needs to hold information on any 
> requests to create users and when those users login supply session id - the 
> backend process needs to work for many users in parallel).
> 
> So my question is, is Django the right framework for what I want to do, or 
> should I be looking at a different framework, can I write Rest API's that 
> send JSON encoded command and parameter data requests and get back JSON 
> encoded responses from my engine process? If the answer to the last 
> question is yes, can someone give me an example on how I write that using 
> Django ie. do I not bother with a model, but just serialize a set of fields 
> to represent the command and the data parameters for that request the app 
> represents? Instead of using framework .as_view() functions etc do I write 
> my own messaging function or does the framework actually have something 
> already to do this kind of thing?
> 
> Thanks in advance for answers/suggestions etc?
> 
> Andy
> 
> -- 
> 
> 
> 
> 
> 
> CONFIDENTIALITY NOTICE: This e-mail transmission and/or any 
> attachments may contain confidential information belonging to the sender. 
> Any unauthorised interception of this transmission is illegal under the 
> law. If you have received this transmission in error, please promptly 
> notify the sender by reply e-mail, and then destroy all copies of the 
> transmission.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "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/14cea50a-dd1c-4746-9547-7a71a2e146e0%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/20181122213559.GE8710%40fattuba.com.
For more options, visit https://groups.google.com/d/optout.


Re: email

2018-11-22 Thread Ryan Nowakowski
On Thu, Nov 22, 2018 at 02:59:02PM +0530, Tushar Nadkar wrote:
> i have email id of multiple user , so how can i send mail after 3 days when
> he click a button .or checkout button in django

I record the timestamp of the button click in a model then I run cron
or celery periodically to query the model like this:

ready_to_email = 
MyModel.objects.filter(when_button_clicked__lte=timezone.now()-timedelta(days=3),
 already_emailed=False)

Then I use the django mail module to send the emails.  Finally I record
that the emails were sent in the model(already_emailed = True) so they
don't get sent again.

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


Re: mail sending

2018-11-22 Thread Joel
django-kronos is probably the easiest to do this. As mentioned, you could
create a management command to check a database or file for the time when
you want to run this, with any other data, then you'd set an interval at
which you want to check if mails need be sent, and then execute your mail
sending function if the criteria is satisfied.

On Thu, 22 Nov, 2018, 8:19 PM Jani Tiainen  Hi.
>
> Essentially you need to record the time you want your mail to be sent and
> then you need some kind of background worker to check (periodically) if
> there are any mails to be sent.
>
> Celery is one tool that can do that.
>
> I personally use simple cron job that uses django management command to
> achieve same stuff (sending emails asynchronously).
>
> Tushar Nadkar  kirjoitti to 22. marrask. 2018
> klo 8.53:
>
>> when a button is clicked , i want to send specific mail after 3 days ?
>> how can i do that in 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/CAAHYEvMUPoT%2BivTkPx%2BekvksnVWo%3DiByAt48iQX8m-HjTSQMTw%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/CAHn91ocf3eFL7QMiXj0Mspg4zDCovE0VGaJ8-onEaRdsq02TXA%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/CAA%3Diw_-KvAkYrF0hhKfvc_GZo_wueLrTM%2B1kCHXtQvJH8VfjQg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


URL path not working with Django ver 2.1.2

2018-11-22 Thread Ben Hamlitsch
This is the message I get when I run python manage.py runserver

[image: Screen Shot 2018-11-22 at 7.18.58 PM.png]


This is my setup in Atom 


[image: Screen Shot 2018-11-22 at 7.22.10 PM.png]


ANY help you can provide much 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+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/11324094-eea3-488c-b8dd-9e0cc1d38262%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Working with kronos

2018-11-22 Thread Jason
the documentation is ambiguous in that regard.  that said, I feel it says 
you can register the cron tasks either way, but it doesn't do anything to 
actually install the commands.  you can see the code of the installtasks 
management command:

https://github.com/jgorset/django-kronos/blob/v1.0/kronos/management/commands/installtasks.py

which then runs the functions in 
https://github.com/jgorset/django-kronos/blob/v1.0/kronos/__init__.py#L117-L154

as you can see there, it uses the python crontab package to install the 
crontab task.

Furthermore, in 
https://github.com/jgorset/django-kronos/blob/v1.0/kronos/__init__.py#L107-L114,
 
you can see what exactly the decorator consists of.  It just adds the task 
to a task registry set and doesn't do anything about actual installation.

as an aside, one of the things I've found to be pretty valuable is to look 
at the project repository when it comes to questions like this.  this is 
not meant to be mean, and I'm sorry if it comes across that way.  I didn't 
know about this project before your question, but a brief look in the repo 
revealed those links and functions above, which are the most likely answers 
to your question above.  you're asking good questions here and giving good 
help in return, so if you internalize a method of investigating problems 
like this, or have more specific and focused questions that your 
investigations have unearthed.

-- 
You received this message because you are subscribed to the Google Groups 
"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/7e5feb84-d1d6-4dfe-bc48-2e36ac0f0e30%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to fix TypeError: __init__() missing 1 required positional argument: 'on_delete'

2018-11-22 Thread Jason
on_delete is a required parameter now in django 2.0

https://docs.djangoproject.com/en/2.0/releases/2.0/#features-removed-in-2-0


   - The on_delete argument for ForeignKey and OneToOneField is now 
   required in models and migrations. Consider squashing migrations so that 
   you have fewer of them to update.

-- 
You received this message because you are subscribed to the Google Groups 
"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/c3ea951d-4426-4973-b1bf-1d645402d1bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to send data from form site page

2018-11-22 Thread Jason
https://stackoverflow.com/help/how-to-ask

how to ask a good question is one of the most valuable skills you can 
learn.  if you do so, you won't have several people asking for more 
clarifications to broad, imprecise queries and struggling to give any 
meaningful 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 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/956693bd-5a85-4744-a0a7-521f2aa33d70%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Working with kronos

2018-11-22 Thread Joel
Yes, the language of the documentation certainly needs tweaking. I had done
the installtasks and it did work. Thank you very much for your help.
Now, I can have my app check for upcoming appointments and send reminders.
It was a much needed functionality.

On Fri, 23 Nov, 2018, 9:06 AM Jason  the documentation is ambiguous in that regard.  that said, I feel it says
> you can register the cron tasks either way, but it doesn't do anything to
> actually install the commands.  you can see the code of the installtasks
> management command:
>
>
> https://github.com/jgorset/django-kronos/blob/v1.0/kronos/management/commands/installtasks.py
>
> which then runs the functions in
> https://github.com/jgorset/django-kronos/blob/v1.0/kronos/__init__.py#L117-L154
>
> as you can see there, it uses the python crontab package to install the
> crontab task.
>
> Furthermore, in
> https://github.com/jgorset/django-kronos/blob/v1.0/kronos/__init__.py#L107-L114,
> you can see what exactly the decorator consists of.  It just adds the task
> to a task registry set and doesn't do anything about actual installation.
>
> as an aside, one of the things I've found to be pretty valuable is to look
> at the project repository when it comes to questions like this.  this is
> not meant to be mean, and I'm sorry if it comes across that way.  I didn't
> know about this project before your question, but a brief look in the repo
> revealed those links and functions above, which are the most likely answers
> to your question above.  you're asking good questions here and giving good
> help in return, so if you internalize a method of investigating problems
> like this, or have more specific and focused questions that your
> investigations have unearthed.
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/7e5feb84-d1d6-4dfe-bc48-2e36ac0f0e30%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/CAA%3Diw_8W%3Dwk5PZv2MJbrcrbBokD7JwMCO3sfJq0V5CkDEzFLjA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Working with kronos

2018-11-22 Thread Joel
Thanks for the advise regarding understanding the issue in depth. My
initiation to python has been all of three months, and to django since two.
So far, I'd been scared to look under the hood, and any further than the
documentation. But I realize that it's not as daunting now add it used to
be. And coming from perl, I'm impressed at how cleaner it is.

Now I'm feeling power packed to examine the innards of django and python.
Thank you!

On Fri, 23 Nov, 2018, 9:06 AM Jason  the documentation is ambiguous in that regard.  that said, I feel it says
> you can register the cron tasks either way, but it doesn't do anything to
> actually install the commands.  you can see the code of the installtasks
> management command:
>
>
> https://github.com/jgorset/django-kronos/blob/v1.0/kronos/management/commands/installtasks.py
>
> which then runs the functions in
> https://github.com/jgorset/django-kronos/blob/v1.0/kronos/__init__.py#L117-L154
>
> as you can see there, it uses the python crontab package to install the
> crontab task.
>
> Furthermore, in
> https://github.com/jgorset/django-kronos/blob/v1.0/kronos/__init__.py#L107-L114,
> you can see what exactly the decorator consists of.  It just adds the task
> to a task registry set and doesn't do anything about actual installation.
>
> as an aside, one of the things I've found to be pretty valuable is to look
> at the project repository when it comes to questions like this.  this is
> not meant to be mean, and I'm sorry if it comes across that way.  I didn't
> know about this project before your question, but a brief look in the repo
> revealed those links and functions above, which are the most likely answers
> to your question above.  you're asking good questions here and giving good
> help in return, so if you internalize a method of investigating problems
> like this, or have more specific and focused questions that your
> investigations have unearthed.
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/7e5feb84-d1d6-4dfe-bc48-2e36ac0f0e30%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/CAA%3Diw_9zVznFM3pp3rG1%3DrGepULA6TmzmaefDSMsRfWEv-M25w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: URL path not working with Django ver 2.1.2

2018-11-22 Thread Yavin Aalto Arba
Path is not using regular expressions. Use empty quotes and it should work.

On Fri, Nov 23, 2018, 5:28 AM Ben Hamlitsch  This is the message I get when I run python manage.py runserver
>
> [image: Screen Shot 2018-11-22 at 7.18.58 PM.png]
>
>
> This is my setup in Atom
>
>
> [image: Screen Shot 2018-11-22 at 7.22.10 PM.png]
>
>
> ANY help you can provide much 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+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/11324094-eea3-488c-b8dd-9e0cc1d38262%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/CA%2B%2Be-ZUdOsZRJwJwikmbMN-EzTuY9H%2BOf61XpWGXquLgpX_L%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Website is running in Django and also clients want to make the Mobile APP.

2018-11-22 Thread Pravin Yadav
Hello Everyone,

Good Morning,

I have created the website in Django + Python3. Website is running.
But I want to make the Mobile App. Can anyone guide me how will i work.



Thanks & Regards,
Pravin Kr Yadav

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