Django for desktop app development

2018-09-07 Thread Muhammad Dilshad Khaliq
I am final year student of software engineering.My final year project is 
about fee management system where student submit fee online and 
administrator use this system for managing fee and scholarship of student 
and notifying them about their any issue.So can i  make web based 
application or desktop application for administration site and notify 
student through mobile application.?*Is it good idea to use Django for 
desktop application?*  

-- 
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/199c0ed7-ce95-42e4-b391-462a491c22fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django install

2018-09-07 Thread gonzalo rodrigo pereyra
saludos. soy nuevo en el increible mundo de la programacion, primero 
comence leyendo mucho y me gusto python., asi que lo instale ( la version 
3.6.5.)
y me gusta mucho dibujar asi que me incline para hacer diseño de paginas 
con django. si no es mucha molestia me podrian ayudar a instalar el mismo. 
me quede trabado luego que instale pip.Desde ya muchas gracias desde 
Argentina un saludo enorme!!!

-- 
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/5e81-5ac1-47b2-8999-60f231d70a8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Different results of running pure SQL query from Django and from PGAdmin

2018-09-07 Thread Pierre-Louis K.
Hello django-users,

I have been encountering a strange behaviour when trying to run SQL 
directly with a cursor. I am using Django 1.11 with porstgres 9.5.The query 
normally returns 7 rows with 2 columns.

Symptoms:
- When reading the queryset of a query I get wrong results -> I still have 
7 rows with two columns but values of the second column are weirdly similar 
in pair where they should be all different
ex: I get 500-500-800-800 where nomal results should be 500 400 800 700
- If I run the query directly (extracted from the cursor object in debug) 
with pgadmin I get the expected results
- The first columns behaves as expected

I use cursor.execute() and cursor.fetchall() to run the query and read the 
results.

I don't know if it's a bug or if I do something wrong, that's why I ask it 
there before posting a ticket.

If anyone has encountered the bug or has an idea I am interested.

Cheers,

Pierre-Louis K.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/eaa476ae-604e-405c-a1e2-681d8c139fad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How can I modify the html of the fileupload?

2018-09-07 Thread Jorge Cadena
I forgot to leave, as I render the input


{% elif field.field.widget.input_type in "file" %}

{{ field.errors }}

{{ field.label }}
{{ field }}

{% if field.help_text %}
{{ field.help_text|safe 
}}
{% endif %}


El viernes, 7 de septiembre de 2018, 16:45:37 (UTC-5), Jorge Cadena 
escribió:
>
> I want to modify or format the html generators by the input type="file".
>
> I want to give it its own style, with the same structure as the html of 
> the input type="file", of the admin
>
>
> but:
>
>
>
> I'm rendering the form, manually, to add materializecss styles
>
>
> https://docs.djangoproject.com/en/2.1/topics/forms/#looping-over-the-form-s-fields
>
>
>

-- 
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/4eb2727a-4826-42e2-b308-931d9eb9c4ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How can I modify the html of the fileupload?

2018-09-07 Thread Jorge Cadena
I want to modify or format the html generators by the input type="file".

I want to give it its own style, with the same structure as the html of the 
input type="file", of the admin


but:



I'm rendering the form, manually, to add materializecss styles

https://docs.djangoproject.com/en/2.1/topics/forms/#looping-over-the-form-s-fields


-- 
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/09522fa8-da0c-4649-8e60-8f85d975259c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: what is the difference?

2018-09-07 Thread Andréas Kühne
Hi,

First of all - the examples you are giving can't be correct.

z = Model.objects.get(name=x)

will only return 1 object - and will raise an exception if you get more
than one result. So in this case z should be an instance of the model Model.

z = 
and cannot be [, ]

When querying the second query you should get a QuerySet as a result,
because you have filtered.

So from : z = Model.objects.filter(name=x) you would get:
[]

in other words a list of 1 object (because the name was unique). Then your
code:
for x in z:
   print(x.id)

should definitely work.

If your want to do the query and just get one result (because you are
querying with the unique name), you can write:
z = Model.objects.filter(name=x).first()
This way z will also be None if there isn't any object that has the name =
x.

Regards,

Andréas


Den fre 7 sep. 2018 kl 18:44 skrev MikeKJ :

> [, ]
>
> and
>
> [[, ]]
>
> 1st came from z = Model.objects.get(name=x)
>
> This returns the object name
>
>
> 2nd came from z = Model.objects.filter(name=x)
>
> The 2nd method when you look for the id
>
> for x in z:
>print(x.id)
>
> fails with
> 'QuerySet' object has no attribute 'id'
>
> also tried
>
> zz = Model.objects.filter(name=x)
> z = z.id
>
> same result
>
> I understand that get just gets the first singular match but so should filter 
> as in this instance name is unique
>
> --
> 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/c4596762-fff4-4384-9cd2-9edabb9a58f7%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/CAK4qSCct81WvkB9_SiUphK1h4VyCPh%3DocRihU-Ah5_nP6zvs5g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


what is the difference?

2018-09-07 Thread MikeKJ


[, ]

and

[[, ]]

1st came from z = Model.objects.get(name=x)

This returns the object name


2nd came from z = Model.objects.filter(name=x)

The 2nd method when you look for the id 

for x in z:
   print(x.id)

fails with 
'QuerySet' object has no attribute 'id'

also tried

zz = Model.objects.filter(name=x)
z = z.id

same result

I understand that get just gets the first singular match but so should filter 
as in this instance name is unique

-- 
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/c4596762-fff4-4384-9cd2-9edabb9a58f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: models.py => Mandatory to create tables?

2018-09-07 Thread Andréas Kühne
Yes but it is completely OK to have a directory called models to store your
models in. That's the way we do it for our project. However you can't have
both a directory AND a models.py file.

If you choose to go with the models module (a directory called models), you
need to have the __init__.py file and separate files for each model, which
you then import in the __init__.py file - like I said earlier.

Hope everything works for you now!

Regards,

Andréas


Den fre 7 sep. 2018 kl 17:10 skrev Benjamin SOULAS <
benjamin.soula...@gmail.com>:

> Ok ... Shame ... i found, One day I created a "models" directory to store
> my models ... So because of this, it didn't make any migrations ...
>
> Sorry for the inconvenience, but now I know I have to take care about my
> folder naming convention ...
>
> Kind regards
>
> Benjamin.
>
> --
> 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/2833a84d-296b-4669-ac94-d1a83a293c7d%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/CAK4qSCcXgHPKeDw9exZMoDxnP7xR-5r9Jc8tJL4ML2OkdG5C4g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: models.py => Mandatory to create tables?

2018-09-07 Thread Benjamin SOULAS
Ok ... Shame ... i found, One day I created a "models" directory to store 
my models ... So because of this, it didn't make any migrations ...

Sorry for the inconvenience, but now I know I have to take care about my 
folder naming convention ...

Kind regards

Benjamin.

-- 
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/2833a84d-296b-4669-ac94-d1a83a293c7d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Nested Query with Aggregate.Sum()

2018-09-07 Thread Simon Charette
The annotate(seats_remaining=...) will add a `seats_remaining` attribute to 
Event
instances returned from the queryset so you should be able to use 
{{i.seats_remaining }}

Cheers,

