Re: help with my signup api

2020-05-13 Thread Vijay Khemlani
in your code data is json.dumps(request.data), which is a string
representation of the json dictionary

so data is a str and then you are trying to do item assignment to it

On Wed, May 13, 2020 at 8:05 AM ola neat  wrote:

> good day guys, please i need help with my signup api, when the user click
> signup i get this err msg "TypeError: 'str' object does not support item
> assignment", in my CLI, which as a result display err msg to the user, but
> eventually the user get created. i got the code and err msg attached below
> thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHLKn72ZwUjSgHCDxLdu4C6wcg_zv8N%2Brx4EnmFySmcyLHPG7w%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALn3ei2HL%3DHZU5P1J7gYZnAW6iDiTv4-kTX1%2BP-GNpGWXDv11g%40mail.gmail.com.


Re: error in models

2019-08-05 Thread Vijay Khemlani
Remove the quotes

On Mon, Aug 5, 2019 at 11:24 AM Mudasir Mian 
wrote:

> Dear Team,
> im facing this error in models
> help me please
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAPoXitiJ5ofvswBE7Zjz72RGNoUunHmgoEi5PEOMsCC5-xHNRA%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALn3ei29j9mYgF1OzcPpUtpKnSJPBEX50QG_zfMBTXfFFT-bGg%40mail.gmail.com.


Re: Redireccionamiento

2019-07-10 Thread Vijay Khemlani
No hay ningun JavaScript interceptando los links en tu pagina?

On Tue, Jul 9, 2019 at 10:23 PM samuel lopez  wrote:

> Tengo un problema con los links y es que todo está bien internamente osea
> los tags, urls, views y todo, pero cuando le doy click al botón o al enlace
> del nav o cualquier otro, no me redirecciona pero si le doy a abrir en otra
> ventana, me redirecciona correctamente y en el navegador de Chrome cuando
> pongo el puntero por encima del link se visualiza la dirección del enlace
> pero no redirecciona en la misma página, repito en una página externa a
> esta , redirecciona correctamente. Alguien me podría ayudar con este
> problemita. (No tengo ningún opcion del Tag a osea link activa, todo normal)
>
> --
> 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/CAOt0vAztS4z4-XdStoQ6WJ5LSoe2UP7MM0RFRVp0aPiJjM3KzA%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/CALn3ei0qwdyPYFbHVLVsOEcdY%2Bb7vXAh7R4K9ab%3DKQg_a1ST9w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Existing database for users to use django user auths

2019-06-05 Thread Vijay Khemlani
Yes, you can write your own Authentication Backend with your custom
authentication logic

https://docs.djangoproject.com/en/2.2/topics/auth/customizing/

On Wed, Jun 5, 2019 at 8:53 AM michael ababao 
wrote:

> I am new to django and i would like to know if it is possible to use the
> django user authentication using a different database for users?
>
> --
> 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/688efd6f-8768-44e0-b9aa-79e6b508bfb4%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/CALn3ei0MiUifhW3NFU8rosK-agS8NjMO3otm%2BUki1g2--WCyEA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: File not getting uploaded

2019-04-17 Thread Vijay Khemlani
When he said "uploading it from there" I was not sure whether "there" meant
Django's admin page or the same view that's failing now

As far as I know the form has to have a multipart enctype to upload files

On Wed, Apr 17, 2019 at 9:53 AM Ram sundar  wrote:

> Hi Vijay,
>
> You are right, but he has mentioned that it gets uploaded when logged in
> as admin. Will it be a different template for the same view? Just
> wondering...
>
> @Aakaash: can you please check in both cases and confirm please
>
> Regards,
> Ramsundar
>
>
> On Wed 17 Apr, 2019, 6:18 PM Vijay Khemlani,  wrote:
>
>> In your HTML, the form tag should have an enctype
>>
>> 
>> ...
>> 
>>
>> On Wed, Apr 17, 2019 at 2:36 AM Aakash Baranwal 
>> wrote:
>>
>>> Sorry, the image file wasnt uploaded.
>>>
>>>
>>>
>>> On Wed, Apr 17, 2019 at 12:04 PM Aakash Baranwal 
>>> wrote:
>>>
>>>> Hi Everybody,
>>>>
>>>> I am trying to upload a file, but it says "No file chosen", even when I
>>>> have selected the file. However it is getting uploaded when I have logged
>>>> in as as admin and i am uploading it from there.
>>>>
>>>> Kindly help me, thanks in advance.
>>>>
>>>> views.py file:
>>>>
>>>> class VideoCreateView(CreateView):
>>>> form_class = VideoModelForm
>>>> fields = ['Video_Description','videofile']
>>>> template_name = 'deploy/create_view.html'
>>>>
>>>> success_url = "/video/create/"
>>>>
>>>> def form_valid(self, form):
>>>> form.instance.user = self.request.videofile
>>>> return super(VideoCreateView, self).form_valid(form)
>>>>
>>>>
>>>> models.py file:
>>>>
>>>> class Video(models.Model):
>>>> Video_Description= models.CharField(max_length=500)
>>>> videofile= models.FileField(upload_to='videos/', null=True,
>>>> verbose_name="")
>>>> timestamp   = models.DateTimeField(auto_now_add=True)
>>>>
>>>> class Meta:
>>>> ordering = ['-timestamp']
>>>>
>>>>
>>>> def __str__(self):
>>>> return self.Video_Description + ": " + str(self.id)
>>>>
>>>>
>>>> urls.py file:
>>>>
>>>>
>>>> url(r'^create/$', VideoCreateView.as_view(), name='create')
>>>>
>>>>
>>>> create_view.html :
>>>>
>>>> 
>>>> {% csrf_token %}
>>>> {{ form.as_p }}
>>>> 
>>>> 
>>>>
>>>> PFA the image file displaying the page after i selected the file and
>>>> hit the Upload Video button
>>>>
>>>> With Kind Regards
>>>>
>>>> Aakash Baranwal
>>>>
>>> --
>>> 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/CALr9hQ2eq0np-THVoQOBJ6ux3fqw%2BzA1DM4DBHshTP5dMNat2g%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CALr9hQ2eq0np-THVoQOBJ6ux3fqw%2BzA1DM4DBHshTP5dMNat2g%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CALn3ei1ZicOfYs2Xe1CuEuHgxhQVFLv3BDhcEa5VWoa%2BC7JQzw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CALn3ei1ZicOfYs2Xe1CuEuHgxhQVFLv3BDhcEa5VWoa%2BC7JQzw%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit

Re: File not getting uploaded

2019-04-17 Thread Vijay Khemlani
In your HTML, the form tag should have an enctype


...


On Wed, Apr 17, 2019 at 2:36 AM Aakash Baranwal 
wrote:

> Sorry, the image file wasnt uploaded.
>
>
>
> On Wed, Apr 17, 2019 at 12:04 PM Aakash Baranwal 
> wrote:
>
>> Hi Everybody,
>>
>> I am trying to upload a file, but it says "No file chosen", even when I
>> have selected the file. However it is getting uploaded when I have logged
>> in as as admin and i am uploading it from there.
>>
>> Kindly help me, thanks in advance.
>>
>> views.py file:
>>
>> class VideoCreateView(CreateView):
>> form_class = VideoModelForm
>> fields = ['Video_Description','videofile']
>> template_name = 'deploy/create_view.html'
>>
>> success_url = "/video/create/"
>>
>> def form_valid(self, form):
>> form.instance.user = self.request.videofile
>> return super(VideoCreateView, self).form_valid(form)
>>
>>
>> models.py file:
>>
>> class Video(models.Model):
>> Video_Description= models.CharField(max_length=500)
>> videofile= models.FileField(upload_to='videos/', null=True,
>> verbose_name="")
>> timestamp   = models.DateTimeField(auto_now_add=True)
>>
>> class Meta:
>> ordering = ['-timestamp']
>>
>>
>> def __str__(self):
>> return self.Video_Description + ": " + str(self.id)
>>
>>
>> urls.py file:
>>
>>
>> url(r'^create/$', VideoCreateView.as_view(), name='create')
>>
>>
>> create_view.html :
>>
>> 
>> {% csrf_token %}
>> {{ form.as_p }}
>> 
>> 
>>
>> PFA the image file displaying the page after i selected the file and hit
>> the Upload Video button
>>
>> With Kind Regards
>>
>> Aakash Baranwal
>>
> --
> 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/CALr9hQ2eq0np-THVoQOBJ6ux3fqw%2BzA1DM4DBHshTP5dMNat2g%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/CALn3ei1ZicOfYs2Xe1CuEuHgxhQVFLv3BDhcEa5VWoa%2BC7JQzw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Guardar many to many Django

2019-04-13 Thread Vijay Khemlani
Esta línea

Articulo_Consolidacion.objects.create(articulo=articulo_data,tagicNone,
tono=array_tono, tema__id=None)

No tiene mucho sentido (que es tagicNone?, de donde sale arrary_tono? no
estas usando tag_list ni tema_list...)

Ademas en tu modelo el campo "articulo" de "ArticuloConsolidacion" es un
ManyToManyField pero le estas asignando una instancia especifica en tu
llamado a create ("articulo=articulo_data")

Lo único que te puedo decir es que primero crees y guardes la instancia de
ArticuloConsolidacion SIN setear los campos ManyToMany, y despues de eso
llamar al metodo set de sus campos manytomany para setear esos campos
despues

Saludos

On Fri, Apr 12, 2019 at 7:23 PM  wrote:

> Hola, tengo una duda acerca de como guardar many to many en Django ,
> agradecería mucho sus ayudas
>
>
>
> En la tabla de artículos cargo los datos, luego quiero asociarlos con la
> tabla temas, pero cuando hago el save me sale este error
>
>
> Guardo primero todos los articulos.
>
>
> *TypeError: Direct assignment to the forward side of a many-to-many set is
> prohibited. Use articulo.set() instead.*
>
>
> Busque el error y ya instacio el id del articulo que guarde, pero me sigue
> saliendo el mismo error:
>
>  de esta manero lo guardo
>
>
>
>
>  articulo_data = Articulo.objects.get(id=dato) #instancia de articulo
>
>
> #TAGS
>
> taglist =  []
>
> for tag in tags:
>
> tags = Tag.objects.get(id=tag)
>
> taglist.append(tags)
>
> print(taglist)
>
>
> #TEMAS
>
> temalist =  []
>
> for topic in topics_array:
>
> tema = Tema.objects.get(nombre=topic)
>
> temalist.append(tema)
>
> print(temalist)
>
>
> save =
> Articulo_Consolidacion.objects.create(articulo=articulo_data,tagicNone,
> tono=array_tono, tema__id=None)
>
>
>
>
>
> Estos son mis modelos
>
> --
>
> class Articulo(models.Model):
>
> titulo = models.CharField(max_length=255, blank=True)
>
> texto = models.TextField()
>
> url = models.CharField(max_length=255)
>
> fuente = models.ForeignKey(Fuente, on_delete=models.CASCADE)
>
> fecha = models.DateTimeField(null=True)
>
> created_at = models.DateTimeField(auto_now_add=True, auto_now=False,
> verbose_name=u'Fecha de creación')
>
> ubicacion = models.CharField(max_length=255)
>
> tipo_facebook = models.CharField(max_length=255)
>
> id_articulo_facebook = models.CharField(max_length=255,blank=True,
> null=True)
>
> proyecto = models.ManyToManyField('Proyecto')
>
> finished = models.BooleanField(verbose_name=u'Finalizado',
> default=False)
>
> asignado = models.BooleanField(verbose_name=u'Asignado', default=False)
>
> state = models.BooleanField(verbose_name=u'Para borrar', default=False)
>
> recategorisation = models.BooleanField(verbose_name=u'Recategorizar',
> default=False)
>
> history = HistoricalRecords()
>
> --
>
>
> class Articulo_Consolidacion(models.Model):
>
> state = models.BooleanField(verbose_name=u'Prueba', default=False)
>
> articulo = models.ManyToManyField('Articulo')
>
> tag = models.ManyToManyField('tag')
>
> tema = models.ManyToManyField('Tema')
>
> tono = models.ManyToManyField('Tono')
>
> narrativa = models.ManyToManyField('Narrativa')
>
> nivelpromocion = models.ManyToManyField('NivelPromocion')
>
> posicion = models.ManyToManyField('Posicion')
>
> brand_love = models.ManyToManyField('BrandLove')
>
> promocion = models.ManyToManyField('Promocion')
>
> created_at = models.DateTimeField(auto_now_add=True)
>
> updated_at = models.DateTimeField(auto_now=True)
>
> history = HistoricalRecords()
>
> id_comentario = models.CharField(max_length=255,null=True)
> --
> class Tema(models.Model):
> nombre = models.CharField(max_length=255)
> history = HistoricalRecords()
> -
>
>
>
>
>
> [image: Captura de pantalla de 2019-04-12 18-07-56.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/743469b3-1fbf-4002-8d9e-4dd01e37e948%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 

Re: How to resole Integrity Error caused by NOT NULL

2019-03-09 Thread Vijay Khemlani
Your assign should be

new_material_review.material = material_instance

instead of

new_material_review.material_instance = material_instance

that you have now

On Sat, Mar 9, 2019 at 4:29 AM Chukwunonso Nwankpa 
wrote:

> Good Morning.
> I'm new to django and currently using the framework for a pet project.
>
> I am currently trying to implement a review system.
> Whereby a user can see reviews on an item and also leave a review on
> the item.
>
> When I try posting a review from the user end it returns the error seen on
> the screenshot
> From the admin area, I can add reviews without errors popping up.
>
> Please, I need help in resolving it.
> Any help would be much appreciated.
> Thanks in anticipation
>
> --
> 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/80453449-006b-479b-9439-e6f7a5ec30dc%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/CALn3ei0%2B82W8qmJ-TemTEJzwbjyowfn3REZ%2Bv1qm4jzJDJWt0w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: "Project object has no attribute review_set"

2018-10-12 Thread Vijay Khemlani
Since the related name in the project foreign key is "review" you have to
use that keyword for the related query from project, so it should be
"self.review.all()" instead of "self.review_set.all()" in your Project
methods.

Regards!

On Fri, Oct 12, 2018 at 9:25 AM Melissa Malala 
wrote:

> Getting an error that says "Project object has no attribute review_set"
> when trying to get the mean of ratings using Numpy. HTML looks something
> like this, what could be the problem? Please have a look below and let us
> know what you think:
>
>
> {{ project.review.count }} reviews ({{
> project.average_design | floatformat }} average rating of design){{ 
> project.review.count }} reviews ({{
> project.average_content | floatformat }} average rating of 
> content){{ project.review.count }} reviews ({{ 
> project.average_usability | floatformat }} average rating of 
> usability)class Project(models.Model):
> title = models.TextField(max_length=200, null=True, blank=True, 
> default="title")
> project_image = models.ImageField(upload_to='picture/', null=True, blank=True)
> description = models.TextField()
> project_url=models.URLField(max_length=250)def average_design(self):
> design_ratings = list(map(lambda x: x.design_rating, 
> self.review_set.all()))
> return np.mean(design_ratings)
> def average_usability(self):
> usability_ratings = list(map(lambda x: x.usability_rating, 
> self.review_set.all()))
> return np.mean(usability_ratings)
> def average_content(self):
> content_ratings = list(map(lambda x: x.content_rating, 
> self.review_set.all()))
> return np.mean(content_ratings)
>
> class Review(models.Model):
> RATING_CHOICES = (
> (1, '1'),
> (2, '2'),
> (3, '3'),
> (4, '4'),
> (5, '5'),
> (6, '6'),
> (7, '7'),
> (8, '8'),
> (9, '9'),
> (10, '10'),
> )
> project = models.ForeignKey(Project, null=True, blank=True, 
> on_delete=models.CASCADE, related_name="review")
> user = models.ForeignKey(User, null=True, blank=True, 
> on_delete=models.CASCADE, related_name='user')
> image = models.ForeignKey(Image, on_delete=models.CASCADE, 
> related_name="project", null=True, blank=True)
> comment = models.TextField()
> design_rating = models.IntegerField(choices=RATING_CHOICES,
>
>

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


Re: A questionale developer had added exraneous code to image URLS that used to work. I would be gratefuldor your assitamce please?

2018-09-09 Thread Vijay Khemlani
If you're using django-storages with S3 as the media backend then there is
a setting called AWS_S3_FILE_OVERWRITE that prevents files with the same
name form being uploaded. In those cases the library appends a suffix
similar to your example.

Usually this is useful to prevent files from being overwritten (for example
if you upload photos for different products with the same filename you
don't want one to overwrite the other)

On Sun, Sep 9, 2018 at 8:06 PM mottaz hejaze  wrote:

> please share code ..
>
> Is this image from admin panel or from website front ..
>
> please share models.py , admin.py , views.py and forms.py
>
>
>
>
> On Mon, Sep 10, 2018 at 12:47 AM KarmaFish  wrote:
>
>> Hello we  had no issues uploaded images to our servers pointing toa n
>> image name.
>> But this Dev came in and changed the code.
>> Whenever we upload a new image for a product, after save , we'd go back
>> to find that the image name had an automatically generated code added to
>> the jpg filename making the image blank.
>>
>> Where can I fix that please? Remove that superfluous random numbers
>> please?
>>
>> Thank you in advance,
>>
>> [image: random.jpg]
>>
>> --
>> 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/eb34f554-04c8-487a-a03b-020a48e0bd14%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/CAHV4E-d7jA49anFAPbsO1m%3D_HyeoFWeT6x%2BjiT_oAV-NHf6NRA%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/CALn3ei0F1pbhprFEZCoh%2B%2BnerYSB5PVKxZa1ffMrkk9zJs90kw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django performance issue that's troubling

2018-08-24 Thread Vijay Khemlani
Please reply to the user group

"But, in order to have the update work, it needs the ForeignKey to the
parent in the form"

As far as I know, it doesn't need to (if the entry already exists in the
database and you are just editing it), you just need to set up the fields
that you want to be editable by the user


On Fri, Aug 24, 2018 at 2:06 PM Jim Illback  wrote:

> Vijay, think of this is a parent - child relationship. I have 37K parents.
> Now I want to update a child of one of the parents. But, in order to have
> the update work, it needs the ForeignKey to the parent in the form.
> However, to add that key, Django must then allow it to update that field
> and thus has to fill in all 37K entries. Is there no way to tell Django
> that the FK relationship can not be changed? If I leave it off of the form,
> the update fails because it is a required field. If I add it to the form,
> Django has to allow all potential update values to be shown. What’s the way
> out of this mess?
>
> Thanks,
> Jim
>
>
> Begin forwarded message:
>
> *From: *Vijay Khemlani 
> *Subject: **Re: Django performance issue that's troubling*
> *Date: *August 24, 2018 at 5:07:07 AM PDT
> *To: *django-users@googlegroups.com
> *Reply-To: *django-users@googlegroups.com
>
> To tell you the truth I couldn't understand some parts of your message,
> but if your AddictionForm is a ModelForm then you should be able to limit
> its fields to just the ones you want your users to be able to update.
>
> https://docs.djangoproject.com/en/2.1/topics/forms/modelforms/
>
> Regards!
>
>
>
> On Thu, Aug 23, 2018 at 8:19 PM Jim Illback  wrote:
>
>> Vijay, you are exactly correct. Thank you much!
>>
>> Now, knowing the problem, I still don’t have a great solution. Here’s how
>> it is supposed to work.
>>
>> Someone chooses a client from the list or a search. All the possible
>> support records are shown, whether they exist or not, on a screen to
>> hyperlink to one of them. If the record exists, the URL includes the PK and
>> transfers to the UpdateView. This is similar for an AddView if the record
>> does not exist. However, in the Update or Add, I don’t want the primary key
>> changed. So, I hid the field (and thus all the records were read). However,
>> now I can’t limit that field to only one value. If I format the entire
>> SELECT tag with only one OPTION, Django gives an invalid expression for the
>> ID or Name because it is based on my query set I passed in that fills out
>> the values (ID and name). If I use the form’s field value, all the fields
>> are read. Especially on an Add, I don’t know a way to fill the client ID
>> field in such a way that Django will take it as valid.
>>
>> My thoughts on possible solutions:
>> 1. Override the get query set method to only pass in the single record -
>> will that work?
>> 2. I’ve been trying to show the field in a  tag and override the
>> View’s post method by aftering is_valid(), but it always returns invalid
>> expression errors.
>>
>> What am I missing?
>>
>> Thanks much again -
>> Jim
>>
>>
>> On Aug 23, 2018, at 3:48 PM, Vijay Khemlani  wrote:
>>
>> Maybe your update form has a field related to a model with thousands of
>> records? like rendering a select combo box with thousands of choices?
>>
>> On Thu, Aug 23, 2018 at 5:30 PM Jim Illback 
>> wrote:
>>
>>> I have a Django app in development that performed perfectly with about
>>> 20 client records. Each client could have one or more support records and
>>> there are 40 potential support records, connected to the client with a
>>> ForeignKey (client_id). Then, I loading about 37K client records. Search
>>> queries perform almost instantaneously. A paginated list of support records
>>> with 40 pages and 10 clients per page comes back in half a second. Great
>>> performance.
>>>
>>> However, when I click on any record in the list to go to update a
>>> specific support record for that specific client (it uses the PK in the URL
>>> so is a direct call to the UpdateView routine), I get about 10 second
>>> response times and these kind of statistics from Django-debug-toolbar:
>>> *SQL*: 5 queries, 20ms (so clearly not a DB related performance issue)
>>> *TIME*:  Resource usage:
>>> User CPU time 8827 msec
>>> System CPU time 137 msec
>>> Elapsed time 9003 msec
>>> Context switches 1 voluntary, 9639 involuntary
>>> Browser timing:
>>> domLoading 9026 (+52130) msec
>>>
>>> *CACHE*: 0 calls in 0.00ms (so clearly not 

Re: Django performance issue that's troubling

2018-08-24 Thread Vijay Khemlani
To tell you the truth I couldn't understand some parts of your message, but
if your AddictionForm is a ModelForm then you should be able to limit its
fields to just the ones you want your users to be able to update.

https://docs.djangoproject.com/en/2.1/topics/forms/modelforms/

Regards!



On Thu, Aug 23, 2018 at 8:19 PM Jim Illback  wrote:

> Vijay, you are exactly correct. Thank you much!
>
> Now, knowing the problem, I still don’t have a great solution. Here’s how
> it is supposed to work.
>
> Someone chooses a client from the list or a search. All the possible
> support records are shown, whether they exist or not, on a screen to
> hyperlink to one of them. If the record exists, the URL includes the PK and
> transfers to the UpdateView. This is similar for an AddView if the record
> does not exist. However, in the Update or Add, I don’t want the primary key
> changed. So, I hid the field (and thus all the records were read). However,
> now I can’t limit that field to only one value. If I format the entire
> SELECT tag with only one OPTION, Django gives an invalid expression for the
> ID or Name because it is based on my query set I passed in that fills out
> the values (ID and name). If I use the form’s field value, all the fields
> are read. Especially on an Add, I don’t know a way to fill the client ID
> field in such a way that Django will take it as valid.
>
> My thoughts on possible solutions:
> 1. Override the get query set method to only pass in the single record -
> will that work?
> 2. I’ve been trying to show the field in a  tag and override the View’s
> post method by aftering is_valid(), but it always returns invalid
> expression errors.
>
> What am I missing?
>
> Thanks much again -
> Jim
>
>
> On Aug 23, 2018, at 3:48 PM, Vijay Khemlani  wrote:
>
> Maybe your update form has a field related to a model with thousands of
> records? like rendering a select combo box with thousands of choices?
>
> On Thu, Aug 23, 2018 at 5:30 PM Jim Illback  wrote:
>
>> I have a Django app in development that performed perfectly with about 20
>> client records. Each client could have one or more support records and
>> there are 40 potential support records, connected to the client with a
>> ForeignKey (client_id). Then, I loading about 37K client records. Search
>> queries perform almost instantaneously. A paginated list of support records
>> with 40 pages and 10 clients per page comes back in half a second. Great
>> performance.
>>
>> However, when I click on any record in the list to go to update a
>> specific support record for that specific client (it uses the PK in the URL
>> so is a direct call to the UpdateView routine), I get about 10 second
>> response times and these kind of statistics from Django-debug-toolbar:
>> *SQL*: 5 queries, 20ms (so clearly not a DB related performance issue)
>> *TIME*:  Resource usage:
>> User CPU time 8827 msec
>> System CPU time 137 msec
>> Elapsed time 9003 msec
>> Context switches 1 voluntary, 9639 involuntary
>> Browser timing:
>> domLoading 9026 (+52130) msec
>>
>> *CACHE*: 0 calls in 0.00ms (so clearly not a cache issue either)
>>
>> Here are some details: Django 2.1, python 3.6.3
>> Hardware: iMac with 32GB, i7 quad core
>> Installed apps: Bootstrap3 v9.1.0, crispy forms v1.7.0, easyPDF v0.1.1,
>> registration-redux v2.2, Pillow v4.3.0
>>
>> Here’s one of the specific UpdateView routines being executed - there are
>> only 5 fields in the AddictionForm plus the prime key (no image or file
>> attachments).
>>
>> class AddictionUpdate(PermissionRequiredMixin, UpdateView):
>> model = Addiction
>> form_class = AddictionForm
>> template_name = 'addiction_update.html'
>> permission_required = 'clientapp.change_addiction'
>>
>> The slow response appears to be on UpdateView pages only, even though all
>> updates are called with the prime key (ID) in the URL. Can anyone give me
>> guidance where to look for improving the performance? Why all the
>> involuntary context switches? Why the large domLoading time?
>>
>> Thanks in advance -
>> Jim
>>
>> --
>> 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/76

Re: Django performance issue that's troubling

2018-08-23 Thread Vijay Khemlani
Maybe your update form has a field related to a model with thousands of
records? like rendering a select combo box with thousands of choices?

On Thu, Aug 23, 2018 at 5:30 PM Jim Illback  wrote:

> I have a Django app in development that performed perfectly with about 20
> client records. Each client could have one or more support records and
> there are 40 potential support records, connected to the client with a
> ForeignKey (client_id). Then, I loading about 37K client records. Search
> queries perform almost instantaneously. A paginated list of support records
> with 40 pages and 10 clients per page comes back in half a second. Great
> performance.
>
> However, when I click on any record in the list to go to update a specific
> support record for that specific client (it uses the PK in the URL so is a
> direct call to the UpdateView routine), I get about 10 second response
> times and these kind of statistics from Django-debug-toolbar:
> *SQL*: 5 queries, 20ms (so clearly not a DB related performance issue)
> *TIME*:  Resource usage:
> User CPU time 8827 msec
> System CPU time 137 msec
> Elapsed time 9003 msec
> Context switches 1 voluntary, 9639 involuntary
> Browser timing:
> domLoading 9026 (+52130) msec
>
> *CACHE*: 0 calls in 0.00ms (so clearly not a cache issue either)
>
> Here are some details: Django 2.1, python 3.6.3
> Hardware: iMac with 32GB, i7 quad core
> Installed apps: Bootstrap3 v9.1.0, crispy forms v1.7.0, easyPDF v0.1.1,
> registration-redux v2.2, Pillow v4.3.0
>
> Here’s one of the specific UpdateView routines being executed - there are
> only 5 fields in the AddictionForm plus the prime key (no image or file
> attachments).
>
> class AddictionUpdate(PermissionRequiredMixin, UpdateView):
> model = Addiction
> form_class = AddictionForm
> template_name = 'addiction_update.html'
> permission_required = 'clientapp.change_addiction'
>
> The slow response appears to be on UpdateView pages only, even though all
> updates are called with the prime key (ID) in the URL. Can anyone give me
> guidance where to look for improving the performance? Why all the
> involuntary context switches? Why the large domLoading time?
>
> Thanks in advance -
> Jim
>
> --
> 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/76F251D2-A429-4700-9F69-053673BDB91F%40hotmail.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/CALn3ei2korG5V3dDcCUQuKiAhG6tzAz%3DJZssNpGJpkAOyKAXpQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Use an external REST API in django admin

2018-07-16 Thread Vijay Khemlani
django rest framework would be your best bet

http://www.django-rest-framework.org/

On Mon, Jul 16, 2018 at 10:16 AM micka 
wrote:

> Hello,
>
> I wish I could use the data from an external API in the administration of
> Django. I wish I could list, read, edit and create objects but instead of
> using a postgres database, I would use a REST API.
> Do you know a module to do it or resources that could help me?
>
> 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/49ac56e6-a259-4fce-a8c2-3be2841021c6%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/CALn3ei2-cKCsnVpJ5b0QTDFPwbgChRcfx%3Db%2B-Wh-i8VFSO%3Dp_w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: A few doubts with an implementation.

2018-07-02 Thread Vijay Khemlani
You can also use PubNub (https://www.pubnub.com/) or similar services

On Mon, Jul 2, 2018 at 10:29 AM Vineeth Sagar  wrote:

> Mikhailo Keda wrote:
>>
>> to fetch emails every N minutes or hours  -
>> http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html
>> I want the user to know that the mails are being retrieved -
>> https://channels.readthedocs.io/en/latest/
>>
>
> Thanks Mikhailo for the prompt reply, I'll spend a few days reading the
> documentation of the libraries you have pointed me to. Are web sockets
> supported in IE, iirc I don't think they do. Half of our clients Will use
> IE, not edge, good old fucked up IE. Also I was expecting a critique on my
> ideas. I want to weigh the pro's and con's of my approach vs clerey's(It
> might be clear once I read the docs.)
>
> again thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/10ea3eba-a72f-4d33-8504-4658c0b810ef%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/CALn3ei08qdj0g5UOsjokDyQrTLPUoejqj1R_N_ot0uY2uqm13Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Nested for loops in templates

2018-06-13 Thread Vijay Khemlani
As far as I know you can't do it directly in the templating system

Yo could write a template tag as described here

https://stackoverflow.com/questions/2894365/use-variable-as-dictionary-key-in-django-template/10700142#10700142

or use a different data structure, for example each row as a list of the
values in the order that they should appear

On Wed, Jun 13, 2018 at 4:54 PM Mikkel Kromann 
wrote:

> Dear Django users.
>
> Thanks to the good advice of many people on this list, I've managed to
> create some nice generic class based views that work simultaneously with
> many models.
> The models may differ from each other with regards to the number of
> columns in their data tables as well as the naming of the columns.
> In order to use the same ListView template for many models, I will need to
> iterate not only over the rows of the queries, but also the columns.
>
> I managed to pass a field_list into the context_data - it works as it
> shows nicely in the table headers.
> However, when I iterate over the rows of the query result table, I'm not
> able to pinpoint the fields of the data row using the field iterator.
>
> My template.html is:
> 
> 
> {% for fields in field_list %}
> {{field}}
> {% endfor %}
> {% for row in row_list %}
> 
> {% for field in field_list %}
> {{row.field}}
> {% endfor %}
> {% endfor %}
> 
>
>
> Besides trying with {{row.field}}, I've tried with {{row}}.{{field}}, as
> well as {{ row.{{field}} }} (yeah, long shot ...)
>
> Any ideas, or should I try to create an entirely different data structure
> in my view, which can be parsed more easily by Django templates?
>
>
> cheers + thanks, Mikkel
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+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/c9e29d66-f93c-4fc4-ae9f-dbeae93a2e45%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Interfaz administrativa, login con SSH

2018-06-12 Thread Vijay Khemlani
La máxima seguridad (razonable) sería conectarse a una VPN y que el admin
de Django solo acepte logins desde dentro de la VPN, pero para el 99% de
los casos suena innecesario.

Para abrir un navegador dentro del servidor mismo tendrías que tener
instalado todo ambiente de escritorio en el servidor (XFCE, GNome, KDE,
algo, asumiendo un Linux), conectarte por SSH con soporte para X Server y
mandar todos los comandos via red a ese navegador, lo que es extremadamente
engorroso.

La autenticación por dos pasos es lo que usa Google, Steam, y muchos otros
servicios de alta seguridad.



On Mon, Jun 11, 2018 at 7:06 PM Frank Mascarell <
frank_mascar...@gandiweb.com> wrote:

> Gracias por vuestras recomendaciones de seguridad, muy interesantes.
> Después de recapacitar con todo esto, me planteo lo siguiente; si estamos
> desarrollando una tienda online,
> donde la base de datos se encuentra en un host remoto, y los
> administradores de la tienda deben
> entrar en ella diariamente, con todos los permisos (CRUD), ¿ la máxima
> seguridad que se puede
> implementar para la interfaz administrativa es mediante la autenticación
> de dos pasos ?
> ¿ No hay otra forma de hacerlo ? Por ejemplo, podría crear un programa en
> Python, utilizando
> la librería Paramiko para conectarme via SSH, y después ejecutar el
> comando que puede llamar
> al mismo tiempo a otro programa personalizado en el servidor, que abriría
> una ventana de navegador
> con la interfaz administrativa, si la autenticación es correcta.
> ¿alguna idea mejor?
>
> --
> 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/ad384adf-4b44-4e3b-9beb-daff67458ca6%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/CALn3ei187SBNfz06ZGYUuhgMcpzNtJ%3DHWABibVN%3DBxdxODSyfA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Interfaz administrativa, login con SSH

2018-06-11 Thread Vijay Khemlani
"Vijay, thanks for the help, but the authentication of two factors seems
quite uncomfortable, considering that an administrator can enter every day,
several times a day, having to depend on a mobile device for each login.
"

Session cookies last for 2 weeks by default in Django, regardless of the
login method

On Sun, Jun 10, 2018 at 11:31 PM carlos  wrote:

> Hola, tambien te recomiendo que leas esto
> Hi, i also recommend you read this
>
> https://hackernoon.com/5-ways-to-make-django-admin-safer-eb7753698ac8
>
>
> On Sun, Jun 10, 2018 at 8:02 PM Frank Mascarell <
> frank_mascar...@gandiweb.com> wrote:
>
>> Vijay, thanks for the help, but the authentication of two factors seems
>> quite uncomfortable, considering that an administrator can enter every day,
>> several times a day, having to depend on a mobile device for each login.
>>
>> I have to rethink the problem, perhaps by directly accessing postgres,
>> through
>> SSH with a GUI for the client-user that includes a CRUD interface,
>> although I do not have
>> knowledge of the software available for this. I have to investigate what
>> other ways I can
>> identify myself to a postgress database with SSH.
>>
>> Greetings.
>>
>> --
>> 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/05cc0a47-79e8-4088-b54f-15d9d098c514%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> att.
> Carlos Rocha
>
> --
> 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/CAM-7rO0B1Qk%3DO6o8kwFv1UdxGFMxYg-eKbOb5VAwkj6XHfWvGQ%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/CALn3ei2WkhJ%3DhvuZ0Z3GnepUqk4X9wpBbzL_40OHQ1mH%2BzQLmA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Interfaz administrativa, login con SSH

2018-06-10 Thread Vijay Khemlani
En general SSH sirve para hacer conexiones remotas por terminal (bueno,
puedes hacer una sesión X a través de SSH pero no creo que sea lo que
necesites)

La forma más común de aumentar la seguridad del login es por two factor
authorization, básicamente mandar una validación a tu celular o algun otro
dispositivo que valide que seas tú el que está iniciando sesión.

Personalmente nunca lo he hecho, pero hay paquetes de Django que lo
implementan

http://django-two-factor-auth.readthedocs.io/en/stable/

Aunque requieren cierto nivel de configuración

El proyecto que linkeas no parece servir para hacer login con llaves SSH,
solo las almacena

Saludos

On Sun, Jun 10, 2018 at 8:49 PM Frank Mascarell <
frank_mascar...@gandiweb.com> wrote:

> Hi, sorry for the mistakes, I'm using google-translator :)
>
> I hired a VPS on Digital Ocean, installed Django-Postgres and everything
> works
>
> correctly. Now I want to increase the security of Django's administrative
> interface,
> I want site administrators to login using SSH, eliminating authentication
> by password. It would be something similar to when I connect to the server
> with PuTTY via SSH.
>
> There is little documentation of SSH-Django, but I found an interesting
> package called
> simplesshkey , which can
> relate SSH keys to a user, saving them in the database
> of Django. I do not know if with this package I can achieve my goal, but I
> do not think so.
>
> Is there any way to do this?
> Can I reconsider another way of connecting as an administrator to the
> database, less
>
> safe ? I would not like to have a remote open port in postgres, I would
> prefer it to be
>
> Managed through Django.
>
> --
> 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/9b1bb164-73af-4c92-9ed9-d7371c6bfa92%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/CALn3ei0C20rLDPyKJXWNCksFS_-uoov_AyQJrdTGQ95ABF3sJg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Passing Django Template Vars to JS

2018-06-10 Thread Vijay Khemlani
I'm not sure why your code does not work (maybe there is a "race condition"
between the JS click handlers), but that global variable is a bad idea in
general.

You can add the comment ID as an attribute to your button, like



and in your event handler obtain the comment id

$("#like_comment_button").click(function (event) {
   var comment_id = event.target.getAttribute('data-comment-id')
   // Call AJAX
})

That way you don't need the global variable or the other click handler

Finally, it's a bad idea to have multiple elements with the same ID (all
comments will have a button with ID "like_comment_button") so it's better
to add it as a class rather than an id.

Regards





On Sun, Jun 10, 2018 at 11:19 AM Simon Connah 
wrote:

> I know that the standard way to do this is to create a script tag with
> a global JS variable in your Django template before you import your
> other JS files but that won't work for my current situation.
>
> I have an article detail view which is a single model instance. But I
> also have a list of comment objects that have a Foreign Key to the
> article (because that is the article that is being commented on).
>
> I need to pass the comment_id to the JS files that I am loading. If
> you want to see the code I am using then you can see it here:
>
>
> https://gitlab.com/glamorous-systems/seductive/blob/master/blog/templates/blog/article_detail.html
>
> I thought I'd use an onclick event on the Like / Dislike button to
> call a JS function which then passes that value to this JS file:
>
>
> https://gitlab.com/glamorous-systems/seductive/blob/master/blog/static/js/pass_comment_id.js
>
> and then I'd just call the return_comment_id() function from my other
> JS files to get the comment_id of the specific comment the user
> clicked the Like / Dislike button for. I think the problem is that my
> jQuery AJAX selectors are also looking for a click event, so they
> happen in a strange order, but I'm not sure.
>
> I'm totally lost on what I should be doing here. Any help would be
> very much appreciated :).
>
> --
> 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/CADNsu1OksTqc2crvX%3DK%3D_Kf_Xz1fCfABTRV-q48htRUikiAtXA%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/CALn3ei0ZneJzKAbSyN958_1RCaS7kjQY6VszQb8a%3D-Mxgod-GQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem in part 6, CSS doesn't work

