Strongly Want to Eat Django

2019-06-16 Thread Mohammad Etemaddar




https://metemaddar.ir/?p=24

-- 
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/89dda610-66b0-4a93-b613-629979d09907%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Confused with deleted migrations

2019-06-16 Thread Mohammad Etemaddar
I got really confused. I don't know how to use version control. I think 
this might happen again.
I need to understand what you did with version control. It would be 
appreciated if you could post an instructions on here or any blog.
Thank you.

On Wednesday, June 12, 2019 at 10:57:56 PM UTC+4:30, Mohammad Etemaddar 
wrote:
>
> Hey folks
> After uploading the app to the server, I got problems by local migrations 
> in development. So deleted the migrations and local sqlite db (Server uses 
> MySQL).
> After more development, uploaded the whole project to the server and 
> overwrite the files. And typed migrate on server. I don't know what 
> happened to the database. Some new tables seems to be created (or not). I 
> got really confused with this situation. It is much confusing to get backup 
> from server's data and then restore them back.
> What is your opinion?
>

-- 
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/8b904f72-e321-41b8-b8a4-44480560544c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Confused with deleted migrations

2019-06-12 Thread Mohammad Etemaddar
Hey folks
After uploading the app to the server, I got problems by local migrations 
in development. So deleted the migrations and local sqlite db (Server uses 
MySQL).
After more development, uploaded the whole project to the server and 
overwrite the files. And typed migrate on server. I don't know what 
happened to the database. Some new tables seems to be created (or not). I 
got really confused with this situation. It is much confusing to get backup 
from server's data and then restore them back.
What is your opinion?

-- 
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/d050785c-3924-40cb-8c9c-2b878dda4ad5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: models

2019-05-08 Thread Mohammad Etemaddar
The one who should have foreign key is is filter, box and barel to shelf.
Then you can access them from shelf:
Shelf0.boxs
Shelf0.barels
And shelf0.filters

Note that you can set the relation_name in foreign key so that you can use
the related name instead of filters, boxs and barels

On Wed, 8 May 2019 11:05 Robin Riis,  wrote:

> if i have a model like
>
> class ShelfManager(models.Manager):
>
> use_for_related_fields = True
>
> def create_cabinet(self, name, number_of_shelfs):
>
> cabinet = self.create(name=name, number_of_shelfs=number_of_shelfs)
>
> created_shelfs = 0
>
> while created_shelfs < number_of_shelfs:
>
> cabinet.shelfs.create()
>
> created_shelfs += 1
>
> return place
>
>
> class Cabinet(models.Model):
>
> name = models.CharField(max_length=50, unique=True)
>
> number_of_shelfs = models.IntegerField
>
> shelfs = ShelfManager()
>
> class Shelfs(models.Model):
>
> place = models.ForeignKey(Cabinet, on_delete=models.CASCADE, null=True,
> blank=True, related_name='shelfs')
> ...
>
> and i want shelf to hold either model Box, Filter or Barrel
> but not sure which approach to use :P
>
>
> --
> 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/CAPLZMbPTNJ8OavQiaUpdELVH4wo9V9p94zkFWDwZS4sXdZtS8g%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/CALJt1ntd4roJy_KOpXRDb9%2BfGLeue2gkJSQi5Q8cKXT3%2B8zk%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why my email goes to spam?

2019-04-20 Thread Mohammad Etemaddar
Here it is:



Delivered-To: arash.etemad...@gmail.com
Received: by 2002:ab3:7117:0:0:0:0:0 with SMTP id n23csp431925lte;
Thu, 18 Apr 2019 01:23:17 -0700 (PDT)
X-Google-Smtp-Source: 
APXvYqzQO4QTZZjxmg7C1RyW1QDcfvbrcM3P4GBxxK0XOLen8RntVeF2on0PDZMImrmFOwPZDCnp
X-Received: by 2002:a24:220c:: with SMTP id o12mr2351361ito.1.175797582;
Thu, 18 Apr 2019 01:23:17 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=175797; cv=none;
d=google.com; s=arc-20160816;
b=uRIYsGsfnAGBoj+wV+KSxTcMsU0MUwmQ3tv18vgqDD5xqhkNPZ7eZhxZdeLQchVscZ
 r+KUvqDaLS9LPH57GWeupv8eiVh4A3lEJOLOei1ZUrAzuFiACkUAju30hsuHGXcqeeSM
 DoqD79QkhfLq4kJksD8LxKRTJpKNOz9+IzYF1lwpsW8dYMbLqfbNz7SyObVpSDIkG1Un
 5ChRr4ckHygu6AZM04q0ymvo0PMdpoBsBFl5XYjArsNKIh/v3X+z9DwidCQO/J/kcE+y
 Xrp+8TjyH2txoxyzmaF0o+C0M9P+RyB8u4dRC3LyYXeqjv7nCY2BZiJicH1faPzNl1LR
 WVyQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; 