Le vendredi 7 septembre 2018 04:38:05 UTC-4, mab.mo...@gmail.com a écrit :
>
> Thank you Simon.
>
> I will take a look at annotations. 
>
> How would I represent seats remaining in the template for loop? Here is 
> what I have so far.
>
> #
>
> {% for i in events %}
>
>
>   {{ i.event_date|date:"l M j, Y" }} {{ 
> i.event_time|date:"g:i A" }}
>   {{i.event_type|title}} - 
> {{i.title|title}}
>   Purchase Reservation ${{i.price}} Seats 
> Remaining ### VARIABLE HERE ###
>{{ i.description|safe}} 
>
>
>
>
>
>
>
>
>
>
>
> {% endfor %}
>
>
> #
>
>
>
> On Thursday, September 6, 2018 at 8:04:36 AM UTC-5, Simon Charette wrote:
>>
>> Hello there,
>>
>> You should be able to achieve what you're after by using annotations[0].
>>
>> In your case you'll want to declare your Event and Reservation 
>> relationship explicitly by using
>> a ForeignKey
>>
>> class Event(models.Model):
>> ...
>> seating = models.PositiveIntegerField(default=0)
>>
>> class Reservation(models.Model):
>> ...
>> event = models.ForeignKey(Event, related_name='reservations')
>> seats = models.PositiveIntegerField(default=0)
>>
>> And perform the following query
>>
>> Event.objects.annotate(
>> seats_remaining=F('seating') - Sum('reservations__seats').
>> )
>>
>> Cheers,
>> Simon
>>
>> [0] 
>> https://docs.djangoproject.com/en/2.1/topics/db/aggregation/#generating-aggregates-for-each-item-in-a-queryset
>>
>> Le jeudi 6 septembre 2018 07:42:36 UTC-4, mab.mo...@gmail.com a écrit :
>>>
>>>
>>> QUESTION
>>>
>>> I have an application that will make on-line reservations for a series 
>>> of weekly events. I would like to display the list of upcoming events in an 
>>> html template with the number of remaining seats available in a single html 
>>> page. I was able to create views to display the list of upcoming events and 
>>> another view to display the number of remaining seats available but I am 
>>> unable to figure out how to nest the two into a single view. Example 
>>> below...
>>>
>>> HTML OUTPUT
>>>
>>> Event Title Week 1 - x amount of seats remaining for this event
>>>
>>> Event Title Week 2 - x amount of seats remainign for this event
>>>
>>> Event Title Week 3 - x amount of seats remaining for this event
>>>
>>> and so on 
>>>
>>> MODELS
>>>
>>> class Events(models.Model):
>>>event_date = models.DateField(auto_now_add=False)
>>>event_time = models.TimeField(auto_now_add=False)
>>>event_type = models.CharField(max_length=20, choices=EVENT_TYPE)
>>>seating = models.IntegerField(default=0)
>>>title = models.CharField(max_length=200)
>>>description = models.TextField()
>>>menu = models.TextField()
>>>price = models.DecimalField(max_digits=6, decimal_places=2)
>>>publish = models.CharField(max_length=1, choices=PUBLISH_CHOICE)
>>>
>>>def __int__(self):
>>>   return self.title
>>>
>>> class Reservations(models.Model):
>>>user_id = models.IntegerField(default=0)
>>>event_id = models.IntegerField(default=0)
>>>reservations = models.IntegerField(default=0)
>>>
>>>def __int__(self):
>>>   return self.event
>>>
>>>
>>> VIEWS
>>>
>>> def events_view(request):
>>> 
>>> events=Events.objects.filter(publish='Y').filter(event_date__gte=datetime.now()).order_by('event_date')
>>>  
>>> reservation_count = Reservations.objects.aggregate(Sum('reservations'))
>>>  
>>> return render(request, 'restaurant/events.html',{"events":events, 
>>> "reservation_count":reservation_count, })
>>>
>>> def make_reservation_view(request, pk):
>>>event = Events.objects.get(id=pk)
>>>seating_available = Events.objects.get(id=pk)
>>>seating_available = seating_available.seating
>>>reservation_count = 
>>> Reservations.objects.filter(event_id=pk).aggregate(res_sum=Sum('reservations'))
>>>res = reservation_count['res_sum']
>>>seats_remaining = seating_available - res
>>>
>>>return render(request, 'restaurant/make_reservation.html', 
>>> {"event":event, \
>>>   
>>>  "seats_remaining":seats_remaining,})
>>>
>>>
>>>

-- 
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/7e36ea7d-83bb-44ab-95cd-79ffcf359bc9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: models.py => Mandatory to create tables?

2018-09-07 Thread Andréas Kühne
Ok - I think you need first of all to decide if you want to use the models
module or a models.py file. You are now using both - which won't work. The
import that you have written in the __init__.py file shouldn't work either
because you are using a relative import to get an absolute file.

First try to delete the models module and start without that.
Also looking at your layout of your code - the project seems a bit strange
(the amount of subdirectories in the api project). This is a rather "ok"
way to do it:
https://www.revsys.com/tidbits/recommended-django-project-layout/

And then add the models module if required.

Regards,

Andréas


Den fre 7 sep. 2018 kl 16:55 skrev Benjamin SOULAS <
benjamin.soula...@gmail.com>:

> I agree it should, but it doesn't, better, it does not find my model:
>
> [image: project_structure.png]
>
>
> [image: issue__init__.png]
>
>
>
>
>
> --
> 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/869963f4-81c9-42aa-9fbf-618291e3b2f2%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/CAK4qSCfABxjpjQAQeFhig-2z%2B08ioA8A_oDMKu__M1aKMmiryg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: models.py => Mandatory to create tables?

2018-09-07 Thread Benjamin SOULAS
I agree it should, but it doesn't, better, it does not find my model:

[image: project_structure.png]


[image: issue__init__.png]





-- 
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/869963f4-81c9-42aa-9fbf-618291e3b2f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: models.py => Mandatory to create tables?

2018-09-07 Thread Andréas Kühne
So the models directory should look like this:
__init__.py
model1.py

In the __init__.py file you should have the following:
from .model1 import Model1

Then it should "just work".

Regards

Andréas


Den fre 7 sep. 2018 kl 16:35 skrev Benjamin SOULAS <
benjamin.soula...@gmail.com>:

> Ok, so I think I really have a much deeper problem, __init__.py file are
> there, nothing still happen
>
> Le vendredi 7 septembre 2018 16:31:01 UTC+2, Andréas Kühne a écrit :
>>
>> If you follow the way Mike suggests - migrations will work (this is the
>> way we do it in our plattform). The important thing is that you MUST have a
>> models.py file OR a models module (a directory with the name models and a
>> __init__.py file with the imports from the individual files).
>>
>> Regards,
>>
>> Andréas
>>
>>
>> Den fre 7 sep. 2018 kl 16:27 skrev Benjamin SOULAS > >:
>>
>>> Hi Mike (again !),
>>>
>>> Okay, but it seems I have a much deeper problem, nothing happens during
>>> make migration command, I am thinking on deleting my db and restart from
>>> scratch ...
>>>
>>> Thanks !
>>>
>>> Le vendredi 7 septembre 2018 16:25:21 UTC+2, Mike Dewhirst a écrit :

 Easy

 Create a models directory. In there make __init__.py file and in there
 ...

 from .whatever import Whatever
 ... 100 classes

 Then in ./models create 100 files with one model class in each file

 Anywhere in the project you can say ...

 from app.models import Whatever



 *Connected by Motorola*


 Benjamin SOULAS  wrote:

 Hi everyone,

 Quick question I do not find the answer: does models have to located
 into *models.py* script? It believe not, If I got a project composed
 of 100 tables, it's weird to me that all models should be located here ...

 I tried, in this file, to import a model located somewhere else, but
 when i run *python manage.py makemigrations*, nothing happens, any
 idea?

 Kind regards

 Benjamin

 --
 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/a4da5a12-9c9b-42b6-b295-5492658cb046%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...@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/65c0b624-886c-46f7-9776-91971564d8d8%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/4298cf98-cad3-413d-a7bc-2a8e587b2ba2%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/CAK4qSCdbOBWuKAQ51byWRhoXqtxmjjqYb%3D91VjXkpwQQf63JGw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: models.py => Mandatory to create tables?

2018-09-07 Thread Benjamin SOULAS
Ok, so I think I really have a much deeper problem, __init__.py file are 
there, nothing still happen 

Le vendredi 7 septembre 2018 16:31:01 UTC+2, Andréas Kühne a écrit :
>
> If you follow the way Mike suggests - migrations will work (this is the 
> way we do it in our plattform). The important thing is that you MUST have a 
> models.py file OR a models module (a directory with the name models and a 
> __init__.py file with the imports from the individual files).
>
> Regards,
>
> Andréas
>
>
> Den fre 7 sep. 2018 kl 16:27 skrev Benjamin SOULAS  >:
>
>> Hi Mike (again !),
>>
>> Okay, but it seems I have a much deeper problem, nothing happens during 
>> make migration command, I am thinking on deleting my db and restart from 
>> scratch ...
>>
>> Thanks ! 
>>
>> Le vendredi 7 septembre 2018 16:25:21 UTC+2, Mike Dewhirst a écrit :
>>>
>>> Easy
>>>
>>> Create a models directory. In there make __init__.py file and in there 
>>> ...
>>>
>>> from .whatever import Whatever
>>> ... 100 classes
>>>
>>> Then in ./models create 100 files with one model class in each file
>>>
>>> Anywhere in the project you can say ...
>>>
>>> from app.models import Whatever
>>>
>>>
>>>
>>> *Connected by Motorola*
>>>
>>>
>>> Benjamin SOULAS  wrote:
>>>
>>> Hi everyone,
>>>
>>> Quick question I do not find the answer: does models have to located 
>>> into *models.py* script? It believe not, If I got a project composed of 
>>> 100 tables, it's weird to me that all models should be located here ...
>>>
>>> I tried, in this file, to import a model located somewhere else, but 
>>> when i run *python manage.py makemigrations*, nothing happens, any idea?
>>>
>>> Kind regards
>>>
>>> Benjamin
>>>
>>> -- 
>>> 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/a4da5a12-9c9b-42b6-b295-5492658cb046%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...@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/65c0b624-886c-46f7-9776-91971564d8d8%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/4298cf98-cad3-413d-a7bc-2a8e587b2ba2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: models.py => Mandatory to create tables?

