Re: how to pass the ID of a slected item in a list to ORM

2018-06-15 Thread Gerald Brown
When I inspect the object in Firefox that is what it looks like because 
it is generated by Django. Does the user have to select an item and then 
submit it in order for me to get the ID?


Thanks.


On Friday, 15 June, 2018 10:29 PM, C. Kirby wrote:

So you have a
|

A
|B
|||C

||
|

If you make your option tags look like
|
{{person.name}}
|

The submitted value for the field will be the patient_id, which you 
then use in your filter statement.



On Friday, June 15, 2018 at 8:46:53 AM UTC-4, Gerald Brown wrote:

Greetings:

I have a form with a listbox that has people's names and their ID
from the database.  I am trying to get the ID from that list for
the selected person so I can use it in ORM statements: I.E. v1 =
Visit.objects.filter(person_id = ??) where ?? is the ID from the
select list.

Has anyone had any experience on how I can accomplish this?

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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bd054ed4-8761-415d-adaf-07bfc144956d%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/11e7c90f-4305-3062-1d2e-c0f49f97d81d%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to pass the ID of a slected item in a list to ORM

2018-06-15 Thread Gerald Brown

The ID is an integer as it is the ID for the table. The name is a VARCHAR.

I have had this same problem in the past with other programming 
languages.  How to get my head around how to get the ID for a selected item.



On Friday, 15 June, 2018 10:09 PM, Anthony Anonde wrote:

Sorry your question is a bit complicated, you have a form that contains a list 
of names and id, what data types are they contain in? Understand how the list 
box is structured will help to give you a better ans



--
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/9d61cf55-43b1-a7ac-2a87-894227cf4b91%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django Admin: multi-table inheritance child model with many-to-many through inline fails with “Please correct the error below”

2018-06-15 Thread Scott Obara
I'm not sure if this is a bug, limitation or error on my part, but I would 
like to get feedback on if there is a solution or work around to this 
issue...

In Django Admin, I have created a many-to-many inline based on a 'through' 
model `ReleaseCardCount`. The inline is linked to a parent class `Card` 
which is used for numerous child models. In Django Admin, I am only 
interested in configuring the child classes of `Card`, for example, 
`ActionCard`.

If I configure Django Admin for the parent `Card` model and 
`ReleaseCardCount` inline, I am able to add, remove and modify parent and 
inline objects without issue. If I configure the same set up for a child 
object of card, for example `ActionCard`, I can add inline objects if there 
are none or delete all inline objects, but I am unable to modify 
`ActionCard` or an inline object if an inline exists. If an inline object 
is present and I attempt to modify and save any data I get a "Please 
correct the error below" message, with no error present. 

I've minimised the code needed to recreate the issue to the following...

models.py: 

from django.db import models

class Release2(models.Model):
release_id = models.AutoField(primary_key=True)
release_name = models.CharField(max_length=100)

def __str__(self):
return self.release_name

class Card2(models.Model):
card_id = models.AutoField(primary_key=True) 
card_name = models.CharField(max_length=100)
release_card_count = models.ManyToManyField( Release2, 
through='ReleaseCardCount2',)

def __str__(self):
return self.card_name

class ReleaseCardCount2(models.Model):
rcc_id = models.AutoField(primary_key=True)
rcc_release = models.ForeignKey(Release2, on_delete=models.CASCADE)
rcc_card = models.ForeignKey(Card2, on_delete=models.CASCADE)
rcc_count = models.PositiveIntegerField(default=1, null=True, 
blank=True)

class ActionCard2(Card2):
action_card_id = models.AutoField(primary_key=True)
action_name = models.CharField(max_length=100)

def __str__(self):
return self.card_name

admin.py:

from .models import (Release2, Card2, ReleaseCardCount2, ActionCard2)

class ReleaseCardCount2InLine(admin.TabularInline):
model = ReleaseCardCount2
extra = 1

class Card2Admin(admin.ModelAdmin):
inlines = (ReleaseCardCount2InLine,)
model = Card2

class ActionCard2Admin(admin.ModelAdmin):
inlines = (ReleaseCardCount2InLine,)
model = ActionCard2

admin.site.register(Release2)
admin.site.register(Card2, Card2Admin)
admin.site.register(ActionCard2, ActionCard2Admin)