s=arc-20160816;
h=message-id:date:to:from:subject:content-transfer-encoding
 :mime-version:dkim-signature;
bh=x1QmOPfmAREqGV3IruUfKZv2zTIATOj5nVQCBw0a1KQ=;
b=irefjZ7w+DqBs+z4OMgBe2x4SYxIP2pFb9N4UI/6QfdhwqdDMn5FYQGckFOOZhAYEW
 iEBYptRzLmjsbYxGNoiFycHYD14IycwyXsP7hXUI2NNRm+bgG49Jdf8iqJpkIPOseyZc
 145rF5dS+jjsbGKa9NoYjUil/f0LSruyyGELt5xjQ3AsMCY4wZzOfJbIRMMwU463dg+j
 Siz2b9yEnlOFOXmGgZk0ERE2AmVLGVd9+jCnnLCUdWmWqAdbe5PPHOsWVaIYTa9cAfa1
 QU42jJvk/KcN2PAykDKy4ZTB+ZOcY60EMjGw8VN3F/Ai//3d5QlJKrjmRqxAPLWSNrWx
 Jlqg==
ARC-Authentication-Results: i=1; mx.google.com;
   dkim=fail header.i=@myaa.ir header.s=2019 header.b=Q8G8809R;
   spf=pass (google.com: domain of nore...@myaa.ir designates 
198.143.182.181 as permitted sender) smtp.mailfrom=nore...@myaa.ir
Return-Path: 
Received: from host.myaa.ir ([198.143.182.181])
by mx.google.com with ESMTPS id a66si894582jaa.81.2019.04.18.01.23.17
for 
(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
Thu, 18 Apr 2019 01:23:17 -0700 (PDT)
Received-SPF: pass (google.com: domain of nore...@myaa.ir designates 
198.143.182.181 as permitted sender) client-ip=198.143.182.181;
Authentication-Results: mx.google.com;
   dkim=fail header.i=@myaa.ir header.s=2019 header.b=Q8G8809R;
   spf=pass (google.com: domain of nore...@myaa.ir designates 
198.143.182.181 as permitted sender) smtp.mailfrom=nore...@myaa.ir
Received: from host.myaa.ir (localhost [IPv6:::1]) by host.myaa.ir (Postfix) 
with ESMTPSA id 89D20122E25 for ; Thu, 18 Apr 2019 
04:23:15 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=myaa.ir; s=2019; 
t=175796; bh=x1QmOPfmAREqGV3IruUfKZv2zTIATOj5nVQCBw0a1KQ=; 
h=Subject:From:To:Date:From; 
b=Q8G8809R+/QKFVgsnQsuEWhJ7VmKvEpbHgNjwsW4eVO6U/s/smEi6WbjlXE8/8kLx
 0mODT/3bws2DD/Q+d7kIKvsE2VQ7GRMuV0cTD6Rt/7CA7YD4zdzuxSRE6499J4uUsJ
 LHoc2mGISKYuIwveu/Pg/+XTXHAKa+ObAHO/rbBnyDZs9Yf1YVMQ+i1+l5XiOzaabH
 rWILAMhGXzlXjbAOR4xHTkcfWiOpDEB7rNZvnQTHOzK+Sfe3kr8m4/0YUtV7oeP2ST
 pA2FRx2zcXbR9Iktf9IIIvWkHTLn/P92vjJXH7+LfG3M3zbx6uXi1zel1JAB2yefSk
 e1e6XZD4+jg0g==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [Myaa.ir] لطفا ایمیل خودتان را تأیید فرمایید
From: nore...@myaa.ir
To: arash.etemad...@gmail.com
Date: Thu, 18 Apr 2019 08:23:15 -
Message-ID: <17579553.21365.882940801908681...@host.myaa.ir>

Hello from Myaa.ir!
این ایمیل را به این دلیل دریافت کردید که کاربر arash.etemaddar آدرس ایمیل شما 
را به عنوان آدرس خود به حساب کاربری خود متصل کرده.

برای تایید درستی این موضوع، به لینک زیر بروید:
https://myaa.ir/accounts/confirm-email/MjA:1hH2KA:c6USpdrEt0pkN5SofEBrsav6gqk/

سپاس از طرف Myaa.ir!
myaa.ir




On Thursday, April 18, 2019 at 2:14:30 PM UTC+4:30, Kasper Laudrup wrote:
>
> Hi Mohammad, 
>
> On 18/04/2019 10.05, Mohammad Etemaddar wrote: 
> > Hello. I'm working on a bussiness website. I send invitation and also 
> > confirm emails by django-allauth. 
> > Invitation and allauth emails go to spam box. 
> > I don't know what is the problem? 
> > How can I prevent emails going to spam? 
> > 
>
> This is hardly related to Django, but anyway... 
>
> There is really no standard way to detect spam, for good reasons, so it 
> really depends on the mail server receiving the mail. 
>
> The first thing I would do would be to look at the headers for the mail 
> flagged as spam. Some spam scanners (eg. spamassasin) sets some 
> additional headers with scores it has used to determine the mail is 
> spam. You could use that to see what might be the cause for this mail 
> being flagged as spam. 
>
> It could be something as simple as the mail only having HTML content 
> which is not only a violation of the RFC but also one of the seven 
> deadly sins :-) 
>
> Apart fro