2018-09-07 Thread Andréas Kühne
If you follow the way Mike suggests - migrations will work (this is the way
we do it in our plattform). The important thing is that you MUST have a
models.py file OR a models module (a directory with the name models and a
__init__.py file with the imports from the individual files).

Regards,

Andréas


Den fre 7 sep. 2018 kl 16:27 skrev Benjamin SOULAS <
benjamin.soula...@gmail.com>:

> Hi Mike (again !),
>
> Okay, but it seems I have a much deeper problem, nothing happens during
> make migration command, I am thinking on deleting my db and restart from
> scratch ...
>
> Thanks !
>
> Le vendredi 7 septembre 2018 16:25:21 UTC+2, Mike Dewhirst a écrit :
>>
>> Easy
>>
>> Create a models directory. In there make __init__.py file and in there ...
>>
>> from .whatever import Whatever
>> ... 100 classes
>>
>> Then in ./models create 100 files with one model class in each file
>>
>> Anywhere in the project you can say ...
>>
>> from app.models import Whatever
>>
>>
>>
>> *Connected by Motorola*
>>
>>
>> Benjamin SOULAS  wrote:
>>
>> Hi everyone,
>>
>> Quick question I do not find the answer: does models have to located into
>> *models.py* script? It believe not, If I got a project composed of 100
>> tables, it's weird to me that all models should be located here ...
>>
>> I tried, in this file, to import a model located somewhere else, but when
>> i run *python manage.py makemigrations*, nothing happens, any idea?
>>
>> Kind regards
>>
>> Benjamin
>>
>> --
>> 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/a4da5a12-9c9b-42b6-b295-5492658cb046%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/65c0b624-886c-46f7-9776-91971564d8d8%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/CAK4qSCd3q_n6cVSAJcEkJi2MOAoqUq_%3DfNjddBM2R3EPPLQBOA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: models.py => Mandatory to create tables?

2018-09-07 Thread Benjamin SOULAS
Hi Mike (again !),

Okay, but it seems I have a much deeper problem, nothing happens during 
make migration command, I am thinking on deleting my db and restart from 
scratch ...

Thanks ! 

Le vendredi 7 septembre 2018 16:25:21 UTC+2, Mike Dewhirst a écrit :
>
> Easy
>
> Create a models directory. In there make __init__.py file and in there ...
>
> from .whatever import Whatever
> ... 100 classes
>
> Then in ./models create 100 files with one model class in each file
>
> Anywhere in the project you can say ...
>
> from app.models import Whatever
>
>
>
> *Connected by Motorola*
>
>
> Benjamin SOULAS > wrote:
>
> Hi everyone,
>
> Quick question I do not find the answer: does models have to located into 
> *models.py* script? It believe not, If I got a project composed of 100 
> tables, it's weird to me that all models should be located here ...
>
> I tried, in this file, to import a model located somewhere else, but when 
> i run *python manage.py makemigrations*, nothing happens, any idea?
>
> Kind regards
>
> Benjamin
>
> -- 
> 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/a4da5a12-9c9b-42b6-b295-5492658cb046%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/65c0b624-886c-46f7-9776-91971564d8d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: models.py => Mandatory to create tables?

2018-09-07 Thread Mike Dewhirst
Easy

Create a models directory. In there make __init__.py file and in there ...

from .whatever import Whatever
... 100 classes

Then in ./models create 100 files with one model class in each file

Anywhere in the project you can say ...

from app.models import Whatever



Connected by Motorola

Benjamin SOULAS  wrote:

>Hi everyone,
>
>
>Quick question I do not find the answer: does models have to located into 
>models.py script? It believe not, If I got a project composed of 100 tables, 
>it's weird to me that all models should be located here ...
>
>
>I tried, in this file, to import a model located somewhere else, but when i 
>run python manage.py makemigrations, nothing happens, any idea?
>
>
>Kind regards
>
>
>Benjamin
>
>-- 
>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/a4da5a12-9c9b-42b6-b295-5492658cb046%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/xf7t99txw3avt68gsuu12x58.1536330258869%40email.android.com.
For more options, visit https://groups.google.com/d/optout.


Re: models.py => Mandatory to create tables?

2018-09-07 Thread Benjamin SOULAS
Ok, but importing external scripts (but still in the project) should work?

Even adding my model code inside models.py, no migration happens.

Le vendredi 7 septembre 2018 16:18:47 UTC+2, Gerald Brown a écrit :
>
> There should be a models.py file under each of your applications.
>
> On Friday, 07 September, 2018 10:06 PM, Benjamin SOULAS wrote:
>
> Hi everyone, 
>
> Quick question I do not find the answer: does models have to located into 
> *models.py* script? It believe not, If I got a project composed of 100 
> tables, it's weird to me that all models should be located here ...
>
> I tried, in this file, to import a model located somewhere else, but when 
> i run *python manage.py makemigrations*, nothing happens, any idea?
>
> Kind regards
>
> Benjamin
> -- 
> 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/a4da5a12-9c9b-42b6-b295-5492658cb046%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/60797bc7-1410-48a9-b029-133b4bd41185%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: models.py => Mandatory to create tables?

2018-09-07 Thread Gerald Brown

There should be a models.py file under each of your applications.


On Friday, 07 September, 2018 10:06 PM, Benjamin SOULAS wrote:

Hi everyone,

Quick question I do not find the answer: does models have to located 
into *models.py* script? It believe not, If I got a project composed 
of 100 tables, it's weird to me that all models should be located here ...


I tried, in this file, to import a model located somewhere else, but 
when i run *python manage.py makemigrations*, nothing happens, any idea?


Kind regards

Benjamin
--
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/a4da5a12-9c9b-42b6-b295-5492658cb046%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/9158f47b-58ac-b866-2e14-4aede5f0ca6c%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


models.py => Mandatory to create tables?

2018-09-07 Thread Benjamin SOULAS
Hi everyone,

Quick question I do not find the answer: does models have to located into 
*models.py* script? It believe not, If I got a project composed of 100 
tables, it's weird to me that all models should be located here ...

I tried, in this file, to import a model located somewhere else, but when i 
run *python manage.py makemigrations*, nothing happens, any idea?

Kind regards

Benjamin

-- 
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/a4da5a12-9c9b-42b6-b295-5492658cb046%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to save multiple model form in one template?

2018-09-07 Thread Anthony Petrillo
Here is an example. I've cut out some of the code, but I this will give you 
the general idea. Note, I move the data from the Day form in to the Classes 
table. But you could just save both sets of data to their respective tables 
if desired.

in views.py

class ClassesAddView(LoginRequiredMixin,View):
classesFormClass = ClassesRegForm
daysFormClass = DaysForm
template_name = 'qing/classes.html'

def get(self,request,role='NoRole'):
classesForm = self.classesFormClass()
context['form'] = classesForm
daysForm = self.daysFormClass()
context['daysform'] = daysForm
return render(request,self.template_name, context)

def post(self, request, *args, **kwargs):
classesForm = self.classesFormClass(request.POST)
daysForm = self.daysFormClass(request.POST)
if classesForm.is_valid() and daysForm.is_valid():
days = str(request.POST.getlist('days'))
reference = request.POST['reference']
classes = classesForm.save()
classes = Classes.objects.get(reference=reference)
classes.days = days
classes.save()
else:
classesForm = self.classesFormClass(request.POST)
context['form'] = classesForm
daysForm = self.daysFormClass(request.POST)
context['daysform'] = daysForm
context['datavalid'] = False
return render(request, self.template_name, context)
return HttpResponseRedirect(reverse('classesadd',args=(role,)))

in forms.py

class ClassesForm(ModelForm):
class Meta:
model = Classes
fields = ['reference','course','teachers',etc...]

class DaysForm(forms.Form):
OPTIONS = (
("Sunday", "Sunday"),
("Monday", "Monday"),
("Tuesday", "Tuesday"),
("Wednesday", "Wednesday"),
("Thursday", "Thursday"),
("Friday", "Friday"),
("Saturday", "Saturday"),
)
days = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple,
 choices=OPTIONS)