Of interest, in my troubleshooting, I dropped and recreated the database in 
a dev environment. I found that one of the child models that was not 
working before, suddenly began to work. I suspect, that it worked due to 
being the first child model I configured Django Admin for with the inline. 
To recreate the issue with the above code, you may need try running it 
*FIRST* on the parent `Card` model. Once you have added, saved then 
modified and saved an inline object on `Card`, you can try it on 
`ActionCard`.

Relevant environment info:

 - Django - 2.0.6
 - Python - 3.6.4
 - PostgreSQL - 10.4

Thanks, Scott

-- 
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/2704cc01-75de-4244-8548-7daeda18df82%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: 404 error on tried these URL patterns, in this order: ^polls/ ^admin/

2018-06-15 Thread C. Kirby
What it the url you tried to access? 

On Friday, June 15, 2018 at 10:41:41 AM UTC-4, emmanuel wyckens wrote:
>
> Hello
>
> I didn't find my 404 error, it's seems that the issue is arround the urls 
> configuration on the project. In additionnal, find the zip project for more 
> details.
> Confg : django 1.11.11, python 2.7
>
> Please could you help me ?
>
> Thanks
>
> In urls.py 
>
> from django.conf.urls import url, include
> from django.contrib import admin
>
> urlpatterns = [
> url(r'^polls/', include('polls.urls')),
> url(r'^admin/', admin.site.urls),
> ]
>
> In polls/urls.py
>
> # -*- coding: utf-8 -*-
> from django.conf.urls import url, include
>
> from . import views
>
> urlpatterns = [
> url('', views.index, name='index'),
> ]
>
>
>
>

-- 
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/d3fa686e-8185-49ba-82b2-76831bb66bf8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Mixins] - Order of the Mixins - Is it a bug?

2018-06-15 Thread Vinnicyus Gracindo
Hi. I beat my brains out trying to find out why my cbv was not working with
LoginRequiredMixin.
I found the order of the mixins in the inheritance:
It works: class UserListView(LoginRequiredMixin, ListView)
Doesn't work:  class UserListView(ListView, LoginRequiredMixin)

Is that how it was designed? or is it a bug?

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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMjWKi9RFwDWSnNU%3Dv16-bXx%2BjEvMOfnVnWnhrnFnFzrWsMsyQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


404 error on tried these URL patterns, in this order: ^polls/ ^admin/

2018-06-15 Thread emmanuel wyckens
Hello

I didn't find my 404 error, it's seems that the issue is arround the urls 
configuration on the project. In additionnal, find the zip project for more 
details.
Confg : django 1.11.11, python 2.7

Please could you help me ?

Thanks

In urls.py 

from django.conf.urls import url, include
from django.contrib import admin

urlpatterns = [
url(r'^polls/', include('polls.urls')),
url(r'^admin/', admin.site.urls),
]

In polls/urls.py

# -*- coding: utf-8 -*-
from django.conf.urls import url, include

from . import views

urlpatterns = [
url('', views.index, name='index'),
]



-- 
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/25321b55-f2e3-48e7-a9e5-c7d5456a6f32%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<>