Why my email goes to spam?

2019-04-18 Thread Mohammad Etemaddar
Hello. I'm working on a bussiness website. I send invitation and also 
confirm emails by django-allauth.
Invitation and allauth emails go to spam box.
I don't know what is the problem?
How can I prevent emails going to spam?

-- 
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/2ad0d969-1d04-4c94-8aa7-671ef5915057%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using forms to handle request.GET data?

2019-04-03 Thread Mohammad Etemaddar
Set default value:
year = forms.ChoiceField(required=False, choices=[(j, j) for j in range(2018, 
2021)], default=2019)
You do not need clean_year any more I think.

On Wednesday, April 3, 2019 at 1:42:50 AM UTC+4:30, Carsten Fuchs wrote:
> Dear Django group,
> 
> I would like to show users a form that they can use to customize the view, 
> for example a ChoiceField from which the year of the report can be chosen. It 
> seems straightforward to use a forms.Form to handle the request.GET data:
> 
> 
> from django import forms
> 
> class JahrAuswahl(forms.Form):
> year = forms.ChoiceField(required=False, choices=[(j, j) for j in 
> range(2018, 2021)])
> 
> def clean_year(self):
> y = self.cleaned_data['year']
> if not y:
> # Set a "default" value here.
> y = 2019
> print('Year:', y)
> return y
> 
> 
> However, the problem is with default values. Please consider this:
> 
> 
> >>> year_form = JahrAuswahl({'year': 2018})   # Provide explicit data.
> >>> print(year_form)
> Year: 2018 # from JahrAuswahl.clean_year()
> Year: id="id_year">
>   2018# Just as expected!
>   2019
>   2020
> 
> 
> 
> >>> year_form = JahrAuswahl({})# Data is empty now, need default values!
> >>> print(year_form)
> Year: 2019 # JahrAuswahl.clean_year() provides a default value.
> Year: id="id_year">
>   2018
>   2019   # BUT it doesn't make it back into 
> year_form.data !
>   2020
> 
> 
> 
> Well, the problem is that with {} (that is, request.GET == {}), we get 
> default values in year_form.cleaned_data, but we cannot use year_form in the 
> template context to render the form fields.
> Some work-around might be to use the year_form.cleaned_data to initialize a 
> new JahrAuswahl instance:
> 
> 
> >>> year_form = JahrAuswahl(year_form.cleaned_data)   # HACK!?
> >>> print(year_form)
> Year: 2019
> Year: id="id_year">
>   2018
>   2019# ok!
>   2020
> 
> 
> 
> But this feels like a hack and really not like the proper way to do this.
> How can I solve this problem in an elegant Django manner?
> 
> Best regards,
> Carsten