On Friday, September 7, 2018 at 9:47:51 AM UTC-4, Akshay Gaur wrote:
>
> I think it would be easier to write out a custom form (without using your 
> model classes, just the fields that you will need for all the models) and 
> then in the save method for that form's view, you create model objects 
> using the fields in the POST request.
>
> On Friday, September 7, 2018 at 5:43:11 AM UTC-5, Django Lover wrote:
>>
>>
>> I have one page, which I have to show three model form and three 
>> different submit button for each.
>>
>> My question is how I can save these three form individually?
>>
>> FOLLOWING IS CODE:-
>>
>> **form.py**
>>
>>
>> class UserTaxesMultiForm(MultiModelForm):
>>form_classes = {
>>'user_tax_form': MyForm,
>>'user_discount_form': DiscountForm,
>>'user_shiping_form': ShipmentForm,
>>}
>>
>> *Note- myForm, DiscountForm, ShipmentForm are model forms. like 
>> following-*
>>
>> class MyForm(forms.ModelForm):
>>prefix = 'tax'
>>class Meta:
>>model = StUserTaxDetails
>>fields = ('tax_name', 'tax_rate')
>>  
>>tax_name = forms.CharField(max_length=10,
>> widget=forms.TextInput(),
>> required=True, label="tax name")
>>
>> tax_rate = forms.FloatField(required=True,  label="tax rate")
>>
>>
>> error_messages  = {
>>'required': _('fields are required.'),
>>}
>>
>> def clean_title(self):
>>return self.cleaned_data['tax_name']
>>
>> def clean(self):
>>tax_name = self.cleaned_data.get('tax_name')
>>tax_rate = self.cleaned_data.get('tax_rate')
>> 
>> if not tax_name and not tax_rate:
>>raise forms.ValidationError(
>>self.error_messages['required'],
>>code='required',
>>)
>>return self.cleaned_data
>>
>> **view.py**
>> class AddTaxView(LoginRequiredMixin, CreateView):
>>template_name = 'invoices/add_tax.html'
>>form_class = UserTaxesMultiForm
>>success_url = '/add/tax/'
>>
>>*{WHAT IS THE CODE HERE FOR THE POST METHOD TO SAVE DATA ACORDING 
>> DIFFRENT FORM SUBMIT} *
>> 
>>
>>
>>
>> **HTML**
>>
>>
>>
>> 
>> {% form.user_tax_form%}
>>
>> 
>> 
>>
>> 
>> {% form.user_discount_form%}
>>
>> 
>> 
>>
>> 
>> {% form.user_shiping_form%}
>>
>> 
>> 
>>
>> PLEASE 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 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: How to save multiple model form in one template?

2018-09-07 Thread Akshay Gaur
I think it would be easier to write out a custom form (without using your 
model classes, just the fields that you will need for all the models) and 
then in the save method for that form's view, you create model objects 
using the fields in the POST request.

On Friday, September 7, 2018 at 5:43:11 AM UTC-5, Django Lover wrote:
>
>
> I have one page, which I have to show three model form and three 
> different submit button for each.
>
> My question is how I can save these three form individually?
>
> FOLLOWING IS CODE:-
>
> **form.py**
>
>
> class UserTaxesMultiForm(MultiModelForm):
>form_classes = {
>'user_tax_form': MyForm,
>'user_discount_form': DiscountForm,
>'user_shiping_form': ShipmentForm,
>}
>
> *Note- myForm, DiscountForm, ShipmentForm are model forms. like following-*
>
> class MyForm(forms.ModelForm):
>prefix = 'tax'
>class Meta:
>model = StUserTaxDetails
>fields = ('tax_name', 'tax_rate')
>  
>tax_name = forms.CharField(max_length=10,
> widget=forms.TextInput(),
> required=True, label="tax name")
>
> tax_rate = forms.FloatField(required=True,  label="tax rate")
>
>
> error_messages  = {
>'required': _('fields are required.'),
>}
>
> def clean_title(self):
>return self.cleaned_data['tax_name']
>
> def clean(self):
>tax_name = self.cleaned_data.get('tax_name')
>tax_rate = self.cleaned_data.get('tax_rate')
> 
> if not tax_name and not tax_rate:
>raise forms.ValidationError(
>self.error_messages['required'],
>code='required',
>)
>return self.cleaned_data
>
> **view.py**
> class AddTaxView(LoginRequiredMixin, CreateView):
>template_name = 'invoices/add_tax.html'
>form_class = UserTaxesMultiForm
>success_url = '/add/tax/'
>
>*{WHAT IS THE CODE HERE FOR THE POST METHOD TO SAVE DATA ACORDING 
> DIFFRENT FORM SUBMIT} *
> 
>
>
>
> **HTML**
>
>
>
> 
> {% form.user_tax_form%}
>
> 
> 
>
> 
> {% form.user_discount_form%}
>
> 
> 
>
> 
> {% form.user_shiping_form%}
>
> 
> 
>
> PLEASE 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 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/dae1f0b7-7853-40df-88f3-fbace7aaa920%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


I have to make a master detail form

2018-09-07 Thread Md.iftequar iqbal
I am a newbie to Django. I was trying in to make an employee management 
system.
So I need an advice on how to create a master-detail type layout

-- 
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/16b72acb-ed1b-4e8a-8b35-55ef588d27bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to save multiple model form in one template?

2018-09-07 Thread Sunil Kothiyal
Do you have something to save multiform using by one view?/


On Fri, Sep 7, 2018 at 5:33 PM Elphas Rop  wrote:

> you make the 3 forms then make a view for saving each form then url for
> each them then in each form action add a url to the view responsible for
> saving it
>
> On Fri, Sep 7, 2018, 14:27 Elphas Rop  wrote:
>
>> >>>
 tax_rate = forms.FloatField(required=True,  label="tax rate")


 error_messages  = {
'required': _('fields are required.'),
}

 def clean_title(self):
return self.cleaned_data['tax_name']

 def clean(self):
tax_name = self.cleaned_data.get('tax_name')
tax_rate = self.cleaned_data.get('tax_rate')

 if not tax_name and not tax_rate:
raise forms.ValidationError(
self.error_messages['required'],
code='required',
)
return self.cleaned_data

 **view.py**
 class AddTaxView(LoginRequiredMixin, CreateView):
template_name = 'invoices/add_tax.html'
form_class = UserTaxesMultiForm
success_url = '/add/tax/'

*{WHAT IS THE CODE HERE FOR THE POST METHOD TO SAVE DATA ACORDING
 DIFFRENT FORM SUBMIT} *




 **HTML**



 
 {% form.user_tax_form%}

 
 

 
 {% form.user_discount_form%}

 
 

 
 {% form.user_shiping_form%}

 
 

 PLEASE 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 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/45a017a3-9633-426f-81e1-b261189e714a%40googlegroups.com
 
 .
 For more options, visit https://groups.google.com/d/optout.

>>>
>>>
>>> --
>>> Mohd Aqib
>>> Software Engineer
>>> 9873141865
>>>
>>> --
>>> 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/CAOh93neYb8me%3DkLOigxMjeBLETPB2_bszL8nB4WhZsEreHwJMQ%40mail.gmail.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/HlJSOz8zgwM/unsubscribe.
> To unsubscribe from this group and all its topics, 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/CAKNYNB%3Db8NnRnONyy_PrAovnqko1NQ4CA%2BeP-2mtK24-CGcxwA%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
*Thanks & Regards,*

*Sunil Kothiyal*

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


Re: How to save multiple model form in one template?

2018-09-07 Thread Elphas Rop
you make the 3 forms then make a view for saving each form then url for
each them then in each form action add a url to the view responsible for
saving it

On Fri, Sep 7, 2018, 14:27 Elphas Rop  wrote:

> >>
>>> tax_rate = forms.FloatField(required=True,  label="tax rate")
>>>
>>>
>>> error_messages  = {
>>>'required': _('fields are required.'),
>>>}
>>>
>>> def clean_title(self):
>>>return self.cleaned_data['tax_name']
>>>
>>> def clean(self):
>>>tax_name = self.cleaned_data.get('tax_name')
>>>tax_rate = self.cleaned_data.get('tax_rate')
>>>
>>> if not tax_name and not tax_rate:
>>>raise forms.ValidationError(
>>>self.error_messages['required'],
>>>code='required',
>>>)
>>>return self.cleaned_data
>>>
>>> **view.py**
>>> class AddTaxView(LoginRequiredMixin, CreateView):
>>>template_name = 'invoices/add_tax.html'
>>>form_class = UserTaxesMultiForm
>>>success_url = '/add/tax/'
>>>
>>>*{WHAT IS THE CODE HERE FOR THE POST METHOD TO SAVE DATA ACORDING
>>> DIFFRENT FORM SUBMIT} *
>>>
>>>
>>>
>>>
>>> **HTML**
>>>
>>>
>>>
>>> 
>>> {% form.user_tax_form%}
>>>
>>> 
>>> 
>>>
>>> 
>>> {% form.user_discount_form%}
>>>
>>> 
>>> 
>>>
>>> 
>>> {% form.user_shiping_form%}
>>>
>>> 
>>> 
>>>
>>> PLEASE 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 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/45a017a3-9633-426f-81e1-b261189e714a%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> --
>> Mohd Aqib
>> Software Engineer
>> 9873141865
>>
>> --
>> 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/CAOh93neYb8me%3DkLOigxMjeBLETPB2_bszL8nB4WhZsEreHwJMQ%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/CAKNYNB%3Db8NnRnONyy_PrAovnqko1NQ4CA%2BeP-2mtK24-CGcxwA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to save multiple model form in one template?

