Re: Form Validation Error NOT Raised When Form Is Submitted

2016-12-22 Thread Chris Kavanagh
I got it working Vijay! Thank you so much for your help, and have a great 
Christmas!!


On Thursday, December 22, 2016 at 9:55:05 PM UTC-5, Vijay Khemlani wrote:
>
> if the form is not valid then form.errors should contain human-readable 
> errors for each field, including the one you validate yourself (the string 
> inside the raise ValidationError call), you can return that.
>
> On Thu, Dec 22, 2016 at 11:49 PM, Chris Kavanagh  > wrote:
>
>> Yeah, I was wrong Vijay. For some odd reason I thought the 
>> ValidationError would catch it BEFORE submitted. . .
>>
>> I re-read the docs and saw I was wrong. .
>>
>> In other words, I I try to submit the form with the input field empty, I 
>> get a small pop up error saying "Please Enter An Email".
>>
>> Or, if I use an invalid email format, I get the same popup error saying 
>> "Please Enter An Email Address."
>>
>> Is there a way to do this with this (with django)?
>>
>> On Thursday, December 22, 2016 at 9:30:22 PM UTC-5, Vijay Khemlani wrote:
>>>
>>> I'm not following
>>>
>>> If you submit the form with incorrect information (non unique email) 
>>> then your view does not return anything because form.is_valid() returns 
>>> False
>>>
>>> Validation errors don't prevent the form from being submitted, they 
>>> prevent the form from validation (making form.is_valid() return False and 
>>> adding values to form.errors)
>>>
>>> On Thu, Dec 22, 2016 at 5:14 PM, Chris Kavanagh  
>>> wrote:
>>>
 I have a model form called *"ContactForm" *that has an email field. I 
 created a custom* forms.ValidationError* in *"clean_email"* method

  which checks to see if the email is already in the database , however 
 it's never raised on submit.


  When submit is called, the view runs and I get the error *"The view 
 customer.views.send_email didn't return an HttpResponse object.*

 * It returned None instead"*, because it's not being passed an actual 
 email. . 

 I don't understand why the *forms.ValidationError* isn't stopping it 
 from being submitted? The query in the *"clean_email"* works fine, so 
 that's not the problem.

 I've used this same code before with no problems. I'm sure it's 
 something easy I'm forgetting or missing, but any help is GREATLY 
 appreciated. .

 Note: I am using django crispy forms


 *#Model:*
 class Customer(models.Model):
 email = models.EmailField(max_length=70,blank=False)
 created = models.DateTimeField(auto_now_add=True)

 class Meta:
 ordering = ('email',)

 def __unicode__(self):
 return self.email




 *#Form:*
 class ContactForm(forms.ModelForm):

 class Meta:
 model = Customer
 fields = ['email']

 def clean_email(self):
 email = self.cleaned_data['email']
 cust_email = Customer.objects.filter(email=email).count()
 if cust_email:
 raise forms.ValidationError('This email is already in use.')
 return email




 *#View:*
 def send_email(request):
 if request.method == 'POST':
 form = ContactForm(request.POST)
 if form.is_valid():
 cd = form.cleaned_data
 email = cd['email']
 new_email = form.save(commit=True)
 to_email = form.cleaned_data['email']   # cd['email']
 subject = 'Newsletter'
 from_email = settings.EMAIL_HOST_USER
 message = 'You Are Now Signed Up For BenGui Newsletter!'
 #send_mail(subject, message, from_email, [to_email,], 
 fail_silently=False)
 return redirect('home')
 else:
 return render(request, 'home.html', context)



 *#customer.urls:*

 urlpatterns = [
 url(r'^send-email/$', views.send_email, name='send_email'),
 ]


 #Template:

 
 {% csrf_token %}
 {{ form|crispy }}
 >>> type='submit' value='Submit'>
 

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

>>>
>>> -- 
>> You received this 

Re: Form Validation Error NOT Raised When Form Is Submitted

2016-12-22 Thread Vijay Khemlani
if the form is not valid then form.errors should contain human-readable
errors for each field, including the one you validate yourself (the string
inside the raise ValidationError call), you can return that.

On Thu, Dec 22, 2016 at 11:49 PM, Chris Kavanagh  wrote:

> Yeah, I was wrong Vijay. For some odd reason I thought the ValidationError
> would catch it BEFORE submitted. . .
>
> I re-read the docs and saw I was wrong. .
>
> In other words, I I try to submit the form with the input field empty, I
> get a small pop up error saying "Please Enter An Email".
>
> Or, if I use an invalid email format, I get the same popup error saying
> "Please Enter An Email Address."
>
> Is there a way to do this with this (with django)?
>
> On Thursday, December 22, 2016 at 9:30:22 PM UTC-5, Vijay Khemlani wrote:
>>
>> I'm not following
>>
>> If you submit the form with incorrect information (non unique email) then
>> your view does not return anything because form.is_valid() returns False
>>
>> Validation errors don't prevent the form from being submitted, they
>> prevent the form from validation (making form.is_valid() return False and
>> adding values to form.errors)
>>
>> On Thu, Dec 22, 2016 at 5:14 PM, Chris Kavanagh  wrote:
>>
>>> I have a model form called *"ContactForm" *that has an email field. I
>>> created a custom* forms.ValidationError* in *"clean_email"* method
>>>
>>>  which checks to see if the email is already in the database , however
>>> it's never raised on submit.
>>>
>>>
>>>  When submit is called, the view runs and I get the error *"The view
>>> customer.views.send_email didn't return an HttpResponse object.*
>>>
>>> * It returned None instead"*, because it's not being passed an actual
>>> email. .
>>>
>>> I don't understand why the *forms.ValidationError* isn't stopping it
>>> from being submitted? The query in the *"clean_email"* works fine, so
>>> that's not the problem.
>>>
>>> I've used this same code before with no problems. I'm sure it's
>>> something easy I'm forgetting or missing, but any help is GREATLY
>>> appreciated. .
>>>
>>> Note: I am using django crispy forms
>>>
>>>
>>> *#Model:*
>>> class Customer(models.Model):
>>> email = models.EmailField(max_length=70,blank=False)
>>> created = models.DateTimeField(auto_now_add=True)
>>>
>>> class Meta:
>>> ordering = ('email',)
>>>
>>> def __unicode__(self):
>>> return self.email
>>>
>>>
>>>
>>>
>>> *#Form:*
>>> class ContactForm(forms.ModelForm):
>>>
>>> class Meta:
>>> model = Customer
>>> fields = ['email']
>>>
>>> def clean_email(self):
>>> email = self.cleaned_data['email']
>>> cust_email = Customer.objects.filter(email=email).count()
>>> if cust_email:
>>> raise forms.ValidationError('This email is already in use.')
>>> return email
>>>
>>>
>>>
>>>
>>> *#View:*
>>> def send_email(request):
>>> if request.method == 'POST':
>>> form = ContactForm(request.POST)
>>> if form.is_valid():
>>> cd = form.cleaned_data
>>> email = cd['email']
>>> new_email = form.save(commit=True)
>>> to_email = form.cleaned_data['email']   # cd['email']
>>> subject = 'Newsletter'
>>> from_email = settings.EMAIL_HOST_USER
>>> message = 'You Are Now Signed Up For BenGui Newsletter!'
>>> #send_mail(subject, message, from_email, [to_email,],
>>> fail_silently=False)
>>> return redirect('home')
>>> else:
>>> return render(request, 'home.html', context)
>>>
>>>
>>>
>>> *#customer.urls:*
>>>
>>> urlpatterns = [
>>> url(r'^send-email/$', views.send_email, name='send_email'),
>>> ]
>>>
>>>
>>> #Template:
>>>
>>> 
>>> {% csrf_token %}
>>> {{ form|crispy }}
>>> >> type='submit' value='Submit'>
>>> 
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/django-users/8ff5313f-3783-4897-afa7-5edd4fe1b436%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 

Re: Form Validation Error NOT Raised When Form Is Submitted

2016-12-22 Thread Chris Kavanagh
Yeah, I was wrong Vijay. For some odd reason I thought the ValidationError 
would catch it BEFORE submitted. . .

I re-read the docs and saw I was wrong. .

In other words, I I try to submit the form with the input field empty, I 
get a small pop up error saying "Please Enter An Email".

Or, if I use an invalid email format, I get the same popup error saying 
"Please Enter An Email Address."

Is there a way to do this with this (with django)?

On Thursday, December 22, 2016 at 9:30:22 PM UTC-5, Vijay Khemlani wrote:
>
> I'm not following
>
> If you submit the form with incorrect information (non unique email) then 
> your view does not return anything because form.is_valid() returns False
>
> Validation errors don't prevent the form from being submitted, they 
> prevent the form from validation (making form.is_valid() return False and 
> adding values to form.errors)
>
> On Thu, Dec 22, 2016 at 5:14 PM, Chris Kavanagh  > wrote:
>
>> I have a model form called *"ContactForm" *that has an email field. I 
>> created a custom* forms.ValidationError* in *"clean_email"* method
>>
>>  which checks to see if the email is already in the database , however 
>> it's never raised on submit.
>>
>>
>>  When submit is called, the view runs and I get the error *"The view 
>> customer.views.send_email didn't return an HttpResponse object.*
>>
>> * It returned None instead"*, because it's not being passed an actual 
>> email. . 
>>
>> I don't understand why the *forms.ValidationError* isn't stopping it 
>> from being submitted? The query in the *"clean_email"* works fine, so 
>> that's not the problem.
>>
>> I've used this same code before with no problems. I'm sure it's something 
>> easy I'm forgetting or missing, but any help is GREATLY appreciated. .
>>
>> Note: I am using django crispy forms
>>
>>
>> *#Model:*
>> class Customer(models.Model):
>> email = models.EmailField(max_length=70,blank=False)
>> created = models.DateTimeField(auto_now_add=True)
>>
>> class Meta:
>> ordering = ('email',)
>>
>> def __unicode__(self):
>> return self.email
>>
>>
>>
>>
>> *#Form:*
>> class ContactForm(forms.ModelForm):
>>
>> class Meta:
>> model = Customer
>> fields = ['email']
>>
>> def clean_email(self):
>> email = self.cleaned_data['email']
>> cust_email = Customer.objects.filter(email=email).count()
>> if cust_email:
>> raise forms.ValidationError('This email is already in use.')
>> return email
>>
>>
>>
>>
>> *#View:*
>> def send_email(request):
>> if request.method == 'POST':
>> form = ContactForm(request.POST)
>> if form.is_valid():
>> cd = form.cleaned_data
>> email = cd['email']
>> new_email = form.save(commit=True)
>> to_email = form.cleaned_data['email']   # cd['email']
>> subject = 'Newsletter'
>> from_email = settings.EMAIL_HOST_USER
>> message = 'You Are Now Signed Up For BenGui Newsletter!'
>> #send_mail(subject, message, from_email, [to_email,], 
>> fail_silently=False)
>> return redirect('home')
>> else:
>> return render(request, 'home.html', context)
>>
>>
>>
>> *#customer.urls:*
>>
>> urlpatterns = [
>> url(r'^send-email/$', views.send_email, name='send_email'),
>> ]
>>
>>
>> #Template:
>>
>> 
>> {% csrf_token %}
>> {{ form|crispy }}
>> > type='submit' value='Submit'>
>> 
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/8ff5313f-3783-4897-afa7-5edd4fe1b436%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/39ec5818-92b6-4b2c-ad9a-58e09acd5427%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Form Validation Error NOT Raised When Form Is Submitted

2016-12-22 Thread Vijay Khemlani
I'm not following

If you submit the form with incorrect information (non unique email) then
your view does not return anything because form.is_valid() returns False

Validation errors don't prevent the form from being submitted, they prevent
the form from validation (making form.is_valid() return False and adding
values to form.errors)

