Printing to console from async method inside django channels

2018-03-08 Thread Chris Barry
I'm trying to print inside these methods in from this example in django 
channels:

https://github.com/andrewgodwin/channels-examples/blob/master/multichat/chat/consumers.py

But nothing is coming through to the console.

I haven't worked with python Async before, so I'm not sure if I'm doing 
something really stupid? The examples in the python docs seem to show 
prints working no problem

-- 
You received this message because you are subscribed to the Google Groups 
"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/abc849e2-11fe-49ca-a936-7dfaf5b811b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Trouble deploying Django (project folder, wsgi.py and libapache2-mod-wsgi)

2018-03-08 Thread Jason
you need to use libapache2-mod-wsgi-py3, since the package you used is for 
python2 only

On Thursday, March 8, 2018 at 1:23:44 PM UTC-5, drone4four wrote:
>
> I’m having some issues deploying Django.
>
>
> Here is my site: https://daniel496.agency/ 
>
>
> I’m running a Digital Ocean Droplet with Ubuntu 14.04 and Python v3.4 with 
> Django 2.0.2 installed.
>
>
> In this post first I share what errors I am encountering, then what I 
> think is the issue is and then what I’ve tried to resolve the issue.  At 
> the end of this post are my configuration files like ssl.conf and wsgi.py.
>
>
> Before I begin, I think the issue might involve the naming of my project 
> folders. My project folder on my local machine is named: 
> `first_project_attempt`.  But on my remote server, the project folder is 
> named, `cel2fah`. I copied the contents locally to my remote host and now 
> trying to iron out the issues.
>
>
> Here I go.  If you access my site linked to above, right now it is showing:
>
>
> Internal Server Error
>> The server encountered an internal error or misconfiguration and was 
>> unable to complete your request.
>> Please contact the server administrator at @gmail.com to inform 
>> them of the time this error occurred, and the actions you performed just 
>> before this error.
>> More information about this error may be available in the server error 
>> log.
>> Apache/2.4.7 (Ubuntu) Server at daniel496.agency Port 443
>
>
> Here are the last ~50 lines of my apache error log file: 
> https://pastebin.com/UPsTmf28 
>
>
> I’m thinking that there could be a potential conflict between 
> libapache2-mod-wsgi and libapache2-mod-wsgi-py3.  I encountered a similar 
> issue a few weeks ago. There are apparently still traces of 
> libapache2-mod-wsgi (for Python 2.7) still flagged as active on my system 
> given that $ sudo dpkg -s libapache2-mod-wsgi prints:
>
>
> Package: libapache2-mod-wsgi
>> Status: deinstall ok config-files
>> Priority: optional
>> Section: httpd
>> Installed-Size: 242
>> Maintainer: Ubuntu Developers > >
>> Architecture: amd64
>> Source: mod-wsgi
>> Version: 3.4-4ubuntu2.1.14.04.2
>> Config-Version: 3.4-4ubuntu2.1.14.04.2
>> Provides: httpd-wsgi
>> Depends: libc6 (>= 2.14), libpython2.7 (>= 2.7), apache2-api-20120211, 
>> python (>= 2.7), python (<< 2.8)
>> Conffiles:
>> /etc/apache2/mods-available/wsgi.load 06d2b4d2c95b28720f324bd650b7cbd6 
>> obsolete
>> /etc/apache2/mods-available/wsgi.conf c4ca5be35d0820b5d5cc2892097b476b 
>> obsolete
>> Description: Python WSGI adapter module for Apache
>> The mod_wsgi adapter is an Apache module that provides a WSGI (Web Server
>> Gateway Interface, a standard interface between web server software and
>> web applications written in Python) compliant interface for hosting Python
>> based web applications within Apache. The adapter provides significantly
>> better performance than using existing WSGI adapters for mod_python or 
>> CGI.
>> .
>> This package provides module for Python 2.X.
>> Homepage: http://www.modwsgi.org/
>> Original-Maintainer: Debian Python Modules Team <
>> python-mo...@lists.alioth.debian.org >
>
>
> However when I go to remove it, it says it’s not installed:
>
>
> $ sudo apt remove libapache2-mod-wsgi
>> Reading package lists... Done
>> Building dependency tree   
>> Reading state information... Done
>> Package 'libapache2-mod-wsgi' is not installed, so not removed
>> 0 upgraded, 0 newly installed, 0 to remove and 44 not upgraded.
>
>
> More to the point, when invoking this as root:
>
>
> apache2ctl -t -D DUMP_MODULES
>
>
> ...it lists what modules apache2 has loaded. And libapache2-mod-wsgi (for 
> Python version 2) is included.  So I Google ‘how to remove apache modules’ 
> which turns up this SO post: 
> https://stackoverflow.com/questions/9288865/how-can-i-uninstall-an-apache2-module
>
> So I set out to rename my libapache2-mod-wsgi.so (for Python version 2) 
> from my apache2 modules directory inside /usr/lib. I see a symlink 
> mod_wsgi.so which refers to mod_wsgi.so-3.4:
>
>
> @:/usr/lib/apache2/modules$ ls -la mod_wsgi*
>> lrwxrwxrwx 1 root root 15 Nov 18 2014 mod_wsgi.so -> mod_wsgi.so-3.4
>> -rw-r--r-- 1 root root 174448 Nov 18  2014 mod_wsgi.so-3.4
>> @:/usr/lib/apache2/modules$ 
>
>
> So is my Apache serving the libapache2-mod-wsgi module for python2 or just 
> for python3 or what?
>
>
> What else can you people determine could be the issue here?
>
>
> Here is my wsgi.py:
>
>> """
>> WSGI config for first_project_attempt project.
>> It exposes the WSGI callable as a module-level variable named 
>> ``application``.
>> For more information on this file, see
>> https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
>> """
>> import os
>> import sys
>> from django.core.wsgi import get_wsgi_application
>> sys.path.append('/home/tranq/cel2fah/cel2fah')
>> # NEW:
>> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cel2fah.settings")
>> # OLD:
>> # os.environ.setdefault("DJANGO_SETTINGS_MODULE", 
>> "first_proj

Re: Reverse for 'detail' with arguments '('',)' not found. 1 pattern(s) tried: ['(?P[0-9]+)/$']