2018-09-07 Thread Sunil Kothiyal
 following are my models they are not related to each other.

class StUserTaxDetails(models.Model):
user = models.ForeignKey(UserModel, on_delete=models.DO_NOTHING, null=False,
default=None)
tax_name = models.CharField(max_length=50)
tax_rate = models.FloatField()


def __str__(self):
return self.tax_name

class Meta:
managed = True
db_table = 'st_user_tax_details'


class StUserDiscountDetails(models.Model):
creater = models.OneToOneField(
UserModel, on_delete=models.CASCADE, blank=False)
discount_name = models.CharField(max_length=50)
discount_rate = models.FloatField()

class Meta:
managed = True
db_table = 'st_user_discount_details'


On Fri, Sep 7, 2018 at 4:50 PM Mohammad Aqib 
wrote:

> Show your models.py.
>
> On Fri, Sep 7, 2018 at 4:13 PM Django Lover 
> wrote:
>
>>
>> I have one page, which I have to show three model form and three
>> different submit button for each.
>>
>> My question is how I can save these three form individually?
>>
>> FOLLOWING IS CODE:-
>>
>> **form.py**
>>
>>
>> class UserTaxesMultiForm(MultiModelForm):
>>form_classes = {
>>'user_tax_form': MyForm,
>>'user_discount_form': DiscountForm,
>>'user_shiping_form': ShipmentForm,
>>}
>>
>> *Note- myForm, DiscountForm, ShipmentForm are model forms. like
>> following-*
>>
>> class MyForm(forms.ModelForm):
>>prefix = 'tax'
>>class Meta:
>>model = StUserTaxDetails
>>fields = ('tax_name', 'tax_rate')
>>
>>tax_name = forms.CharField(max_length=10,
>> widget=forms.TextInput(),
>> required=True, label="tax name")
>>
>> tax_rate = forms.FloatField(required=True,  label="tax rate")
>>
>>
>> error_messages  = {
>>'required': _('fields are required.'),
>>}
>>
>> def clean_title(self):
>>return self.cleaned_data['tax_name']
>>
>> def clean(self):
>>tax_name = self.cleaned_data.get('tax_name')
>>tax_rate = self.cleaned_data.get('tax_rate')
>>
>> if not tax_name and not tax_rate:
>>raise forms.ValidationError(
>>self.error_messages['required'],
>>code='required',
>>)
>>return self.cleaned_data
>>
>> **view.py**
>> class AddTaxView(LoginRequiredMixin, CreateView):
>>template_name = 'invoices/add_tax.html'
>>form_class = UserTaxesMultiForm
>>success_url = '/add/tax/'
>>
>>*{WHAT IS THE CODE HERE FOR THE POST METHOD TO SAVE DATA ACORDING
>> DIFFRENT FORM SUBMIT} *
>>
>>
>>
>>
>> **HTML**
>>
>>
>>
>> 
>> {% form.user_tax_form%}
>>
>> 
>> 
>>
>> 
>> {% form.user_discount_form%}
>>
>> 
>> 
>>
>> 
>> {% form.user_shiping_form%}
>>
>> 
>> 
>>
>> PLEASE 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 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/45a017a3-9633-426f-81e1-b261189e714a%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> Mohd Aqib
> Software Engineer
> 9873141865
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/HlJSOz8zgwM/unsubscribe.
> To unsubscribe from this group and all its topics, 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/CAOh93neYb8me%3DkLOigxMjeBLETPB2_bszL8nB4WhZsEreHwJMQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
*Thanks & Regards,*

*Sunil Kothiyal*

-- 
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/CAB%3DWnGcyfiN2txQODBP86m%2BwQ87V-VbpKBWKy_AUv%3DDviunpLw%40mail.gmail.com.
For 

Re: How to save multiple model form in one template?

2018-09-07 Thread Mohammad Aqib
Show your models.py.

On Fri, Sep 7, 2018 at 4:13 PM Django Lover  wrote:

>
> I have one page, which I have to show three model form and three
> different submit button for each.
>
> My question is how I can save these three form individually?
>
> FOLLOWING IS CODE:-
>
> **form.py**
>
>
> class UserTaxesMultiForm(MultiModelForm):
>form_classes = {
>'user_tax_form': MyForm,
>'user_discount_form': DiscountForm,
>'user_shiping_form': ShipmentForm,
>}
>
> *Note- myForm, DiscountForm, ShipmentForm are model forms. like following-*
>
> class MyForm(forms.ModelForm):
>prefix = 'tax'
>class Meta:
>model = StUserTaxDetails
>fields = ('tax_name', 'tax_rate')
>
>tax_name = forms.CharField(max_length=10,
> widget=forms.TextInput(),
> required=True, label="tax name")
>
> tax_rate = forms.FloatField(required=True,  label="tax rate")
>
>
> error_messages  = {
>'required': _('fields are required.'),
>}
>
> def clean_title(self):
>return self.cleaned_data['tax_name']
>
> def clean(self):
>tax_name = self.cleaned_data.get('tax_name')
>tax_rate = self.cleaned_data.get('tax_rate')
>
> if not tax_name and not tax_rate:
>raise forms.ValidationError(
>self.error_messages['required'],
>code='required',
>)
>return self.cleaned_data
>
> **view.py**
> class AddTaxView(LoginRequiredMixin, CreateView):
>template_name = 'invoices/add_tax.html'
>form_class = UserTaxesMultiForm
>success_url = '/add/tax/'
>
>*{WHAT IS THE CODE HERE FOR THE POST METHOD TO SAVE DATA ACORDING
> DIFFRENT FORM SUBMIT} *
>
>
>
>
> **HTML**
>
>
>
> 
> {% form.user_tax_form%}
>
> 
> 
>
> 
> {% form.user_discount_form%}
>
> 
> 
>
> 
> {% form.user_shiping_form%}
>
> 
> 
>
> PLEASE 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 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/45a017a3-9633-426f-81e1-b261189e714a%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Mohd Aqib
Software Engineer
9873141865

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


Re: Creating a single page app

2018-09-07 Thread Jani Tiainen
Hi.

Django is really frontend agnostic and there isn't definite answer what is
the best framework.

So pick one that you're happy with.


pe 7. syysk. 2018 klo 8.20 Md.iftequar iqbal 
kirjoitti:

> Which is the best best frontend js for django
>
>
> On Fri, 7 Sep 2018, 10:34 am Andréas Kühne, 
> wrote:
>
>> Short answer - yes it's possible, but not optimal.
>>
>> Long answer:
>> A single page app isn't really dependent that much on the view that you
>> use but rather some sort of javascript frontend. You will need to use a js
>> frontend like Vue, React or Angular. The backend should probably then be
>> based on a rest framework (django rest framework for example). That way the
>> frontend will be able to easily communicate with the backend.
>>
>> Regards,,
>>
>> Andréas
>>
>>
>> Den fre 7 sep. 2018 kl 04:35 skrev Md.iftequar iqbal <
>> iftequa...@gmail.com>:
>>
>>> Can we create a single page app that performs CRUD(Create, Read, Update,
>>> Delete) operations by using class-based views
>>>
>>> --
>>> 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/439a3906-bf68-42c3-92c8-9e46023e0858%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/CAK4qSCebhTmRj2c1AkhxToVKVAE-M-Qm2AqNbtLXFtYZNYZAtQ%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/CAHAmP3ScwKgEpoZv3nbK%3DRbXHAOnhCWCd4Scch7otaT5Vx8atw%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/CAHn91odfFoPEsmuNpHvdvSs9viC3Sy-2z7efXHH%3DmQd36Bdoig%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to save multiple model form in one template?

2018-09-07 Thread Django Lover

I have one page, which I have to show three model form and three 
different submit button for each.

My question is how I can save these three form individually?

FOLLOWING IS CODE:-

**form.py**


class UserTaxesMultiForm(MultiModelForm):
   form_classes = {
   'user_tax_form': MyForm,
   'user_discount_form': DiscountForm,
   'user_shiping_form': ShipmentForm,
   }