On Thu, Dec 22, 2016 at 5:14 PM, Chris Kavanagh  wrote:

> I have a model form called *"ContactForm" *that has an email field. I
> created a custom* forms.ValidationError* in *"clean_email"* method
>
>  which checks to see if the email is already in the database , however
> it's never raised on submit.
>
>
>  When submit is called, the view runs and I get the error *"The view
> customer.views.send_email didn't return an HttpResponse object.*
>
> * It returned None instead"*, because it's not being passed an actual
> email. .
>
> I don't understand why the *forms.ValidationError* isn't stopping it from
> being submitted? The query in the *"clean_email"* works fine, so that's
> not the problem.
>
> I've used this same code before with no problems. I'm sure it's something
> easy I'm forgetting or missing, but any help is GREATLY appreciated. .
>
> Note: I am using django crispy forms
>
>
> *#Model:*
> class Customer(models.Model):
> email = models.EmailField(max_length=70,blank=False)
> created = models.DateTimeField(auto_now_add=True)
>
> class Meta:
> ordering = ('email',)
>
> def __unicode__(self):
> return self.email
>
>
>
>
> *#Form:*
> class ContactForm(forms.ModelForm):
>
> class Meta:
> model = Customer
> fields = ['email']
>
> def clean_email(self):
> email = self.cleaned_data['email']
> cust_email = Customer.objects.filter(email=email).count()
> if cust_email:
> raise forms.ValidationError('This email is already in use.')
> return email
>
>
>
>
> *#View:*
> def send_email(request):
> if request.method == 'POST':
> form = ContactForm(request.POST)
> if form.is_valid():
> cd = form.cleaned_data
> email = cd['email']
> new_email = form.save(commit=True)
> to_email = form.cleaned_data['email']   # cd['email']
> subject = 'Newsletter'
> from_email = settings.EMAIL_HOST_USER
> message = 'You Are Now Signed Up For BenGui Newsletter!'
> #send_mail(subject, message, from_email, [to_email,],
> fail_silently=False)
> return redirect('home')
> else:
> return render(request, 'home.html', context)
>
>
>
> *#customer.urls:*
>
> urlpatterns = [
> url(r'^send-email/$', views.send_email, name='send_email'),
> ]
>
>
> #Template:
>
> 
> {% csrf_token %}
> {{ form|crispy }}
>  type='submit' value='Submit'>
> 
>
> --
> 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/8ff5313f-3783-4897-afa7-5edd4fe1b436%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/CALn3ei1L-1Lc%2BEst-c9nfJR%3DE8Rk2pZHwRssCXgtWRNpzXHBWg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to display user's photo that i follow in post's list in Django

2016-12-22 Thread skerdi
That get_photo func, I'm not using it. It tried to do something and I 
forgot to delete it.
About screenshotting the code, I thought that it was more clarifying.

class ProfileManager(models.Manager):
use_for_related_fields = True

def all(self):
qs = self.get_queryset().all()
try:
if self.instance:
qs = qs.exclude(user=self.instance)
except:
pass
return qs

def toggle_follow(self, user, to_toggle_user):
user_profile = user.profile
if to_toggle_user in user_profile.following.all():
user_profile.following.remove(to_toggle_user)
adedd = False
else:
user_profile.following.add(to_toggle_user)
adedd = True
return adedd

def is_following(self, user, followed_by_user):
user_profile = user.profile
if followed_by_user in user_profile.following.all():
return True
return False


class Profile(models.Model):
user = models.OneToOneField(settings.AUTH_USER_MODEL, 
on_delete=models.CASCADE)
following = models.ManyToManyField(settings.AUTH_USER_MODEL, blank=True, 
related_name='followed_by')
date_of_birth = models.DateField(blank=True, null=True)
city = models.CharField(max_length=50, blank=True, null=True)
country = models.CharField(max_length=50, blank=True, null=True)
education = models.CharField(max_length=150, blank=True, null=True)
photo = models.ImageField(upload_to='profile photos/', blank=True, 
null=True)

objects = ProfileManager()

def __str__(self):
return 'Profile for user {}'.format(self.user.username)

def get_following(self):
users = self.following.all()
return users.exclude(username=self.user.username)

@receiver(post_save, sender=User)
def create_or_update_user_profile(sender, instance, created, *args, 
**kwargs):
if created:
Profile.objects.create(user=instance)

instance.profile.save() 

class Post(models.Model):
author = models.ForeignKey(settings.AUTH_USER_MODEL)
profile = models.ForeignKey(Profile)
title = models.CharField(max_length=200)
content = models.TextField()
image = models.FileField(upload_to='posts/', blank=True)
created = models.DateTimeField(auto_now_add=True, db_index=True)
modified = models.DateTimeField(auto_now=True)
slug = models.SlugField(unique=True)
likes = models.PositiveIntegerField(default=0)

@property
def total_likes(self):
return self.likes.count()

def __str__(self):
return self.title

class Meta:
ordering = ["-created"]

def get_absolute_url(self):
return reverse("detail", kwargs={"slug": self.slug})

def _get_unique_slug(self):
slug = slugify(self.title)
unique_slug = slug
num = 1
while Post.objects.filter(slug=unique_slug).exists():
unique_slug = '{}-{}'.format(slug, num)
num += 1
return unique_slug

def save(self, *args, **kwargs):
if not self.slug:
self.slug = self._get_unique_slug()
super(Post, self).save()


This is copy/pasting it :)
I still need to make that queryset to show a list of posts the users that I 
follow(and myself) with Profile combined or showing the post.content and 
profile.photo. 



On Thursday, December 22, 2016 at 2:26:36 PM UTC+1, Melvyn Sopacua wrote:
>
> Hi, 
>
> not sure why you're screenshotting code instead of copying it...makes it 
> harder to point you at the mistake. 
>
> On Wednesday 21 December 2016 14:33:58 skerdi wrote: 
> > *In a  post list I've shown only the users posts that I follow but I'm 
> > not able to display their photo. * 
>
> in Profile.get_photo() you set users to self.photo. I don't think you 
> wanted to do that. 
>
> -- 
> 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/b86e2526-8ade-4f5c-9ddf-e3cca81150cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django.db.migrations.graph.NodeNotFoundError:

2016-12-22 Thread skerdi
I have the same problem, but with an existing project. I've deleted 
migrations and the database and shows the same problem.
I have 2+ hours searching but I haven't fixed it. 

On Wednesday, June 1, 2016 at 12:58:55 AM UTC+2, Bose Yi wrote:
>
> When new project start,   commands makemigrations and runserver  get 
>  error message.I do not know what I did wrong.   I cannot find solution 
> to fix it.  Please  any suggestion ? 
>
>
> 
>
> System check identified no issues (0 silenced).
>
> Unhandled exception in thread started by 
>
> Traceback (most recent call last):
>
>   File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 
> 229, in wrapper
>
> fn(*args, **kwargs)
>
>   File 
> "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", 
> line 116, in inner_run
>
> self.check_migrations()
>
>   File 
> "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", 
> line 168, in check_migrations
>
> executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
>
>   File "C:\Python27\lib\site-packages\django\db\migrations\executor.py", 
> line 19, in __init__
>
> self.loader = MigrationLoader(self.connection)
>
>   File "C:\Python27\lib\site-packages\django\db\migrations\loader.py", 
> line 47, in __init__
>
> self.build_graph()
>
>   File "C:\Python27\lib\site-packages\django\db\migrations\loader.py", 
> line 318, in build_graph
>
> _reraise_missing_dependency(migration, parent, e)
>
>   File "C:\Python27\lib\site-packages\django\db\migrations\loader.py", 
> line 288, in _reraise_missing_dependency
>
> raise exc
>
> django.db.migrations.graph.NodeNotFoundError: Migration 
> auth.0007_user_following dependencies reference nonexistent parent node 
> (u'account', u'0003_contact')
>

-- 
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/5b1ee73e-b8cc-4542-8d80-9ef33c25a4cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How can I access field values generically?

2016-12-22 Thread Mike Dewhirst
Very generous. Thank you. It looks as though you did get the model 
structure. Your first comment nails it because mixtures can have other 
mixtures as ingredients. I'm right into recursion nowadays :)


Mike

On 22/12/2016 7:48 PM, C. Kirby wrote:
Ill be honest, I'm still not getting how your models are structured. 
That is ok though, I can give you some pointers and hopefully  that 
will be sufficient. I'll also be very explicit in describing the 
steps. Several are probably better as single orm calls. _meta docs at 
https://docs.djangoproject.com/en/1.10/ref/models/meta/


Hope this helps. If you have any clarifying questions I am happy to 
chime in more.


|
fromdjango.db.models importTextField
#First get all ingredients you are interested in (I am assuming that
#mixtures are only one level deep, if not then build a recursive call)
ingredients =Substance_Ingredients.objects.filter(substance=substance>).values_list('ingredient.pk',flat=True)

#Get the substance instances for these
child_substances =Substance.objects.filter(pk__in =ingredients)
target_text =''
forcs inchild_substance:
#Get all OneToOne and OneToMany fields

models =[
(f,f.model iff.model !=(SubstanceorSubstanceIngredient)elseNone)
forf inSubstance._meta.get_fields()
if(f.one_to_many orf.one_to_one)
andnotf.auto_created andnotf.concrete
]

ingredient_text =''
forfield,model inmodels:
#Check the model for TextFields
tfs =[f forf inmodel._met.get_fields()ifisinstance(f,TextField)]
#get the textfield attributes for your substance field
field_text =[getattr(field,tf,'')fortf intfs]
#compile you text strings at the necessary levels
ingredient_text ='{}, 
{}'.format(ingredient_text,'.'.join(field_text))


child_text ='{}: {}'.format(cs.substance_name,ingredient_text)
target_text ='{}\n{}'.formate(target_text,child_text)

#Save you target text to the original substance
|


--
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/b39f85e3-1ecc-4a2f-93e7-f6f426a63520%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/d26f3359-1282-284b-910b-53a96706a060%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: Unique app name error problem when building a Wagtail multisite solution

2016-12-22 Thread 'Matthias Brück' via Django users
Hi Melvyn,

thanks for your answer. Unfortunately switching the CMS isn't an option. 
And even if I skip the multisite requirements i could think of usecases 
where it might be a problem in just a django project as well, wanting to 
have a similar project structure, doesn't it?

Am Donnerstag, 22. Dezember 2016 13:16:45 UTC+1 schrieb Melvyn Sopacua:
>
> Hi, 
>
> On Wednesday 21 December 2016 14:30:32 'Matthias Brück' via Django users 
> wrote: 
> > is this really just not possible? What I found is this: 
> > 
> > you can't have two apps with the same name, even if they have 
> > different 
> > > fully qualified module paths 
> > 
> > https://groups.google.com/forum/#!msg/django-users/AMYLfQo6Ba4/Y-57B0i 
> > 7qy4J 
> > 
> > How would you guys handle this? 
>
> By picking the right tool for the job. Judging from 1.8 Release notes, 
> Wagtail is working towards multi-tenancy, but isn't there yet. So, pick 
> a different CMS (for example Mezzanine) that is. Especially one that 
> uses the multi-tenancy that is built-in to django through the sites 
> module. 
> Don't work against the flow :) 
> -- 
> 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/7e1d0676-0715-4a42-ae24-5de2406ed5b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Form Validation Error NOT Raised When Form Is Submitted

2016-12-22 Thread Chris Kavanagh
I have a model form called *"ContactForm" *that has an email field. I 
created a custom* forms.ValidationError* in *"clean_email"* method

 which checks to see if the email is already in the database , however it's 
never raised on submit.


 When submit is called, the view runs and I get the error *"The view 
customer.views.send_email didn't return an HttpResponse object.*

* It returned None instead"*, because it's not being passed an actual 
email. . 

