Re: Deploying SSL for my Django 2.0.1 server with Apache on Ubuntu 16.04 (droplet)

2018-01-26 Thread drone4four


The username on my droplet is ‘tranq’ but there is a line in both my vhost 
config files which reads:



So I swapped out ‘user’ for ‘tranq’. That line now reads:



Now some of my static files are accessible.  For example you can see here:

https://www.angeles4four.info/static/admin/css/responsive.css

https://www.angeles4four.info/static/admin/css/login.css

But the following is still saying, “Forbidden”: 

https://www.angeles4four.info/static/admin/ 

This may be pointing to an issue I noticed with how my user and group 
permissions are set up for Django.  The sqlite.db file was grouped in with 
‘tranq’. According to the guide I’ve been using, it should be: ‘www-data’. 
 I’m not sure how I overlooked this mistake because I very clearly remember 
doing it properly.  I think I’m conflating this with one of my multiple 
recent previous attempts following this guide. Anyways, here is what my 
group permissions look like now from within my project directory:

$ ls -la

total 68

drwxrwxr-x  5 tranq www-data  4096 Jan 25 23:12 .

drwxr-xr-x 18 tranq tranq 4096 Jan 26 21:57 ..

drwxrwxr-x  3 tranq tranq 4096 Jan 25 23:13 cel2fah

-rw-rw-r--  1 tranq www-data 38912 Jan 25 23:11 db.sqlite3

-rwxrwxr-x  1 tranq tranq  539 Jan 25 23:05 manage.py

drwxrwxr-x  3 tranq tranq 4096 Jan 25 23:12 static

drwxrwxr-x  5 tranq tranq 4096 Jan 25 23:04 venv

Notice sqlite.db above? It now says ‘www-data’.  This is how it should be, 
right?

The parent directory (home user folder) shows these permissions for my 
project:

...

drwxrwxr-x  5 tranq www-data  4096 Jan 25 23:12 cel2fah

Does this look right to all of you?

The steps I took to arrange the permissions as such were from the bottom of 
the mod_wsgi guide on DigitalOcean 

 
which I referred to initially.

Thanks for your attention.

On Friday, January 26, 2018 at 1:21:07 AM UTC-5, drone4four wrote:
>
> You’re right, @Antonis, that I don’t want my Django source code exposed. 
> No sysadmin would.  I have since moved my Django project folder to my home 
> user’s directory. However (out of curiosity), if I continued to house 
> Django in my public_html folder (which I am not any more, but say if i did) 
> I would think that my .htaccess config file would prevent unauthorized 
> access to my Django source.  Am I right?
>
> I didn’t realize that Django was suppose to be run using wsgi.  I was just 
> foolishly running the server with ``$ python manage.py runserver 
> 0.0.0.0:8000`` like when I was testing locally when I was coding my app. 
> The keyword here is mod_wsgi.  So I found this guide 
> .
>  
> I followed along but the issue I now have is that Apache serves my 
> public_html folder (just some light  HTML, CSS and Js).  Serving these 
> contents take priority over Django.  I’m OK with this. I would prefer to 
> keep my public_html folder accessible as it is, but how do I arrange for 
> wsgi to serve Django from a subdirectory, say: 
> www.angeles4four.info/cel2fah or something like that? 
>
> @Mulianto:
>
> An example of a static file would be a style sheet, like: 
> ~/cel2fah/static/admin/css/responsive.css
>
> How would trying to access this CSS file help?
>
> I tried: 
>
> http://www.angeles4four.info:8000/cel2fah/static/admin/css/responsive.css 
>
> https://www.angeles4four.info:8000/cel2fah/static/admin/css/responsive.css 
>  
>
> Both show “This site can’t be reached”
>
> Here are the contents of my two apache configuration files.
>
> /etc/apache2/sites-available/angeles4four.info.conf :
>
> 
>
>
>
> ServerAdmin coffee.drinker.dan...@gmail.com
>
> ServerName angeles4four.info
>
> ServerAlias www.angeles4four.info
>
> DocumentRoot /var/www/html/angeles4four.info/public_html
>
>
> 
>
> Options Indexes FollowSymlinks
>
> AllowOverride All
>
> Require all granted
>
> 
>
>
> ErrorLog ${APACHE_LOG_DIR}/error.log
>
> CustomLog ${APACHE_LOG_DIR}/access.log combined
>
>
> RewriteEngine on
>
> RewriteCond %{SERVER_NAME} =angeles4four.info [OR]
>
> RewriteCond %{SERVER_NAME} =www.angeles4four.info
>
> RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} 
> [END,NE,R=permanent]
>
>
> Alias /static /home/tranq/cel2fah/static
>
>
> 
>
> Require all granted
>
> 
>
>
> 
>
> 
>
> Require all granted
>
> 
>
> 
>
>
> WSGIDaemonProcess cel2fah 