2018-05-29 Thread Vijay Khemlani
That's only for production environments, for development you don't need to
run that command

Where did you finally put the css file and what path did you put in the
 tag?

On Tue, May 29, 2018 at 1:46 PM Mikko Meronen 
wrote:

> Hi,
>
> Thank you, but I should have those correct.
>
> I did some googling and ran following: python manage.py collectstatic
>
> And I got this:
>
> Django-project\lib\site-packages\django\contrib\staticfiles\storage.py",
> line 43, in path
> raise ImproperlyConfigured("You're using the staticfiles app "
> django.core.exceptions.ImproperlyConfigured: You're using the staticfiles
> app without having set the STATIC_ROOT setting to a filesystem path.
>
> If any advices available, I would appreciate it a lot, thank you.
>
> -Mikko
>
> 2018-05-29 10:18 GMT+03:00 s.f.wrobel via Django users <
> django-users@googlegroups.com>:
>
>> Make sure that you add the following line to your settings.py:
>>
>> INSTALLED_APPS = [
>> 'YOUR_APP_NAME',
>> 'django.contrib.admin',
>> 'django.contrib.auth',
>> 'django.contrib.contenttypes',
>> 'django.contrib.sessions',
>> 'django.contrib.messages',
>> 'django.contrib.staticfiles',
>> ]
>>
>> In your case YOUR_APP_NAME should be polls.
>> Only with this line set, django looks in polls/static/polls/ for static
>> (e.g .css) files.
>>
>> --
>> 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/1ce28246-ddf6-48b2-9811-988678beb65c%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/CAGD0jjJUHeZD2ep52j-NArHPjEibVMK3Jiiqor4O4BEuS2_gtw%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/CALn3ei2ujyB0g4fV-Ow2ogcgkv8%3D_XfvK2rzHTtfPjGAyJz%3DAQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Managing multiple user types in Django

2018-05-15 Thread Vijay Khemlani
I would make a UserType table and have a foreign key from your user model
to it, or maybe just have an enumerated type in your user model depending
on how much custom logic there is to each user type.

On Tue, May 15, 2018 at 11:50 AM Frankline  wrote:

> Hello Everyone,
>
> I am developing an API based on Django Rest Framework
> . Currently I have 4 user types
> i.e. Buyer, Merchant, Insurer, and Admin.
>
> The system I'm developing has an *API endpoint* and a *Dashboard* view.
>
> Each of the above user types have different fields and may need to login
> to the system at one point, so having one user model is the best way to go.
> Note that, a user can only be of one type.
>
> However, only the merchant will be actively using the API endpoint.
>
> My question is then, how will I be able to manage the different user types
> in the system?
>
> My current options are:
>
> 1.
>
>1. class BaseUser(AbstractBaseUser):
>2. ...
>3.
>4. class Buyer(BaseUser):
>5. ...
>6.
>
>
>1. class Merchant(BaseUser):
>2. ...
>3.
>
>
>1. class Insurer(BaseUser):
>2. ...
>
>
> 2.
>
>
>1. from django.db import models
>2. from django.contrib.auth.models import User
>3.
>4. class Buyer(models.Model):
>5. user = models.OneToOneField(User)
>6.
>7. class Merchant(models.Model):
>8. user = models.OneToOneField(User)
>9.
>
>
>1. class Insurer(models.Model):
>2. user = models.OneToOneField(User)
>
>
>
>1. ...
>
>
> Which is the most optimal way of handling this?
>
>1.
>
>
>
>
> --
> 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/CAEAUGdVwB_RrOP_s9Oj5fe6AoOXJ9qpPLUKpE%2BbAO_NLGMRn6g%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/CALn3ei0xcocCdB-TF%2BFGyjutV7hFELpiqsbc6jnscVz4OijVww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: M2M Magic Accessors without explicit ManyToMany Field

2018-05-08 Thread Vijay Khemlani
Why would it be a muti table inheritance?

I would just inherit Car (class MyCar) and add the m2m field there, seems
way more explicit and easy to understand too.

On Tue, May 8, 2018 at 12:18 PM Clayton D  wrote:

> I posted a question on SO (https://stackoverflow.com/q/50222402/1978687),
> but it's been viewed very few times so I'm hoping this is the right place
> to get attention from those "in the know".  The complete question (and
> progress so far) is documented on SO so that's probably the best place to
> answer.
>
> The essentials of the question are:
>
>- I need to create an M2M relationship between two models, but...
>- The models are from external libraries (trivially User and Car)
>- The models are non-abstract and multi-table inheritance would
>introduce a ton of unnecessary overhead
>- Others will use my code like (if not literally as) a 3rd party
>library so I want to provide all of the usual magic methods for usability
>-- e.g. Cars.objects.filter(users=user) -- which doesn't happen if I create
>a manual M2M (i.e. "through") table.
>
> A commenter suggested using `add_to_class` on one of the 3rd party
> models.  It passes trivial test cases, but has hair and some of the magic
> breaks because it's treated as a `through=` relationship even though it's a
> trivial M2M table.
>
> I'm hoping someone who understands the ManyToMany implementation can tell
> me if I can hijack the `contribute...` methods (or something similar) to
> get this job done.
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/cc6f6c74-e5df-4fcf-b473-42f894fd3abb%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/CALn3ei1SzY12rvv%2BQsL9NP9yc_z%2BET6ZZD%2BssgmALHA43xtY%2BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: committing migration files

2018-04-30 Thread Vijay Khemlani
At least for me I have custom migrations (for a materialized view) so that
needs to be commited, and a migration seems the most logical place to do so

Also if you already have a production database and you need to execute a
complex change in the data model you may need a sequence of steps that
include for example running migrations to a certain point, run a script,
and then run the rest of the migrations, which can't be done if the server
just makes its own migration in one step.

There may be other reasons but those are the most common for me

On Mon, Apr 30, 2018 at 1:03 PM Tom Scrace  wrote:

> Hi all,
>
> The way I've always worked, developers run `makemigrations` locally, and
> commit migration files to the repo.
>
> However, a suggestion has recently come my way that a better strategy is
> to only commit model changes to the repo (leaving the migrations directory
> gitignored), and then run `makemigrations` in whatever environment the app
> needs to run, whether that's another developer's laptop, or in production.
> The putative benefit is that this avoids the possibility of migration
> conflicts, and always guarantees a clean migration from the state of a
> database schema to the state of the Django models.
>
> Googling around, this opinion seems to be moderately widespread, although
> the official docs, and the *majority* of commenters seem to agree that
> committing migration files is the right way.
>
> I think I agree, but I can't quite put my finger on decisive arguments
> against the idea of not committing migration files. I feel like I am
> missing something.
>
> What are some reasons we should go the route of committing migration files?
>
> Thanks,
> Tom
>
> --
> 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/08ef20a1-9b51-4bea-a1d8-7d3ed61093fe%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/CALn3ei1JmrBG08kBqKVNeK_ExGDUgjEe%2Bg-J9yuUU9Yt341RkQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django y Python

2018-04-16 Thread Vijay Khemlani
No es necesario usar anaconda para instalar Django

Puedes usar Django 1.5 en adelante con Python 3, pero lo ideal es usar la
última versión (2.0.4)

On Sun, Apr 15, 2018 at 8:38 PM, Marcelo Giorno 
wrote:

> Soy nuevo en todo esto.
> Instale Anaconda.
> Tengo Python 3,6
> La consulta es puedo instalarme cualquier version de DJANGO?
>
> --
> 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/1bb5fde2-d427-4424-9dfd-0e929d211d37%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/CALn3ei3jTU%2BzdX2FqVYufc0%2BpoPZgPPUCO0QuT9yx8A26ObTow%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-03 Thread Vijay Khemlani
Well, you should've said that in the first post.

First I would try with a saner DB (Postgres)

Also I don't think 300 ms is particularly bad, but in that case start
looking into caching alternatives (e.g. memcached) or a search index (e.g.
ElasticSearch)

On Sat, Feb 3, 2018 at 3:14 AM, Web Architect <pinak...@gmail.com> wrote:

> Hi Furbee,
>
> Thanks for your response.
>
> With my experience I have always noticed that a query within query kills
> the mysql and Mysqld CPU usage hits the ceiling. I would still check your
> alternate.
>
> I have mentioned the size of A and B in response to Vijay's reply.
>
> On Saturday, February 3, 2018 at 1:06:48 AM UTC+5:30, Furbee wrote:
>>
>> There are a couple options you could try to see which is the best fit for
>> your data. With DEBUG=True in settings.py you can check the actual queries
>> and process time. It depends on the sizes of A and B. Another query you can
>> run is:
>>
>> A.objects.exclude(id__in=B.objects.all().values_list('a_id', flat=True))
>>
>> When I tried, it seemed to be about the same speed with my test data as
>> the one you had A.objects.filter(bs__isnull=True).
>>
>> To see what queries are generated and the query time with DEBUG=True:
>> Open your Django Python Shell
>> >>> A.objects.exclude(id__in=B.objects.all().values_list('a_id',
>> flat=True))
>> >>> A.objects.filter(bs__isnull=True)
>> >>> from django.db import connection
>> >>> for q in connection.queries:
>> >>> print("{0}: {1}".format(q['sql'], q['time']))
>>
>> This will show you both queries generated and how long it took to get a
>> response from your DB.
>>
>> You can also write raw SQL, if you can make one more efficiently.
>>
>> Furbee
>>
>> On Fri, Feb 2, 2018 at 10:56 AM, Vijay Khemlani <vkhe...@gmail.com>
>> wrote:
>>
>>> "with large of records in A and B, the above takes lot of time"
>>>
>>> How long? At first glance it doesn't look like a complex query or
>>> something particularly inefficient for a DB.
>>>
>>> On Fri, Feb 2, 2018 at 11:31 AM, Andy <kaku...@gmail.com> wrote:
>>>
>>>> not that i know of
>>>>
>>>>
>>>> Am Freitag, 2. Februar 2018 15:28:26 UTC+1 schrieb Web Architect:
>>>>>
>>>>> Hi Andy,
>>>>>
>>>>> Thanks for your response. I was pondering on option a before posting
>>>>> this query thinking there could be better ways in django/SQL to handle
>>>>> this. But now I would probably go with a.
>>>>>
>>>>> Thanks.
>>>>>
>>>>> On Friday, February 2, 2018 at 7:50:53 PM UTC+5:30, Andy wrote:
>>>>>>
>>>>>> a) Maybe its an option to put the foreign key to the other model?
>>>>>> This way you dont need to make a join to find out if there is a relation.
>>>>>>
>>>>>> b) Save the existing ralation status to model A
>>>>>>
>>>>>> c) cache the A.objects.filter(bs__isnull=False) query
>>>>>>
>>>>>> But apart from that i fear you cannot do much more, since this is
>>>>>> just a DB and not a Django ORM question.
>>>>>>
>>>>>>
>>>>>> Am Freitag, 2. Februar 2018 14:47:45 UTC+1 schrieb Web Architect:
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I am trying to optimise Django queries on my ecommerce website. One
>>>>>>> of the fundamental query is where I have no clue how to make efficient. 
>>>>>>> It
>>>>>>> could be trivial and probably been known long time back. But I am new to
>>>>>>> Django and would appreciate any help. This is primarily for one to many 
>>>>>>> or
>>>>>>> many to many relations.
>>>>>>>
>>>>>>> Following is an example scenario:
>>>>>>> (Please pardon my syntax as I want to put across the concept and not
>>>>>>> the exact django code unless it's really needed):
>>>>>>>
>>>>>>> Model A:
>>>>>>>
>>>>>>> class A(models.Model):
>>>>>>> # Fields of model A
>>>>>>>
>>>>>>> Model B (which is related to A with foreign key):
>>>>>>>

Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-02 Thread Vijay Khemlani
"with large of records in A and B, the above takes lot of time"

How long? At first glance it doesn't look like a complex query or something
particularly inefficient for a DB.

On Fri, Feb 2, 2018 at 11:31 AM, Andy  wrote:

> not that i know of
>
>
> Am Freitag, 2. Februar 2018 15:28:26 UTC+1 schrieb Web Architect:
>>
>> Hi Andy,
>>
>> Thanks for your response. I was pondering on option a before posting this
>> query thinking there could be better ways in django/SQL to handle this. But
>> now I would probably go with a.
>>
>> Thanks.
>>
>> On Friday, February 2, 2018 at 7:50:53 PM UTC+5:30, Andy wrote:
>>>
>>> a) Maybe its an option to put the foreign key to the other model? This
>>> way you dont need to make a join to find out if there is a relation.
>>>
>>> b) Save the existing ralation status to model A
>>>
>>> c) cache the A.objects.filter(bs__isnull=False) query
>>>
>>> But apart from that i fear you cannot do much more, since this is just a
>>> DB and not a Django ORM question.
>>>
>>>
>>> Am Freitag, 2. Februar 2018 14:47:45 UTC+1 schrieb Web Architect:

 Hi,

 I am trying to optimise Django queries on my ecommerce website. One of
 the fundamental query is where I have no clue how to make efficient. It
 could be trivial and probably been known long time back. But I am new to
 Django and would appreciate any help. This is primarily for one to many or
 many to many relations.

 Following is an example scenario:
 (Please pardon my syntax as I want to put across the concept and not
 the exact django code unless it's really needed):

 Model A:

 class A(models.Model):
 # Fields of model A

 Model B (which is related to A with foreign key):

 class B(models.Model):
 a = models.ForeignKey('A', related_name='bs')

 Now I would like to find out all As for which there is atleast one b.
 The only way I know is as follows:

 A.objects.filter(bs__isnull=False)

 But the above isn't an optimal way as with large of records in A and B,
 the above takes lot of time. It gets more inefficient if it's a many to
 many relationship.

 Could anyone please let me know the most efficient way to use django
 queryset for the above scenario?

 Thanks.

>>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/73ed5ff7-d4db-4057-a812-01c82bf08cf3%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/CALn3ei1Q2p31NrcdYC-2EPfH78kBxCXZPZKW1e6k%2BqCTuUgYDw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Will django include a simpler way to change username to email for registration in the future ?

2018-01-23 Thread Vijay Khemlani
I have been using django-custom-user for that without any issues

On Tue, Jan 23, 2018 at 6:43 PM, Daniel Cîrstea 
wrote:

> Hello. For a while I noticed that it is a struggle to extend the
> AbstractBaseUser in order to change user to email for registration and
> login. Takes time and it is a lot of code. I was wondering if django will
> include a simpler way of doing it ? Something simple like just changing a
> settings.py variable to email and boom, u can create accounts with email
> address.
>
> --
> 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/606c63a3-792a-4827-8211-1d4be998cc2a%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/CALn3ei0evyKJEEkSabqRTNOEKRnRnyLqYi1SLHyauvvE%2Bk2oPg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to Design Models for Matches in Django Dating App?

2017-12-23 Thread Vijay Khemlani
If you have the survey answers for all the people and you are only going to
base the matches based on that data, I'd rather use a K Nearest Neighbors
implementation

http://scikit-learn.org/stable/modules/neighbors.html

Or some other similar system to suggest the matches.

For 1.000 users it should be extremely fast to determine the closest
matches for everyone, so there would be no need to store the intermediate
scores, you just need to store the answers to the survey questions.

Problem is, it does well with semantic numeric values ("age", "weight", and
so on), so if you just give it model instance IDs it may work well for
exact matches but not so much if they start growing apart.

There are ways to solve that, but I'm not sure if this answer works for you.

On Sat, Dec 23, 2017 at 4:39 PM, Jason  wrote:

> This is an issue where regular tablular database structure really doesn't
> work well for a number of reasons.  You should look into a graph database
> for querying matches, and use a regular mysql/postgres for table-related
> data.
>
> --
> 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/4ea4e50e-0214-45f1-b076-a33200828835%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/CALn3ei3AJ7LqjYVMdxHQ5kZSAWjEir7e8idUkatPCmGMuXm9SQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 2.0 released

2017-12-04 Thread Vijay Khemlani
I just wanted to take the chance to thank Tim and all the other people
working on Django, especially on this big milestone for the project.

At least for me It has served me well over the last 5 years, has
incorporated many useful features while still being relatively lean, and
has top notch documentation.

Thanks for the hard work guys!

On Sun, Dec 3, 2017 at 10:40 PM, Jorge Gimeno  wrote:

> If you use pipenv, it will do that for you.
>
> -Jorge
>
> On Dec 3, 2017 3:05 PM, "Simon Charette"  wrote:
>
>> > My mistake? My "requirements.txt" file did not mention package versions.
>>
>> You should definitely make sure to lock/freeze your requirements to
>> prevent
>> your application's behavior from changing under your feet.
>>
>> Best,
>> Simon
>>
>> Le samedi 2 décembre 2017 15:02:55 UTC-5, Adler Neves a écrit :
>>>
>>> I guess I noticed it updated the worst way possible:
>>>
>>>- A commit has been pushed
>>>- Continuous Integration tests passes
>>>- CI sends "it's safe to deploy" signal to production server
>>>- Downtime in production
>>>
>>> My mistake? My "requirements.txt" file did not mention package versions.
>>>
>>> Seeing the changelog, a lot of stuff changed. Seeing the tracebacks,
>>> some helper applications I use ("django-avatar" is one of them) will need
>>> updates before I migrate to the newer version.
>>>
>>> Em sábado, 2 de dezembro de 2017 14:28:59 UTC-2, Tim Graham escreveu:

 Django 2.0 is now available:

 https://www.djangoproject.com/weblog/2017/dec/02/django-20-released/

 With the release of Django 2.0, Django 1.11 has reached the end of
 mainstream support. The final minor bug fix release (1.11.8) was
 issued today. As a long-term support release, Django 1.11 will receive
 security and data loss fixes until April 2020.

 Django 1.10 has reached the end of extended support. All Django 1.10
 users are encouraged to upgrade to Django 1.11 or later to continue
 receiving fixes for security issues.

 See the downloads page [1] for a table of supported versions and the
 future release schedule.

 [1] https://www.djangoproject.com/download/#supported-versions

>>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/9d01a490-ded0-4d22-8d3b-6734968eaaf5%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/CANfN%3DK8uW-kK5YSkh0VA10%2B3aySezEwBa8--%2BUSetjri-
> aVn5w%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/CALn3ei1rR%3D4FvVFwTi-RmMMtrOqj_e4vMdGwro8dtv-mnsAdOw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: İ want to setup a server at home for testing and lerning to deploy django projects, thanks for any helping.

2017-12-01 Thread Vijay Khemlani
For a typical setup, a VM (using VirtualBox or similar) running the OS of
your server should be enough to test

On Fri, Dec 1, 2017 at 2:39 AM, Ali İNCE  wrote:

> İ want to setup a server at home for testing and lerning to deploy django
> projects, can anyone help me , advice and share sources  thanks for all.
>
> --
> 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/HE1PR10MB0522F6B109EBF350BC57687CAA390%40HE1PR10MB0522.
> EURPRD10.PROD.OUTLOOK.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/CALn3ei0h%2BY%3D59uo3SBQiY8r-WAuDsvt9k6A%2Bi5RPYjimp6fqbQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Templates and Conditional CSS classes

2017-11-10 Thread Vijay Khemlani
You can also add a "state_css_class" (or something) method to your object
class and just call

...

the method should be quite simple

On Fri, Nov 10, 2017 at 7:01 PM, Adam Simon  wrote:

>
>  You can pass the class from either the model or the view into the
> template. For example, you can assign a class to a button with a variable:
>
> <|button>
>
> And then the class would have to be defined in your style somewhere
>
> On Fri, Nov 10, 2017 at 1:37 PM treyd  wrote:
>
>> At some point I plan on figuring out how to do more intelligent front-end
>> in-browser stuff (Angular, etc) which yeah would definitely help me here
>> but I was wondering if there was a Django-only way of doing this.
>>
>>
>> On Friday, November 10, 2017 at 3:51:09 PM UTC-5, Adam wrote:
>>
>>>
>>> Are you open to using JavaScript in the front end? It would make it
>>> really easy
>>>
>> On Fri, Nov 10, 2017 at 12:40 PM treyd  wrote:
>>>
>> Hello,

 I am trying to render a model field in a django template, and, based on
 the value of the field, I want to specify a different CSS class.  Right
 now, my solution is this:

 {{ myobject.state }}

 This works, but seems like a really ugly solution and a bunch of logic
 in the template.  Is there a better way of doing this?  My thought was to
 put the class names as another field in the model, but that seems like it
 would violate the MVC (or MVT) separation. Any ideas?

 Thanks in advance,
 treyd

 --
 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/6a3adb62-f3d7-4cc2-8c97-add34cf757ce%
 40googlegroups.com
 
 .
 For more options, visit https://groups.google.com/d/optout.

>>> --
>>> --
>>>
>>> Adam F. Simon, PhD
>>> Calabasas, CA.
>>>
>>> cell:  818-425-3719
>>> home:   818-880-8405
>>>
>>> Feel free to link w/ me: LinkedIn
>>>
>>>
>>> --
>> 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/360d495a-6715-40a6-ae25-4ee5aed7e3cc%
>> 40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> --
>
> Adam F. Simon, PhD
> Calabasas, CA.
>
> cell:  818-425-3719
> home:   818-880-8405
>
> Feel free to link w/ me: LinkedIn
>
>
> --
> 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/CAH-jdcwVhxnbn9uRr1C7kR4SP6mB9CN-
> rAzRU28tCMLZ64bosw%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/CALn3ei3qud9RH9zggT3jMkZ_FWXeoyAuvLu2pEgd1mWy_HFwEw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: tutorial site not working

2017-11-05 Thread Vijay Khemlani
did you keep the manage.py shell open while making the code changes? you
need to close/open it again

On Sat, Nov 4, 2017 at 10:36 PM, Kyle Foley  wrote:

> Let me also show what I have placed in the terminal
>
> >>> Question.objects.get(pk=1)
>
> 
>
> >>> q = Question.objects.get(pk=1)
>
> >>> q.was_published_recently()
>
> I also don't understand why I am outputting:
>
> 
>
> And the website says the output should be:
>
> 
>
>
>
> --
> 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/6087580b-5be3-484e-a929-d0e4e6a7ad5c%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/CALn3ei1b2AHyRsNA3fHMwPtnUAhTAKJpC%2BZsrsWaQ7%3Dds%3DKg7w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: make a button element outside be on the right side of another element inside

2017-09-28 Thread Vijay Khemlani
An input with type "button" instead of "submit" should not trigger the form
submit.

On Thu, Sep 28, 2017 at 7:56 PM, fábio andrews rocha marques <
fabioandrewsrochamarq...@gmail.com> wrote:

> In my template, I have a form. This form has a lot of textfields and a
> submit button. There's another button, lets name it "?", that displays a
> popup window whenever it's clicked.
> I want the "?" button to be on the right side of one of the textfields on
> my form. The problem is: since the form has an action associated with it,
> if i put the button inside the form, whenever the user clicks on it, the
> system computes it's action as if the submit button was clicked too... I
> don't want this to happen.
>
> How can i position my "?" button to the right of a component which is
> inside a  even though my "?" button is outside the ?
>
> --
> 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/96716dc0-19d9-46e0-9c04-f0e644c57b8c%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/CALn3ei3wRdXsV6soirEjqUa7EURQx2w-1XK%3DWdOh1QE%3DhS%2BXFw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Email validation in form

2017-09-12 Thread Vijay Khemlani
If you render the form using the typical methods ("{{ form.as_p }}" or
similar) then there should be a message over the email field with the error.

>From the code, you an use form.errors to check the errors in the form.

On Tue, Sep 12, 2017 at 8:10 AM, Moreplavec <stanislav.va...@gmail.com>
wrote:

> I understand, but why while using model form it's not cought by form
> itself same as missing or incorect field like "asdf" for email? This is my
> problem. I need to show error and not to try to save :)
>
>
>
> Dne úterý 12. září 2017 12:47:16 UTC+2 Vijay Khemlani napsal(a):
>>
>> "asdf@asdf" is not a valid email so form.is_valid returns False and
>> form.save is never called
>>
>>
>>
>> On Tue, Sep 12, 2017 at 4:52 AM, Moreplavec <stanisl...@gmail.com> wrote:
>>
>>> Greetings,
>>>
>>> i have strange problem with my model form. I have simple form for taking
>>> orders, model looks like:
>>>
>>> class Order(models.Model):
>>>> name = models.CharField(max_length=50, blank=False,
>>>> verbose_name='Jméno')
>>>> surname = models.CharField(max_length=50, blank=False,
>>>> verbose_name='Příjmení')
>>>> email = models.EmailField(max_length=254, blank=True)
>>>> phone = models.CharField(max_length=50, verbose_name='Telefon',
>>>> blank=True)
>>>> coursedate = models.ForeignKey(CourseDate, verbose_name='Termín')
>>>> note = models.CharField(max_length=500, blank=True,
>>>> verbose_name='Poznámka')
>>>> created = models.DateTimeField(auto_now_add=True)
>>>> updated = models.DateTimeField(auto_now=True)
>>>> def __str__(self):
>>>> return '%s, %s' % (self.surname, self.coursedate.course.name)
>>>
>>>
>>> and template (bootstrap, modal):
>>>
>>>
>>>
>>>> {{ form.non_field_errors }}
>>>
>>> {% csrf_token %}
>>>> {{ form.non_field_errors }}
>>>> {% for hidden in form.hidden_fields %}
>>>> {{ hidden }}
>>>> {% endfor %}
>>>> {% for field in form.visible_fields %}
>>>> 
>>>> {% if field.field.required %}
>>>> {{ field.errors }}
>>>> {{ field.label }}>>> class="special_class">*{{ field }}
>>>> {% else  %}
>>>> {{ field.label }} {{ field }}
>>>> {% endif %}
>>>> 
>>>> {% endfor %}
>>>>
>>>> 
>>>> 
>>>> Close
>>>> Send
>>>> 
>>>> 
>>>
>>>
>>> And in model:
>>>
>>> def serve(self, request):
>>>> from crm.forms import OrderFormNew
>>>> if request.method == 'POST':
>>>> form = OrderFormNew(request.POST)
>>>> if form.is_valid():
>>>> form.date_changed = datetime.date.today()
>>>> form.save()
>>>> return render(request, 'courses/course_web.html', {
>>>> 'page': self,
>>>> 'form': form,
>>>> })
>>>> else:
>>>> form = OrderFormNew()
>>>> form.fields["coursedate"].queryset =
>>>> CourseDate.objects.filter(course=self.course).order_by('date_start')
>>>> return render(request, 'courses/course_web.html', {
>>>> 'page': self,
>>>> 'form': form,
>>>> })
>>>
>>>
>>>
>>> All fields work fine, but when i insert email, for example "asdf@asdf"
>>> form is taken away but not saved to model. So Django wont validate, but
>>> form takes it. How to make form to use same rules as Django? When i use
>>> email "te...@test.com" all works fine and data are in model saved.
>>>
>>> Thanks for help, maybe it's to much things together while using pop-up +
>>

