Django Forms

2017-10-21 Thread test
Hi,

I have a form that contains a question and a multiple choice answer field. 

For example:
What is your favorite color?

   - Blue
   - Green
   - Red
   - Yellow

I render the page with a list of forms (or I guess formset?) and loop 
through them. So something like this.


for form in formset:
 form





Since each form is set to only allow you to select 1 multiple choice 
option, if I add many forms in one page, I can only select one option 
overall. So if I answer question 1, I can't answer any of the other 
questions without it unselecting question 1's answer.

Does anyone know how to fix this?

-- 
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/e65b59e6-136f-4b1e-933c-5d44d63f5e3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Forms

2017-10-21 Thread test


class PollForm(forms.Form):
answer = forms.ChoiceField(
widget=forms.RadioSelect,
choices=cool_choices)

def __init__(self, poll, *args, **kwargs):
super(PollForm, self).__init__(*args, **kwargs)
b = poll.choice_set.all()
list_choice = []
for i in range(len(b)):
list_choice.append(b[i].choice)

list_choice = zip(list_choice, list_choice)
self.fields['answer'].choices = list_choice
self.fields['answer'].label = poll.question

self.fields[poll.pk] = self.fields['answer']
del self.fields['answer']


So I managed to fix it by creating a name tag for each of the radioselect 
options. I thought self.fields['answers'].widget.name would let me set the 
tag but that did not work as there was no default name tag. So I googled 
and I found that the last two lines made it work
self.fields[poll.pk] = self.fields['answer']
del self.fields['answer']
It set the name tag as the pk for the poll. I honestly don't understand how 
that works. Could you please explain how the last two lines work?





On Saturday, October 21, 2017 at 6:41:16 PM UTC-4, James Schneider wrote:
>
>
>
>
> Since each form is set to only allow you to select 1 multiple choice 
> option, if I add many forms in one page, I can only select one option 
> overall. So if I answer question 1, I can't answer any of the other 
> questions without it unselecting question 1's answer.
>
> Does anyone know how to fix this?
>
>
> If that's the case you are not formatting the form correctly. Each form 
> set should contain it's own radio group of answers so that an answer may be 
> selected for each one. Post up the template code you're using.
>
> -James
>

-- 
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/e873025d-aee6-4793-9907-ee8dd3f5bca1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How do you access parent object values in an admin inline

2017-11-22 Thread test
For example:

class AnswerInLine(admin.TabularInline):
  model = Answers 

class QuestionAdmin(admin.ModelAdmin):
  inlines = [AnswerInLine]


 I want to change the model in the AnswerInLine depending on what the 
QuestionAdmin value is

-- 
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/7300b116-9681-46f9-8df5-aa95691f37d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do you access parent object values in an admin inline

2017-11-22 Thread test
Thanks for the response.

I'm still kind of confused.
So I save the request by overriding the function. Then I can only read the 
request by overriding a function in the inline. How do I change the model 
in the overrided function in the inline.


On Wednesday, November 22, 2017 at 1:54:08 PM UTC-5, Matemática A3K wrote:
>
>
>
> On Wed, Nov 22, 2017 at 3:21 PM, test > 
> wrote:
>
>> For example:
>>
>> class AnswerInLine(admin.TabularInline):
>>   model = Answers 
>>
>> class QuestionAdmin(admin.ModelAdmin):
>>   inlines = [AnswerInLine]
>>
>>
>>  I want to change the model in the AnswerInLine depending on what the 
>> QuestionAdmin value is
>>
>> First save the request object in the parent of the inline, then use it in 
> fk field in the inline. Here is an example:
>
> https://github.com/math-a3k/django-ai/blob/master/django_ai/bayesian_networks/admin.py
>  
>
>> -- 
>> 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/7300b116-9681-46f9-8df5-aa95691f37d4%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/7300b116-9681-46f9-8df5-aa95691f37d4%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> 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/9b1c32ba-7441-488a-a9e4-9bcec9eaa824%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to store a boolean expression (parse tree) in a model?

2020-02-18 Thread test
Let's say I have:

Calculator #1:
Expression: (True AND False) AND (True OR False)

This expression should be a child of some calculator. 

class Calculator(models.Model):
name = ...

class Expression(models.Model):
parent = models.ForeignKey(Calculator)

boolean = AND or OR

sub_exp1 = models.ForeignKey(Expression)
sub_exp2 = models.ForeignKey(Expression)


When I query all the expressions for the Calculator #1, I should get all 
the subexpressions.

1 AND 2 5
2 AND 3 4
3 leaf node of True 
4 lead node of False
5 OR 6 7
6 leaf node of True
7 leaf node of False

>From this, I can quickly apply my parse tree.

How would I display the base case/leaf nodes in my model? Also, is there a 
better way?

Thanks, I would really appreciate any help

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/551f122e-3821-4395-b8b4-cf77d7e34c5f%40googlegroups.com.


Re: How to store a boolean expression (parse tree) in a model?

2020-02-19 Thread test
thanks, do you know how i can create custom leaf nodes when using MPTT or 
treebeard?

My parent nodes should have connector types such as AND/OR but the child 
should not


