Re: testing API

2019-04-22 Thread Jani Tiainen
Hi,

DRF does have built-in API viewer. To enable that you need to add
rest_framework app in your INSTALLED_APPS so it can find necessary
templates for showing.

On Tue, Apr 23, 2019 at 7:15 AM Shubham Joshi  wrote:

> I have created the custom model authentication in django rest , so far I
> dont have front end , so my question is , Im I done with the API, since on
> browser it gives an error TemplateDoesNotExist at /
> rest_framework/api.html that of course due to I dont have template, in
> postmen its giving {
> "detail": "Method \"GET\" not allowed."
> } , Am I going right?
>
> https://github.com/shubham1507/school
> 
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/5596723f-0358-41b5-9b0f-cf0f9dc84057%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Jani Tiainen
Software wizard

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

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

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


Re: Database setup

2019-04-22 Thread Sipum
Hi somen,

Just Open xampp control panel and run apache and mySQL sever.
then go to localhost/phpmyadmin in browser and there create a database as u 
do for php.

then in search DATABASE in settings.py file (which would be created when u 
create a project in django) do the below changes -
 
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'webapp', --> name of db which u created b4
'USER': 'root',--> user is root 
'PASSWORD': '',   > it is pasword less
'HOST': '127.0.0.1',---> this is for local host
'PORT': '3306',   > this port number u will get 
from xampp control panel where u start MYSQL
}


Hope it will help... Njoy



On Saturday, 20 April 2019 09:52:05 UTC+5:30, Soumen Khatua wrote:
>
> Hi Folks,
> How can I configure xampp server provided mysql database in django.
>
> Thank you.  
>

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


Integrating Google calendar API in TODO list

2019-04-22 Thread Sipum
Hello friends.

I am going to integrate google calendar API in to my TODO List.
can anyone suggest how to integrate so that when I will add any event in my 
TODO List app it will directly show in my google calendar.

Thanks.

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


testing API

2019-04-22 Thread Shubham Joshi
I have created the custom model authentication in django rest , so far I 
dont have front end , so my question is , Im I done with the API, since on 
browser it gives an error TemplateDoesNotExist at /
rest_framework/api.html that of course due to I dont have template, in 
postmen its giving {
"detail": "Method \"GET\" not allowed."
} , Am I going right?

https://github.com/shubham1507/school 


-- 
You received this message because you are subscribed to the Google Groups 
"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/5596723f-0358-41b5-9b0f-cf0f9dc84057%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Converting django app to iPhone app

2019-04-22 Thread Larry Martell
Thanks for the replies!

On Mon, Apr 22, 2019 at 12:43 PM Nick Sarbicki
 wrote:
>
> The JavaScript I assume is just for frontend logic so hopefully isn't very 
> relevant - this will always need to be redone in the native language (unless 
> using something like react native).
>
> If it only renders HTML then there is a bit of work you need to do in 
> python/Django land.
>
> Think about what you want to show on your app and what data this will require 
> from your backend server, as well as any other way it may have to interact 
> with the server. Usually it will be standard CRUD operations. Write these 
> down.
>
> Then find a library that will allow you to transmit this data in a serialised 
> format like JSON, and run the relevant operations. Usually you'd look at 
> something like a REST API (Django rest framework) or websockets (channels), 
> whatever you feel most comfortable with.
>
> These generally work well with existing projects (django rest framework can 
> often be integrated with <100 LOC). Once you have that integrated there is 
> generally very little to think about for the backend, it's almost all about 
> getting the frontend to make the correct requests and deserialising the data. 
> Authentication often serves as a tripping point as well but there's n 
> solutions to the problem.
>
> On Mon, 22 Apr 2019, 17:28 Larry Martell,  wrote:
>>
>> Yes, it only renders HTML and also has a lot of javascript.
>>
>> On Mon, Apr 22, 2019 at 12:25 PM Nick Sarbicki
>>  wrote:
>> >
>> > That's the point, you don't. Assuming your backend has an effective way of 
>> > delivering data (e.g. a REST API).
>> >
>> > If your Django server currently only renders HTML templates then you may 
>> > want to consider adding an API on top of that. But the backend definitely 
>> > does not need to be rewritten, only slightly expanded upon (using python).
>> >
>> > Outside of that you only need to focus on the frontend, usually with swift.
>> >
>> > On Mon, 22 Apr 2019, 16:47 Larry Martell,  wrote:
>> >>
>> >> Googling I found where someone said you could leave the back end in
>> >> python and rewrite the front end in objective C or swift or rewrite
>> >> the entire app in objective C or swift. Why would you need to rewrite
>> >> the python back end that runs on the server?
>> >>
>> >> On Mon, Apr 22, 2019 at 10:27 AM Nick Sarbicki
>> >>  wrote:
>> >> >
>> >> > Kind of...
>> >> >
>> >> > I've worked with several Django APIs that we use to back apps on 
>> >> > Android and iOS as well as web apps.
>> >> >
>> >> > I generally find that's the key, make sure you can pass all the data 
>> >> > along as an API and the rest is just understanding how to build a 
>> >> > frontend on the platform. Django doesn't really get in the way at all 
>> >> > at that point.
>> >> >
>> >> >
>> >> > On Mon, 22 Apr 2019, 14:19 Larry Martell,  
>> >> > wrote:
>> >> >>
>> >> >> Has anyone here every taken a django web app and converted it to an
>> >> >> iPhone app? If so, can you share your experiences here please?
>> >> >>
>> >> >> Thanks!

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


Re: User Posts not posting to page

2019-04-22 Thread silverstrings026
**FIXED**

>
> #public_posts/forms/py
>
> from django.forms import ModelForm
>
> from .models import PublicPost
>
> class PublicPostForm(ModelForm):
>
> class Meta:
> model = PublicPost
> fields = ('title', 'text') #didn't need author
>
>
>
>
> # public_posts/views.py
>
>
>
> from django.shortcuts import render
> from django.utils import timezone
> from .models import PublicPost
> from django.urls import reverse_lazy
> from django.views import generic
> from django.http import HttpResponseRedirect
> from django.shortcuts import render, redirect
> from . import forms
> from django.forms import ModelForm as Form
>
>
> def pub_post_list(request):
>
> posts = 
> PublicPost.objects.filter(published_date__lte=datetime.now()).order_by('published_date')
>  
> <== Changed
>
> return render(request, 'public_posts/pub_posts.html', {'posts': posts})
>
> def post_new(request):
> if request.method == 'POST':
> form = forms.PublicPostForm(request.POST)
> if form.is_valid():
> content = form.save(commit=False)
> content.author = request.user
> content.save()
> return redirect('pub_posts')
> else:
> form = forms.PublicPostForm()
> return render(request, 'public_posts/new_post.html', {'form': form})
>
>
>
>
>
> # public_posts/models.py
>
> from django.conf import settings
> from django.db import models
> from django.utils import timezone
> from django.utils.http import urlquote
> from django.utils.translation import ugettext_lazy as _
> from django.core.mail import send_mail
> from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin
> from django.contrib.auth.models import BaseUserManager
> from django.contrib.auth import get_user_model
> User = get_user_model()
>
> # Create your models here.
> class PublicPost(models.Model):
> author = models.ForeignKey(User, related_name='pub_poster', 
> on_delete=models.CASCADE, null=True)
> title = models.CharField(max_length=200)
> text = models.TextField()
> created_date = models.DateTimeField(default=timezone.now)
> published_date = models.DateTimeField(auto_now=True, null=True) <== 
> Changed
>
>
> def publish(self):
> self.published_date = published_date <== Changed
> self.save()
>
> def __str__(self):
> return self.title
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/709074e3-964e-4c02-8b6f-d119284ffbc3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Converting django app to iPhone app