Re: Email validation in form

2017-09-12 Thread Vijay Khemlani
"asdf@asdf" is not a valid email so form.is_valid returns False and
form.save is never called



On Tue, Sep 12, 2017 at 4:52 AM, Moreplavec 
wrote:

> Greetings,
>
> i have strange problem with my model form. I have simple form for taking
> orders, model looks like:
>
> class Order(models.Model):
>> name = models.CharField(max_length=50, blank=False,
>> verbose_name='Jméno')
>> surname = models.CharField(max_length=50, blank=False,
>> verbose_name='Příjmení')
>> email = models.EmailField(max_length=254, blank=True)
>> phone = models.CharField(max_length=50, verbose_name='Telefon',
>> blank=True)
>> coursedate = models.ForeignKey(CourseDate, verbose_name='Termín')
>> note = models.CharField(max_length=500, blank=True,
>> verbose_name='Poznámka')
>> created = models.DateTimeField(auto_now_add=True)
>> updated = models.DateTimeField(auto_now=True)
>> def __str__(self):
>> return '%s, %s' % (self.surname, self.coursedate.course.name)
>
>
> and template (bootstrap, modal):
>
>
>
>> {{ form.non_field_errors }}
>
> {% csrf_token %}
>> {{ form.non_field_errors }}
>> {% for hidden in form.hidden_fields %}
>> {{ hidden }}
>> {% endfor %}
>> {% for field in form.visible_fields %}
>> 
>> {% if field.field.required %}
>> {{ field.errors }}
>> {{ field.label }}> class="special_class">*{{ field }}
>> {% else  %}
>> {{ field.label }} {{ field }}
>> {% endif %}
>> 
>> {% endfor %}
>>
>> 
>> 
>> Close
>> Send
>> 
>> 
>
>
> And in model:
>
> def serve(self, request):
>> from crm.forms import OrderFormNew
>> if request.method == 'POST':
>> form = OrderFormNew(request.POST)
>> if form.is_valid():
>> form.date_changed = datetime.date.today()
>> form.save()
>> return render(request, 'courses/course_web.html', {
>> 'page': self,
>> 'form': form,
>> })
>> else:
>> form = OrderFormNew()
>> form.fields["coursedate"].queryset =
>> CourseDate.objects.filter(course=self.course).order_by('date_start')
>> return render(request, 'courses/course_web.html', {
>> 'page': self,
>> 'form': form,
>> })
>
>
>
> All fields work fine, but when i insert email, for example "asdf@asdf"
> form is taken away but not saved to model. So Django wont validate, but
> form takes it. How to make form to use same rules as Django? When i use
> email "t...@test.com" all works fine and data are in model saved.
>
> Thanks for help, maybe it's to much things together while using pop-up +
> validation and i'm mixing things together and error is shown somewhere, but
> lost in code :)
>
> Moreplavec
>
> --
> 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/fabad5ea-8535-483c-895f-ebb0d90e5c1a%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/CALn3ei2qaVXFvZsyJtasn0Vspt%2B9g%3DQOwAO9A%2Bk2vNthQZ%3DDUA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to write APIview to access a specific item by using APIViews only

2017-09-05 Thread Vijay Khemlani
To retrieve a particular object in your API you should implement it in a
method called "retrieve", not "get", if I remember correctly

On Tue, Sep 5, 2017 at 10:28 AM, Rakhee Menon 
wrote:

> CODE:
>
> class FormList(APIView):
> def get(self, request, id):
> import ipdb;ipdb.set_trace()
> item_obj = ItemMaster.objects.get(id=id)
> serializer = ItemMasterSerializer(forms,many=False)
> return Response(serializer.data, content_type="application/json")
> def get(self,request):
> forms = ItemMaster.objects.all()
> serializer=ItemMasterSerializer(forms,many=True)
> return Response(serializer.data, content_type="application/json")
>
>
>
> I get this error.django-got-an-unexpected-keyword-argument-id.
> when i try to access a specific item..Please can anyone suggest how to
> solve this bug using APIViews and not by using viewset  as there is lot of
> customization in my API.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/8f1a1edf-ed7f-490f-8c29-73aa31531a3b%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/CALn3ei3fp0uWeBr0a6ycGvw03ZKqzXRdepJpD%2B34VKxTQV-4hQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Deploy app under subdirectory

2017-08-28 Thread Vijay Khemlani
If possible try and run as a subdomain

myapp.mydomain.com

it is easier to configure things in that case

On Sun, Aug 27, 2017 at 11:39 PM, Angel Ruiz  wrote:

> Hello everybody, I need run my app under subdirectory, e.g.
> mydomain.com/myapp
>
> I have one app running with Nginx and Gunicorn in Ubuntu Server, but I
> don't know how run under subdirectory.
>
> Please, I need 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/1d1ae134-affc-4335-a90e-4113430b6bf9%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/CALn3ei234Q%2BMnXVPRx9kRL8uX0EAE75F4wW_xbt-FBt1OGeGTg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: please help me about django error that encoding is wrong

2017-08-22 Thread Vijay Khemlani
What is the hostname of your machine? If you are using Windows then you can
execute "ipconfig /all" on a cmd prompt

On Mon, Aug 21, 2017 at 11:27 PM, 輝夜三日月  wrote:

>
> 
> just create a django project in Pycharm which was in a virtual environment
> ,while it send me a unsolved problem about following things:
>
>
>
> "C:\Program Files\JetBrains\PyCharm 2017.2.1\bin\runnerw.exe"
> C:\Users\Administrator\sample——venv\Scripts\python.exe
> C:/Users/Administrator/PycharmProjects/untitle7/manage.py runserver 8000
> Performing system checks...
>
> System check identified some issues:
>
> WARNINGS:
> ?: (1_8.W001) The standalone TEMPLATE_* settings were deprecated in Django
> 1.8 and the TEMPLATES dictionary takes precedence. You must put the values
> of the following settings into your default TEMPLATES dict: TEMPLATE_DIRS.
>
> System check identified 1 issue (0 silenced).
> August 22, 2017 - 02:05:59
> Django version 1.11.4, using settings 'untitle7.settings'
> Starting development server at http://127.0.0.1:8000/
> Quit the server with CTRL-BREAK.
> Unhandled exception in thread started by  check_errors..wrapper at 0x03827030>
> Traceback (most recent call last):
>   File "C:\Users\Administrator\AppData\Local\Programs\Python\
> Python36-32\lib\site-packages\django\utils\autoreload.py", line 228, in
> wrapper
> fn(*args, **kwargs)
>   File "C:\Users\Administrator\AppData\Local\Programs\Python\
> Python36-32\lib\site-packages\django\core\management\commands\runserver.py",
> line 149, in inner_run
> ipv6=self.use_ipv6, threading=threading, server_cls=self.server_cls)
>   File "C:\Users\Administrator\AppData\Local\Programs\Python\
> Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 164,
> in run
> httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=ipv6)
>   File "C:\Users\Administrator\AppData\Local\Programs\Python\
> Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 74,
> in __init__
> super(WSGIServer, self).__init__(*args, **kwargs)
>   File "C:\Users\Administrator\AppData\Local\Programs\Python\
> Python36-32\Lib\socketserver.py", line 453, in __init__
> self.server_bind()
>   File "C:\Users\Administrator\AppData\Local\Programs\Python\
> Python36-32\Lib\wsgiref\simple_server.py", line 50, in server_bind
> HTTPServer.server_bind(self)
>   File "C:\Users\Administrator\AppData\Local\Programs\Python\
> Python36-32\Lib\http\server.py", line 138, in server_bind
> self.server_name = socket.getfqdn(host)
>   File 
> "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\Lib\socket.py",
> line 673, in getfqdn
> hostname, aliases, ipaddrs = gethostbyaddr(name)
> UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbb in position 0:
> invalid start byte
>
>
>
> 
> just a empty project,I have done nothing but receive so many errors.I try
> to find some methods to solve it in starkflow or somewhere but,just find a
> unsolved question.
>
> --
> 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/a5580eb5-2b2b-4207-becb-65e183144f2d%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/CALn3ei0WZFSM9qicnxdPmG4JWQ1cM%2BXnvdChoJ1kx%2B3mg6zZAQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Row based permissions: In DB or App? ... farewell pain

2017-08-17 Thread Vijay Khemlani
How can we propose faster alternatives if we don't know how fast must it be?

Of course it is up to you in the end, but if you are seriously considering
exotic options such as using stored procedures at least I would like to
know what specific bottlenecks did you stumble upon as I also use
object-level permissions extensively in my own project and haven't had any
performance issues yet.

If nothing else, your results would prove useful to the community.

On Thu, Aug 17, 2017 at 10:18 AM, guettli <guettli.goo...@thomas-guettler.de
> wrote:

>
>
> Am Mittwoch, 16. August 2017 13:39:53 UTC+2 schrieb Vijay Khemlani:
>>
>> So, please share the specific numbers you got from your profiling.
>>
>>
> Why should I share the numbers? How would this 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/7e009200-1a25-4609-93c3-49117e509e6d%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/7e009200-1a25-4609-93c3-49117e509e6d%40googlegroups.com?utm_medium=email_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Making/Creating a verified user for unit test (django-allauth)

2017-08-17 Thread Vijay Khemlani
Check that the created user has the "is_active" field set to True

On Thu, Aug 17, 2017 at 2:41 AM, Desmond Lim  wrote:

> Hi there,
>
> I'm wonder, how do we create a verified user for testing purpose
>
> I have this line that creates a user
>
> *cls.user = get_user_model().objects.create_user(username='testuser', 
> email='testu...@testing.com ', password='password')*
>
>
> When I do a test of this for my custom login interface
>
>
>
>
>
>
>
>
>
>
>
> *def test_login_page_login_without_verification(self):response = 
> self.client.post(reverse('account_login'),{
> 'login': 'testu...@docdoc.com ','password': 
> 'password',})self.assertRedirects(response, 
> '/accounts/testuser/')*
>
>
> I keep getting the error that it redirects to /accounts/confirm-email/ (which 
> is the verification page). I'm wondering, how can I make the user verified or 
> create a verified user, so that I can test that a verified user will be 
> redirected to the correct page after login.
>
>
> Thanks.
>
>
> Desmond
>
> --
> 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/128591dc-b8c0-4f78-af86-faf7a42f3f0a%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/CALn3ei3NdUrNDfZtf7_66gcvA3Qz7Yukjg%2B43i%3DRgb47XUprLQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Row based permissions: In DB or App? ... farewell pain