On Tuesday, February 18, 2020 at 11:30:40 PM UTC-5, Simon Charette wrote:
>
> I suggest you have a look at the "Trees and Graph" section of the
> Django Packages website[0]. I've personally used MPTT and Treebeard
> in the past without too much trouble.
>
> You could also a field able to store composite data structures
> such as JSONField or even a dedicated PostgreSQL type[1] to efficiently 
> store
> such data.
>
> Cheers,
> Simon
>
> [0] https://djangopackages.org/grids/g/trees-and-graphs/
> [1] https://www.postgresql.org/docs/current/sql-createtype.html
>
> Le mardi 18 février 2020 18:13:39 UTC-5, test a écrit :
>>
>> Let's say I have:
>>
>> Calculator #1:
>> Expression: (True AND False) AND (True OR False)
>>
>> This expression should be a child of some calculator. 
>>
>> class Calculator(models.Model):
>> name = ...
>>
>> class Expression(models.Model):
>> parent = models.ForeignKey(Calculator)
>>
>> boolean = AND or OR
>>
>> sub_exp1 = models.ForeignKey(Expression)
>> sub_exp2 = models.ForeignKey(Expression)
>>
>>
>> When I query all the expressions for the Calculator #1, I should get all 
>> the subexpressions.
>>
>> 1 AND 2 5
>> 2 AND 3 4
>> 3 leaf node of True 
>> 4 lead node of False
>> 5 OR 6 7
>> 6 leaf node of True
>> 7 leaf node of False
>>
>> From this, I can quickly apply my parse tree.
>>
>> How would I display the base case/leaf nodes in my model? Also, is there 
>> a better way?
>>
>> Thanks, I would really appreciate any help
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/75510047-05c3-4f66-ade8-f76c4866f249%40googlegroups.com.


Label in Charfield

2015-07-20 Thread Info Test
Hello,
What is the best way to add class css for a label in Charfield form?
Thanks

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


Can't update extended user django model

2015-07-21 Thread Info Test
When I save my model, there is no effect in database.
What is the problem?

class Profil(models.Model):
user = models.OneToOneField(User)


in manage.py shell

>>> p = models.Profil.objects.get(user__username='testname')

>>> p.user.is_superuser
False
>>> p.user.is_superuser = True
>>> p.user.is_superuser
True
>>> exit()
>>> p = models.Profil.objects.get(user__username='testname')
>>> p.user.is_superuser

False -> 


-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/df7490d5-108e-4960-b80b-8071662d8db1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can't update extended user django model

2015-07-21 Thread Info Test


Le mardi 21 juillet 2015 10:55:19 UTC+3, Info Test a écrit :
>
> When I save my model, there is no effect in database.
> What is the problem?
>
> class Profil(models.Model):
> user = models.OneToOneField(User)
>
>
> in manage.py shell
>
> >>> p = models.Profil.objects.get(user__username='testname')
>
> >>> p.user.is_superuser
> False
> >>> p.user.is_superuser = True
>
>>> p.save() 

> >>> p.user.is_superuser
> True
> >>> exit()
> >>> p = models.Profil.objects.get(user__username='testname')
> >>> p.user.is_superuser
>
> False -> 
>
>
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bcdedd95-10fd-4724-93ba-53afb108eff0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can't update extended user django model

2015-07-21 Thread Info Test
Even with p.save(force_update = True) , it 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/44c307bd-8c0a-4924-810f-ab0f2eb123ae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can't update extended user django model

2015-07-21 Thread Info Test
Any error appear on console, is it possible that only superuser can do that?

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8e3bd42d-da1c-42a1-be11-296c2d49d208%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can't update extended user django model

2015-07-21 Thread Info Test
Thanks for all your answers.
Solution : 
http://stackoverflow.com/questions/31534715/cant-update-extended-user-django-model

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4a53a742-9db6-4b16-9208-42bc55ff0674%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Use django-console app url in template

2015-07-23 Thread Info Test
I can access to django-console app with:
127.0.0.1:8000/admin/console.
How to link this with href = "url " in template

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7026d6b0-2138-4f30-b7b8-2613ffebfe1c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Unit-Testing Django Views

2019-03-30 Thread Test Bot
Thanks everyone for the clearance of the problem. I will remove the unit
test's logic to check fir template, it seems a viable test case along with
the status code value.

On Fri, Mar 29, 2019, 2:24 AM Chetan Ganji  wrote:

> There is one more way you could do it
>
>
> class TestIndexPageLoad(TestCase):
>
> def setUp(self):
> self.client = Client()
> self.response = self.client.get('/')
>
> def test_check_response(self):
> self.assertTemplateUsed(self.response, 'index.html')
>
>
>
> Regards,
> Chetan Ganji
> +91-900-483-4183
> ganji.che...@gmail.com
> http://ryucoder.in
>
>
> On Fri, Mar 29, 2019 at 1:56 AM Chetan Ganji 
> wrote:
>
>> I would prefer to just check the status code of the response object.
>> This is what I have done. You have to check if it works for forms with
>> csrf_token or not.
>>
>>
>> class TestReverseUrls(TestCase):
>>
>> def setUp(self):
>> self.client = Client()
>> self.reverseUrls = ['index', 'login', 'register']
>> self.response = {url:self.client.get(reverse(url)) for url in self
>> .reverseUrls}
>>
>> def test_reverse_urls(self):
>> for url in self.reverseUrls:
>> self.assertEqual(self.response[url].status_code, 200)
>>
>>
>>
>> Regards,
>> Chetan Ganji
>> +91-900-483-4183
>> ganji.che...@gmail.com
>> http://ryucoder.in
>>
>>
>> On Fri, Mar 29, 2019 at 12:57 AM Aldian Fazrihady 
>> wrote:
>>
>>> There are several things you can try:
>>> 1. Mocking csrf token functions
>>> 2. Passing the csrf token context from first HTML generation to the
>>> second HTML generation
>>> 3. Wiping out the csrf token parts from both HTML before comparing them.
>>>
>>> On Thu, 28 Mar 2019, 23:54 Simon Charette,  wrote:
>>>
>>>> This is effectively failing because of a mechanism added in 1.10 to
>>>> protect
>>>> against BREACH attacks[0] by salting the CSRF token.
>>>>
>>>> I'm not aware of any way to disable this mechanism but testing against
>>>> the
>>>> exact HTML returned from a view seems fragile.
>>>>
>>>> I suggest you use assertContains[1] (with or without html=True) and
>>>> assertTemplateUsed[2] instead.
>>>>
>>>> Cheers,
>>>> Simon
>>>>
>>>> [0] https://docs.djangoproject.com/en/2.1/ref/csrf/#how-it-works
>>>> [1]
>>>> https://docs.djangoproject.com/en/2.1/topics/testing/tools/#django.test.SimpleTestCase.assertContains
>>>> [2]
>>>> https://docs.djangoproject.com/en/2.1/topics/testing/tools/#django.test.SimpleTestCase.assertTemplateUsed
>>>>
>>>> Le jeudi 28 mars 2019 12:16:43 UTC-4, OnlineJudge95 a écrit :
>>>>>
>>>>> Hi people,
>>>>>
>>>>> I am following the book Test-Driven Development with Python
>>>>> <https://www.amazon.in/Test-Driven-Development-Python-Selenium-JavaScript/dp/1491958707>
>>>>>  by
>>>>> *Harry J.W. Perceval.* The book is using Django version 1.7 which is
>>>>> outdated as of now so I started with version 2.1.
>>>>>
>>>>> I am trying to unit test my index view. One unit-test that I have
>>>>> written is testing whether the index view returns correct HTML or not by
>>>>> comparing the input received through
>>>>> django.template.loader.render_to_string
>>>>> the unit-test fail with the following traceback
>>>>> python manage.py test
>>>>> Creating test database for alias 'default'...
>>>>> .System check identified no issues (0 silenced).
>>>>> F.
>>>>> ==
>>>>> FAIL: test_index_view_returns_correct_html (lists.tests.IndexViewTest)
>>>>> --
>>>>> Traceback (most recent call last):
>>>>>   File "tests.py", line 24, in test_index_view_returns_correct_html
>>>>> self.assertEqual(expected_html, actual_html)
>>>>> AssertionError: '>>>> chars]lue="BJMT1b9fxuXOGugp00SDypeTYZxvlmc6KtBSYMDon[198 chars]l>\n' !=
>>>>> '>>>> char

Re: Unit-Testing Django Views

2019-03-30 Thread Test Bot
I tried removing the {% csrf_token %} from my index.html But it seemed to
have no effect. I got the following traceback for further clarity

*
START OF TRACEBACK*
===
python superlists/manage.py test
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
.F.
Destroying test database for alias 'default'...
==
FAIL: test_index_view_returns_correct_html (lists.tests.HomePageTest)
--
Traceback (most recent call last):
  File "superlists/lists/tests.py", line 25, in
test_index_view_returns_correct_html
self.assertEqual(expected_html, actual_html)
AssertionError: '\n' !=
'\n'

--
Ran 3 tests in 0.005s

FAILED (failures=1)

Process finished with exit code 1
===
*
 END OF TRACEBACK*


On Fri, Mar 29, 2019 at 12:58 AM Aldian Fazrihady  wrote:

> There are several things you can try:
> 1. Mocking csrf token functions
> 2. Passing the csrf token context from first HTML generation to the second
> HTML generation
> 3. Wiping out the csrf token parts from both HTML before comparing them.
>
> On Thu, 28 Mar 2019, 23:54 Simon Charette,  wrote:
>
>> This is effectively failing because of a mechanism added in 1.10 to
>> protect
>> against BREACH attacks[0] by salting the CSRF token.
>>
>> I'm not aware of any way to disable this mechanism but testing against the
>> exact HTML returned from a view seems fragile.
>>
>> I suggest you use assertContains[1] (with or without html=True) and
>> assertTemplateUsed[2] instead.
>>
>> Cheers,
>> Simon
>>
>> [0] https://docs.djangoproject.com/en/2.1/ref/csrf/#how-it-works
>> [1]
>> https://docs.djangoproject.com/en/2.1/topics/testing/tools/#django.test.SimpleTestCase.assertContains
>> [2]
>> https://docs.djangoproject.com/en/2.1/topics/testing/tools/#django.test.SimpleTestCase.assertTemplateUsed
>>
>> Le jeudi 28 mars 2019 12:16:43 UTC-4, OnlineJudge95 a écrit :
>>>
>>> Hi people,
>>>
>>> I am following the book Test-Driven Development with Python
>>> <https://www.amazon.in/Test-Driven-Development-Python-Selenium-JavaScript/dp/1491958707>
>>>  by
>>> *Harry J.W. Perceval.* The book is using Django version 1.7 which is
>>> outdated as of now so I started with version 2.1.
>>>
>>> I am trying to unit test my index view. One unit-test that I have
>>> written is testing whether the index view returns correct HTML or not by
>>> comparing the input received through
>>> django.template.loader.render_to_string
>>> the unit-test fail with the following traceback
>>> python manage.py test
>>> Creating test database for alias 'default'...
>>> .System check identified no issues (0 silenced).
>>> F.
>>> ==
>>> FAIL: test_index_view_returns_correct_html (lists.tests.IndexViewTest)
>>> --
>>> Traceback (most recent call last):
>>>   File "tests.py", line 24, in test_index_view_returns_correct_html
>>> self.assertEqual(expected_html, actual_html)
>>> AssertionError: '>> chars]lue="BJMT1b9fxuXOGugp00SDypeTYZxvlmc6KtBSYMDon[198 chars]l>\n' !=
>>> '>> chars]l>\n'
>>>
>>> --
>>> Ran 3 tests in 0.006s
>>>
>>> FAILED (failures=1)
>>> Destroying test database for alias 'default'...
>>>
>>> Process finished with exit code 1
>>>
>>>
>>> It was clear that the csrf token is causing the test to fail. Is there
>>> any way to test it, or should it be tested? I ask this as when I changed my
>>> Django version to 1.7, the tests were passing, even after giving the csrf
>>> token field in the form. I tried going through the changelogs but 1.7 is
>>> far behind (beginner here). Please find the code snippets, directory
>>> structure provided below.
>>>
>>>
>>> *lists/views.py*