2018-03-08 Thread anyi.ll...@gmail.com
Ok i will try out the second one you gave now. Thanks 

Sent from my HTC

- Reply message -
From: "Andy" 
To: "Django users" 
Subject: Reverse for 'detail' with arguments '('',)' not found. 1 pattern(s) 
tried: ['(?P[0-9]+)/$']
Date: Thu, Mar 8, 2018 20:00

which one of your calls to detail are failing?orreverse('student:detail', kwargs={'pk': self.pk})?
if its the second one, try with args=[self.pk]
Am Donnerstag, 8. März 2018 19:48:44 UTC+1 schrieb anyi.lloyd:
Yes it is named profile.




- Reply message -
From: "Andy Grabow" 
To: 
Subject: Reverse for 'detail' with arguments '('',)' not found. 1 pattern(s) 
tried: ['(?P[0-9]+)/$']
Date: Thu, Mar 8, 2018 05:18

Well, is it actually named profile inside the view? Rather than the default 
original? Check if the name is right and your profile is named profile in the 
template. 

anyi@gmail.com  schrieb am Mi. 7. März 2018 um 20:15:

The profile already have an id. Just wanted to add to an existing profile in 
the db with generic view.





- Reply message -
From: "Andy" 
To: "Django users" 
Subject: Reverse for 'detail' with arguments '('',)' not found. 1 pattern(s) 
tried: ['(?P[0-9]+)/$']
Date: Wed, Mar 7, 2018 11:08

If you actually are inside the profile create view, the profile probably does 
not have an id yet and thats why the url lookup is failing. The ID will be 
created on first save of the object.

Am Dienstag, 6. März 2018 00:11:53 UTC+1 schrieb anyi.lloyd:Am new to Django, 
please i need help here. Am trying to add a subject into a particular id using 
generic CreatView, i keeping getting errors
Reverse for 'detail' with arguments '('',)' not found. 1 pattern(s) tried: 
['(?P[0-9]+)/$']

models.py
from django.db import models
from datetime import date
from django.core.urlresolvers import reverse
from django.shortcuts import redirect


class Profile(models.Model):
firstName = models.CharField(max_length=30)
middleName = models.CharField(max_length=30)
lastName = models.CharField(max_length=30)
dob = models.DateField(blank=True, null=True)
stud_id = models.CharField(max_length=5000)
gender = models.CharField(max_length=10)
parentsName =models.CharField(max_length=30)
address = models.CharField(max_length=250)
lga = models.CharField(max_length=250)
Religion = models.CharField(max_length=50)
email = models.EmailField(max_length=70, null=True, blank=True, unique=True)
phone = models.CharField(max_length=11, unique=True)
photo = models.FileField()
Comment = models.CharField(max_length=250)

def get_absolute_url(self):
return reverse('student:detail', kwargs={'pk': self.pk})

def __str__(self):
return self.firstName

class Course(models.Model):
profile = models.ForeignKey(Profile, on_delete=models.CASCADE, null=True)
subject = models.CharField(max_length=20)
score = models.CharField(max_length=20)
grade = models.CharField(max_length=20)

def get_absolute_url(self,):
return reverse('student:detail', kwargs={'pk': self.pk})

views.pyfrom django.views import generic
from django.views.generic import View
from django.views.generic.edit import CreateView, UpdateView, DeleteView
from django.core.urlresolvers import reverse_lazy, reverse
from django.shortcuts import render, redirect
from django.contrib.auth import authenticate, login
from .models import Profile, Course
from .forms import UserForm



#Index view
class IndexView(generic.ListView):
template_name = 'student/index.html'
context_object_name = 'all_profile'

def get_queryset(self):
return Profile.objects.all()

#Detail view
class DetailView(generic.DetailView):
model = Profile
template_name = 'student/detail.html'

#Add student section
class ProfileCreate(generic.CreateView):
model = Profile
fields = ['firstName', 'middleName', 'lastName', 'dob', 'gender', 
'parentsName', 'address',
'lga', 'Religion', 'email', 'phone', 'photo']

#Add Subject section
class CourseCreate(CreateView):
model = Course
fields = ['subject', 'score', 'grade']


def get_form_kwargs(self):
kwargs = super(CourseCreate, self).get_form_kwargs()
kwargs['instance'] = Course(pk=self.kwargs['pk'])
return kwargs
urls.py
urlpatterns = [
#index url
url(r'^$', views.IndexView.as_view(), name='index'),

url(r'^signup/$', views.UserFormView.as_view(), name='signup'),
#details
url(r'^(?P[0-9]+)/$', views.DetailView.as_view(), name='detail'),
#profile/add
url(r'^profile/add/$', views.ProfileCreate.as_view(), name='profile-add'),
#course/add
url(r'^(?P[0-9]+)/course_form/$', views.CourseCreate.as_view(), 
name='course_form'),
#profile/pk for update
url(r'^profile/(?P[0-9]+)/$', views.ProfileUpdate.as_view(), 
name='profile-update'),
#profile/pk for deleting
url(r'^profile/(?P[0-9]+)/delete/$', views.ProfileDelete.as_view(), 
name='profile-delete'),
]

template{% extends 'student/base.html' %}
{% block title %}{% endblock %}

{% block body %}







{{profile.lastName}} {{profile.firstName}}



{% if profile.photo %}

{% else %}
No image to display
{% endif %}








View 
All
Add New Song




Add Subject


Add Sub

Re: Reverse for 'detail' with arguments '('',)' not found. 1 pattern(s) tried: ['(?P[0-9]+)/$']

2018-03-08 Thread anyi.ll...@gmail.com
This 
But my views on the section of adding subject, please is it correct.

- Reply message -
From: "Andy" 
To: "Django users" 
Subject: Reverse for 'detail' with arguments '('',)' not found. 1 pattern(s) 
tried: ['(?P[0-9]+)/$']
Date: Thu, Mar 8, 2018 20:00

which one of your calls to detail are failing?orreverse('student:detail', kwargs={'pk': self.pk})?
if its the second one, try with args=[self.pk]
Am Donnerstag, 8. März 2018 19:48:44 UTC+1 schrieb anyi.lloyd:
Yes it is named profile.