2019-04-22 Thread Nick Sarbicki
The JavaScript I assume is just for frontend logic so hopefully isn't very
relevant - this will always need to be redone in the native language
(unless using something like react native).

If it only renders HTML then there is a bit of work you need to do in
python/Django land.

Think about what you want to show on your app and what data this will
require from your backend server, as well as any other way it may have to
interact with the server. Usually it will be standard CRUD operations.
Write these down.

Then find a library that will allow you to transmit this data in a
serialised format like JSON, and run the relevant operations. Usually you'd
look at something like a REST API (Django rest framework) or websockets
(channels), whatever you feel most comfortable with.

These generally work well with existing projects (django rest framework can
often be integrated with <100 LOC). Once you have that integrated there is
generally very little to think about for the backend, it's almost all about
getting the frontend to make the correct requests and deserialising the
data. Authentication often serves as a tripping point as well but there's n
solutions to the problem.

On Mon, 22 Apr 2019, 17:28 Larry Martell,  wrote:

> Yes, it only renders HTML and also has a lot of javascript.
>
> On Mon, Apr 22, 2019 at 12:25 PM Nick Sarbicki
>  wrote:
> >
> > That's the point, you don't. Assuming your backend has an effective way
> of delivering data (e.g. a REST API).
> >
> > If your Django server currently only renders HTML templates then you may
> want to consider adding an API on top of that. But the backend definitely
> does not need to be rewritten, only slightly expanded upon (using python).
> >
> > Outside of that you only need to focus on the frontend, usually with
> swift.
> >
> > On Mon, 22 Apr 2019, 16:47 Larry Martell, 
> wrote:
> >>
> >> Googling I found where someone said you could leave the back end in
> >> python and rewrite the front end in objective C or swift or rewrite
> >> the entire app in objective C or swift. Why would you need to rewrite
> >> the python back end that runs on the server?
> >>
> >> On Mon, Apr 22, 2019 at 10:27 AM Nick Sarbicki
> >>  wrote:
> >> >
> >> > Kind of...
> >> >
> >> > I've worked with several Django APIs that we use to back apps on
> Android and iOS as well as web apps.
> >> >
> >> > I generally find that's the key, make sure you can pass all the data
> along as an API and the rest is just understanding how to build a frontend
> on the platform. Django doesn't really get in the way at all at that point.
> >> >
> >> >
> >> > On Mon, 22 Apr 2019, 14:19 Larry Martell, 
> wrote:
> >> >>
> >> >> Has anyone here every taken a django web app and converted it to an
> >> >> iPhone app? If so, can you share your experiences here please?
> >> >>
> >> >> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To 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/CACwCsY4rDGWXMgD-pitf%3D_Z3%2BDNjLWCuGA2udmghW4diaRzamQ%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/CAGuvt91dyNb3ZvoL%3DA7NeG_wxYyC5FL4i-KmqQB5AcNY%3DvC0sw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: problems with url and views - new to django

2019-04-22 Thread Robert Wahoo
Actually, I found why I got that last message, was a typo on my part.

On to the next problem…Thank you.

From: "django-users@googlegroups.com"  on behalf 
of "Victor H. Velasquez Rizo" 
Reply-To: "django-users@googlegroups.com" 
Date: Sunday, April 21, 2019 at 9:02 PM
To: "django-users@googlegroups.com" 
Subject: Re: problems with url and views - new to django

Hello Rob.
With the url "hello/", your trying to call the "hello" function on your view.py.
First, you need to import "hello" to be able to use it. from  from  
lct_app.views import hello
Second, call the function. path('hello/', hello),

urls.py
from django.contrib import admin
from django.urls import path
from  lct_app.views import hello

urlpatterns = [
path('admin/', admin.site.urls),
path('hello/', hello),
]

views.py

from django.shortcuts import render

def hello(request):
   return render(request, "lct_app/templates/hello.html", {})

On Sun, Apr 21, 2019 at 5:07 PM Rob W 
mailto:randmwhee...@gmail.com>> wrote:
setting up a new project.
all good, loaded up the project on localhost.