2017-08-16 Thread Vijay Khemlani
So, please share the specific numbers you got from your profiling.

On Wed, Aug 16, 2017 at 6:10 AM, guettli <guettl...@gmail.com> wrote:

>
>
> Am Donnerstag, 10. August 2017 14:30:31 UTC+2 schrieb Vijay Khemlani:
>>
>> It's still implemented like that in the background, but I'm not sure why
>> do you call it slow.
>>
>>
>
> Here are more docs about guardian being slow:
>
> http://django-guardian.readthedocs.io/en/stable/userguide/performance.html
>
>
>
>
>> Did you run benchmarks? Profiling?
>>
>>
> Yes, we profiled this. The above link explains it better than I can do it
> :-)
>
> Regards,
>   Thomas Güttler
>
> --
> 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/5b892553-dacf-46f6-81e1-6004924cc474%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/5b892553-dacf-46f6-81e1-6004924cc474%40googlegroups.com?utm_medium=email_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: How to use try..except, but when DEBUG is True, show the error?

2017-08-12 Thread Vijay Khemlani
from django.conf import settings

try:
   x = parse_date('')
except TypeError:
  if settings.DEBUG:
raise
  else:
return False


On Sat, Aug 12, 2017 at 10:54 AM, Fellipe Henrique 
wrote:

> Hello,
>
> i have these code, for example:
>
> try:
>x = parse_date('')
> except TypeError:
>   return False
>
> ​
>
>  It's ok for me code like these.. but, when DEBUG == True, I like to show
> the django default error page...
>
> How can I do that?
>
> Regards
>
> T.·.F.·.A.·. S+F
> *Fellipe Henrique P. Soares*
>
> e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \
> 's/(.)/chr(ord($1)-2*3)/ge'
> *Fedora Ambassador: https://fedoraproject.org/wiki/User:Fellipeh
> *
> *Blog: *http:www.fellipeh.eti.br
> *GitHub: https://github.com/fellipeh *
> *Twitter: @fh_bash*
>
> --
> 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/CAF1jwZF%2Bf2KAZjNWA%2BjVnhTKbSj-
> vQQ4WjQRUzsr5vCxrqg4Eg%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/CALn3ei2t6xh3zjHBbuVC_rjZmw6csnBRQ1gxY7tX-y3741tg_w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Row based permissions: In DB or App? ... farewell pain

2017-08-10 Thread Vijay Khemlani
It's still implemented like that in the background, but I'm not sure why do
you call it slow.

Did you run benchmarks? Profiling?

Usually your own business logic will be the bottleneck of your application,
not your permission checking.

On Thu, Aug 10, 2017 at 5:15 AM, guettli <guettli.goo...@thomas-guettler.de>
wrote:

>
>
> Am Mittwoch, 9. August 2017 18:03:44 UTC+2 schrieb Vijay Khemlani:
>>
>> https://django-guardian.readthedocs.io/en/stable/userguide/
>> check.html#get-objects-for-user
>>
>> projects = get_objects_for_user(request.user, 'projects.view_project')
>>
>>
>>
> Thank you for providing this link. I guess it is new to many developers.
>
> I worked with this method some years ago and it was slow. It was slow
> since the permission checking
> gets done at several ways (via is_superuser, via perms for user, via perms
> for group, ...) But this is old and outdated
> information. I guess this is not true any more.
>
>
>
> --
> 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/afc9ac15-8e61-400a-a36c-c62b5bac22dc%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/afc9ac15-8e61-400a-a36c-c62b5bac22dc%40googlegroups.com?utm_medium=email_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALn3ei3u%3Dk4Js%3DknDkWVAwPSfYVbx5fL78BeFabkAkD1mOT%2Biw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Row based permissions: In DB or App? ... farewell pain

2017-08-09 Thread Vijay Khemlani
https://django-guardian.readthedocs.io/en/stable/userguide/check.html#get-objects-for-user

projects = get_objects_for_user(request.user, 'projects.view_project')


On Wed, Aug 9, 2017 at 10:55 AM, guettli 
wrote:

>
>
> Am Mittwoch, 9. August 2017 10:04:25 UTC+2 schrieb James Schneider:
>
>>
>>
>> On Aug 3, 2017 1:08 AM, "guettli"  wrote:
>>
>> First I asked a similar question on the postgresql-general list. The 
>> discussion[1] has settled there.
>>
>> Now I would love the hear what you think.
>>
>>
>> I am thinking about rewriting an existing application which uses PostgreSQL 
>> via Django.
>>
>> Up to now the permission checks are done at the application level.
>>
>> Up to now queries like: "Show all items which the current user is allowed to 
>> modify" result in complicated SQL and
>> this leads to slow queries.
>>
>> Up to now there is one db-user and the application does the filtering of 
>> rows to prevent application users to see
>> items which they are not allowed to see.
>>
>> I guess most web applications work like this.
>>
>> I would like to reduce the "ifing and elsing" in my python code (less 
>> conditions, less bugs, more SQL, more performance)
>> One important intention for me: I would like to avoid the redundancy. As 
>> soon as I want to query for
>> "Show all items which the current user is allowed to modify" I need the 
>> permission checking in a SQL WHERE condition.
>>
>> If I implement this. Then my code which might look like this is redundant:
>>
>> {{{
>>
>> def has_perm(obj, user):
>> if user.is_superuser:
>> return True
>> ...
>>
>> }}}
>>
>>
>> Yes, I feel farewell pain. I love Python, but I guess I will use perm 
>> checking via SQL WHERE for new projects in the future.
>>
>> What do you think?
>>
>>  Regards,
>>Thomas Güttler
>>
>> [1]: 
>> https://www.postgresql.org/message-id/e662fd8a-6001-514c-71e8-01718444f338%40thomas-guettler.de
>>
>> I thumbed through the threads on the PG list, and the best summary of the
>> answers you received is:
>>
>> A. Yes you can probably do that, but it would likely be extremely
>> complicated and Django won't necessarily make it easy.
>>
>> B. The "problem" you are trying to solve is more of a "preference" with a
>> questionable motive of speed increases.
>>
>>
>> There wasn't a great amount of support for what you are trying to do, and
>> I doubt you'll find much on this list.
>>
>> The DB should not be responsible for business logic (in this case,
>> authorization rules). DB's are only good at storing, searching, and
>> returning data. Data doesn't care who you are, nor does the DBMS past the
>> table level in most cases.
>>
>> There are several other points to consider.
>>
>> - By moving this logic in to the DB, you are almost certainly vendor
>> locking yourself to the DB. If your project is not distributed to others,
>> then it may not be an issue. If you do, abstract away the function calls as
>> much as possible to build an internal Python API. If you need to change the
>> underlying database functionality later, your application code should
>> remain relatively untouched, and you can send the bundle of money in labor
>> you saved to me. ;-)
>>
>> - You'll almost certainly take a performance hit when connecting to the
>> database. If each connection to the DB is using a different user, then you
>> likely cannot take advantage of things like DB connection pooling. Every
>> request would require that a connection be built, utilized, and then torn
>> down. Those operations have a cost in both time and resources.
>>
>> - It likely won't scale well. Assuming you have a fair number of unique
>> users with concurrent connections (depending on the resources available and
>> tuning, this could be as little as a few dozen), your DB now has to manage
>> at least a single connection or
>>
>>
>>
>
>
> My concern is that this python code can't return a queryset with all items
> where a given permission+user tuple match.
>
>
> def has_perm(obj, user):
> if user.is_superuser:
> return True
>
> This means I need a SQL WHERE condition
>
> For example MyModel.objects.filter(Q(...)|Q())
>
> I never wanted business logic in the database. Sorry, if you misunderstood me.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/64d929fa-ea5c-49ca-8b9f-5ff872616435%40googlegroups.com
> 
> .
>
> For more options, visit 

Re: database tables are not being created

2017-08-07 Thread Vijay Khemlani
As far as I know you also need to declare the app_label for each model

class Meta:
app_label = 'your_app_name_here'

On Mon, Aug 7, 2017 at 4:15 PM, Andréas Kühne 
wrote:

> Ok,
>
> Regarding point 2 there - have you added the models to the __init__.py
> file? Imported them as in:
>
> from .model1 import Model1
>
> As far as I have seen, this is needed to make sure the migrations can
> detect the models.
>
> Regards,
>
> Andréas
>
> 2017-08-07 22:09 GMT+02:00 :
>
>>
>> Andreas,
>>
>> The apps are included in the INSTALL_APPS in settings.py
>>
>> With regard to the models file, I'm not sure what you are referring to.
>> In my application there is a driectory 'models' and in that directory,
>> there is a separate file for each model and inside each of those files
>> there is a class for the model that is indirectly derived from models.Model.
>>
>> Jim
>>
>>
>> On Monday, August 7, 2017 at 3:33:18 PM UTC-4, jjander...@gmail.com
>> wrote:
>>>
>>>
>>> I have been working on a django application for several months, learning
>>> as I go. I have run into a problem now and I'm not sure what I should be
>>> doing next.
>>>
>>> Up until now my admin has worked, but I had a problem and a colleague
>>> told me he was pretty sure it was a pycharm bug. He suggested that I remove
>>> the database (db.sqlite3). I did that and I also removed all of the
>>> existing migration files in my development area.
>>>
>>> When I run 'python manage.py makemigrations', I now get the followoing
>>> output:
>>>
>>> /home/jja/.virtualenvs/PivotalBase-2017.6.16/bin/python
>>> /home/jja/prog/newSiggy/manage.py makemigrations
>>> setting.py: BASE_DIR =  /home/jja/prog/newSiggy
>>> FINISHED settings.py
>>> No changes detected
>>>
>>> Process finished with exit code 0
>>>
>>> Then I run 'python manage.py migrate' and my output is:
>>>
>>> /home/jja/.virtualenvs/PivotalBase-2017.6.16/bin/python
>>> /home/jja/prog/newSiggy/manage.py migrate
>>> setting.py: BASE_DIR =  /home/jja/prog/newSiggy
>>> FINISHED settings.py
>>> Operations to perform:
>>>   Apply all migrations: admin, auth, contenttypes, sessions, sites
>>> Running migrations:
>>>   No migrations to apply.
>>>
>>> Process finished with exit code 0
>>>
>>>
>>> I'm not sure what to do next. My models are in place, my 2 admin
>>> directories are in place. I have created an 'xxx_admin' file for each model
>>> and I have registered the admin classes. After running 'makemigrations' and
>>> 'migrate', a db.sqlite3 file exists, but only the django tables are to be
>>> found, not the tables for my models. I'm going through the documentation to
>>> try to figure out if I have missed a step in the process, but so far I have
>>> not found anything.
>>>
>>> Any suggestions?
>>>
>>> Jim A.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/1a4cf7ba-2435-4635-add9-04780f44b6a6%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/CAK4qSCfYkCkMY9h%2B-J--D9qdZ7Fy98me3Po6tX4WYNtKw9psPQ
> %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/CALn3ei36NjSUg7quBKYhjXMMOFqS-LNMhRw1fW77vq74-VaWHA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Row based permissions: In DB or App? ... farewell pain

2017-08-07 Thread Vijay Khemlani
I use django-guardian for object level permissions and it works
surprisingly well

On Mon, Aug 7, 2017 at 4:59 AM, Antonis Christofides <
anto...@djangodeployment.com> wrote:

> Hello,
>
> This is a tricky issue and we need to start from the basics. You already
> know the basics, but they bear repeating. (Related questions are relatively
> common, which is why this is something like the third time I'm pasting this
> information here).
>
> As you know, RDBMS's keep their own list of users and have sophisticated
> permissions systems with which different users have different permissions
> on different tables. This is particularly useful in desktop applications
> that connect directly to the database. Web applications changed that.
> Instead of the RDBMS managing the users and their permissions, we have a
> single RDBMS user as which Django connects to the RDBMS, and this user has
> full permissions on the database. The actual users and their permissions
> are managed by Django itself (more precisely, by the included Django app
> django.contrib.auth), using database tables created by Django. What a user
> can or cannot do is decided by Django, not by the RDBMS. This is a pity
> because django.contrib.auth (or the equivalent in other web frameworks)
> largely duplicates functionality that already exists in the RDBMS, and
> because having the RDBMS check the permissions is more robust and more
> secure. I believe that the reason web frameworks were developed this way is
> independence from any specific RDBMS, but I don't really know.
>
> So the canonical way of working is to have a single *database user* as
> which Django logs on to the database, with full permissions on the database
> (including permission to create and delete tables), and many *Django
> users*, each one with different permissions. Typically only one Django
> superuser is created. I call the superuser "admin", which I believe is the
> common practice.
>
> You can probably do things differently, and maybe there exist custom
> database backends that would allow you to switch the database user on
> login, but if there's no compelling reason you should really stick to the
> canonical way.
>
> So, I agree with you that, in theory, it would be more elegant (and more
> robust and more secure) to do this thing at the db level, and that it is a
> pity that Django and similar systems have moved this functionality from the
> db to the app. However, as I said, without a compelling reason you should
> really stick to the canonical way. The canonical way is more maintainable,
> because it's widely used. It will be easier for other programmers to
> understand what you are doing. Elegance of solution is not compelling
> enough. A compelling reason would be, for example, if you also have a
> desktop application that is controlled by the user and connects directly to
> the database.
>
> Regards,
>
> Antonis
>
> Antonis Christofideshttp://djangodeployment.com
>
>
> On 2017-08-07 09:43, guettli wrote:
>
> Hello this post is now four days old. I would like to hear from other
> people.
>
> Something like:
>
>  "I have no clue what you are talking about" or
>  "I understand your concerns, but I have no clue, too" or
>  "Thank you about talking about this, this raised my awareness"
>
> would make me happy.
>
> Thank you.
>
> Am Donnerstag, 3. August 2017 10:07:53 UTC+2 schrieb guettli:
>>
>> First I asked a similar question on the postgresql-general list. The 
>> discussion[1] has settled there.
>>
>> Now I would love the hear what you think.
>>
>>
>> I am thinking about rewriting an existing application which uses PostgreSQL 
>> via Django.
>>
>> Up to now the permission checks are done at the application level.
>>
>> Up to now queries like: "Show all items which the current user is allowed to 
>> modify" result in complicated SQL and
>> this leads to slow queries.
>>
>> Up to now there is one db-user and the application does the filtering of 
>> rows to prevent application users to see
>> items which they are not allowed to see.
>>
>> I guess most web applications work like this.
>>
>> I would like to reduce the "ifing and elsing" in my python code (less 
>> conditions, less bugs, more SQL, more performance)
>>
>> One important intention for me: I would like to avoid the redundancy. As 
>> soon as I want to query for
>> "Show all items which the current user is allowed to modify" I need the 
>> permission checking in a SQL WHERE condition.
>>
>> If I implement this. Then my code which might look like this is redundant:
>>
>> {{{
>>
>> def has_perm(obj, user):
>> if user.is_superuser:
>> return True
>> ...
>>
>> }}}
>>
>>
>> Yes, I feel farewell pain. I love Python, but I guess I will use perm 
>> checking via SQL WHERE for new projects in the future.
>>
>> What do you think?
>>  Regards,
>>Thomas Güttler
>>
>> [1]: 
>> https://www.postgresql.org/message-id/e662fd8a-6001-514c-71e8-01718444f338%40thomas-guettler.de
>>
>> --
> You received this 

Re: Unable to extend User model and see it in Django Admin

2017-07-29 Thread Vijay Khemlani
AUTH_USER_MODEL should point to your model class, not the model admin

use

AUTH_USER_MODEL = 'user_text.User'

Assuming that the app where the User model lives is called "user_text"

On Sat, Jul 29, 2017 at 12:56 PM, Binny Zupnick  wrote:

> I've tried many things, but I'll write what I currently have implemented.
>
> admin.py
> admin.site.register(User, UserAdmin)
>
> models.py
> class User(AbstractUser):
>  phone = models.CharField(max_length=40, unique=True)
>
> settings.py
> AUTH_USER_MODEL = 'user_text.UserAdmin'
>
> I do `makemigrations` and I'm getting this error:
> Traceback (most recent call last):
>   File "manage.py", line 22, in 
> execute_from_command_line(sys.argv)
>   File "/usr/local/lib/python2.7/dist-packages/django/core/
> management/__init__.py", line 363, in execute_from_command_line
> utility.execute()
>   File "/usr/local/lib/python2.7/dist-packages/django/core/
> management/__init__.py", line 337, in execute
> django.setup()
>   File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line
> 27, in setup
> apps.populate(settings.INSTALLED_APPS)
>   File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py",
> line 108, in populate
> app_config.import_models()
>   File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py",
> line 202, in import_models
> self.models_module = import_module(models_module_name)
>   File "/usr/lib/python2.7/importlib/__init__.py", line 37, in
> import_module
> __import__(name)
>   File "/home/binny/Development/politikal/user_text/models.py", line 7, in
> 
> from django.contrib.auth.admin import UserAdmin
>   File "/usr/local/lib/python2.7/dist-packages/django/contrib/
> auth/admin.py", line 7, in 
> from django.contrib.auth.forms import (
>   File "/usr/local/lib/python2.7/dist-packages/django/contrib/
> auth/forms.py", line 22, in 
> UserModel = get_user_model()
>   File "/usr/local/lib/python2.7/dist-packages/django/contrib/
> auth/__init__.py", line 198, in get_user_model
> "AUTH_USER_MODEL refers to model '%s' that has not been installed" %
> settings.AUTH_USER_MODEL
> django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to
> model 'user_text.UserAdmin' that has not been installed
>
> Some nice people on the internet have advised to remove the
> `AUTH_USER_MODEL` line in `settings.py`. when I remove that line and run
> `makemigrations` I get:
>
> auth.User.groups: (fields.E304) Reverse accessor for 'User.groups'
> clashes with reverse accessor for 'User.groups'.
>  HINT: Add or change a related_name argument to the definition for
> 'User.groups' or 'User.groups'.
> auth.User.user_permissions: (fields.E304) Reverse accessor for
> 'User.user_permissions' clashes with reverse accessor for
> 'User.user_permissions'.
>  HINT: Add or change a related_name argument to the definition for
> 'User.user_permissions' or 'User.user_permissions'.
> user_text.User.groups: (fields.E304) Reverse accessor for 'User.groups'
> clashes with reverse accessor for 'User.groups'.
>  HINT: Add or change a related_name argument to the definition for
> 'User.groups' or 'User.groups'.
> user_text.User.user_permissions: (fields.E304) Reverse accessor for
> 'User.user_permissions' clashes with reverse accessor for
> 'User.user_permissions'.
>  HINT: Add or change a related_name argument to the definition for
> 'User.user_permissions' or 'User.user_permissions'.
>
>
> I've been spending a day on this, am really lost, and would love some
> direction.
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/ee778413-2451-477a-9c98-408567ff41e7%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/CALn3ei0LRNfu0bZ0TJAryZCOFjdfYB%2B1%3Dd%2BSE2E96tTOAzxG%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Dos Modelos en un formulario django

2017-07-28 Thread Vijay Khemlani
Puedes crear un formulario común y corriente de Django

class Formulario(forms.Form):
... campos del usuario
... campos de sus caracteristicas

Y manejar la lógica en tu vista

formulario = Formulario(this.request.POST)
if formulario.is_valid():
  ... actualizar usuario con campos de formulario.cleaned_data
  ... actualizar sus caracteristicas con campos de formulario.cleaned_data

2017-07-27 15:15 GMT-04:00 Nelson Fernando Garcia Gomez <
nefeg...@misena.edu.co>:

> hola Buenas soy algo nuevo en django y me anima aprender cada vez mas,l
> bueno mi inquietud es la siguiente
> como puedo enlazar dos modelos a un formulario
> tengo como modelos usuarios y características y donde el modelo
> características tiene una relacion models.OneToOneField
> con usuarios, quisiera saber como puedo trabajar estos dos modelos en un
> solo formulario con un solo submit
> espero sea claro bueno en fin deseo es crear un solo formulario para
> recoger datos para estos dos modelos y hay si almacenarlos.
> gracias por su colaboración  :)
>
>
>
> *Declinación de Responsabilidades:* Los servicios de MISENA son
> soportados tecnológicamente por © Google y ofrecidos por el Servicio
> Nacional de Aprendizaje – SENA de manera gratuita a los aprendices e
> instructores de programas de formación titulada, las opiniones que contenga
> este mensaje son exclusivas de su autor y no representan la opinión del
> Servicio Nacional de Aprendizaje o de sus autoridades. El receptor deberá
> verificar posibles virus informáticos que tenga el correo o cualquier
> anexo, razón por la cual el SENA no es responsable de los daños causados
> por cualquier virus transmitido en este correo electrónico.
>
> Los contenidos, textos, imágenes, archivos enviados en este mensaje son
> responsabilidad exclusiva del remitente y no reflejan ni comprometen de
> ninguna manera a la institución. No se autoriza el uso de esta herramienta
> para el intercambio de correos masivos, cadenas o spam, ni de mensajes
> ofensivos, de carácter político, sexual o religioso, con fines de lucro,
> con propósitos delictivos o cualquier otro mensaje que se considere
> indebido o que vaya en contra de la Ley.
>
> --
> 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/116eff81-4257-4fa1-a71a-ee11f3f22f0b%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/CALn3ei3uf88qAeg0NKu%3DxBU_Oa%2Bmasw%3D-KVHmVoew_vbV0SsGw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Math filter

2017-07-20 Thread Vijay Khemlani
Don't worry, I only knew about the project because I use it in a small part
of an application that can't execute computations on the view

On Wed, Jul 19, 2017 at 10:02 PM, Mike Morris <m...@musicplace.com> wrote:

> On 07/19/2017 06:20 PM, Vijay Khemlani wrote:
>
>> I'm guessing he's using the mathfilters package
>>
>> https://github.com/dbrgn/django-mathfilters
>>
>
> Arggghhh... my ignorance is showing! I hope I included an "I'm new here"
> disclaimer in the original post!!!
>
> Anyway, never heard of it, I'll take a look!
>
> Thank You Vijay!
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/ms
> gid/django-users/bd06d501-0603-e62e-a34d-01ae014c912d%40musicplace.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/CALn3ei1cU2%2BBX0%3DVTVLbJApB6aAWnmaFhJ%2BjdDHc5iaCQKSAzw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Math filter

2017-07-19 Thread Vijay Khemlani
I'm guessing he's using the mathfilters package

https://github.com/dbrgn/django-mathfilters

On Wed, Jul 19, 2017 at 7:28 PM, Mike Morris  wrote:

> Of course, if they're integers you could implement the "mul" as a loop of
> "add"s... clumsy, but would work.
>
> On 07/19/2017 03:39 PM, Mike Morris wrote:
>
> I am a newbie, but I think the answer is that you can't do that in the
> template - instead, calculate the number in the view and pass it to the
> template in the context dictionary.
>
> I think it's a design philosophy of Django Template Language to not
> support this as it muddies the border between data and presentation.
> They've obviously made some exceptions for the really common/easy use cases
> - like "|add"
>
> There are other template languages that do support that of course; if its
> important enough you could look at changing the template engine...
>
>
>
>
> On 07/18/2017 07:21 PM, sum abiut wrote:
>
> Hi,
> needed direction maths filters on django templates. for example how to you
> perform this on a template.
>
> a*b +b*c
>
> i did  a|mul:b|add:b|mul:cbut got a wrong answer. Please point me
> to right direction.
>
> cheers,
> --
> 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/CAPCf-y648sfPwKJWLmRtcx6tfC_PZP6RP6PjUvCmzRKVfOH%3DSg%
> 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/0ff382b8-ecfa-e1ab-43f4-f47bcde5b274%40musicplace.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/735d3169-5d8f-dfb7-84cf-ba87a490573d%40musicplace.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/CALn3ei0QOWrZheHH0FC4JLD929pbhVFS9TrL%2Buhf2%2BDK1nymdA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Math filter

2017-07-19 Thread Vijay Khemlani
Also I guess mathfilters just executes left-to-right

so

a|mul:b|add:b|mul:c

is (((a * b) + b) * c)

On Wed, Jul 19, 2017 at 1:50 AM, James Schneider 
wrote:

>
>
> On Jul 18, 2017 7:21 PM, "sum abiut"  wrote:
>
> Hi,
> needed direction maths filters on django templates. for example how to you
> perform this on a template.
>
> a*b +b*c
>
> i did  a|mul:b|add:b|mul:cbut got a wrong answer. Please point me
> to right direction.
>
>
> I wouldn't do any sort of advanced math in the template. It should be
> completed in the view and added to the template context, then referenced as
> a template variable. The template processor has no concept of the order of
> operations in math.
>
> -James
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CA%2Be%2BciWfni0w6XZmfqrjnsrTLiWZLh0N
> Wu9ye%2BA_Cm0NDb6x3A%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/CALn3ei3eX0FOfV2aNMZJbNawsW1ywVRn%2BLKb86V_23uXW9cisQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django webframework