wsgi error

2018-01-26 Thread tango ward
Hi Team,

Not sure if this issue covered here but I am getting an error uploading my
pet project in Heroku.

ModuleNotFoundError: No module named 'animals.wsgi'

2018-01-27T02:59:26.637953+00:00 app[web.1]: [2018-01-27 02:59:26
+] [8] [INFO] Worker exiting (pid: 8)

2018-01-27T02:59:26.669632+00:00 app[web.1]: [2018-01-27 02:59:26
+] [4] [INFO] Shutting down: Master

2018-01-27T02:59:26.669770+00:00 app[web.1]: [2018-01-27 02:59:26
+] [4] [INFO] Reason: Worker failed to boot.



my Procfile in my root folder contains this:

web: gunicorn animals.wsgi:application --log-file - --log-level debug

where animals is the name of my project, where my wsgi.py file is residing.

I tried searching this in StackOverflow but most of the answers are saying
that it must be "web: gunicorn PROJECT_NAME.wsgi:application --log-file -
--log-level debug" which I already did in my Procfile.


Any suggestions?



Regards,
Jarvis

-- 
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/CAA6wQLKi4vjKpVByRykvkXoPkpPUBprVq2pvmn-OabzSkAFoyQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


PyCon Charlas at PyCon US: hablas español?

2018-01-26 Thread Roberta Takenaka Granero
Novedades en PyCon US.
En Febrero, call for Papers para charlas en español
https://www.facebook.com/pyconcharlas/


Roberta Takenaka

-- 
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/CAJ9dYMHvCFBv2thByHn7OsAoCJoQx_ybj4N%3Dw02NYNm0r1rssA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: how do I handle a dropdown in Django whose only purpose is to get data.

2018-01-26 Thread eileen

well, you certainly got me correct! I'm fairly new to python - didn't do 
much coding to learn. Trial by fire, sort of. and the original person who 
put this together is now gone from the company and won't answer any 
outstanding questions. Plus, I *think* he got most of the code from 3rd 
party sources. I could be wrong on that. I was raised on Perl and PL/I (as 
ancient as the latter may seem)

On Friday, January 26, 2018 at 3:12:19 PM UTC-5, Melvyn Sopacua wrote:
>
> There are a bunch of issues with this code: 
>
> 1) Spell Physical correctly: 
>
>
> >   2 - Phyiscal 
>
> > if form.data['handicapped'] is 'Physical' or 'Mental': 
>
> > handicapped = forms.ChoiceField(choices=[(x, x) for x in ('---', 
> > 'Mental', 'Physcal')], required=False) 
>
> Comparison of non boolean or None values using "is" instead of "==": 
> > if form.data['handicapped'] is 'Physical' or 'Mental': 
>
> Use of or as if natural language in RHS of comparisons (should be a == x 
> or a 
> == y, not a == x or y): 
>
> > if form.data['handicapped'] is 'Physical' or 'Mental': 
> > if form['handicapped'].data == 1 or 2: 
>
> So this reads as if someone with very little knowledge of Python is 
> modifying 
> a 3rd party app, written by someone with a decent amount of Django 
> experience. 
>
> Finally, when accessing form data from a valid form, we access 
> form.cleaned_data and generally use a local variable to reference the 
> dict: 
>
> if form.is_valid(): 
> data = form.cleaned_data 
> # do stuff with data 
> -- 
> Melvyn Sopacua 
>