Re: Getting django.db.utils.OperationalError: (2005, "Unknown MySQL server host error with AWS

2018-06-15 Thread prateek gupta
Thanks, I will verify.

On Friday, June 15, 2018 at 7:55:10 PM UTC+5:30, Andréas Kühne wrote:
>
> As Jason stated you probably have an issue with security groups. Make sure 
> that your EC2 instance is in a security group that can access the mysql 
> server. Otherwise you won't be able to connect. And the error you have is 
> what you get when the security groups aren't correct.
>
> See here:
>
> https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/TUT_WebAppWithRDS.html
>
> Regards,
>
> Andréas
>
> 2018-06-15 15:11 GMT+02:00 Jason >:
>
>> have you checked your security settings in the aws console to make sure 
>> the port is open?
>>
>> also have you seen https://stackoverflow.com/a/45792248/214892
>>
>> -- 
>> 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/ff00ed62-d489-42b7-90de-a835e4f57da2%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/f5afb193-5ba0-4db2-907c-a1eba457a522%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting django.db.utils.OperationalError: (2005, "Unknown MySQL server host error with AWS

2018-06-15 Thread prateek gupta
Thanks Json, I will check this.

On Friday, June 15, 2018 at 6:41:42 PM UTC+5:30, Jason wrote:
>
> have you checked your security settings in the aws console to make sure 
> the port is open?
>
> also have you seen https://stackoverflow.com/a/45792248/214892
>

-- 
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/568b8f4f-5f07-4745-a72f-2652e8b7832b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to pass the ID of a slected item in a list to ORM

2018-06-15 Thread C. Kirby
So you have a 

  A
  B
  C


If you make your option tags look like
{{person.name}}

The submitted value for the field will be the patient_id, which you then 
use in your filter statement.


On Friday, June 15, 2018 at 8:46:53 AM UTC-4, Gerald Brown wrote:
>
> Greetings:
>
> I have a form with a listbox that has people's names and their ID from the 
> database.  I am trying to get the ID from that list for the selected person 
> so I can use it in ORM statements: I.E. v1 = Visit.objects.filter(person_id 
> = ??) where ?? is the ID from the select list.
>
> Has anyone had any experience on how I can accomplish this?
>
> 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bd054ed4-8761-415d-adaf-07bfc144956d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting django.db.utils.OperationalError: (2005, "Unknown MySQL server host error with AWS

2018-06-15 Thread Andréas Kühne
As Jason stated you probably have an issue with security groups. Make sure
that your EC2 instance is in a security group that can access the mysql
server. Otherwise you won't be able to connect. And the error you have is
what you get when the security groups aren't correct.

See here:
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/TUT_WebAppWithRDS.html

Regards,

Andréas

2018-06-15 15:11 GMT+02:00 Jason :

> have you checked your security settings in the aws console to make sure
> the port is open?
>
> also have you seen https://stackoverflow.com/a/45792248/214892
>
> --
> 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/ff00ed62-d489-42b7-90de-a835e4f57da2%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/CAK4qSCd1tNmwex0ezLoLDANWPdtiyozswtA-LxWdNXx45JrU8w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to pass the ID of a slected item in a list to ORM

2018-06-15 Thread Anthony Anonde
Sorry your question is a bit complicated, you have a form that contains a list 
of names and id, what data types are they contain in? Understand how the list 
box is structured will help to give you a better ans

-- 
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/b4131227-2319-4cb7-973c-40e8ae41b46f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Admin verification

2018-06-15 Thread Anthony Anonde
I will suggest to have a field with active set to false, so when the use signs 
in you cleaned the data send a notice to the admin, mean while the user info is 
save to the database but user account is not active because the field active is 
set to false. When the admin sees the user data he can choose to activate the 
user.
Hope that make sense 

-- 
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/a8efe997-b84f-448d-a595-3496de1e6f7a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: Nested for loops in templates

2018-06-15 Thread Matthew Pava
I would probably even simplify the code.  Apparently, there’s a setting called 
TEMPLATE_STRING_IF_INVALID


def getattribute(value, arg):
"""Gets an attribute of an object dynamically from a string name"""
return getattr(value, arg, settings.TEMPLATE_STRING_IF_INVALID) or 
settings.TEMPLATE_STRING_IF_INVALID




From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Mikkel Kromann
Sent: Friday, June 15, 2018 6:36 AM
To: Django users
Subject: Re: Nested for loops in templates

Thanks Matthew.

The field_list is a list strings containnig the field names hardcoded in 
Models.py by the programmer.
I.e. the field names that shoud appear in the Class Based Views.
So, perhaps this answers my question to Vijay - that the row in the iteration 
is in fact the Model object.
And that I can get the contents of the field specified by the contents of the 
"field" string using getattr()

And since (unless the programmer entered wrong values for the field names, I 
can use a simplified version of the filter, e.g.:


def getattribute(value, arg):
"""Gets an attribute of an object dynamically from a string name"""
if hasattr(value, str(arg)):
return getattr(value, arg)
else
return ""

thanks, Mikkel

torsdag den 14. juni 2018 kl. 00.19.24 UTC+2 skrev Matthew Pava:
field is a string – a name of a field, field is not actually an attribute of 
row.  You’ll need a template tag to get the attribute named field from row.
This StackOverflow question may help you:
https://stackoverflow.com/questions/844746/performing-a-getattr-style-lookup-in-a-django-template?utm_medium=organic_source=google_rich_qa_campaign=google_rich_qa


From: django...@googlegroups.com 
[mailto:django...@googlegroups.com] On Behalf Of Mikkel Kromann
Sent: Wednesday, June 13, 2018 3:54 PM
To: Django users
Subject: Nested for loops in templates

Dear Django users.

Thanks to the good advice of many people on this list, I've managed to create 
some nice generic class based views that work simultaneously with many models.
The models may differ from each other with regards to the number of columns in 
their data tables as well as the naming of the columns.
In order to use the same ListView template for many models, I will need to 
iterate not only over the rows of the queries, but also the columns.

I managed to pass a field_list into the context_data - it works as it shows 
nicely in the table headers.
However, when I iterate over the rows of the query result table, I'm not able 
to pinpoint the fields of the data row using the field iterator.

My template.html is:


{% for fields in field_list %}
{{field}}
{% endfor %}
{% for row in row_list %}

{% for field in field_list %}
{{row.field}}
{% endfor %}
{% endfor %}


Besides trying with {{row.field}}, I've tried with {{row}}.{{field}}, as well 
as {{ row.{{field}} }} (yeah, long shot ...)

Any ideas, or should I try to create an entirely different data structure in my 
view, which can be parsed more easily by Django templates?


cheers + thanks, Mikkel
--
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 djang...@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/c9e29d66-f93c-4fc4-ae9f-dbeae93a2e45%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/2bf96986-c977-49bb-b71a-6d789a1c996b%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 

Re: im facing this problem please help me

2018-06-15 Thread Jason
this is a common issue, apparently, with powershell.  First result when 
looking at *django powershell* brought me to 
https://stackoverflow.com/questions/23439089/using-django-admin-on-windows-powershell

-- 
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/c2357f01-8ca5-4707-965e-bca5b86a4cc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting django.db.utils.OperationalError: (2005, "Unknown MySQL server host error with AWS

2018-06-15 Thread Jason
have you checked your security settings in the aws console to make sure the 
port is open?

also have you seen https://stackoverflow.com/a/45792248/214892

-- 
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/ff00ed62-d489-42b7-90de-a835e4f57da2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


how to pass the ID of a slected item in a list to ORM

2018-06-15 Thread Gerald Brown
Greetings:

I have a form with a listbox that has people's names and their ID from the 
database.  I am trying to get the ID from that list for the selected person 
so I can use it in ORM statements: I.E. v1 = Visit.objects.filter(person_id 
= ??) where ?? is the ID from the select list.

Has anyone had any experience on how I can accomplish this?

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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/12b0da2c-359c-4da2-ac13-9e627a91c12d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Admin verification

2018-06-15 Thread Daniel Ale
Let's talk more on this project.

You still have to add the the data to database, maybe u can create a field
to check for verification , there is no way u can persist the data plus an
instance of the model will be sent to admin in order to verify it...
Good job.

On Wed, Jun 13, 2018, 13:13 habib mobolaji  wrote:

> Please, I am currently working on a project for a modeling agency where
> the admin verifies the details of a new model after completing a
> registration form. The project is using python django framework.
>
> This is the breakdown;
>
>- A new model fills a form.
>- The form is send to the administrator's email for notification and
>confirmation of the data before being added to the database .
>- The new model is then added to the database .
>
> I have little understanding about the above problem, I will be very
> grateful for any kind of help in this, 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f18776fd-8bac-4013-af82-75120e803a86%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/CALZOSo04rshzc6njNW5ahxBbrdMEvw0OTDrDU_GczMF9vdLMig%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


im facing this problem please help me

2018-06-15 Thread Yashwanth Gathuku
django-admin.py : The term 'django-admin.py' is not recognized as the name 
of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was 
included, verify that the path is correct and try
again.
At line:1 char:1
+ django-admin.py startproject mysite
+ ~~~
+ CategoryInfo  : ObjectNotFound: (django-admin.py:String) [], 
CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

-- 
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/1e001982-640b-4b5e-9b36-f902f2f32231%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Getting django.db.utils.OperationalError: (2005, "Unknown MySQL server host error with AWS

2018-06-15 Thread prateek gupta
Hi All,

I am trying to connect with AWS and when I run the server I get following 
error-
django.db.utils.OperationalError: (2005, "Unknown MySQL server 
host 'psdbuat.chmnxeoa2hhd.ap-southeast-1.rds.amazonaws.com' (0)")

I checked the connection in mysql workbench and details are fine.
My settings.py is as below-

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'myschema',
'USER': 'admin',
'PASSWORD': 'aadmin',
'HOST': 'psdbuat.chmnxeoa2hhd.ap-southeast-1.rds.amazonaws.com',
'PORT': '3306',
}
}


I googled and found it is issue with AWS but did not find any solution.

Can anyone please share teh solution for 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/5558daa2-89c7-44aa-9553-a5441e904b71%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Nested for loops in templates

2018-06-15 Thread Mikkel Kromann
Thanks Matthew. 

The field_list is a list strings containnig the field names hardcoded in 
Models.py by the programmer.
I.e. the field names that shoud appear in the Class Based Views.
So, perhaps this answers my question to Vijay - that the row in the 
iteration is in fact the Model object.
And that I can get the contents of the field specified by the contents of 
the "field" string using getattr()

And since (unless the programmer entered wrong values for the field names, 
I can use a simplified version of the filter, e.g.:


def getattribute(value, arg): 
"""Gets an attribute of an object dynamically from a string name""" 
if hasattr(value, str(arg)): 
return getattr(value, arg)
else
return ""


thanks, Mikkel

torsdag den 14. juni 2018 kl. 00.19.24 UTC+2 skrev Matthew Pava:
>
> field is a string – a name of a field, field is not actually an attribute 
> of row.  You’ll need a template tag to get the attribute named field from 
> row.
>
> This StackOverflow question may help you:
>
>
> https://stackoverflow.com/questions/844746/performing-a-getattr-style-lookup-in-a-django-template?utm_medium=organic_source=google_rich_qa_campaign=google_rich_qa
>
>  
>
>  
>
> *From:* django...@googlegroups.com  [mailto:
> django...@googlegroups.com ] *On Behalf Of *Mikkel Kromann
> *Sent:* Wednesday, June 13, 2018 3:54 PM
> *To:* Django users
> *Subject:* Nested for loops in templates
>
>  
>
> Dear Django users.
>
>  
>
> Thanks to the good advice of many people on this list, I've managed to 
> create some nice generic class based views that work simultaneously with 
> many models.
>
> The models may differ from each other with regards to the number of 
> columns in their data tables as well as the naming of the columns.
>
> In order to use the same ListView template for many models, I will need to 
> iterate not only over the rows of the queries, but also the columns.
>
>  
>
> I managed to pass a field_list into the context_data - it works as it 
> shows nicely in the table headers.
>
> However, when I iterate over the rows of the query result table, I'm not 
> able to pinpoint the fields of the data row using the field iterator. 
>
>  
>
> My template.html is:
>
> 
> 
> {% for fields in field_list %}
> {{field}}
> {% endfor %}
> {% for row in row_list %}
> 
> {% for field in field_list %}
> {{row.field}}
> {% endfor %}
> {% endfor %}
> 
>
>
> Besides trying with {{row.field}}, I've tried with {{row}}.{{field}}, as 
> well as {{ row.{{field}} }} (yeah, long shot ...)
>
>  
>
> Any ideas, or should I try to create an entirely different data structure 
> in my view, which can be parsed more easily by Django templates?
>
>  
>
>  
>
> cheers + thanks, Mikkel
>
> -- 
> 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 djang...@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/c9e29d66-f93c-4fc4-ae9f-dbeae93a2e45%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/2bf96986-c977-49bb-b71a-6d789a1c996b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Nested for loops in templates

2018-06-15 Thread Mikkel Kromann
Thank you Vijay.

That link seems to be a feasible path for me to take (reproduced below).

Perhaps you or others can help me with an additional question (I am a bit 
new to both Python and Django), that I'm struggling with:
Which type of data structure is Django iterating over in the templates 
(i.e. the {% for row in row_list %} in my code example above).
Is "row" the Model object or is it some sort of dictionary / array data 
structure?
I've been browsing through the Classy CBV ListView pages to try to get hold 
of that, but I was not able to clarify this myself.

thank you, Mikkel


Create a template tag like this (in yourproject/templatetags):
@register.filter 
def keyvalue(dict, key): 
return dict[key] 


Usage in template:

{{dictionary|keyvalue:key_variable}} 




torsdag den 14. juni 2018 kl. 00.17.26 UTC+2 skrev Vijay Khemlani:
>
> As far as I know you can't do it directly in the templating system
>
> Yo could write a template tag as described here
>
>
> https://stackoverflow.com/questions/2894365/use-variable-as-dictionary-key-in-django-template/10700142#10700142
>
> or use a different data structure, for example each row as a list of the 
> values in the order that they should appear
>
> On Wed, Jun 13, 2018 at 4:54 PM Mikkel Kromann  > wrote:
>
>> Dear Django users.
>>
>> Thanks to the good advice of many people on this list, I've managed to 
>> create some nice generic class based views that work simultaneously with 
>> many models.
>> The models may differ from each other with regards to the number of 
>> columns in their data tables as well as the naming of the columns.
>> In order to use the same ListView template for many models, I will need 
>> to iterate not only over the rows of the queries, but also the columns.
>>
>> I managed to pass a field_list into the context_data - it works as it 
>> shows nicely in the table headers.
>> However, when I iterate over the rows of the query result table, I'm not 
>> able to pinpoint the fields of the data row using the field iterator. 
>>
>> My template.html is:
>> 
>> 
>> {% for fields in field_list %}
>> {{field}}
>> {% endfor %}
>> {% for row in row_list %}
>> 
>> {% for field in field_list %}
>> {{row.field}}
>> {% endfor %}
>> {% endfor %}
>> 
>>
>>
>> Besides trying with {{row.field}}, I've tried with {{row}}.{{field}}, as 
>> well as {{ row.{{field}} }} (yeah, long shot ...)
>>
>> Any ideas, or should I try to create an entirely different data structure 
>> in my view, which can be parsed more easily by Django templates?
>>
>>
>> cheers + thanks, Mikkel
>>
>> -- 
>> 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/c9e29d66-f93c-4fc4-ae9f-dbeae93a2e45%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/6d443c64-0c68-412b-9eb9-0a5640aab37d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: saving django session data for anonymous user

2018-06-15 Thread 'Anthony Flury' via Django users

How are you authenticating them ?

Assuming you call :

        authenicate( username, password)

then before that call - store the sesssion key

after that call - identify the new session key

with the old and new session keys - now update the database - so that 
the cart gets associated with the new session key.



On 13/06/18 13:40, Siddharth Srivastava wrote:
Thanks  Anthony for your prompt reply. current implementation is that 
i am using django orm query to pull the user cart details and cart 
id(session key) is the key so when user switch from anonymous

user to actual user then i loses the data came from the query.

so when user gets authenticated then it create new session id then 
previous session data we lose. I am not finding much help in google:(.


Thanks,

Siddharth



On Tue, Jun 12, 2018 at 8:37 AM, Anthony Flury 
mailto:anthony.fl...@btinternet.com>> 
wrote:


The only way I can think of is when your user goes to log in -
check if their session id is already recorded.

When they login - I assume that they get an new Session Id - and
remap the data from their old session id to their new session Id.

Would that work ?

On 12/06/18 11:01, Siddharth Srivastava wrote:

Hi ,

i was writing small ecommerce application in django framework.
so i was trying to implement add to cart functionality like
that if user is anonymous user then selected products should
be mapped to it's session id which is act. cart id in models.
so the scenario is that whenever anonymous user check out and
mapped data against that session id is purged. Is there any
mechanism to save anonymous user session data even after user
logs in. kindly provide easy possible solution as i am bit new
to django:)

Thanks,

Siddharth


-- 
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/d17bbc16-4c0b-4d06-bfa5-af814a20cbc6%40googlegroups.com



>.
For more options, visit https://groups.google.com/d/optout
.



-- 
-- 
Anthony Flury

email : *anthony.fl...@btinternet.com
*
Twitter : *@TonyFlury >*




--
--
Anthony Flury
email : *anthony.fl...@btinternet.com*
Twitter : *@TonyFlury *

--
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/e341aaeb-62b8-9071-181c-32305a9f08cf%40btinternet.com.
For more options, visit https://groups.google.com/d/optout.