2017-07-03 Thread Vijay Khemlani
You can use Django even if you are new to Python, but it will be more
difficult (basically learning 2 things at the same time).

You can run a django application over tomcat using Jython and
django-jython, but I've never done so myself

https://docs.djangoproject.com/en/1.11/howto/jython/

On Mon, Jul 3, 2017 at 1:48 AM, arun kumar  wrote:

> Hi,
>
> My name is arun and i am a junior software engineer.i am very new with
> python and i want to develop a web project so first i have selected python
> script but after doing some online research i found routing is very
> difficult in python if you are a new programmer in pyhton
>
> so i finally decided to do this project with django because it supports
> mvc.so i need your valuable suggestion if  i am new with pyhton is it ok to
> go for django framework because i think documentation for django is very
> good and it has less code and it supports many databases also.
>
> so please help me currently i am using windows so i want to ask which is
> better linux or windows and apache tomcat is also required for this web
> application project so basically i need a overview for django how to use
> whether to use.
>
> --
> 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/0942dee0-72c3-4f64-8e0c-a7d3607253b2%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/CALn3ei1brmrDKqtTGWrFFn%3DuAThaoha1bjt7gXV5KBr8mwi5Pg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django signals **kwargs

2017-06-27 Thread Vijay Khemlani
Same link

https://docs.djangoproject.com/en/1.11/ref/signals/#post-save

post_save¶ <https://docs.djangoproject.com/en/1.11/ref/signals/#post-save>
django.db.models.signals.post_save¶
<https://docs.djangoproject.com/en/1.11/ref/signals/#django.db.models.signals.post_save>

Like pre_save
<https://docs.djangoproject.com/en/1.11/ref/signals/#django.db.models.signals.pre_save>,
but sent at the end of the save()
<https://docs.djangoproject.com/en/1.11/ref/models/instances/#django.db.models.Model.save>
 method.

Arguments sent with this signal:
senderThe model class.instanceThe actual instance being saved.createdA
boolean; True if a new record was created.rawA boolean; True if the model
is saved exactly as presented (i.e. when loading a fixture). One should not
query/modify other records in the database as the database might not be in
a consistent state yet.usingThe database alias being used.update_fieldsThe
set of fields to update as passed to Model.save()
<https://docs.djangoproject.com/en/1.11/ref/models/instances/#django.db.models.Model.save>,
or None if update_fieldswasn’t passed to save().

On Tue, Jun 27, 2017 at 4:48 PM, yingi keme <yingik...@gmail.com> wrote:

> Okk.
>
> But what i am actually asking is, what type of contents does the **kwargs.
> Give me a typical example of **kwargs in the context of signals. The actual
> data **kwargs may contain.
>
> Yingi Kem
>
> On 27 Jun 2017, at 9:24 PM, Vijay Khemlani <vkhem...@gmail.com> wrote:
>
> https://docs.djangoproject.com/en/1.11/topics/signals/#receiver-functions
>
> We’ll look at senders a bit later, but right now look at the **kwargs
> argument. All signals send keyword arguments, and may change those keyword
> arguments at any time. In the case of request_finished, it’s documented as
> sending no arguments, which means we might be tempted to write our signal
> handling as my_callback(sender).
>
> This would be wrong – in fact, Django will throw an error if you do so.
> That’s because at any point arguments could get added to the signal and
> your receiver must be able to handle those new arguments.
>
>
> On Tue, Jun 27, 2017 at 4:14 PM, yingi keme <yingik...@gmail.com> wrote:
>
>> So i want to know, when using a model signals. The reciever function has
>> **kwargs. What is the content of **kwargs in this reciever function below:
>>
>> @reciever(post_save, sender=MyModel)
>> def func(sender, instance, **kwargs):
>> # some action.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/504e60a9-9ef7-4dc6-a1a8-ab734f250455%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/CALn3ei0kP77zFO_WDPDptZPg7GWOdkyZwtN6sJ9W07d9r
> uZicg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CALn3ei0kP77zFO_WDPDptZPg7GWOdkyZwtN6sJ9W07d9ruZicg%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/C07282C1-3DFC-4787-9F52-9C12B07A0AE3%40gmail.com
> <https://groups.google.com/d/msgid/django-users/C07282C1-3DFC-4787-9F52-9C12B07A0AE3%40gmail.com?utm_medium=email_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe f

Re: Django signals **kwargs

2017-06-27 Thread Vijay Khemlani
https://docs.djangoproject.com/en/1.11/topics/signals/#receiver-functions

We’ll look at senders a bit later, but right now look at the **kwargs
argument. All signals send keyword arguments, and may change those keyword
arguments at any time. In the case of request_finished, it’s documented as
sending no arguments, which means we might be tempted to write our signal
handling as my_callback(sender).

This would be wrong – in fact, Django will throw an error if you do so.
That’s because at any point arguments could get added to the signal and
your receiver must be able to handle those new arguments.


On Tue, Jun 27, 2017 at 4:14 PM, yingi keme  wrote:

> So i want to know, when using a model signals. The reciever function has
> **kwargs. What is the content of **kwargs in this reciever function below:
>
> @reciever(post_save, sender=MyModel)
> def func(sender, instance, **kwargs):
> # some action.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/504e60a9-9ef7-4dc6-a1a8-ab734f250455%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/CALn3ei0kP77zFO_WDPDptZPg7GWOdkyZwtN6sJ9W07d9ruZicg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: NOVICE Question; Installing Django 1.11.2 in Python 3.6 with the correct path

2017-06-27 Thread Vijay Khemlani
You should run pip from the command line, not from inside the python
interpreter shell

On Tue, Jun 27, 2017 at 11:25 AM,  wrote:

> A a Novice to Python and to Django How do i install Django into the
> correct path , I followed the instruction in a Django manual and got an
> error message; How do I install Django 1.11.2  on windows 10 with the
> following sys path
> >>> import sys
> >>> sys.path
> ['C:/Users/hlidd/AppData/Local/Programs/Python/Python36',
> 'C:\\Users\\hlidd\\AppData\\Local\\Programs\\Python\\Python36\\Lib\\idlelib',
> 'C:\\Users\\hlidd\\AppData\\Local\\Programs\\Python\\Python36\\python36.zip',
> 'C:\\Users\\hlidd\\AppData\\Local\\Programs\\Python\\Python36\\DLLs',
> 'C:\\Users\\hlidd\\AppData\\Local\\Programs\\Python\\Python36\\lib',
> 'C:\\Users\\hlidd\\AppData\\Local\\Programs\\Python\\Python36',
> 'C:\\Users\\hlidd\\AppData\\Local\\Programs\\Python\\
> Python36\\lib\\site-packages']
> >>> pip install Django == 1.11.2
> SyntaxError: invalid syntax
>
> Do I have Python in the correct path? Am I calling Django with the correct
> path? Python seems to work okay but am I storing my nascent programs into
> the right directory.? If I install Django with these paths will my work go
> to the right directory? Or am I looking at the problem all wrong and it is
> not the dicrectories at all but me that is misguided by the instruction
> book's to use  ">>> pip install Django ==1.11.2"?
> Any help or path(excuse the pun) I can go down to  tolearn how to
>  establish Django 1.11.2 on my machine? I am reading and
> absobing "Mastering Django: Core ". ANy help will be appreciated.
>
> --
> 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/f3d6d2c3-34d6-4a54-8015-7a93c5fb160b%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/CALn3ei07t%3Dpd%2BTGYWwjFOCLppOxFCuLtCPXnvR5iKx%3DtWwxDwg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: 'migrate' does not find existing postgres database

2017-06-26 Thread Vijay Khemlani
Maybe I'm misunderstanding, but you don't access PostgreSQL databases
as normal files with a path.

If you were using SQlite that might work, but not on typical SQL
databases (MySQL, Postgres, etc)

On 6/26/17, Rich Shepard  wrote:
>This is my first django project and is intended for my own use, but I'll
> put it on git-hub when it's working.
>
>The database backend is postgresql-9.6.3 and exists in /var/www/htdocs/.
> When I run 'python3 manage.py migrate' django looks for the database in
> ~/development/crm_project/crm/ and does not find it there. In settings.py I
> have defined the engine:
>
> DATABASES = {
>  'default': {
>  'ENGINE': 'django.db.backends.postgresql',
>  'NAME': os.path.join(BASE_DIR, 'crm'),
>  'USER': 'rshepard',
>  'PASSWORD': '',
>  'HOST': '',
>  'PORT': '5432',
>  }
> }
>
>Again, this is for my use and the database with its existing tables
> lives
> in the same cluster with all my other databases. And, each table will be a
> separate app; the models have been translated from sql to django.
>
>I'd appreciate suggestions on how to proceed.
>
> Rich
>

-- 
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/CALn3ei0LPf0DioV3ed%2BfAuZEnECjOp7NF1Q8-iriSLE%2B2-Wbow%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ModuleNot Found Error

2017-06-26 Thread Vijay Khemlani
Could you post the stack trace of the error?

On Mon, Jun 26, 2017 at 5:35 AM, akhil kumar  wrote:

> this is my polls/urls.py
>
>
> from django.conf.urls import url
> from . import views
>
> urlpatterns=[
> url(r'^$',views.index,name='index'),
>]
>
>
>
> mysite/urls.py
>
>
> from django.conf.urls import include,url
> from django.contrib import admin
>
> urlpatterns = [
> url(r'^polls/',include('polls.urls',namespace="polls")),
> url(r'^admin/', admin.site.urls),
>]
>
>
>
> settings.py
>
>
>
>
> INSTALLED_APPS = [
> 'polls.apps.PollsConfig'
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> ]
>
>
>
> models.py
>
>
> from django.db import models
>
> # Create your models here.
> class Question(models.Model):
> question_text=models.CharField(max_length=500)
> pub_date=models.DateTimeField('date published')
>
> class choice(models.Model):
> Question=models.ForeignKey(Question,on_delete=models.CASCADE)
> choice_text=models.CharField(max_length=500)
> votes=models.IntegerField(default=0)
>
>   --
> 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/ef68772a-877a-482f-9ead-1b69125b23aa%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/CALn3ei1N8FrhS85oS5uwA3S0FFN6rhpR4U5b%2Bo9oKpT7GBP0gw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Retrieve field values from ManyToMany field in model

2017-06-25 Thread Vijay Khemlani
A DocumentMetaData instance may be associated with multiple documents
and multiple metadata according to your model, so your question is
ambiguous.

If you want a particular DocumentMetaData to only refer to a single
document and a single metadata then change the ManyToManyField for a
ForeignKey

If you do that then you can do self.document.title and
self.metadata.name to access those fields.

On 6/25/17, Mark Phillips  wrote:
> I have this class
>
> class DocumentMetaData(models.Model):
> document = models.ManyToManyField(Document)
> metadata = models.ManyToManyField(MetaData)
> metadatavalue = models.ManyToManyField(MetaDataValue)
>
> def __str__(self):
> return "%s - %s" % (self.document, self.metadata)
>
> The Document class has a field called 'title' and the Metadata class has a
> field called 'name'. How do I accesses these two fields from the class
> DocumentMetaData so the string output is something like  -
> <
> metadata.name>?
>
> Thanks!
>
> Mark
>
> --
> 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/CAEqej2NCVAp07CvESrUnR7k61UG4b0_q5OcaemfOrh%2B77mnTdQ%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/CALn3ei0k-kV42aK%2BcT0%2By5jLGtaZOG3U2YPGT35j1nixJFxn9g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: null value in column violates not-null constraint

2017-05-25 Thread Vijay Khemlani
"form.instance.user"

should be

"form.instance.seller"

But the "null value in column" error could also apply to any of the
non-nullable fields in your Product model that are not set by the time
you save the instance.

On 5/25/17, Ismail Sarenkapic  wrote:
> Tnx.
> The slug is not important here.
> The main question is how do I add product  with current user!
>
> On Thursday, May 25, 2017 at 8:00:08 PM UTC+2, Muhammad wrote:
>>
>> Ismail,
>>
>> You don't seem to be handling the value for Product.slug anywhere, either
>>
>> in the model or the view.
>>
>> You can fix the slug issue by overriding the Product model's save ()
>> method like this:
>>
>> def save (self, *args, **kwargs):
>>  if not self.slug:
>> self.slug = slugify(self.title)
>> super(Product, self).save (*args, **kwargs)
>>
>> This way, you can automatically generate the value of the slug field when
>>
>> a valid form is submitted.
>>
>> If you are still having problems, please, do let us know.
>>
>> All the best.
>>
>> Sincerely,
>> Muhammad
>>
>> On May 25, 2017 7:20 AM, "Ismail Sarenkapic" > > wrote:
>>
>> Hi, I'm trying to create a digital marketplace site where users will be
>> able to register and submit their products.
>> I created the Product model and connected it with User with foreign
>> key.Everything seems  to be alright, but when I submit my product i get
>> the
>> following error:
>>
>> null value in column violates not-null constraint
>>  it looks like relation between product and user is not properly
>> configured(regardless of my mixin that is suppose to handle it)
>>
>> __
>> note that I'm using:
>>
>> database:postgresql
>>
>> allauth(for user registration)
>>
>> __
>>
>> 
>> models.py
>>
>> from django.conf import settings
>> from django.db import models
>> from django.db.models.signals import pre_save, post_save
>> from django.core.urlresolvers import reverse
>> from django.utils.text import slugify
>> # Create your models here.
>>
>>
>>
>> class Product(models.Model):
>>seller = models.ForeignKey(settings.AUTH_USER_MODEL)
>>#user = models.OneToOneField(settings.AUTH_USER_MODEL)
>># user = models.ForeignKey(settings.AUTH_USER_MODEL)
>># managers = models.ManyToManyField(settings.AUTH_USER_MODEL,
>> related_name="managers_products", blank=True)
>>title = models.CharField(max_length=30)
>> #owiuerpoajsdlfkjasd;flkiu1p3o4u134123 ewjfa;sd
>>slug = models.SlugField(blank=True, unique=True)
>>description = models.TextField()
>>price = models.DecimalField(max_digits=100, decimal_places=2,
>> default=9.99, null=True,) #100.00
>>
>>
>>def __unicode__(self): #def __unicode__(self):
>>   return self.title
>>
>> ___
>> views.py
>>
>>
>> from django.views import View
>> from django.views.generic import (
>> CreateView,
>> )
>>
>> from .forms import ProductModelForm
>> from .mixins import FormUserNeededMixin
>> # Create your views here.
>>
>>
>> class ProductCreateView(FormUserNeededMixin, CreateView):
>> form_class = ProductModelForm
>> template_name = 'create_view.html'
>>
>> ___
>> forms.py
>>
>> from django import forms
>>
>> from django.utils.text import slugify
>>
>> from .models import Product
>>
>>
>> class ProductModelForm(forms.ModelForm):
>>class Meta:
>>   model = Product
>>   fields = [
>>  "title",
>>  "description",
>>  "price",
>>   ]
>>
>> 
>> mixins.py
>>
>> from django import forms
>> from django.forms.utils import ErrorList
>>
>> class FormUserNeededMixin(object):
>>
>>  def form_valid(self, form):
>> if self.request.user.is_authenticated():
>> form.instance.user = self.request.user
>> return super(FormUserNeededMixin, self).form_valid(form)
>> else:
>> form._errors[forms.forms.NON_FIELD_ERRORS] = ErrorList(["User
>> must be logged in to continue."])
>> return self.form_invalid(form)
>>
>>
>>
>>
>>
>>
>>
>> --
>> 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/0d2d44eb-a2df-4f00-8d60-3f163ed72c9b%40googlegroups.com
>>
>> 
>> .
>> For more options, visit 

Re: Unicode error in __unicode__(self) function

2017-05-09 Thread Vijay Khemlani
Paste the whole stack traceof the error

On 5/9/17, rmschne  wrote:
>
>
>> I'm sorry - but this isn't your real error.
>>
>> You will see it in your WSGI daemon logs once you set DEBUG to false.
>>
>>
>>
>> This error is caused by Django trying to print the error using ascii codec
>>
>> for the debug output (I haven't chased it down any further and I should
>> really report it).
>>
>>
>>
>> As said, your real error is somewhere else and that will probably make
>> more sense.
>>
>>
>>
>> --
>>
>> Melvyn Sopacua
>>
>
> Melvyn,
>
> Thanks. I understand what you are saying. Obvious, but I didn't notice
> that. However, I do think it's a Django bug. This app is not running on a
> web server so there is no WSGI daemon.  Do you have a suggestion on what I
> can do to get a better detection of the error to enable reporting it?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b3ed676d-811a-4c53-b176-bd460f5dd54a%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/CALn3ei13o3uH%2BVZK%3D6BE7tvf82KW6ccRPrP%3DfcHwZVyY9PydFA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: get method inside class based view

2017-05-07 Thread Vijay Khemlani
Assuming this view is for a path like

http://example.com/shortener

If you make a GET request to it (as in navigating to it in a browser)
it displays the form calling the "get" method in the view. When you
submit the form it usually does so to the same URL but with the POST
method.

So in this case, GET => Displays form, POST => Handles form submission

On 5/7/17, Daniel Roseman  wrote:
>
>
> On Sunday, 7 May 2017 17:21:10 UTC+1, Ismail Sarenkapic wrote:
>>
>> The question is, what is the purpose of get method here,when we have post
>>
>> method
>> is it useless in this case?If not what is function of get method?
>>
>>
> Why would it be useless? The get method is for GET requests, the post
> method is for POST requests.
> --
> DR.
>
> --
> 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/c97e45cc-140e-4493-a697-3c214517bc99%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/CALn3ei3%2BjHMwrN4uB6FE-1_z7cRQkGrVm2aZxvmM2ZeU-8r3Xg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: makemigration detect error

2017-05-06 Thread Vijay Khemlani
You are adding a non-null field to a table, so the existing rows from
that table need a value to put in it to enforce the non-null rule.

If you select 1, you type that value, and it is used for all
previously existing rows in the table.

On 5/6/17, Er. Rv Ranga  wrote:
>  python manage.py makemigrations blog
>
> You are trying to add a non-nullable field 'body' to post without a
> default; we can't do that (the database needs something to populate
> existing rows).
> Please select a fix:
>  1) Provide a one-off default now (will be set on all existing rows with a
> null value for this column)
>  2) Quit, and let me add a default in models.py
> Select an option:
>
> what is this and how we solve it
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4fd75ea1-3963-45bb-8411-7e3edf7d960c%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/CALn3ei1FAHx06cRLN4EnV-y3jjky8BSWMk_Q92X13qD1SefDXg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Make a separate table for a model without additional fields

2017-05-01 Thread Vijay Khemlani
Why do you need an additional model for automatic payments?

I don't know the whole project, but I would just add a field to the
Payment class