- Reply message -
From: "Andy Grabow" 
To: 
Subject: Reverse for 'detail' with arguments '('',)' not found. 1 pattern(s) 
tried: ['(?P[0-9]+)/$']
Date: Thu, Mar 8, 2018 05:18

Well, is it actually named profile inside the view? Rather than the default 
original? Check if the name is right and your profile is named profile in the 
template. 

anyi@gmail.com  schrieb am Mi. 7. März 2018 um 20:15:

The profile already have an id. Just wanted to add to an existing profile in 
the db with generic view.





- Reply message -
From: "Andy" 
To: "Django users" 
Subject: Reverse for 'detail' with arguments '('',)' not found. 1 pattern(s) 
tried: ['(?P[0-9]+)/$']
Date: Wed, Mar 7, 2018 11:08

If you actually are inside the profile create view, the profile probably does 
not have an id yet and thats why the url lookup is failing. The ID will be 
created on first save of the object.

Am Dienstag, 6. März 2018 00:11:53 UTC+1 schrieb anyi.lloyd:Am new to Django, 
please i need help here. Am trying to add a subject into a particular id using 
generic CreatView, i keeping getting errors
Reverse for 'detail' with arguments '('',)' not found. 1 pattern(s) tried: 
['(?P[0-9]+)/$']

models.py
from django.db import models
from datetime import date
from django.core.urlresolvers import reverse
from django.shortcuts import redirect


class Profile(models.Model):
firstName = models.CharField(max_length=30)
middleName = models.CharField(max_length=30)
lastName = models.CharField(max_length=30)
dob = models.DateField(blank=True, null=True)
stud_id = models.CharField(max_length=5000)
gender = models.CharField(max_length=10)
parentsName =models.CharField(max_length=30)
address = models.CharField(max_length=250)
lga = models.CharField(max_length=250)
Religion = models.CharField(max_length=50)
email = models.EmailField(max_length=70, null=True, blank=True, unique=True)
phone = models.CharField(max_length=11, unique=True)
photo = models.FileField()
Comment = models.CharField(max_length=250)

def get_absolute_url(self):
return reverse('student:detail', kwargs={'pk': self.pk})

def __str__(self):
return self.firstName

class Course(models.Model):
profile = models.ForeignKey(Profile, on_delete=models.CASCADE, null=True)
subject = models.CharField(max_length=20)
score = models.CharField(max_length=20)
grade = models.CharField(max_length=20)

def get_absolute_url(self,):
return reverse('student:detail', kwargs={'pk': self.pk})

views.pyfrom django.views import generic
from django.views.generic import View
from django.views.generic.edit import CreateView, UpdateView, DeleteView
from django.core.urlresolvers import reverse_lazy, reverse
from django.shortcuts import render, redirect
from django.contrib.auth import authenticate, login
from .models import Profile, Course
from .forms import UserForm



#Index view
class IndexView(generic.ListView):
template_name = 'student/index.html'
context_object_name = 'all_profile'

def get_queryset(self):
return Profile.objects.all()

#Detail view
class DetailView(generic.DetailView):
model = Profile
template_name = 'student/detail.html'

#Add student section
class ProfileCreate(generic.CreateView):
model = Profile
fields = ['firstName', 'middleName', 'lastName', 'dob', 'gender', 
'parentsName', 'address',
'lga', 'Religion', 'email', 'phone', 'photo']

#Add Subject section
class CourseCreate(CreateView):
model = Course
fields = ['subject', 'score', 'grade']


def get_form_kwargs(self):
kwargs = super(CourseCreate, self).get_form_kwargs()
kwargs['instance'] = Course(pk=self.kwargs['pk'])
return kwargs
urls.py
urlpatterns = [
#index url
url(r'^$', views.IndexView.as_view(), name='index'),

url(r'^signup/$', views.UserFormView.as_view(), name='signup'),
#details
url(r'^(?P[0-9]+)/$', views.DetailView.as_view(), name='detail'),
#profile/add
url(r'^profile/add/$', views.ProfileCreate.as_view(), name='profile-add'),
#course/add
url(r'^(?P[0-9]+)/course_form/$', views.CourseCreate.as_view(), 
name='course_form'),
#profile/pk for update
url(r'^profile/(?P[0-9]+)/$', views.ProfileUpdate.as_view(), 
name='profile-update'),
#profile/pk for deleting
url(r'^profile/(?P[0-9]+)/delete/$', views.ProfileDelete.as_view(), 
name='profile-delete'),
]

template{% extends 'student/base.html' %}
{% block title %}{% endblock %}

{% block body %}







{{profile.lastName}} {{profile.firstName}}



{% if profile.photo %}

{% else %}
No image to display
{% endif %}








View 
All
Add New Song




Add Subject


Add S

Re: Reverse for 'detail' with arguments '('',)' not found. 1 pattern(s) tried: ['(?P[0-9]+)/$']

2018-03-08 Thread Andy
which one of your calls to detail are failing?



or

reverse('student:detail', kwargs={'pk': self.pk})

?


if its the second one, try with args=[self.pk]