I don't understand why the *forms.ValidationError* isn't stopping it from 
being submitted? The query in the *"clean_email"* works fine, so that's not 
the problem.

I've used this same code before with no problems. I'm sure it's something 
easy I'm forgetting or missing, but any help is GREATLY appreciated. .

Note: I am using django crispy forms


*#Model:*
class Customer(models.Model):
email = models.EmailField(max_length=70,blank=False)
created = models.DateTimeField(auto_now_add=True)

class Meta:
ordering = ('email',)

def __unicode__(self):
return self.email




*#Form:*
class ContactForm(forms.ModelForm):

class Meta:
model = Customer
fields = ['email']

def clean_email(self):
email = self.cleaned_data['email']
cust_email = Customer.objects.filter(email=email).count()
if cust_email:
raise forms.ValidationError('This email is already in use.')
return email




*#View:*
def send_email(request):
if request.method == 'POST':
form = ContactForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
email = cd['email']
new_email = form.save(commit=True)
to_email = form.cleaned_data['email']   # cd['email']
subject = 'Newsletter'
from_email = settings.EMAIL_HOST_USER
message = 'You Are Now Signed Up For BenGui Newsletter!'
#send_mail(subject, message, from_email, [to_email,], 
fail_silently=False)
return redirect('home')
else:
return render(request, 'home.html', context)



*#customer.urls:*

urlpatterns = [
url(r'^send-email/$', views.send_email, name='send_email'),
]


#Template:


{% csrf_token %}
{{ form|crispy }}



-- 
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/8ff5313f-3783-4897-afa7-5edd4fe1b436%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do you recommend to use Hebrew gender-related translations?

2016-12-22 Thread Avraham Serour
maybe translation context?
https://docs.djangoproject.com/en/dev/topics/i18n/translation/#contextual-markers


On Thu, Dec 22, 2016 at 9:29 PM, Fergus Cameron  wrote:

> I personally try to use language agnostic message IDs and translate
> everything (i.e. including English).  Your idea of appending the
> gender is along the same lines and seems logical.
>
> On 22/12/2016, Uri Even-Chen  wrote:
> > Hi Django users,
> >
> > How do you recommend to use Hebrew gender-related translations?
> >
> > For example, here are the choices for diet in Speedy Net (notice it's
> > currently only used in Speedy Match, but it's part of the profile of
> Speedy
> > Net):
> >
> > ```
> > class User(Entity, PermissionsMixin, AbstractBaseUser):
> > 
> > GENDER_FEMALE = 1
> > GENDER_MALE = 2
> > GENDER_OTHER = 3
> > GENDER_CHOICES = (
> > (GENDER_FEMALE, _('Female')),
> > (GENDER_MALE, _('Male')),
> > (GENDER_OTHER, _('Other')),
> > )
> >
> > DIET_UNKNOWN   = 0
> > DIET_VEGAN  = 1
> > DIET_VEGETARIAN = 2
> > DIET_CARNIST= 3
> > DIET_CHOICES = (
> > (DIET_UNKNOWN, _('Please select...')),
> > (DIET_VEGAN, _('Vegan (eats only plants and fungi)')),
> > (DIET_VEGETARIAN, _('Vegetarian (doesn\'t eat fish and meat)')),
> > (DIET_CARNIST, _('Carnist (eats animals)'))
> > )
> > 
> > gender = models.SmallIntegerField(verbose_name=_('I am'),
> > choices=GENDER_CHOICES)
> > diet = models.SmallIntegerField(verbose_name=_('diet'),
> > choices=DIET_CHOICES, default=DIET_UNKNOWN)
> > ```
> >
> > And here are the translations:
> > ```
> > #: .\accounts\models.py:151
> > msgid "Vegan (eats only plants and fungi)"
> > msgstr "טבעוני/ת (אוכל/ת רק צמחים ופטריות)"
> >
> > #: .\accounts\models.py:152
> > msgid "Vegetarian (doesn't eat fish and meat)"
> > msgstr "צמחוני/ת (לא אוכל/ת דגים ובשר)"
> >
> > #: .\accounts\models.py:153
> > msgid "Carnist (eats animals)"
> > msgstr "קרניסט/ית (אוכל/ת חיות)"
> > ```
> >
> > The correct translations in Hebrew are per gender (female, male or other)
> > but in English they are the same. How do you recommend to program it? I
> > thought about adding " [female]", " [male]" or " [other]" suffixes to the
> > strings and then removing them in the English translations. But then
> > English would also require a translation. Is there a better approach? And
> > how do I write the model when this feature is gender-related?
> >
> > The same question is related to any site which has a language where the
> > text is gender-related, and a language where it is not.
> >
> > You can see the code on GitHub: https://github.com/
> urievenchen/speedy-net
> >
> > Thanks,
> > Uri.
> >
> > *Uri Even-Chen*
> > [image: photo] Phone: +972-54-3995700
> > Email: u...@speedy.net
> > Website: http://www.speedysoftware.com/uri/en/
> > 
> > 
> >     <
> http://github.com/urievenchen>
> > 
> >
> > --
> > 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/CAMQ2MsGv_
> fvj6ijM4rb-Y7XfQeGbPJvd38_7o_LYbiukuhxyrg%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/CAHCf7OFGAsD5dAWKOwM535U7ChftJ3LLM9BS2u%3DHPm9Oiued_Q%
> 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/CAFWa6t%2BwK%2BZBGuayQp8RBpfbC%3DE5QtshfJC13ANMdqru9WCENw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do you recommend to use Hebrew gender-related translations?

2016-12-22 Thread Fergus Cameron
I personally try to use language agnostic message IDs and translate
everything (i.e. including English).  Your idea of appending the
gender is along the same lines and seems logical.

On 22/12/2016, Uri Even-Chen  wrote:
> Hi Django users,
>
> How do you recommend to use Hebrew gender-related translations?
>
> For example, here are the choices for diet in Speedy Net (notice it's
> currently only used in Speedy Match, but it's part of the profile of Speedy
> Net):
>
> ```
> class User(Entity, PermissionsMixin, AbstractBaseUser):
> 
> GENDER_FEMALE = 1
> GENDER_MALE = 2
> GENDER_OTHER = 3
> GENDER_CHOICES = (
> (GENDER_FEMALE, _('Female')),
> (GENDER_MALE, _('Male')),
> (GENDER_OTHER, _('Other')),
> )
>
> DIET_UNKNOWN   = 0
> DIET_VEGAN  = 1
> DIET_VEGETARIAN = 2
> DIET_CARNIST= 3
> DIET_CHOICES = (
> (DIET_UNKNOWN, _('Please select...')),
> (DIET_VEGAN, _('Vegan (eats only plants and fungi)')),
> (DIET_VEGETARIAN, _('Vegetarian (doesn\'t eat fish and meat)')),
> (DIET_CARNIST, _('Carnist (eats animals)'))
> )
> 
> gender = models.SmallIntegerField(verbose_name=_('I am'),
> choices=GENDER_CHOICES)
> diet = models.SmallIntegerField(verbose_name=_('diet'),
> choices=DIET_CHOICES, default=DIET_UNKNOWN)
> ```
>
> And here are the translations:
> ```
> #: .\accounts\models.py:151
> msgid "Vegan (eats only plants and fungi)"
> msgstr "טבעוני/ת (אוכל/ת רק צמחים ופטריות)"
>
> #: .\accounts\models.py:152
> msgid "Vegetarian (doesn't eat fish and meat)"
> msgstr "צמחוני/ת (לא אוכל/ת דגים ובשר)"
>
> #: .\accounts\models.py:153
> msgid "Carnist (eats animals)"
> msgstr "קרניסט/ית (אוכל/ת חיות)"
> ```
>
> The correct translations in Hebrew are per gender (female, male or other)
> but in English they are the same. How do you recommend to program it? I
> thought about adding " [female]", " [male]" or " [other]" suffixes to the
> strings and then removing them in the English translations. But then
> English would also require a translation. Is there a better approach? And
> how do I write the model when this feature is gender-related?
>
> The same question is related to any site which has a language where the
> text is gender-related, and a language where it is not.
>
> You can see the code on GitHub: https://github.com/urievenchen/speedy-net
>
> Thanks,
> Uri.
>
> *Uri Even-Chen*
> [image: photo] Phone: +972-54-3995700
> Email: u...@speedy.net
> Website: http://www.speedysoftware.com/uri/en/
> 
> 
>     
> 
>
> --
> 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/CAMQ2MsGv_fvj6ijM4rb-Y7XfQeGbPJvd38_7o_LYbiukuhxyrg%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/CAHCf7OFGAsD5dAWKOwM535U7ChftJ3LLM9BS2u%3DHPm9Oiued_Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


ProgrammingError: relation "auth_user" does not exist.

2016-12-22 Thread Biplab Gautam
I tried to set up custom user model by inheriting from AbstractBaseUser as 
instructed in django documentation, but I am encountering relation 
"auth_user" does not exist error.

#models.py
from django.db import models
from django.contrib.auth.models import (BaseUserManager, AbstractBaseUser)

class MyUserManager(BaseUserManager):
def create_user(self, email, date_of_birth, password=None):
"""Creates and saves the user with the given email, DOB and password"""
if not email:
raise ValueError('Users must have an email address')
user = 
self.model(email=self.normalize_email(email),date_of_birth=date_of_birth,)
user.set_password(password)
user.save(using=self._db)
return user

def create_superuser(self, email, date_of_birth, password):
"""Creates and saves a superuser with the given email, date of birth and 
password."""
user = self.create_user(email, password=password, 
date_of_birth=date_of_birth)
user.is_admin = True
user.save(using=self._db)
return user

class MyUser(AbstractBaseUser):
email = models.EmailField(verbose_name='email address', max_length=255, 
unique=True,)
date_of_birth = models.DateField()
is_active = models.BooleanField(default=True)
is_admin = models.BooleanField(default=False)

objects = MyUserManager()

USERNAME_FIELD = 'email'
REQUIRED_FIELDS = ['date_of_birth']

def get_full_name(self):
return self.email
def get_short_name(self):
return self.email
def __str__(self):
return self.email
def has_perm(self, perm, obj=None):
return True
def has_module_perms(self, app_label):
return True
@property
def is_staff(self):
return self.is_admin

#admin.py
from django import forms
from django.contrib import admin
from django.contrib.auth.models import Group
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.contrib.auth.forms import ReadOnlyPasswordHashField

from user.models import MyUser

class UserCreationForm(forms.ModelForm):
"""A form for creating new users. Includes all the required fields, plus a 
repeated password."""
password1 = forms.CharField(label='Password', widget=forms.PasswordInput)
password2 = forms.CharField(label='Password confirmation', 
widget=forms.PasswordInput)

class Meta:
model = MyUser
fields = ('email', 'date_of_birth')

def clean_password2(self):
"""Check that the two password entries match"""
password1 = self.cleaned_data.get("password1")
password2 = self.cleaned_data.get("password2")
if password1 and password2 and password1 != password2:
raise forms.ValidationError("Passwords don't match")
return password2

def save(self, commit=True):
#Save the provided password in hashed format
user = super(UserCreationForm, self).save(commit=False)
user.set_password(self.cleaned_data["password1"])
if commit:
user.save()
return user
class UserChangeForm(forms.ModelForm):
"""A form for updating users. Includes all the fields on the user, but 
replaces the password field with admin's password hash display field."""
password = ReadOnlyPasswordHashField()
class Meta:
model = MyUser
fields = ('email', 'password', 'date_of_birth', 'is_active', 'is_admin')
def clean_password(self):
return self.initial["password"]
# Regardless of what the user provides, return the initial value.
# This is done here, rather than on the field, because the
# field does not have access to the initial value