On 5/1/17, Victor Porton  wrote:
> I store into the DB payments received through PayPal. Every payment is
> either manual or automatic (automatic payments are done for the user by
> PayPal automatically, based on user's permission to pay in the future). I
> wish to distinguish manual and automatic payments in the DB. But in the
> following code both regular payments and automatic payments share the same
> table, so that they cannot be distinguished. I ask for an advice how to
> make them distinct in the DB. The best thing I invented insofar is to add
> `dummy = models.SmallIntegerField()` to AutomaticPayment class, to allocate
>
> a new table for it. Are there better ways?
>
> class Payment(models.Model):
> transaction = models.OneToOneField('BaseTransaction')
> email = models.EmailField(null=True)
>
> class AutomaticPayment(Payment):
> pass
>
> By the way, it is an open source project, so you will benefit from my work.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/2e6e83b6-616a-4fc8-9abc-32d2ce25e247%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/CALn3ei0ERr8kmX1keQ2sAo44qj8toZrPNDakNkxLAxSATAEWuQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Models not appearing in Admin page.

2017-04-25 Thread Vijay Khemlani
Register in in the admin.py file

https://docs.djangoproject.com/en/1.11/intro/tutorial02/#make-the-poll-app-modifiable-in-the-admin

On Tue, Apr 25, 2017 at 9:46 AM, Ratul Shams  wrote:

> Hey Pythonistas!
> I was working on Django and made a Model, but its not appearing on my
> Django Admin page even after migrating.
>
>
> https://pastebin.com/A2QiLEhp
>
>
> Suggestions will help people!
>
> 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/32ef42c5-90b6-4692-bf89-66f7aedd31c4%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/CALn3ei0NYZmwkqjaiYzp1fAaEYMynCpbMLJJxzyMCV06VvLO3A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to set mysql database in setting up django setup in eclipse ?

2017-04-23 Thread Vijay Khemlani
I don't use Eclipse for development, but your screenshot says "Django
version 1.1 or earlier" which is awfully old, we are at 1.11, as in
there was a versions 1.2 1.3 1.4 1.5  1.11.

settings file has changed a lot since that time.

On 4/23/17, Pubudu Goonetilleke  wrote:
> Hi,
> I am very new to web programming and trying to learn ABCs of this whole new
>
> thing. I am following some online tutorials and facing some few things that
>
> I am trying to understand.
> first, when I create dJango (1.11) project in eclipse (Neon 3) in pyDev
> (latest), I set data base information as follows :
>
> 
>
>
> new my issue is that when I open the *settings.py *it does not show the
> setting as I expect.
> it is like follows :
>
> 
>
>
>
> what I expect as per the tutorials is as follows : (I manually typed it)
>
>
> 
>
>
> I know I could type this into the *setting.py, *but trying to understand
> why does it not create that automatically during setup since that
> information is already entered in the dialog.
>
> Thank you for the help in advance.
>
>
> Thanks,
>
> Pubudu
>
>
>
>
> --
> 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/9f30f786-adae-455f-8411-ab4a29645079%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/CALn3ei04Vp9wck79BnmnMRdkgZZi%2BZQQowBf%2Bpv6RqwV42gqTQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django forks

2017-04-17 Thread Vijay Khemlani
I'm not trying to scare anyone

If you need particular form widgets or fields not readily available in
Django I would prefer to write an app that includes them instead of forking
the whole framework.

On Mon, Apr 17, 2017 at 12:39 PM, Matthew Pava  wrote:

> Well, since web2py is in Python, you might find some inspiration there for
> any extensions or improvements to Django that you would like to see.  Why
> reinvent the wheel, you know?
>
> -Original Message-
> From: django-users@googlegroups.com [mailto:django-users@googlegroups.com]
> On Behalf Of Jamesie Pic
> Sent: Monday, April 17, 2017 10:19 AM
> To: django-users@googlegroups.com
> Subject: Re: Django forks
>
> Matthew, using another framework for new projects would be a tempting
> solution, if I was not already maintaining god knows how many Django apps
> and projects, and basically had not been capitalizing on Django itself for
> the last decade.
>
> Vijay, that RoR failed at it, fails to scare me out, and does not look
> like a logic argument *for me*. I'm a lot more comfortable with failing
> than with not trying. And even if it was really "impossible"
> and that I fail to understand it, I'm not saying it would be better for
> you anyway, I'm just looking for other people who think it would serve them
> too, hence my initial questions, where are forks ?
>
> --
> 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/CAC6Op1_4skkvV0PVxAxjsShG%3DD5ryF6uYypwtL2v2UhN8ZGMSw%
> 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/ab7afe0af29e4d57bcf6724aa81517ea%40ISS1.ISS.LOCAL.
> 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/CALn3ei2ToOVLabQLs50eMtNDimuBCofUjSG_htpoqBv_ixhd4w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django forks

2017-04-17 Thread Vijay Khemlani
Django is essentially a backend development framework (essentially receive
http request, make http response)

Ruby on Rails tried to integrate with a javascript "framework" in its time
(Prototype / Scriptaculous if I remember correctly) and it exploded on
their faces in my humble opinion.

On Mon, Apr 17, 2017 at 12:01 PM, Matthew Pava  wrote:

> Something you may want to consider is web2py.  It has a lot out of the box.
> http://www.web2py.com/
>
>
>
> -Original Message-
> From: django-users@googlegroups.com [mailto:django-users@googlegroups.com]
> On Behalf Of Jamesie Pic
> Sent: Monday, April 17, 2017 9:58 AM
> To: django-users@googlegroups.com
> Subject: Re: Django forks
>
> Dear Andréas,
>
> During the past decade, I have fought that model fields do not have usable
> form fields out of the box.
>
> "Django doesn't want to couple a JS framework", is what I remember from
> discussions. For me, having JS enabled form fields does not mean
> **removing** support for pure-HTML form fields, so, nobody would be
> actually "coupled with a JS framework". And, supporting one JS framework
> doesn't mean Django couldn't support other framework neither.
>
> I'd like to try a Django fork that LOVES javascript and out of the box
> experience. Currently, the philosophy in Django is "if it can be in an app
> then it should be in an app", which opposes what "improving ootb
> experience" means for me.
>
> Also, I'd like it to make it easier for newbies to install Django
> projects, I've posted about this in a thread about DJANGO_SETTINGS_FILE on
> django-dev.
>
> And of course, I'd like a fork that's easy to contribute to, iterate with,
> so that features can mature outside of Django before being proposed
> upstream. I'm up for helping others on their features too of course ;)
>
> Best,
> Jamesie
> <3
>
> --
> 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/CAC6Op1_TS58kQUnDv0_3vXtF%3DbnsUaqtOe7zq2f8kKe4XBsssw%
> 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/622fa051501f48bd9dc72865ca42c8d4%40ISS1.ISS.LOCAL.
> 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/CALn3ei2J8miNWupexEEADOq5uz0axSOiOZ%2BomWUxAmA3zXhjBw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error with Tutorial - Writing your first Django app, part 1

2017-04-12 Thread Vijay Khemlani
In the first case he mispelled "urlpatters", it should be "urlpatterns"
(notice the n)

On Wed, Apr 12, 2017 at 3:47 PM, Lynn Capps  wrote:

> Shah,
>
> Did you get this figured out? I am having the same issue as you did.
>
>
>
> On Friday, December 9, 2016 at 1:50:22 PM UTC-6, shah wrote:
>>
>> Hi, I am facing the same issue with the tutorial.
>>
>> I have got my program correct. But after running the sever. It shows an
>> error on chrome.
>>
>> Page not found (404)
>> Request Method: GET
>> Request URL: http://localhost:8000/polls/
>>
>> Using the URLconf defined in mysite.urls, Django tried these URL
>> patterns, in this order:
>>
>>1. ^admin/
>>
>> The current URL, polls/, didn't match any of these.
>>
>> You're seeing this error because you have DEBUG = True in your Django
>> settings file. Change that to False, and Django will display a standard
>> 404 page.
>>
>> Since this is first ste of tutorial. I am not able to move forward. Thanx
>> for rely in advance.
>>
>> On Tuesday, 11 October 2016 02:12:30 UTC+5:30, Johnny McClung wrote:
>>>
>>> I am getting an error when I try to run the Django server.
>>>
>>> >> mysite >> polls >> urls.py
>>> from django.conf.urls import url
>>>
>>>
>>> from . import views
>>>
>>> urlpatters = [
>>> url(r'^$', views.index, name='index'),
>>> ]
>>>
>>>
>>>
>>>
>>> >> mysite >> mysite >> urls.py
>>> from django.conf.urls import include, url
>>> from django.contrib import admin
>>>
>>> urlpatterns = [
>>> url(r'^polls/', include('polls.urls'))
>>> url(r'^admin/', admin.site.urls),
>>> ]
>>>
>>>
>>>
>>> Error:
>>>
>>> E:\Dropbox\Python Scripts\mysite>python manage.py runserver
>>> Performing system checks...
>>>
>>> Unhandled exception in thread started by >> check_errors..wrapper at 0x03F616A8>
>>> Traceback (most recent call last):
>>>   File "C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib
>>> \site-packages\django\utils\autoreload.py", line 226, in wrapper
>>> fn(*args, **kwargs)
>>>   File "C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib
>>> \site-packages\django\core\management\commands\runserver.py", line 121,
>>> in inner_run
>>> self.check(display_num_errors=True)
>>>   File "C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib
>>> \site-packages\django\core\management\base.py", line 374, in check
>>> include_deployment_checks=include_deployment_checks,
>>>   File "C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib
>>> \site-packages\django\core\management\base.py", line 361, in _run_checks
>>> return checks.run_checks(**kwargs)
>>>   File "C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib
>>> \site-packages\django\core\checks\registry.py", line 81, in run_checks
>>> new_errors = check(app_configs=app_configs)
>>>   File "C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib
>>> \site-packages\django\core\checks\urls.py", line 14, in check_url_config
>>> return check_resolver(resolver)
>>>   File "C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib
>>> \site-packages\django\core\checks\urls.py", line 24, in check_resolver
>>> for pattern in resolver.url_patterns:
>>>   File "C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib
>>> \site-packages\django\utils\functional.py", line 35, in __get__
>>> res = instance.__dict__[self.name] = self.func(instance)
>>>   File "C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib
>>> \site-packages\django\urls\resolvers.py", line 313, in url_patterns
>>> patterns = getattr(self.urlconf_module, "urlpatterns",
>>> self.urlconf_module)
>>>   File "C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib
>>> \site-packages\django\utils\functional.py", line 35, in __get__
>>> res = instance.__dict__[self.name] = self.func(instance)
>>>   File "C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib
>>> \site-packages\django\urls\resolvers.py", line 306, in urlconf_module
>>> return import_module(self.urlconf_name)
>>>   File 
>>> "C:\Users\geek\AppData\Local\Programs\Python\Python35-32\lib\importlib\__init__.py",
>>> line 126, in import_module
>>> return _bootstrap._gcd_import(name[level:], package, level)
>>>   File "", line 986, in _gcd_import
>>>   File "", line 969, in _find_and_load
>>>   File "", line 958, in
>>> _find_and_load_unlocked
>>>   File "", line 673, in _load_unlocked
>>>   File "", line 661, in
>>> exec_module
>>>   File "", line 767, in get_code
>>>   File "", line 727, in
>>> source_to_code
>>>   File "", line 222, in
>>> _call_with_frames_removed
>>>   File "E:\Dropbox\Python Scripts\mysite\mysite\urls.py", line 21
>>> url(r'^admin/', admin.site.urls),
>>>   ^
>>> SyntaxError: invalid syntax
>>>
>>>
>>> Any help would be appreciated. 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
> 

Re: Manage.py runserver is showing somthing else

2017-04-12 Thread Vijay Khemlani
Please copy and paste the whole stack trace (the messages on the command
prompt)

On Wed, Apr 12, 2017 at 3:01 PM, Divya Rajpurohit 
wrote:

> I started learning django a few days ago & i am trying to run a example
> project for a demo but when i put this command "manage.py runserver" it
> show so many lines on cmd promt & at end line showing 'invalid character'
> it's not showing those result which showed in documentation of django & for
> this i check my environment path but it having that /python36 i am using
> python in windows os if anyone knows what's going wrong tell me waiting for
> reply
>
> --
> 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/d4427871-2ff4-4e30-8d82-1607ad06eb1e%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/CALn3ei2hTuj1eMeEguTeW7m3vSUSLp-kUimY7ch5ofqajZ0F_g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Will function based views ever be deprecated?

2017-04-03 Thread Vijay Khemlani
Any function based view can be reduced to a CBV trivially

class MyView(View):
   def get(request):# or post, or whatever http method
  

Point is there are patterns that repeat themselves enough to justify CBV,
aside from the benefits of using classes (inheritance, mixins, etc).

Also

"I can write just about any view I want in less than 5 minutes with a
function based view. The only slow down on my end is my typing speed."

If your typing speed is the limiting factor in your workflow... *shudders*

On Mon, Apr 3, 2017 at 12:01 PM, Some Developer 
wrote:

> Try doing something that a class based view doesn't support out of the box
> and then you'll understand why function based views are still used. Even
> something as simple as returning some JSON means you have to dig into how a
> class based view works where as it is about 3 lines of code in a function
> based view.
>
> Then what about a view that has to handle 2 (or more) different form
> classes on the same page? You'll soon find that having to do that in a
> class based view means major work rewriting or building your own class
> based view.
>
> As I said I'll give them another go but I've yet to be convinced of their
> greatness.
>
> On 03/04/2017 15:54, Andréas Kühne wrote:
>
>> I find it interesting that so many haven't embraced the new CBV's. I
>> ONLY use CBV's when designing and find the usages much simpler - because
>> of no boilerplate and also the fact that I can derive from other classes
>> when needed.
>>
>> Of course - the first time you use a form view or a template view and
>> you find yourself having problems - debugging that could take a while,
>> however, once you have done that I really haven't seen this as an issue.
>> Also because most of the default views inherit from the same mixins -
>> once you have understood how one works - you usually get the hang of it.
>>
>> It could be that the first thing I did in django was to refactor views
>> from function based to class based - and therefore haven't started
>> exploring FBV's more :-)
>>
>> Just my 2 cents...
>>
>> Regards,
>>
>> Andréas
>>
>> 2017-04-03 13:52 GMT+02:00 Some Developer > >:
>>
>>
>> Hi,
>>
>> Awesome thanks. I can see the reason for some class based views as
>> they remove the need for boilerplate code but if you run into a
>> problem with them for whatever reason you generally have to dig out
>> the Python debugger and set a break point in your view to see what
>> the Django framework code is doing in the background.
>>
>> I can write just about any view I want in less than 5 minutes with a
>> function based view. The only slow down on my end is my typing
>> speed. I just find them much easier to understand and debug when you
>> can look at the entire code for the view with nothing else getting
>> in the way.
>>
>> I think I will try again to use some class based views in my code
>> just so I can make a more informed decision. I just remember my last
>> attempt to use the FormView class based view with multiple forms on
>> the same page and giving up in disgust because it was so much harder
>> than doing the same thing in a function based view.
>>
>> Some Developer.
>>
>> On 02/04/2017 06:37, James Bennett wrote:
>>
>> If you're asking "Will there ever be a point when all built-in
>> views in
>> Django are class-based", the answer is "maybe", because whether
>> to write
>> one of those class-based or function-based depends on what the
>> view
>> needs to do, how much configurability/extensibility it needs to
>> support,
>> etc.
>>
>> If you're asking "Will there ever be a point when Django no longer
>> supports using functions as views, period", the answer is almost
>> certainly "no".
>>
>> Officially, the definition of a Django view is a Python callable
>> which
>> takes an HttpRequest object as its first positional argument,
>> and which
>> either returns an HttpResponse object or raises an exception. That
>> definition is unlikely to change.
>>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/ms
> gid/django-users/7d612ef6-4438-70ab-9aea-d5595af22e5a%40googlemail.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 

Re: cannot get div to reload with ajax

2017-03-17 Thread Vijay Khemlani
And what error are you getting?

The only weird thing I see at first is

url: "{% url candidate_notes %}",

If your JS file is a standalone file served as a static file then you
have no "url" tag available inside it.

On 3/17/17, Shezan Kazi  wrote:
> hi all,
>
> i am trying to reload a div that is in an {% include %} tag when a form is
> submitted. This is what i have so far:
>
> the page i am viewing:
>
> 
>  {% crispy note_form %}
>  {% include 'item/item_notes.html' %}
> 
>
> the included template:
>
>  aria-multiselectable="true" role="tablist">
>  {% for note in object.itemnote_set.all reversed %}
>  
>   role="tab">
>data-toggle="collapse" href="#noteCollapse{{ forloop.counter }}"
>  aria-controls="noteCollapse{{ forloop.counter }}" aria-expanded="false">
>  {{ note.owner.first_name }}
>  {{ note.get_action_display|upper }}
>  {{ note.date_added }}
>  
>  
>aria-labelledby="noteHeading{{ forloop.counter }}" role="tabpanel"
> aria-expanded="false"
>  style="height: 0px;">
>  
>  {{ note.content }}
>  
>  
>  
>  {% endfor %}
> 
>
>
> js
>
> $("#notesTab form").submit(function(event){
>  console.log("submitting form")
>  // prevent page from being submitted and reloaded
>  event.preventDefault();
>  $('#notesList').remove();
>  console.log('old notes removed')
>  //var new_notes = '{% url candidate_notes %}';
>  //console.log(new_notes);
>  $.ajax({
>  url: "{% url candidate_notes %}",
>  success: function(data){
>  $('#notesColumn').html('data');
>  }
>  })
>
> views.py
>
> def candidate_notes(request):
>  return render_to_response(request, 'candidate/candidate_notes.html')
>
>
> urls.py
>
> url(r'item/notes', views.item_notes, name='item_notes'),
>
> Can yomeone please point me in the right direction? Thanks!!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b3fe4cf7-d423-4968-bf53-015db73c37db%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/CALn3ei1uR6o10C9pVtorFeLVT3dnR86Xx6pQ0ADZVhjw39GO_g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django and Nginx through uwsgi is not working

2017-03-17 Thread Vijay Khemlani
I fail to see what's so complex of uwsgi for a simple deploy, my
typical configuration file has 8 lines

On 3/17/17, Antonis Christofides  wrote:
>> Thanx you very much, i've spent days on this issue
> I'm sorry to hear that, especially because when I was using uwsgi I was
> also
> spending days for various issues. All this pain went away when I started to
> use
> Gunicorn. You can read more about that in
> https://djangodeployment.com/2017/01/02/which-wsgi-server-should-i-use/.
>
> Regards,
>
> A.
>
> Antonis Christofides
> http://djangodeployment.com
>
> On 03/17/2017 09:19 AM, valerio orfano wrote:
>> I want to thank Melvyn publicly, without his support i wouldn't succed!
>>
>> unix:/// in the uwsgi.ini file DOES NOT work (at least in Centos)
>>
>> insted unix:/  WORKS OUT
>>
>> Thanx you very much, i've spent days on this issue
>>
>>
>> On Thursday, March 16, 2017 at 8:58:52 PM UTC+1, Melvyn Sopacua wrote:
>>
>> On Thursday 16 March 2017 11:04:53 valerio orfano wrote:
>>
>> > http://uwsgi-docs.readthedocs.io/en/latest/Nginx.htm
>> 
>>
>> *sigh*
>>
>>
>>
>> http://nginx.org/en/docs/http/ngx_http_uwsgi_module.html#uwsgi_pass
>> 
>>
>>
>>
>> unix:/path/to
>>
>>
>>
>> Maybe unix:/// works, maybe it doesn't. But file:/// is supposed to be
>> the
>> exception to the URI rules, not the rule itself.
>>
>>
>>
>> Also, just providing a plain path (socket = /var/run/uwsgi/myapp.sock)
>> in
>> uwsgi.ini works.
>>
>>
>>
>> Of course, it will try to create the socket under the user uwsgi runs
>> as,
>> so permissions for the directory need to allow that.
>>
>> --
>>
>> Melvyn Sopacua
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com
>> .
>> To post to this group, send email to django-users@googlegroups.com
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/b6cfe3f2-ca74-44b3-830a-25c5f3c8afc3%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/be7e5d19-40b4-4d8a-c4e3-1812c634b090%40djangodeployment.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/CALn3ei04gX2%2BVWkYfTiykX4ONAQVrzswJG8HWyrt%3DtYemvwZPw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error running Django tutorial

2017-03-16 Thread Vijay Khemlani
Why is there a backslash in

from django.conf.urls import polls\

?

On 3/16/17, Camilo Torres  wrote:
> Hi.
>
> You may have a strange, non-visible character in your file just before the
> line giving error.
>
> --
> 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/f9e098eb-2362-4cc1-bc41-0b5a03f64172%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/CALn3ei2hsX-YPbrf-47E5vfyR-So88UVGHGWGt06br1Jaiqf%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django and Nginx through uwsgi is not working

2017-03-16 Thread Vijay Khemlani
Not sure if a typo on your email, but your command says

"chown nginx:nginx -R /sockect/uwsgi.sock"

sockect ?

On 3/16/17, valerio orfano  wrote:
> Hi All
>
> i ve created a django application not using virtual environment. I ve
> installed nginx and trying to integrate them via uwsgi application.
> Here my configurations files.
>
> [uwsgi]
> chdir = /home/elastic/workspace/ES_Brevetti
> wsgi-file = ES_Brevetti/wsgi.py
> master = true
> processes = 5
> uid = nginx
> gid = nginx
> socket = unix:///socket/uwsgi.sock
> chmod-socket = 666
> vacuum = true
>
> i've created the file /sockect/uwsgi.sock with permission 777
>
> chown nginx:nginx -R /sockect/uwsgi.sock
>
> and below nginx conf file:
>
> upstream django {
> server unix:///socket/uwsgi.sock; # for a file socket
> #server 127.0.0.1:8001; # for a web port socket (we'll use this
> first)
> }
> server {
> listen 80;
> server_name 10.184.2.231;
> error_log /var/log/nginx/error.log;
> access_log /var/log/nginx/access.log;
> charset utf-8;
>
> location /static/ {
> alias /home/elastic/workspace/ES_Brevetti;
> }
>
> location / {
> include uwsgi_params;
> uwsgi_pass  unix:///socket/uwsgi.sock;
> }
> }
>
>
> When i launch "systemctl start nginx" nginx is started with error:
>  connect() to unix:///socket/uwsgi.sock failed (111: Connection refused)
> while connecting to upstream,
>
>  When i run uwsgi --ini /etc/uwsgi/sites/ES_Brevetti.ini  it doesnt run
> with error:
>
> .
> lock engine: pthread robust mutexes
> thunder lock: disabled (you can enable it with --thunder-lock)
> bind(): Permission denied [core/socket.c line 230]
>
>
> What i am doing wrong? On google i can only see configurations with VENV
> while i am not using virtual environment.
>
> --
> 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/891545d5-a99c-425d-8171-c6a9e43f5dd8%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/CALn3ei3kOMcm5UL%2BPojo%3Dsa7r9jk9zZRDi_2QGDBh0%3Da_fhcAQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: 'OneToOneField' object has no attribute 'get' in function-based view

2017-03-15 Thread Vijay Khemlani
At least I can help with the original problem

Your view function should return an HttpResponse object, but inside
your view you have this

new_title = title_form.save()
return new_title

new_title is an instance of your ObjectName model, that's why Django
crashes when it tries to use it as an HttpResponse object and throws
that error.

I'm not quite sure what are you trying to accomplish in your view.

On 3/15/17, Pedro Paulo Palazzo <pedro.pala...@gmail.com> wrote:
> Here is the traceback:
>
> Environment:
> Request Method: POSTRequest URL: http://127.0.0.1:8000/work/add/
> Django Version: 1.10.6Python Version: 3.6.0Installed
> Applications:['django.contrib.admin',
>  'django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.messages',
>  'django.contrib.staticfiles',
>  'reversion',
>  'historicdate.apps.HistoricdateConfig',
>  'place.apps.PlaceConfig',
>  'agent.apps.AgentConfig',
>  'storageunit.apps.StorageunitConfig',
>  'objectinfo.apps.ObjectinfoConfig',
>  'reorg.apps.ReorgConfig']Installed
> Middleware:['django.middleware.security.SecurityMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.middleware.common.CommonMiddleware',
>  'django.middleware.csrf.CsrfViewMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.contrib.messages.middleware.MessageMiddleware',
>  'django.middleware.clickjacking.XFrameOptionsMiddleware']
> Traceback:
> File
> "/path/to/venv/lib/python3.6/site-packages/django/core/handlers/exception.py"
> in inner
>   42. response = get_response(request)
> File "/path/to/venv/lib/python3.6/site-packages/django/utils/deprecation.py"
> in __call__
>   138. response = self.process_response(request, response)
> File
> "/path/to/venv/lib/python3.6/site-packages/django/middleware/clickjacking.py"
> in process_response
>   32. if response.get('X-Frame-Options') is not None:
> Exception Type: AttributeError at /work/add/Exception Value: 'ObjectName'
> object has no attribute 'get'
>
>
>
> I ended up trying a different approach, splitting these forms into two
> separate views. I was able to pass the pk of the first (title) form to the
> second (register) through the URL and to prepopulate the latter's
> OneToOneField with the correct object. However, when I try to save this
> form, I get an ObjectDoesNotExist:
>
> ObjectName matching query does not exist.
>
>
> The traceback for this latter error follows:
>
> Environment:Request Method: POSTRequest URL:
> http://127.0.0.1:8000/work/add/57/register/Django Version: 1.10.6Python
> Version: 3.6.0Installed Applications:['django.contrib.admin',
> 'django.contrib.auth', 'django.contrib.contenttypes',
> 'django.contrib.sessions', 'django.contrib.messages',
> 'django.contrib.staticfiles', 'reversion',
> 'historicdate.apps.HistoricdateConfig', 'place.apps.PlaceConfig',
> 'agent.apps.AgentConfig', 'storageunit.apps.StorageunitConfig',
> 'objectinfo.apps.ObjectinfoConfig', 'reorg.apps.ReorgConfig']Installed
> Middleware:['django.middleware.security.SecurityMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware']Traceback:File
> "/path/to/venv/lib/python3.6/site-packages/django/core/handlers/exception.py"
> in inner  42. response = get_response(request)File
> "/path/to/venv/lib/python3.6/site-packages/django/core/handlers/base.py" in
> _get_response  187. response =
> self.process_exception_by_middleware(e, request)File
> "/path/to/venv/lib/python3.6/site-packages/django/core/handlers/base.py" in
> _get_response  185. response = wrapped_callback(request,
> *callback_args, **callback_kwargs)File
> "/path/to/project/objectinfo/views.py" in object_entry  45.
> object_form = ObjectEntry(request.POST, request.FILES)File
> "/path/to/project/objectinfo/forms.py" in __init__  9.
> self.fields['preferred_title'].initial =
> ObjectName.objects.get(pk=objectname_id)File
> "/path/to/venv/lib/python3.6/site-packages/django/db/models/manager.py" in
> manager_method  85. return getattr(self.get_queryset(),
> name)(*args, **kwargs)File
> "/path/to/venv/lib/python3.6/site-packages/django/db/models/query.py" in get
>  385. self.model._meta.object_nameException Type:
> DoesNotExist at /work/add/57/register/Exc

Re: 'OneToOneField' object has no attribute 'get' in function-based view

2017-03-15 Thread Vijay Khemlani
Can you post the whole stack trace of the error?

There are some things that don't make sense in the view function (for
example returning "new_title" from the view) but they are not related
to your initial error.

On 3/15/17, Pedro Paulo Palazzo  wrote:
>
>
> I am writing a two-part form where I want to pass the object saved in the
> first part as a OneToOneField for the object in the second part.
>
> In views.py:
>
>
> def object_entry(request):
> if request.method == 'POST':
> title_form = TitleEntry(request.POST)
> object_form = ObjectEntry(request.POST)
> if title_form.is_valid():
> title = title_form.cleaned_data['title']
> title_type = title_form.cleaned_data['title_type']
> title_lang = title_form.cleaned_data['lang']
> title_translation = title_form.cleaned_data['translation']
> title_currency = title_form.cleaned_data['currency']
> title_level = title_form.cleaned_data['level']
> title_note = title_form.cleaned_data['note']
> title_source = title_form.cleaned_data['source']
> new_title = title_form.save()
> return new_title
>
> else:
> return render_to_response('objectinfo/objectregister_form.html',
> {'object_form': object_form, 'title_form': title_form})
>
> if object_form.is_valid():
> object_form.preferred_title = new_title
> snapshot = object_form.cleaned_data['snapshot']
> work_type = object_form.cleaned_data['work_type']
> source = object_form.cleaned_data['source']
> brief_description =
> object_form.cleaned_data['brief_description']
> description_source =
> object_form.cleaned_data['description_source']
> comments = object_form.cleaned_data['comments']
> distinguishing_features =
> object_form.cleaned_data['distinguishing_features']
> new_object = object_form.save()
> reorg.AccessionNumber.generate(new_object.pk)
>
> return HttpResponseRedirect('/work/')
> # return HttpResponseRedirect(reverse(description_edit,
> args=(new_object.pk,)))
>
> else:
> return render_to_response('objectinfo/objectregister_form.html',
> {'object_form': object_form, 'title_form': title_form})
>
> else:
> title_form = TitleEntry()
> object_form = ObjectEntry()
> return render(request, 'objectinfo/objectregister_form.html',
> {'object_form': object_form, 'title_form': title_form})
>
>
> And in forms.py:
>
>
> class ObjectEntry(ModelForm):
> class Meta:
> model = ObjectRegister
> fields = ['snapshot', 'work_type', 'source', 'brief_description',
> 'description_source', 'comments', 'distinguishing_features', 'storage_unit',
> 'normal_unit']
>
>  class TitleEntry(ModelForm):
> class Meta:
> model = ObjectName
> fields = ['title', 'title_type', 'lang', 'translation', 'currency',
> 'level', 'note', 'source']
>
>
> When submitting the form it returns the error 'ObjectName' object has no
> attribute 'get'. What would be the correct way to pass new_title as the
> OneToOneField of object_form.preferred_title?
>
> --
> 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/90eb2aa6-d802-4972-81ca-284b5bebe052%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/CALn3ei2XmJ7mbHWqM2wbw5z6qDWXV2MYp37JUQ9frWfhXDc%3Ddg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django queryset High CPU Usage

2017-03-14 Thread Vijay Khemlani
"In the above, the CPU was hitting almost 100% and was taking almost a second"

So, your query was resolved in a second, that's normal, also the spike
in cpu usage because... the cpu is working...

Your problem seems to be in your for loop

for a in As:
 retrieve other related data from associated models.
 Write Data in a csv report file

if A has 10.000 records then it is reasonable that this part explodes,
especially if you are querying the database in each iteration, also
you are writing multiple csv files?

Can't you find a way to prefetch all the records of the associated
models that you are going to need in a single query before the for
loop and store it in a dictionary or something?