Am Donnerstag, 8. März 2018 19:48:44 UTC+1 schrieb anyi.lloyd:
>
> Yes it is named profile.
>
> - Reply message -
> From: "Andy Grabow" >
> To: >
> Subject: Reverse for 'detail' with arguments '('',)' not found. 1 
> pattern(s) tried: ['(?P[0-9]+)/$']
> Date: Thu, Mar 8, 2018 05:18
>
> Well, is it actually named profile inside the view? Rather than the 
> default original? Check if the name is right and your profile is named 
> profile in the template. 
>
> anyi@gmail.com  > 
> schrieb am Mi. 7. März 2018 um 20:15:
>
>> The profile already have an id. Just wanted to add to an existing profile 
>> in the db with generic view.
>>
>>
>> - Reply message -
>> From: "Andy" >
>> To: "Django users" >
>> Subject: Reverse for 'detail' with arguments '('',)' not found. 1 
>> pattern(s) tried: ['(?P[0-9]+)/$']
>> Date: Wed, Mar 7, 2018 11:08
>>
>> If you actually are inside the profile create view, the profile probably 
>> does not have an id yet and thats why the url lookup is failing. The ID 
>> will be created on first save of the object.
>>
>> Am Dienstag, 6. März 2018 00:11:53 UTC+1 schrieb anyi.lloyd:
>>>
>>> Am new to Django, please i need help here. Am trying to add a subject 
>>> into a particular id using generic CreatView, i keeping getting errors
>>> Reverse for 'detail' with arguments '('',)' not found. 1 pattern(s) 
>>> tried: ['(?P[0-9]+)/$']
>>>
>>> models.py
>>>
>>> from django.db import models
>>> from datetime import date
>>> from django.core.urlresolvers import reverse
>>> from django.shortcuts import redirect
>>>
>>>
>>> class Profile(models.Model):
>>> firstName = models.CharField(max_length=30)
>>> middleName = models.CharField(max_length=30)
>>> lastName = models.CharField(max_length=30)
>>> dob = models.DateField(blank=True, null=True)
>>> stud_id = models.CharField(max_length=5000)
>>> gender = models.CharField(max_length=10)
>>> parentsName =models.CharField(max_length=30)
>>> address = models.CharField(max_length=250)
>>> lga = models.CharField(max_length=250)
>>> Religion = models.CharField(max_length=50)
>>> email = models.EmailField(max_length=70, null=True, blank=True, 
>>> unique=True)
>>> phone = models.CharField(max_length=11, unique=True)
>>> photo = models.FileField()
>>> Comment = models.CharField(max_length=250)
>>>
>>> def get_absolute_url(self):
>>> return reverse('student:detail', kwargs={'pk': self.pk})
>>>
>>> def __str__(self):
>>> return self.firstName
>>>
>>> class Course(models.Model):
>>> profile = models.ForeignKey(Profile, on_delete=models.CASCADE, 
>>> null=True)
>>> subject = models.CharField(max_length=20)
>>> score = models.CharField(max_length=20)
>>> grade = models.CharField(max_length=20)
>>>
>>> def get_absolute_url(self,):
>>> return reverse('student:detail', kwargs={'pk': self.pk})
>>>
>>> views.py
>>>
>>> from django.views import generic
>>> from django.views.generic import View
>>> from django.views.generic.edit import CreateView, UpdateView, DeleteView
>>> from django.core.urlresolvers import reverse_lazy, reverse
>>> from django.shortcuts import render, redirect
>>> from django.contrib.auth import authenticate, login
>>> from .models import Profile, Course
>>> from .forms import UserForm
>>>
>>>
>>>
>>> #Index view
>>> class IndexView(generic.ListView):
>>> template_name = 'student/index.html'
>>> context_object_name = 'all_profile'
>>>
>>> def get_queryset(self):
>>> return Profile.objects.all()
>>>
>>> #Detail view
>>> class DetailView(generic.DetailView):
>>> model = Profile
>>> template_name = 'student/detail.html'
>>>
>>> #Add student section
>>> class ProfileCreate(generic.CreateView):
>>> model = Profile
>>> fields = ['firstName', 'middleName', 'lastName', 'dob', 'gender', 
>>> 'parentsName', 'address',
>>>   'lga', 'Religion', 'email', 'phone', 'photo']
>>>
>>> #Add Subject section
>>> class CourseCreate(CreateView):
>>> model = Course
>>> fields = ['subject', 'score', 'grade']
>>>
>>>
>>> def get_form_kwargs(self):
>>> kwargs = super(CourseCreate, self).get_form_kwargs()
>>> kwargs['instance'] = Course(pk=self.kwargs['pk'])
>>> return kwargs
>>>
>>>
>>> urls.py
>>>
>>>
>>> urlpatterns = [
>>> #index url
>>> url(r'^$', views.IndexView.as_view(), name='index'),
>>>
>>> url(r'^signup/$', views.UserFormView.as_view(), name='signup'),
>>> #details
>>> url(r'^(?P[0-9]+)/$', views.DetailView.as_view(), name='detail'),
>>> #profile/add
>>> url(r'^profile/add/$', views.ProfileCreate.as_view(), 
>>> name='profile-add'),
>>> #course/add
>>> url(r'^(?P[0-9]+)/course_form/$', views.CourseCreate.as_view(), 
>>> name='course_form'),
>>>  

Re: Reverse for 'detail' with arguments '('',)' not found. 1 pattern(s) tried: ['(?P[0-9]+)/$']

2018-03-08 Thread anyi.ll...@gmail.com
Yes it is named profile.

- Reply message -
From: "Andy Grabow" 
To: 
Subject: Reverse for 'detail' with arguments '('',)' not found. 1 pattern(s) 
tried: ['(?P[0-9]+)/$']
Date: Thu, Mar 8, 2018 05:18

Well, is it actually named profile inside the view? Rather than the default 
original? Check if the name is right and your profile is named profile in the 
template. 

anyi.ll...@gmail.com  schrieb am Mi. 7. März 2018 um 
20:15:

The profile already have an id. Just wanted to add to an existing profile in 
the db with generic view.





- Reply message -
From: "Andy" 
To: "Django users" 
Subject: Reverse for 'detail' with arguments '('',)' not found. 1 pattern(s) 
tried: ['(?P[0-9]+)/$']
Date: Wed, Mar 7, 2018 11:08

If you actually are inside the profile create view, the profile probably does 
not have an id yet and thats why the url lookup is failing. The ID will be 
created on first save of the object.

Am Dienstag, 6. März 2018 00:11:53 UTC+1 schrieb anyi.lloyd:Am new to Django, 
please i need help here. Am trying to add a subject into a particular id using 
generic CreatView, i keeping getting errors
Reverse for 'detail' with arguments '('',)' not found. 1 pattern(s) tried: 
['(?P[0-9]+)/$']

models.py
from django.db import models
from datetime import date
from django.core.urlresolvers import reverse
from django.shortcuts import redirect


class Profile(models.Model):
firstName = models.CharField(max_length=30)
middleName = models.CharField(max_length=30)
lastName = models.CharField(max_length=30)
dob = models.DateField(blank=True, null=True)
stud_id = models.CharField(max_length=5000)
gender = models.CharField(max_length=10)
parentsName =models.CharField(max_length=30)
address = models.CharField(max_length=250)
lga = models.CharField(max_length=250)
Religion = models.CharField(max_length=50)
email = models.EmailField(max_length=70, null=True, blank=True, unique=True)
phone = models.CharField(max_length=11, unique=True)
photo = models.FileField()
Comment = models.CharField(max_length=250)

def get_absolute_url(self):
return reverse('student:detail', kwargs={'pk': self.pk})

def __str__(self):
return self.firstName

class Course(models.Model):
profile = models.ForeignKey(Profile, on_delete=models.CASCADE, null=True)
subject = models.CharField(max_length=20)
score = models.CharField(max_length=20)
grade = models.CharField(max_length=20)

def get_absolute_url(self,):
return reverse('student:detail', kwargs={'pk': self.pk})

views.pyfrom django.views import generic
from django.views.generic import View
from django.views.generic.edit import CreateView, UpdateView, DeleteView
from django.core.urlresolvers import reverse_lazy, reverse
from django.shortcuts import render, redirect
from django.contrib.auth import authenticate, login
from .models import Profile, Course
from .forms import UserForm



#Index view
class IndexView(generic.ListView):
template_name = 'student/index.html'
context_object_name = 'all_profile'

def get_queryset(self):
return Profile.objects.all()

#Detail view
class DetailView(generic.DetailView):
model = Profile
template_name = 'student/detail.html'

#Add student section
class ProfileCreate(generic.CreateView):
model = Profile
fields = ['firstName', 'middleName', 'lastName', 'dob', 'gender', 
'parentsName', 'address',
'lga', 'Religion', 'email', 'phone', 'photo']

#Add Subject section
class CourseCreate(CreateView):
model = Course
fields = ['subject', 'score', 'grade']


def get_form_kwargs(self):
kwargs = super(CourseCreate, self).get_form_kwargs()
kwargs['instance'] = Course(pk=self.kwargs['pk'])
return kwargs
urls.py
urlpatterns = [
#index url
url(r'^$', views.IndexView.as_view(), name='index'),

url(r'^signup/$', views.UserFormView.as_view(), name='signup'),
#details
url(r'^(?P[0-9]+)/$', views.DetailView.as_view(), name='detail'),
#profile/add
url(r'^profile/add/$', views.ProfileCreate.as_view(), name='profile-add'),
#course/add
url(r'^(?P[0-9]+)/course_form/$', views.CourseCreate.as_view(), 
name='course_form'),
#profile/pk for update
url(r'^profile/(?P[0-9]+)/$', views.ProfileUpdate.as_view(), 
name='profile-update'),
#profile/pk for deleting
url(r'^profile/(?P[0-9]+)/delete/$', views.ProfileDelete.as_view(), 
name='profile-delete'),
]

template{% extends 'student/base.html' %}
{% block title %}{% endblock %}

{% block body %}







{{profile.lastName}} {{profile.firstName}}



{% if profile.photo %}

{% else %}
No image to display
{% endif %}








View 
All
Add New Song




Add Subject


Add Subject
{% if error_message %}
{{ error_message }}
{% endif %}

{% csrf_token %}

{% include 'student/form-profile-temp.html' %}


Submit











{% endblock %}






-- 

You received this message because you are subscribed to a topic in the Google 
Groups "Django users" group.

To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/django-users/By5BEzS0ZJE/unsubscribe.

To unsubscribe from this group and all its topics, send an email to 
django-users+

Trouble deploying Django (project folder, wsgi.py and libapache2-mod-wsgi)

2018-03-08 Thread drone4four


I’m having some issues deploying Django.


Here is my site: https://daniel496.agency/ 


I’m running a Digital Ocean Droplet with Ubuntu 14.04 and Python v3.4 with 
Django 2.0.2 installed.


In this post first I share what errors I am encountering, then what I think 
is the issue is and then what I’ve tried to resolve the issue.  At the end 
of this post are my configuration files like ssl.conf and wsgi.py.


Before I begin, I think the issue might involve the naming of my project 
folders. My project folder on my local machine is named: 
`first_project_attempt`.  But on my remote server, the project folder is 
named, `cel2fah`. I copied the contents locally to my remote host and now 
trying to iron out the issues.


Here I go.  If you access my site linked to above, right now it is showing:


Internal Server Error
> The server encountered an internal error or misconfiguration and was 
> unable to complete your request.
> Please contact the server administrator at @gmail.com to inform them 
> of the time this error occurred, and the actions you performed just before 
> this error.
> More information about this error may be available in the server error log.
> Apache/2.4.7 (Ubuntu) Server at daniel496.agency Port 443


Here are the last ~50 lines of my apache error log file: 
https://pastebin.com/UPsTmf28 


I’m thinking that there could be a potential conflict between 
libapache2-mod-wsgi and libapache2-mod-wsgi-py3.  I encountered a similar 
issue a few weeks ago. There are apparently still traces of 
libapache2-mod-wsgi (for Python 2.7) still flagged as active on my system 
given that $ sudo dpkg -s libapache2-mod-wsgi prints:


Package: libapache2-mod-wsgi
> Status: deinstall ok config-files
> Priority: optional
> Section: httpd
> Installed-Size: 242
> Maintainer: Ubuntu Developers 
> Architecture: amd64
> Source: mod-wsgi
> Version: 3.4-4ubuntu2.1.14.04.2
> Config-Version: 3.4-4ubuntu2.1.14.04.2
> Provides: httpd-wsgi
> Depends: libc6 (>= 2.14), libpython2.7 (>= 2.7), apache2-api-20120211, 
> python (>= 2.7), python (<< 2.8)
> Conffiles:
> /etc/apache2/mods-available/wsgi.load 06d2b4d2c95b28720f324bd650b7cbd6 
> obsolete
> /etc/apache2/mods-available/wsgi.conf c4ca5be35d0820b5d5cc2892097b476b 
> obsolete
> Description: Python WSGI adapter module for Apache
> The mod_wsgi adapter is an Apache module that provides a WSGI (Web Server
> Gateway Interface, a standard interface between web server software and
> web applications written in Python) compliant interface for hosting Python
> based web applications within Apache. The adapter provides significantly
> better performance than using existing WSGI adapters for mod_python or CGI.
> .
> This package provides module for Python 2.X.
> Homepage: http://www.modwsgi.org/
> Original-Maintainer: Debian Python Modules Team 
> 


However when I go to remove it, it says it’s not installed:


$ sudo apt remove libapache2-mod-wsgi
> Reading package lists... Done
> Building dependency tree   
> Reading state information... Done
> Package 'libapache2-mod-wsgi' is not installed, so not removed
> 0 upgraded, 0 newly installed, 0 to remove and 44 not upgraded.


More to the point, when invoking this as root:


apache2ctl -t -D DUMP_MODULES


...it lists what modules apache2 has loaded. And libapache2-mod-wsgi (for 
Python version 2) is included.  So I Google ‘how to remove apache modules’ 
which turns up this SO post: 
https://stackoverflow.com/questions/9288865/how-can-i-uninstall-an-apache2-module

So I set out to rename my libapache2-mod-wsgi.so (for Python version 2) 
from my apache2 modules directory inside /usr/lib. I see a symlink 
mod_wsgi.so which refers to mod_wsgi.so-3.4:


@:/usr/lib/apache2/modules$ ls -la mod_wsgi*
> lrwxrwxrwx 1 root root 15 Nov 18 2014 mod_wsgi.so -> mod_wsgi.so-3.4
> -rw-r--r-- 1 root root 174448 Nov 18  2014 mod_wsgi.so-3.4
> @:/usr/lib/apache2/modules$ 


So is my Apache serving the libapache2-mod-wsgi module for python2 or just 
for python3 or what?


What else can you people determine could be the issue here?


Here is my wsgi.py:

> """
> WSGI config for first_project_attempt project.
> It exposes the WSGI callable as a module-level variable named 
> ``application``.
> For more information on this file, see
> https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
> """
> import os
> import sys
> from django.core.wsgi import get_wsgi_application
> sys.path.append('/home/tranq/cel2fah/cel2fah')
> # NEW:
> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cel2fah.settings")
> # OLD:
> # os.environ.setdefault("DJANGO_SETTINGS_MODULE", 
> "first_project_attempt.settings")