Re: Unit-Testing Django Views

2019-03-30 Thread Test Bot
Sorry for the bother but I finally solved it by using Django's Test Client
and checking for status_code and template used to render the response in my
unit-test.

Regards,
Test Bot

On Sat, Mar 30, 2019 at 5:00 PM Test Bot  wrote:

> I tried removing the {% csrf_token %} from my index.html But it seemed to
> have no effect. I got the following traceback for further clarity
>
> *
> START OF TRACEBACK*
>
> ===
> python superlists/manage.py test
> Creating test database for alias 'default'...
> System check identified no issues (0 silenced).
> .F.
> Destroying test database for alias 'default'...
> ==
> FAIL: test_index_view_returns_correct_html (lists.tests.HomePageTest)
> --
> Traceback (most recent call last):
>   File "superlists/lists/tests.py", line 25, in
> test_index_view_returns_correct_html
> self.assertEqual(expected_html, actual_html)
> AssertionError: ' chars]lue="UUl2QtIopzqg9Co4uPlTlSuEPP2O44aMhda056gd4[201 chars]l>\n' !=
> ' chars]l>\n'
>
> --
> Ran 3 tests in 0.005s
>
> FAILED (failures=1)
>
> Process finished with exit code 1
>
> ===
> *
>  END OF TRACEBACK*
>
>
> On Fri, Mar 29, 2019 at 12:58 AM Aldian Fazrihady 
> wrote:
>
>> There are several things you can try:
>> 1. Mocking csrf token functions
>> 2. Passing the csrf token context from first HTML generation to the
>> second HTML generation
>> 3. Wiping out the csrf token parts from both HTML before comparing them.
>>
>> On Thu, 28 Mar 2019, 23:54 Simon Charette,  wrote:
>>
>>> This is effectively failing because of a mechanism added in 1.10 to
>>> protect
>>> against BREACH attacks[0] by salting the CSRF token.
>>>
>>> I'm not aware of any way to disable this mechanism but testing against
>>> the
>>> exact HTML returned from a view seems fragile.
>>>
>>> I suggest you use assertContains[1] (with or without html=True) and
>>> assertTemplateUsed[2] instead.
>>>
>>> Cheers,
>>> Simon
>>>
>>> [0] https://docs.djangoproject.com/en/2.1/ref/csrf/#how-it-works
>>> [1]
>>> https://docs.djangoproject.com/en/2.1/topics/testing/tools/#django.test.SimpleTestCase.assertContains
>>> [2]
>>> https://docs.djangoproject.com/en/2.1/topics/testing/tools/#django.test.SimpleTestCase.assertTemplateUsed
>>>
>>> Le jeudi 28 mars 2019 12:16:43 UTC-4, OnlineJudge95 a écrit :
>>>>
>>>> Hi people,
>>>>
>>>> I am following the book Test-Driven Development with Python
>>>> <https://www.amazon.in/Test-Driven-Development-Python-Selenium-JavaScript/dp/1491958707>
>>>>  by
>>>> *Harry J.W. Perceval.* The book is using Django version 1.7 which is
>>>> outdated as of now so I started with version 2.1.
>>>>
>>>> I am trying to unit test my index view. One unit-test that I have
>>>> written is testing whether the index view returns correct HTML or not by
>>>> comparing the input received through
>>>> django.template.loader.render_to_string
>>>> the unit-test fail with the following traceback
>>>> python manage.py test
>>>> Creating test database for alias 'default'...
>>>> .System check identified no issues (0 silenced).
>>>> F.
>>>> ==
>>>> FAIL: test_index_view_returns_correct_html (lists.tests.IndexViewTest)
>>>> --
>>>> Traceback (most recent call last):
>>>>   File "tests.py", line 24, in test_index_view_returns_correct_html
>>>> self.assertEqual(expected_html, actual_html)
>>>> AssertionError: '>>> chars]lue="BJMT1b9fxuXOGugp00SDypeTYZxvlmc6KtBSYMDon[198 chars]l>\n' !=
>>>> '>>> chars]l>\n'
>>>>
>>>> --
>>>&g

Re: how can i get current username in model field ??