*Note- myForm, DiscountForm, ShipmentForm are model forms. like following-*

class MyForm(forms.ModelForm):
   prefix = 'tax'
   class Meta:
   model = StUserTaxDetails
   fields = ('tax_name', 'tax_rate')
 
   tax_name = forms.CharField(max_length=10,
widget=forms.TextInput(),
required=True, label="tax name")

tax_rate = forms.FloatField(required=True,  label="tax rate")


error_messages  = {
   'required': _('fields are required.'),
   }

def clean_title(self):
   return self.cleaned_data['tax_name']

def clean(self):
   tax_name = self.cleaned_data.get('tax_name')
   tax_rate = self.cleaned_data.get('tax_rate')

if not tax_name and not tax_rate:
   raise forms.ValidationError(
   self.error_messages['required'],
   code='required',
   )
   return self.cleaned_data

**view.py**
class AddTaxView(LoginRequiredMixin, CreateView):
   template_name = 'invoices/add_tax.html'
   form_class = UserTaxesMultiForm
   success_url = '/add/tax/'

   *{WHAT IS THE CODE HERE FOR THE POST METHOD TO SAVE DATA ACORDING 
DIFFRENT FORM SUBMIT} *




**HTML**




{% form.user_tax_form%}





{% form.user_discount_form%}





{% form.user_shiping_form%}




PLEASE 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 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/45a017a3-9633-426f-81e1-b261189e714a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to support to connect GreenPlum with the 'django.db.backends.postgresql_psycopg2' ?

2018-09-07 Thread Vincent Pemberton
Hi Ruping,

I realise you posted this over two years ago but my company is trying to 
integrate Django with Greenplum for a small project. I more or less believe 
it isn't possible without changing Django's own code (which we strictly do 
not want to do) so I'm wondering if you ever got it to work, and if so, 
could you please summarise how?

Sorry I cannot be of any help (two years down the line).

Regards,
Vinny

On Sunday, 8 May 2016 11:57:41 UTC+1, Ruping Wang wrote:
>
> Hello,
>
> I got an error when I tried to utilize 
> the 'django.db.backends.postgresql_psycopg2' to connect Greenplum.Given,The 
> Greenplum is based on PostgreSQL to develop and Djando's backend support to 
> connect PostgreSQL,so I guess it should be support Greenplum to 
> connect.After I modified the database configuration and executed the 
> command like 
>  python manage.py syncdb --noinput
> I got an error as following: 
> $ python manage.py syncdb --noinput
> Syncing...
> Creating tables ...
> Creating table auth_permission
> Traceback (most recent call last):
>   File "manage.py", line 11, in 
> execute_from_command_line(sys.argv)
>   File 
> "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 
> 443, in execute_from_command_line
> utility.execute()
>   File 
> "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 
> 382, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/usr/lib/python2.7/site-packages/django/core/management/base.py", 
> line 196, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File "/usr/lib/python2.7/site-packages/django/core/management/base.py", 
> line 232, in execute
> output = self.handle(*args, **options)
>   File "/usr/lib/python2.7/site-packages/django/core/management/base.py", 
> line 371, in handle
> return self.handle_noargs(**options)
>   File 
> "/usr/lib/python2.7/site-packages/south/management/commands/syncdb.py", 
> line 90, in handle_noargs
> syncdb.Command().execute(**options)
>   File "/usr/lib/python2.7/site-packages/django/core/management/base.py", 
> line 232, in execute
> output = self.handle(*args, **options)
>   File "/usr/lib/python2.7/site-packages/django/core/management/base.py", 
> line 371, in handle
> return self.handle_noargs(**options)
>   File 
> "/usr/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", 
> line 102, in handle_noargs
> cursor.execute(statement)
>   File "/usr/lib/python2.7/site-packages/django/db/backends/util.py", line 
> 40, in execute
> return self.cursor.execute(sql, params)
>   File 
> "/usr/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py",
>  
> line 52, in execute
> return self.cursor.execute(query, args)
> django.db.utils.DatabaseError: Greenplum Database does not allow having 
> both PRIMARY KEY and UNIQUE constraints
>
> I found it didn't work when I removed all UNIQUE constraints statements.So 
> I want to get some proposals what to modify to support greenplum!
> 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/45ab3703-59a7-44dd-95bc-b7c57d20feb0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Query is breking for no clear reason

2018-09-07 Thread Marcelo Juan Saciloto


HELLO, good morning!

 

I am not very familiarised with python, but I have been reading some 
documentations, so have been struggling with one problem, I hope  someone 
is able to help me.

 

So I have created a queryset to insert the locale clause in all queries in 
3 different models of my application and I had to inherit my query set, 
this models also extend other querysets


The queries is working fine, I have unit test they are woking as expected, 
except for one case where I have the follow exception:


[image: Screen Shot 2018-09-07 at 10.34.34.png]



I debug the query that is executed for this method and it looks all right:

 

[image: Screen Shot 2018-09-07 at 10.41.22.png]


 

It seems correct I had a doubt if it is necessary to insert single quotes 
in the *en-us*, so I tried to use in my code locale with* “ ‘ en-us ’ ”,* I 
saw that the first quotes are skipped so when I check the query it was not 
returning syntax error, but it makes the query do not filter the results 
the way it is expected. Then I revert it.

 

Anyone has seen the same issue ?


Best regards,

Marcelo Saciloto

-- 
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/d86fe953-60dd-4c25-ba4a-96c4bbb0cdfc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Nested Query with Aggregate.Sum()

2018-09-07 Thread mab . mobile . 01
Thank you Simon.

I will take a look at annotations. 

How would I represent seats remaining in the template for loop? Here is 
what I have so far.

#

{% for i in events %}

   
  {{ i.event_date|date:"l M j, Y" }} {{ 
i.event_time|date:"g:i A" }}
  {{i.event_type|title}} - 
{{i.title|title}}
  Purchase Reservation ${{i.price}} Seats 
Remaining ### VARIABLE HERE ###
   {{ i.description|safe}} 
   

   
   

   
   

   
   

{% endfor %}


#



On Thursday, September 6, 2018 at 8:04:36 AM UTC-5, Simon Charette wrote:
>
> Hello there,
>
> You should be able to achieve what you're after by using annotations[0].
>
> In your case you'll want to declare your Event and Reservation 
> relationship explicitly by using
> a ForeignKey
>
> class Event(models.Model):
> ...
> seating = models.PositiveIntegerField(default=0)
>
> class Reservation(models.Model):
> ...
> event = models.ForeignKey(Event, related_name='reservations')
> seats = models.PositiveIntegerField(default=0)
>
> And perform the following query
>
> Event.objects.annotate(
> seats_remaining=F('seating') - Sum('reservations__seats').
> )
>
> Cheers,
> Simon
>
> [0] 
> https://docs.djangoproject.com/en/2.1/topics/db/aggregation/#generating-aggregates-for-each-item-in-a-queryset
>
> Le jeudi 6 septembre 2018 07:42:36 UTC-4, mab.mo...@gmail.com a écrit :
>>
>>
>> QUESTION
>>
>> I have an application that will make on-line reservations for a series of 
>> weekly events. I would like to display the list of upcoming events in an 
>> html template with the number of remaining seats available in a single html 
>> page. I was able to create views to display the list of upcoming events and 
>> another view to display the number of remaining seats available but I am 
>> unable to figure out how to nest the two into a single view. Example 
>> below...
>>
>> HTML OUTPUT
>>
>> Event Title Week 1 - x amount of seats remaining for this event
>>
>> Event Title Week 2 - x amount of seats remainign for this event
>>
>> Event Title Week 3 - x amount of seats remaining for this event
>>
>> and so on 
>>
>> MODELS
>>
>> class Events(models.Model):
>>event_date = models.DateField(auto_now_add=False)
>>event_time = models.TimeField(auto_now_add=False)
>>event_type = models.CharField(max_length=20, choices=EVENT_TYPE)
>>seating = models.IntegerField(default=0)
>>title = models.CharField(max_length=200)
>>description = models.TextField()
>>menu = models.TextField()
>>price = models.DecimalField(max_digits=6, decimal_places=2)
>>publish = models.CharField(max_length=1, choices=PUBLISH_CHOICE)
>>
>>def __int__(self):
>>   return self.title
>>
>> class Reservations(models.Model):
>>user_id = models.IntegerField(default=0)
>>event_id = models.IntegerField(default=0)
>>reservations = models.IntegerField(default=0)
>>
>>def __int__(self):
>>   return self.event
>>
>>
>> VIEWS
>>
>> def events_view(request):
>> 
>> events=Events.objects.filter(publish='Y').filter(event_date__gte=datetime.now()).order_by('event_date')
>>  
>> reservation_count = Reservations.objects.aggregate(Sum('reservations'))
>>  
>> return render(request, 'restaurant/events.html',{"events":events, 
>> "reservation_count":reservation_count, })
>>
>> def make_reservation_view(request, pk):
>>event = Events.objects.get(id=pk)
>>seating_available = Events.objects.get(id=pk)
>>seating_available = seating_available.seating
>>reservation_count = 
>> Reservations.objects.filter(event_id=pk).aggregate(res_sum=Sum('reservations'))
>>res = reservation_count['res_sum']
>>seats_remaining = seating_available - res
>>
>>return render(request, 'restaurant/make_reservation.html', 
>> {"event":event, \
>>   
>>  "seats_remaining":seats_remaining,})
>>
>>
>>