application = get_wsgi_application()

And my ssl.conf:



>
> 
>ServerAdmin @gmail.com
>ServerName daniel496.agency
>ServerAlias www.daniel496.agency
> #   DocumentRoot /var/www/html/daniel496.agency/public_html
> #   ErrorLog ${APACHE_LOG_DIR}/error.log
>ErrorLog ${APACHE_LOG_DIR}/daniel496/error.log
>Cu

Re: how to do inner join using 3 tables

2018-03-08 Thread Simon Charette
Hello Angel,

Did you try the following

transaction = Transaction.objects.filter(
user=user,
status=F('detail__status'),
).first()

Best,
Simon

Le jeudi 8 mars 2018 09:52:44 UTC-5, Angel Rojas a écrit :
>
> Hello friends, I have a little problem with a relationship with 3 tables
>
> tables
> - User
> - Transaction
> - TransactionDetail
>
> my query is
>
> class TransactionInitiated(generics.ListAPIView):
> """
> List Transaction Initiated
> """
> serializer_class = TransactionSerializer
>
> def get_object(self, pk):
> user = User.objects.get(id=pk)
> transaction = Transaction.objects.filter(user_id=user.id, 
> current_status=0)
> # Transactiondetail.objects.filter(transaction_id=transaction.id, 
> status=0)
> return Transaction.objects.filter(user_id=user.id, 
> current_status=0).order_by('-id')
>
> def get(self, request, pk, format=None):
> current_user = request.user
> list_trans_init = self.get_object(current_user.id)
> serializer = TransactionSerializer(list_trans_init, many=True)
> return JsonResponse({'data': serializer.data}, safe=False)
>
>
> with this query I recovery all user with a respective transaction, but I 
> don't how to use inner join in here, I try next
>
>
> def get_object(self, pk):
> user = User.objects.get(id=pk)
> transaction = Transaction.objects.filter(user_id=user.id, 
> current_status=0)
> return Transaction_Detail.objects.filter(transaction_id=transaction, 
> status=0)
>
>
> in here return me the next error
>
>
> more than one row returned by a subquery used as an expression.
>
>
>
> please some help me.
>
>
> thanks for your attention.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/5b5505c0-5e15-4c35-b141-3a566cda6726%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to do inner join using 3 tables