2019-04-01 Thread Test Bot
+1
DoesNotMakesSenseError("Author of any comment should not be related to the
currently logged in user")

On Mon, Apr 1, 2019, 7:09 PM Joel Mathew  wrote:

> This does not make sense to me. A model is not a dynamic entity. It is
> something that's created beforehand. Getting the current username into
> model should be done in your logic (views), or the template
> Sincerely yours,
>
>  Joel G Mathew
>
>
>
> On Mon, 1 Apr 2019 at 19:01, omar ahmed  wrote:
>
>> i want to put value of logged in user.username in author field
>> class Comment(models.Model):
>> leaguenews = models.ForeignKey(LeagueNews, on_delete= models.CASCADE,
>> related_name='comments')
>> author = models.CharField(max_length=200)
>> text = models.TextField()
>>
>> --
>> 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/8a24a020-af3a-4a5f-ac25-5da3aa1fa8db%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/CAA%3Diw_9E9szHxpGUwXB1UFgcEkJDOCaSK8-an%2BxFyV0jt4sR2g%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/CAD%3DM5eSj-Mwe2ok%3D9bd7bUOse76c-E3a_JwPLBsubRKpa1jbRA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: I have created a Django App, How to create a Django App Launcher?

2019-04-09 Thread Test Bot
The issue here is you have a web app and you expect a desktop application.
This should be asked on a GUI-Framework mailing list.

You can call your APIs from that desktop app instead of writing the same
code again(DRY).

On Tue, Apr 9, 2019, 8:42 PM Julio Cojom  wrote:

> Django Is a web application, I guess if you create a shortcut of your
> browser with the URL of your app, that will be fine. Even you can change
> the icon to make a distinction between your app and the real browser.
>
>
> If you want to those scripts run every n hours or minutes to maintain your
> app feed , then create a crontab :)
>
>
>
> On Tue, Apr 9, 2019, 9:02 AM jaidev joshi  wrote:
>
>>
>> Hello all,
>>
>>
>> I have created a Django application, specifically, a dashboard
>> application, python scripts that collect data from sensors running in the
>> background will feed that data to Django app for live data plotting.
>>
>> I want to build this application in a more user-friendly way, and rather
>> launching it with the help of terminal I want to create an Icon on Desktop
>> by clicking that icon one can start this dashboard application to manage
>> sensor related data.
>>
>> Please suggest me a way through which I can do it.
>>
>> Thanks.
>>
>>
>> Jay
>>
>> --
>> 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/a9c28f8f-c28e-4268-87d3-afe7ccded5bc%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/CAHRQUH%3D%2BD331Q7EQxh%3DNshBUpMk1sGDLCBX2rbk04R2O7%2BheDw%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/CAD%3DM5eRafviMbHQkvc7QrpwYbNz4yrrjZXvYa6-BqbQaaBH8VQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Failed to understand syntax

2019-04-12 Thread Test Bot
The part you want to understand is same as ORDER BY clause in SQL. The
slicing will provide only the top 5 results. By default the order_by sorts
in ascending order only. But providing a "-" would make it to sort in
descending order.

On Fri, Apr 12, 2019, 6:56 PM Mayur Bagul  wrote:

> Hello coders,
>
> I'm here to understand line of code which im unable to understand how it
> work.
> i'm looking forward to get help from you.
>
> code is given below :
>
>
> from django.shortcuts import render
>
> from .models import Question
>
>
> def index(request):
> latest_question_list = Question.objects.order_by*('-pub_date')[:5]*
> context = {'latest_question_list': latest_question_list}
> return render(request, 'polls/index.html', context)
>
>
>
>
> - in the code above i'm looking forward to know about bold and highlighted
> part how it 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/bbc7142c-bf46-4fb4-8e25-bbe7a2594c9f%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

On Fri, Apr 12, 2019, 6:56 PM Mayur Bagul  wrote:

> Hello coders,
>
> I'm here to understand line of code which im unable to understand how it
> work.
> i'm looking forward to get help from you.
>
> code is given below :
>
>
> from django.shortcuts import render
>
> from .models import Question
>
>
> def index(request):
> latest_question_list = Question.objects.order_by*('-pub_date')[:5]*
> context = {'latest_question_list': latest_question_list}
> return render(request, 'polls/index.html', context)
>
>
>
>
> - in the code above i'm looking forward to know about bold and highlighted
> part how it 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/bbc7142c-bf46-4fb4-8e25-bbe7a2594c9f%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/CAD%3DM5eTqF%2B-AKXxG5QADXsouGPCsRNWfsM1tLahFiL7DzGKtUQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Failed to understand syntax

2019-04-13 Thread Test Bot
That is because

Question.objects.order_by("-pub_date")


would give you a list of all records so you can simply apply slicing
without the use of . operator.
For understanding purpose, you can break down your code as

result = Question.objects.order_by("-pub_date")
> latest_question_list = result[:5]


This is a feature provided by *Python* itself.
Would suggest going through the Django docs about ORM in case you have not.

On Sat, Apr 13, 2019, 1:09 PM Mayur Bagul  wrote:

> Hello Judge95,
>
> thanks for useful information but i want to know how [:5] is used without
> . operator and how it is work.
>
> thanking you.
>
> On Friday, April 12, 2019 at 7:31:49 PM UTC+5:30, OnlineJudge95 wrote:
>>
>> The part you want to understand is same as ORDER BY clause in SQL. The
>> slicing will provide only the top 5 results. By default the order_by sorts
>> in ascending order only. But providing a "-" would make it to sort in
>> descending order.
>>
>> On Fri, Apr 12, 2019, 6:56 PM Mayur Bagul  wrote:
>>
>>> Hello coders,
>>>
>>> I'm here to understand line of code which im unable to understand how it
>>> work.
>>> i'm looking forward to get help from you.
>>>
>>> code is given below :
>>>
>>>
>>> from django.shortcuts import render
>>>
>>> from .models import Question
>>>
>>>
>>> def index(request):
>>> latest_question_list = Question.objects.order_by*('-pub_date')[:5]*
>>> context = {'latest_question_list': latest_question_list}
>>> return render(request, 'polls/index.html', context)
>>>
>>>
>>>
>>>
>>> - in the code above i'm looking forward to know about bold and
>>> highlighted part how it 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...@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/bbc7142c-bf46-4fb4-8e25-bbe7a2594c9f%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> On Fri, Apr 12, 2019, 6:56 PM Mayur Bagul  wrote:
>>
>>> Hello coders,
>>>
>>> I'm here to understand line of code which im unable to understand how it
>>> work.
>>> i'm looking forward to get help from you.
>>>
>>> code is given below :
>>>
>>>
>>> from django.shortcuts import render
>>>
>>> from .models import Question
>>>
>>>
>>> def index(request):
>>> latest_question_list = Question.objects.order_by*('-pub_date')[:5]*
>>> context = {'latest_question_list': latest_question_list}
>>> return render(request, 'polls/index.html', context)
>>>
>>>
>>>
>>>
>>> - in the code above i'm looking forward to know about bold and
>>> highlighted part how it 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...@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/bbc7142c-bf46-4fb4-8e25-bbe7a2594c9f%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/4dd06d2a-1a88-4a9e-916a-28bf29fc97d5%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/CAD%3DM5eRjwV8W7-EfL