-- 
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/feb71ac9-f4b4-4ee0-a7c9-07e0a0376abc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: Login by phone number best practice

2019-04-03 Thread Mohammad Etemaddar
Thank you. But django-phone-login seems a bit complex. It uses rest framework. 
I don't know why.

-- 
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/1b5e02f9-4b1a-499c-a566-9a682a1ca1e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


I need help on adding a search button to an input field

2019-04-03 Thread Mohammad Etemaddar
You can use FieldWithButtons in form helper's layout:
https://django-crispy-forms.readthedocs.io/en/d-0/layouts.html

-- 
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/59a2b90b-d146-4cf5-8047-40ed533586e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Login by phone number best practice

2019-04-03 Thread Mohammad Etemaddar
I want users to login by phone number (without registration).
But we need username field for authentication.
This is just for make easy for users that don't know about using email. And 
also make it easier to login for them.
But I need also username and email for other users for future.
I need you opinion on how to implement it.
Set username field to phone_number / create random username for users that need 
to login by phone

I also need best practices and documentations if is available for login and 
registration in this situation.

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/56016d6f-d6c6-4368-a7c0-74037d7b3fdb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 2.7.1 - "TemplateDoesNotExist at /munichlivingapp/seekers/ "

2019-03-30 Thread Mohammad Etemaddar
Dear Kabiba,
It would be good to post your code (specially the part that renders the 
template). I think you're addressing the template by 'seeker_list.html'.
You need to specify the mother directory 'munichi...app/seeker_list.html'.
or put seeker_list.html right inside the templates directory.

On Saturday, March 30, 2019 at 6:40:08 PM UTC+4:30, kamiba...@gmail.com 
wrote:
>
> Hello,
>
> I thought I would post here the link to the question (which was not 
> answered)  I just asked on Stackoverflow.
>
>
> https://stackoverflow.com/questions/55431695/django-2-7-1-templatedoesnotexist-at-munichlivingapp-seekers
>
> Any suggestions are welcome. Thanks.
>
> K.
>
>
>

-- 
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/0ad1beef-8229-4fb5-bab1-5158ed4fe850%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Crispy: Helper Layout has no effect on form.

2019-03-26 Thread Mohammad Etemaddar
Found the answer.
I used crispy like this:
{{ form|crispy }}

*But We should use like this to get form helper effect:*

{% crispy form %}

On Wednesday, March 20, 2019 at 7:02:31 PM UTC+3:30, Mohammad Etemaddar 
wrote:

> Here is my model form which is rendered by crispy.
> When I change the layout, ordering, or adding elements, has no effect on 
> rendered form.
>
> Do you see any problem in the code?
>
> Thank you
>
>
> class FactoryForm(forms.ModelForm):
> class Meta:
> model = Factory
> fields = ('name','field', 'description', 'manager','province','city',
> 'address','phone_number','logo')
>
> province = forms.ModelChoiceField(queryset=Province.objects.all())
>
> def __init__(self, *args, **kwargs):
> super(FactoryForm, self).__init__(*args, **kwargs)
>
> self.helper = FormHelper(self)
> self.helper.form_tag = False
> self.helper.disable_csrf = True
>
> self.helper.layout = Layout(
> Fieldset(
> 'Legend',
> 'name', 'field', 'description', 'manager', 'province', 'city', 'address', 
> 'phone_number',
> HTML(""""""),
> 'logo',
> )
> )
>
> if self.instance.name:
> self.fields['province'].initial = self.instance.city.province
> self.fields['city'].queryset = City.objects.filter(province=self
> .instance.city.province)
>
>

-- 
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/c9df2370-dfce-4b63-aa50-9766d06c71b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: is_valid() method and cleaned_data attribute

2019-03-22 Thread Mohammad Etemaddar
Every field in Form has validators which check the value against their 
conditions.
as Django Doc sais 

:
The primary task of a Form 
 
object is to validate data. With a bound Form 
 
instance, call the is_valid() 

 
method to run validation and return a boolean designating whether the data 
was valid