class UserAdmin(BaseUserAdmin):
# The forms to add and change user instances
form = UserChangeForm
add_form = UserCreationForm

# The fields to be used in displaying the User model.
# These override the definitions on the base UserAdmin
# that reference specific fields on auth.User.
list_display = ('email', 'date_of_birth', 'is_admin')
list_filter = ('is_admin',)
fieldsets = (
(None, {'fields': ('email', 'password')}),
('Personal info', {'fields': ('date_of_birth',)}),
('Permissions', {'fields': ('is_admin',)}),
)
# add_fieldsets is not a standard ModelAdmin attribute. UserAdmin
# overrides get_fieldsets to use this attribute when creating a user.
add_fieldsets = (
(None, {
'classes': ('wide',),
'fields': ('email', 'date_of_birth', 'password1', 'password2')}
),
)
search_fields = ('email',)
ordering = ('email',)
filter_horizontal = ()

# Now register the new UserAdmin...
admin.site.register(MyUser, UserAdmin)
# ... and, since we're not using Django's built-in permissions,
# unregister the Group model from admin.
admin.site.unregister(Group)

#views.py
from django.shortcuts import render

from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.contrib.auth import login, authenticate, logout
from django.contrib.auth.forms import UserCreationForm

def logout_view(request):
"""Log the user out """
logout(request)
return HttpResponseRedirect(reverse('home_page:subject_select'))

def register(request):
"""Registers a new user"""
if request.method != 'POST':
#Display blank registration 

How do I translate site.name to other languages?

2016-12-22 Thread Uri Even-Chen
Hi Django users,

We have our site.name and other site names (we have 4 sites in Django right
now) in templates such as base.html. The site is taken from model Site
(```from django.contrib.sites.models import Site```). In templates we just
use "{{ site.name }}" or "{{ other_site.name }}". How do we translate these
site names to other languages? What is the correct way? Currently I only
need the site names in English and Hebrew, but maybe later I will want
other languages too.

Our settings file translates the site title. Is it better to translate it
in the templates? Because we don't want to translate it twice. If the site
title is not defined, the default is the site name (which we want for 2 of
our sites). But we need it translated.

from django.conf import settings as dj_settings
from django.contrib.sites.models import Site


def sites(request):
site = Site.objects.get_current()
site_title = site.name
if hasattr(dj_settings, 'SITE_TITLE'):
site_title = dj_settings.SITE_TITLE
return {
'site': site,
'site_title': site_title,
'sites': Site.objects.all().order_by('pk'),
}


You can see the code on GitHub: https://github.com/urievenchen/speedy-net

Thanks,
Uri.

*Uri Even-Chen*
[image: photo] Phone: +972-54-3995700
Email: u...@speedy.net
Website: http://www.speedysoftware.com/uri/en/
  
    


-- 
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/CAMQ2MsHRPzzdGVcQi1D0g%2BPe6GS0gjhbZaEOrUvH0-PMGq%3DdRg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: starting django

2016-12-22 Thread Antonis Christofides
You typed pools instead of polls in your browser.

Antonis Christofides
http://djangodeployment.com


On 12/22/2016 06:29 PM, Giovanni Oliverio wrote:
>
> Hello, I'm following the guide at the following link:
> https://docs.djangoproject.com/en/1.10/intro/tutorial01/ but when I go to call
> the page:  http://localhost:8000/polls/the result is the following:
> 
> where am I wrong?
> -- 
> 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/e6332dc6-1b8e-4c98-bb9b-e966c49578be%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/3ee08ffa-dcea-1fc7-956f-dcd7ba063da5%40djangodeployment.com.
For more options, visit https://groups.google.com/d/optout.


Re: starting django

2016-12-22 Thread pradam programmer
just correct pools to polls in url

On Thu, Dec 22, 2016 at 9:59 PM, Giovanni Oliverio 
wrote:

>
> Hello, I'm following the guide at the following link:
> https://docs.djangoproject.com/en/1.10/intro/tutorial01/ but when I go to
> call the page:  http://localhost:8000/polls/ the result is the following:
>
>
> 
>
>
>
> where am I wrong?
>
> --
> 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/e6332dc6-1b8e-4c98-bb9b-e966c49578be%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/CAGGVXBNuWAi-PxA8ggqmmuy9OOLXkOUSd9Nm%3D7HWENw0rScZLA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


starting django

2016-12-22 Thread Giovanni Oliverio

Hello, I'm following the guide at the following link: 
https://docs.djangoproject.com/en/1.10/intro/tutorial01/ but when I go to 
call the page:  http://localhost:8000/polls/ the result is the following:


 



where am I wrong?

-- 
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/e6332dc6-1b8e-4c98-bb9b-e966c49578be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Channels - WebSocket connection to 'wss://mysite.local/chat/stream/' failed: WebSocket is closed before the connection is established. response code: 200

2016-12-22 Thread Adam Teale
I do have the mod_proxy_wstunnel module loaded.
I realised that I am getting an error in apache:

No protocol handler was valid for the URL /chat/stream/. If you are using a 
DSO version of mod_proxy, make sure the proxy submodules are included in 
the configuration using LoadModule.

I've tried a lot of the suggestions i've sound through google but nothing 
seems to work. Perhaps this Mac OS X Server.app Apache install has issues. 

Thanks anyway Andrew!



On Thursday, 22 December 2016 13:15:36 UTC-3, Andrew Godwin wrote:
>
> Apache's default mod_proxy does not support WebSockets. If you want to 
> keep using Apache I would consider looking at mod_proxy_wstunnel.
>
> Andrew
>
> On Thu, Dec 22, 2016 at 2:24 PM, Adam Teale  > wrote:
>
>> Hi everyone,
>>
>> I have a django app running on mac os x server via mod_wsgi (apache 2.4).
>>
>> I am using proxypass to point to daphne (running on port 8000).
>>
>> As far as I can tell things should be running ok. Daphne is being run via 
>> this command:
>>
>> daphne mysite.asgi:channel_layer -v2 -p 8000
>>
>> When ever I access the url with the Channels chat demo app (/chat) daphne 
>> prints the following:
>>
>> 2016-12-22 10:58:15,398 INFO Starting server at 127.0.0.1:8000, 
>> channel layer mysite.asgi:channel_layer
>>
>> 2016-12-22 10:58:15,400 INFO Using busy-loop synchronous mode on 
>> channel layer
>>
>> 2016-12-22 10:58:18,342 DEBUGHTTP GET request for 
>> http.response!SAKtXWGjqdCG
>>
>> 2016-12-22 10:58:18,373 DEBUGHTTP 200 response started for 
>> http.response!SAKtXWGjqdCG
>>
>> 2016-12-22 10:58:18,373 DEBUGHTTP close for http.response!SAKtXWGjqdCG
>>
>> 2016-12-22 10:58:18,374 DEBUGHTTP response complete for 
>> http.response!SAKtXWGjqdCG
>>
>> 127.0.0.1:49944 - - [22/Dec/2016:10:58:18] "GET /chat/" 200 6550
>>
>> 2016-12-22 10:58:18,440 DEBUGHTTP GET request for 
>> http.response!mDjckxncNYGS
>>
>> 2016-12-22 10:58:18,476 DEBUGHTTP 200 response started for 
>> http.response!mDjckxncNYGS
>>
>> 2016-12-22 10:58:18,477 DEBUGHTTP close for http.response!mDjckxncNYGS
>>
>> 2016-12-22 10:58:18,477 DEBUGHTTP response complete for 
>> http.response!mDjckxncNYGS
>>
>> 127.0.0.1:49950 - - [22/Dec/2016:10:58:18] "GET /chat/stream/" 200 6550
>>
>> 2016-12-22 10:58:19,527 DEBUGHTTP GET request for 
>> http.response!lCwBwWsyjxGf
>>
>> 2016-12-22 10:58:19,550 DEBUGHTTP 200 response started for 
>> http.response!lCwBwWsyjxGf
>>
>> 2016-12-22 10:58:19,551 DEBUGHTTP close for http.response!lCwBwWsyjxGf
>>
>> 2016-12-22 10:58:19,551 DEBUGHTTP response complete for 
>> http.response!lCwBwWsyjxGf
>>
>> ...
>>
>>
>>
>>
>> The rqworker also:
>>
>>
>> mysite.local
>>
>> 2016-12-22 10:58:31,984 - DEBUG - worker - Got message on http.request 
>> (reply http.response!MLkDhtLSmyEy)
>>
>> 2016-12-22 10:58:31,985 - DEBUG - runworker - http.request
>>
>> 2016-12-22 10:58:31,985 - DEBUG - worker - Dispatching message on 
>> http.request to channels.staticfiles.StaticFilesConsumer
>>
>>
>> The error I am getting in safari & chrome is:
>> "WebSocket connection to 'wss://mysite.local/chat/stream/' failed: 
>> WebSocket is closed before the connection is established. response code: 
>> 200"
>>
>>
>> When I access the site on from the server via localhost:8000/chat 
>> everything works fine and daphne prints out:
>>
>> 2016-12-22 11:03:10,393 DEBUGHTTP GET request for 
>> http.response!MJBzHhZMRNnb
>>
>> 2016-12-22 11:03:10,406 DEBUGHTTP 200 response started for 
>> http.response!MJBzHhZMRNnb
>>
>> 2016-12-22 11:03:10,407 DEBUGHTTP close for http.response!MJBzHhZMRNnb
>>
>> 2016-12-22 11:03:10,407 DEBUGHTTP response complete for 
>> http.response!MJBzHhZMRNnb
>>
>> 127.0.0.1:50013 - - [22/Dec/2016:11:03:10] "GET /chat" 200 6550
>>
>> 2016-12-22 11:03:10,411 DEBUGWebSocket closed for 
>> websocket.send!wlxnNRjdYtZi
>>
>> 127.0.0.1:50026 - - [22/Dec/2016:11:03:10] "WSDISCONNECT /chat/stream/" 
>> - -
>>
>> 2016-12-22 11:03:10,413 DEBUGHTTP GET request for 
>> http.response!aGsxTkWhWXxh
>>
>> 2016-12-22 11:03:10,415 DEBUGHTTP GET request for 
>> http.response!fOyocApjCNFZ
>>
>> 2016-12-22 11:03:10,416 DEBUGHTTP GET request for 
>> http.response!EdzYIGSakoQB
>>
>> 2016-12-22 11:03:10,429 DEBUGHTTP 304 response started for 
>> http.response!fOyocApjCNFZ
>>
>> 2016-12-22 11:03:10,430 DEBUGHTTP close for http.response!fOyocApjCNFZ
>>
>> 2016-12-22 11:03:10,430 DEBUGHTTP response complete for 
>> http.response!fOyocApjCNFZ
>>
>> 127.0.0.1:50034 - - [22/Dec/2016:11:03:10] "GET 
>> /static/css/style_chat.css" 304 -
>>
>> 2016-12-22 11:03:10,431 DEBUGHTTP 304 response started for 
>> http.response!EdzYIGSakoQB
>>
>> 2016-12-22 11:03:10,432 DEBUGHTTP close for http.response!EdzYIGSakoQB
>>
>> 2016-12-22 11:03:10,432 DEBUGHTTP response complete for 
>> http.response!EdzYIGSakoQB
>>
>> 127.0.0.1:50035 - - [22/Dec/2016:11:03:10] "GET 
>> 

Re: Django Channels - WebSocket connection to 'wss://mysite.local/chat/stream/' failed: WebSocket is closed before the connection is established. response code: 200

2016-12-22 Thread Andrew Godwin
Apache's default mod_proxy does not support WebSockets. If you want to keep
using Apache I would consider looking at mod_proxy_wstunnel.

Andrew

On Thu, Dec 22, 2016 at 2:24 PM, Adam Teale  wrote:

> Hi everyone,
>
> I have a django app running on mac os x server via mod_wsgi (apache 2.4).
>
> I am using proxypass to point to daphne (running on port 8000).
>
> As far as I can tell things should be running ok. Daphne is being run via
> this command:
>
> daphne mysite.asgi:channel_layer -v2 -p 8000
>
> When ever I access the url with the Channels chat demo app (/chat) daphne
> prints the following:
>
> 2016-12-22 10:58:15,398 INFO Starting server at 127.0.0.1:8000,
> channel layer mysite.asgi:channel_layer
>
> 2016-12-22 10:58:15,400 INFO Using busy-loop synchronous mode on
> channel layer
>
> 2016-12-22 10:58:18,342 DEBUGHTTP GET request for
> http.response!SAKtXWGjqdCG
>
> 2016-12-22 10:58:18,373 DEBUGHTTP 200 response started for
> http.response!SAKtXWGjqdCG
>
> 2016-12-22 10:58:18,373 DEBUGHTTP close for http.response!SAKtXWGjqdCG
>
> 2016-12-22 10:58:18,374 DEBUGHTTP response complete for
> http.response!SAKtXWGjqdCG
>
> 127.0.0.1:49944 - - [22/Dec/2016:10:58:18] "GET /chat/" 200 6550
>
> 2016-12-22 10:58:18,440 DEBUGHTTP GET request for
> http.response!mDjckxncNYGS
>
> 2016-12-22 10:58:18,476 DEBUGHTTP 200 response started for
> http.response!mDjckxncNYGS
>
> 2016-12-22 10:58:18,477 DEBUGHTTP close for http.response!mDjckxncNYGS
>
> 2016-12-22 10:58:18,477 DEBUGHTTP response complete for
> http.response!mDjckxncNYGS
>
> 127.0.0.1:49950 - - [22/Dec/2016:10:58:18] "GET /chat/stream/" 200 6550
>
> 2016-12-22 10:58:19,527 DEBUGHTTP GET request for
> http.response!lCwBwWsyjxGf
>
> 2016-12-22 10:58:19,550 DEBUGHTTP 200 response started for
> http.response!lCwBwWsyjxGf
>
> 2016-12-22 10:58:19,551 DEBUGHTTP close for http.response!lCwBwWsyjxGf
>
> 2016-12-22 10:58:19,551 DEBUGHTTP response complete for
> http.response!lCwBwWsyjxGf
>
> ...
>
>
>
>
> The rqworker also:
>
>
> mysite.local
>
> 2016-12-22 10:58:31,984 - DEBUG - worker - Got message on http.request
> (reply http.response!MLkDhtLSmyEy)
>
> 2016-12-22 10:58:31,985 - DEBUG - runworker - http.request
>
> 2016-12-22 10:58:31,985 - DEBUG - worker - Dispatching message on
> http.request to channels.staticfiles.StaticFilesConsumer
>
>
> The error I am getting in safari & chrome is:
> "WebSocket connection to 'wss://mysite.local/chat/stream/' failed:
> WebSocket is closed before the connection is established. response code:
> 200"
>
>
> When I access the site on from the server via localhost:8000/chat
> everything works fine and daphne prints out:
>
> 2016-12-22 11:03:10,393 DEBUGHTTP GET request for
> http.response!MJBzHhZMRNnb
>
> 2016-12-22 11:03:10,406 DEBUGHTTP 200 response started for
> http.response!MJBzHhZMRNnb
>
> 2016-12-22 11:03:10,407 DEBUGHTTP close for http.response!MJBzHhZMRNnb
>
> 2016-12-22 11:03:10,407 DEBUGHTTP response complete for
> http.response!MJBzHhZMRNnb
>
> 127.0.0.1:50013 - - [22/Dec/2016:11:03:10] "GET /chat" 200 6550
>
> 2016-12-22 11:03:10,411 DEBUGWebSocket closed for
> websocket.send!wlxnNRjdYtZi
>
> 127.0.0.1:50026 - - [22/Dec/2016:11:03:10] "WSDISCONNECT /chat/stream/" -
> -
>
> 2016-12-22 11:03:10,413 DEBUGHTTP GET request for
> http.response!aGsxTkWhWXxh
>
> 2016-12-22 11:03:10,415 DEBUGHTTP GET request for
> http.response!fOyocApjCNFZ
>
> 2016-12-22 11:03:10,416 DEBUGHTTP GET request for
> http.response!EdzYIGSakoQB
>
> 2016-12-22 11:03:10,429 DEBUGHTTP 304 response started for
> http.response!fOyocApjCNFZ
>
> 2016-12-22 11:03:10,430 DEBUGHTTP close for http.response!fOyocApjCNFZ
>
> 2016-12-22 11:03:10,430 DEBUGHTTP response complete for
> http.response!fOyocApjCNFZ
>
> 127.0.0.1:50034 - - [22/Dec/2016:11:03:10] "GET
> /static/css/style_chat.css" 304 -
>
> 2016-12-22 11:03:10,431 DEBUGHTTP 304 response started for
> http.response!EdzYIGSakoQB
>
> 2016-12-22 11:03:10,432 DEBUGHTTP close for http.response!EdzYIGSakoQB
>
> 2016-12-22 11:03:10,432 DEBUGHTTP response complete for
> http.response!EdzYIGSakoQB
>
> 127.0.0.1:50035 - - [22/Dec/2016:11:03:10] "GET 
> /static/js/reconnecting-websocket.min.js"
> 304 -
>
> 2016-12-22 11:03:10,433 DEBUGHTTP 304 response started for
> http.response!aGsxTkWhWXxh
>
> 2016-12-22 11:03:10,433 DEBUGHTTP close for http.response!aGsxTkWhWXxh
>
> 2016-12-22 11:03:10,433 DEBUGHTTP response complete for
> http.response!aGsxTkWhWXxh
>
> 127.0.0.1:50013 - - [22/Dec/2016:11:03:10] "GET
> /static/js/jquery-1.12.2.min.js" 304 -
>
> 2016-12-22 11:03:10,446 DEBUGWebSocket open for
> websocket.send!GTaoMdCohNRJ
>
> 127.0.0.1:50038 - - [22/Dec/2016:11:03:10] "WSCONNECT /chat/stream/" - -
>
> 2016-12-22 11:03:10,447 DEBUGUpgraded connection
> http.response!uqNYcIilOUmR to WebSocket websocket.send!GTaoMdCohNRJ
>
>
> And the rqworker
>
> 2016-12-22 

How do you recommend to use Hebrew gender-related translations?

2016-12-22 Thread Uri Even-Chen
Hi Django users,

How do you recommend to use Hebrew gender-related translations?

For example, here are the choices for diet in Speedy Net (notice it's
currently only used in Speedy Match, but it's part of the profile of Speedy
Net):

```
class User(Entity, PermissionsMixin, AbstractBaseUser):

GENDER_FEMALE = 1
GENDER_MALE = 2
GENDER_OTHER = 3
GENDER_CHOICES = (
(GENDER_FEMALE, _('Female')),
(GENDER_MALE, _('Male')),
(GENDER_OTHER, _('Other')),
)

DIET_UNKNOWN   = 0
DIET_VEGAN  = 1
DIET_VEGETARIAN = 2
DIET_CARNIST= 3
DIET_CHOICES = (
(DIET_UNKNOWN, _('Please select...')),
(DIET_VEGAN, _('Vegan (eats only plants and fungi)')),
(DIET_VEGETARIAN, _('Vegetarian (doesn\'t eat fish and meat)')),
(DIET_CARNIST, _('Carnist (eats animals)'))
)

gender = models.SmallIntegerField(verbose_name=_('I am'),
choices=GENDER_CHOICES)
diet = models.SmallIntegerField(verbose_name=_('diet'),
choices=DIET_CHOICES, default=DIET_UNKNOWN)
```

And here are the translations:
```
#: .\accounts\models.py:151
msgid "Vegan (eats only plants and fungi)"
msgstr "טבעוני/ת (אוכל/ת רק צמחים ופטריות)"

#: .\accounts\models.py:152
msgid "Vegetarian (doesn't eat fish and meat)"
msgstr "צמחוני/ת (לא אוכל/ת דגים ובשר)"

#: .\accounts\models.py:153
msgid "Carnist (eats animals)"
msgstr "קרניסט/ית (אוכל/ת חיות)"
```

The correct translations in Hebrew are per gender (female, male or other)
but in English they are the same. How do you recommend to program it? I
thought about adding " [female]", " [male]" or " [other]" suffixes to the
strings and then removing them in the English translations. But then
English would also require a translation. Is there a better approach? And
how do I write the model when this feature is gender-related?

The same question is related to any site which has a language where the
text is gender-related, and a language where it is not.

You can see the code on GitHub: https://github.com/urievenchen/speedy-net

Thanks,
Uri.

*Uri Even-Chen*
[image: photo] Phone: +972-54-3995700
Email: u...@speedy.net
Website: http://www.speedysoftware.com/uri/en/
  
    


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


Re: Django stops working with RuntimeError: populate() isn't reentrant

2016-12-22 Thread pradam programmer
I restarted hundred times still can't able to rectify it

On 22 Dec 2016 9:07 pm, "ADEWALE ADISA"  wrote:

Restart the server
On Dec 22, 2016 4:27 PM, "pradam programmer" 
wrote:

> Hi Guys,
> I am unable to rectify this error I am doing the following things:
> 1. I am running the project in django 1.7 later upgraded to 1.7.11 to
> check whether I fix the issue but no use. :(
> 2. In settings.py I commented the allowed_host = [*] still no use :(
> I don't know why this error is coming..?
> 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/ms
> gid/django-users/CAGGVXBN%2BkjQZeyr2gTMEQm8NLJA8s1MeLJ7tGsjh
> __wA5D-LLA%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/CAMGzuy8QL1FEodO%2BW30g_c9w5z801jMrgdaM6y90woraSjj6KQ%
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/CAGGVXBOKK1L-eVzduEqZ9P7-G2JE%3D-357nh0_1z3NaEhJ8YswA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django stops working with RuntimeError: populate() isn't reentrant

2016-12-22 Thread ADEWALE ADISA
Restart the server
On Dec 22, 2016 4:27 PM, "pradam programmer" 
wrote:

> Hi Guys,
> I am unable to rectify this error I am doing the following things:
> 1. I am running the project in django 1.7 later upgraded to 1.7.11 to
> check whether I fix the issue but no use. :(
> 2. In settings.py I commented the allowed_host = [*] still no use :(
> I don't know why this error is coming..?
> 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/CAGGVXBN%2BkjQZeyr2gTMEQm8NLJA8s1MeLJ7t
> Gsjh__wA5D-LLA%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/CAMGzuy8QL1FEodO%2BW30g_c9w5z801jMrgdaM6y90woraSjj6KQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django stops working with RuntimeError: populate() isn't reentrant

2016-12-22 Thread pradam programmer
Hi Guys,
I am unable to rectify this error I am doing the following things:
1. I am running the project in django 1.7 later upgraded to 1.7.11 to check
whether I fix the issue but no use. :(
2. In settings.py I commented the allowed_host = [*] still no use :(
I don't know why this error is coming..?
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/CAGGVXBN%2BkjQZeyr2gTMEQm8NLJA8s1MeLJ7tGsjh__wA5D-LLA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Postgres SQL vs SQLite vs MS SQL vs MY SQL

2016-12-22 Thread Tim Chase
On 2016-12-22 03:56, NoviceSortOf wrote:
> Our DB requirements though are complicated by the need to work with
> Asian languages, Chinese, Japanese and so on as well as European
> languages.

If you are genuinely interested in MS-SQL Server, I would spin up a
simple test server and bang against it.  Especially when it comes to
these international characters.  I've had issues with how it treats
Unicode regardless of my settings and encodings (UTF-8 and UTF-16 can
get truncated mid-sequence, spotty support for anything beyond 16-bit
character ranges, tooling support for such characters, etc).  If
you're willing to treat your strings as opaque binary blobs and do
all your character translation in Python, it's a little less
headache.

I used to be more vociferously against MSSQL due to its lack of
OFFSET support, but have since learned that OFFSET is almost always
the wrong solution and keysets+indexes almost always offer a more
performant (and reliable) solution.  So while OFFSET is nice for
dev/testing, I now try to avoid it in production.

While MSSQL has some great features, my only reservations now boil
down to licensing:  both in terms of monetary cost (especially when
scaling) and availability of F/LOSS connectors.  It can be done, but
make sure that the benefits you receive are worth those costs.

I wouldn't touch MySQL with a 10-foot pole thanks to Oracle.  Its
sister MariaDB (MySQL-minus-Oracle) has a few benefits, but more
weirdnesses than I like to have when entrusting it with my data
https://grimoire.ca/mysql/choose-something-else

As others have mentioned, sqlite is great for local dev work, but
doesn't scale as well.  The classic "sqlite is a replacement for
fopen()" is a good reminder.

-tim


-- 
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/20161222090316.05292535%40bigbox.christie.dr.
For more options, visit https://groups.google.com/d/optout.


Django Channels - WebSocket connection to 'wss://mysite.local/chat/stream/' failed: WebSocket is closed before the connection is established. response code: 200

2016-12-22 Thread Adam Teale
Hi everyone,

I have a django app running on mac os x server via mod_wsgi (apache 2.4).

I am using proxypass to point to daphne (running on port 8000).

As far as I can tell things should be running ok. Daphne is being run via 
this command:

daphne mysite.asgi:channel_layer -v2 -p 8000

When ever I access the url with the Channels chat demo app (/chat) daphne 
prints the following:

2016-12-22 10:58:15,398 INFO Starting server at 127.0.0.1:8000, channel 
layer mysite.asgi:channel_layer

2016-12-22 10:58:15,400 INFO Using busy-loop synchronous mode on 
channel layer

2016-12-22 10:58:18,342 DEBUGHTTP GET request for 
http.response!SAKtXWGjqdCG

2016-12-22 10:58:18,373 DEBUGHTTP 200 response started for 
http.response!SAKtXWGjqdCG

2016-12-22 10:58:18,373 DEBUGHTTP close for http.response!SAKtXWGjqdCG

2016-12-22 10:58:18,374 DEBUGHTTP response complete for 
http.response!SAKtXWGjqdCG

127.0.0.1:49944 - - [22/Dec/2016:10:58:18] "GET /chat/" 200 6550

2016-12-22 10:58:18,440 DEBUGHTTP GET request for 
http.response!mDjckxncNYGS

2016-12-22 10:58:18,476 DEBUGHTTP 200 response started for 
http.response!mDjckxncNYGS

2016-12-22 10:58:18,477 DEBUGHTTP close for http.response!mDjckxncNYGS

2016-12-22 10:58:18,477 DEBUGHTTP response complete for 
http.response!mDjckxncNYGS

127.0.0.1:49950 - - [22/Dec/2016:10:58:18] "GET /chat/stream/" 200 6550

2016-12-22 10:58:19,527 DEBUGHTTP GET request for 
http.response!lCwBwWsyjxGf

2016-12-22 10:58:19,550 DEBUGHTTP 200 response started for 
http.response!lCwBwWsyjxGf

2016-12-22 10:58:19,551 DEBUGHTTP close for http.response!lCwBwWsyjxGf

2016-12-22 10:58:19,551 DEBUGHTTP response complete for 
http.response!lCwBwWsyjxGf

...




The rqworker also:


mysite.local

2016-12-22 10:58:31,984 - DEBUG - worker - Got message on http.request 
(reply http.response!MLkDhtLSmyEy)

2016-12-22 10:58:31,985 - DEBUG - runworker - http.request

2016-12-22 10:58:31,985 - DEBUG - worker - Dispatching message on 
http.request to channels.staticfiles.StaticFilesConsumer


The error I am getting in safari & chrome is:
"WebSocket connection to 'wss://mysite.local/chat/stream/' failed: 
WebSocket is closed before the connection is established. response code: 
200"


When I access the site on from the server via localhost:8000/chat 
everything works fine and daphne prints out:

2016-12-22 11:03:10,393 DEBUGHTTP GET request for 
http.response!MJBzHhZMRNnb

2016-12-22 11:03:10,406 DEBUGHTTP 200 response started for 
http.response!MJBzHhZMRNnb

2016-12-22 11:03:10,407 DEBUGHTTP close for http.response!MJBzHhZMRNnb

2016-12-22 11:03:10,407 DEBUGHTTP response complete for 
http.response!MJBzHhZMRNnb

127.0.0.1:50013 - - [22/Dec/2016:11:03:10] "GET /chat" 200 6550

2016-12-22 11:03:10,411 DEBUGWebSocket closed for 
websocket.send!wlxnNRjdYtZi

127.0.0.1:50026 - - [22/Dec/2016:11:03:10] "WSDISCONNECT /chat/stream/" - -

2016-12-22 11:03:10,413 DEBUGHTTP GET request for 
http.response!aGsxTkWhWXxh

2016-12-22 11:03:10,415 DEBUGHTTP GET request for 
http.response!fOyocApjCNFZ

2016-12-22 11:03:10,416 DEBUGHTTP GET request for 
http.response!EdzYIGSakoQB

2016-12-22 11:03:10,429 DEBUGHTTP 304 response started for 
http.response!fOyocApjCNFZ

2016-12-22 11:03:10,430 DEBUGHTTP close for http.response!fOyocApjCNFZ

2016-12-22 11:03:10,430 DEBUGHTTP response complete for 
http.response!fOyocApjCNFZ

127.0.0.1:50034 - - [22/Dec/2016:11:03:10] "GET /static/css/style_chat.css" 
304 -

2016-12-22 11:03:10,431 DEBUGHTTP 304 response started for 
http.response!EdzYIGSakoQB

2016-12-22 11:03:10,432 DEBUGHTTP close for http.response!EdzYIGSakoQB

2016-12-22 11:03:10,432 DEBUGHTTP response complete for 
http.response!EdzYIGSakoQB

127.0.0.1:50035 - - [22/Dec/2016:11:03:10] "GET 
/static/js/reconnecting-websocket.min.js" 304 -

2016-12-22 11:03:10,433 DEBUGHTTP 304 response started for 
http.response!aGsxTkWhWXxh

2016-12-22 11:03:10,433 DEBUGHTTP close for http.response!aGsxTkWhWXxh

2016-12-22 11:03:10,433 DEBUGHTTP response complete for 
http.response!aGsxTkWhWXxh

127.0.0.1:50013 - - [22/Dec/2016:11:03:10] "GET 
/static/js/jquery-1.12.2.min.js" 304 -

2016-12-22 11:03:10,446 DEBUGWebSocket open for 
websocket.send!GTaoMdCohNRJ

127.0.0.1:50038 - - [22/Dec/2016:11:03:10] "WSCONNECT /chat/stream/" - -

2016-12-22 11:03:10,447 DEBUGUpgraded connection 
http.response!uqNYcIilOUmR to WebSocket websocket.send!GTaoMdCohNRJ


And the rqworker

2016-12-22 11:03:43,757 - DEBUG - worker - Got message on http.request 
(reply http.response!lSnLnqtZGeAQ)

2016-12-22 11:03:43,758 - DEBUG - runworker - http.request

2016-12-22 11:03:43,758 - DEBUG - worker - Dispatching message on 
http.request to channels.staticfiles.StaticFilesConsumer

mysite.local

2016-12-22 11:03:43,775 - DEBUG - worker - Got message on 
websocket.disconnect (reply websocket.send!GTaoMdCohNRJ)

2016-12-22 11:03:43,775 - DEBUG 

Re: Postgres SQL vs SQLite vs MS SQL vs MY SQL

2016-12-22 Thread Antonis Christofides
Hi,

I'm using SQLite in production in one application I've made for an eshop hosted
by BigCommerce. It gets the orders from the BigCommerce API and formats them on
a PDF for printing on labels. It has no models, and all the data is stored in
BigCommerce. The only significant data stored in SQLite is the users' names and
passwords used for login, by ``django.contrib.auth``. It's hardly three users.
Recreating them would be easier than maintaining a PostgreSQL installation. So
SQLite it is.

What if your database is small and you don't have many users, but you store
mission-critical data in the database? That's a hard one. The thing is, no-one
really knows if SQLite is appropriate, because no-one is using it for
mission-critical data. Thunderbird doesn't use it for storing emails, but for
storing indexes, which can be recreated. Likewise for Firefox. The SQLite people
claim it's appropriate for mission-critical applications
(https://www.sqlite.org/testing.html), but industry experience on that is
practically nonexistent. I've never seen corruption in SQLite. I've seen
corruption in PostgreSQL, but we are comparing apples to oranges. I have a gut
feeling (but no hard data) that I can trust SQLite more than MySQL.

If I ever choose to use SQLite for mission-critical data, I will make sure I not
just backup the database file, but also backup a plain text dump of the
database. I trust plain text dumps more than database files in case there is
silent corruption that can go unnoticed for some time.

As for MySQL, I never understood why it has become so popular when there's
PostgreSQL around. My only explanation is it was marketed better. PostgreSQL is
more powerful, it is easier, and it has better documentation. Every now and then
I hear of silly MySQL problems that are unheard of in PostgreSQL (the latest I
heard is the broken Unicode support,
https://mathiasbynens.be/notes/mysql-utf8mb4). If you have a reason to use
MySQL, it's probably that you already know it, or that people around you know it
(e.g. it is company policy). Same thing with MS SQL. Otherwise PostgreSQL is
easily the best option.

Regards,

Antonis Christofides
http://djangodeployment.com



On 12/22/2016 01:40 PM, NoviceSortOf wrote:
>
> Curious what advantages if any people are finding working with DBs other than
> the default SQLLite?
>
> We are considering migrating to MSSQL to avoid kinks/ETL involved with having
> various DB backends for
> office and server applications, but uncertain the additional cost will be
> worth it or not.
>
>
> -- 
> 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/42f1c4b9-e75d-4aed-b179-63191b407da0%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/13f9823e-6fa2-9849-57b2-8fb117ba9b1a%40djangodeployment.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to display user's photo that i follow in post's list in Django

2016-12-22 Thread Melvyn Sopacua
Hi,

not sure why you're screenshotting code instead of copying it...makes it 
harder to point you at the mistake.

On Wednesday 21 December 2016 14:33:58 skerdi wrote:
> *In a  post list I've shown only the users posts that I follow but I'm
> not able to display their photo. *

in Profile.get_photo() you set users to self.photo. I don't think you 
wanted to do that.

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


Re: Django - save user in another table

2016-12-22 Thread Avraham Serour
I think you should create another table called Profile that will hold all
the addtitional info the common users have that the admins do not.
The auth.user table is useful for handling password, authentication,
session and common features all users have.

On Wed, Dec 21, 2016 at 11:45 PM, milad ranaei siadat <
ranaei.mila...@gmail.com> wrote:

> Django - save user in another table
> 
> up vote
> down votefavorite
> 
>
> Is there a way to save my user registration in another table from the
> database?
>
> I don't want to mix AdminUsers with CommonUsers (All the tutorials I've
> seen, they save the registration inside auth_user)
>
> The reasons:
>
>- CommonUsers have different columns and informations
>- CommonUsers can upload content
>- AdminUsers verify the content uploaded by the CommonUsers and make
>sure there is nothing inappropriate
>
> What do I need to use? models? modelform? forms?
>
>
> please help me
>
> --
> 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/e1ae8ddc-a70d-4c76-bdd4-8947871ee1f0%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/CAFWa6tJef6s_p5M0NMmgdy4XkzLc23RXKTAPuGtRKMnNE1P4Vg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Postgres SQL vs SQLite vs MS SQL vs MY SQL

2016-12-22 Thread Avraham Serour
if one really wants to pay for suport you can still use postgres and pay to
enterpriseDB

On Thu, Dec 22, 2016 at 2:45 PM, Sundararajan Seshadri 
wrote:

> The situation justifies the data base. There are more data bases (like
> Oracle and Firebird) than what you have specified. But, let me compare the
> ones you listed. Same observations apply to the other data bases too.
>
> On the first level comparison, you can say SQLITE is excellent for
> productivity during development. It is also free. You can live with it if
> only one or two users are likely to use the system. But if there are more
> users or more entities (or tables), go for 'regular' RDBMS.
>
> If you are ready to pay consistent with the number of users (and get a
> consistent support too!), go for MS SQL. But remember, MS SQL will also
> mean more investment in terms of better hardware. (Note: There is a special
> 'reduced' version of MS SQL which is 'free' can also be used. But remember
> to read the licensing condition)
>
> If you want more than SQLITE but not ready to pay money, go for MySQL or
> Postgre SQL. They are,by nature, without support (except among users, forum
> etc.) but there are companies which offer paid support for these.) Either
> of them is fine and almost they are replaceable by each other. But,
> personally I would vote for Postgrew SQL since this is a little more
> 'corporate' in nature. (Please do not fight with me - I love MYSQL too. The
> comparison is like that between PHP and PYTHON. Again, I love both
> languages!)
>
> I think there was a statement in Django documentation to the effect 'we
> personally love Postgre!'. May be I am wrong?
>
> So back to my original reply: the situation decides what should be used.
>
> Food for thought: there are situations where RDBMS are not the best - and
> they go for 'non-SQL Database'!
>
> 
> ---
>
> On Thursday, December 22, 2016 at 5:10:17 PM UTC+5:30, NoviceSortOf wrote:
>>
>>
>> Curious what advantages if any people are finding working with DBs other
>> than the default SQLLite?
>>
>> We are considering migrating to MSSQL to avoid kinks/ETL involved with
>> having various DB backends for
>> office and server applications, but uncertain the additional cost will be
>> worth it or not.
>>
>>
>> --
> 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/64d650a0-6bc1-4259-8d08-063fbb66c231%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/CAFWa6tJ%2B1suijBMF1rSwjCom_oFQuRsS25fbXdcddxNVS60cCw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Postgres SQL vs SQLite vs MS SQL vs MY SQL

2016-12-22 Thread Sundararajan Seshadri
The situation justifies the data base. There are more data bases (like 
Oracle and Firebird) than what you have specified. But, let me compare the 
ones you listed. Same observations apply to the other data bases too.

On the first level comparison, you can say SQLITE is excellent for 
productivity during development. It is also free. You can live with it if 
only one or two users are likely to use the system. But if there are more 
users or more entities (or tables), go for 'regular' RDBMS.

If you are ready to pay consistent with the number of users (and get a 
consistent support too!), go for MS SQL. But remember, MS SQL will also 
mean more investment in terms of better hardware. (Note: There is a special 
'reduced' version of MS SQL which is 'free' can also be used. But remember 
to read the licensing condition)

If you want more than SQLITE but not ready to pay money, go for MySQL or 
Postgre SQL. They are,by nature, without support (except among users, forum 
etc.) but there are companies which offer paid support for these.) Either 
of them is fine and almost they are replaceable by each other. But, 
personally I would vote for Postgrew SQL since this is a little more 
'corporate' in nature. (Please do not fight with me - I love MYSQL too. The 
comparison is like that between PHP and PYTHON. Again, I love both 
languages!)

I think there was a statement in Django documentation to the effect 'we 
personally love Postgre!'. May be I am wrong?

So back to my original reply: the situation decides what should be used. 

Food for thought: there are situations where RDBMS are not the best - and 
they go for 'non-SQL Database'!

---

On Thursday, December 22, 2016 at 5:10:17 PM UTC+5:30, NoviceSortOf wrote:
>
>
> Curious what advantages if any people are finding working with DBs other 
> than the default SQLLite?
>
> We are considering migrating to MSSQL to avoid kinks/ETL involved with 
> having various DB backends for
> office and server applications, but uncertain the additional cost will be 
> worth it or not.
>
>
>

-- 
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/64d650a0-6bc1-4259-8d08-063fbb66c231%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to display user's photo that i follow in post's list in Django

2016-12-22 Thread skerdi
*In a  post list I've shown only the users posts that I follow but I'm not 
able to display their photo. *


*Here is my Profile model, extending Django User model*







































Here is my Post model:














































I want to show the photo of the user as shown below.
What would be the right queryset to display that.
Any help would be apriciated.









-- 
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/436cd055-2ec0-4116-a391-ab377e03c1ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django - save user in another table

2016-12-22 Thread milad ranaei siadat
Django - save user in another table 

up vote
down votefavorite 


Is there a way to save my user registration in another table from the 
database?

I don't want to mix AdminUsers with CommonUsers (All the tutorials I've 
seen, they save the registration inside auth_user)

The reasons:

   - CommonUsers have different columns and informations
   - CommonUsers can upload content
   - AdminUsers verify the content uploaded by the CommonUsers and make 
   sure there is nothing inappropriate

What do I need to use? models? modelform? forms?


please help me

-- 
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/e1ae8ddc-a70d-4c76-bdd4-8947871ee1f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Postgres SQL vs SQLite vs MS SQL vs MY SQL

2016-12-22 Thread graeme
SQLite is very good for what it is and requires zero admin and no 
installation, but it cannot scale, has no replication, and cannot run on 
separate server.

Postgres has robust transaction DDL, which means that if you get a crash in 
the middle of a migration the change gets reversed. MySQL does not have 
this, MSSQL used not to do it very well, SQlite does not do it but Django 
migrations try to emulate it. See here for more on migrations; 
https://docs.djangoproject.com/en/1.10/topics/migrations/#backend-support

Postgres is also very flexible, feature rich, FOSS, well supported by 
Django (especially with contrib.postgres )  and well tested with Django. It 
is even available on Azure as a hosted service from at least two providers. 
It should be the default choice unless you have strong reasons for using 
something else. 

On Thursday, December 22, 2016 at 5:26:07 PM UTC+5:30, NoviceSortOf wrote:
>
>
> The primary cost is licensing unless we can scale the MS-SQL db projects 
> size and more expensive hosting cost .  
>
> Currently we use PostGresSQL, based in part of my suspicions of the 
> limitations of SQLite. 
>
> Our DB requirements though are complicated by the need to work with Asian 
> languages, Chinese, Japanese and so on as well as European languages.  This 
> makes a relative import/export trivial between various tables and is a 
> major bottleneck. The workstations are Windows, the appeal of Azure is also 
> knocking at the door, being able to off set some admin hardware costs. 
>
>
>
>
>
>
> On Thursday, December 22, 2016 at 12:40:17 PM UTC+1, NoviceSortOf wrote:
>>
>>
>> Curious what advantages if any people are finding working with DBs other 
>> than the default SQLLite?
>>
>> We are considering migrating to MSSQL to avoid kinks/ETL involved with 
>> having various DB backends for
>> office and server applications, but uncertain the additional cost will be 
>> worth it or not.
>>
>>
>>

-- 
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/b9830773-fc78-4514-83ad-adb79dd9849e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Postgres SQL vs SQLite vs MS SQL vs MY SQL

2016-12-22 Thread Melvyn Sopacua
Hi,

On Thursday 22 December 2016 03:56:07 NoviceSortOf wrote:

> Our DB requirements though are complicated by the need to work with
> Asian languages, Chinese, Japanese and so on as well as European
> languages.  This makes a relative import/export trivial between
> various tables and is a major bottleneck.

I don't get how languages tie in to choice of DB server software, other 
then "can it handle encoding X and Y". This you can research and for 
your own sanity, you may want to convert everything to UTF-8 before it 
enters the database.
The cost calculation is simple:
What can MSSQL do, that you actually *use* that others cannot.

When you put the emphasis on feature use, a lot of propriety software 
becomes schockingly expensive and cheap to work around / do differently 
in perspective.

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


SOLVED Erroneous links in my Django URLs - all load the home page -- not a 404 or other error.page

2016-12-22 Thread NoviceSortOf
Thanks that does the job.

I'm editing subject to read as 'Solved' 

- Is this considered best practice in this form?


On Thursday, December 22, 2016 at 2:43:23 AM UTC+1, NoviceSortOf wrote:
>
>
> URLs not defined in my urls.py all show my home page and not a 404 missing 
> page error.
>
> For instance 
>
> www.mysite.com  
> Naturally shows my home page.
>
> www.mysite.com/catalogs 
> Shows the downloadable catalogs
>  
> then anything goes.
>
> www.mysite.com/thisisanonsenselink
> or
> www.mysite.com/AnythingTypedHere
>
>
> Shows my homepage
>
> Why isn't my project issuing 404 or other errors when page not found?
>
> Please advise 
>
>
>
On Thursday, December 22, 2016 at 2:43:23 AM UTC+1, NoviceSortOf wrote:
>
>
> URLs not defined in my urls.py all show my home page and not a 404 missing 
> page error.
>
> For instance 
>
> www.mysite.com  
> Naturally shows my home page.
>
> www.mysite.com/catalogs 
> Shows the downloadable catalogs
>  
> then anything goes.
>
> www.mysite.com/thisisanonsenselink
> or
> www.mysite.com/AnythingTypedHere
>
>
> Shows my homepage
>
> Why isn't my project issuing 404 or other errors when page not found?
>
> Please advise 
>
>
>

-- 
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/56302c7c-1896-420f-b136-a0ea41b45570%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Unique app name error problem when building a Wagtail multisite solution

2016-12-22 Thread Melvyn Sopacua
Hi,

On Wednesday 21 December 2016 14:30:32 'Matthias Brück' via Django users 
wrote:
> is this really just not possible? What I found is this:
> 
> you can't have two apps with the same name, even if they have
> different
> > fully qualified module paths
> 
> https://groups.google.com/forum/#!msg/django-users/AMYLfQo6Ba4/Y-57B0i
> 7qy4J
> 
> How would you guys handle this?

By picking the right tool for the job. Judging from 1.8 Release notes, 
Wagtail is working towards multi-tenancy, but isn't there yet. So, pick 
a different CMS (for example Mezzanine) that is. Especially one that 
uses the multi-tenancy that is built-in to django through the sites 
module.
Don't work against the flow :)
-- 
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/9597820.ipCVOE8xS6%40devstation.
For more options, visit https://groups.google.com/d/optout.


Re: Postgres SQL vs SQLite vs MS SQL vs MY SQL

2016-12-22 Thread Vijay Khemlani
https://sqlite.org/whentouse.html

SQLite is not directly comparable to client/server SQL database engines
such as MySQL, Oracle, PostgreSQL, or SQL Server since SQLite is trying to
solve a different problem.

Client/server SQL database engines strive to implement a shared repository
of enterprise data. They emphasis scalability, concurrency, centralization,
and control. SQLite strives to provide local data storage for individual
applications and devices. SQLite emphasizes economy, efficiency,
reliability, independence, and simplicity.

SQLite does not compete with client/server databases. SQLite competes with
fopen().

---

In that regard, for web development, sqlite is not very useful because it
is not made for that.


On Thu, Dec 22, 2016 at 8:56 AM, NoviceSortOf 
wrote:

>
> The primary cost is licensing unless we can scale the MS-SQL db projects
> size and more expensive hosting cost .
>
> Currently we use PostGresSQL, based in part of my suspicions of the
> limitations of SQLite.
>
> Our DB requirements though are complicated by the need to work with Asian
> languages, Chinese, Japanese and so on as well as European languages.  This
> makes a relative import/export trivial between various tables and is a
> major bottleneck. The workstations are Windows, the appeal of Azure is also
> knocking at the door, being able to off set some admin hardware costs.
>
>
>
>
>
>
> On Thursday, December 22, 2016 at 12:40:17 PM UTC+1, NoviceSortOf wrote:
>>
>>
>> Curious what advantages if any people are finding working with DBs other
>> than the default SQLLite?
>>
>> We are considering migrating to MSSQL to avoid kinks/ETL involved with
>> having various DB backends for
>> office and server applications, but uncertain the additional cost will be
>> worth it or not.
>>
>>
>> --
> 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/d8ab0337-d8b9-4c72-9f70-66624acba00f%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/CALn3ei3QaW6NQ_%3DdeqstFwxxL7o%2BVJ8dj532bLEd5it8KnruQw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Erroneous links in my URLs - all load the home page -- not a 404 or other error.page

2016-12-22 Thread Vijay Khemlani
(r'$',index2), matches anything i think

you would need something like

(r'^/$',index2),

On Thu, Dec 22, 2016 at 8:36 AM, NoviceSortOf 
wrote:

> Thanks for the response... Apache setting and URL's follow.
>
> Apache setting looks like this...
> 
> 
> Require all granted
> 
> 
> =
>
>
> URLS look like this
> urlpatterns = patterns('',
>   (r'^search/$', search),
>   (r'^searchadv/$', searchadv),
>   (r'^searchcat/$', searchcat),
>   (r'^searchhlt/$', searchhlt),
>   (r'^searchquick/$', searchquick),
>   (r'^edition/(?P\w+)/$',edition),
>   (r'^add_to_cart/(?P\w+)/$',add_to_cart),
>   (r'^remove_from_cart/(?P\w+)/$',remove_from_cart),
>
>   (r'^view_cart/$',view_cart),
>   (r'^cart_mail/$',cart_mail),
>   (r'^cart_maileasy/$',cart_maileasy),
>   (r'^check_out/$',check_out),
>   (r'^check_outeasy/$',check_outeasy),
>   (r'^login/$',login),
>   (r'^testit/$',testit),
>   (r'^request_catalogs/$',request_catalogs),
>   (r'^request_catalogs/$',request_catalogs),
>   (r'^profileopt/$', TemplateView.as_view(template_name=
> "profiles/profileopt.html")),
>   (r'^library.htm/$', TemplateView.as_view(template_name=
> "library.html")),
>   (r'^collect.htm/$', TemplateView.as_view(template_name=
> "collect.html")),
>   (r'^ecatalogsdnld.htm/$', TemplateView.as_view(template_name=
> "ecatalogsdnld2.html")),
>   (r'^about.htm/$', TemplateView.as_view(template_name=
> "about.html")),
>   (r'^contactus.htm/$', TemplateView.as_view(template_name=
> "contactus.html")),
>   (r'^subjectslst/$', TemplateView.as_view(template_name=
> "subjectslst.html")),
>   (r'$',index2),
>   (r'^index2/$',index2),
> )
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> On Thursday, December 22, 2016 at 2:56:57 AM UTC+1, Vijay Khemlani wrote:
>>
>> show your urls.py
>>
>> On Wed, Dec 21, 2016 at 10:43 PM, NoviceSortOf 
>> wrote:
>>
>>>
>>> URLs not defined in my urls.py all show my home page and not a 404
>>> missing page error.
>>>
>>> For instance
>>>
>>> www.mysite.com
>>> Naturally shows my home page.
>>>
>>> www.mysite.com/catalogs
>>> Shows the downloadable catalogs
>>>
>>> then anything goes.
>>>
>>> www.mysite.com/thisisanonsenselink
>>> or
>>> www.mysite.com/AnythingTypedHere
>>>
>>>
>>> Shows my homepage
>>>
>>> Why isn't my project issuing 404 or other errors when page not found?
>>>
>>> Please advise
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/django-users/94dc7439-38f5-464c-b93e-001faf03491c%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/1bc667a6-86f2-404d-9cc8-7a5a53ce97a2%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/CALn3ei1nXgehgy39_8ZvY0BD3dTwu6G7UhjC7q50b%3DMF1-snpw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Postgres SQL vs SQLite vs MS SQL vs MY SQL

2016-12-22 Thread NoviceSortOf

The primary cost is licensing unless we can scale the MS-SQL db projects 
size and more expensive hosting cost .  

Currently we use PostGresSQL, based in part of my suspicions of the 
limitations of SQLite. 

Our DB requirements though are complicated by the need to work with Asian 
languages, Chinese, Japanese and so on as well as European languages.  This 
makes a relative import/export trivial between various tables and is a 
major bottleneck. The workstations are Windows, the appeal of Azure is also 
knocking at the door, being able to off set some admin hardware costs. 






On Thursday, December 22, 2016 at 12:40:17 PM UTC+1, NoviceSortOf wrote:
>
>
> Curious what advantages if any people are finding working with DBs other 
> than the default SQLLite?
>
> We are considering migrating to MSSQL to avoid kinks/ETL involved with 
> having various DB backends for
> office and server applications, but uncertain the additional cost will be 
> worth it or not.
>
>
>

-- 
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/d8ab0337-d8b9-4c72-9f70-66624acba00f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Postgres SQL vs SQLite vs MS SQL vs MY SQL

2016-12-22 Thread Avraham Serour
I do not want to speak ill of sqlite, it is very useful for development,
testing and other uses, but in short it is not a fully featured DBMS.

Django can work with many different databases, not only sqlite and MSSQL.

You will have license costs for the database and for the OS, I would
personally choose postgres, but it would be valid to use MSSQL if your
organization has no problem paying the license for the ultimate version and
already have an experienced MS DBA with time to worry about the DB for your
application.

What kinds of costs are you worried about?

Avraham

On Thu, Dec 22, 2016 at 1:40 PM, NoviceSortOf 
wrote:

>
> Curious what advantages if any people are finding working with DBs other
> than the default SQLLite?
>
> We are considering migrating to MSSQL to avoid kinks/ETL involved with
> having various DB backends for
> office and server applications, but uncertain the additional cost will be
> worth it or not.
>
>
> --
> 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/42f1c4b9-e75d-4aed-b179-63191b407da0%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/CAFWa6tLYRKxajx2N%3Dq-P7uxD261V_v%3DiQs%2BsqYFnuQYuWBBSWQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Postgres SQL vs SQLite vs MS SQL vs MY SQL

2016-12-22 Thread NoviceSortOf

Curious what advantages if any people are finding working with DBs other 
than the default SQLLite?

We are considering migrating to MSSQL to avoid kinks/ETL involved with 
having various DB backends for
office and server applications, but uncertain the additional cost will be 
worth it or not.


-- 
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/42f1c4b9-e75d-4aed-b179-63191b407da0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Erroneous links in my URLs - all load the home page -- not a 404 or other error.page

2016-12-22 Thread NoviceSortOf
Thanks for the response... Apache setting and URL's follow.

Apache setting looks like this...


Require all granted


=


URLS look like this
urlpatterns = patterns('',
  (r'^search/$', search),
  (r'^searchadv/$', searchadv),  
  (r'^searchcat/$', searchcat),  
  (r'^searchhlt/$', searchhlt),  
  (r'^searchquick/$', searchquick), 
  (r'^edition/(?P\w+)/$',edition),  
  (r'^add_to_cart/(?P\w+)/$',add_to_cart),  
  (r'^remove_from_cart/(?P\w+)/$',remove_from_cart),   
   
  (r'^view_cart/$',view_cart),   
  (r'^cart_mail/$',cart_mail),
  (r'^cart_maileasy/$',cart_maileasy),
  (r'^check_out/$',check_out),   
  (r'^check_outeasy/$',check_outeasy),
  (r'^login/$',login),  
  (r'^testit/$',testit),
  (r'^request_catalogs/$',request_catalogs),
  (r'^request_catalogs/$',request_catalogs),
  (r'^profileopt/$', TemplateView.as_view(template_name= 
"profiles/profileopt.html")),
  (r'^library.htm/$', TemplateView.as_view(template_name= 
"library.html")),
  (r'^collect.htm/$', TemplateView.as_view(template_name= 
"collect.html")),
  (r'^ecatalogsdnld.htm/$', TemplateView.as_view(template_name= 
"ecatalogsdnld2.html")),
  (r'^about.htm/$', TemplateView.as_view(template_name= "about.html")),
  (r'^contactus.htm/$', TemplateView.as_view(template_name= 
"contactus.html")),
  (r'^subjectslst/$', TemplateView.as_view(template_name= 
"subjectslst.html")),
  (r'$',index2),  
  (r'^index2/$',index2),
)
















On Thursday, December 22, 2016 at 2:56:57 AM UTC+1, Vijay Khemlani wrote:
>
> show your urls.py
>
> On Wed, Dec 21, 2016 at 10:43 PM, NoviceSortOf  > wrote:
>
>>
>> URLs not defined in my urls.py all show my home page and not a 404 
>> missing page error.
>>
>> For instance 
>>
>> www.mysite.com  
>> Naturally shows my home page.
>>
>> www.mysite.com/catalogs 
>> Shows the downloadable catalogs
>>  
>> then anything goes.
>>
>> www.mysite.com/thisisanonsenselink
>> or
>> www.mysite.com/AnythingTypedHere
>>
>>
>> Shows my homepage
>>
>> Why isn't my project issuing 404 or other errors when page not found?
>>
>> Please advise 
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/94dc7439-38f5-464c-b93e-001faf03491c%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/1bc667a6-86f2-404d-9cc8-7a5a53ce97a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: GeoDjango: Filter by Area

2016-12-22 Thread Sanjay Bhangar
On Wed, Dec 21, 2016 at 10:08 PM, Tim Graham  wrote:

> If you don't get an answer here, you can also ask on the geodjango list:
> https://groups.google.com/forum/#!forum/geodjango.
>
>
Will do. Thanks Tim, you're the best!

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


Re: How can I access field values generically?

2016-12-22 Thread C. Kirby
Ill be honest, I'm still not getting how your models are structured. That 
is ok though, I can give you some pointers and hopefully  that will be 
sufficient. I'll also be very explicit in describing the steps. Several are 
probably better as single orm calls. _meta docs at 
https://docs.djangoproject.com/en/1.10/ref/models/meta/

Hope this helps. If you have any clarifying questions I am happy to chime 
in more.

from django.db.models import TextField
#First get all ingredients you are interested in (I am assuming that
#mixtures are only one level deep, if not then build a recursive call)
ingredients = Substance_Ingredients.objects.filter(substance=).values_list('ingredient.pk', flat=True)
#Get the substance instances for these
child_substances = Substance.objects.filter(pk__in = ingredients)
target_text = ''
for cs  in child_substance:
#Get all OneToOne and OneToMany fields

models =  [
(f, f.model if f.model != (Substance or SubstanceIngredient) else 
None)
for f in Substance._meta.get_fields()
if (f.one_to_many or f.one_to_one)
and not f.auto_created and not f.concrete
]

ingredient_text = ''
for field, model in models:
#Check the model for TextFields
tfs = [f for f in model._met.get_fields() if isinstance(f, TextField
)]
#get the textfield attributes for your substance field
field_text = [getattr(field, tf, '') for tf in tfs]
#compile you text strings at the necessary levels
ingredient_text = '{}, {}'.format(ingredient_text, '.'.join(
field_text))

child_text = '{}: {}'.format(cs.substance_name, ingredient_text)
target_text = '{}\n{}'.formate(target_text, child_text)

#Save you target text to the original substance


-- 
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/b39f85e3-1ecc-4a2f-93e7-f6f426a63520%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.