2018-03-08 Thread Angel Rojas
thank you for your answer, but I need a next result

select * select User as u inner join transaction as tr on u.id=user_id.id 
inner join transactionDetail as trd on tr.id=trd.transaction_id
where tr.current_status=trd.status



please how can I do that


thanks for your attention.

 

On Thursday, March 8, 2018 at 1:25:00 PM UTC-2, C. Kirby wrote:
>
> As written it looks like you want to get all the 0 status transactions for 
> a given user, and then get all the transaction details for those 
> transactions (.filter allows for any number of results) Since your var 
> transaction is a list, and you really only care about the ids to pull the 
> transaction details, you should have your code like this:
>
> def get_object(self, pk):
> user = User.objects.get(id=pk)
> transactions = Transaction.objects.filter(user_id=user.id, 
> current_status=0).values_list('id', flat=True)
> return Transaction_Detail.objects.filter(transaction_id__in=
> transactions, status=0)
>
>
>
> On Thursday, March 8, 2018 at 9:52:44 AM UTC-5, Angel Rojas wrote:
>>
>> Hello friends, I have a little problem with a relationship with 3 tables
>>
>> tables
>> - User
>> - Transaction
>> - TransactionDetail
>>
>> my query is
>>
>> class TransactionInitiated(generics.ListAPIView):
>> """
>> List Transaction Initiated
>> """
>> serializer_class = TransactionSerializer
>>
>> def get_object(self, pk):
>> user = User.objects.get(id=pk)
>> transaction = Transaction.objects.filter(user_id=user.id, 
>> current_status=0)
>> # Transactiondetail.objects.filter(transaction_id=transaction.id, 
>> status=0)
>> return Transaction.objects.filter(user_id=user.id, 
>> current_status=0).order_by('-id')
>>
>> def get(self, request, pk, format=None):
>> current_user = request.user
>> list_trans_init = self.get_object(current_user.id)
>> serializer = TransactionSerializer(list_trans_init, many=True)
>> return JsonResponse({'data': serializer.data}, safe=False)
>>
>>
>> with this query I recovery all user with a respective transaction, but I 
>> don't how to use inner join in here, I try next
>>
>>
>> def get_object(self, pk):
>> user = User.objects.get(id=pk)
>> transaction = Transaction.objects.filter(user_id=user.id, 
>> current_status=0)
>> return Transaction_Detail.objects.filter(transaction_id=transaction, 
>> status=0)
>>
>>
>> in here return me the next error
>>
>>
>> more than one row returned by a subquery used as an expression.
>>
>>
>>
>> please some help me.
>>
>>
>> thanks for your attention.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"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/e8b0c942-178d-4dd0-95eb-a9a797663851%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to do inner join using 3 tables