-- 
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/ffc7caf1-1d6b-4d3e-8cd9-8c458367d499%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Subgroups Implementation (from LDAP)

2018-09-07 Thread Benjamin SOULAS
Well indeed, flattening the ldap groups hierarchy could be a solution, but 
I don't know if my boss will be OK with that, we are still thinking about 
implementation and explore the techno we need to implement our features.

But I think I will keep it in mind seriously, because it could resolve the 
ldap groups + subgroups link. Anyway, I think I cannot solve the link 
between my LDAP groups and app groups (which name conventions are obviously 
different) better than create a django "Link" (I have to find a goup name) 
model.

For now, just on the beginning, I implemented functions (in views, should 
find an other way ...) that creates my groups, I don't know (yet) how, when 
your server starts, I can already populate my app Groups without any django 
admin user intervention, I think it can be easily implemented, just have to 
take a look, because doing this in view with a GET or POST request, its 
good enough to see the result in /admin page, but, be honest, so dirty ...

Any way, for now I found a way for my groups retrieval, now, next steps: 
introduce my own groups with their own permissions, implement the Links 
table, find a way to create links between LDAP groups and my app group 
(maybe in /admin, in registering the Link model in admin.py) and then, 
check scenario thought about can be done.

To be honest, you helped me with the flattened representation of the 
groups, thanks a lot for that, now, I think I will follow your advices for 
creating new subjects, I did in django-auth-ldap google groups, but nobody 
answers, this is why I came here ..

Thanks a lot (*Merci beaucoup*!

Kind regards

Le vendredi 7 septembre 2018 09:48:16 UTC+2, Mike Dewhirst a écrit :
>
> On 7/09/2018 4:38 PM, Benjamin SOULAS wrote: 
> > Actually, I don't use ldap groups permission really, 
>
> I'm jumping to conclusions here with inadequate evidence. But I'll go 
> ahead anyway. It makes sense to me that your app being different than 
> the ldap system will have no use for ldap permissions. 
>
> So let me presume that the ldap group names mean something to you. For 
> example I'm guessing ldap group "chief_exec" might translate in your app 
> to "chief_exec". 
>
> I'm also guessing from your subject line that there are ldap groups 
> subordinate to "chief_exec". Perhaps for example "budgeting" or "awards" 
> but which are both ldap sub-groups of "chief_exec" 
>
> To flatten them out you might adopt a naming convention of "chief_exec", 
> "chief_exec_budgeting" and "chief_exec_awards" 
>
> My only interest in this thread really was to suggest such a flattening 
> of the corporate ldap hierarchy into simple Django auth-groups as being 
> a possible solution to the problem as I (mis)understood at the time. 
>
> I don't have sufficient experience with Django-ldap to help with the 
> technicalities. 
>
> I hope I haven't spoiled your flow. Lots of very helpful people on this 
> list will ignore this thread simply because there is already a 
> conversation happening. I suggest you start a new thread with a subject 
> line somewhat different but which really encapsulates the nub of your 
> problem. 
>
> Bon chance! 
>
> Cheers 
>
> Mike 
>
> > I have just configured my settings in which AUTH_LDAP_GROUP_SEARCH 
> > looks for a posixGroup Type (it is what I use for now, but in the 
> > future, it would be logical there will have GroupOfName and other 
> types). 
> > 
> > My aim is to use django-auth-ldap only as authentication, because we 
> > won't be able to know which groups will be implemented and which 
> > Django group will be applied to the LDAP group. I tried to check in 
> > django-auth-ldap source code how groups are handled/retrieved, it 
> > seems relly complicated (I don't know How should I implement the 
> > LDAPBackend and use/override the related method in order to use the 
> > LDAP admin to retrieve all the groups and populate them into the 
> > Django ORM) 
> > 
> > For now, the solution I got is to directly use python-ldap library to 
> > execute a search request in wich I specify the node I want to look at 
> > to retrieve them recursively, and finally, I succeed in populate them) 
> > 
> > For the links between Django groups and LDAP groups, I have no choice 
> > to do this, so I thought I should have to implement a django model 
> > (which aim, like other models, is to store stuff in ORM) which could 
> > have a OneToManyField in order to link several LDAP groups to my 
> > Django groups predefined in my app 
> > 
> > When you say "If you have ldap subgroups I would flatten them into the 
> > smallest denominator and make equivalent auth-groups." I am not sure 
> > to understand what it really means and how to implement this, thanks 
> > to django-auth-ldap? Or as I already done with python-ldap?? 
> > 
> > I don't think I could chosse a naming convention if, in advance, it is 
> > not possible to me to know which groups will be retrieved, right? 
> > 
> > Le vendredi 7 septembre 2018 01:57:27 UTC+2, Mike 

Re: Subgroups Implementation (from LDAP)

2018-09-07 Thread Mike Dewhirst

On 7/09/2018 4:38 PM, Benjamin SOULAS wrote:

Actually, I don't use ldap groups permission really,


I'm jumping to conclusions here with inadequate evidence. But I'll go 
ahead anyway. It makes sense to me that your app being different than 
the ldap system will have no use for ldap permissions.


So let me presume that the ldap group names mean something to you. For 
example I'm guessing ldap group "chief_exec" might translate in your app 
to "chief_exec".


I'm also guessing from your subject line that there are ldap groups 
subordinate to "chief_exec". Perhaps for example "budgeting" or "awards" 
but which are both ldap sub-groups of "chief_exec"


To flatten them out you might adopt a naming convention of "chief_exec", 
"chief_exec_budgeting" and "chief_exec_awards"


My only interest in this thread really was to suggest such a flattening 
of the corporate ldap hierarchy into simple Django auth-groups as being 
a possible solution to the problem as I (mis)understood at the time.


I don't have sufficient experience with Django-ldap to help with the 
technicalities.


I hope I haven't spoiled your flow. Lots of very helpful people on this 
list will ignore this thread simply because there is already a 
conversation happening. I suggest you start a new thread with a subject 
line somewhat different but which really encapsulates the nub of your 
problem.


Bon chance!

Cheers

Mike

I have just configured my settings in which AUTH_LDAP_GROUP_SEARCH 
looks for a posixGroup Type (it is what I use for now, but in the 
future, it would be logical there will have GroupOfName and other types).


My aim is to use django-auth-ldap only as authentication, because we 
won't be able to know which groups will be implemented and which 
Django group will be applied to the LDAP group. I tried to check in 
django-auth-ldap source code how groups are handled/retrieved, it 
seems relly complicated (I don't know How should I implement the 
LDAPBackend and use/override the related method in order to use the 
LDAP admin to retrieve all the groups and populate them into the 
Django ORM)


For now, the solution I got is to directly use python-ldap library to 
execute a search request in wich I specify the node I want to look at 
to retrieve them recursively, and finally, I succeed in populate them)


For the links between Django groups and LDAP groups, I have no choice 
to do this, so I thought I should have to implement a django model 
(which aim, like other models, is to store stuff in ORM) which could 
have a OneToManyField in order to link several LDAP groups to my 
Django groups predefined in my app


When you say "If you have ldap subgroups I would flatten them into the 
smallest denominator and make equivalent auth-groups." I am not sure 
to understand what it really means and how to implement this, thanks 
to django-auth-ldap? Or as I already done with python-ldap??


I don't think I could chosse a naming convention if, in advance, it is 
not possible to me to know which groups will be retrieved, right?


Le vendredi 7 septembre 2018 01:57:27 UTC+2, Mike Dewhirst a écrit :

On 7/09/2018 12:49 AM, Benjamin SOULAS wrote:
> Hi Mike !
>
> The problem is our app have to be able to retrieve a Customer LDAP
> server. So we won't be able to know groups will be into the LDAP
server.
>
> To be concise, when we'll set up the app, we'll have to retrieve
the
> LDAP groups, insert them in django ORM, then make the link (with a
> table, so a model) between LDAP groups extracted and our App groups