Re: Failed to push Django project on github using gitbash

2019-04-18 Thread Test Bot
It means your remote has some changes that are not there in your local so
when you are pushing, git is unable to merge those changes.

Try a git pull then local merge and then push. Feel free to ask in case of
any queries.

On Thu, Apr 18, 2019, 6:58 PM Mayur Bagul  wrote:

> Hello Community,
>
> im using gitbash to upload my code to github but it giving below error:
>
>  ! [rejected]master -> master (non-fast-forward)
> error: failed to push some refs to '
> https://github.com/MayurBagul/Weather-Informer.git'
> hint: Updates were rejected because the tip of your current branch is
> behind
> hint: its remote counterpart. Integrate the remote changes (e.g.
> hint: 'git pull ...') before pushing again.
> hint: See the 'Note about fast-forwards' in 'git push --help' for details.
>
> i tried to use fetch and merge command but even though it is giving error.
> please help me to solve this issue.
>
> Thanking You,
> Mayur Bagul.
>
> --
> 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/a27866f8-1a92-45b9-80c4-84099df30df5%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/CAD%3DM5eQGxcJ9M31%3DmRC9e_xMrM7y0X%2BFAzoCy-SD75N%2B9ZbPuw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can Anyone Please Provide djago-select2 Documentation

2019-05-14 Thread Test Bot
Okay so there is no need to go to different websites if you want to install
a Python module. You will find almost everything related to Python modules
in pypi.org, it includes everything like installation instructions, gut
repo for the packages etc

On Wed, May 15, 2019, 11:57 AM Balaji Shetty  wrote:

> Hi Julio Cojom
>
> Thank You very much for your reply.
> Can you please provide me the web link for necessary package installation
> and steps also.
> I have been trying since 4 hour and tried all the option for select2 from
> different web sites still could not get success.
> I will really appreciate if you do it.
> Please.
>
>
> On Wed, May 15, 2019 at 11:35 AM Julio Cojom 
> wrote:
>
>> Hi, I used a package exclusive for admin, it call django-select2-admin
>> and it's magic. Only register in installed apps and that's all.
>>
>> Regards.
>>
>> El mar., 14 de may. de 2019 11:12 p. m., Balaji Shetty <
>> balajishe...@gmail.com> escribió:
>>
>>> Hi
>>>
>>> I need Cascading drop down list in Django Admin GUI.
>>>
>>> I have bee trying to use Django-select2 but i am not getting the desired
>>> output.
>>> ( Example Select Continents, select respective Country under Continent )
>>>
>>> Can Anyone Please Provide djago-select2 Documentation or any other
>>> simple alternative. I want to use django admin Panel only. I am not
>>> designing any form
>>>
>>> I will appreciate your help.
>>>
>>> --
>>>
>>>
>>> *Mr. Shetty Balaji S.Asst. ProfessorDepartment of Information
>>> Technology,*
>>> *SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.India*
>>> *Official: bsshe...@sggs.ac.in  *
>>> *  Mobile: +91-9270696267*
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAECSbOuAhpUOrq8OvLFi3dFZtkoU703zWpW5RmzWkEGBa9GcSg%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/CAHRQUHkW5gXuEmLWfmf3p7Q3RmW%3DEuCSJ043F2i%3DRXbATq8ctA%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
>
>
> *Mr. Shetty Balaji S.Asst. ProfessorDepartment of Information Technology,*
> *SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.India*
> *Official: bsshe...@sggs.ac.in  *
> *  Mobile: +91-9270696267*
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAECSbOveeFjzUjMhkd%2BpzNf8mv%3D7mA_7n2Kc4oWxXRomVR5SAQ%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/CAD%3DM5eSxkyB8HSVhi-enaTUk3NBm%2BJ9HQs1bqLhJMeS%3Dt4JFgg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432?

2019-05-16 Thread Test Bot
Did you check your firewall settings?

On Thu, May 16, 2019, 6:37 PM Rob W  wrote:

> First, you should not share your password to your server to anyone….thats
> very dangerous.  Now anyone can log in to your server with nefarious
> intentions.
> Be more careful.
>
> But it sounds like something on the server is blocking your connection.
>
> On May 16, 2019, at 8:57 AM, omar ahmed  wrote:
>
> hii ..
> i try to publish my first project on python anywhere but it still not
> working and this is my error :
> could not connect to server: Connection refused Is the server running on
> host "localhost" (::1) and accepting TCP/IP connections on port 5432? could
> not connect to server: Connection refused Is the server running on host
> "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?
> could not connect to server: Connection refused Is the server running on
> host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?
> and this is my db settings  :
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.postgresql_psycopg2',
> 'NAME': 'arena',
> 'USER': 'arenadbuser',
> 'PASSWORD': 'mlo9**@la',
> 'HOST': 'localhost',
> 'PORT': '',
> }
> }
>
> --
> 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/93204eb8-f5e3-43bf-98ff-b79478bce544%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/04731D2F-C4EA-4716-969E-71994AF2EB11%40gmail.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/CAD%3DM5eQXCQ3P00X2i_OCp4K%3DFL4uvaKUdFtbL2L%3DH8NP2xZnNg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting MultiValueDictKeyError

2019-05-16 Thread Test Bot
Try putting encrypt="multipart/form-data" in your form tag