On 3/14/17, Web Architect  wrote:
> Hi Daniel,
>
> Thanks for the suggestion. Would look into django-import-export.
>
> Thanks.
>
> On Saturday, March 11, 2017 at 6:29:57 PM UTC+5:30, Daniel Hepper wrote:
>>
>> In additions to the suggestions you already received from others, have a
>> look at django-import-export. It allows you to easily export data in
>> various formats.
>>
>> Hope that helps,
>> Daniel Hepper
>> https://consideratecode.com
>>
>> On Friday, March 10, 2017 at 12:06:13 PM UTC+1, Web Architect wrote:
>>>
>>> Hi James,
>>>
>>> Thanks for your response. Melvyn also posed a similar point of not
>>> loading the whole records.
>>>
>>> But all the records are needed for reporting purposes - where the data is
>>>
>>> read from the DB and a csv report is created. I am not quite an expert on
>>>
>>> Django but I am not sure if there is a better way to do it.
>>>
>>> The scenario is as follows to make it clearer:
>>>
>>> Ours is an ecommerce site built on Django. Our admin/accounting team
>>> needs to download reports now and then. We have a Django model for the
>>> line
>>> items purchased. Now there could be 10k line items sold and each line
>>> items
>>> are associated with other models like payments, shipments etc which is a
>>>
>>> complex set of relations.
>>>
>>> We do not yet have a sophisticated reporting mechanism but was working on
>>>
>>> building a simplistic reporting system on Django. But I am finding issues
>>>
>>> with scaling up - as reported with CPU Usage and the amount of time
>>> taken.
>>> If there is a way to optimise this - would be great otherwise we might
>>> not
>>> have to look for standard methods of reporting tools.
>>>
>>> Would appreciate suggestions/advices on the above.
>>>
>>> Thanks,
>>>
>>> On Friday, March 10, 2017 at 2:52:50 PM UTC+5:30, James Schneider wrote:



 On Mar 9, 2017 9:37 PM, "Web Architect"  wrote:

 Would like to further add - the python CPU Usage is hitting almost 100
 %. When I run  a Select * query on Mysql, its quite fast and CPU is
 normal.
 I am not sure if anything more needs to be done in Django.


 Ironically, things being done in Django is the reason for your CPU
 utilization issue in the first place.

 Calling a qs.all() is NOT the same as a SELECT * statement, even more so

 when speaking to the scale of query that you mention.

 Your SQL query is simply listing data in a table. A very easy thing to
 do, hence the reason it runs quickly.

 The qs.all() call is also running the same query (probably). However, in

 addition to pulling all of the data, it is performing a transformation
 of
 that data in to Django model objects. If you are pulling 10K items, then

 Django is creating 10K objects, which is easily more intensive than a
 raw
 SQL query, even for simple model objects.

 In general, there's usually no practical reason to ever pull that many
 objects from a DB for display on a page. Filter down to a reasonable
 number
 (<100 for almost all sane cases) or implement a paging system to limit
 returned results. It's also probably using a ton of RAM only to be
 immediately thrown away at the end of the request. Browsers will
 disintegrate trying to render that many HTML elements simultaneously.

 Look at implementing a paging system, possibly through Django's built-in

 mechanism, or something like Datatables and the infinite scroll plugin.

 https://docs.djangoproject.com/en/dev/topics/pagination/

 https://datatables.net/extensions/scroller/

 -James

>>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/29c0528f-57a7-4f73-be77-3158fe6e61dd%40googlegroups.com.
> For more options, visit 

Re: Django queryset High CPU Usage

2017-03-11 Thread Vijay Khemlani
"But the CPU usage and time taken are high" <- I'm assuming high
enough to be problematic for OP.

I'm seriously not following. Why are people suggesting reporting and
export software when OP hasn't even described the problem in detail.
It's not even clear whether the high cpu and time taken are due to the
basic query ("Model.objects.all()") or the further processing of the
report.

It could easily be a missing "select_related" which causes thousands
of joins inside a for loop.

On 3/11/17, James Schneider <jrschneide...@gmail.com> wrote:
> On Mar 11, 2017 12:01 PM, "Vijay Khemlani" <vkhem...@gmail.com> wrote:
>
> Am I the only one who thinks that generating a report over a set of
> just 10.000 records could be done in 10 - 20 secs unless there are
> some serious computations going on with that data?
>
> For a report I have to query around 200.000 records, with
> aggregations, and it takes less than a minute using the ORM.
>
>
> The OP never mentioned a time interval that I can find in this thread, only
> CPU utilization. I can only imagine that the query is taking long enough to
> notice the CPU utilization, which would be at least a few seconds.
>
> Querying and aggregating 200K records within the DB is not comparable to
> pulling 10K individual records and performing processing on each one. An
> ORM call with aggregation will perform a large majority of the work in the
> DB, and the ORM simply wraps the response accordingly.
>
> -James
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2Be%2BciWZFoHQD%3D9UpSQzmpzO70_7MXuw6J01myYrAQ4ZN-uX4g%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/CALn3ei3kzzz7XcN4m8DzBO5cAyr9PNhCsw4C_6aRCdk4iVYj7g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django queryset High CPU Usage

2017-03-11 Thread Vijay Khemlani
Am I the only one who thinks that generating a report over a set of
just 10.000 records could be done in 10 - 20 secs unless there are
some serious computations going on with that data?

For a report I have to query around 200.000 records, with
aggregations, and it takes less than a minute using the ORM.

On 3/11/17, Daniel Hepper  wrote:
> In additions to the suggestions you already received from others, have a
> look at django-import-export. It allows you to easily export data in
> various formats.
>
> Hope that helps,
> Daniel Hepper
> https://consideratecode.com
>
> On Friday, March 10, 2017 at 12:06:13 PM UTC+1, Web Architect wrote:
>>
>> Hi James,
>>
>> Thanks for your response. Melvyn also posed a similar point of not loading
>>
>> the whole records.
>>
>> But all the records are needed for reporting purposes - where the data is
>>
>> read from the DB and a csv report is created. I am not quite an expert on
>>
>> Django but I am not sure if there is a better way to do it.
>>
>> The scenario is as follows to make it clearer:
>>
>> Ours is an ecommerce site built on Django. Our admin/accounting team needs
>>
>> to download reports now and then. We have a Django model for the line
>> items
>> purchased. Now there could be 10k line items sold and each line items are
>>
>> associated with other models like payments, shipments etc which is a
>> complex set of relations.
>>
>> We do not yet have a sophisticated reporting mechanism but was working on
>>
>> building a simplistic reporting system on Django. But I am finding issues
>>
>> with scaling up - as reported with CPU Usage and the amount of time taken.
>>
>> If there is a way to optimise this - would be great otherwise we might not
>>
>> have to look for standard methods of reporting tools.
>>
>> Would appreciate suggestions/advices on the above.
>>
>> Thanks,
>>
>> On Friday, March 10, 2017 at 2:52:50 PM UTC+5:30, James Schneider wrote:
>>>
>>>
>>>
>>> On Mar 9, 2017 9:37 PM, "Web Architect"  wrote:
>>>
>>> Would like to further add - the python CPU Usage is hitting almost 100 %.
>>>
>>> When I run  a Select * query on Mysql, its quite fast and CPU is normal.
>>> I
>>> am not sure if anything more needs to be done in Django.
>>>
>>>
>>> Ironically, things being done in Django is the reason for your CPU
>>> utilization issue in the first place.
>>>
>>> Calling a qs.all() is NOT the same as a SELECT * statement, even more so
>>>
>>> when speaking to the scale of query that you mention.
>>>
>>> Your SQL query is simply listing data in a table. A very easy thing to
>>> do, hence the reason it runs quickly.
>>>
>>> The qs.all() call is also running the same query (probably). However, in
>>>
>>> addition to pulling all of the data, it is performing a transformation of
>>>
>>> that data in to Django model objects. If you are pulling 10K items, then
>>>
>>> Django is creating 10K objects, which is easily more intensive than a raw
>>>
>>> SQL query, even for simple model objects.
>>>
>>> In general, there's usually no practical reason to ever pull that many
>>> objects from a DB for display on a page. Filter down to a reasonable
>>> number
>>> (<100 for almost all sane cases) or implement a paging system to limit
>>> returned results. It's also probably using a ton of RAM only to be
>>> immediately thrown away at the end of the request. Browsers will
>>> disintegrate trying to render that many HTML elements simultaneously.
>>>
>>> Look at implementing a paging system, possibly through Django's built-in
>>>
>>> mechanism, or something like Datatables and the infinite scroll plugin.
>>>
>>> https://docs.djangoproject.com/en/dev/topics/pagination/
>>>
>>> https://datatables.net/extensions/scroller/
>>>
>>> -James
>>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/90218749-c5e1-4ca8-ab6c-3e191a79798f%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/CALn3ei03dwabCie0J6xMKxynDB%3Dr%3D%2Byzty-Vf1arnU-Z5HbfAA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Migrations

2017-03-11 Thread Vijay Khemlani
Not really, as long as you understand what's going on and not
inputting commands just for the sake of it.

On 3/11/17, Mike Dewhirst  wrote:
> On 11/03/2017 7:17 AM, Matthew Pava wrote:
>>
>> Does anyone else get a migraine when working migrations?
>>
>
> Only when I try to game them. If I follow instructions they are
> magnificent. That said, what are your problems?
>
> Mike
>
>
>> --
>> 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/41f9ad6271964c208f3726a4fa28bfff%40ISS1.ISS.LOCAL
>>
>> .
>> 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/8e23d94f-696c-91b4-af71-0418d047cd80%40dewhirst.com.au.
> 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/CALn3ei2iF2TgeuDHVmFKPZi0FmLt110PYeEAZbxa7Rp2%2B%2Bs4qg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django queryset High CPU Usage

2017-03-10 Thread Vijay Khemlani
This is what you said

"There is a Model A with 1 records. Just a simple queryset -
A.objects.all() is resulting in CPU hitting almost 100%. Is there a
way to optimize this? But why would such a query result in high CPU
Usage?"

By that, I assume that you opened a shell and executed

"A.objects.all()"

If you have other code that is being executed (your for loop or
something) you better post it to clarify your question.

On 3/10/17, Web Architect <pinak...@gmail.com> wrote:
> Hi,
>
> Thanks for your response.
>
> Well, its not just the queryset but when the query triggered by an if
> condition or a for loop - thats what I meant. I was doing some basic
> performance check as well while working on the report generation - I
> observed the issue. There's no manager other than the default one. The CPU
> usage spikes and it takes some time before the Objects are created.
>
> But when you say not all objects are created at one go, you mean they can
> be deferred? You mean the query results are stored in the memory till each
> record is accessed or something using the objects? Could you please
> clarify?
>
> Thanks.
>
> On Friday, March 10, 2017 at 5:31:14 PM UTC+5:30, Vijay Khemlani wrote:
>>
>> There is something wrong in your setup
>>
>> I can query a 400.000 item table in less than a second with the
>> typical "Model.objects.all()". Django does not convert all of the
>> entries into objects just by that query.
>>
>> You don't have any managers, or anything that can result in a
>> side-effect beyond the query itself?
>>
>>
>>
>> On 3/10/17, James Bennett <ubern...@gmail.com > wrote:
>> > If all you need is to export data from your database (with or without
>> > transforming it along the way) to a CSV, using the normal QuerySet
>> methods
>> > is probably the wrong approach; you don't need model objects to do that.
>> >
>> > Some options include:
>> >
>> > * Use raw SQL to query for the data and push it to CSV (also, some
>> > databases natively understand how to export query results to CSV)
>> > * Use the values() or values_list() methods to use lighter-weight basic
>> >
>> > Python data structures (dictionaries and lists) instead of model objects
>> >
>> > * If you *must* instantiate model objects, use the iterator() method to
>> >
>> > avoid keeping them around in-memory, and look at server-side cursors as
>> >
>> an
>> > option
>> > * If you're fetching related data, make sure you're eager-loading the
>> > relations to avoid N+1 problems.
>> >
>> >
>> > On Fri, Mar 10, 2017 at 3:06 AM, Web Architect <pina...@gmail.com
>> > wrote:
>> >
>> >> Hi James,
>> >>
>> >> Thanks for your response. Melvyn also posed a similar point of not
>> >> loading
>> >> the whole records.
>> >>
>> >> But all the records are needed for reporting purposes - where the data
>> >>
>> is
>> >> read from the DB and a csv report is created. I am not quite an expert
>> >>
>> on
>> >> Django but I am not sure if there is a better way to do it.
>> >>
>> >> The scenario is as follows to make it clearer:
>> >>
>> >> Ours is an ecommerce site built on Django. Our admin/accounting team
>> >> needs
>> >> to download reports now and then. We have a Django model for the line
>> >> items
>> >> purchased. Now there could be 10k line items sold and each line items
>> are
>> >> associated with other models like payments, shipments etc which is a
>> >> complex set of relations.
>> >>
>> >> We do not yet have a sophisticated reporting mechanism but was working
>> >>
>> on
>> >> building a simplistic reporting system on Django. But I am finding
>> issues
>> >> with scaling up - as reported with CPU Usage and the amount of time
>> >> taken.
>> >> If there is a way to optimise this - would be great otherwise we might
>> >>
>> >> not
>> >> have to look for standard methods of reporting tools.
>> >>
>> >> Would appreciate suggestions/advices on the above.
>> >>
>> >> Thanks,
>> >>
>> >> On Friday, March 10, 2017 at 2:52:50 PM UTC+5:30, James Schneider
>> wrote:
>> >>>
>> >>>
>> >>>
>> >>> On Mar 9, 2017 9:37 PM, "Web A

Re: Django queryset High CPU Usage

2017-03-10 Thread Vijay Khemlani
There is something wrong in your setup

I can query a 400.000 item table in less than a second with the
typical "Model.objects.all()". Django does not convert all of the
entries into objects just by that query.

You don't have any managers, or anything that can result in a
side-effect beyond the query itself?



On 3/10/17, James Bennett  wrote:
> If all you need is to export data from your database (with or without
> transforming it along the way) to a CSV, using the normal QuerySet methods
> is probably the wrong approach; you don't need model objects to do that.
> Some options include:
>
> * Use raw SQL to query for the data and push it to CSV (also, some
> databases natively understand how to export query results to CSV)
> * Use the values() or values_list() methods to use lighter-weight basic
> Python data structures (dictionaries and lists) instead of model objects
> * If you *must* instantiate model objects, use the iterator() method to
> avoid keeping them around in-memory, and look at server-side cursors as an
> option
> * If you're fetching related data, make sure you're eager-loading the
> relations to avoid N+1 problems.
>
>
> On Fri, Mar 10, 2017 at 3:06 AM, Web Architect  wrote:
>
>> Hi James,
>>
>> Thanks for your response. Melvyn also posed a similar point of not
>> loading
>> the whole records.
>>
>> But all the records are needed for reporting purposes - where the data is
>> read from the DB and a csv report is created. I am not quite an expert on
>> Django but I am not sure if there is a better way to do it.
>>
>> The scenario is as follows to make it clearer:
>>
>> Ours is an ecommerce site built on Django. Our admin/accounting team
>> needs
>> to download reports now and then. We have a Django model for the line
>> items
>> purchased. Now there could be 10k line items sold and each line items are
>> associated with other models like payments, shipments etc which is a
>> complex set of relations.
>>
>> We do not yet have a sophisticated reporting mechanism but was working on
>> building a simplistic reporting system on Django. But I am finding issues
>> with scaling up - as reported with CPU Usage and the amount of time
>> taken.
>> If there is a way to optimise this - would be great otherwise we might
>> not
>> have to look for standard methods of reporting tools.
>>
>> Would appreciate suggestions/advices on the above.
>>
>> Thanks,
>>
>> On Friday, March 10, 2017 at 2:52:50 PM UTC+5:30, James Schneider wrote:
>>>
>>>
>>>
>>> On Mar 9, 2017 9:37 PM, "Web Architect"  wrote:
>>>
>>> Would like to further add - the python CPU Usage is hitting almost 100
>>> %.
>>> When I run  a Select * query on Mysql, its quite fast and CPU is normal.
>>> I
>>> am not sure if anything more needs to be done in Django.
>>>
>>>
>>> Ironically, things being done in Django is the reason for your CPU
>>> utilization issue in the first place.
>>>
>>> Calling a qs.all() is NOT the same as a SELECT * statement, even more so
>>> when speaking to the scale of query that you mention.
>>>
>>> Your SQL query is simply listing data in a table. A very easy thing to
>>> do, hence the reason it runs quickly.
>>>
>>> The qs.all() call is also running the same query (probably). However, in
>>> addition to pulling all of the data, it is performing a transformation
>>> of
>>> that data in to Django model objects. If you are pulling 10K items, then
>>> Django is creating 10K objects, which is easily more intensive than a
>>> raw
>>> SQL query, even for simple model objects.
>>>
>>> In general, there's usually no practical reason to ever pull that many
>>> objects from a DB for display on a page. Filter down to a reasonable
>>> number
>>> (<100 for almost all sane cases) or implement a paging system to limit
>>> returned results. It's also probably using a ton of RAM only to be
>>> immediately thrown away at the end of the request. Browsers will
>>> disintegrate trying to render that many HTML elements simultaneously.
>>>
>>> Look at implementing a paging system, possibly through Django's built-in
>>> mechanism, or something like Datatables and the infinite scroll plugin.
>>>
>>> https://docs.djangoproject.com/en/dev/topics/pagination/
>>>
>>> https://datatables.net/extensions/scroller/
>>>
>>> -James
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/
>> msgid/django-users/566cf05e-babf-456c-91fa-a698f7c7537d%40googlegroups.com
>> 
>> 

Re: Advice: count hits/pageview for high traffic website

2017-03-08 Thread Vijay Khemlani
Maybe I'm missing something, but why not Google Analytics?

On 3/8/17, ludovic coues  wrote:
> Have you looked at an analytics solution like piwik ?
>
> 2017-03-08 6:40 GMT+01:00 carlos :
>> Daniel, no i say i used django for a website with high traffic maybe 70k
>> per
>> days, but i need count visit page like
>> django-hitocunts but the problems like django-hitcount is not for a
>> website
>> high traffic, the database is very slow ans the website down
>>
>> my question is exist any method, third party app like django-hitcount but
>> for site very high traffic Or some idea to do that?
>>
>> cheers
>>
>> On Tue, Mar 7, 2017 at 6:04 PM, Daniel Bess  wrote:
>>>
>>> Hi Carlos,
>>>
>>> You email is a little unclear.  Are you suggesting I should not use
>>> Django
>>> for a web backend?
>>>
>>> Let me know!
>>>
>>> Thanks,
>>>
>>> Daniel
>>>
>>> On Mar 7, 2017, at 3:38 PM, carlos  wrote:
>>>
>>> Hi,
>>> i try used django-hitcount but really not for website high traffic
>>> any advice for count visits/hits page for 60k or 100k  traffic for day
>>>
>>> thank any idea, link or whatever helps
>>>
>>> --
>>> att.
>>> Carlos Rocha
>>>
>>> --
>>> 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/CAM-7rO1eRU8kNrbq1J9fmO1yTvEnqbhKp3i2YtnFO5U-oGgbLQ%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/C1AB7BB4-BBA6-4156-9826-6C68EE71DF1F%40endocrypt.com.
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>>
>> --
>> att.
>> Carlos Rocha
>>
>> --
>> 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/CAM-7rO27%2B8aWAwrAstsvffPBFk%3DTcq29VURG_%2BbX4HdUerOTcQ%40mail.gmail.com.
>>
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
>
> Cordialement, Coues Ludovic
> +336 148 743 42
>
> --
> 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/CAEuG%2BTY4vp5A14t2nH3VwoOf_sOB8d3CFUTQEtB1kwi1p0a5Fw%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/CALn3ei358ivGswC1%3DWx%3D_VmSCjjbMvadR6GLiTnZt_%3DaBiu3EA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Chart library for django

2017-03-06 Thread Vijay Khemlani
Rendering server-side charts is usually a mess, and the result
(usually a static image) is not as good as using a JS library.

I use Highcharts, just had to make a little layer on top of it to make
it compatible with the JSON django was generating.

It also encourages separation of concerns between the frontend and backend

On 3/6/17, Melvyn Sopacua  wrote:
> On Sunday 05 March 2017 22:10:07 Luvpreet Singh wrote:
>
>> I am looking for some solution to display django database
> queryset to
>> django admin over graphs.
>
> https://djangopackages.org/grids/g/charts/
>
> Problem is, the majority is abandonware.
> --
> Melvyn Sopacua
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1685391.OzplGY75kk%40devstation.
> 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/CALn3ei3Kk4_QoM60d5%2BoAVLRzrFCKmQmkgDcMq--Qc92Ym3-_w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Request for advice on refactoring a big Django project

2017-03-06 Thread Vijay Khemlani
Also, this type mailing lists are usually for specific questions about
the framework

"How do I make this particular query with the ORM"
"Why isn't this variable getting rendered in the template"

etc

Your question is kinda broad

On 3/6/17, Bob Haugen  wrote:
> Antonis, thank you very much for the feedback! You are absolutely
> correct! I apologize to you and the list, and will strive to follow
> your suggestions in the future.
>
> I suspect, however, that the very long explanation that would have
> been required to avoid the links would have been offputting, too. This
> might be a request that was just inappropriate for this list.
>
> As for now, we're charging happily ahead.
>
> On Mon, Mar 6, 2017 at 5:45 AM, Antonis Christofides
>  wrote:
>> Hi,
>>
>> I, like many people, am busy. I will generally not spend too much time on
>> the messages of this list. I delete most of them after only reading the
>> subject line. If I do choose to read the body, I expect to understand
>> what
>> it is about after a few seconds of reading. But all I can see in your
>> original message is that you have a big Django project that needs
>> refactoring, and several links with the code and your discussions about
>> them. Essentially the message I'm getting is "I can't tell you what I
>> want
>> in this email message, but if you click on these links and study them for
>> about half an hour, you'll get it".
>>
>> Likewise, it would have been way better to include your original message
>> in
>> the reply. In order to find your original message I had to dig in my
>> Trash
>> folder. I would normally not do that, and I would have ignored your reply
>> as
>> well. It just happens that I'm travelling and I'm quite relaxed.
>>
>> Bottom line: you need to make it very easy for me to help you, and I
>> believe
>> the same goes for other people as well.
>>
>> Regards,
>>
>> Antonis
>>
>> Antonis Christofides
>> http://djangodeployment.com
>>
>> On 03/06/2017 12:36 PM, bobhaugen wrote:
>>
>> I was disappointed to get no response on this topic, and would be
>> grateful
>> for any feedback on why that might have been.
>>
>> Too big? Big ball of mud? Stupid project? ? (I have very little
>> touchiness...)
>>
>> I hope people did not think we wanted to get them to do all or even very
>> much work for us. We are charging ahead here:
>> https://github.com/django-rea
>>
>> We did find, and are using, some delicious advice from Marty Alchin:
>> http://martyalchin.com/2008/jan/10/simple-plugin-framework/
>> And upgrading to the latest version of django, changing to class-based
>> views, and breaking up both models and views into several files.
>>
>> Next: a bunch of abstract base classes.
>>
>> After that: more API work and a mobile app to use it.
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/a3e12fd2-fc27-447a-a5f5-e394c3d67cff%40googlegroups.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/9OU0TfwcmTQ/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/4d7559f1-e3a2-64f0-d6b3-60c902e17921%40djangodeployment.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%2BSvw0WRHpTUUV1RceS8MWuRjGQ3JyJqZ%3DCKdKGSLYV8%2BQma2g%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 

Re: Having trouble with Django tutorial

2017-03-03 Thread Vijay Khemlani
Starting from the project root (the directory that contains your
manage.py file), that project's main url file should be in

learning_python/urls.py

also, there should be only two urls.py in your project directory, the
one for the project and the other inside the polls app.

On 3/3/17, Yves S. Garret <yoursurrogate...@gmail.com> wrote:
> Is this learning_python/urls.py or learning_python/learning_python/urls.py?
>
> On Friday, March 3, 2017 at 10:04:32 AM UTC-5, Vijay Khemlani wrote:
>>
>> You should import the polls urls as it appears in the tutorial
>>
>> url(r'^polls/', include('polls.urls')),
>>
>> On 3/3/17, Yves S. Garret <yoursurr...@gmail.com > wrote:
>> > Like this:
>> >
>> > from django.conf.urls import include, url
>> > from django.contrib import admin
>> >
>> > urlpatterns = [
>> >   url(r'^polls/', urls),
>> >   url(r'^admin/', admin.site.urls),
>> > ]
>> >
>> > Is there a way to print out strings to indicate where the problem is?
>> >
>> > On Friday, March 3, 2017 at 8:35:47 AM UTC-5, Vijay Khemlani wrote:
>> >>
>> >> How does your learning_python.urls look like?
>> >>
>> >> On 3/3/17, Yves S. Garret <yoursurr...@gmail.com > wrote:
>> >>
>> >> > Yes.
>> >> >
>> >> > On Thursday, March 2, 2017 at 11:09:58 AM UTC-5, Vijay Khemlani
>> wrote:
>> >> >>
>> >> >> Did you do this step?
>> >> >>
>> >> >> The next step is to point the root URLconf at the polls.urls module.
>> >> >>
>> In
>> >> >>
>> >> >> mysite/urls.py, add an import for django.conf.urls.include and
>> insert
>> >> an
>> >> >> include()
>> >> >> <
>> >>
>> https://docs.djangoproject.com/en/1.10/ref/urls/#django.conf.urls.include>
>>
>>
>> >>
>> >>
>> >> >> in
>> >> >> the urlpatterns list, so you have:
>> >> >> mysite/urls.py
>> >> >>
>> >> >> from django.conf.urls import include, urlfrom django.contrib import
>> >> >>
>> >> admin
>> >> >> urlpatterns = [
>> >> >> url(r'^polls/', include('polls.urls')),
>> >> >> url(r'^admin/', admin.site.urls),]
>> >> >>
>> >> >>
>> >> >> On Thu, Mar 2, 2017 at 11:40 AM, Yves S. Garret <
>> yoursurr...@gmail.com
>> >> >>
>> >> >> > wrote:
>> >> >>
>> >> >>> Hi all,
>> >> >>>
>> >> >>> I'm going through this tutorial:
>> >> >>> https://docs.djangoproject.com/en/1.10/intro/tutorial01/
>> >> >>>
>> >> >>> And the problem that I'm having is when I start the 'polls'
>> >> application
>> >> >>> from inside my project and then go to localhost:8000/polls, I get a
>> >> >>>
>> >> 404.
>> >> >>>
>> >> >>> Page not found (404)
>> >> >>> Request Method: GET
>> >> >>> Request URL: http://localhost:8000/polls
>> >> >>>
>> >> >>> Using the URLconf defined in learning_python.urls, Django tried
>> these
>> >> >>>
>> >> >>> URL patterns, in this order:
>> >> >>>
>> >> >>>1. ^admin/
>> >> >>>
>> >> >>> The current URL, polls, didn't match any of these.
>> >> >>>
>> >> >>>
>> >> >>> I did everything as the tutorial told me, so I'm a little bit lost
>> >> >>>
>> as
>> >> >>>
>> >> to
>> >> >>>
>> >> >>> why this is happening.  Thanks in advance.
>> >> >>>
>> >> >>> --
>> >> >>> 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 dj