Take a look at is_valid at Django source code 

 
(At BaseForm's source code).
as you see there it checks if the form is bound and *not has errors.*

If you see *errors*, it's a method with attribute decorator. that triggers 
the full_clean( ) method.
full_clean does _clean_fields which populates the *cleaned_data *with 
validation checked data.

So, If you call the is_valid() and it returns True, You know that all form 
validators are applied to the data and it had no errors. also the 
cleaned_data is ready to use.

On Friday, March 22, 2019 at 10:43:03 PM UTC+4:30, omar ahmed wrote:
>
> hello guys
> i created contact form
> in my view :
> if form.is_valid():
> message = form.cleaned_data['message']
> what is .is_valid() method and what is cleaned_data attribute ???
>

-- 
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/d6ec41ed-b01d-42b8-bc57-9026988248e2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: 404 error when posting a multipart/form-data form

2019-03-22 Thread Mohammad Etemaddar
I'm not sure about this, but I think maybe it would be about your Django 
bug. Have you updated your Django?

On Friday, March 22, 2019 at 7:37:14 PM UTC+4:30, Manlio Perillo wrote:
>
> On Friday, March 22, 2019 at 3:23:32 PM UTC+1, Manlio Perillo wrote:
>>
>> On Friday, March 22, 2019 at 1:28:55 PM UTC+1, Hamady Medvall wrote:
>>>
>>> You have to add the path /bug in URLConfig
>>>
>>>
>> A GET request to /mp/bug/ does not return an error, only a POST request 
>> and *only* when using a file upload.
>>
>> From the trace I see that it's the URL resolver that raises the 404 
>> exception.  But what I don't understand is why a GET request work.
>>
>> This is the trace for a POST request: https://paste.ee/p/sjq5s
>>
>>
> Some more details.
>
> I have the following main urlpatterns:
>
> urlpatterns = [
> urls.path('mp/', urls.include('lpg.mperillo.urls')),
> ]
>
> And in my application:
>
> urlpatterns = [
> urls.path('bug/', views.bug, name='bug'),
> urls.path('debug/', views.debug, name='debug')
> ]
>
> When accessing https://fast-page.it/mp/bug/, Django tries to match the 
> path `bug` with the pattern `mp` and it fail, raising a 404 exception.
> This does not happen with a GET request or with a POST request without a 
> file upload.  Also, I can't reproduce this error on my system, but only on 
> the hosting server.
> I have a different Django application on a different account of the same 
> hosting company, and it works correctly.
>
> I originally found the problem in the Django admin, when trying to create 
> a model instance with a file field.
>
>
> Thanks
> Manlio Perillo 
>

-- 
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/83a30de5-1f16-4694-88f8-d50e77844153%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: 404 error while loading uploaded image when debug is False

2019-03-21 Thread Mohammad Etemaddar
In production , we serve static files (like images) stright from httpd like
apache, and we do not call django to serve them.
But in testing while run django test server, we use static paths in urls.py
to serve them,

Maybe you have added mediaurls to your urlpatterns in urls.py conditionally
(when settings.debug == True) so they are not added when debug is False.

On Thu, 21 Mar 2019 21:35 mayank dubey,  wrote:

> Hii there,
>
> I am not able to load images which have been uploaded through the admin
> portal on my Django site if I set debug = false. While when debug = true,
> images are easily loaded. I am not able to understand what is the problem,
> please help me out.
>
> Thank you,
> M
>
> --
> 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/CAMJ6Xs6qROL597vvX53%3DSpLqagovcMcz_wROFp828zm%3DrYE8DA%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/CALJt1nsRuK1yeyxsdoB6p50eOjz6-JCLkzY%3D%3Dz5Cy8eudiwzrA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: log out a user when user closes tab or browser

2019-03-21 Thread Mohammad Etemaddar
I have a suggest for you. Its non standard.

First create a javascript infinite loop to make a get call every 1 minute.
Also make session expiration time at 2 minutes. So if tabs closed the
session will expire at 1 minute.

On Thu, 21 Mar 2019 15:17 Christian Ledermann, <
christian.lederm...@gmail.com> wrote:

> SESSION_EXPIRE_AT_BROWSER_CLOSE works for me
> but only when you close the browswer, closing a tab will not log you out
> also it depends on the browser (firefox seemed in the past to ignore this)
>
> On Thu, 21 Mar 2019 at 05:34, Sam W  wrote:
>
>> Is there a way in Django to log out a user when user closes tab or
>> browser? This one "SESSION_EXPIRE_AT_BROWSER_CLOSE =True" Doesn't work
>>
>> --
>> 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/644cca74-0443-4c71-8d8e-7326a252eb2e%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> Best Regards,
>
> Christian Ledermann
>
> Newark-on-Trent - UK
> Mobile : +44 7474997517
>
> https://uk.linkedin.com/in/christianledermann
> https://github.com/cleder/
>
>
> <*)))>{
>
> If you save the living environment, the biodiversity that we have left,
> you will also automatically save the physical environment, too. But If
> you only save the physical environment, you will ultimately lose both.
>
> 1) Don’t drive species to extinction
>
> 2) Don’t destroy a habitat that species rely on.
>
> 3) Don’t change the climate in ways that will result in the above.
>
> }<(((*>
>
> --
> 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/CABCjzWq_uy06FeNF%2Bs5f5r9NOT14bcENz52HvKdTrRxKqTiHQA%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/CALJt1ntZabSenvJg%2BjbKoR4irn6Te3Eg2Ykzq-NBx1s4cx%3Du6A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: 404 error when posting a multipart/form-data form

2019-03-21 Thread Mohammad Etemaddar
Can you send your view here?

On Thu, 21 Mar 2019 12:58 Manlio Perillo,  wrote:

> I have a Django application that works perfectly fine both on my PC and on
> a hosting system with CloudLinux and Passenger.
> However when I added a form with a file field, I started to get 404 errors
> on POST.
>
> I tried to remove all the middleware, but the problem is still here.
> The error message says that the 404 error was raised by my view, but
> that's not true; my view is not called at all during a POST request.
>
> What's strange is that I have another Django application on a different
> hosting account with the same environment and it works fine.
> The problem is probably in my application, but I'm unable to find it.
>
> Where should I search to find the cause of the problem?
>
>
> Thanks
> Manlio Perillo
>
> --
> 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/313db9e4-340c-475a-abe6-f12f96213b05%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/CALJt1nvkXie8yTG%2BG9c7C8C%3D3modPsubLK%2B2R-RHgGBXiSizxw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Crispy: Helper Layout has no effect on form.

2019-03-20 Thread Mohammad Etemaddar
Here is my model form which is rendered by crispy.
When I change the layout, ordering, or adding elements, has no effect on 
rendered form.

Do you see any problem in the code?

Thank you


class FactoryForm(forms.ModelForm):
class Meta:
model = Factory
fields = ('name','field', 'description', 'manager','province','city',
'address','phone_number','logo')

province = forms.ModelChoiceField(queryset=Province.objects.all())

def __init__(self, *args, **kwargs):
super(FactoryForm, self).__init__(*args, **kwargs)

self.helper = FormHelper(self)
self.helper.form_tag = False
self.helper.disable_csrf = True

self.helper.layout = Layout(
Fieldset(
'Legend',
'name', 'field', 'description', 'manager', 'province', 'city', 'address', 
'phone_number',
HTML(""),
'logo',
)
)

if self.instance.name:
self.fields['province'].initial = self.instance.city.province
self.fields['city'].queryset = City.objects.filter(province=self
.instance.city.province)

-- 
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/4962a495-c0d3-4164-b0ee-4978a74ade8e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Passing values

2019-02-13 Thread Mohammad Etemaddar
Dear Ivan,
If I get you right, You have a page with form, and you want to post it to 
another page. so, fill the "action" part of html form with the second 
page's url.

Also the timezone.now is allways available in any python file you are 
working on it, and also request and request.user

What do you want to do exactly?

On Wednesday, February 13, 2019 at 1:45:46 PM UTC+3:30, Ivan Martić wrote:
>
> Hi all,
>
> where can i find more info regarding passing values in views/forms/url.
> What I need is to pass value from form in previous url page to the form in 
> next url page(also prefilling with data like timezone.now, request,user)
>
> Thank you in advance.
> Ivan
>

-- 
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/5eb3df26-ae0d-44c7-8f4b-e7b0b6e5e01e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


update object without updating auto_now fields

2019-02-13 Thread Mohammad Etemaddar
I think about times that I need to edit user profiles without touching 
auto_now field.
How can I do it?

-- 
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/0d3ef3d6-8452-4028-b2a2-ca9980b51476%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django, mod_wsgi and apache2.4 = 403 forbidden

2019-01-29 Thread Mohammad Etemaddar
I have no experience in configure apache. But these two lines have conflict.

DocumentRoot 
C:\Frontier_Website\FATWebsite\FrontierWebApp\zigview\templates\FrounterWeb
and:
WSGIScriptAlias / 
C:\Frontier_Website\FATWebsite\FrontierWebApp\FrounterWeb\wsgi.py

Both of these lines tell apache how to handle the 
*/ *
But for the first one you did not grant access to it's folder and you 
shouldn't
So you should remove the first line. I mean DocumentRoot. You do not need 
it when you are configure your django site at root ( / )

On Tuesday, January 29, 2019 at 11:12:22 AM UTC+3:30, Rookies DJ wrote:
>
> I'm sorry if I'm asking the repetitive but i really need assistance I been 
> trying to setup a server for my company system but I had no progress. 
>
> As the tile subject mention the I'm Using Mod_wsgi 4.6.5 and Apache 2.4
>
> for my Django is 2.1 and python 3.7
>
> When try to run on my local machine I get 403 and I did many google search 
> and the only answer I get is add in Require all granted which I had already 
> add in. you could see below for particle section for my Apache http
>
> LoadModule wsgi_module 
> "C:\users\user\appdata\local\programs\python\python37\lib\site-packages/mod_wsgi/server/mod_wsgi.cp37-win_amd64.pyd"
> WSGIScriptAlias / "C:\Frontier_Website\FrounterWebApp\FrounterWeb\wsgi.py"\
> WSGIPythonPath "C:\Frontier_Website\FrounterWebApp\zigview"
> WSGIPythonHome "C:\Users\user\AppData\Local\Programs\Python\Python37"
>
> 
> Require all granted
> 
>
> 
> 
> Require all granted
> 
> 
>
>
> for more detail you can look at at code in stackoverflow.com:
>  
>
> https://stackoverflow.com/questions/54249683/django-mod-wsgi-and-apache2-4-problems
>   
> I had try to run the system in virtualenv but I get no result as well and 
> when I try to start the server, I get this error: *The system cannot find 
> the path specified.*
> The virtualenv code is below;
>
> #python and mod_wsgi setting 
> 
>  ServerName Localhost.com 
>  DocumentRoot 
> C:\Frontier_Website\FATWebsite\FrontierWebApp\zigview\templates\FrounterWeb
> LoadModule wsgi_module 
> C:\users\user\appdata\local\programs\python\python37\lib\site-packages/mod_wsgi/server/mod_wsgi.cp37-win_amd64.pyd
> WSGIScriptAlias / 
> C:\Frontier_Website\FATWebsite\FrontierWebApp\FrounterWeb\wsgi.py
> WSGIPythonHome C:\Frontier_Website\FATWebsite\Lib
> WSGIPythonPath C:\Frontier_Website\FrounterWebApp\zigview
>
> Alias /static \Frontier_Website\FATWebsite\FrounterWebApp\zigview\static
> 
> Require all granted
> 
>
>  C:\Frontier_Website\FATWebsite\FrounterWebApp\FronterWeb\wsgi-script>
> 
>Require all granted
> 
>
> 
>  
>  
> Please help I had been trying to solve this problem for month now
>

-- 
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/aba38722-89e1-455a-a536-8713b79c39c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


forms with get_or_create and inlineformset_factory

2019-01-26 Thread Mohammad Etemaddar
I think the answer is in your signal-connected function in your question query 
which you choosed all() questions.
I did not understand the project, but you should choose questions in signal and 
not all questions I think.

-- 
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/500bbf6f-9b4d-47eb-9766-aa61b6d266a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Access to the last object of model inside model itself

2019-01-26 Thread Mohammad Etemaddar
I commented out the default value and then ran the makemigrations again, and 
then uncommented again and worked. Of course by lambda.

-- 
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/c0d314eb-32cb-49e6-8f99-e08b800eb2e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Access to the last object of model inside model itself

2019-01-26 Thread Mohammad Etemaddar
Im not agree. Managers are created for custom query. But here the query is last.
I think I got the philosophy. The default value should not be a manager, 
because the database does not understand it.
Maybe I am 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/e6c53610-e754-47bf-88b3-587aaa0fa3c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Access to the last object of model inside model itself

2019-01-25 Thread Mohammad Etemaddar
Hello
I need the last object of model inside it.
for example I have:
class Field(models.Model):
category = models.ForeignKey(Category, related_name='fields', on_delete=
models.CASCADE,
default = get_last_factory_field_category())

def get_last_factory_field_category():
return Field.objects.last().category

In this definition, will get not defined error. because the function is 
defined after model.

preivously, I used *lambda* to get access to the last category. But 
*makemigrations 
*did not work while using lambda.

The clear problem is getting access to the last object of model inside of 
it.

-- 
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/7de3335f-4afe-4f4b-ac1d-067e326cad1b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Best Learning Resources

2019-01-20 Thread Mohammad Etemaddar
I liked "django by example"

-- 
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/f5c1156f-ac06-49f2-a383-f5dfe354c592%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


submit button redirecting to unknown url

2019-01-20 Thread Mohammad Etemaddar
Change action="." To action=""

-- 
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/5c630883-7bd3-4b65-a9c9-5429375cca94%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Adding default rows to Django admin inlines

2019-01-19 Thread Mohammad Etemaddar
If I get you right you need to add m2m objects with a default value.
In this situation, you can create an intermediate model to build m2m.
For example:
JobActionRel:
job = fk
action = fk-to-actions (default=Action.objects.get...)

And use it as through model:
https://docs.djangoproject.com/en/2.1/topics/db/models/#extra-fields-on-many-to-many-relationships

Now, in admin you see the default action.
Remember, before making it through, create JobActionRels from previous m2m 
objects.

-- 
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/445a903a-408b-445e-a8cb-4e09db5162d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Fresh Django with mod_wsgi and apache goes Time Out on 18.04

2018-07-07 Thread Mohammad Etemaddar
I have installed Ubuntu server 18.04 and *VirtualMin* on it. installed 
python3-pip and then virtualenv.
Also installed *libapache2-mod-wsgi-py3*
Created new virtual server and configured the modwsgi for it.
Also created fresh django website for it.
But I get Timeout error!
Here is my apache configuration for mod_wsgi:

Code:

WSGIDaemonProcess username.ir python-home=/home/username/venv 
python-path=/home/username/website
WSGIProcessGroup username.ir


Alias /media/ /home/username/website/media/
Alias /static/ /home/username/website/static/


Require all granted



Require all granted


WSGIScriptAlias / /home/username/website/website/wsgi.py



Require all granted



Django version: 1.11.14
I have configured website like this on a Debian 9 server and worked great.
How can I solve it?

-- 
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/95b2df4a-bba5-4cd6-9e28-f069fb092126%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to get two django rest framework to communicate with each other

2018-01-15 Thread Mohammad Etemaddar
Excuse me for giving advice for this change.
But why don't you put these two projects in one Django project as two apps?
You have two options. First you can make a ManyToMany relationship. Of 
course this has a problem. For example some people may not want to share 
his/her future information to a doctor.

There is other way also. You can copy data from one app to another one. Or 
one model to another.

On Monday, January 15, 2018 at 8:12:59 AM UTC+3:30, chern...@gmail.com 
wrote:
>
> So i have 2 django project. Both have its seperated database and table. I 
> create the django rest framework api for both project but i want both of 
> them to communicate with each other.
>
>
> In django 1 is about the social media and medical record app API. In 
> django 2 is a clinic app API where the it is for staff of the clinic and 
> collect user information from django 1 and to give a queue number for user 
> that make appointment.
>
>
> What im trying to do is django 2 will have a qr code for django 1 to scan. 
> After scanning, it will ask for permission to allow their information to be 
> share with django 2(their user information/medical record). After user 
> allow, their information will be save to django 2 database.
>
> For now, i just want to allow django 2 to save the user information from 
> django 1.
>
>
> Is there a way for 2 different django project to communicate with each 
> other through the api ?
>

-- 
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/4137338d-1da2-411b-b300-95ec4c32d439%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.