-- 
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/394ce2de-fc0c-4ed2-9c89-7dab9a1c727a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how do I handle a dropdown in Django whose only purpose is to get data.

2018-01-26 Thread Melvyn Sopacua
There are a bunch of issues with this code:

1) Spell Physical correctly:


>   2 - Phyiscal

> if form.data['handicapped'] is 'Physical' or 'Mental':

> handicapped = forms.ChoiceField(choices=[(x, x) for x in ('---',
> 'Mental', 'Physcal')], required=False)

Comparison of non boolean or None values using "is" instead of "==":
> if form.data['handicapped'] is 'Physical' or 'Mental':

Use of or as if natural language in RHS of comparisons (should be a == x or a 
== y, not a == x or y):

> if form.data['handicapped'] is 'Physical' or 'Mental':
> if form['handicapped'].data == 1 or 2:

So this reads as if someone with very little knowledge of Python is modifying 
a 3rd party app, written by someone with a decent amount of Django experience.

Finally, when accessing form data from a valid form, we access 
form.cleaned_data and generally use a local variable to reference the dict:

if form.is_valid():
data = form.cleaned_data
# do stuff with data
-- 
Melvyn Sopacua

-- 
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/2249082.G35ka1OakX%40fritzbook.
For more options, visit https://groups.google.com/d/optout.


Re: how do I make django search for male or female without needing to specify an age?

2018-01-26 Thread Julio Biason
Hi Eileen,

Your problem seems to be the line

  if form.is_valid() and form.data['gender'] != '-':

It seems it will only accept the form if the gender is not "-"; if you
change that (say, removing the part after the and), it should solve it.

... although you should have a better understanding of what your
application does to know if that will work or not.

On Fri, Jan 26, 2018 at 3:26 PM,  wrote:

> I should add that this initally loads a list of children without
> specifying either gender or age
>
>
> On Friday, January 26, 2018 at 12:05:04 PM UTC-5, eil...@themaii.org
> wrote:
>>
>> I have a file: views.py which refers to two main fields on the page: age
>> and gender
>> Right now, the search requires that an age to be chosen whether or not
>> the gender is, and I'd like to make the age optional as well. I.e get all
>> the children.
>> Additionally, I'd like to search for only males or females without
>> selecting an age...
>>
>> -Eileen
>> from __future__ import unicode_literals
>> from django.contrib.auth import get_user_model
>> from django.shortcuts import redirect
>> from django.template.response import TemplateResponse
>> from django.http import HttpResponse
>> from django.db.models import Q
>> from django.db.models import F
>> from mezzanine.conf import settings
>> from sponsorship.forms import FilterForm
>> from sponsorship.models import Child
>> from pinax.stripe.models import Customer
>> import json
>> import logging
>>
>> logger = logging.getLogger(__name__)
>>
>> User = get_user_model()
>>
>> steps = [{'title': 'Find a child to sponsor', 'no': '1'}, {'title': 'Sign
>> up or sign in', 'no': '2'}]
>>
>> def filterchain_all(request, app_name, model_name, method_name, gender):
>> gender_dict = {'MALE': 0, 'FEMALE': 1}
>> if gender in gender_dict:
>> qs = Child.objects.filter(gender=gender_dict[gender]).order_by('
>> age')
>> results = list(qs)
>> final = []
>> for item in results:
>> if int(item.age) not in [d['display'] for d in final]:
>> final.append({'value': int(item.age), 'display':
>> int(item.age)})
>> return HttpResponse(json.dumps(final),
>> content_type='application/json')
>> else:
>> return HttpResponse(json.dumps({'success': True}),
>> content_type='application/json')
>>
>> def children_list(request, template="pages/sponsorship.html",
>> extra_context=None):
>> templates = []
>> templates.append(template)
>> children = Child.objects.filter(Q(has_photo=1) &
>> Q(image__isnull=False) & Q(sponsor__isnull=True))
>> context = {"child_filter": children, "filter_form": FilterForm(),
>> "steps": steps, "activestep": "1"}
>> if request.method == "POST":
>> if "id" in request.POST:
>> child_id = context['child_filter'].filter
>> (id=request.POST['id'])[0].child_id
>> authenticated = request.user.is_authenticated()
>> if settings.SHOP_CHECKOUT_ACCOUNT_REQUIRED and not
>> authenticated:
>> url = "/accounts/signup/?next=/donat
>> e/product/sponsor-a-child/new_customer/%s" % child_id
>> return redirect(url)
>> else:
>> url = "/donate/product/sponsor-a-child/%s" % child_id
>> return redirect(url)
>> else:
>>   form = FilterForm(request.POST)
>>   gender_dict = {'MALE': 0, 'FEMALE': 1}
>>
>>   search_message = "There are no children that match your
>> selection"
>>   if form.is_valid() and form.data['gender'] != '-':
>> if form.data['gender'] is 0 or 1:
>>   q = context['child_filter'].filter
>> (Q(gender=gender_dict[request.POST['gender']]))
>>
>> import pdb; pdb.set_trace()
>> if form['handicapped'].data == 1 or 2:
>> q = context['child_filter'].filter
>> (Q(handicapped=handicapped_dict[request.POST['handicapped']]))
>>
>> if request.POST['age'] != '':
>> q = context['child_filter'].filter
>> (Q(age=request.POST['age']))
>>
>> # start of output using search parameters
>>
>> if q.count() > 1:
>>   search_message = "There are %s children that match your
>> selection of %s"  %  (q.count(), request.POST['gender'])
>> else:
>>   search_message = "There is 1 child that matches your
>> selection of %s"  %  (request.POST['gender'])
>>
>> if q.count() > 1:
>>search_message = ", age: %s"  %  (request.POST['age'])
>> else:
>>search_message = ", age: %s"  % (request.POST['age'])
>>
>> context['child_filter'] = q
>> context['filter_form'] = FilterForm()
>> context['activestep'] = "1"
>> context['search_message'] = search_message
>> extra_context = {"message": "Updating filter"}
>> context.update(extra_context or {})
>> return 

Re: how do I make django search for male or female without needing to specify an age?

2018-01-26 Thread eileen
I should add that this initally loads a list of children without specifying 
either gender or age

On Friday, January 26, 2018 at 12:05:04 PM UTC-5, eil...@themaii.org wrote:
>
> I have a file: views.py which refers to two main fields on the page: age 
> and gender
> Right now, the search requires that an age to be chosen whether or not the 
> gender is, and I'd like to make the age optional as well. I.e get all the 
> children.
> Additionally, I'd like to search for only males or females without 
> selecting an age...
>
> -Eileen
> from __future__ import unicode_literals
> from django.contrib.auth import get_user_model
> from django.shortcuts import redirect
> from django.template.response import TemplateResponse
> from django.http import HttpResponse
> from django.db.models import Q
> from django.db.models import F
> from mezzanine.conf import settings
> from sponsorship.forms import FilterForm
> from sponsorship.models import Child
> from pinax.stripe.models import Customer
> import json
> import logging
>
> logger = logging.getLogger(__name__)
>
> User = get_user_model()
>
> steps = [{'title': 'Find a child to sponsor', 'no': '1'}, {'title': 'Sign 
> up or sign in', 'no': '2'}]
>
> def filterchain_all(request, app_name, model_name, method_name, gender):
> gender_dict = {'MALE': 0, 'FEMALE': 1}
> if gender in gender_dict:
> qs = 
> Child.objects.filter(gender=gender_dict[gender]).order_by('age')
> results = list(qs)
> final = []
> for item in results:
> if int(item.age) not in [d['display'] for d in final]:
> final.append({'value': int(item.age), 'display': 
> int(item.age)})
> return HttpResponse(json.dumps(final), 
> content_type='application/json')
> else:
> return HttpResponse(json.dumps({'success': True}), 
> content_type='application/json')
>
> def children_list(request, template="pages/sponsorship.html", 
> extra_context=None):
> templates = []
> templates.append(template)
> children = Child.objects.filter(Q(has_photo=1) & 
> Q(image__isnull=False) & Q(sponsor__isnull=True))
> context = {"child_filter": children, "filter_form": FilterForm(), 
> "steps": steps, "activestep": "1"}
> if request.method == "POST":
> if "id" in request.POST:
> child_id = 
> context['child_filter'].filter(id=request.POST['id'])[0].child_id
> authenticated = request.user.is_authenticated()
> if settings.SHOP_CHECKOUT_ACCOUNT_REQUIRED and not 
> authenticated:
> url = 
> "/accounts/signup/?next=/donate/product/sponsor-a-child/new_customer/%s" % 
> child_id
> return redirect(url)
> else:
> url = "/donate/product/sponsor-a-child/%s" % child_id
> return redirect(url)
> else:
>   form = FilterForm(request.POST)
>   gender_dict = {'MALE': 0, 'FEMALE': 1}
>
>   search_message = "There are no children that match your 
> selection"
>   if form.is_valid() and form.data['gender'] != '-':
> if form.data['gender'] is 0 or 1:
>   q = 
> context['child_filter'].filter(Q(gender=gender_dict[request.POST['gender']]))
>
> import pdb; pdb.set_trace()
> if form['handicapped'].data == 1 or 2:
> q = 
> context['child_filter'].filter(Q(handicapped=handicapped_dict[request.POST['handicapped']]))
>
> if request.POST['age'] != '':
> q = 
> context['child_filter'].filter(Q(age=request.POST['age']))
>
> # start of output using search parameters
>
> if q.count() > 1:
>   search_message = "There are %s children that match your 
> selection of %s"  %  (q.count(), request.POST['gender'])
> else:
>   search_message = "There is 1 child that matches your 
> selection of %s"  %  (request.POST['gender'])
>
> if q.count() > 1:
>search_message = ", age: %s"  %  (request.POST['age'])
> else:
>search_message = ", age: %s"  % (request.POST['age'])
>
> context['child_filter'] = q
> context['filter_form'] = FilterForm()
> context['activestep'] = "1"
> context['search_message'] = search_message
> extra_context = {"message": "Updating filter"}
> context.update(extra_context or {})
> return TemplateResponse(request, templates, context)
>   else:
>   context['filter_form'] = form
>   extra_context = {"message":"Something went wrong"}
>   context.update(extra_context or {})
>   return TemplateResponse(request, templates, context)
>
> else:
> context.update(extra_context or {})
> return TemplateResponse(request, templates, context)
>
>
> def child_detail(request, template="pages/sponsorship.html", 
> extra_context=None, pk=None):
> templates = []
>   

how do I make django search for male or female without needing to specify an age?

2018-01-26 Thread eileen
I have a file: views.py which refers to two main fields on the page: age 
and gender
Right now, the search requires that an age to be chosen whether or not the 
gender is, and I'd like to make the age optional as well. I.e get all the 
children.
Additionally, I'd like to search for only males or females without 
selecting an age...

-Eileen
from __future__ import unicode_literals
from django.contrib.auth import get_user_model
from django.shortcuts import redirect
from django.template.response import TemplateResponse
from django.http import HttpResponse
from django.db.models import Q
from django.db.models import F
from mezzanine.conf import settings
from sponsorship.forms import FilterForm
from sponsorship.models import Child
from pinax.stripe.models import Customer
import json
import logging

logger = logging.getLogger(__name__)

User = get_user_model()

steps = [{'title': 'Find a child to sponsor', 'no': '1'}, {'title': 'Sign 
up or sign in', 'no': '2'}]

def filterchain_all(request, app_name, model_name, method_name, gender):
gender_dict = {'MALE': 0, 'FEMALE': 1}
if gender in gender_dict:
qs = 
Child.objects.filter(gender=gender_dict[gender]).order_by('age')
results = list(qs)
final = []
for item in results:
if int(item.age) not in [d['display'] for d in final]:
final.append({'value': int(item.age), 'display': 
int(item.age)})
return HttpResponse(json.dumps(final), 
content_type='application/json')
else:
return HttpResponse(json.dumps({'success': True}), 
content_type='application/json')

def children_list(request, template="pages/sponsorship.html", 
extra_context=None):
templates = []
templates.append(template)
children = Child.objects.filter(Q(has_photo=1) & Q(image__isnull=False) 
& Q(sponsor__isnull=True))
context = {"child_filter": children, "filter_form": FilterForm(), 
"steps": steps, "activestep": "1"}
if request.method == "POST":
if "id" in request.POST:
child_id = 
context['child_filter'].filter(id=request.POST['id'])[0].child_id
authenticated = request.user.is_authenticated()
if settings.SHOP_CHECKOUT_ACCOUNT_REQUIRED and not 
authenticated:
url = 
"/accounts/signup/?next=/donate/product/sponsor-a-child/new_customer/%s" % 
child_id
return redirect(url)
else:
url = "/donate/product/sponsor-a-child/%s" % child_id
return redirect(url)
else:
  form = FilterForm(request.POST)
  gender_dict = {'MALE': 0, 'FEMALE': 1}

  search_message = "There are no children that match your selection"
  if form.is_valid() and form.data['gender'] != '-':
if form.data['gender'] is 0 or 1:
  q = 
context['child_filter'].filter(Q(gender=gender_dict[request.POST['gender']]))

import pdb; pdb.set_trace()
if form['handicapped'].data == 1 or 2:
q = 
context['child_filter'].filter(Q(handicapped=handicapped_dict[request.POST['handicapped']]))

if request.POST['age'] != '':
q = 
context['child_filter'].filter(Q(age=request.POST['age']))

# start of output using search parameters

if q.count() > 1:
  search_message = "There are %s children that match your 
selection of %s"  %  (q.count(), request.POST['gender'])
else:
  search_message = "There is 1 child that matches your 
selection of %s"  %  (request.POST['gender'])

if q.count() > 1:
   search_message = ", age: %s"  %  (request.POST['age'])
else:
   search_message = ", age: %s"  % (request.POST['age'])

context['child_filter'] = q
context['filter_form'] = FilterForm()
context['activestep'] = "1"
context['search_message'] = search_message
extra_context = {"message": "Updating filter"}
context.update(extra_context or {})
return TemplateResponse(request, templates, context)
  else:
  context['filter_form'] = form
  extra_context = {"message":"Something went wrong"}
  context.update(extra_context or {})
  return TemplateResponse(request, templates, context)

else:
context.update(extra_context or {})
return TemplateResponse(request, templates, context)


def child_detail(request, template="pages/sponsorship.html", 
extra_context=None, pk=None):
templates = []
templates.append(template)
children = Child.objects.filter(pk=pk)

if request.method == "GET":
context = {"child_filter": children, "filter_form": FilterForm(), 
"steps": steps, "activestep": "3"}
else:
context = {"child_filter": children, "filter_form": FilterForm(), 
"steps": steps, "activestep": "4"}

context.update(extra_context or {})
return 

Re: unable to save object Django (2.0)

2018-01-26 Thread harsh sharma
thank you 

regards 

On Wednesday, January 24, 2018 at 2:58:07 PM UTC+5:30, Anoosha Masood Keen 
wrote:
>
> Try this in models.py file
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *class personmanager(models.Model):notes = models.TextField()link 
> = models.URLField()number = models.IntegerField()def 
> create_person(self,note,link,number):self.notes=note
> self.link=linkself.number=numberreturn selfdef 
> __str__(self):return self.notesobject = 
> personmanager()a=object.create_person("this","c.com 
> ",1);a.save()*
>
> On Tuesday, January 23, 2018 at 8:10:00 PM UTC, harsh sharma wrote:
>>
>> i am trying to save the basic information about a person 
>> i have created a model form for it but i am unable to save the object 
>> (unable to update the database)
>>
>> here is my views file
>>
>> @login_required
>> def dashboard(request):
>> if request.method=="post":
>> form = linkform(request.POST)
>> if form.is_valid():
>> try:
>> notes = form.cleaned_data['note']
>> link = form.cleaned_data['link']
>> number = form.cleaned_data['number']
>> perso = person.object.create_person(notes,link,number)
>> perso.save()
>> return HttpResponse('succeess')
>> except:
>> return HttpResponse('can not create object')
>> else:
>> return HttpResponse('bad form')
>> else:
>> form = linkform(request.POST)
>> return render(request, 'dashboard.html', {'form':form})
>>
>>
>> here is my model file :
>>
>> class personmanager(models.Manager):
>> def create_person(self,note,link,number):
>> pers = self.create(note=note,link=link,number=number)
>> return pers
>>
>>
>>
>> class person(models.Model):
>> notes = models.TextField()
>> link = models.URLField()
>> number = models.IntegerField()
>> object = personmanager()
>>
>>

-- 
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/6e137774-e270-4673-b36f-a9102bccc29b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: unable to save object Django (2.0)

2018-01-26 Thread harsh sharma
their is no error message 
i am doing something wrong in my forms
which is being solved
thank you

 
regards

On Friday, January 26, 2018 at 3:09:43 AM UTC+5:30, Andy wrote:
>
> what is the actual error message?
>
> Am Dienstag, 23. Januar 2018 21:10:00 UTC+1 schrieb harsh sharma:
>>
>> i am trying to save the basic information about a person 
>> i have created a model form for it but i am unable to save the object 
>> (unable to update the database)
>>
>> here is my views file
>>
>> @login_required
>> def dashboard(request):
>> if request.method=="post":
>> form = linkform(request.POST)
>> if form.is_valid():
>> try:
>> notes = form.cleaned_data['note']
>> link = form.cleaned_data['link']
>> number = form.cleaned_data['number']
>> perso = person.object.create_person(notes,link,number)
>> perso.save()
>> return HttpResponse('succeess')
>> except:
>> return HttpResponse('can not create object')
>> else:
>> return HttpResponse('bad form')
>> else:
>> form = linkform(request.POST)
>> return render(request, 'dashboard.html', {'form':form})
>>
>>
>> here is my model file :
>>
>> class personmanager(models.Manager):
>> def create_person(self,note,link,number):
>> pers = self.create(note=note,link=link,number=number)
>> return pers
>>
>>
>>
>> class person(models.Model):
>> notes = models.TextField()
>> link = models.URLField()
>> number = models.IntegerField()
>> object = personmanager()
>>
>>

-- 
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/391cbb98-31a0-4f94-ab20-3692e204fd1a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Error

2018-01-26 Thread 'Anoosha Masood Keen' via Django users
Working with ticket 
#29039 *Error:*
 if name.startswith('.'):
AttributeError: 'NoneType' object has no attribute 'startswith'
*CODE added to settings.py:*


MIGRATION_MODULES = {}
for app in INSTALLED_APPS:
if app:
MIGRATION_MODULES[app] = None
print (MIGRATION_MODULES[app])


-- 
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/bb0143ba-9b20-4df6-a222-bc4e37c376bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: unable to save object Django (2.0)

2018-01-26 Thread harsh sharma
thank you the problem has being solve 

regards

On Friday, January 26, 2018 at 10:56:14 AM UTC+5:30, Omar Abou Mrad wrote:
>
>
> On Tue, Jan 23, 2018 at 10:10 PM, harsh sharma  > wrote:
>
>> i am trying to save the basic information about a person 
>> i have created a model form for it but i am unable to save the object 
>> (unable to update the database)
>>
>> here is my views file
>>
>> @login_required
>> def dashboard(request):
>> if request.method=="post":
>> form = linkform(request.POST)
>> if form.is_valid():
>> try:
>> notes = form.cleaned_data['note']
>> link = form.cleaned_data['link']
>> number = form.cleaned_data['number']
>> perso = person.object.create_person(notes,link,number)
>> perso.save()
>> return HttpResponse('succeess')
>> except:
>>
>>
> Your "except" swallows the exceptions that are happening and you're unable
> to figure out the reason it's failing.
>  
>
>> class personmanager(models.Manager):
>> def create_person(self,note,link,number):
>> pers = self.create(note=note,link=link,number=number)
>> return pers
>>
>>
> The problem is due to your use of "note" whereas the field name
> is actually "notes" (plural)
>  
> Finally, the entire "create_person" serves no purpose as you're just
> aliasing "create"
>
> person.object.create_person(a=a, b=b, c=c)
> Person.objects.create(a=a, b=b, c=c)
>
> Regards,
>

-- 
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/efc92a9a-628e-4f4b-bd0b-248e01af8a52%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: unable to save object Django (2.0)

2018-01-26 Thread harsh sharma
change that variable but still i mm unable to save the object

On Friday, January 26, 2018 at 10:56:14 AM UTC+5:30, Omar Abou Mrad wrote:
>
>
> On Tue, Jan 23, 2018 at 10:10 PM, harsh sharma  > wrote:
>
>> i am trying to save the basic information about a person 
>> i have created a model form for it but i am unable to save the object 
>> (unable to update the database)
>>
>> here is my views file
>>
>> @login_required
>> def dashboard(request):
>> if request.method=="post":
>> form = linkform(request.POST)
>> if form.is_valid():
>> try:
>> notes = form.cleaned_data['note']
>> link = form.cleaned_data['link']
>> number = form.cleaned_data['number']
>> perso = person.object.create_person(notes,link,number)
>> perso.save()
>> return HttpResponse('succeess')
>> except:
>>
>>
> Your "except" swallows the exceptions that are happening and you're unable
> to figure out the reason it's failing.
>  
>
>> class personmanager(models.Manager):
>> def create_person(self,note,link,number):
>> pers = self.create(note=note,link=link,number=number)
>> return pers
>>
>>
> The problem is due to your use of "note" whereas the field name
> is actually "notes" (plural)
>  
> Finally, the entire "create_person" serves no purpose as you're just
> aliasing "create"
>
> person.object.create_person(a=a, b=b, c=c)
> Person.objects.create(a=a, b=b, c=c)
>
> Regards,
>

-- 
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/9cc034c1-6445-40ea-9da2-bc16ee6f9d57%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: url issues

2018-01-26 Thread rajendran . p
def login(request):
return render(request,'login.html')

On Friday, January 26, 2018 at 6:33:07 AM UTC+5:30, suabiut wrote:
>
> Hi,
> i am having some issues with my url pattern. i can't seem to figure out 
> the problem. i am running django 1.11.
>
> i have an app name userprofile which automatically create user profiles on 
> user creation. I have create a login template to allow users to login in 
> before i can direct them to update their profile but i cannot seem to 
> access the login page.
>
> i get this below error
>
> [image: Inline image 1]
>
> view.py
> def login(request):
> return render(request,'login.html')
>
>
>
> urls.py
> from django.conf.urls import url
> from django.contrib import admin
>
> from . import views
>
>
> urlpatterns = [
> url(r'^$',views.login,name='login'),
>
> #url('', views.edit_user),
> url(r'success/$', views.success),
>
> ]
>
>
> cheers
>
>

-- 
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/636f672a-7ab9-4853-892b-374e1b16f461%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Get request, has PK, how do I access the PK data with in the model

2018-01-26 Thread Andy

Travis have a look the very cool and complete django tutorial which 
explaining how you query models in part2.
Once you have create the admin views, watch closely at how the list filters 
work to get an idea of what you have to do. :)

-- 
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/85a3ded4-a710-4c5a-a4a2-b592002d8773%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django 2 under python 2

2018-01-26 Thread Andy
okay after digging a little bit more yesterday i found out why this is 
happening ..

https://code.djangoproject.com/ticket/28878
its fixed in 2.0.1, but maybe they will be able to reupload 2.0

Just to be clear: i know that django 2 aint working under python2, but its 
a pain to setup cross version testing if "pip install django" under pthon2 
will just fail whereas "pip install ipython" will just install the latest 
compatible release (5.5.x) and wont even bother to download 6.x which is 
correctly marked as python3 only. So i already knew that django2 could be 
hidden from python2, just wondered why its not behaving correctly.

Just trying to install django under python2 you will notice, that pip wil 
not bother to download the fixed django 2.0.1 .. but sadly it will install 
the incompatible 2.0 and fail ..

But the django folks are at it .. until then my travis config will be a 
little bit more complicated than it has to be. :(

-- 
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/828351c7-49e0-4060-9965-4f95160cd49f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.