Re: Having trouble with Django tutorial

2017-03-03 Thread Vijay Khemlani
You should import the polls urls as it appears in the tutorial

url(r'^polls/', include('polls.urls')),

On 3/3/17, Yves S. Garret <yoursurrogate...@gmail.com> wrote:
> Like this:
>
> from django.conf.urls import include, url
> from django.contrib import admin
>
> urlpatterns = [
>   url(r'^polls/', urls),
>   url(r'^admin/', admin.site.urls),
> ]
>
> Is there a way to print out strings to indicate where the problem is?
>
> On Friday, March 3, 2017 at 8:35:47 AM UTC-5, Vijay Khemlani wrote:
>>
>> How does your learning_python.urls look like?
>>
>> On 3/3/17, Yves S. Garret <yoursurr...@gmail.com > wrote:
>> > Yes.
>> >
>> > On Thursday, March 2, 2017 at 11:09:58 AM UTC-5, Vijay Khemlani wrote:
>> >>
>> >> Did you do this step?
>> >>
>> >> The next step is to point the root URLconf at the polls.urls module. In
>> >>
>> >> mysite/urls.py, add an import for django.conf.urls.include and insert
>> an
>> >> include()
>> >> <
>> https://docs.djangoproject.com/en/1.10/ref/urls/#django.conf.urls.include>
>>
>>
>> >> in
>> >> the urlpatterns list, so you have:
>> >> mysite/urls.py
>> >>
>> >> from django.conf.urls import include, urlfrom django.contrib import
>> admin
>> >> urlpatterns = [
>> >> url(r'^polls/', include('polls.urls')),
>> >> url(r'^admin/', admin.site.urls),]
>> >>
>> >>
>> >> On Thu, Mar 2, 2017 at 11:40 AM, Yves S. Garret <yoursurr...@gmail.com
>> >>
>> >> > wrote:
>> >>
>> >>> Hi all,
>> >>>
>> >>> I'm going through this tutorial:
>> >>> https://docs.djangoproject.com/en/1.10/intro/tutorial01/
>> >>>
>> >>> And the problem that I'm having is when I start the 'polls'
>> application
>> >>> from inside my project and then go to localhost:8000/polls, I get a
>> 404.
>> >>>
>> >>> Page not found (404)
>> >>> Request Method: GET
>> >>> Request URL: http://localhost:8000/polls
>> >>>
>> >>> Using the URLconf defined in learning_python.urls, Django tried these
>> >>>
>> >>> URL patterns, in this order:
>> >>>
>> >>>1. ^admin/
>> >>>
>> >>> The current URL, polls, didn't match any of these.
>> >>>
>> >>>
>> >>> I did everything as the tutorial told me, so I'm a little bit lost as
>> >>>
>> to
>> >>>
>> >>> why this is happening.  Thanks in advance.
>> >>>
>> >>> --
>> >>> 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/56610bfb-c82b-426c-8346-ec8abe2300d5%40googlegroups.com
>>
>> >>>
>> >>> <
>> https://groups.google.com/d/msgid/django-users/56610bfb-c82b-426c-8346-ec8abe2300d5%40googlegroups.com?utm_medium=email_source=footer>
>>
>>
>> >>> .
>> >>> For more options, visit https://groups.google.com/d/optout.
>> >>>
>> >>
>> >>
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups
>> > "Django users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> an
>> > email to django-users...@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/d1be737c-05de-4f0b-8dd0-abe7ac3f0aa4%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/4f860c1e-cedc-4719-af38-31a6a7c87d4f%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/CALn3ei3G7q_pe67GogrFh2UvNKsahM4pkMLEOvep_A7dkPZ79A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Having trouble with Django tutorial

2017-03-03 Thread Vijay Khemlani
How does your learning_python.urls look like?

On 3/3/17, Yves S. Garret <yoursurrogate...@gmail.com> wrote:
> Yes.
>
> On Thursday, March 2, 2017 at 11:09:58 AM UTC-5, Vijay Khemlani wrote:
>>
>> Did you do this step?
>>
>> The next step is to point the root URLconf at the polls.urls module. In
>> mysite/urls.py, add an import for django.conf.urls.include and insert an
>> include()
>> <https://docs.djangoproject.com/en/1.10/ref/urls/#django.conf.urls.include>
>> in
>> the urlpatterns list, so you have:
>> mysite/urls.py
>>
>> from django.conf.urls import include, urlfrom django.contrib import admin
>> urlpatterns = [
>> url(r'^polls/', include('polls.urls')),
>> url(r'^admin/', admin.site.urls),]
>>
>>
>> On Thu, Mar 2, 2017 at 11:40 AM, Yves S. Garret <yoursurr...@gmail.com
>> > wrote:
>>
>>> Hi all,
>>>
>>> I'm going through this tutorial:
>>> https://docs.djangoproject.com/en/1.10/intro/tutorial01/
>>>
>>> And the problem that I'm having is when I start the 'polls' application
>>> from inside my project and then go to localhost:8000/polls, I get a 404.
>>>
>>> Page not found (404)
>>> Request Method: GET
>>> Request URL: http://localhost:8000/polls
>>>
>>> Using the URLconf defined in learning_python.urls, Django tried these
>>> URL patterns, in this order:
>>>
>>>1. ^admin/
>>>
>>> The current URL, polls, didn't match any of these.
>>>
>>>
>>> I did everything as the tutorial told me, so I'm a little bit lost as to
>>>
>>> why this is happening.  Thanks in advance.
>>>
>>> --
>>> 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/56610bfb-c82b-426c-8346-ec8abe2300d5%40googlegroups.com
>>>
>>> <https://groups.google.com/d/msgid/django-users/56610bfb-c82b-426c-8346-ec8abe2300d5%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d1be737c-05de-4f0b-8dd0-abe7ac3f0aa4%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/CALn3ei0_2F3kSwZD2bqPesPDQGC5io1iZ2nxfKtcUAoJGgewYw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Having trouble with Django tutorial

2017-03-02 Thread Vijay Khemlani
Did you do this step?

The next step is to point the root URLconf at the polls.urls module. In
mysite/urls.py, add an import for django.conf.urls.include and insert an
include()
 in
the urlpatterns list, so you have:
mysite/urls.py

from django.conf.urls import include, urlfrom django.contrib import admin
urlpatterns = [
url(r'^polls/', include('polls.urls')),
url(r'^admin/', admin.site.urls),]


On Thu, Mar 2, 2017 at 11:40 AM, Yves S. Garret 
wrote:

> Hi all,
>
> I'm going through this tutorial:
> https://docs.djangoproject.com/en/1.10/intro/tutorial01/
>
> And the problem that I'm having is when I start the 'polls' application
> from inside my project and then go to localhost:8000/polls, I get a 404.
>
> Page not found (404)
> Request Method: GET
> Request URL: http://localhost:8000/polls
>
> Using the URLconf defined in learning_python.urls, Django tried these URL
> patterns, in this order:
>
>1. ^admin/
>
> The current URL, polls, didn't match any of these.
>
>
> I did everything as the tutorial told me, so I'm a little bit lost as to
> why this is happening.  Thanks in advance.
>
> --
> 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/56610bfb-c82b-426c-8346-ec8abe2300d5%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/CALn3ei1KPoBvt%2B93b7ni9m4M%3DZ1Y_kSQQcTY1x1uyd2x5D6gBg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: get_or_create IntegrityError

2017-02-16 Thread Vijay Khemlani
As far as I know Postgres uses "sequences" for generating the model IDs.

If you set the id manually I think you are bypassing the sequence,
which doesn't autoincrement. So when you use the sequence the next
time the ID clashes.

pgAdmin should auto generate the id if you leave the field blank.

On 2/16/17, Matthew Pava  wrote:
> This is a fascinating issue, fellow Django users.
>
> I have a model called Lookups that is basically just an auto-generated pk
> and a name.  I added some data to that table using pgAdmin 3 since I'm using
> a PostgreSQL backend.
> One of my users then filled out a form that ran some code that would
> 'get_or_create' on the Lookups model.  It threw an IntegrityError saying
> that the Key (id)=# already exists.
> Upon further investigation, I realized that the id # was one that I had
> already entered manually in the database several days ago.  Only after the
> user kept running that form until the id incremented to one that did not
> exist did the IntegrityError go away.
>
> Maybe I entered the id manually in pgAdmin 3 instead of letting it do the
> auto-generation and that's why it broke?
>
> But Django was generating the proper SQL, so I can't imagine how Django
> could possibly be involved in addressing this issue:
>
> 'INSERT INTO "general_lookups" ("name") VALUES (%s) RETURNING
> "general_lookups"."id"'
>
>
> Maybe it's more a problem with PostgreSQL, but I wanted to share this with
> you in case you ever run into this issue.  I think for now, I should just
> use Django to enter data into the database, or test pgAdmin to
> auto-increment the id with manual data entry.
>
> --
> 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/5d108192354c470ca56946d28ffe02b7%40ISS1.ISS.LOCAL.
> 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/CALn3ei3ZjhY%2BYfZyJUzZamA8t1t3JUw37_mGm%2BY4ymFG%2Bq%3D7Cw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Debug Toolbar installation

2017-01-28 Thread Vijay Khemlani
Did you install debug_toolber on your server?

pip install django-debug-toolbar

On 1/28/17, Richard Jackson  wrote:
> Hi everyone,
>
> I've recently installed the Django Debug Toolbar for local use; I've just
> pushed the code online and am greeted with the below error:
>
> [81.95.157.172] out: Traceback (most recent call last):
> [81.95.157.172] out:   File "", line 1, in 
> [81.95.157.172] out:   File
> "/home/rjackson87/.virtualenvs/richardjackson/lib/python2.7/site-packages/django/__init__.py",
>
> line 18, in setup
> [81.95.157.172] out: apps.populate(settings.INSTALLED_APPS)
> [81.95.157.172] out:   File
> "/home/rjackson87/.virtualenvs/richardjackson/lib/python2.7/site-packages/django/apps/registry.py",
>
> line 85, in populate
> [81.95.157.172] out: app_config = AppConfig.create(entry)
> [81.95.157.172] out:   File
> "/home/rjackson87/.virtualenvs/richardjackson/lib/python2.7/site-packages/django/apps/config.py",
>
> line 86, in create
> [81.95.157.172] out: module = import_module(entry)
> [81.95.157.172] out:   File
> "/usr/local/lib/python2.7/importlib/__init__.py", line 37, in import_module
> [81.95.157.172] out: __import__(name)
> [81.95.157.172] out: ImportError: No module named debug_toolbar
> [81.95.157.172] out:
>
> Fatal error: run() received nonzero return code 1 while executing!
>
> Requested: python -c "import
> os;os.environ['DJANGO_SETTINGS_MODULE']='richardjackson.settings';import
> django;django.setup();from django.conf import
> settings;print(settings.STATIC_ROOT)"
> Executed: /bin/bash -l -c "cd /home/rjackson87/webapps/richardjackson
>>/dev/null && source
> /home/rjackson87/.virtualenvs/richardjackson/bin/activate && python -c
> \"import
> os;os.environ['DJANGO_SETTINGS_MODULE']='richardjackson.settings';import
> django;django.setup();from django.conf import
> settings;print(settings.STATIC_ROOT)\""
>
> What should I do to resolve this?
>
> Cheers,
>
> Rich
>
> --
> 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/d3657e15-1375-481c-ba6d-f3a97ed0dca5%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/CALn3ei33n0c9wxz_%3Depj2er1jbE1PYF8nYRq1sO_91wk8omYSg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Am I stupid or is there an essential error in Django 1.10 Docs?

2017-01-28 Thread Vijay Khemlani
> A quick one is e.g. that there is no explanation of what a view is and what
>
> its purpose is.

"The code above maps URLs, as simple regular expressions, to the
location of Python callback functions (“views”)"

"Each view is responsible for doing one of two things: Returning an
HttpResponse object containing the content for the requested page, or
raising an exception such as Http404. The rest is up to you."

> For a beginner it would be much more easy to simply user render() from the
> beginning on and later show cases where render() is not sufficient to do
> the job.

As a matter of fact it is easier to use Class based views usually, so
calling render explicitly is not that common, but function based views
are easier to understand initially.

> If I could I would gladly rewrite the tutorial. But sadly I do not have
> enough time to do so.

Maybe... it's a good thing you don't have time really

On 1/28/17, 'Peter Müller' via Django users
 wrote:
>
> If I could I would gladly rewrite the tutorial. But sadly I do not have
> enough time to do so.
> However I think it is bad since it not only completely disregards the zen
> of py but also its own principles (DRY etc.) If you need concrete examples
> I can name you tons.
> A quick one is e.g. that there is no explanation of what a view is and what
>
> its purpose is.
> Also there is literally in part three: "But, don’t do that. It’s silly.".
> If I should not do it then do not mention in a beginners tutorial…
> Another example here is the "shortcut" render() function. It is a beginners
>
> tutorial so I do not expect an in-depth explanation of any way possible but
>
> only the easiest one.
> For a beginner it would be much more easy to simply user render() from the
> beginning on and later show cases where render() is not sufficient to do
> the job.
> By far the best tutorial I yet had was of pygame. One well documented
> example and the docs were enough to teach me how it works.
>
> On a side-note (this is only personal preference):
> I do not like that the tutorial is part of the documentation.
> A tutorial should never be a documentation. A documentation should capture
> anything you can do with the framework.
> However a tutorial should only show you one way (and also the easiest) of
> doing of one certain task.
>
> Am Freitag, 27. Januar 2017 20:50:39 UTC+1 schrieb Melvyn Sopacua:
>>
>> https://github.com/django/django/pulls
>>
>>
>>
>> The tutorial has a very logical order, going from the database abstraction
>>
>> up to the template layer and beyond. But feel free to rewrite it and
>> submit
>> it to the project.
>>
>>
>>
>> I never follow tutorials to the letter - for example back when I did it in
>>
>> Django 1.3, my polls app had an ip-based rate limiter tucked onto existing
>>
>> code - but it certainly is one of the top tutorials for a framework I've
>> seen.
>>
>>
>>
>> On Friday 27 January 2017 10:27:46 'Peter Müller' via Django users wrote:
>>
>> > What do you mean by PR?
>>
>> >
>>
>> > Am Freitag, 27. Januar 2017 18:32:23 UTC+1 schrieb Melvyn Sopacua:
>>
>> > > On Monday 16 January 2017 07:49:00 'Peter Müller' via Django users
>> wrote:
>>
>> > > > Also I used the tutorial just that I abstracted the concept since
>>
>> > > > I
>>
>> > > >
>>
>> > > > think the tutorial is more than bad.
>>
>> > >
>>
>> > > Awaiting your PRs.
>>
>> > >
>>
>> > >
>>
>> > > Melvyn Sopacua
>>
>>
>>
>> --
>>
>> Melvyn Sopacua
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/6c24f788-7a60-4118-96d7-58c52376bb30%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/CALn3ei0_8Pi2ZC0KJ5U70DpZpuR145TMVqkgW52ce6Sga%2BXZAQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Model forms

2017-01-24 Thread Vijay Khemlani
Crispy forms is also good

http://django-crispy-forms.readthedocs.io/en/latest/

On 1/24/17, Fred Chevitarese  wrote:
> Hey!
>
> I use this app to make my job easier :P
> https://github.com/dyve/django-bootstrap3
>
> Just install it and follow the instructions ;)
>
>
> Cheers!
>
>
>
> *"*
> *São os homens que mais me surpreendem na humanidade. Porque perdem a saúde
> para juntar dinheiro, depois perdem dinheiro para recuperar a saúde. E por
> pensarem ansiosamente no futuro, esquecem do presente de tal forma que
> acabam por não viver nem o presente nem o futuro. E vivem como se nunca
> fossem morrer e morrem como se nunca tivessem vivido” - Dalai Lama.*
> *"*
>
> *Fred Chevitarese - GNU/Linux*
> *http://chevitarese.wordpress.com* 
>
>
>
> 2017-01-24 11:06 GMT-02:00 JJEMBA KENNETH :
>
>> Hello Django user,
>> Am a new user and am worndering  How can I add a css class to django
>> model
>> forms, like bootstrap classes
>>
>> --
>> Jjemba Kenneth
>>
>> --
>> 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/CALHyo8_vKn7wJQAjTOqgqZMscB2nUakBxCCDi
>> %2Bhb62rCYOuQ-g%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/CAKyfVp%2ByKyuGUqUXe72efNVD_jW3-YwcEH-Okc2LTD_ik51VbQ%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/CALn3ei1AWZTt%3D1LobouhxsEEZGYecSHPTW%2BcGPSpNF406OwKsw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: urls with https and s3:// as parameters

2017-01-19 Thread Vijay Khemlani
Shouldn't the paths be passed as GET or POST arguments instead of part
of the URL path? Why would you need the regex then?

On 1/19/17, Ramon Ramirez-Linan  wrote:
> Hi
>
> I am building a django app which urls take 2 parameters a source and
> destination.
> The source is either a url for a file http://something.com/file.jpg or an
> s3 arn s3://bucketname/key.jpg
>
> I am having difficulties creating a regex expression that matches that to
> route it to my view
>
> The first problem is from the fact that the source may contain '/' and '.'
>
> Any suggestion will be welcome
>
> Thanks
>
> Ramon
>
> --
> 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/44c48066-2cd1-49a9-aa88-c9730c9a9d79%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/CALn3ei1rm%3DXG%2BGTgKoB%3D_q7_BQO2XGMAr2vQeUbAtGAPpc9mxg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: What is the best library for Facebook social auth?

2017-01-18 Thread Vijay Khemlani
I like django-allauth

http://django-allauth.readthedocs.io/en/latest/

On 1/18/17, christina zou  wrote:
> Hi,
>
> I am new to Django and web development in general. I am trying to
> incorporate facebook social auth into django. I assume this is a common
> need for which there is a well supported library.
>
> I was using django-social-auth and running into a lot of errors. In
> particular, I am currently receiving the following error when trying to
> authenticate:
>
> AuthAlreadyAssociated at /oauth/complete/facebook/ This facebook account is
>
> already in use.
>
> Does anyone have guidance on this error?
>
> Anyways, I noticed this library has been deprecated for python-social-auth.
>
> But when I visited its github page, I see that python-social-auth itself
> was deprecated last month. So what is the recommended solution here, if not
>
> django-social-auth?
>
>
> --
> 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/ef1c348b-3992-46fb-b179-baf7ed9269e7%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/CALn3ei2iS68oOiCLnf32We%3DKb6JhmqdCGTTdvpp-OnOd_%2Bg2ng%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Am I stupid or is there an essential error in Django 1.10 Docs?

2017-01-17 Thread Vijay Khemlani
The only "custom include" in Django is for loading other url files

The rest of the imports are typical Python module / packages

On 1/17/17, 'Peter Müller' via Django users
 wrote:
> Ah I now see the problem. However I tried to remove the entry in the
> __init__.py file
> Python is then unable to find *any *module in that directory. Don't ask me
> why that is.
>
> Also I noticed that django has its completely own import ecosystem.
> So I used django.conf.urls.include to include a new urls file in that sub
> directory.
> And suddenly everything works fine.
>
> Thanks everyone
>
> Am Dienstag, 17. Januar 2017 08:01:41 UTC+1 schrieb Michal Petrucha:
>>
>> On Mon, Jan 16, 2017 at 12:23:09PM -0800, 'Peter Müller' via Django users
>>
>> wrote:
>> > Am Montag, 16. Januar 2017 21:20:53 UTC+1 schrieb Daniel Roseman:
>> > > The traceback shows that you are importing your views module in the
>> > > __init__.py of your app. Don't do that.
>> >
>> > Well else python doesn't find the view.py file?
>>
>> Python will be able to import db_testing.views just fine even if you
>> don't import viewsi from . in db_testing/__init__.py. All Python cares
>> about is that there is a correct Python file in the correct location.
>>
>> If you're interested in more details about what's going wrong here,
>> there's an explanation here:
>>
>> https://docs.djangoproject.com/en/1.10/ref/applications/#how-applications-are-loaded
>>
>>
>> In particular, the following paragraphs:
>>
>> > At this stage, your code shouldn’t import any models!
>> >
>> > In other words, your applications’ root packages and the modules
>> > that define your application configuration classes shouldn’t import
>> > any models, even indirectly.
>>
>> What's happening here is that the root of your “db_testing” package
>> (i.e. db_testing/__init__.py) indirectly imports models, because it
>> imports the views module, which in turn imports models.
>>
>> Just removing the “from . import views” line should let you move
>> forward – unless you also have other imports in the __init__.py file,
>> in which case you can most likely just remove them, too. In general,
>> in an average Django package, there's little reason to import stuff in
>> its root package.
>>
>> Good luck,
>>
>> 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/b1760656-c6a0-40c5-a002-19958e5706ef%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/CALn3ei3UOv%2BeiT6eRbZqSnmaNadbc-Smwfc%2BCK0%3DMuxC2opTCg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help with a school project

2017-01-14 Thread Vijay Khemlani
Read the tutorial I guess

https://docs.djangoproject.com/en/1.10/intro/tutorial01/

After that handling form data and saving to the databse should be trivial

On 1/14/17, Grant Holman  wrote:
> I need help starting a django project for a school project. I am brand new
> to Django but have some experience with Python.
>
> I need to design web application where inputs are put onto a screen and
> then inputted into a database. From my research this is a simple process
> with Django. Does anyone have any code that simply does this that I can use
>
> to get started>
>
> --
> 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/882e8968-9b85-4736-9b92-662e0c7ec329%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/CALn3ei0EfEXb%3DrT1Wk-5dh8BJ5qzYvJo8apWifdLw2HCh3XXQg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Get current site inside model

2017-01-13 Thread Vijay Khemlani
I'm not gonna start on the "cool" part

You could generate the urls on the view and pass them already
generated to the template

On 1/13/17, Max  wrote:
> {{ domain }}{{ ob.get_absolute url }} - is not cool , i set site with
> context proccesor for domain
>
> Once again, if you don't have a default site_id or the request object
>> available inside the method, then what do you expect it to return? I'm
>> not asking programatically, but logically,
>
>
> if site_id is enabled, django is not use site by request.
>
> So, can i get request obj inside model? Is not true MVC pattern, but in
> docs i cannot change runtime settings(not recommended)
>
>
>
> --
> 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/0b7653e3-0b93-4f09-81eb-51d23216dec5%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/CALn3ei0LYsY_ruP5Q9CGB377Q-%3DWSiSDiVp-PVo%3DEjkcvmkiKA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Get current site inside model

2017-01-13 Thread Vijay Khemlani
Once again, if you don't have a default site_id or the request object
available inside the method, then what do you expect it to return? I'm
not asking programatically, but logically,

If you only care about the template the you can concatenate the domain
and the absolute path in the template itself

{{ domain }}{{ ob.get_absolute url }}

where the absolute url is something like '/model/5' or something like
that, without the domain.



On 1/13/17, Max <kiselev...@gmail.com> wrote:
> Vijay Khemlani, i think my question have not a lot of details. More
> 1) Django site framework (works with request.get_host() without Site_id).
> I can get the current site with Site.objects.get_current(*request*),
> shortcuts (get_current_site) or through model. But i have only one model
> with site relationship.
>
> 2) Django class-based view.
>
> 3) For example, template
>
>> {{obj.get_url}} <- error Site does not exists [set site_id or use 1)]
>
>
> Model
> class Model(models.Model):
>   def get_absolute_url(self):
>
> return 'http://{}{}'.format(Site.objects.get_current().domain,
> reverse(viewname='product',
> args=[self.slug]))
>
>
> Thanks, also i do not want to change site_id dynamically (thread) or use
> site through model-model.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/32ee2f28-8d2b-4a14-ba87-c6150fd88399%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/CALn3ei1Sj4%3DEu-pzWa5RKbi%3DfDVhX3%2B6byNESqYeN%3DvUz4WBYw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


  1   2   3   4   >