however, when creating a view then setting the url, it doesn't work.


urls.py

from django.contrib import admin
from django.urls import path

urlpatterns = [
path('admin/', admin.site.urls),
path('hello/', lct_app.site.urls),


views.py

from django.shortcuts import render

def hello(request):
   return render(request, "lct_app/templates/hello.html", {})

i comment out the path in urls.py, django comes back. what am i missing?



--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+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/4872beca-597c-4689-a12e-9e888c5266ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--



Atte...,.
Vìctor Hugo Velàsquez Rizo
Cali - Colombia
--
You received this message because you are subscribed to the Google Groups 
"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/CAFCXTzga%3DFAMdPFwhfp3yMEtyZkA7rzmjhB29rAG160ALuP3Og%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/BL0PR01MB4354017875EE71CD3DF45828F4220%40BL0PR01MB4354.prod.exchangelabs.com.
For more options, visit https://groups.google.com/d/optout.


Re: Converting django app to iPhone app

2019-04-22 Thread Larry Martell
Yes, it only renders HTML and also has a lot of javascript.

On Mon, Apr 22, 2019 at 12:25 PM Nick Sarbicki
 wrote:
>
> That's the point, you don't. Assuming your backend has an effective way of 
> delivering data (e.g. a REST API).
>
> If your Django server currently only renders HTML templates then you may want 
> to consider adding an API on top of that. But the backend definitely does not 
> need to be rewritten, only slightly expanded upon (using python).
>
> Outside of that you only need to focus on the frontend, usually with swift.
>
> On Mon, 22 Apr 2019, 16:47 Larry Martell,  wrote:
>>
>> Googling I found where someone said you could leave the back end in
>> python and rewrite the front end in objective C or swift or rewrite
>> the entire app in objective C or swift. Why would you need to rewrite
>> the python back end that runs on the server?
>>
>> On Mon, Apr 22, 2019 at 10:27 AM Nick Sarbicki
>>  wrote:
>> >
>> > Kind of...
>> >
>> > I've worked with several Django APIs that we use to back apps on Android 
>> > and iOS as well as web apps.
>> >
>> > I generally find that's the key, make sure you can pass all the data along 
>> > as an API and the rest is just understanding how to build a frontend on 
>> > the platform. Django doesn't really get in the way at all at that point.
>> >
>> >
>> > On Mon, 22 Apr 2019, 14:19 Larry Martell,  wrote:
>> >>
>> >> Has anyone here every taken a django web app and converted it to an
>> >> iPhone app? If so, can you share your experiences here please?
>> >>
>> >> Thanks!

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


Re: Converting django app to iPhone app

2019-04-22 Thread Nick Sarbicki
That's the point, you don't. Assuming your backend has an effective way of
delivering data (e.g. a REST API).

If your Django server currently only renders HTML templates then you may
want to consider adding an API on top of that. But the backend definitely
does not need to be rewritten, only slightly expanded upon (using python).

Outside of that you only need to focus on the frontend, usually with swift.

On Mon, 22 Apr 2019, 16:47 Larry Martell,  wrote:

> Googling I found where someone said you could leave the back end in
> python and rewrite the front end in objective C or swift or rewrite
> the entire app in objective C or swift. Why would you need to rewrite
> the python back end that runs on the server?
>
> On Mon, Apr 22, 2019 at 10:27 AM Nick Sarbicki
>  wrote:
> >
> > Kind of...
> >
> > I've worked with several Django APIs that we use to back apps on Android
> and iOS as well as web apps.
> >
> > I generally find that's the key, make sure you can pass all the data
> along as an API and the rest is just understanding how to build a frontend
> on the platform. Django doesn't really get in the way at all at that point.
> >
> >
> > On Mon, 22 Apr 2019, 14:19 Larry Martell, 
> wrote:
> >>
> >> Has anyone here every taken a django web app and converted it to an
> >> iPhone app? If so, can you share your experiences here please?
> >>
> >> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To 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/CACwCsY586vT-kcP%2B6zq%2BLj6Lb70%2B1%3DscxTA-2n3HdgNESz_GOw%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/CAGuvt906j6%2BAKXiL6r1vhYXO39F3EJg5%2BxDUoZ%3D7VJj0h6cpOg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Converting django app to iPhone app

2019-04-22 Thread Larry Martell
Googling I found where someone said you could leave the back end in
python and rewrite the front end in objective C or swift or rewrite
the entire app in objective C or swift. Why would you need to rewrite
the python back end that runs on the server?

On Mon, Apr 22, 2019 at 10:27 AM Nick Sarbicki
 wrote:
>
> Kind of...
>
> I've worked with several Django APIs that we use to back apps on Android and 
> iOS as well as web apps.
>
> I generally find that's the key, make sure you can pass all the data along as 
> an API and the rest is just understanding how to build a frontend on the 
> platform. Django doesn't really get in the way at all at that point.
>
>
> On Mon, 22 Apr 2019, 14:19 Larry Martell,  wrote:
>>
>> Has anyone here every taken a django web app and converted it to an
>> iPhone app? If so, can you share your experiences here please?
>>
>> Thanks!

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


Re: problems with url and views - new to django

2019-04-22 Thread Robert Wahoo
Awesome,Thanks Victor, I’ll give this a shot.

Thanks.


From: "django-users@googlegroups.com"  on behalf 
of "Victor H. Velasquez Rizo" 
Reply-To: "django-users@googlegroups.com" 
Date: Sunday, April 21, 2019 at 9:02 PM
To: "django-users@googlegroups.com" 
Subject: Re: problems with url and views - new to django

Hello Rob.
With the url "hello/", your trying to call the "hello" function on your view.py.
First, you need to import "hello" to be able to use it. from  from  
lct_app.views import hello
Second, call the function. path('hello/', hello),

urls.py
from django.contrib import admin
from django.urls import path
from  lct_app.views import hello

urlpatterns = [
path('admin/', admin.site.urls),
path('hello/', hello),
]

views.py

from django.shortcuts import render

def hello(request):
   return render(request, "lct_app/templates/hello.html", {})

On Sun, Apr 21, 2019 at 5:07 PM Rob W 
mailto:randmwhee...@gmail.com>> wrote:
setting up a new project.
all good, loaded up the project on localhost.

however, when creating a view then setting the url, it doesn't work.


urls.py

from django.contrib import admin
from django.urls import path

urlpatterns = [
path('admin/', admin.site.urls),
path('hello/', lct_app.site.urls),


views.py

from django.shortcuts import render

def hello(request):
   return render(request, "lct_app/templates/hello.html", {})

i comment out the path in urls.py, django comes back. what am i missing?



--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+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/4872beca-597c-4689-a12e-9e888c5266ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--



Atte...,.
Vìctor Hugo Velàsquez Rizo
Cali - Colombia
--
You received this message because you are subscribed to the Google Groups 
"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/CAFCXTzga%3DFAMdPFwhfp3yMEtyZkA7rzmjhB29rAG160ALuP3Og%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/BL0PR01MB43546102A2EB13B93EB26E08F4220%40BL0PR01MB4354.prod.exchangelabs.com.
For more options, visit https://groups.google.com/d/optout.


User Posts not posting to page

2019-04-22 Thread silverstrings026
Hello, i'm trying to allow users to post to a public posts page, it shows 
up in the admin page (where you manage a pages post) but it isn't showing 
up on the page.

Relevant Files & HTML (app level & project level urls.py is not included 
because routing is fine)

***CAN'T FORMAT CODE, IT WON'T LET ME POST THE THREAD IF I TRY TO FORMAT***



#public_posts/forms/py

from django.forms import ModelForm

from .models import PublicPost

class PublicPostForm(ModelForm):

class Meta:
model = PublicPost
fields = ('title', 'text', 'author')




# public_posts/views.py



from django.shortcuts import render
from django.utils import timezone
from .models import PublicPost
from django.urls import reverse_lazy
from django.views import generic
from django.http import HttpResponseRedirect
from django.shortcuts import render, redirect
from . import forms
from django.forms import ModelForm as Form


def pub_post_list(request):
   
posts = 
PublicPost.objects.filter(published_date__lte=timezone.now()).order_by('published_date')
return render(request, 'public_posts/pub_posts.html', {'posts': posts})

def post_new(request):
if request.method == 'POST':
form = forms.PublicPostForm(request.POST)
if form.is_valid():
content = form.save(commit=False)
content.author = request.user
content.save()
return redirect('pub_posts')
else:
form = forms.PublicPostForm()
return render(request, 'public_posts/new_post.html', {'form': form})





# public_posts/models.py

from django.conf import settings
from django.db import models
from django.utils import timezone
from django.utils.http import urlquote
from django.utils.translation import ugettext_lazy as _
from django.core.mail import send_mail
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin
from django.contrib.auth.models import BaseUserManager
from django.contrib.auth import get_user_model
User = get_user_model()

# Create your models here.
class PublicPost(models.Model):
author = models.ForeignKey(User, related_name='pub_poster', 
on_delete=models.CASCADE, null=True)
title = models.CharField(max_length=200)
text = models.TextField()
created_date = models.DateTimeField(default=timezone.now)
published_date = models.DateTimeField(blank=True, null=True)

def publish(self):
self.published_date = timezone.now()
self.save()

def __str__(self):
return self.title










{% extends 'public_posts/bang.html' %}
Home
{% block content %}

{% csrf_token %}
{{ form }}



{% endblock %}  

   





{% load static %}


FreeSpeech








Free Speech




{% block content %}
{% endblock %}







-- 
You received this message because you are subscribed to the Google Groups 
"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/f3ab4354-aa19-42c2-971d-68da4e033b71%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Converting django app to iPhone app

2019-04-22 Thread Nick Sarbicki
Kind of...

I've worked with several Django APIs that we use to back apps on Android
and iOS as well as web apps.

I generally find that's the key, make sure you can pass all the data along
as an API and the rest is just understanding how to build a frontend on the
platform. Django doesn't really get in the way at all at that point.


On Mon, 22 Apr 2019, 14:19 Larry Martell,  wrote:

> Has anyone here every taken a django web app and converted it to an
> iPhone app? If so, can you share your experiences here please?
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To 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/CACwCsY6R%2BLAw5BGYZtrC%2BTJ%2B13yApo7JH6xn-fVORiOP%2BoLU%2Bg%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/CAGuvt927mPEbeN3t1uK%2BoGnNWvG0jHR0AzqKUGdnmGi2diQ%3DBQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: compute model field by related field

2019-04-22 Thread omar ahmed
i put this function in "Match" class :
def points(self):
if self.score_local > self.score_visitor:
return (self.club_local.won)+1 and (self.club_visitor.lost)+1
elif self.score_local < self.score_visitor:
return (self.club_local.lost)+1 and (self.club_visitor.won)+1
else:
return (self.club_local.draw)+1 and (self.club_visitor.draw)+1
and i want it to update fields and 'CalcPoints' function in "Club" class 
class Club(models.Model):
...
def CalcPoints(self):
return self.won*3 + self.draw

but until now it does not update objects (( how can i use post_save here )) 

On Saturday, April 20, 2019 at 9:09:01 AM UTC+2, Derek wrote:
>
> That should just require a basic if/then logic test; "get" the correct 
> Club object, update the win/loss field and save the Club. Repeat for both 
> Clubs.
>
> On Thursday, 18 April 2019 14:09:41 UTC+2, omar ahmed wrote:
>>
>> thank you for response , derek
>> but how can i increment 'win' 'lost' or 'draw' Club fields by 'winner' 
>> Match field
>>
>> On Wednesday, April 17, 2019 at 3:26:22 PM UTC+2, Derek wrote:
>>>
>>> 1. Add a "winner" field to your Match
>>> 2. Implement a post_save  signal for the Match model that updates the 
>>> "won" or "lost" fields for each Club in the match (simple if/then logic 
>>> based on winner).
>>>
>>> PS I think the default values for "won" and "lost" for a Club should be 
>>> "0" and not "1".
>>>
>>> On Tuesday, 16 April 2019 20:19:34 UTC+2, omar ahmed wrote:

 hello ... i have two models "Club" class and "Match" class and it has 
 foreign key to Club
 now i want to increment "won" field (or draw or lost) in "Club" class 
 by "score_local" and "score_visitor" in "Match" class ..
 how can i do this
 class Club(models.Model):
 name = models.CharField(max_length=100)
 won = models.IntegerField(default=1)
 draw = models.IntegerField(default=1)
 lost = models.IntegerField()
 goal_for = models.IntegerField()
 goal_against = models.IntegerField()


 class Match(models.Model):
 play_date = models.DateTimeField('play date')
 club_visitor = models.ForeignKey(Club, on_delete=models.CASCADE, 
 related_name='match_club_visitor')
 club_local = models.ForeignKey(Club, on_delete=models.CASCADE, 
 related_name='match_club_local')
 score_visitor = models.IntegerField()
 score_local = models.IntegerField()

>>>

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


Re: Django interview Questions

2019-04-22 Thread Karan Mittal
Also you can check out my articles on Django and learn it from scratch.
https://data-flair.training/blogs/category/django/
The articles are uploaded on a timely basis and we will be covering more
advanced topics too.


On Mon, Apr 22, 2019 at 6:18 PM  wrote:

>
>> Some of the questions which are usually asked in Django interview are:
>>
>>
>>1. Explain what is Django and some basic features of Django framework.
>>2. How can we customize Django admin interface?
>>3. Define Django ORM and its importance.
>>4. What is Django model? Explain its working in Django architecture.
>>5. How we can add View functions to urls.py?
>>6. Describe about Django's user authentication.
>>7. Which websites are using Django framework?
>>8. Explain about Django Rest Framework.
>>
>> Prepare for your interview with some more Django interview questions
>>  along
>> with answers.
>>
>
> On Monday, April 22, 2019 at 5:10:06 PM UTC+5:30, Aakash Bachheriya wrote:
>>
>> Which type of Questions are generally asked during Django interview?
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "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/b2cba696-c500-4d89-90e9-3e198a3d1d28%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/CAO24gqxabcE_P3STSY%3D0Houk5%2BvEuWmiaxYPJ98BjcZJFUAA2Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Converting django app to iPhone app

2019-04-22 Thread Larry Martell
Has anyone here every taken a django web app and converted it to an
iPhone app? If so, can you share your experiences here please?

Thanks!

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


Re: Django interview Questions

2019-04-22 Thread animeshagrawaal

>
>
> Some of the questions which are usually asked in Django interview are:
>
>
>1. Explain what is Django and some basic features of Django framework.
>2. How can we customize Django admin interface?
>3. Define Django ORM and its importance.
>4. What is Django model? Explain its working in Django architecture.
>5. How we can add View functions to urls.py?
>6. Describe about Django's user authentication.
>7. Which websites are using Django framework?
>8. Explain about Django Rest Framework.
>
> Prepare for your interview with some more Django interview questions 
>  along 
> with answers.
>

On Monday, April 22, 2019 at 5:10:06 PM UTC+5:30, Aakash Bachheriya wrote:
>
> Which type of Questions are generally asked during Django interview?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/b2cba696-c500-4d89-90e9-3e198a3d1d28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Migration of Django to AWS Server

2019-04-22 Thread Davin Pore
May i know to transfer a django  file to AWS server

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


Genetic Algorithm for generating timetable

2019-04-22 Thread brittocj
How to implement genetic algorithm in Django to develop a web application 
for timetable generation?

-- 
You received this message because you are subscribed to the Google Groups 
"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/66b48364-c769-4c68-a2a2-29efb77d13a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django test

2019-04-22 Thread Elber Tavares
Test 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/20190421230217.7EDA0C248C%40localhost.
For more options, visit https://groups.google.com/d/optout.


Django interview Questions

2019-04-22 Thread Aakash Bachheriya
Which type of Questions are generally asked during Django interview?

-- 
You received this message because you are subscribed to the Google Groups 
"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/3f74a649-179f-4167-8767-6479fb6ed787%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


models and forms

2019-04-22 Thread Shereyne Casimsiman
I am current making a project and django is very new to me, I've been 
following tutorials but it did not answer my concern..
My project is to build a quiz that will have an audio as the question . I 
already installed  the django-audiofield and successfully added it into the 
admin but my problem is that I don't know how to show it in the templates 
please help me ... I am running out of time  

-- 
You received this message because you are subscribed to the Google Groups 
"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/7bde61fb-7479-4c7a-a9a4-b8c88f06f6e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Generate PDF using reportlab and write to s3 bucket without saving locally

2019-04-22 Thread Danny Blaker
I'm trying to generate a PDF using reportlab and write to s3 bucket without 
saving locally

I know I'm missing something simple:

# create a stream
stream = io.BytesIO()

# generate PDF
doc = SimpleDocTemplate(stream, pagesize=letter,
rightMargin=72, leftMargin=72,
topMargin=72, bottomMargin=18)
Story = []

styles = getSampleStyleSheet()

Story.append(Paragraph('This is a PDF', 
styles["Normal"]))

doc.build(Story)

# get buffer
pdf_buffer = stream.getbuffer()

filename = "new.pdf"
bucket_name = 'insert_bucket_name'
object_name = bucket_name

# here is where I get stuck - how should be passing the pdf_buffer to s3?

# how you typically write to s3 :
# Method 1

s3 = boto3.client('s3')
with open(filename, "rb") as f:
s3.upload_fileobj(f, bucket_name, object_name)

# Method 2
s3.Bucket(bucket_name).put_object(Key=filename, Body=file)

Any ideas most appreciated!

Thanks!

here are some related resources:

https://stackoverflow.com/questions/43373006/django-reportlab-save-generated-pdf-directly-to-filefield-in-aws-s3
https://sciwiki.fredhutch.org/compdemos/aws-python/#about-pandas-and-dask
https://stackoverflow.com/questions/12570465/how-to-upload-a-file-to-s3-without-creating-a-temporary-local-file

-- 
You received this message because you are subscribed to the Google Groups 
"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/aea27da8-0c37-4e4e-9f0a-929ca85e34bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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

2019-04-22 Thread Balaji Shetty
Dear Gaurav Sir

I am very much thankful to you for your reply to my query.

My questions is *How can i make  the customization in Django Admin Panel
itself to implement necessary logic after user of particular department do
the login.( How and where to embed proposed Logic
T1.objects.filter(user=current_user, department=current_user.department)*

If i design separate pages for login using templates and showing necessary
content user-wise (Login wise),
Your suggested logic will definitely work  (after making necessary changes
in schema)



On Sun, Apr 21, 2019 at 11:00 AM Gourav Chawla <
gauravchawla.chawla...@gmail.com> wrote:

> First of all, use appropriate model fields for linking objects. For
> example users should be a foreign key to your(or Django's) user table.
>
> Then whenever you want to show data on any interface to any user, just
> filter content/rows by user department.
>
> Something like:
>
> T1.objects.filter(user=current_user, department=current_user.department)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a4484706-2f3a-488c-a28c-41f78e2f42ca%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 


*Mr. Shetty Balaji S.Asst. ProfessorDepartment of Information Technology,*
*SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.India*
*Official: bsshe...@sggs.ac.in  *
*  Mobile: +91-9270696267*

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