Are you using django-auth with auth-groups and
auth-group-permissions?

If it was me, I'd set up all the ldap groups as Django auth-groups
and
preset their permissions. Then all the login backend has to do is
check
that a user's ldap groups haven't changed. If they have changed
then I
would have to adjust the auth-groups accordingly.

If you have ldap subgroups I would flatten them into the smallest
denominator and make equivalent auth-groups.

If you choose a strategic naming convention you could work it out
on the
fly without needing a mapping table between ldap groups/sub-groups
and
Django auth-groups.


>
> The App permissions will follow the same principle, stored in the
> Django ORM (which is the regular case) and thanks to the app
> (something django admin-like) we will link the permissions to
the App
> groups
>
> I don't know how clear I am ...
>
> Kind regards
>
> Benjamin
>
> Le mercredi 5 septembre 2018 23:51:49 UTC+2, Mike Dewhirst a
écrit :
>
>     On 5/09/2018 11:25 PM, Benjamin SOULAS wrote:
>     > Hi everyone,
>     >
>     > I m not expert at all in Django so it can be a silly
question but I
>     > take the risk:
>
>     I'm an expert in nothing!
>
>     What about simplifying things by making your groups have
  

Re: Contributing to Django

2018-09-07 Thread Michal Petrucha
On Fri, Sep 07, 2018 at 11:36:27AM +0530, Sanjeev Singh wrote:
> Thank you for replying me back Sir, It will be great help for me if you can
> provide me some links where I should go for that, how I can jump into this.
> Thank you.

Hi Sanjeev,

Really cool that you want to get involved! I'd suggest that a good
place to start would be
https://docs.djangoproject.com/en/2.1/internals/contributing/

Cheers,

Michal

-- 
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/20180907065646.GW1181%40konk.org.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


Re: Subgroups Implementation (from LDAP)

2018-09-07 Thread Benjamin SOULAS
Actually, I don't use ldap groups permission really, I have just configured 
my settings in which AUTH_LDAP_GROUP_SEARCH looks for a posixGroup Type (it 
is what I use for now, but in the future, it would be logical there will 
have GroupOfName and other types).

My aim is to use django-auth-ldap only as authentication, because we won't 
be able to know which groups will be implemented and which Django group 
will be applied to the LDAP group. I tried to check in django-auth-ldap 
source code how groups are handled/retrieved, it seems relly complicated (I 
don't know How should I implement the LDAPBackend and use/override the 
related method in order to use the LDAP admin to retrieve all the groups 
and populate them into the Django ORM)

For now, the solution I got is to directly use python-ldap library to 
execute a search request in wich I specify the node I want to look at to 
retrieve them recursively, and finally, I succeed in populate them)

For the links between Django groups and LDAP groups, I have no choice to do 
this, so I thought I should have to implement a django model (which aim, 
like other models, is to store stuff in ORM) which could have a 
OneToManyField in order to link several LDAP groups to my Django groups 
predefined in my app

When you say "If you have ldap subgroups I would flatten them into the 
smallest denominator and make equivalent auth-groups." I am not sure to 
understand what it really means and how to implement this, thanks to 
django-auth-ldap? Or as I already done with python-ldap??

I don't think I could chosse a naming convention if, in advance, it is not 
possible to me to know which groups will be retrieved, right?

Le vendredi 7 septembre 2018 01:57:27 UTC+2, Mike Dewhirst a écrit :
>
> On 7/09/2018 12:49 AM, Benjamin SOULAS wrote: 
> > Hi Mike ! 
> > 
> > The problem is our app have to be able to retrieve a Customer LDAP 
> > server. So we won't be able to know groups will be into the LDAP server. 
> > 
> > To be concise, when we'll set up the app, we'll have to retrieve the 
> > LDAP groups, insert them in django ORM, then make the link (with a 
> > table, so a model) between LDAP groups extracted and our App groups 
>
> Are you using django-auth with auth-groups and auth-group-permissions? 
>
> If it was me, I'd set up all the ldap groups as Django auth-groups and 
> preset their permissions. Then all the login backend has to do is check 
> that a user's ldap groups haven't changed. If they have changed then I 
> would have to adjust the auth-groups accordingly. 
>
> If you have ldap subgroups I would flatten them into the smallest 
> denominator and make equivalent auth-groups. 
>
> If you choose a strategic naming convention you could work it out on the 
> fly without needing a mapping table between ldap groups/sub-groups and 
> Django auth-groups. 
>
>
> > 
> > The App permissions will follow the same principle, stored in the 
> > Django ORM (which is the regular case) and thanks to the app 
> > (something django admin-like) we will link the permissions to the App 
> > groups 
> > 
> > I don't know how clear I am ... 
> > 
> > Kind regards 
> > 
> > Benjamin 
> > 
> > Le mercredi 5 septembre 2018 23:51:49 UTC+2, Mike Dewhirst a écrit : 
> > 
> > On 5/09/2018 11:25 PM, Benjamin SOULAS wrote: 
> > > Hi everyone, 
> > > 
> > > I m not expert at all in Django so it can be a silly question but 
> I 
> > > take the risk: 
> > 
> > I'm an expert in nothing! 
> > 
> > What about simplifying things by making your groups have smaller 
> > sets of 
> > permisssions and putting users into multiple groups to suit their 
> > roles. 
> > 
> > 
> > > 
> > > I have to implement *LDAP server* (which work perfectly with 
> > > *django-auth-ldap*, but my question is not related to this 
> > library). I 
> > > was wondering what happens if groups possesses subgroups? Even 
> > if it 
> > > is not handled in the lib, I assume I can override a recursive 
> > > mechanism in order to populate the subgroup in the *auth_group* 
> > table. 
> > > 
> > > BUT my problem is "*How can link subgroups to parent groups*" ? 
> > > Because through */admin* page, If you create a group, you can only 
> > > define its permission and nothing else (which make sens if the 
> > aim is 
> > > to have One level group handling), but if I want to implement 
> > > subgroups, how do you suggest to do it? I found the module 
> > django MPTT 
> > > but does it corresponds to the need? Bur because I already use 
> > DRF + 
> > > Django + Django-auth-LDAP, does its implementation worth it? 
> > > 
> > > I though it was possible, thanks to *custom models* which could 
> > have 
> > > as fields *parent-group* and *subgroup* (and maybe more, still 
> > > thinking about it). Once the model is implemented, should I link 
> my 
> > > *overriden django-auth-ldap code* to map 

Re: Contributing to Django

2018-09-07 Thread Sanjeev Singh
Thank you for replying me back Sir, It will be great help for me if you can
provide me some links where I should go for that, how I can jump into this.
Thank you.



On Fri, Sep 7, 2018 at 11:12 AM Andréas Kühne 
wrote:

> That's good if you think you have that experience. Contributing back is
> always good :-)
>
> However - if you want to discuss this, I think you should change to the
> developers mailing list instead. They can probably help you. Or just go and
> check the issues on the django project and see if you can help there?
>
> Regards,
>
> Andréas
>
>
> Den fre 7 sep. 2018 kl 07:24 skrev Sanjeev Singh <
> sanjeevsinghdevi...@gmail.com>:
>
>> Hello Sir,
>> I've already done some projects in django but now I want to contribute. I
>> want to start this by solving some easy bugs, If you suggest some.
>> Thank you.
>>
>> On Fri, Sep 7, 2018 at 10:37 AM Andréas Kühne 
>> wrote:
>>
>>> Hi,
>>>
>>> I think you really should get some experience with writing applications
>>> in django before you start contributing to the project itself. The django
>>> project is rather complex and it takes a while to understand the concepts
>>> behind it. I have been working with django for 5 years now and haven't
>>> found anything that I would feel comfortable with changing in the project
>>> itself yet.
>>>
>>> Regards,
>>>
>>> Andréas
>>>
>>>
>>> Den fre 7 sep. 2018 kl 04:35 skrev Sanjeev Singh <
>>> sanjeevsinghdevi...@gmail.com>:
>>>
 Hello,

 I’m a beginner want to contribute please help me in
 solving some easy bugs so that I can get started.



 Thank you.



 Sent from Mail  for
 Windows 10



 --
 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/5b91518c.1c69fb81.6db14.affc%40mx.google.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/CAK4qSCeYBZOP9axZF10YnjJtChNT_oQyu1jAtw4KhTM66sS6mw%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/CA%2Btz_ABAiGGubYQyLJeu5bJbADi%3D9QZ4Zj2Tf%2BQy22eyk5NLLQ%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/CAK4qSCdosQ6DuVuLk4sXYdEk9fCGNWppts1pptnhTpDrQ0nndQ%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