On Thu, May 16, 2019, 6:05 PM Sipum  wrote:

> Hi Friends,
>
> when retrieving file that is uploaded , I'm getting multiValueDictKeyError.
> Below are my codes. I have proided some codes where I m getting error.
> could anyone help me here ?
>
> views.py
> -
>
> def webform_submit(request):
> if request.method =='POST':
> name = request.POST['name']
> email = request.POST['email']
> phone = request.POST['phone']
> job_title = request.POST['job_title']
> resume = request.FILES['document']   -- getting
> error here
>
> user_info = UserField(name = name, email = email, phone = phone,
>   job_title = job_title, resume = resume)
> user_info.save()
> messages.success(request,"Congrats!! Form is successfully saved in
> DB")
> return render(request, 'html/form.html', {})
>
>
> form.html
> --
>   
> Job title
> 
>
> 
> Resume
>  id="exampleFormControlFile1">
>   
> 
> 
>
> 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/37a3ca49-6410-420f-a6a6-23bcf8e3f983%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/CAD%3DM5eQp8%3DBZVmDe7RFjdf0LOvoZcdGMqGgt0xSdEw_Nj%2BJaig%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432?

2019-05-16 Thread Test Bot
So one check would be to see all the connections that are allowed by your
firewall.

On Thu, May 16, 2019, 6:45 PM omar ahmed  wrote:

> no but can it struggle it ?
> how can i check it
>
> On Thursday, May 16, 2019 at 3:09:55 PM UTC+2, OnlineJudge95 wrote:
>>
>> Did you check your firewall settings?
>>
>> On Thu, May 16, 2019, 6:37 PM Rob W  wrote:
>>
>>> First, you should not share your password to your server to
>>> anyone….thats very dangerous.  Now anyone can log in to your server with
>>> nefarious intentions.
>>> Be more careful.
>>>
>>> But it sounds like something on the server is blocking your connection.
>>>
>>> On May 16, 2019, at 8:57 AM, omar ahmed  wrote:
>>>
>>> hii ..
>>> i try to publish my first project on python anywhere but it still not
>>> working and this is my error :
>>> could not connect to server: Connection refused Is the server running on
>>> host "localhost" (::1) and accepting TCP/IP connections on port 5432? could
>>> not connect to server: Connection refused Is the server running on host
>>> "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?
>>> could not connect to server: Connection refused Is the server running on
>>> host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?
>>> and this is my db settings  :
>>>
>>> DATABASES = {
>>> 'default': {
>>> 'ENGINE': 'django.db.backends.postgresql_psycopg2',
>>> 'NAME': 'arena',
>>> 'USER': 'arenadbuser',
>>> 'PASSWORD': 'mlo9**@la',
>>> 'HOST': 'localhost',
>>> 'PORT': '',
>>> }
>>> }
>>>
>>> --
>>> 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...@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/93204eb8-f5e3-43bf-98ff-b79478bce544%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...@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/04731D2F-C4EA-4716-969E-71994AF2EB11%40gmail.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/f69f93cb-e456-4d4b-949c-38baa3e80e15%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/CAD%3DM5eQwiprGXXU4nwcVi3vQwZE0Vyo23QnPzqW4sM%2ByO7qy9A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Anyone kind enough to help me understand these few concepts

2019-05-16 Thread Test Bot
Hi

In models you have to define your database tables as class and any response
to the user should be handled in views.py

You can introduce randomness via random module or for any customisation you
can write it as a different app altogether.

You can create your coin as a separate model and attach it as a relation to
your players model, for payment you can use any payment gateway.


On Thu, May 16, 2019, 10:02 PM DumbaClassics 
wrote:

> I am still new on Django Web Framework and I want to understand the MVC
> concept based on this Project structure. Say I am trying to come up with an
> Online Gambling platform. Where exaclty do put the following;
>
> 1. say I want the player to randomly shuffle cards, is this whole business
> called on views.py or models or in models I just put a class related to
> creating my database?
> 2. say I want a player to have a ticket which is a receipt that can be
> picked randomly from those who have signed up for a draw. how exaclty do i
> have my clients get randomly generated receipts numbers using the
> random.randint module
> 3. Is there a possibility to generate a coin that is a local currency
> which enables players to buy them and then use the tokens for buying
> tickets into the game? If so how do i go about it in django python
>
> --
> 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/6658851f-f32c-42d4-bb04-7e00c0715a97%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/CAD%3DM5eSji9bVHhZFh_jqdWZWiBAodTkMDjhu8f6dw2AOO0ksUQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: reg: Django model sequense of the fields

2019-05-17 Thread Test Bot
[Just Curious] would it matter in any way what the position of field is in
the respective tables.

On Fri, May 17, 2019, 5:46 PM 'Akash Sinha' via Django users <
django-users@googlegroups.com> wrote:

> Hello
>
> This happens for 2 reasons
>
> 1st. Those fields might be Foreign key, Foreign key fields are shown at
> the end in DB.
>
>
> 2nd.  You have added those fields later in our model class, if you will
> add new fields in model.py file those fields will be listed at the end.
>
>
>
>
> On Wed, May 8, 2019 at 9:22 PM, 'Amitesh Sahay' via Django users
>  wrote:
> Hello Users,
>
> I am seeing a very strange issue with my Django models.
> in my models.py, I have 21 fields. Out of them , the 6th field is
> DASHBoard. However, when I see those fields in my postgres DB through
> PgAdminIII, it is listed at the very end of the list.
>
> Sorry, for security reasons I couldn't give the list of the fields here.
>
> Could there be any explanation for this situation?
>
> Regards,
> Amitesh Sahay
>
> --
> 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/1048828608.1995499.1557330720573%40mail.yahoo.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/284735666.2028007.1558069879362%40mail.yahoo.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/CAD%3DM5eRMBwtQfgEacV3SqDCh4zZMDPtJ_yarb1_eazMYpcuDAA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Should there be separate django app for every user type in a django project?

2019-10-13 Thread test user
Hi,

I have got multiple user types(around 4 to 5) in my Django project. Should 
i make separate Django app for each user type? Each user type will have 
different interface after they log into the website.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f7dc3b18-ab79-42ea-9ba2-7d3b2b8187fb%40googlegroups.com.


Re: Should there be separate django app for every user type in a django project?

2019-10-14 Thread test user
Yes, i have checked this article many times. It tells you how to implement 
user model to handle multiple user types not on how the apps should be laid 
out in that case. 

My question was if you have 5 types of users in your website and each user 
has different interfaces and tasks to perform. Should code layout be with 
one Django app or split up into 5 apps along with the common app which 
handles the common functionality?


On Monday, October 14, 2019 at 8:11:46 AM UTC+5, Joalbert Palacios wrote:
>
> I think you don't need several apps for each user type. You have different 
> ways to approach it, one could be used with permisology policy for each 
> model and each user type in the Django app, other one could be managing the 
> policies by yourself. 
>
> I suggest to search in Google a entry in the blog 
> simpleisbetterthancomplex.com ir read documentation in django for further 
> details.
>
> I hope this helps.
>
>  
>
> On Sun, Oct 13, 2019, 8:33 PM test user > 
> wrote:
>
>> Hi,
>>
>> I have got multiple user types(around 4 to 5) in my Django project. 
>> Should i make separate Django app for each user type? Each user type will 
>> have different interface after they log into the website.
>>
>> -- 
>> 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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/f7dc3b18-ab79-42ea-9ba2-7d3b2b8187fb%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/f7dc3b18-ab79-42ea-9ba2-7d3b2b8187fb%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/76a5c431-c69e-49f5-beca-8ae883bf0997%40googlegroups.com.


LookupError: No installed app with label 'admin'.

2019-05-19 Thread This is a test message
Hi,

I am new to django and am trying out the tutorial. Get the following error:
1. Create a virtual environment using anaconda
2. Activate the virtual environment
3. Create the project
4. Get the following error when trying to start the server:

Directory of C:\Users\bradl\Documents\web sites\poll

2019/05/19  02:25 PM  .
2019/05/19  02:25 PM  ..
2019/05/19  02:25 PM   645 manage.py
2019/05/19  02:26 PM  poll
   1 File(s)645 bytes
   3 Dir(s)  200 980 545 536 bytes free

(pollapp) C:\Users\bradl\Documents\web sites\poll>python manage.py runserver
Watching for file changes with StatReloader
Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Users\bradl\Anaconda3\envs\pollapp\lib\threading.py", line 917, in 
_bootstrap_inner
self.run()
  File "C:\Users\bradl\Anaconda3\envs\pollapp\lib\threading.py", line 865, in 
run
self._target(*self._args, **self._kwargs)
  File 
"C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\utils\autoreload.py",
 line 54, in wrapper
fn(*args, **kwargs)
  File 
"C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\core\management\commands\runserver.py",
 line 109, in inner_run
autoreload.raise_last_exception()
  File 
"C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\utils\autoreload.py",
 line 77, in raise_last_exception
raise _exception[0](_exception[1]).with_traceback(_exception[2])
  File 
"C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\utils\autoreload.py",
 line 54, in wrapper
fn(*args, **kwargs)
  File 
"C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\__init__.py", 
line 24, in setup
apps.populate(settings.INSTALLED_APPS)
  File 
"C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\apps\registry.py",
 line 114, in populate
app_config.import_models()
  File 
"C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\apps\config.py",
 line 211, in import_models
self.models_module = import_module(models_module_name)
  File "C:\Users\bradl\Anaconda3\envs\pollapp\lib\importlib\__init__.py", line 
127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 1006, in _gcd_import
  File "", line 983, in _find_and_load
  File "", line 967, in _find_and_load_unlocked
  File "", line 677, in _load_unlocked
  File "", line 728, in exec_module
  File "", line 219, in _call_with_frames_removed
  File 
"C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\contrib\auth\models.py",
 line 2, in 
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File 
"C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\contrib\auth\base_user.py",
 line 47, in 
class AbstractBaseUser(models.Model):
  File 
"C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\db\models\base.py",
 line 117, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
  File 
"C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\db\models\base.py",
 line 321, in add_to_class
value.contribute_to_class(cls, name)
  File 
"C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\db\models\options.py",
 line 204, in contribute_to_class
self.db_table = truncate_name(self.db_table, 
connection.ops.max_name_length())
  File 
"C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\db\__init__.py",
 line 28, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
  File 
"C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\db\utils.py", 
line 201, in __getitem__
backend = load_backend(db['ENGINE'])
  File 
"C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\db\utils.py", 
line 110, in load_backend
return import_module('%s.base' % backend_name)
  File "C:\Users\bradl\Anaconda3\envs\pollapp\lib\importlib\__init__.py", line 
127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File 
"C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\db\backends\sqlite3\base.py",
 line 28, in 
from .introspection import DatabaseIntrospection# isort:skip
  File 
"C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\db\backends\sqlite3\introspection.py",
 line 4, in 
import sqlparse
ModuleNotFoundError: No module named 'sqlparse'

Traceback (most recent call last):
  File 
"C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\apps\registry.py",
 line 155, in get_app_config
return self.app_configs[app_label]
KeyError: 'admin'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 21, in 
main()
  File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
  File 
"C:\Users\bradl\Anaconda3\envs\pollapp\lib\site-packages\django\core\management\__init__.py",
 line