2018-03-08 Thread C. Kirby
As written it looks like you want to get all the 0 status transactions for 
a given user, and then get all the transaction details for those 
transactions (.filter allows for any number of results) Since your var 
transaction is a list, and you really only care about the ids to pull the 
transaction details, you should have your code like this:

def get_object(self, pk):
user = User.objects.get(id=pk)
transactions = Transaction.objects.filter(user_id=user.id, 
current_status=0).values_list('id', flat=True)
return Transaction_Detail.objects.filter(transaction_id__in=transactions
, status=0)



On Thursday, March 8, 2018 at 9:52:44 AM UTC-5, Angel Rojas wrote:
>
> Hello friends, I have a little problem with a relationship with 3 tables
>
> tables
> - User
> - Transaction
> - TransactionDetail
>
> my query is
>
> class TransactionInitiated(generics.ListAPIView):
> """
> List Transaction Initiated
> """
> serializer_class = TransactionSerializer
>
> def get_object(self, pk):
> user = User.objects.get(id=pk)
> transaction = Transaction.objects.filter(user_id=user.id, 
> current_status=0)
> # Transactiondetail.objects.filter(transaction_id=transaction.id, 
> status=0)
> return Transaction.objects.filter(user_id=user.id, 
> current_status=0).order_by('-id')
>
> def get(self, request, pk, format=None):
> current_user = request.user
> list_trans_init = self.get_object(current_user.id)
> serializer = TransactionSerializer(list_trans_init, many=True)
> return JsonResponse({'data': serializer.data}, safe=False)
>
>
> with this query I recovery all user with a respective transaction, but I 
> don't how to use inner join in here, I try next
>
>
> def get_object(self, pk):
> user = User.objects.get(id=pk)
> transaction = Transaction.objects.filter(user_id=user.id, 
> current_status=0)
> return Transaction_Detail.objects.filter(transaction_id=transaction, 
> status=0)
>
>
> in here return me the next error
>
>
> more than one row returned by a subquery used as an expression.
>
>
>
> please some help me.
>
>
> thanks for your attention.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/7d8b7d7b-5dfc-4ba6-816a-294264f2020b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


how to do inner join using 3 tables

2018-03-08 Thread Angel Rojas
Hello friends, I have a little problem with a relationship with 3 tables

tables
- User
- Transaction
- TransactionDetail

my query is

class TransactionInitiated(generics.ListAPIView):
"""
List Transaction Initiated
"""
serializer_class = TransactionSerializer

def get_object(self, pk):
user = User.objects.get(id=pk)
transaction = Transaction.objects.filter(user_id=user.id, 
current_status=0)
# Transactiondetail.objects.filter(transaction_id=transaction.id, 
status=0)
return Transaction.objects.filter(user_id=user.id, 
current_status=0).order_by('-id')

def get(self, request, pk, format=None):
current_user = request.user
list_trans_init = self.get_object(current_user.id)
serializer = TransactionSerializer(list_trans_init, many=True)
return JsonResponse({'data': serializer.data}, safe=False)


with this query I recovery all user with a respective transaction, but I 
don't how to use inner join in here, I try next


def get_object(self, pk):
user = User.objects.get(id=pk)
transaction = Transaction.objects.filter(user_id=user.id, current_status=0)
return Transaction_Detail.objects.filter(transaction_id=transaction, 
status=0)


in here return me the next error


more than one row returned by a subquery used as an expression.



please some help me.


thanks for your attention.























-- 
You received this message because you are subscribed to the Google Groups 
"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/2ea9259d-19de-4c10-be8d-34df2b0aa66c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I transmit any changes to databases(i.e. creates and updates pertaining to a particular user) using Django Channels?

2018-03-08 Thread Andrew Godwin
Hi Alexis,

You'll need to do some work yourself - hook into database changes (either
via signals or overriding the save method) to send change notifications to
a different Group for each user (maybe use group names like "user-123213",
where the number is their ID).

Then, when someone connects via a socket or long-poll, add their consumer
to the group and listen for the change message. You can see some docs on
this here:
http://channels.readthedocs.io/en/latest/topics/channel_layers.html and an
example of sending messages to groups (albeit from another consumer rather
than a save method) here:
https://github.com/andrewgodwin/channels-examples/tree/master/multichat

Andrew

On Thu, Mar 8, 2018 at 7:35 AM, Alexis Candelaria <
alexiscandelar...@gmail.com> wrote:

> My goal is to send send any database updates to the relevant users. I was
> thinking of utilizing the views of the post and patch requests to do this
> but am not sure if there is better or more documented way.
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/b8810aad-de6b-4fb3-b1b6-06547d4e2d6a%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/CAFwN1uraY%3DFpWjSHy8P-UrLNWVbFAKjnFr2S5erVdNL%2B7%3DZ9Xw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Reverse for 'detail' with arguments '('',)' not found. 1 pattern(s) tried: ['(?P[0-9]+)/$']

2018-03-08 Thread Andy Grabow
Well, is it actually named profile inside the view? Rather than the default
original? Check if the name is right and your profile is named profile in
the template.

anyi.ll...@gmail.com  schrieb am Mi. 7. März 2018 um
20:15:

> The profile already have an id. Just wanted to add to an existing profile
> in the db with generic view.
>
>
> - Reply message -
> From: "Andy" 
> To: "Django users" 
> Subject: Reverse for 'detail' with arguments '('',)' not found. 1
> pattern(s) tried: ['(?P[0-9]+)/$']
> Date: Wed, Mar 7, 2018 11:08
>
> If you actually are inside the profile create view, the profile probably
> does not have an id yet and thats why the url lookup is failing. The ID
> will be created on first save of the object.
>
> Am Dienstag, 6. März 2018 00:11:53 UTC+1 schrieb anyi.lloyd:
>>
>> Am new to Django, please i need help here. Am trying to add a subject
>> into a particular id using generic CreatView, i keeping getting errors
>> Reverse for 'detail' with arguments '('',)' not found. 1 pattern(s)
>> tried: ['(?P[0-9]+)/$']
>>
>> models.py
>>
>> from django.db import models
>> from datetime import date
>> from django.core.urlresolvers import reverse
>> from django.shortcuts import redirect
>>
>>
>> class Profile(models.Model):
>> firstName = models.CharField(max_length=30)
>> middleName = models.CharField(max_length=30)
>> lastName = models.CharField(max_length=30)
>> dob = models.DateField(blank=True, null=True)
>> stud_id = models.CharField(max_length=5000)
>> gender = models.CharField(max_length=10)
>> parentsName =models.CharField(max_length=30)
>> address = models.CharField(max_length=250)
>> lga = models.CharField(max_length=250)
>> Religion = models.CharField(max_length=50)
>> email = models.EmailField(max_length=70, null=True, blank=True, 
>> unique=True)
>> phone = models.CharField(max_length=11, unique=True)
>> photo = models.FileField()
>> Comment = models.CharField(max_length=250)
>>
>> def get_absolute_url(self):
>> return reverse('student:detail', kwargs={'pk': self.pk})
>>
>> def __str__(self):
>> return self.firstName
>>
>> class Course(models.Model):
>> profile = models.ForeignKey(Profile, on_delete=models.CASCADE, null=True)
>> subject = models.CharField(max_length=20)
>> score = models.CharField(max_length=20)
>> grade = models.CharField(max_length=20)
>>
>> def get_absolute_url(self,):
>> return reverse('student:detail', kwargs={'pk': self.pk})
>>
>> views.py
>>
>> from django.views import generic
>> from django.views.generic import View
>> from django.views.generic.edit import CreateView, UpdateView, DeleteView
>> from django.core.urlresolvers import reverse_lazy, reverse
>> from django.shortcuts import render, redirect
>> from django.contrib.auth import authenticate, login
>> from .models import Profile, Course
>> from .forms import UserForm
>>
>>
>>
>> #Index view
>> class IndexView(generic.ListView):
>> template_name = 'student/index.html'
>> context_object_name = 'all_profile'
>>
>> def get_queryset(self):
>> return Profile.objects.all()
>>
>> #Detail view
>> class DetailView(generic.DetailView):
>> model = Profile
>> template_name = 'student/detail.html'
>>
>> #Add student section
>> class ProfileCreate(generic.CreateView):
>> model = Profile
>> fields = ['firstName', 'middleName', 'lastName', 'dob', 'gender', 
>> 'parentsName', 'address',
>>   'lga', 'Religion', 'email', 'phone', 'photo']
>>
>> #Add Subject section
>> class CourseCreate(CreateView):
>> model = Course
>> fields = ['subject', 'score', 'grade']
>>
>>
>> def get_form_kwargs(self):
>> kwargs = super(CourseCreate, self).get_form_kwargs()
>> kwargs['instance'] = Course(pk=self.kwargs['pk'])
>> return kwargs
>>
>>
>> urls.py
>>
>>
>> urlpatterns = [
>> #index url
>> url(r'^$', views.IndexView.as_view(), name='index'),
>>
>> url(r'^signup/$', views.UserFormView.as_view(), name='signup'),
>> #details
>> url(r'^(?P[0-9]+)/$', views.DetailView.as_view(), name='detail'),
>> #profile/add
>> url(r'^profile/add/$', views.ProfileCreate.as_view(), 
>> name='profile-add'),
>> #course/add
>> url(r'^(?P[0-9]+)/course_form/$', views.CourseCreate.as_view(), 
>> name='course_form'),
>> #profile/pk for update
>> url(r'^profile/(?P[0-9]+)/$', views.ProfileUpdate.as_view(), 
>> name='profile-update'),
>> #profile/pk for deleting
>> url(r'^profile/(?P[0-9]+)/delete/$', views.ProfileDelete.as_view(), 
>> name='profile-delete'),
>> ]
>>
>>
>>
>> template
>>
>> {% extends 'student/base.html' %}
>> {% block title %}{% endblock %}
>>
>> {% block body %}
>>
>> 
>> 
>> 
>> 
>> 
>> 
>> {{profile.lastName}} 
>> {{profile.firstName}}
>> 
>> 
>>
>> 

How do I transmit any changes to databases(i.e. creates and updates pertaining to a particular user) using Django Channels?

2018-03-08 Thread Alexis Candelaria
My goal is to send send any database updates to the relevant users. I was 
thinking of utilizing the views of the post and patch requests to do this 
but am not sure if there is better or more documented way. 

-- 
You received this message because you are subscribed to the Google Groups 
"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/b8810aad-de6b-4fb3-b1b6-06547d4e2d6a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Borrowing functionality from Django Admin forms

2018-03-08 Thread Andy
Take a deeper look at the *RelatedFieldWidgetWrapper 
(https://github.com/django/django/blob/1.3.2/django/contrib/admin/widgets.py#L200)*

Am Mittwoch, 7. März 2018 21:11:18 UTC+1 schrieb Justin Johnson:
>
> I have a user who saw how new objects can be created using the Admin 
> forms, and asked if I could reproduce some of that functionality.  I'm 
> still new to Django, and even newer to building forms.  I'm wondering if 
> there is a way to "borrow" elements from the Admin forms into my own forms 
> and templates.  Particularly, I would like the ability to create a new 
> related object by clicking the "+" sign next to that dropdown list on 
> another form.
>
> I have not been able to find much documentation on how the Admin forms are 
> constructed for a given Django project.  I understand the basic form 
> construction method, but I can't seem to find the equivalent workings in 
> the Admin site.  Where is the equivalent of urls.py, where the links are 
> mapped to specific Views?  Where are the equivalents of the Views, where a 
> context is created and sent to the template?
>
> I would like to get more familiar with the working code behind Django, and 
> eventually contribute to the project, so feel free to get technical.
>
> Thx.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/a60deb69-3580-46f5-8f2b-eb59ef9be955%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.