Slick Reporting Dashboard

2024-02-16 Thread Rupert Robin
I am have a slick-reporting dashboard with 4 reports.
However, the filters and CSV export options do not appear in the dashboard 
rendering of the ReportView(s).
When a single report view is called directly, now the Filter and Export CSV 
options are shown.
How can I get the Filters and Export CSV to appear in the dashboard 
renderings?

Any insights appreciated! 
Thanks - Rupert

-- 
You received this message because you are subscribed to the Google Groups 
"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/a169113b-e039-4f7c-b8b2-edd7e4656c2en%40googlegroups.com.


Django Slick Reporting Dashboard

2024-02-16 Thread Rupert Robin
I have a Slick-Reporting Dashboard with 4 reports.
The dashboard rendering of the ReportView reports using the 
get_widget_from_url method does not include the Filter and Export CSV 
options.
These options DO render when the report is called directly into a single 
page view.

Is there a way of including the Filter and Export CSV options into the 
dashboard?

Any insights welcomed! 

Thank you - Rupert

-- 
You received this message because you are subscribed to the Google Groups 
"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/45ad31a2-243c-4e88-a894-7202bc652404n%40googlegroups.com.


Re: Django books

2024-01-30 Thread Marcelo Robin
https://dokumen.pub/qdownload/django-for-beginners-build-websites-with-python-and-django-1st-edition-1983172669-9781983172663.html

El lun, 29 ene 2024 a la(s) 10:01 p.m., AshiQul Islam Munna (
ashiq.cse.m...@gmail.com) escribió:

> Can I get the 'Django for Beginners Build websites with Python and Django
> By William S. Vincent' pdf for free?
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/6e50722f-a36d-407e-b5f3-f7afec5adb6cn%40googlegroups.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/CAH25kbR4a4%2Bw%2BosPgQO3%2BiSeZpTrjqZPJu3mo77-bmBj3OUmJw%40mail.gmail.com.


Re: Using JavaScript to enumerate a dataset returned to a page.

2023-06-19 Thread Robin Riis
With vanilla js

for(let i = 1; i < myArray.length; i += 1) {
document.log("index: " + i);
document.log(myArray[i] + "\n");
}

Wrote this on my phone so may contain some fault, but a for-loop is
sufficent.

On Mon, Jun 19, 2023, 16:29 Lee Stevens  wrote:

> Helo,
>
> I have a dataset returning to a page.  I need JavaScript to be able to
> process this.
>
> Instead of using:
> {% for item in dataset %}
> {{ item.field1 }}
> {{ item.field2 }}
> {% endfor %}
>
> Is there a *JavaScript* way to read this dataset/variable instead?
>
> 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/37febb44-36e2-47ca-9eff-7011c4e9b963n%40googlegroups.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/CAPLZMbPghY%2BCAEW6G3T2qC1w7GM5P0TkCZ_XedtANcmbsSmo7w%40mail.gmail.com.


Re: Question re: input

2023-04-01 Thread Robin Riis
You can check out rabbitMQ if it can fit your needs. Theres a plugin in
django that simplifies integration.

On Sat, Apr 1, 2023, 19:06 o1bigtenor  wrote:

> On Sat, Apr 1, 2023 at 9:51 AM Robin Riis  wrote:
> >
> > What kind of environment are we talking about?
>
> Me designed software  - - - physically challenging (possible outdoors,
> possible inclement conditions + )
> >
> > But i guess you mean that you have a server in one location and multiple
> clients from diffrent locations that should be able to upload some kind of
> data to the server.
>
> Not really
> >
> > SSH is great to connect to a remote machine in a secure manner. And scp
> to send files over ssh.
> >
> > But it may not be what you are seeking. Is it files you wanna send or a
> bytestream? What requirements are needed regarding security? About how much
> data will be sent per request? Would you wanna send data over udp or tcp?
> Are you really asking in the right forum?
> >
> > Maybee checkout unix sockets.
> >
> > Or is it just like people would login and write like a comment or upload
> a photo?
> >
>
> More like user a needs to include notes on item xx
> user b is doing y
> user c has observed event WNIYx
> possibly 15 to 20 input streams possible
>
>
> (information I can find is predominantly finding information on web - - - -
> this is much more doing task x - - - generating notes/data
> task . . . .
> etc to where there are a lot of tasks (some will generate a lot of
> data (pulled into a database))
>
> Does 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAPpdf59q8YbZMbaZ8%3DVkNVyWFa59mMCW%2BUWA807qafP%3DHNTu%2BQ%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/CAPLZMbNx3-gDLUsw3k0Bp%2BbTn0i%3DATbNTzK7%3Des-OQzgOFX2Vg%40mail.gmail.com.


Re: Adding extra registration fields to my user registration

2023-04-01 Thread Marcelo Robin
you can create an application called profile where in its models you can
place all the fields you need to add about the user. This video explains
how you can do it. https://youtu.be/R8EHCohLvbw

El jue, 30 mar 2023 a la(s) 00:08, Ebenezer Otchere (swazyman1...@gmail.com)
escribió:

> I want to collect user information in my registration forms like first
> name last name and country
> but it give me errors that unexpected keyword arguments with firstname
> lastname and country
> Any help how i will add extra fields to be store in the database thank You
> and 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/97319e37-1d3d-4000-8f65-4c161140d878n%40googlegroups.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/CAH25kbSWp_1jmFYKdOcOWG3UTeU0EX%2BOTevKQ6f_T-b99Vxgzg%40mail.gmail.com.


Re: Question re: input

2023-04-01 Thread Robin Riis
What kind of environment are we talking about?

But i guess you mean that you have a server in one location and multiple
clients from diffrent locations that should be able to upload some kind of
data to the server.

SSH is great to connect to a remote machine in a secure manner. And scp to
send files over ssh.

But it may not be what you are seeking. Is it files you wanna send or a
bytestream? What requirements are needed regarding security? About how much
data will be sent per request? Would you wanna send data over udp or tcp?
Are you really asking in the right forum?

Maybee checkout unix sockets.

Or is it just like people would login and write like a comment or upload a
photo?

Im just shooting in the dark here..
Please be more specific.

On Sat, Apr 1, 2023, 16:33 o1bigtenor  wrote:

> Greetings
>
> I am in the porcess of planning out a complicated environment.
>
> User will almost always be remote.
>
> How does one easily get information 'into' the environment?
>
> (Not sure these are the right questions but
> 1. Does one have to be connected to the environment
> 2. Does the complete form have to be on the inputting device   )
>
> for starters
>
> TIA
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/CAPpdf59HucOB%3Ds99MxkxkfZ3HFmMO7DN4EP%3Dm3ub67%3D_iHArew%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/CAPLZMbMqvkL1xVdmuh8L1mNTX5GcWs_ForpxugncJMYnKCAmKA%40mail.gmail.com.


Django-allauth & Facebook login

2023-04-01 Thread Marcelo A. Robin
Hi, I'm trying to use django-allauth to create a facebook login system.  i 
managed to get it all done but in my local test i get an error where 
facebook tells me my app path is not safe.  I understand that my 
http://localhost is missing the https://localhost.  this is so ?  How can I 
add https to my Django test server?

I think there is an add-on that by installing it creates the https at the 
beginning of the route 127.0.0.1:8000.  What I don't know is if, when 
uploading the project to production, I should remove that library along 
with all the configurations that I have to do in settings.py

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


Re: Loop through QuerySet in Django

2022-11-04 Thread Marcelo Robin
I have a problem

El jue., 3 nov. 2022 16:40, subin  escribió:

> Please let me know if that is okay.
>
> On Wed, Nov 2, 2022 at 5:03 PM Marcelo A. Robin 
> wrote:
>
>> I have a processors.py file where I generate a context processor to load
>> static data into my project's base template. I have posts and I want to
>> generate as a kind of archive in a aside, where you can access through a
>> link, the posts that were created in the month of August 2022 (for example)
>> and that will take me to a page where I will see the entire list of posts.
>> To build that list, from this kind of file, I do the following in the
>> processors.py file:
>>
>> def ctx_dic_history(request):
>> ctx_history = {} ctx_history['dates'] =
>> Post.objects.dates('created','month').distinct()
>> return ctx_history
>>
>> If I put {{ dates }} in the aside, it returns the following:
>>
>> > datetime.date(2022, 9, 1), datetime.date(2022, 10, 1)]>
>>
>> Now I want to go through that queryset, but I can't get what I need: I
>> want them to be sorted descending first, that is, the most recent month on
>> top. Second, I want to access the month and the year, that is, something
>> like "August 2022" appears.
>>
>> {% for item in dates %} Probando {% endfor %}
>>
>> With that I can iterate over the items that this queryset brings me, but
>> I don't know how to access the date in question for each item in the
>> queryset. If you can give me a hand I would appreciate it in advance. If I
>> manage to get it to work, I'll definitely post the answer that worked for
>> me. Thank you so much
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "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/96f58712-88e9-4eae-94f6-909918f2045en%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/96f58712-88e9-4eae-94f6-909918f2045en%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
> --
> 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/H1o_Zpd47jk/unsubscribe.
> To unsubscribe from this group and all its topics, 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/CAJnMy6ch9TUmu01%2BTw65jApLasVXSvMPu7%2BmMKWi6O-BFW10VA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAJnMy6ch9TUmu01%2BTw65jApLasVXSvMPu7%2BmMKWi6O-BFW10VA%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

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


Loop through QuerySet in Django

2022-11-02 Thread Marcelo A. Robin
I have a processors.py file where I generate a context processor to load 
static data into my project's base template. I have posts and I want to 
generate as a kind of archive in a aside, where you can access through a 
link, the posts that were created in the month of August 2022 (for example) 
and that will take me to a page where I will see the entire list of posts. 
To build that list, from this kind of file, I do the following in the 
processors.py file:

def ctx_dic_history(request): 
ctx_history = {} ctx_history['dates'] = 
Post.objects.dates('created','month').distinct()
return ctx_history

If I put {{ dates }} in the aside, it returns the following:



Now I want to go through that queryset, but I can't get what I need: I want 
them to be sorted descending first, that is, the most recent month on top. 
Second, I want to access the month and the year, that is, something like 
"August 2022" appears.

{% for item in dates %} Probando {% endfor %}

With that I can iterate over the items that this queryset brings me, but I 
don't know how to access the date in question for each item in the 
queryset. If you can give me a hand I would appreciate it in advance. If I 
manage to get it to work, I'll definitely post the answer that worked for 
me. Thank you so much

-- 
You received this message because you are subscribed to the Google Groups 
"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/96f58712-88e9-4eae-94f6-909918f2045en%40googlegroups.com.


Re: recursos premium en Django

2022-10-10 Thread Marcelo Robin
muchas gracias !!! ya los estoy siguiendo !!!

El dom, 2 oct 2022 a la(s) 07:10, ASAMOAH EMMANUEL (
emmanuelasamoah...@gmail.com) escribió:

> Hola compañeros desarrolladores, he configurado un canal privado en
> telegram donde he puesto recursos premium. Los recursos cubren el
> desarrollo web de Django desde principiante hasta profesional, tecnologías
> docker, git, desarrollo de API, pruebas y todos los recursos de pila
> completa. Hay un grupo de discusión donde las personas pueden conectarse y
> colaborar para acelerar sus habilidades de desarrollo. Si está interesado,
> encuentre a continuación los enlaces privados tanto al grupo de discusión
> como al canal. ¡Cautela! este grupo es estrictamente para cosas
> relacionadas con django y python, se desaconsejan los spams, se respetan
> mutuamente la cultura y los antecedentes.
> https://t.me/+VXTu7RXQ47VlM2Q0
>
> https://t.me/+X6y16nFHNIA5ZjE0
> Si por alguna razón, no pudiera acceder a los enlaces proporcionados,
> podría enviarme un mensaje en telegram en mi identificador: @simple_genius.
> ¡Atentamente!
> Emmanuel Asamoah.
> Desarrollador backend 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/77e098e6-84bf-4282-ab48-8d5d38967857n%40googlegroups.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/CAH25kbQr_CsAyo%3DtSGg5hdSAXJOom67Pc-x0ewNpm0-yxk848A%40mail.gmail.com.


Re: How to approach

2021-11-04 Thread Robin Riis
i agree with kasper, but one tip is to start with the user class.
check out django.contrib.auth.base_user

Den tors 4 nov. 2021 kl 18:36 skrev Kasper Laudrup :

> On 04/11/2021 14.54, Trippy Samurai wrote:
> > Hi there,
> > I am new to django and have a problem statement am not quite sure how to
> > approach this,Please help me,
> >
>
> I think you should approach it just as it has been described, i.e. one
> step at a time.
>
> Kind regards,
>
> Kasper Laudrup
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/9c9dbfc3-8fa8-5ff2-8405-f5614da92f55%40stacktrace.dk
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/CAPLZMbNd1McEj53dx-ddf1SH4Scq69%3D8hW1MMPBP4BkuyRY%2ByQ%40mail.gmail.com.


[Django + Heroku] Timeout when receiving a request

2021-05-21 Thread Robin Bonnin

Hello! 

I maintain a Django app hosted on Heroku. We use DRF intensively to serve 
our FE app. 
Django version: 2.2.21.

We have an endpoint that works perfectly well 99% of the time, but 
sometimes, it timeouts.

We use Sentry to monitor and you can find the traces here 
<https://sentry.io/share/issue/791a44ef15404e36a1f52332b4217a90/>.

FYI but maybe it is not useful, this endpoint:

   - Has very little processing then starts a background task.
   - In the breadcrumb of Sentry, we can see that the REDIS *LPUSH *command 
   is triggered at the very end of the 20s heroku timeout.

It seems to me that the function calls is going back and forth between 

   - django/core/handlers/exception.py in inner at line 34
   - django/utils/deprecation.py in __call__ at line 94
   
This has been happening for months now and we still do not have a solution. 

Any idea as to why this might happen?
And why only in certain cases?

Thank you very much for the help!

Robin Bonnin

-- 
You received this message because you are subscribed to the Google Groups 
"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/fb444998-4c9d-4ba0-b8bf-903f063effc3n%40googlegroups.com.


models

2019-05-08 Thread Robin Riis
if i have a model like

class ShelfManager(models.Manager):

use_for_related_fields = True

def create_cabinet(self, name, number_of_shelfs):

cabinet = self.create(name=name, number_of_shelfs=number_of_shelfs)

created_shelfs = 0

while created_shelfs < number_of_shelfs:

cabinet.shelfs.create()

created_shelfs += 1

return place


class Cabinet(models.Model):

name = models.CharField(max_length=50, unique=True)

number_of_shelfs = models.IntegerField

shelfs = ShelfManager()

class Shelfs(models.Model):

place = models.ForeignKey(Cabinet, on_delete=models.CASCADE, null=True,
blank=True, related_name='shelfs')
...

and i want shelf to hold either model Box, Filter or Barrel
but not sure which approach to use :P

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


Re: Comment Form Related issue

2019-04-26 Thread Robin Riis
its pretty much the same, you can check on class based view where you have
CreateView and UpdateView and so on

and i would recomend to add the following to models.py:
updated_at = models.DateTimeField(null=True)
updated_by = models.ForeignKey(get_user_model(), on_delete=models.CASCADE,
null=True)

cheers mate

Den fre 26 apr. 2019 kl 14:05 skrev Soumen Khatua :

> Okay,Could you tell me If any user want to update their comment it later
> the process is same or different?
>
> Thank You
>
>
> On Fri, Apr 26, 2019 at 5:31 PM Robin Riis  wrote:
>
>> class Comment(models.Model): <--- in models.py
>>
>> class CommentForm(forms.ModelForm): <--- in forms.py
>>
>> def CommentVideo(request, pk): <--- in views.py
>>
>> and the video is another model i used since you said like youtube. :)
>>
>> Den fre 26 apr. 2019 kl 13:33 skrev Soumen Khatua <
>> soumenkhatua...@gmail.com>:
>>
>>> yes,I'm new to django so let me check once.
>>> Thank You for your response.
>>>
>>> On Fri, Apr 26, 2019 at 4:36 PM Robin Riis 
>>> wrote:
>>>
>>>> class Comment(models.Model):
>>>>
>>>> message = models.TextField()
>>>>
>>>> video = models.ForeignKey(Video, related_name='comments',
>>>> on_delete=models.CASCADE)
>>>>
>>>> created_at = models.DateTimeField(auto_now_add=True)
>>>>
>>>> created_by = models.ForeignKey(get_user_model(),
>>>> related_name='comments', on_delete=models.CASCADE)
>>>>
>>>>
>>>> class CommentForm(forms.ModelForm):
>>>>
>>>> class Meta:
>>>>
>>>> model = Comment
>>>>
>>>> fields = ['message',]
>>>>
>>>>
>>>> def CommentVideo(request, pk):
>>>>
>>>> video = get_object_or_404(Video, pk=pk)
>>>>
>>>> if request.method == 'POST':
>>>>
>>>> form = CommentForm(request.POST)
>>>>
>>>> if form.is_valid():
>>>>
>>>> comment = form.save(commit=False)
>>>>
>>>> comment.video = video
>>>>
>>>> comment.created_by = request.user
>>>>
>>>> comment.save()
>>>>
>>>> return reverse_lazy('my_cool_place')
>>>>
>>>> else:
>>>>
>>>> form = CommentForm()
>>>>
>>>> return render(request, 'path/to/html/file.html', {'video': video,
>>>> 'form': form})
>>>>
>>>> something like that?
>>>>
>>>> Den fre 26 apr. 2019 kl 12:34 skrev Soumen Khatua <
>>>> soumenkhatua...@gmail.com>:
>>>>
>>>>> Hi Folks,
>>>>> I want to show one textarea where only logged in users can comment
>>>>> otherwise if they are click the textareabox redirect them to login page
>>>>> just like youutbe comnet box. If anyone have any source code related to
>>>>> this please share.
>>>>>
>>>>> Thank You.
>>>>>
>>>>>
>>>>> Regards,
>>>>> Soumen
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Django users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to django-users+unsubscr...@googlegroups.com.
>>>>> To post to this group, send email to django-users@googlegroups.com.
>>>>> Visit this group at https://groups.google.com/group/django-users.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/django-users/CAPUw6WadmH6vfXBrpSfNdGrMRgVoBAV-DZfGbJkoO%2B1tVuWyfw%40mail.gmail.com
>>>>> <https://groups.google.com/d/msgid/django-users/CAPUw6WadmH6vfXBrpSfNdGrMRgVoBAV-DZfGbJkoO%2B1tVuWyfw%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.

Re: Comment Form Related issue

2019-04-26 Thread Robin Riis
class Comment(models.Model): <--- in models.py

class CommentForm(forms.ModelForm): <--- in forms.py

def CommentVideo(request, pk): <--- in views.py

and the video is another model i used since you said like youtube. :)

Den fre 26 apr. 2019 kl 13:33 skrev Soumen Khatua :

> yes,I'm new to django so let me check once.
> Thank You for your response.
>
> On Fri, Apr 26, 2019 at 4:36 PM Robin Riis  wrote:
>
>> class Comment(models.Model):
>>
>> message = models.TextField()
>>
>> video = models.ForeignKey(Video, related_name='comments',
>> on_delete=models.CASCADE)
>>
>> created_at = models.DateTimeField(auto_now_add=True)
>>
>> created_by = models.ForeignKey(get_user_model(), related_name='comments',
>> on_delete=models.CASCADE)
>>
>>
>> class CommentForm(forms.ModelForm):
>>
>> class Meta:
>>
>> model = Comment
>>
>> fields = ['message',]
>>
>>
>> def CommentVideo(request, pk):
>>
>> video = get_object_or_404(Video, pk=pk)
>>
>> if request.method == 'POST':
>>
>> form = CommentForm(request.POST)
>>
>> if form.is_valid():
>>
>> comment = form.save(commit=False)
>>
>> comment.video = video
>>
>> comment.created_by = request.user
>>
>> comment.save()
>>
>> return reverse_lazy('my_cool_place')
>>
>> else:
>>
>> form = CommentForm()
>>
>> return render(request, 'path/to/html/file.html', {'video': video, 'form':
>> form})
>>
>> something like that?
>>
>> Den fre 26 apr. 2019 kl 12:34 skrev Soumen Khatua <
>> soumenkhatua...@gmail.com>:
>>
>>> Hi Folks,
>>> I want to show one textarea where only logged in users can comment
>>> otherwise if they are click the textareabox redirect them to login page
>>> just like youutbe comnet box. If anyone have any source code related to
>>> this please share.
>>>
>>> Thank You.
>>>
>>>
>>> Regards,
>>> Soumen
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAPUw6WadmH6vfXBrpSfNdGrMRgVoBAV-DZfGbJkoO%2B1tVuWyfw%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAPUw6WadmH6vfXBrpSfNdGrMRgVoBAV-DZfGbJkoO%2B1tVuWyfw%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/CAPLZMbMsH-55Z_KK3byho-BqMDHaXWmWQcwnmn1ZDuKHUB56eg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAPLZMbMsH-55Z_KK3byho-BqMDHaXWmWQcwnmn1ZDuKHUB56eg%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/CAPUw6WbCeF%2BUuQVfOBoNEzM1vZo9dheKTQYoMz%3DQXfQmtgeTSQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAPUw6WbCeF%2BUuQVfOBoNEzM1vZo9dheKTQYoMz%3DQXfQmtgeTSQ%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/CAPLZMbOxPsNjD%2BDX6t36i3WZEwXLRXJW-qO7e%2BGeV5m%3DhXss-g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Comment Form Related issue

2019-04-26 Thread Robin Riis
class Comment(models.Model):

message = models.TextField()

video = models.ForeignKey(Video, related_name='comments',
on_delete=models.CASCADE)

created_at = models.DateTimeField(auto_now_add=True)

created_by = models.ForeignKey(get_user_model(), related_name='comments',
on_delete=models.CASCADE)


class CommentForm(forms.ModelForm):

class Meta:

model = Comment

fields = ['message',]


def CommentVideo(request, pk):

video = get_object_or_404(Video, pk=pk)

if request.method == 'POST':

form = CommentForm(request.POST)

if form.is_valid():

comment = form.save(commit=False)

comment.video = video

comment.created_by = request.user

comment.save()

return reverse_lazy('my_cool_place')

else:

form = CommentForm()

return render(request, 'path/to/html/file.html', {'video': video, 'form':
form})

something like that?

Den fre 26 apr. 2019 kl 12:34 skrev Soumen Khatua :

> Hi Folks,
> I want to show one textarea where only logged in users can comment
> otherwise if they are click the textareabox redirect them to login page
> just like youutbe comnet box. If anyone have any source code related to
> this please share.
>
> Thank You.
>
>
> Regards,
> Soumen
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAPUw6WadmH6vfXBrpSfNdGrMRgVoBAV-DZfGbJkoO%2B1tVuWyfw%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/CAPLZMbMsH-55Z_KK3byho-BqMDHaXWmWQcwnmn1ZDuKHUB56eg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


m2m createview bootstrap modal

2019-04-26 Thread Robin Riis
Hello Django community :D

i am currently learning django and am working on a vehicle app
where i currently have this models.py

class Engine(models.Model):
objects = EngineManager()
manufacture = models.CharField(max_length=80)
name = models.CharField(max_length=80)
filter_to_use = models.ManyToManyField('Filter') #this is in another app

class Meta:
unique_together = (('manufacture', 'name'),)

def natural_key(self):
return (self.manufacture, self.name)

def __unicode__(self):
return self.__str__()

def __str__(self):
return self.manufacture+' - '+self.name

class Vehicle_Model(models.Model):
engine = models.ForeignKey(Engine, on_delete=models.CASCADE)
name = models.CharField(max_length=100)
year_from = models.IntegerField(blank=True, null=True)
year_to = models.IntegerField(blank=True, null=True)
serial_number_from = models.CharField(max_length=100, blank=True,
null=True)
serial_number_to = models.CharField(max_length=100, blank=True,
null=True)
picture = models.ImageField(upload_to=modell_picture_path,
default='machine_models/none.png')



and i am trying to create a form for Engine.filter_to_use that will open in
a modal
the form currently looks like this:

class AddEngineFilterAjaxForm(PopRequestMixin, CreateUpdateAjaxMixin,
forms.ModelForm):

class Meta:
model = Engine
fields = ('filter_to_use',)
widgets = {'filter_to_use': forms.SelectMultiple(),}

def __init__(self, *args, **kwargs):
super(AddEngineFilterAjaxForm, self).__init__(*args, **kwargs)
self.fields['filter_to_use'].widget.attrs['class'] = 'selectpicker
form-control'
self.fields['filter_to_use'].widget.attrs['data-live-search'] =
'true'
self.fields['filter_to_use'].widget.attrs['title'] = 'Which filter
fits in the engine?'

and i am struggling with the view and right now im pretty lost of all the
trial and error :P
but i want it to have pre-selected all filters that are bound to the engine
and i want to be able to save the form.
it does look right, but the behaviour is not what i wanted.
any tips on how to write a class based view for this?

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/CAPLZMbMipUkgqbZiM0jVCrrJk4V6%2Bwqimup5PY4%2BC6iiT18xwA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to run ORM commands from DOM Javascript?

2019-04-09 Thread Robin Riis
in models.py you can define a 'as_json' function

def as_json(self):
return dict(
identification_number = self.id
awesome_picture = self.picture
)

in views.py:

class My_View(View):
def get(self, request):
if request.is_ajax():
q = request.GET.get('q', '')
answer = model.objects.get(pk=q)
if not answer:
this_answer = dict()
this_answer['results'] = 'did not find anything'
return JsonResponse(this_answer)
this_answer = [d.as_json() for d in answer]
return HttpResponse(json.dumps(this_answer,
content_type='application/json')
else:
this_answer = dict()
this_answer['not_allowed'] = 'you are not allowed here.'
return HttpResponse(this_answer,
content_type='application/json')

hope this helps!

Den tis 9 apr. 2019 kl 13:30 skrev sairanganadh Narayana <
ssaaii4...@gmail.com>:

> I'm trying to get run model.objects.filter(id=2) from javascript and show
> on database. I am unable to get solution for this. Please guide me solution
> for this or alternative for this.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/569ce414-b717-4348-a688-b92904036864%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/CAPLZMbMaB%3Dus-q3X%2BHQJNuQyL-74MdjpPUDJ1Mt8wOCcPrH-_g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: UniqueConstraint raises uncaught IntegrityError in Admin

2019-04-09 Thread Robin Riis
The Integrity error means that there is a row in the database with role = 1
So another row with role=1 would break the unique constraint and is not
allowed.

So either remove the unique constraint or make sure it will be unique.

Den tis 9 apr. 2019 13:29Ryan Jarvis  skrev:

> Hey there,
>
> I'm trying out the new UniqueConstraint functionality in Django 2.2 and
> seem to be misunderstanding something.  When adding a Constraint to the
> model I am getting an uncaught IntegrityError in the admin.
> I've got the following sample code:
>
> *models.py*
>
> class Seminar(models.Model):
> seminar_id = models.CharField(max_length=255, unique=True)
> members = models.ManyToManyField(User, through='SeminarRole',
> related_name="studies")
>
> class SeminarRole(models.Model):
> LEAD = 1  # Only 1 Lead permitted per seminar
> SUPPORT = 2
> ROLE_CHOICES = (
> (LEAD, 'Lead'),
> (SUPPORT, 'Support'),
> )
>
> user = models.ForeignKey(User, related_name='seminar_roles',
> on_delete=models.CASCADE)
> seminar = models.ForeignKey('seminar', related_name='roles',
> on_delete=models.CASCADE)
>
> role = models.IntegerField(choices=ROLE_CHOICES)
>
> class Meta:
> constraints = [
> models.UniqueConstraint(fields=['seminar'],
> condition=Q(role=1), name="only_one_lead"),
> ]
>
>
>
> For the code above in the Django Admin I can successfully add a
> SeminarRole with User1 as the Lead for SeminarA, User2 as the Lead for
> SeminarB, and User1 as Support for SeminarB but if I try and add User2 as
> another Lead to SeminarA it gives me an Exception.  Should I be seeing the
> Django Admin catch this before hand?
>
> IntegrityError at /admin/study_management/seminarrole/add/
> duplicate key value violates unique constraint "only_one_lead"
> DETAIL:  Key (seminar_id)=(1) already exists.
>
>
> I'm on Django 2.2, Python 3.7 and Postgres 11.2
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/fb2ab520-178d-4a0c-acf7-8cb0498936e4%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/CAPLZMbPxNN%3DCa6GqjcR_kXDO_a2VyzKxgVNfTgzAdtnfhhYqgA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: how do I create a slug in Django 2.2

2019-04-09 Thread Robin Riis
def save(self, *args, **kwargs):
self.slug = slugify(self.title)
super(name, self).save(*args, **kwargs)

Den tis 9 apr. 2019 12:24AMI FIDELE  skrev:

> I have tried to create a slug watch here and please tell the problem
>
> this is model.py
>
> from django.db import models
>
> # this is my models
> class Article(models.Model):
> title = models.CharField(max_length=100)
> slug = models.SlugField()
> body = models.TextField()
> date = models.DateTimeField(auto_now_add=True)
>
>
> def __str__(self):
> return self.title
> def snippet(self):
>
> return self.body[:90] + '...''
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/aa159472-fb87-44aa-8da1-d1058ccecd5d%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/CAPLZMbOebd%2B_FJCpEmfdiyXzJ%3Dc4C2Kp9bvNfEWXEdfPqHSuSg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: HTML form filled, proposes a download link for the data filled in a json file

2019-04-09 Thread Robin Riis
Hello!

well in the form is there anything that will be saved in a database?
if so you can start by looking at models.py in your application.

if not you can jump directly to forms.py.

an example of a model and form:

*** in models.py
from django.db import models

class Company(models.Model):
"""This is your database model with the fields you want to store and
fetch!
"""
name = models.CharField(max_length=60)
telephone = models.CharField(max_length=15, null=True, blank=True)
info = models.TextField(blank=True, null=True)
is_awesome = models.BooleanField(default=False)

*** in forms.py
from django import forms
from .models import Company

class CompanyForm(forms.ModelForm):
class Meta:
model = Company
fields = '__all__'
widgets = {
'is_awesome': forms.HiddenInput(),
}

then when you have a form and model you can use the generic views like this:

*** in views.py
from django.urls import reverse_lazy
from django.views.generic import CreateView
from django.contrib.messages.views import SuccessMessageMixin

from .models import Company
from .forms import CompanyForm

class Add_Company(SuccessMessageMixin, CreateView):
template_name = 'company/add_a_new.html'
success_message = 'a new company was added!'
success_url = reverse_lazy('home')
form_class = CompanyForm

thats it!


Den tis 9 apr. 2019 kl 00:20 skrev Bassem Boulfarkat <
bassem.boulfar...@gmail.com>:

> I am working on creating a website based on the django framework with
> python. The aim is to have a simple HTML form that will build around where
> the user fills in the form and when it is done can submit it. When
> submitted, he will have a json file downloaded.
>
> After looking around, I found that serializer would be the best way but I
> am still really confused. Would appreciate any kind of 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/3bd76a23-e5d8-4597-8fc1-3e9f2fc7cb90%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/CAPLZMbNnCxVTa%2BXkpGHYSrwYjYPMyvfhtrsTMpkY0E_dxvT16A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[formset] ManyToMany

2019-04-09 Thread Robin Riis
if i have the following models:

class Wiggs_Filter(models.Model):
wiggs_nr = models.CharField(max_length=30, unique=True, blank=True,
null=True)
picture = models.ImageField(upload_to='filter/',
default='filter/saknas.jpg')
description = models.CharField(max_length=100, blank=True, null=True)
outer_diameter = models.CharField(max_length=25, blank=True, null=True)
inner_diameter = models.CharField(max_length=25, blank=True, null=True)
use_with = models.ManyToManyField("self", blank=True)

class Cross_Filter(models.Model):
wiggs = models.ManyToManyField(Wiggs_Filter, related_name='cross_ref')
manufacture = models.CharField(max_length=25, choices=TILLVERKARE)
name = models.CharField(max_length=25)


and i would like to be able to open a modal window in Wiggs_Filter
DetailView
with a formset to Cross_Filter but i cannot get it to work
have the following form:

class FilterCrossForm(forms.ModelForm):
class Meta:
model = Filter_Cross
fields = '__all__'

CrossFormset = forms.formset_factory(FilterCrossForm)

class AddFilterAjaxForm(forms.ModelForm):
class Meta:
model = Wiggs_Filter
exclude = ('picture', 'use_with')

and this is my DetailView:

class Wiggs_Filtret(DetailView):
template_name = 'lager/detta_filter.html'
model = Wiggs_Filter

def get_object(self):
return get_object_or_404(Wiggs_Filter,
wiggs_nr=self.kwargs['wiggs_nr'])

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['cross_options'] = self.get_cross_manufacturer()
context['cross_refs'] = self.object.cross_ref.all()
return context

def get_cross_manufacturer(self):
cross = [obj.manufacture for obj in self.object.cross_ref.all()]
return list(dict.fromkeys(cross))

any tips on how to open a bootstrap modal with the CrossFormset formset?

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


Re: How to use updated model.py from the shell

2019-03-31 Thread Robin Riis
Just re import and redeclare the variable?

from app import model
x = thing.objects.all()


Den sön 31 mars 2019 16:46Betty  skrev:

> Hi all,
>
> I am new to django and following tutorials.
>
> I realized that even if I modified models.py while I was using
> shell(python manage.py shell) the modified models.py does not get
> recognized unless I restart the shell prompt.
> Is there any other way to load my modified models.py by not restarting the
> shell prompt?
>
> I appreciate any help!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/090df280-8443-4441-96bd-3e92cb26de72%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/CAPLZMbOeurjzsp28%2Bm7JXCJv%3D0qObbKgv2J_ROdALW4HEWhb_A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ModuleNotFoundError: No module named 'sample,'

2019-03-07 Thread Robin Riis
from .models import Sample

Den tors 7 mars 2019 10:44  skrev:

> Hi Team
>
> My project name is Sample
> While I am trying to connect database with models.py
> I am finding these type of errors
> ModuleNotFoundError: No module named 'sample,'
> Can anybody help 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/94eba992-1553-40a5-8a58-4f9ad85bbd5c%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/CAPLZMbNwyb0esCbJgR50oxrw_kaXSH4m8COB83Nw7nVfP6DE9A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: settings.py work in local but not on the server

2019-02-06 Thread robin . leroux . 96
Thank you both for yours answers.

Gil : 
I checked again using ftp, git pushed everything correctly, so the error 
don't come from that.

Jeremy :
I tried to comment the application in wsgi.py, nothing changed server-side
#application = get_wsgi_application()

Doing this, I saw that appear (cf bold) :
sent 75,631,757 bytes  received 165,829 bytes  1,783,472.61 bytes/sec
*rsync error**: some files/attrs were not transferred (see previous errors) 
(code 23) at main.c(1196) [sender=3.1.2]*
total size is 74,952,802  speedup is 0.99
sending incremental file list
.gitignore
README.md
requirements.txt
wsgi.py
static/images/usitoo.png
usitoo/manage.py
usitoo/polls/__init__.py
usitoo/polls/*{**all files regarding polls}*
usitoo/usitoo/__init__.py
usitoo/usitoo/settings.py
usitoo/usitoo/urls.py


sent 79,452 bytes  received 811 bytes  160,526.00 bytes/sec
total size is 76,074  speedup is 0.95
-> Build complete
-> Cleaning temporary files

I know wsgi.py should be by default in usitoo/usitoo/, but gandi's 
documentation 

 
said to put it here.
If I move it back, it is correctly place on the file list, but the error 
persist.

I didn't have the rsync error before, but cannot replicate that even when 
uncommenting back wsgi.py

I also tried to deploy like this :
ssh {xxx}@git.sd3.gpaas.net deploy default.git > output.txt 2> 
errors.txt
errors.txt stay empty, and I cannot put -v flag on the command

I contacted gandi's support to see if they could 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/61045139-29b9-4279-a028-38ffc9f240ae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: default groups and permissions

2019-01-08 Thread Robin Riis
 12 class SignUp(PermissionRequiredMixin, generic.CreateView):
 13 form_class = WiggenUserCreationForm
 14 success_url = reverse_lazy('check_users')
 15 template_name = 'registration/signup.html'
 16 login_url = '/konton/login'
 17 permission_required = 'users.add_user'
 18 
 19 def post(self, request, *args, **kwargs):
 20 form = self.form_class(request.POST)
 21 if form.is_valid():
 22 form.save()
 23 grupp = ''
 24 if request.POST.get('title') == 'Försäljningschef':
 25 grupp = Group.objects.get_or_create(name = 
'Försäljningschef')
 26 if request.POST.get('title') == 'Affärsområdeschef':
 27 grupp = Group.objects.get_or_create(name = 
'Affärsområdeschef')
 28 if request.POST.get('title') == 'Ekonomi':
 29 grupp = Group.objects.get_or_create(name = 'Ekonomi')
 30 if request.POST.get('title') == 'Verkstad':
 31 grupp = Group.objects.get_or_create(name = 'Verkstad')
 32 if request.POST.get('title') == 'IT utvecklare':
 33 grupp = Group.objects.get_or_create(name = 'IT 
utvecklare')
 34 
 35 if grupp != '':
 36 user = WiggenUser.objects.get(username = 
form.cleaned_data.get('username'))
 37 user.groups.add(grupp)
 38 print('did it work?')


so does my view look right now, and that did not work :P
am kinda busy right now but will try again tomorrow when i have more time.
thnx Nebojsa! but could you please show me a full example?

Den måndag 7 januari 2019 kl. 13:18:37 UTC+1 skrev Nebojsa:
>
> you can do it from views.py inside signup function
> if Försäljningschef
> then if exist() sign there, if not create that group.
>
> I will be at home in few hours so can write one full example if you can't 
> make it until then.
>
> нед, 6. јан 2019. у 18:55 Robin Riis > 
> је написао/ла:
>
>> i have a custom user model that i want to have 4 default groups depending 
>> on job title.
>>
>> this is my model.py
>>   1 from django.contrib.auth.models import AbstractUser, UserManager, 
>> PermissionsMixin
>>   2 from django.db import models
>>   3 
>>   4 class WiggenUserManager(UserManager):
>>   5 pass
>>   6 
>>   7 class WiggenUser(AbstractUser):
>>   8 title_choices = (
>>   9 ('Försäljningschef', 'Försäljningschef'),
>>  10 ('Affärsområdeschef', 'Affärsområdeschef'),
>>  11 ('Ekonomi', 'Ekonomi'),
>>  12 ('Verkstad', 'Verkstad'),
>>  13 ('IT utvecklare', 'IT utvecklare')
>>  14 )
>>  15 objects = WiggenUserManager()
>>  16 dob = models.DateField(blank=True, null=True)
>>  17 employee_number = models.IntegerField(blank=True, null=True)
>>  18 title = models.CharField(max_length=30, choices=title_choices, 
>> blank=True, null=True)
>>  19 mobile = models.CharField(max_length=15, blank=True, null=True)
>>  20 phone = models.CharField(max_length=15, blank=True, null=True)
>>  21 salary = models.IntegerField(blank=True, null=True)
>>
>> so when i add a new user with for example (title Verkstad) i want that 
>> user to belong to the group verkstad..
>>
>> where do i add that new group and set its permissions? i read somewhere 
>> about signal but it didnt say what to import or where to add it
>>
>> anyone got an idea? :)
>>
>> thnx 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/17b1e7b9-61e1-4643-9679-653d138052c9%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/17b1e7b9-61e1-4643-9679-653d138052c9%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/de9ac45a-4952-44e6-aab7-7c41dc2b684b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


default groups and permissions

2019-01-06 Thread Robin Riis
i have a custom user model that i want to have 4 default groups depending 
on job title.

this is my model.py
  1 from django.contrib.auth.models import AbstractUser, UserManager, 
PermissionsMixin
  2 from django.db import models
  3 
  4 class WiggenUserManager(UserManager):
  5 pass
  6 
  7 class WiggenUser(AbstractUser):
  8 title_choices = (
  9 ('Försäljningschef', 'Försäljningschef'),
 10 ('Affärsområdeschef', 'Affärsområdeschef'),
 11 ('Ekonomi', 'Ekonomi'),
 12 ('Verkstad', 'Verkstad'),
 13 ('IT utvecklare', 'IT utvecklare')
 14 )
 15 objects = WiggenUserManager()
 16 dob = models.DateField(blank=True, null=True)
 17 employee_number = models.IntegerField(blank=True, null=True)
 18 title = models.CharField(max_length=30, choices=title_choices, 
blank=True, null=True)
 19 mobile = models.CharField(max_length=15, blank=True, null=True)
 20 phone = models.CharField(max_length=15, blank=True, null=True)
 21 salary = models.IntegerField(blank=True, null=True)

so when i add a new user with for example (title Verkstad) i want that user 
to belong to the group verkstad..

where do i add that new group and set its permissions? i read somewhere 
about signal but it didnt say what to import or where to add it

anyone got an idea? :)

thnx 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/17b1e7b9-61e1-4643-9679-653d138052c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multiple websocket connection vs single websocket connection when using django channels

2018-04-07 Thread Robin Lery
Yes, I guess that's how to work around per connection for a user. Thank you
for your input!

On Fri, Apr 6, 2018 at 9:49 PM, Ken Whitesell <kenwhites...@comcast.net>
wrote:

> Hi Robin,
>
> I can't speak to any generalized situations, or what might be considered
> "best practices" or most optimal.
>
> What I can say is that we have gone with the single websocket connection
> for each client - whether it's a real person at a browser or an
> application. All our communications through the channel are JSON objects,
> and we include a key named "app" in the object which identifies the
> specific "feature" or "application" to which a message is directed. It's
> done in both directions - submissions through the channel from the browsers
> to the server and from the server to the browser all have that key in the
> JSON.
>
> About the most I can say is that it works well for us.
>
> Ken
>
>
> On Friday, April 6, 2018 at 5:10:41 AM UTC-4, Robin Lery wrote:
>>
>> Hi,
>>
>> Suppose an application has features like Chat, Notification and Activity
>> feeds.
>>
>> I would like to know whether its recommended to have different
>>  websocket connection for different  feautues for each user. Meaning for
>> chat purpose a separate socket connection, for notification another
>> separate connection?
>>
>> Or is it better to have only one websocket connection for a user, and
>> work around that single connection for different features?
>>
>> Sincerely,
>> Robin
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/0bf0d083-1bb3-4963-905c-9e8bfce6c765%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/0bf0d083-1bb3-4963-905c-9e8bfce6c765%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/CA%2B4-nGqLx9FH9FBAbdVP_EtogctGQZPRKx0PnmETEptW-FJVOQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Multiple websocket connection vs single websocket connection when using django channels

2018-04-06 Thread Robin Lery
Hi,

Suppose an application has features like Chat, Notification and Activity
feeds.

I would like to know whether its recommended to have different   websocket
connection for different  feautues for each user. Meaning for chat purpose
a separate socket connection, for notification another separate connection?

Or is it better to have only one websocket connection for a user, and work
around that single connection for different features?

Sincerely,
Robin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group 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%2B4-nGotWh6waiNPdTbH85%3DM0mPPKnh1%3DHR4BdYBsrUCFB6WPg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 2.0 alpha 1 released

2017-09-22 Thread Robin Lery
+1

On Sat, Sep 23, 2017 at 12:16 AM, Tim Graham  wrote:

> We've made the first release on the way to Django's next major
> release, Django 2.0! With just a little over two months until the
> final release (scheduled for December 1), we'll need timely testing
> from the community to ensure an on time, stable release. Check out the
> blog post:
>
> https://www.djangoproject.com/weblog/2017/sep/22/django-20-
> alpha-1-released/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAD-rxRBszJkTg87Ss0oPE0%3DueLOk6p3cSLDteTErUjDAX9QF6g%
> 40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Channels architecture for chat application and subscriptions

2017-09-22 Thread Robin Lery
Okay. Thank you. Really appreciate what you guys are building.

Sincerely,
Robin

On Thu, Sep 21, 2017 at 1:10 AM, Andrew Godwin <and...@aeracode.org> wrote:

> Yes, you can do as you suggest, but you're also right that it will be slow
> to send. Groups are more efficient in theory, but right now their send
> implementation is also a for loop (though it's a little bit tighter) so not
> sure how drastic the difference will be.
>
> Andrew
>
> On Sun, Sep 17, 2017 at 10:15 PM, Robin Lery <robinl...@gmail.com> wrote:
>
>> Thank you, Andrew. Also, after reading more about channels in SO
>> <https://stackoverflow.com/questions/39322241/sending-a-message-to-a-single-user-using-django-channels>
>> and channel's GitHub <https://github.com/django/channels/issues/175> and
>> also here in Django-users group
>> <https://groups.google.com/forum/#!topic/django-users/kNV8hEWWlyA>, it
>> seems to create a group per user works as well.
>>
>> So, like the solution above how you told about adding the users to all
>> the groups (threads) on connect:
>>
>> eg:
>> def ws_connect(message):
>> for thread in user.thread_set.all():
>> Group("thread-%d" %thread.id).add(message.reply_channel)
>>
>>
>> Can I also do something like this - instead of adding the user to all
>> threads group on connect, I will set per user per group, and then whenever
>> a message is received, that thread will send to all the users in its user
>> list using the user's group:
>>
>> eg:
>>
>> def send_msg(message):
>> for user in self.user.all():
>> Group("%d" % user.id).send({
>> "text": json.dumps({
>> "foo": 'bar'
>> })
>> })
>>
>>
>> Also to consider here is that suppose a thread has a large number of
>> users (say, more than 20,000 users), will the above solution be unwise for
>> this type of situation?
>>
>> Sincerely,
>> Robin
>>
>> On Sun, Sep 17, 2017 at 11:22 PM, Andrew Godwin <and...@aeracode.org>
>> wrote:
>>
>>> Hi Robin,
>>>
>>> The most efficient way to do this is to have one WebSocket connection
>>> that all the messages are sent down. Have a Group per group-chat and per
>>> single-user chat (I would model those as a special case of the group-chat
>>> if I were you for simplicity), and when a user connects, add them to the
>>> groups for all the chats they are in. Note that you will need to include
>>> chat IDs in any messages you send down to the browsers via groups, and
>>> de-tangle them using JavaScript to go to the right places.
>>>
>>> Note that you can add and remove a connection from groups in the middle
>>> of the connection - just have something in the "websocket.message" handler
>>> that does this.
>>>
>>> Also note that you'll need a separate send of endpoints that gets
>>> historical chat messages before the WebSocket streaming begins, if that's a
>>> desired feature. I'd recommend doing this slightly after the WebSocket is
>>> established so you don't miss any messages that might get sent between
>>> getting history and opening the socket - you'll risk getting the same
>>> message twice, but giving each message an ID will let you de-duplicate on
>>> the client side in that case.
>>>
>>> Channels is a piece of a solution for a full-featured chat, but you're
>>> going to have to write a lot of additional logic around it. I have on my
>>> backlog a proper event-sourcing solution that would solve many of these,
>>> but I am focused on channels 2.0 first and the changes that will bring.
>>>
>>> Andrew
>>>
>>> On Sun, Sep 17, 2017 at 8:19 AM, Robin Lery <robinl...@gmail.com> wrote:
>>>
>>>> I would like to make a chat application using django and channels. I
>>>> have two models to achieve a chat like application.
>>>>
>>>>1.
>>>>
>>>>Thread - A thread can have list of users. So, it can be used for
>>>>chat between two users, or groups of user. If it's a group thread, it 
>>>> can
>>>>have a subject for the group (eg. group name).
>>>>2.
>>>>
>>>>Message - A message is the actual message sent from one user
>>>>(sender) to a thread. And any users of thread's user list will have 
>>>>

Re: Channels architecture for chat application and subscriptions

2017-09-17 Thread Robin Lery
Thank you, Andrew. Also, after reading more about channels in SO
<https://stackoverflow.com/questions/39322241/sending-a-message-to-a-single-user-using-django-channels>
and channel's GitHub <https://github.com/django/channels/issues/175> and
also here in Django-users group
<https://groups.google.com/forum/#!topic/django-users/kNV8hEWWlyA>, it
seems to create a group per user works as well.

So, like the solution above how you told about adding the users to all the
groups (threads) on connect:

eg:
def ws_connect(message):
for thread in user.thread_set.all():
Group("thread-%d" %thread.id).add(message.reply_channel)


Can I also do something like this - instead of adding the user to all
threads group on connect, I will set per user per group, and then whenever
a message is received, that thread will send to all the users in its user
list using the user's group:

eg:

def send_msg(message):
for user in self.user.all():
Group("%d" % user.id).send({
"text": json.dumps({
"foo": 'bar'
})
})


Also to consider here is that suppose a thread has a large number of users
(say, more than 20,000 users), will the above solution be unwise for this
type of situation?

Sincerely,
Robin

On Sun, Sep 17, 2017 at 11:22 PM, Andrew Godwin <and...@aeracode.org> wrote:

> Hi Robin,
>
> The most efficient way to do this is to have one WebSocket connection that
> all the messages are sent down. Have a Group per group-chat and per
> single-user chat (I would model those as a special case of the group-chat
> if I were you for simplicity), and when a user connects, add them to the
> groups for all the chats they are in. Note that you will need to include
> chat IDs in any messages you send down to the browsers via groups, and
> de-tangle them using JavaScript to go to the right places.
>
> Note that you can add and remove a connection from groups in the middle of
> the connection - just have something in the "websocket.message" handler
> that does this.
>
> Also note that you'll need a separate send of endpoints that gets
> historical chat messages before the WebSocket streaming begins, if that's a
> desired feature. I'd recommend doing this slightly after the WebSocket is
> established so you don't miss any messages that might get sent between
> getting history and opening the socket - you'll risk getting the same
> message twice, but giving each message an ID will let you de-duplicate on
> the client side in that case.
>
> Channels is a piece of a solution for a full-featured chat, but you're
> going to have to write a lot of additional logic around it. I have on my
> backlog a proper event-sourcing solution that would solve many of these,
> but I am focused on channels 2.0 first and the changes that will bring.
>
> Andrew
>
> On Sun, Sep 17, 2017 at 8:19 AM, Robin Lery <robinl...@gmail.com> wrote:
>
>> I would like to make a chat application using django and channels. I have
>> two models to achieve a chat like application.
>>
>>1.
>>
>>Thread - A thread can have list of users. So, it can be used for chat
>>between two users, or groups of user. If it's a group thread, it can have 
>> a
>>subject for the group (eg. group name).
>>2.
>>
>>Message - A message is the actual message sent from one user (sender)
>>to a thread. And any users of thread's user list will have access to it.
>>
>> class Thread(models.Model):
>> subject = models.CharField(max_length=255, blank=True)
>> user = models.ManyToManyField(User)
>> class Message(models.Model):
>> thread = models.ForeignKey(Thread)
>> sender = models.ForeignKey(User)
>> sent_datetime = models.DateTimeField(default=timezone.now)
>> body = models.TextField()
>>
>> So, the chat app will have the basic features:
>>
>>1.
>>
>>Chat with a single user
>>
>>When a user sends a message to a user, django will check if a thread
>>with both sender and recipient exists as the users. If it exist, then
>>create a new message with that existing thread as the foreign key. If it
>>doesn't exits, create a new thread, and create a new message with newly
>>created thread as its foreign key to the thread.
>>2.
>>
>>Chat with a group of users
>>
>>When a user creates a new group, a new thread will be created and
>>that user will be added to the thread's user list. More users can be added
>>to group later on. And any message sent will be available to all the users
>>in the th

Channels architecture for chat application and subscriptions

2017-09-17 Thread Robin Lery
I would like to make a chat application using django and channels. I have
two models to achieve a chat like application.

   1.

   Thread - A thread can have list of users. So, it can be used for chat
   between two users, or groups of user. If it's a group thread, it can have a
   subject for the group (eg. group name).
   2.

   Message - A message is the actual message sent from one user (sender) to
   a thread. And any users of thread's user list will have access to it.

class Thread(models.Model):
subject = models.CharField(max_length=255, blank=True)
user = models.ManyToManyField(User)
class Message(models.Model):
thread = models.ForeignKey(Thread)
sender = models.ForeignKey(User)
sent_datetime = models.DateTimeField(default=timezone.now)
body = models.TextField()

So, the chat app will have the basic features:

   1.

   Chat with a single user

   When a user sends a message to a user, django will check if a thread
   with both sender and recipient exists as the users. If it exist, then
   create a new message with that existing thread as the foreign key. If it
   doesn't exits, create a new thread, and create a new message with newly
   created thread as its foreign key to the thread.
   2.

   Chat with a group of users

   When a user creates a new group, a new thread will be created and that
   user will be added to the thread's user list. More users can be added to
   group later on. And any message sent will be available to all the users in
   the thread's user list.

After reading the docs I am not sure how to actually layout the
architecture for the websocket and routing of the channels. I have the
following confusions:

   1.

   From the docs on models
   <https://channels.readthedocs.io/en/stable/getting-started.html#models>,
   I will have to specify the room name in the url path, and on connect, the
   consumer will add the client (message.reply_channel) to that group of room
   (here thread), and then any messages sent will be broadcasted to all the
   users in the group. However, that is just for one room (thread). How can
   the user again chat with other threads (rooms). Will I have to make a new
   Websocket connection for each thread (room)?..
   2.

   This question is out of context of a chat app, but I need to know this
   to better understand how to make the architecture. In the docs, there's
   a section of live blogs
   <https://channels.readthedocs.io/en/stable/concepts.html#groups> where
   all the clients (message.reply_channel) are added to the "liveblog" group.
   However, in this scenario, we already know that we need to connect to
   "liveblog" groups. Suppose, there's a website where many authors write
   their blogs, and a user is subscribed to many authors (e.g.: "Adam",
   "Mary", "Robin", ...). And, if a author starts its blog, a connected user
   will get notified.

   So here, if the user connects to the websocket connection, on consumer,
   should we add the user to all blogs listed in his/her subscription list

e.g:

for sub in subscriptions:
Group(sub).add(message.reply_channel)

Or is there some better way to handle these kinds of architecture? I really
like channels, and if anyone can help me understand and guide through these
concepts I will really appreciate the help.


Sincerely,

Robin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group 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%2B4-nGrMeAZGzmJAL95BsJAG5q%3D-NWw0_Yb-KNnyFNnV%2BCCz3w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to authenticate a user in websocket connection in django channels when using token authentication

2017-09-16 Thread Robin Lery
Ok, thanks. So, I was confused about two things on authenticating a user.

1. What to do with the token?

   - You can pass the token as a query string and get that query params.
   Read more about how to get the query params here
   
<https://channels.readthedocs.io/en/stable/getting-started.html#persisting-data>.

   - Or if you are already passing it in the request's authorization
   header, you can get it from there (like my final code below). Remeber to
   first fake that request.

2. How validate that token and get the user?

   - Finally, VerifyJSONWebTokenSerializer class was all I needed to
   validate the token, and get that token's user object. You can read the
   actual code of django-rest-framework-jwt here
   
<https://github.com/GetBlimp/django-rest-framework-jwt/blob/master/rest_framework_jwt/serializers.py>
   .


So, I ended up doing this way:

def ws_connect(message):
message.content.setdefault('method', 'FAKE')
django_request = AsgiRequest(message)
token = django_request.GET['token'].split(' ')[1]
try:
data = {'token': token}
valid_data = VerifyJSONWebTokenSerializer().validate(data)
user = valid_data['user']
...
...
message.reply_channel.send({
"accept": True
})
except (KeyError, InvalidTokenError, ValidationError,):
...
...
message.reply_channel.send({
"text": "Authentication error",
"close": True
})



On Fri, Sep 15, 2017 at 10:37 PM, Andrew Godwin <and...@aeracode.org> wrote:

> You'll have to write your own authentication code that runs in `connect`
> and puts a user into the channel session - there's nothing built in that
> will really help you past that I'm afraid.
>
> Andrew
>
> On Thu, Sep 14, 2017 at 6:35 PM, Robin Lery <robinl...@gmail.com> wrote:
>
>> I am using a frontend framework (Vuejs <http://Vuejs.org>) and
>> django-rest-framework <http://www.django-rest-framework.org/> for the
>> REST API in my project. Also, for JSON web token authentication I am using
>> django-rest-framework-jwt
>> <http://getblimp.github.io/django-rest-framework-jwt/>. After a
>> successful login, the user is provided with a token. This token is passed
>> into every request to fetch any API related stuff.
>>
>> Now I would like to integrate django channels
>> <https://channels.readthedocs.io/en/stable/index.html> into my project.
>> So, after successful login, when the token is received in the client side,
>> I would like to initiate a websocket connection. Then on the server
>> (consumer), I would like to check if the requested user is not anonymous.
>> If the requested user is anonymous, I would like to close the connenction
>> or else accept it.
>>
>> This is how I have till now:
>>
>> client side:
>>
>> const socket = new WebSocket("ws://" + "dev.site.com"+ "/chat/");
>>
>> routing.py:
>>
>> channel_routing = [
>> route("websocket.connect", ws_connect),
>> ...
>> ...]
>>
>> consumers:
>>
>> def ws_connect(message):
>>
>> # if the user is no anonymous
>> message.reply_channel.send({
>> "accept": True
>> })
>>
>> # else
>> message.reply_channel.send({
>> "close": True
>> })
>>
>> In the documentation
>> <https://channels.readthedocs.io/en/stable/getting-started.html#authentication>
>> there's a decorator @channel_session_user_from_http which will provide a
>> message.user. But I am using a token instead of a session. How can I
>> check a user on connection when using token authentication, so that I can
>> accept or close connection. Or, if there is a better way could you please
>> advise me with it. 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/ms
>> gid/django-users/CA%2B4-nGp5KhvYKdhD%3Dufus-jmHz%2BN%2BLPzOu
>> X1R3V%2BPOYt8U4QXA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CA%2B4-nGp5KhvYKdhD%3Dufus-jmHz%2BN%2BLPzOuX1R3V%2BPOYt8U4QXA%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>&

Re: Validate and get the user using the jwt token inside a view

2017-09-16 Thread Robin Lery
I was about to that by this

from rest_framework_jwt.serializers import VerifyJSONWebTokenSerializer

data = {'token': token}
valid_data = VerifyJSONWebTokenSerializer().validate(data)
user = valid_data['user']

Hope this helps any body like me.


On Sat, Sep 16, 2017 at 9:34 AM, Robin Lery <robinl...@gmail.com> wrote:

> Thanks. But that doesn't verify the token.
>
> On Fri, Sep 15, 2017 at 6:44 PM, oon arfiandwi <oon.arfian...@gmail.com>
> wrote:
>
>>
>> Hi,
>>
>> have you try to use jwt_decode_handler(token)?
>> I found this on utils.py
>>
>> I check the source code of verify token,
>> there's reference to decode handler inside the code.
>>
>> --
>> sincerely,
>> Oon Arfiandwi
>>
>>
>> On Fri, Sep 15, 2017 at 10:11 AM, Robin Lery <robinl...@gmail.com> wrote:
>>
>>> I am using django-rest-framework <http://www.django-rest-framework.org/>
>>> for the REST API and django-rest-framework-jwt
>>> <https://github.com/GetBlimp/django-rest-framework-jwt> for JSON web
>>> token authentication. After a successful login, the user is provided with a
>>> token. I have found how to verify a token
>>> <https://getblimp.github.io/django-rest-framework-jwt/#verify-token>
>>> with the api call, but is there any way to validate the token inside a view
>>> and get the user of that token, similar to request.user?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> 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/CA%2B4-nGopatOzbDz4HZmZwPOTVpv5whYBpW-%3DgP
>>> dG%2BFhDcmUJsQ%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CA%2B4-nGopatOzbDz4HZmZwPOTVpv5whYBpW-%3DgPdG%2BFhDcmUJsQ%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/ms
>> gid/django-users/CACUNLpWTusizVeP3cFiGkGECoR%2BcRj4uMfu3akwt
>> oqvEsK6iyg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CACUNLpWTusizVeP3cFiGkGECoR%2BcRj4uMfu3akwtoqvEsK6iyg%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/CA%2B4-nGoziUTQhSwUXC3Wenc_bAxQQALybRKPqYK0RpDg4G3p3A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Validate and get the user using the jwt token inside a view

2017-09-15 Thread Robin Lery
Thanks. But that doesn't verify the token.

On Fri, Sep 15, 2017 at 6:44 PM, oon arfiandwi <oon.arfian...@gmail.com>
wrote:

>
> Hi,
>
> have you try to use jwt_decode_handler(token)?
> I found this on utils.py
>
> I check the source code of verify token,
> there's reference to decode handler inside the code.
>
> --
> sincerely,
> Oon Arfiandwi
>
>
> On Fri, Sep 15, 2017 at 10:11 AM, Robin Lery <robinl...@gmail.com> wrote:
>
>> I am using django-rest-framework <http://www.django-rest-framework.org/>
>> for the REST API and django-rest-framework-jwt
>> <https://github.com/GetBlimp/django-rest-framework-jwt> for JSON web
>> token authentication. After a successful login, the user is provided with a
>> token. I have found how to verify a token
>> <https://getblimp.github.io/django-rest-framework-jwt/#verify-token>
>> with the api call, but is there any way to validate the token inside a view
>> and get the user of that token, similar to request.user?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> 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/CA%2B4-nGopatOzbDz4HZmZwPOTVpv5whYBpW-%
>> 3DgPdG%2BFhDcmUJsQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CA%2B4-nGopatOzbDz4HZmZwPOTVpv5whYBpW-%3DgPdG%2BFhDcmUJsQ%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/CACUNLpWTusizVeP3cFiGkGECoR%2BcRj4uMfu3akwtoqvEsK6iyg%
> 40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CACUNLpWTusizVeP3cFiGkGECoR%2BcRj4uMfu3akwtoqvEsK6iyg%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/CA%2B4-nGp75jBtCk3Uw1a8tf4E6537igiUDpqdGYG6xzM_MNrwnA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Validate and get the user using the jwt token inside a view

2017-09-14 Thread Robin Lery
I am using django-rest-framework 
for the REST API and django-rest-framework-jwt
 for JSON web token
authentication. After a successful login, the user is provided with a
token. I have found how to verify a token
 with
the api call, but is there any way to validate the token inside a view and
get the user of that token, similar to request.user?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group 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%2B4-nGopatOzbDz4HZmZwPOTVpv5whYBpW-%3DgPdG%2BFhDcmUJsQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to authenticate a user in websocket connection in django channels when using token authentication

2017-09-14 Thread Robin Lery
I am using a frontend framework (Vuejs ) and
django-rest-framework  for the REST
API in my project. Also, for JSON web token authentication I am using
django-rest-framework-jwt
. After a successful
login, the user is provided with a token. This token is passed into every
request to fetch any API related stuff.

Now I would like to integrate django channels
 into my project. So,
after successful login, when the token is received in the client side, I
would like to initiate a websocket connection. Then on the server
(consumer), I would like to check if the requested user is not anonymous.
If the requested user is anonymous, I would like to close the connenction
or else accept it.

This is how I have till now:

client side:

const socket = new WebSocket("ws://" + "dev.site.com"+ "/chat/");

routing.py:

channel_routing = [
route("websocket.connect", ws_connect),
...
...]

consumers:

def ws_connect(message):

# if the user is no anonymous
message.reply_channel.send({
"accept": True
})

# else
message.reply_channel.send({
"close": True
})

In the documentation

there's a decorator @channel_session_user_from_http which will provide a
message.user. But I am using a token instead of a session. How can I check
a user on connection when using token authentication, so that I can accept
or close connection. Or, if there is a better way could you please advise
me with it. 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/CA%2B4-nGp5KhvYKdhD%3Dufus-jmHz%2BN%2BLPzOuX1R3V%2BPOYt8U4QXA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django runserver not working after installing redis for django channels

2017-09-12 Thread Robin Lery
Yes, i think just running `sudo apt-get install redis-server` installs the
old version of redis, instead of the latest one.

On Mon, Sep 11, 2017 at 6:40 PM, Artem Malyshev 
wrote:

> Hi,
>
> Please check your redis installation. It should be at least minimum
> required version by redis-py.
>
> Regards, Artem.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/beab5ba8-b6db-44f6-b211-bce721259e90%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/CA%2B4-nGphFTcqM9DFO-JSyGh4xaycuu%3DVM5sJ4CMqRhXAriC6JA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django runserver not working after installing redis for django channels

2017-09-11 Thread Robin Lery
I am learning the Django-channels
<https://channels.readthedocs.io/en/stable/index.html> concepts and I am
stuck when after install the asgi_redis and the redis server
<https://channels.readthedocs.io/en/stable/getting-started.html#running-with-channels>.
If I have the CHANNEL_LAYERS configured for the *in-memory backend*. The
server runs okay, and the web page is displayed.However, if I run the
server after configuring the CHANNEL_LAYERS for the *redis backed*, the web
page is not displayed, and I get an error in the terminal:

Channel layer default (asgi_redis.core.RedisChannelLayer)
Quit the server with CONTROL-C.
2017-09-11 12:34:07,259 - INFO - worker - Listening on channels
http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-09-11 12:34:07,260 - INFO - worker - Listening on channels
http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-09-11 12:34:07,261 - INFO - worker - Listening on channels
http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-09-11 12:34:07,263 - INFO - server - HTTP/2 support not enabled
(install the http2 and tls Twisted extras)
2017-09-11 12:34:07,263 - INFO - server - Using busy-loop synchronous mode
on channel layer
2017-09-11 12:34:07,265 - INFO - server - Listening on endpoint
tcp:port=8000:interface=127.0.0.1
2017-09-11 12:34:07,267 - ERROR - server - Error trying to receive
messages: unknown command 'EVALSHA'
2017-09-11 12:34:07,268 - INFO - worker - Listening on channels
http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-09-11 12:34:12,270 - ERROR - server - Error trying to receive
messages: unknown command 'EVALSHA'
2017-09-11 12:34:17,272 - ERROR - server - Error trying to receive
messages: unknown command 'EVALSHA'

I have installed the asgi_redis in my virtualenv, and also installed Redis
server. What am I doing wrong here?

Here are the useful versions that I am using:

   - channels==1.1.6
   - asgi-redis==1.4.2
   - daphne==1.3.0
   - Django==1.11.5


Sincerely

Robin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group 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%2B4-nGrqHGfAbZ7R1pjb528DwJz4gBn81dc4dZk%2BJrm6Pii51Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django rest framework JWT and custom authentication backend

2017-05-26 Thread Robin Lery
I have a custom user model and have created a custom authentication
backend. I am using django rest framework JWT

for token authentication.

User model:

class User(AbstractBaseUser, PermissionsMixin):
email = models.EmailField(
unique=True,
max_length=254,
)
first_name = models.CharField(max_length=15)
last_name = models.CharField(max_length=15)
mobile = models.IntegerField(unique=True)
date_joined = models.DateTimeField(default=timezone.now)
is_active = models.BooleanField(default=True)
is_admin = models.BooleanField(default=False)
objects = UserManager()
USERNAME_FIELD = 'email'
REQUIRED_FIELDS = ['first_name', 'last_name', 'mobile']

Auth backend:

class EmailOrMobileAuthBackend(object):
def authenticate(self, username=None, password=None):
try:
user = get_user_model().objects.get(email=username)
if user.check_password(password):
return user
except User.DoesNotExist:
if username.isdigit():
try:
user = get_user_model().objects.get(mobile=username)
if user.check_password(password):
return user
except User.DoesNotExist:
return None
else:
return None

def get_user(self, user_id):
try:
return get_user_model().objects.get(pk=user_id)
except User.DoesNotExist:
return None
And have added in the settings.py:

AUTHENTICATION_BACKENDS =
('accounts.email_mobile_auth_backend.EmailOrMobileAuthBackend',)

While to log in to django admin site, both the email and mobile number
works fine in authenticating the user. However, when I try get the token
for the user using django rest framework JWT
, I get an
error:

curl -X POST -d "email=ad...@gmail.com=123123"
http://localhost/api-token-auth/

"non_field_errors": [
"Unable to log in with provided credentials."
  ]

What am I missing? Why is it that its working while loggin to the django
admin site, but get error when getting token with django rest framework jwt?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group 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%2B4-nGqs8vvev5Y13Q2q1rtoL%3DHzUOhsfOkwV_aSOtS9jinXYw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django rest framework cannot deal with multple objects in model viewset

2017-04-20 Thread Robin Lery
I have a very simple model and its related serializer and views:

class Page(models.Model):
user = models.ForeignKey(User)
title = models.CharField(max_length=255)
pub_date = models.DateTimeField(default=timezone.now)

class PageSerializer(serializers.ModelSerializer):
class Meta:
model = Page
fields = ('user', 'title', 'pub_date')

class PageViewSet(viewsets.ModelViewSet):
queryset = Page.objects.all()
serializer_class = PageSerializer
Now I can post like this:

{
"user": 1,
"title": "Lorem ipsum"
}
This works fine. But I would like to post multiple objects like this:

[
{
"user": 1,
"title": "Lorem ipsum one"
},
{
"user": 1,
"title": "Lorem ipsum two"
}
]
But this gives me an error:

"non_field_errors": [

"Invalid data. Expected a dictionary, but got list."
]
So to accept multple objects I modified the view as per the doc:

class PageViewSet(viewsets.ModelViewSet):
queryset = Page.objects.all()
serializer_class = PageSerializer(queryset, many=True)

But I am getting an error:

TypeError at /api/blog/pages/

'ListSerializer' object is not callable
What am I missing here?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group 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%2B4-nGqCNu-03O7%3DvDO5G%3DSOA1jW7ef3%3Dfm%3DV1SNbX%2BX9sAtZQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Cannot install channels

2017-02-09 Thread Robin Lery
Yes. That might have been the problem. Thank you once again!

On Fri, Feb 10, 2017 at 12:43 PM, Andrew Godwin <and...@aeracode.org> wrote:

> I'm afraid I can't help without looking at the machine directly - I would
> suspect that either it had a version of Twisted pre-installed on the system
> that it was happy with (the more recent releases increased the Twisted
> version requirement), or the version of Twisted it downloaded did not
> require compilation.
>
> Andrew
>
> On Thu, Feb 9, 2017 at 11:10 PM, Robin Lery <robinl...@gmail.com> wrote:
>
>> Yes that was it. Thank you. Could you please help me understand why this
>> might have worked before in a earlier different virtual env in the same
>> vagrant machine?
>>
>> On Fri, Feb 10, 2017 at 12:28 PM, Andrew Godwin <and...@aeracode.org>
>> wrote:
>>
>>> You don't have the Python development headers installed for your system
>>> - you can tell this because of this line in the error:
>>>
>>> src/twisted/test/raiser.c:4:20: fatal error: Python.h: No such file or
>>> directory
>>>
>>> If you install your distribution's python header package (e.g. on ubuntu
>>> it's python-dev) it should resolve the error.
>>>
>>> Andrew
>>>
>>> On Thu, Feb 9, 2017 at 10:51 PM, Robin Lery <robinl...@gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> I already had a django channels in my other virtual env. But since its
>>>> an older version of channels (0.7.0) I am trying to install a new channel
>>>> version into my project which is in a different virtual environment inside
>>>> a a vagrant box.
>>>>
>>>> I created a new virtualenv
>>>>
>>>>> $ mkvirtualenv newsapp
>>>>>
>>>>
>>>> Install django
>>>>
>>>>> $ pip install django
>>>>>
>>>>
>>>> Install channels
>>>>
>>>>> $ pip install -U channels
>>>>>
>>>>
>>>> Then I am getting error:
>>>>
>>>> Command "/home/vagrant/Envs/newsapp/bin/python -u -c "import
>>>>> setuptools, tokenize;__file__='/tmp/pip-bu
>>>>> ild-IrzQ_E/twisted/setup.py';f=getattr(tokenize, 'open',
>>>>> open)(__file__);code=f.read().replace('\r\n',
>>>>> '\n');f.close();exec(compile(code, __file__, 'exec'))" install
>>>>> --record /tmp/pip-ArjPse-record/install-record.txt
>>>>> --single-version-externally-managed --compile --install-headers
>>>>> /home/vagrant/Envs/newsapp/include/site/python2.7/twisted" failed
>>>>> with error code 1 in /tmp/pip-build-IrzQ_E/twisted/
>>>>
>>>>
>>>> Here is link for the full error
>>>> <https://gist.github.com/robinlery/36c1cc0efbfe485500191d60e33b62b4>
>>>> Can you please help how to solve this issue?
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Django users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to django-users+unsubscr...@googlegroups.com.
>>>> To post to this group, send email to django-users@googlegroups.com.
>>>> 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/CA%2B4-nGpCy3g5KD9Q-UctFF3oKuVqtdfTjkW6XuTL
>>>> BPiH%2BpyTsw%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/django-users/CA%2B4-nGpCy3g5KD9Q-UctFF3oKuVqtdfTjkW6XuTLBPiH%2BpyTsw%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/ms
>>> gid/django-users/CAFwN1urVA5dAAKX2M06Ftny8BE8e9uVWTXKr6LFs-5
>>> xVim6j-Q%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-user

Re: Cannot install channels

2017-02-09 Thread Robin Lery
Yes that was it. Thank you. Could you please help me understand why this
might have worked before in a earlier different virtual env in the same
vagrant machine?

On Fri, Feb 10, 2017 at 12:28 PM, Andrew Godwin <and...@aeracode.org> wrote:

> You don't have the Python development headers installed for your system -
> you can tell this because of this line in the error:
>
> src/twisted/test/raiser.c:4:20: fatal error: Python.h: No such file or
> directory
>
> If you install your distribution's python header package (e.g. on ubuntu
> it's python-dev) it should resolve the error.
>
> Andrew
>
> On Thu, Feb 9, 2017 at 10:51 PM, Robin Lery <robinl...@gmail.com> wrote:
>
>> Hi,
>>
>> I already had a django channels in my other virtual env. But since its an
>> older version of channels (0.7.0) I am trying to install a new channel
>> version into my project which is in a different virtual environment inside
>> a a vagrant box.
>>
>> I created a new virtualenv
>>
>>> $ mkvirtualenv newsapp
>>>
>>
>> Install django
>>
>>> $ pip install django
>>>
>>
>> Install channels
>>
>>> $ pip install -U channels
>>>
>>
>> Then I am getting error:
>>
>> Command "/home/vagrant/Envs/newsapp/bin/python -u -c "import setuptools,
>>> tokenize;__file__='/tmp/pip-build-IrzQ_E/twisted/setup.py';f=getattr(tokenize,
>>> 'open', open)(__file__);code=f.read().replace('\r\n',
>>> '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record
>>> /tmp/pip-ArjPse-record/install-record.txt 
>>> --single-version-externally-managed
>>> --compile --install-headers 
>>> /home/vagrant/Envs/newsapp/include/site/python2.7/twisted"
>>> failed with error code 1 in /tmp/pip-build-IrzQ_E/twisted/
>>
>>
>> Here is link for the full error
>> <https://gist.github.com/robinlery/36c1cc0efbfe485500191d60e33b62b4>
>> Can you please help how to solve this issue?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> 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/CA%2B4-nGpCy3g5KD9Q-UctFF3oKuVqtdfTjkW6XuTL
>> BPiH%2BpyTsw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CA%2B4-nGpCy3g5KD9Q-UctFF3oKuVqtdfTjkW6XuTLBPiH%2BpyTsw%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/CAFwN1urVA5dAAKX2M06Ftny8BE8e9
> uVWTXKr6LFs-5xVim6j-Q%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAFwN1urVA5dAAKX2M06Ftny8BE8e9uVWTXKr6LFs-5xVim6j-Q%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/CA%2B4-nGpddiY2fxD7papAQEP42f%2B43ZYOuCpXj7fjx_jCpzABXQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Cannot install channels

2017-02-09 Thread Robin Lery
Hi,

I already had a django channels in my other virtual env. But since its an
older version of channels (0.7.0) I am trying to install a new channel
version into my project which is in a different virtual environment inside
a a vagrant box.

I created a new virtualenv

> $ mkvirtualenv newsapp
>

Install django

> $ pip install django
>

Install channels

> $ pip install -U channels
>

Then I am getting error:

Command "/home/vagrant/Envs/newsapp/bin/python -u -c "import setuptools,
> tokenize;__file__='/tmp/pip-build-IrzQ_E/twisted/setup.py';f=getattr(tokenize,
> 'open', open)(__file__);code=f.read().replace('\r\n',
> '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record
> /tmp/pip-ArjPse-record/install-record.txt
> --single-version-externally-managed --compile --install-headers
> /home/vagrant/Envs/newsapp/include/site/python2.7/twisted" failed with
> error code 1 in /tmp/pip-build-IrzQ_E/twisted/


Here is link for the full error

Can you please help how to solve this issue?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group 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%2B4-nGpCy3g5KD9Q-UctFF3oKuVqtdfTjkW6XuTLBPiH%2BpyTsw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Override save method to add list in the many to many field

2017-01-04 Thread Robin Lery
I have this model to save post from the users:

class Tag(models.Model):
name = models.CharField(max_length=255, unique=True)

def add_tags(obj_id, body):
object = Post.objects.get(id=obj_id)
tag_list = [Tag.objects.create(name=word) for word in body.split()]
for tag in tag_list:
object.tags.add(tag)

class Post(models.Model):
user = models.ForeignKey(User)
body = models.TextField()
tags = models.ManyToManyField(Tag, blank=True)
pub_date = models.DateTimeField(default=timezone.now)
activity = GenericRelation(Activity, related_query_name="posts")

def save(self, *args, **kwargs):
super(Post, self).save(*args, **kwargs)
if self.body:
body = self.body
obj_id = self.id
add_tags(obj_id, body)

So whenever a user post something, I would like to check if there's any
hash-tag used inside the body. If there are tags, then fetch the tags
inside the list.

But when I am posting, the tag objects are created, but they are not adding
for the Post.tags fields.

post.body example = Check #from the http://somesitedotcom/page#idtop #hell
yeah!

What am I doing wrong here?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group 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%2B4-nGrj%3DoK2Vmj7%2BqiDMJie8rQGFbQsjbbDAmj3vKrLGYx5qA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Filter a contenttype with the content object's field

2017-01-04 Thread Robin Lery
Yes, this works. Thank you. But, as there are or will be more than one
ContentType objects (i.e., Post model and Photo model), how do I iterate
over it? Should I query them separately? Like
post_activities = Activity.objects.filter(post__tags__in=tags).distinct()
photos_activities = Activity.objects.filter(photo__tags__in=tags).distinct()

Or is there any better solution?

On Wed, Jan 4, 2017 at 6:28 PM, Michel Rodrigues 
wrote:

> Sorry, the point is a list of tags as argument, you can do this:
>
> >>> Activity.objects.filter(tags_act__tags__name__in=['tag1','
> tag3']).distinct()
> , , ]>
>
>
> Without .distinct() django return duplicated objects:
>
> >>> Activity.objects.filter(tags_act__tags__name__in=['tag1','tag3'])
> , , ,
> ]>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/62094107-f03e-40ea-874f-d99f7a6dbcc7%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/CA%2B4-nGp3s%3DBDbar8bEcN94rps2VoVwMGbP5NCPa8TR-WBOTG%2BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Filter a contenttype with the content object's field

2017-01-03 Thread Robin Lery
I forgot to mention, there is another class:


class Photo(models.Model):
user = models.ForeignKey(User)
file = models.ImageField()
tags = models.ManyToManyField(Tag)
pub_date = models.DateTimeField(default=timezone.now)
activity = GenericRelation(Activity)

So, filtering would be with the list of content_object's (i.e. Post of
Photo) field (i.e. Post.tags or Photo.tags).

On Wed, Jan 4, 2017 at 12:43 AM, Robin Lery <robinl...@gmail.com> wrote:

> I creating an app where users can post with its related tags:
>
> class Tag(models.Model):
> name = models.CharField(max_length=255, unique=True)
>
> class Post(models.Model):
> user = models.ForeignKey(User)
> body = models.TextField()
> tags = models.ManyToManyField(Tag)
> pub_date = models.DateTimeField(default=timezone.now)
> activity = GenericRelation(Activity)
>
> class Activity(models.Model):
> actor = models.ForeignKey(User)
> verb = models.PositiveIntegerField(choices=VERB_TYPE)
> content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
> object_id = models.PositiveIntegerField()
> content_object = GenericForeignKey('content_type', 'object_id')
> pub_date = models.DateTimeField(default=timezone.now)
>
> What I want to do is filter the Activity with the a list of users, and a
> list of tags of the from list of Post objects.
>
> Eg:
>
> UserA created a new Post obect with tags(#class, #school)
> UserB created a new Post object with tags(#professor, #teacher)
> UserC created a new Post object with tags(#school, #university)
> UserD created a new Post object with tags(#university, #school)
>
>
> So say I want to filter Activity with user_list=[UserA, UserC] and
> tag_list = [#class, #teacher]
>
> It should return:
>
> UserA created a new Post obect with tags(#class, #school)
> UserC created a new Post object with tags(#school, #university)
> UserB created a new Post object with tags(#professor, #teacher)
>
> To filter the Activity with users, I can query this way:
> Activity.objects.filter(actor__in=user_list)
>
> But, how do I filter Activity with the content_object's (i.e.Post) field
> (i.e. Post.tags)? Is this even possible? I cannot figure it out. And your
> help will be very much helpful. 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/CA%2B4-nGp2P_jATzFC7qqcKPgRtZF6cP9ixHa-zAAUr%2BX13Rp%2BNw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Filter a contenttype with the content object's field

2017-01-03 Thread Robin Lery
I creating an app where users can post with its related tags:

class Tag(models.Model):
name = models.CharField(max_length=255, unique=True)

class Post(models.Model):
user = models.ForeignKey(User)
body = models.TextField()
tags = models.ManyToManyField(Tag)
pub_date = models.DateTimeField(default=timezone.now)
activity = GenericRelation(Activity)

class Activity(models.Model):
actor = models.ForeignKey(User)
verb = models.PositiveIntegerField(choices=VERB_TYPE)
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
object_id = models.PositiveIntegerField()
content_object = GenericForeignKey('content_type', 'object_id')
pub_date = models.DateTimeField(default=timezone.now)

What I want to do is filter the Activity with the a list of users, and a
list of tags of the from list of Post objects.

Eg:

UserA created a new Post obect with tags(#class, #school)
UserB created a new Post object with tags(#professor, #teacher)
UserC created a new Post object with tags(#school, #university)
UserD created a new Post object with tags(#university, #school)


So say I want to filter Activity with user_list=[UserA, UserC] and tag_list
= [#class, #teacher]

It should return:

UserA created a new Post obect with tags(#class, #school)
UserC created a new Post object with tags(#school, #university)
UserB created a new Post object with tags(#professor, #teacher)

To filter the Activity with users, I can query this way:
Activity.objects.filter(actor__in=user_list)

But, how do I filter Activity with the content_object's (i.e.Post) field
(i.e. Post.tags)? Is this even possible? I cannot figure it out. And your
help will be very much helpful. 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/CA%2B4-nGobHqLNHShkBpFopO-w%3DHhjgzahqcbRhJoitRSy%3D66rWA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Happy New Year 2017

2016-12-31 Thread Robin Lery
Happy new year!

On 1 Jan 2017 12:05 a.m., "pradam programmer" 
wrote:

> Happy New Year Guys, i hope this year fill with alot of love, happiness
> and Joy to everyone.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAGGVXBOiUZcsYMyu237t2nirG%3DrzOD_v68b1AqYVkijk-fDk5Q%
> 40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Cannot login with user credentials

2016-07-23 Thread Robin Lery
 But again, with the superuser's credentials, I can login

On Sat, Jul 23, 2016 at 12:47 PM, Robin Lery <robinl...@gmail.com> wrote:

> I have a made custom user model.
>
> class CustomUserManager(BaseUserManager):
> def _create_user(self, email, username, password, first_name,
> last_name, date_of_birth, gender, mobile_number,
>  is_active, is_admin, is_superuser):
> """
> Creates and saves a user with given email and password
> """
> if not email:
> raise ValueError('Email must be set')
>
> email = self.normalize_email(email)
> now = timezone.now()
>
> user = self.model(
> email=email,
> username=username,
> first_name=first_name,
> last_name=last_name,
> date_of_birth=date_of_birth,
> gender=gender,
> mobile_number=mobile_number,
> date_joined=now,
> is_active=is_active,
> is_admin=is_admin,
> is_superuser=is_superuser,
> )
> user.set_password(password)
> user.save(using=self._db)
> return user
>
> def create_user(self, email, username, password, first_name,
> last_name, date_of_birth, gender, mobile_number, **extra_fields):
> user = self._create_user(email, username, password, first_name,
> last_name, date_of_birth, gender, mobile_number, True, False, False,
> **extra_fields)
> user.save(using=self._db)
> return user
>
> def create_superuser(self, email, username, password, first_name,
> last_name, date_of_birth, gender, mobile_number, **extra_fields):
> user = self._create_user(email, username, password, first_name,
> last_name, date_of_birth, gender, mobile_number, True, True, True,
> **extra_fields)
> user.save(using=self._db)
> return user
>
>
> class CustomUser(AbstractBaseUser, PermissionsMixin):
> email = models.EmailField(_('email address'), max_length=254,
> unique=True)
> username = models.CharField(_('user name'), max_length=254,
> unique=True)
> first_name = models.CharField(_('first name'), max_length=30)
> last_name = models.CharField(_('last name'), max_length=30)
> date_of_birth = models.DateField()
> gender = models.CharField(choices=GENDERTYPE, max_length=1)
> mobile_number = models.IntegerField(unique=True)
> date_joined = models.DateTimeField(_('date joined'),
> default=timezone.now)
> is_active = models.BooleanField(default=True)
> is_admin = models.BooleanField(default=False)
>
> objects = CustomUserManager()
>
> USERNAME_FIELD = 'email'
> REQUIRED_FIELDS = ['username', 'first_name', 'last_name',
> 'date_of_birth', 'gender', 'mobile_number']
> ...
> ...
>
> And to process the model, I have a custom user creation forms.py
>
> class UserCreationForm(forms.ModelForm):
> password = forms.CharField(label='Password',
> widget=forms.PasswordInput)
>
> class Meta:
> model = CustomUser
> fields = ('email', 'username', 'first_name', 'last_name',
> 'date_of_birth', 'gender', 'mobile_number')
>
> def save(self, commit=True):
> # Save the provided password in hashed format
> user = super(UserCreationForm, self).save(commit=False)
> user.set_password(self.cleaned_data["password"])
> print self.cleaned_data["password"]
> if commit:
> user.save()
> return user
>
>
> class UserChangeForm(forms.ModelForm):
> password = ReadOnlyPasswordHashField()
>
> class Meta:
> model = CustomUser
> fields = (
> 'email', 'username', 'first_name', 'last_name',
> 'date_of_birth', 'gender', 'mobile_number', 'is_active',
> 'is_admin'
> )
>
> def clean_password(self):
> return self.initial["password"]
>
> I can save and create a new user. Also I can see the hashed password in
> the admin. However when I try to login with the `email` and `password` of
> the new user, I am not being authenticated. To check if I am actually
> getting any password, I tried printing the *self.cleaned_data["password"]
> *in the UserCreationForm, and in the console I can see the password I
> gave. What am I doing wrong here? Please 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/CA%2B4-nGocC6r9zwG0a6niNM7DRtnnEOyRhnk0cV8U_tQy8nyzqg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Cannot login with user credentials

2016-07-23 Thread Robin Lery
I have a made custom user model.

class CustomUserManager(BaseUserManager):
def _create_user(self, email, username, password, first_name,
last_name, date_of_birth, gender, mobile_number,
 is_active, is_admin, is_superuser):
"""
Creates and saves a user with given email and password
"""
if not email:
raise ValueError('Email must be set')

email = self.normalize_email(email)
now = timezone.now()

user = self.model(
email=email,
username=username,
first_name=first_name,
last_name=last_name,
date_of_birth=date_of_birth,
gender=gender,
mobile_number=mobile_number,
date_joined=now,
is_active=is_active,
is_admin=is_admin,
is_superuser=is_superuser,
)
user.set_password(password)
user.save(using=self._db)
return user

def create_user(self, email, username, password, first_name, last_name,
date_of_birth, gender, mobile_number, **extra_fields):
user = self._create_user(email, username, password, first_name,
last_name, date_of_birth, gender, mobile_number, True, False, False,
**extra_fields)
user.save(using=self._db)
return user

def create_superuser(self, email, username, password, first_name,
last_name, date_of_birth, gender, mobile_number, **extra_fields):
user = self._create_user(email, username, password, first_name,
last_name, date_of_birth, gender, mobile_number, True, True, True,
**extra_fields)
user.save(using=self._db)
return user


class CustomUser(AbstractBaseUser, PermissionsMixin):
email = models.EmailField(_('email address'), max_length=254,
unique=True)
username = models.CharField(_('user name'), max_length=254, unique=True)
first_name = models.CharField(_('first name'), max_length=30)
last_name = models.CharField(_('last name'), max_length=30)
date_of_birth = models.DateField()
gender = models.CharField(choices=GENDERTYPE, max_length=1)
mobile_number = models.IntegerField(unique=True)
date_joined = models.DateTimeField(_('date joined'),
default=timezone.now)
is_active = models.BooleanField(default=True)
is_admin = models.BooleanField(default=False)

objects = CustomUserManager()

USERNAME_FIELD = 'email'
REQUIRED_FIELDS = ['username', 'first_name', 'last_name',
'date_of_birth', 'gender', 'mobile_number']
...
...

And to process the model, I have a custom user creation forms.py

class UserCreationForm(forms.ModelForm):
password = forms.CharField(label='Password', widget=forms.PasswordInput)

class Meta:
model = CustomUser
fields = ('email', 'username', 'first_name', 'last_name',
'date_of_birth', 'gender', 'mobile_number')

def save(self, commit=True):
# Save the provided password in hashed format
user = super(UserCreationForm, self).save(commit=False)
user.set_password(self.cleaned_data["password"])
print self.cleaned_data["password"]
if commit:
user.save()
return user


class UserChangeForm(forms.ModelForm):
password = ReadOnlyPasswordHashField()

class Meta:
model = CustomUser
fields = (
'email', 'username', 'first_name', 'last_name',
'date_of_birth', 'gender', 'mobile_number', 'is_active',
'is_admin'
)

def clean_password(self):
return self.initial["password"]

I can save and create a new user. Also I can see the hashed password in the
admin. However when I try to login with the `email` and `password` of the
new user, I am not being authenticated. To check if I am actually getting
any password, I tried printing the *self.cleaned_data["password"] *in the
UserCreationForm, and in the console I can see the password I gave. What am
I doing wrong here? Please 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/CA%2B4-nGpF5MBCa3n182UKQcgDiAu1L_GKw1Q0uUyh6EQBaQQz%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Allow users to vote up, down or nothing

2016-06-06 Thread Robin Lery
Hello,
I have made an app to create article. This is the model:

class Article(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL)
title = models.CharField(max_length=150)
body = models.TextField()
pub_date = models.DateTimeField(default=timezone.now)
tags = models.ManyToManyField(Tag)
article_image = models.ImageField(upload_to=get_upload_file_name,
blank=True)

Here I want to setup a voting system for each app. There I would the user
to vote up, or vote down, or do nothing. Boolean field would have been
great, but since an article can have 3 choices of votes  (vote up / vote
down / no vote ), how should I go about doing this? Your help and guidance
will be very much appreciated.

Thank you.


Virus-free.
www.avast.com

<#DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group 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%2B4-nGo-pNLjsEoE5bVT%3DaGxcJGcCm9nvx%2Bqjj8J6rT2J%3Dgq%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Display form errors above its respective field with ajax

2015-12-27 Thread Robin Lery
I have a contact form through which users would be able to contact me. I am
using django with ajax, and it works fine if there's no error. I would like
to show the errors if there's any like it displays above the input fields
and not just the errors, but both the input and the errors. It does however
differentiate between the success and error result, as the ajax request was
successful. But I need to display the actual form errors.

I would like to display the errors like the below as it normally does
without ajax:


​

How do I that? Your help will be very much appreciated. Thank you.

views:

def contact(request):
if request.is_ajax() and request.POST:
form = ContactForm(request.POST)
if form.is_valid():
new_contact = form.save()
data = {
'result': 'success',
'message': 'Message Sent.'
}
return JsonResponse(data)
else:
data = {
'result': 'error',
'message': 'Form invalid',
'form': 'oops.'
}
return JsonResponse(data)
else:
form = ContactForm()
return render(request, 'public_contact.html', {
'form': form
})

js:

contact_right_form.find('#submit').on('click', function(event) {
event.preventDefault();
$.ajax({
type: contact_right_form.attr('method'),
url: '/contact/',
data: contact_right_form.serialize(),
dataType: 'json',
success: function(data) {
if ( data.result == 'success') {
contact_right_message_sent.text(data.message);
contact_right_message_sent.show();
}
else {
contact_right_message_sent.text(data.message);
contact_right_message_sent.show();
}
},
error: function() {
contact_right_message_sent.text('Sorry! Something went wrong.')
}
});
})

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


Re: Merry Xmass

2015-12-25 Thread Robin Lery
Merry Christmas!

On Fri, Dec 25, 2015 at 3:09 AM, Andrea Mucci  wrote:

> Merry Xmass to all and all your family
> Have a good djangoized new year
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/B8DEB09A-4DDD-4B28-BCCF-DAAA457CA60B%40gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Display the form errors in the django template with ajax post

2015-12-24 Thread Robin Lery
I have a contact form through which users would be able to contact me. I am
using django with ajax, and it works fine *if* there's no error. I would
like to show the errors if there's any like it displays above the input
fields and not just the errors, but both the input and the errors. It does
however differentiate between the success and error result, as the ajax
request was successful. But I need to display the actual form errors. How
do I that? Your help will be very much appreciated. Thank you.

views:

def contact(request):
if request.is_ajax() and request.POST:
form = ContactForm(request.POST)
if form.is_valid():
new_contact = form.save()
data = {
'result': 'success',
'message': 'Message Sent.'
}
return JsonResponse(data)
else:
data = {
'result': 'error',
'message': 'Form invalid',
'form': 'oops.'
}
return JsonResponse(data)
else:
form = ContactForm()
return render(request, 'public_contact.html', {
'form': form
})


js:

contact_right_form.find('#submit').on('click', function(event) {
event.preventDefault();
$.ajax({
type: contact_right_form.attr('method'),
url: '/contact/',
data: contact_right_form.serialize(),
dataType: 'json',
success: function(data) {
if ( data.result == 'success') {
contact_right_message_sent.text(data.message);
contact_right_message_sent.show();
}
else {
contact_right_message_sent.text(data.message);
contact_right_message_sent.show();
}
},
error: function() {
contact_right_message_sent.text('Sorry! Something went wrong.')
}
});
})

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


Re: Timer for online examination

2015-11-17 Thread Robin Lery
Yes, that's true.

On Tue, Nov 17, 2015 at 4:52 PM, Jani Tiainen <rede...@gmail.com> wrote:

> Hello,
>
> As I said, on client side doing timer requires javascript usage. But it
> doesn't remove need to actually make sure that no-one can manipulate
> duration of exam.
>
> It's really trivial to have piece of javascript that would render plain
> javascript timer useless (like you could fill out form forever).
>
> So to make sure cheating doesnt happen - at the moment exam is created
> exam end time should be recorderd on server side as well (in database for
> example). So even someone manages to hack the js (which is really simple)
> they can't overcome limitation from the server.
>
> Like the rule #1 in web development says - "Never trust user input".
>
>
> On 17.11.2015 09:47, Robin Lery wrote:
>
> Hello,
> I think you will  have to implement jquery/javascript to make the timer.
> After the countdown finishes js can post the form automatically.
>
> Cheers.
>
> On Tue, Nov 17, 2015 at 1:11 PM, Jani Tiainen <rede...@gmail.com> wrote:
>
>> Hi,
>>
>> If you're looking something magical there isn't anything. Just declare
>> expiracy timestamp and compare against it in code. It should be rather
>> trivial to do with JS down counter to UI for mode concrete feedback to end
>> user.
>>
>> But keep final word of expiracy in Django code.
>>
>>
>> On 17.11.2015 08:28, Arindam sarkar wrote:
>>
>> I am developing an online examination website. And having difficulty
>> implementing the timer .
>> Any one have done it or something related to countdown timer in django ?
>>
>> --
>> Regards,
>>
>> Arindam
>>
>> Contact no. 08732822385
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to <django-users+unsubscr...@googlegroups.com>
>> django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to <django-users@googlegroups.com>
>> django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> <https://groups.google.com/d/msgid/django-users/CAGnF%2BrAAv5DYpPWVxxOGV8%2BsE_w%3DKEhYSnBVArnRTggPuWXfyQ%40mail.gmail.com>
>> https://groups.google.com/d/msgid/django-users/CAGnF%2BrAAv5DYpPWVxxOGV8%2BsE_w%3DKEhYSnBVArnRTggPuWXfyQ%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>
>> django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> <https://groups.google.com/d/msgid/django-users/564ADA2D.501%40gmail.com?utm_medium=email_source=footer>
>> https://groups.google.com/d/msgid/django-users/564ADA2D.501%40gmail.com.
>>
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> <https://groups.google.com/d/msgid/django-users/CA%2B4-nGp_1wr-DeObEnrV9GvtpbvcY5hj%2B7R9%2Bqy3n81F6dFHtg%40mail.gmail.com?utm_medium=email_source=footer>
> https://groups.google.com/d/msgid/django-users/CA%2B4-nGp_1wr-DeObEnrV9GvtpbvcY5hj%2B7R9%2Bqy3n81F6dFHtg%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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/

Re: Timer for online examination

2015-11-16 Thread Robin Lery
Hello,
I think you will  have to implement jquery/javascript to make the timer.
After the countdown finishes js can post the form automatically.

Cheers.

On Tue, Nov 17, 2015 at 1:11 PM, Jani Tiainen  wrote:

> Hi,
>
> If you're looking something magical there isn't anything. Just declare
> expiracy timestamp and compare against it in code. It should be rather
> trivial to do with JS down counter to UI for mode concrete feedback to end
> user.
>
> But keep final word of expiracy in Django code.
>
>
> On 17.11.2015 08:28, Arindam sarkar wrote:
>
> I am developing an online examination website. And having difficulty
> implementing the timer .
> Any one have done it or something related to countdown timer in django ?
>
> --
> Regards,
>
> Arindam
>
> Contact no. 08732822385
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> 
> https://groups.google.com/d/msgid/django-users/CAGnF%2BrAAv5DYpPWVxxOGV8%2BsE_w%3DKEhYSnBVArnRTggPuWXfyQ%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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/564ADA2D.501%40gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: DoesNotExist: Group matching query does not exist.

2015-11-12 Thread Robin Fourcade
Thanks for your reply,
It was in the DB but, I don't know why, I had this issue. I made the 
migration a second time and this time, it worked.

Thanks,
Robin.

-- Solved.

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


Re: Django on CentOS

2015-11-11 Thread Robin Fourcade
Riiigghh,
After many many many tries, it finally worked !

Thanks again, thank you, everybody!

Robin.

-- SOLVED.

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


DoesNotExist: Group matching query does not exist.

2015-11-11 Thread Robin Fourcade
Hi,
I'm working with the auth library.

I've imported all of these:

from django.shortcuts import render, redirect
from pizza_club_order.forms import *
from pizza_club_order.models import *
from django.contrib import auth
from datetime import timedelta, date, datetime, time

But when I'm trying to do this:

auth.models.Group.objects.get(name='test')


Here's the error I get:


Traceback (most recent call last):

  File "", line 1, in 

  File 
"/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 
127, in manager_method

return getattr(self.get_queryset(), name)(*args, **kwargs)

  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", 
line 334, in get

self.model._meta.object_name

DoesNotExist: Group matching query does not exist.


Can someone help me ?


Thanks,

Robin.

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


Re: Django on CentOS

2015-11-11 Thread Robin Fourcade
Hi,

So I made another install with a new user (pizzaclub).

I wrote this in the default.conf:



ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /static /home/pizzaclub/pizzaclub/static

Require all granted




Require all granted



WSGIDaemonProcess pizzaclub 
python-path=/home/pizzaclub:/home/pizzaclub/pizzaclubenv/lib/python2.7/site-packages
WSGIProcessGroup pizzaclub
WSGIScriptAlias / /home/pizzaclub/pizzaclub/wsgi.py



And I still have the same issue which is the 403 error:

[Wed Nov 11 15:07:26.244727 2015] [mpm_event:notice] [pid 27193:tid 
140432722884480] AH00491: caught SIGTERM, shutting down
[Wed Nov 11 15:07:26.354982 2015] [mpm_event:notice] [pid 27289:tid 
140603486005120] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 
configured -- resuming normal operations
[Wed Nov 11 15:07:26.355107 2015] [core:notice] [pid 27289:tid 
140603486005120] AH00094: Command line: '/usr/sbin/apache2'
[Wed Nov 11 15:07:28.461063 2015] [authz_core:error] [pid 27293:tid 
140603387373312] [client 109.10.154.52:51815] AH01630: client denied by 
server configuration: /home/pizzaclub/pizzaclub/wsgi.py
[Wed Nov 11 15:07:30.563364 2015] [authz_core:error] [pid 27293:tid 
140603376875264] [client 109.10.154.52:51815] AH01630: client denied by 
server configuration: /home/pizzaclub/pizzaclub/wsgi.py


Thanks again,

Robin.

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


Re: Django on CentOS

2015-11-11 Thread Robin Fourcade
Hi, 
thanks for your answer.

That's what I did. So if it's a big issue, I'll create a new user on my 
server and I'll redo the installation through this user !

Thanks,
Robin.

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


Re: Django on CentOS

2015-11-11 Thread Robin Fourcade
As I'm not comfortable at all with this, I tried with ubuntu, wich has 
python 2.7 by default.

I follow this 
tutorial: 
https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-apache-and-mod_wsgi-on-ubuntu-14-04

Everything was working well, except at the end, I've 403 error.

[Wed Nov 11 12:56:37.525607 2015] [mpm_event:notice] [pid 28089:tid 
140367682340736] AH00491: caught SIGTERM, shutting down
[Wed Nov 11 12:56:37.635193 2015] [mpm_event:notice] [pid 28192:tid 
140578408851328] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 
configured -- resuming normal operations
[Wed Nov 11 12:56:37.635323 2015] [core:notice] [pid 28192:tid 
140578408851328] AH00094: Command line: '/usr/sbin/apache2'
[Wed Nov 11 12:56:39.823415 2015] [core:error] [pid 28196:tid 
140578239018752] (13)Permission denied: [client 109.10.154.52:50531] 
AH00035: access to / denied (filesystem path '/root/pizzaclub') because 
search permissions are missing on a component of the path
[Wed Nov 11 12:56:40.046750 2015] [core:error] [pid 28196:tid 
140578228528896] (13)Permission denied: [client 109.10.154.52:50531] 
AH00035: access to /favicon.ico denied (filesystem path '/root/pizzaclub') 
because search permissions are missing on a component of the path, referer: 
http://s18710917.domainepardefaut.fr/
[Wed Nov 11 12:56:41.625131 2015] [core:error] [pid 28196:tid 
140578218039040] (13)Permission denied: [client 109.10.154.52:50531] 
AH00035: access to / denied (filesystem path '/root/pizzaclub') because 
search permissions are missing on a component of the path
[Wed Nov 11 12:56:41.871027 2015] [core:error] [pid 28196:tid 
140578207549184] (13)Permission denied: [client 109.10.154.52:50531] 
AH00035: access to /favicon.ico denied (filesystem path '/root/pizzaclub') 
because search permissions are missing on a component of the path, referer: 
http://s18710917.domainepardefaut.fr/

I tried this: 

chmod g+x ./*
or 
chmod +x /root/pizzaclub

But it didn't solve anything. I followed the tutorial line after line, just 
to test (no even with my own project).

Thanks again,
Robin.

Le mercredi 11 novembre 2015 10:04:44 UTC+1, James Schneider a écrit :
>
>
> On Nov 10, 2015 9:46 AM, "Robin Fourcade" <fourca...@gmail.com 
> > wrote:
> >
> > Thanks James,
> > I looked at many tutorials like:
> >
> > 
> https://www.digitalocean.com/community/tutorials/how-to-install-the-django-web-framework-on-centos-7
> > 
> https://devops.profitbricks.com/tutorials/deploy-django-with-virtualenv-on-centos-6/
> >
> > Neither of these are for python 3.7 or higher. :/
> > i would gladly use higher version of python but I can't find any 
> tutorial about it. :/
> >
>
> Python 3.7 would be quite a feat considering it hasn't been invented yet. 
> ;-P
>
> Take a look at these and focus on the parts pertaining to Apache/httpd and 
> mod_wsgi.
>
> https://github.com/crits/crits/wiki/RHEL-Supplemental-Install-Guide
>
>
> https://www.webhostpython.com/billing/knowledgebase.php?action=displayarticle=33
>
>
> https://www.google.com/search?q=centos+6+python+2.7=centos+6+python+=chrome.1.69i57j0l3.8479j1j4=ms-android-hms-tmobile-us=chrome-mobile=UTF-8#q=centos+6+python+2.7+mod_wsgi
>
> If you aren't comfortable compiling your own stuff, you should consider 
> switching to a distribution that supports 2.7 by default. RHEL/CentOS is 
> pretty much the last notable holdout due to their extended release schedule.
>
> -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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8b768c7e-b284-4fd0-a5cd-09234f71fc88%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django on CentOS

2015-11-10 Thread Robin Fourcade
Thanks James,
I looked at many tutorials like:

https://www.digitalocean.com/community/tutorials/how-to-install-the-django-web-framework-on-centos-7
https://devops.profitbricks.com/tutorials/deploy-django-with-virtualenv-on-centos-6/

Neither of these are for python 3.7 or higher. :/
i would gladly use higher version of python but I can't find any tutorial 
about 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bcff03a3-b9a5-4c76-b216-647a369de536%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django on CentOS

2015-11-10 Thread Robin Fourcade
Thanks Matthias,

I set* os.environ.setdefault("DJANGO_SETTINGS_MODULE", 
"pizza_club.settings") in my wsgi.py*
Now I have *ImportError: Could not import settings 'pizza_club.settings' 
(Is it on sys.path?): No module named pizza_club.settings, referer: 
http://www.pizzaclub.fr/*

Is that what you meant ? Because the problem is still there. :/


--

Thanks Timothy,
I'll check the link you gave me. :)

Thanks again,

Robin

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


Re: Django on CentOS

2015-11-09 Thread Robin Fourcade
Thanks for your answer James,
As this server is only the run this project, I can install another linux 
distribution.
I'm able to install theses :

*CentOS 6 minimal system (64 bits)*
Système de base openSUSE 13.1 (64 bits)
Système de base Debian 7 Wheezy (64 bits)
CentOS 6 avec Parallels Plesk Panel 12 (64 bits)
openSUSE 13.1 avec Parallels Plesk Panel 12 (64 bits)
Système de base ubuntu 14.04 (64 bits)

Do you think it's better to install one or another ?

Actually, I already tried on Debian 7 and I followed some tutorial but I 
wasn't able to run the server neither. So if you know a great tutorial 
which shows how to install a django project on one of theses 
distributions, it would be perfect! :)

Thanks again !

Robin.

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


Re: Django on CentOS

2015-11-09 Thread Robin Fourcade
Hi And thanks for your answer.

Le lundi 9 novembre 2015 10:51:01 UTC+1, Gergely Polonkai a écrit :
>
> Hello,
>
> there’s a lot that is not clear for me in your included config:
>
> • Why are all those paths in WSGIPythonPath?
>

I'm not used to install django projects so I followed this 
tutorial: 
http://www.science-emergence.com/LeWebFrameworkDjango/DeployerUneApplicationDjangoSurCentos/#deployer-votre-application-django

I copy-pasted django_wsgi.conf they gave here, and I replaced by the right 
paths.

• Are there Python modules in those directories?
>

Here's all my project:

+--- pizzaclub

|   +--- pizza_club

|   |   +--- settings.py

|   |   +--- wsgi.pyc

|   |   +--- settings.pyc

|   |   +--- wsgi.py

|   |   +--- __init__.pyc

|   |   +--- __init__.py

|   |   +--- templates

|   +--- public

|   |   +--- static

|   |   |   +--- fonts

|   |   |   +--- admin

|   |   |   |   +--- img

|   |   |   |   +--- js

|   |   |   |   +--- css

|   |   |   |   |   +--- base.css

|   |   |   +--- js

|   |   |   +--- css

|   |   +--- statics

|   |   |   +--- fonts

|   |   |   +--- admin

|   |   |   |   +--- js

|   |   |   |   |   +--- jquery.js

|   |   |   |   |   +--- timeparse.js

|   |   |   |   |   +--- actions.js

|   |   |   |   |   +--- collapse.js

|   |   |   |   |   +--- related-widget-wrapper.js

|   |   |   |   |   +--- admin

|   |   |   |   |   |   +--- DateTimeShortcuts.js

|   |   |   |   |   |   +--- RelatedObjectLookups.js

|   |   |   |   |   +--- LICENSE-JQUERY.txt

|   |   |   |   |   +--- urlify.js

|   |   |   |   |   +--- inlines.min.js

|   |   |   |   |   +--- jquery.init.js

|   |   |   |   |   +--- jquery.min.js

|   |   |   |   |   +--- core.js

|   |   |   |   |   +--- prepopulate.min.js

|   |   |   |   |   +--- collapse.min.js

|   |   |   |   |   +--- inlines.js

|   |   |   |   |   +--- SelectFilter2.js

|   |   |   |   |   +--- actions.min.js

|   |   |   |   |   +--- calendar.js

|   |   |   |   |   +--- SelectBox.js

|   |   |   |   |   +--- prepopulate.js

|   |   |   |   +--- css

|   |   |   |   |   +--- dashboard.css

|   |   |   |   |   +--- changelists.css

|   |   |   |   |   +--- forms.css

|   |   |   |   |   +--- widgets.css

|   |   |   |   |   +--- rtl.css

|   |   |   |   |   +--- login.css

|   |   |   |   |   +--- ie.css

|   |   |   |   |   +--- base.css

|   |   |   +--- js

|   |   |   |   +--- bootstrap.js

|   |   |   |   +--- bootstrap.min.js

|   |   |   |   +--- npm.js

|   |   |   +--- css

|   |   |   |   +--- styles.css

|   |   +--- urls.pyc

|   |   +--- media

|   |   +--- django_wsgi.conf

|   |   +--- __init__.pyc

|   |   +--- pizzaclub.wsgi

|   |   +--- urls.py

|   |   +--- __init__.py

|   +--- pizza_club_order

|   |   +--- migrations

|   |   |   +--- 0003_commande_cout.pyc

|   |   |   +--- 0003_commande_cout.py

|   |   |   +--- 0002_transaction.py

|   |   |   +--- 0006_pizza_taille.pyc

|   |   |   +--- 0002_transaction.pyc

|   |   |   +--- 0007_heures.py

|   |   |   +--- 0004_auto_20151025_2251.pyc

|   |   |   +--- __init__.pyc

|   |   |   +--- 0004_auto_20151025_2251.py

|   |   |   +--- 0005_auto_20151025_2251.py

|   |   |   +--- 0007_heures.pyc

|   |   |   +--- 0005_auto_20151025_2251.pyc

|   |   |   +--- __init__.py

|   |   |   +--- 0001_initial.pyc

|   |   |   +--- 0006_pizza_taille.py

|   |   |   +--- 0001_initial.py

|   |   +--- models.pyc

|   |   +--- admin.py

|   |   +--- urls.pyc

|   |   +--- views.pyc

|   |   +--- forms.pyc

|   |   +--- admin.pyc

|   |   +--- models.py

|   |   +--- __init__.pyc

|   |   +--- views.py

|   |   +--- forms.py

|   |   +--- urls.py

|   |   +--- __init__.py

|   |   +--- tests.py

|   |   +--- templates

|   |   |   +--- pizza_club_order

|   |   |   |   +--- intervenant.html

|   |   |   |   +--- inscription.html

|   |   |   |   +--- payement.html

|   |   |   |   +--- crediter.html

|   |   |   |   +--- accueil.html

|   |   |   |   +--- tresorerie.html

|   |   |   |   +--- login.html

|   |   |   |   +--- commander.html

|   |   |   |   +--- profil.html

|   |   |   +--- base.html

|   |   |   +--- .DS_Store

|   +--- manage.py

|   +--- db.sqlite3

|   +--- apache

|   +--- db.sql


Everything is here ! (It's quite a small project)
 

> • Do I get it right that your application is installed under /var/www 
> (which is generally a bad idea)?
>

You're right. I didn't know it was a bad idea, I followed the previous 
tutorial, which actually seems to be not so great.
 

> • Is pizzaclub/settings.py available if you stand in any of those 
> directories? (Ie. try cd ; ls pizzaclub/settings.py)
>
>
It's available, as we can see in my tree.
 

> Best,
> Gergely
>

Thanks,
Robin. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@goo

Re: Django on CentOS

2015-11-09 Thread Robin Fourcade
Hello, thanks for the answer.

I've this code in my wsgi:

import os, sys
#Calculate the path based on the location of the WSGI script
apache_configuration = os.path.dirname(__file__)
project = os.path.dirname(apache_configuration)
workspace = os.path.dirname(project)
sys.path.append(workspace)

os.environ['DJANGO_SETTINGS_MODULE'] = 'pizzaclub.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

And I don't know how to find the error as it works well when I run the 
project with manage.py.

My settings file is there:
/var/www/html/pizzaclub/pizza_club/settings.py

I just added this in httpd.conf:

Include "/var/www/html/pizzaclub/public/django_wsgi.conf"


and this in the wsgi:

Alias /static/ /var/www/html/pizzaclub/public/static/
Alias /media/ "/var/www/html/pizzaclub/public/media/"

WSGIScriptAlias / "/var/www/html/pizzaclub/public/pizzaclub.wsgi"
WSGIPythonPath 
/var/www/html/emergence/:/var/www/html/pizzaclub/pizza_club:/var/www/html/pizzaclub/pizza_club/db:/var/www/html/pizzaclub/public/media:/var/www/html/pizzaclub/apache:/usr/bin/python


Allow from all


Thanks again for your 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ec3bba44-a637-48e5-9636-ff5ffadd13e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django on CentOS

2015-11-08 Thread Robin Fourcade
Hi,
Thanks for your answer !
(I'd add that even if apache is running, if I run the server on the port 
8000, I can acces the django project on this port without any issue)

Here's the log

[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] mod_wsgi 
(pid=22420): Exception occurred processing WSGI script 
'/var/www/html/pizzaclub/public/pizzaclub.wsgi'.
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] Traceback (most 
recent call last):
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File 
"/usr/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 219, 
in __call__
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] 
self.load_middleware()
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File 
"/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 37, 
in load_middleware
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] for 
middleware_path in settings.MIDDLEWARE_CLASSES:
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File 
"/usr/lib/python2.6/site-packages/django/utils/functional.py", line 184, in 
inner
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] self._setup()
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File 
"/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 42, in 
_setup
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] self._wrapped 
= Settings(settings_module)
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File 
"/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 95, in 
__init__
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] raise 
ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % 
(self.SETTINGS_MODULE, e))
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] ImportError: 
Could not import settings 'pizzaclub.settings' (Is it on sys.path?): No 
module named pizzaclub.settings
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] mod_wsgi 
(pid=22420): Exception occurred processing WSGI script 
'/var/www/html/pizzaclub/public/pizzaclub.wsgi'., referer: 
http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] Traceback (most 
recent call last):, referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File 
"/usr/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 219, 
in __call__, referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] 
self.load_middleware(), referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File 
"/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 37, 
in load_middleware, referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] for 
middleware_path in settings.MIDDLEWARE_CLASSES:, referer: 
http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File 
"/usr/lib/python2.6/site-packages/django/utils/functional.py", line 184, in 
inner, referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] 
self._setup(), referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File 
"/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 42, in 
_setup, referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] self._wrapped 
= Settings(settings_module), referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52]   File 
"/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 95, in 
__init__, referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] raise 
ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % 
(self.SETTINGS_MODULE, e)), referer: http://212.227.107.82/
[Sun Nov 08 14:46:41 2015] [error] [client 109.10.154.52] ImportError: 
Could not import settings 'pizzaclub.settings' (Is it on sys.path?): No 
module named pizzaclub.settings, referer: http://212.227.107.82/
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52] mod_wsgi 
(pid=22420): Exception occurred processing WSGI script 
'/var/www/html/pizzaclub/public/pizzaclub.wsgi'.
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52] Traceback (most 
recent call last):
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52]   File 
"/usr/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 219, 
in __call__
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52] 
self.load_middleware()
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52]   File 
"/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 37, 
in load_middleware
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52] for 
middleware_path in settings.MIDDLEWARE_CLASSES:
[Sun Nov 08 14:46:42 2015] [error] [client 109.10.154.52]   File 

Django on CentOS

2015-11-08 Thread Robin Fourcade
Hello,
I'm trying to run my django project on my CentOS server.

I followed this tutorial 
: 
http://www.science-emergence.com/LeWebFrameworkDjango/DeployerUneApplicationDjangoSurCentos/#deployer-votre-application-django

And at the end, they say that I just have to enter my server IP address and 
I'll have access to my project, but I only have a 500 error: *Internal 
Server Error*

However, when I shutdown apache and run: python manage.py runsever 
0.0.0.0:80, everything works fine.

How is it possible to do without runsever, because I read somewhere that it 
what not the right thing to do.

Can somebody help me ?

Thanks,
Robin Fourcade.

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


Re: Exchange models between apps

2015-10-17 Thread Robin Lery
Can u try this
from userprofile.models import UserProfile
On 17 Oct 2015 19:24, "svewa"  wrote:

> Hello everyone,
>
> I have a problem with using models between django apps. In my project I
> have an app called *userprofile *containing a model *UserProfile*. In
> another app where I have a model *Object *I want to use my *UserProfile *model
> to give the *Object *an owner like so:
>
> *from mysite.userprofile.models import UserProfile*
> ...
> *class Object(models.Model):*
> * owner = models.ForeignKey(UserProfile)*
>
> but importing the module userprofile fails:
>
> *ImportError: No module named userprofile.models*
>
> although my project root mysite is in the python path and my IDE is able
> to interpret the import statement. Of course I've registered the apps in my
> settings.py. Any hints what the problem is or do I ignore something that is
> a common technique to exchange models between apps?
>
> Any help is appreciated, many thanks in advance annd best regards,
>
> svewa
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/6e09a837-2505-4148-aa71-0a0ff1b9c268%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGpmq%2BTaH6jHG5AL%3DFNj9nQ0ouxNVJqKGAchDNv7MQkxvA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django on Windows

2015-10-01 Thread Robin Lery
Did you install python? And is it in your environmental variable? If both
the answers yes then you could try all the commands using cmd prompt in
windows.
On 1 Oct 2015 17:51, "Антон Заровский"  wrote:

> How use concole commands at windows?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d9d6d648-f9cd-4f37-8214-9d0d0927c75d%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGqTnJ9iTeDwoZBjU%2BcJ3H2Vcs-8VUtsKbbR1NXP8tm7wQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django clustering - How to manage Image uploading

2015-09-09 Thread Robin Lery
You upload all your images into s3.
On 9 Sep 2015 17:23, "Gabriele Morgante" 
wrote:

> Hi,
>
> I developed a Django 1.8.4 webapp and now I've to deploy it in production
> environment. The app allows users to upload images on the server. My
> problem is that in a production environment I've many servers with django
> deployed and a load balancer. Than, how can I manage Image uploading in a
> clustered production environment? Is there a best practice?
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/815dbc40-8251-41f2-8039-fd921164a682%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGrNQ0b77gCt69W2%3DCOLfuSjgW2e4Vk3MEU_zLMbRfF3jA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Different auth user models withoout doing multi-table inheritance

2015-08-10 Thread Robin Lery
You surely can use Choice field for either Customer or Merchant in your
custom user class.
On 10 Aug 2015 20:12, "Avraham Serour"  wrote:

> I personally like a profile model, but if you implement two you may have
> headaches when doing a reverse relation from user, you would need to check
> every time of the request.user is a customer or merchant.
>
> In any case what is the difference between them anyway? Why can't a user
> be both?
>
> On Mon, Aug 10, 2015, 4:38 PM Ankit Agrawal  wrote:
>
>> I am working on a project which has two different sets of users -
>> Customer and Merchant. Both of these users should be able to register
>> and login to their respective profiles. The most obvious choice to
>> implement this that came to my mind was to make two different models
>> Customer and Merchant that inherit from a BaseUser model that will store
>> the common fields i.e. Multi-table inheritance -
>> https://docs.djangoproject.com/en/1.8/topics/db/models/#multi-table-inheritance
>>
>>
>> Quoting Two Scoops of Django -
>>
>>
>> At all costs, everyone should avoid multi-table inheritance (see warning 
>> above) since it adds both confusion and substantial overhead...Adds 
>> substantial overhead since each query on a child table requires joins with 
>> all parent tables.
>>
>> I would like to know if and why having an explicit OneToOneField is
>> better than Multi-table inheritance. Also, are there any other better ways
>> to model the above relationship?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/81954b62-2c89-404f-94a5-5f9a485c28c8%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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAFWa6tJar_3PcyOytTsY1EKhbW4Y7M45Kqnt4oU3VLyvGjfrEw%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGrDx8Aqiu6Xz%3Dwm_OMWgk_rC-kWBv_WGj%3DurWZNTE8LzA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: No module named 'blog'

2015-08-09 Thread Robin Lery
Did you add your 'blog' app in the installed apps in settings.py?

On Sun, Aug 9, 2015 at 10:35 PM, Maggie Chang 
wrote:

> hi all,
> would like to seek for everyone's help.
> I am following the django girls instruction =>
> http://tutorial.djangogirls.org/en/django_urls/index.html#your-first-django-url,
> but encounter the problem.
> when I connect to 127.0.0.1:8000, I got the No module named 'blog'
> response.
> Here's the message on browser.
> **
> ImportError at /
>
> No module named 'blog'
>
> Request Method:GETRequest URL:http://127.0.0.1:8000/Django 
> Version:1.8Exception
> Type:ImportErrorException Value:
>
> No module named 'blog'
>
> Exception Location:/usr/lib/python3.4/importlib/__init__.py in
> import_module, line 109Python Executable:
> /home/maggie/djangoanywhere/venv/bin/pythonPython Version:3.4.0Python
> Path:
>
> ['/home/maggie/djangoanywhere',
>  '/usr/lib/python3.4',
>  '/usr/lib/python3.4/plat-x86_64-linux-gnu',
>  '/usr/lib/python3.4/lib-dynload',
>  '/home/maggie/djangoanywhere/venv/lib/python3.4/site-packages']
>
> Server time:Mon, 10 Aug 2015 00:47:53 +0800
> **
>
> This issue occurred when I add *url(r'', include('blog.urls')), *into
> *magsite/url.py*
> **
> *url.py*
> **
> from django.conf.urls import include, url
> from django.contrib import admin
>
>
> urlpatterns = [
> url(r'^admin/', include(admin.site.urls)),
> url(r'', include('blog.urls')),
> ]
> **
> Any idea about the root cause? :(
> and any response will be appreciate.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/0c3ba90d-97d3-448c-8656-0b2ad6becca7%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGpULH_6Kswi7jHc5_T6cPSt5%2B07vtUVAsN_z9fPCPdRUg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Upload new file to the uploaded file path

2015-08-08 Thread Robin Lery
It works perfectly! I am using it to upload in s3, and even for s3 it works
as it is supposed to. I am really grateful to you.

Thank you.

On Wed, Aug 5, 2015 at 4:37 PM, 'Tom Evans' via Django users <
django-users@googlegroups.com> wrote:

> On Tue, Aug 4, 2015 at 9:45 PM, Robin Lery <robinl...@gmail.com> wrote:
> > I have a model for Video:
> >
> > class Video(models.Model):
> > title = models.CharField(max_length=75)
> > pubdate = models.DateTimeField(default=timezone.now)
> > original_video = models.FileField(upload_to=get_upload_file_name)
> > mp4_720 = models.FileField(upload_to=get_upload_file_name,blank=True,
> > null=True)
> > converted = models.BooleanField(default=False)
> >
> > And this is the view:
> >
> > def upload_video(request):
> > if request.POST:
> > form = VideoForm(request.POST, request.FILES)
> > if form.is_valid():
> > video = form.save(commit=False)
> > video.save()
> > convert_video.delay(video.id)
> > return HttpResponseRedirect('/')
> >
> > Lastly the tasks.py:
> >
> > def get_upload_file_name(video):
> > name = video.title
> > name = name+'.mp4'
> > return name
> >
> > from pyvid.settings import MEDIA_ROOT
> >
> > @app.task
> > def convert_video(video_id):
> > video = Video.objects.get(id=video_id)
> > video_path = str(MEDIA_ROOT)+'/'+str(video.original_video)
> > convert_video_name = get_upload_file_name(video)
> > cmd = 'ffmpeg -i %s -codec:v libx264 -profile:v baseline -preset slow
> > -b:v 250k -maxrate 250k -bufsize 500k -vf scale=-1:360 -threads 0
> -codec:a
> > libfdk_aac -movflags +faststart %s.mp4' % (video_path,
> convert_video_name)
> > subprocess.call(
> > cmd,
> > shell=True
> > )
> >
> > video.mp4_720 = convert_video_name
> > video.converted = True
> > video.save()
> >
> > The problem is, even though video.mp4_720 is directed to
> > upload_to=get_upload_file_name, its just taking the value of
> > convert_video_name file path (which is in the base directory of the
> project)
> > but not to the path applied.
> >
> > How do I upload the new converted file it to the uploaded path?
> >
>
> You asked this about 3 weeks ago as well (and replied to that email
> today), did this approach not work?:
>
> This is explained in the docs for FileField, you need to create a
> django.core.files.File subclass, and save() it on the FieldFile object
> that is returned when you access the FileField field on your model
> instance.
>
> Eg:
>
> from django.core.files import File
> fp = open('/path/to/file')
> myfile = File(fp)
> my_obj.mp4_720.save(name="", content=myfile)
>
>
> https://docs.djangoproject.com/en/1.8/ref/models/fields/#django.db.models.fields.files.FieldFile.save
>
> Cheers
>
> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAFHbX1%2BxUVC0vnV2wctro46ZOfWrF53BjOj1odQdzg92SDvL0Q%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGoaWkfqb3M2jQzY6OnCiSwicbStmN1f0PZ8u%3D-nQjpSuA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Celery to process task and modify the model fields

2015-08-04 Thread Robin Lery
Hi,
Thank you so very much kind sir. This really helped!

On Wed, Jul 15, 2015 at 4:08 PM, 'Tom Evans' via Django users <
django-users@googlegroups.com> wrote:

> On Tue, Jul 14, 2015 at 9:15 PM, Robin Lery <robinl...@gmail.com> wrote:
> > Yes. That time you were the one to guide me. I was looking at other
> projects
> > after that.
> >
> > I am just confused on how to get the video.mp4_720 to be the converted
> > video. Will you please help.
> >
>
> This is explained in the docs for FileField, you need to create a
> django.core.files.File subclass, and save() it on the FieldFile object
> that is returned when you access the FileField field on your model
> instance.
>
> Eg:
>
> from django.core.files import File
> fp = open('/path/to/file')
> myfile = File(fp)
> my_obj.mp4_720.save(name="", content=myfile)
>
>
> https://docs.djangoproject.com/en/1.8/ref/models/fields/#django.db.models.fields.files.FieldFile.save
>
> Also, you should not pass objects as arguments to celery tasks, you
> should instead pass the id of the object and fetch the object again in
> the celery task.
>
> Cheers
>
> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAFHbX1J%2BGf_hRB7ERLonXpT_jhDqX8NkEYtV5qnftyMgKvJ0OA%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGrVp5AeTeC%3D7w%2BDgy2b02XXZ5qpi7q6%3DGb%2BFr7A9ojrMg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Upload new file to the uploaded file path

2015-08-04 Thread Robin Lery
I have a model for Video:

class Video(models.Model):
title = models.CharField(max_length=75)
pubdate = models.DateTimeField(default=timezone.now)
original_video = models.FileField(upload_to=get_upload_file_name)
mp4_720 = models.FileField(upload_to=get_upload_file_name,blank=True,
null=True)
converted = models.BooleanField(default=False)

And this is the view:

def upload_video(request):
if request.POST:
form = VideoForm(request.POST, request.FILES)
if form.is_valid():
video = form.save(commit=False)
video.save()
convert_video.delay(video.id)
return HttpResponseRedirect('/')

Lastly the tasks.py:

def get_upload_file_name(video):
name = video.title
name = name+'.mp4'
return name

from pyvid.settings import MEDIA_ROOT

@app.task
def convert_video(video_id):
video = Video.objects.get(id=video_id)
video_path = str(MEDIA_ROOT)+'/'+str(video.original_video)
convert_video_name = get_upload_file_name(video)
cmd = 'ffmpeg -i %s -codec:v libx264 -profile:v baseline -preset slow
-b:v 250k -maxrate 250k -bufsize 500k -vf scale=-1:360 -threads 0 -codec:a
libfdk_aac -movflags +faststart %s.mp4' % (video_path, convert_video_name)
subprocess.call(
cmd,
shell=True
)

video.mp4_720 = convert_video_name
video.converted = True
video.save()

The problem is, even though video.mp4_720 is directed to
upload_to=get_upload_file_name,
its just taking the value of convert_video_name file path (which is in the
base directory of the project) but not to the path applied.

How do I upload the new converted file it to the uploaded path?

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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGp8_TW6JdW4D7iKOgAYE9zOFzc1bE-1kUjPj-p9e1somA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: same field in two classes

2015-08-02 Thread Robin Lery
You can use inheritance. Or content type. Or use signals to get the value
of salary from one model and save it to another model.
On 2 Aug 2015 23:38, "Alex Heyden"  wrote:

> Sorry, I think there might be a bit of a language barrier. What do you
> mean by "take the value of employee salary to payroll salary?"
>
> On Sun, Aug 2, 2015 at 12:12 PM, Giovanny Vizcaya <
> gio.vizcaya@gmail.com> wrote:
>
>> Good day,i'm new in django and i'm doing a project, i have a class
>> "Employee" with atribute "salary", same time i have class "Payroll" with
>> atribute "salary", how can i take the value of employee salary to payroll
>> salary? thank you in advance for answers
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/5a479e43-4612-4b2e-92be-638b5eec9124%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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2Bv0ZYWmYsUj1v_q2h4ooK7u_UyrntYqzKGjB00FK3e6s410Zg%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGqBBk-qYhVWKAeCqMv65A3-z%3DSb6LF6Be72nodi01Zmnw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Learning Django problems

2015-07-29 Thread Robin Lery
Do u have static directory? And does it have the required resources?
On 29 Jul 2015 16:50, "Roshan Pannase"  wrote:

> sir i am a new learner  can you send me the code of this application
>
> On Wed, Jul 29, 2015 at 11:33 AM, Stas soroka 
> wrote:
>
>> I'm currently reading a book "Learning Django Web Development". Even
>> thoug I followed the book carefully, it says, that my page should look like
>> this:
>>
>>
>> 
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> When, in fact, my page looks like that:
>>
>> 
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> I will be very greatful, if someone tell me, what can cause such a
>> problem.
>>
>> If it's needed - a link to my GitHub repository, with a code, that I
>> currently have - GitHub 
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/d7f386bb-16ba-473e-81ea-bab24013d251%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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAGkvgN%3DgcihZhqy-zm%3D7BrAMOY%3D4VmbnQi1o%2B_L3jNQDACTB-w%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGrZaa1Uodw09cXfY9cSAt1M-b-SGpmw_mCXuxEDKf2NYw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Allow users to submit django form once per day

2015-07-23 Thread Robin Lery
You can save the datetime of the last form submission and check whether its
oneday or not in the view. If its one day then show pass the form or else
dont.

Hope this helps.
On 23 Jul 2015 20:38, "Nkansah Rexford"  wrote:

> I want to allow users to submit a django form once, and only once
> everyday. After submitting the form, the form wouldn't even show
> (server-side checkings, I don't want to use JS or client side thing; easily
> 'tamper-able')
>
> What is the best way to do so in 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b310e40f-8baa-449a-bcef-36052d0256a5%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGpU8Pmc7ypxZaGACLY1Y34jLsfr75o_Pq2k4-xo35pV%2Bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Thumbnails In Django

2015-07-21 Thread Robin Lery
Yes. I would like to add easy-thumbnails too. Both are great!
On 22 Jul 2015 01:05, "Sadaf Noor"  wrote:

> In one of my projects I used sorl (
> https://github.com/mariocesar/sorl-thumbnail) instead, it was super easy
> and best fit for my project. Every time it asks for a new thumbnail BUT
> if it exists in its cache, then that one is returned. If it doesn't, a
> new one is generated and stored, then returned. So ultimately it saves. I
> don't know your use case. I am just saying it can be an option.
>
> 2015-07-22 1:22 GMT+06:00 divyanshi kathuria 
> :
>
>> I am using Django Rest framework. I have three fields in my Pin Model :
>> image,thumbnail_medium and thumbnail_small. I want to create two thumbnails
>> from the image. How to do that? I tried the following code : But it's not
>> working.
>> from django.db import models
>> from django.contrib.auth.models import User
>> from thumbs import ImageWithThumbsField
>> #from taggit.managers import TaggableManager
>> from PIL import Image
>> from cStringIO import StringIO
>> from django.core.files.uploadedfile import SimpleUploadedFile
>> import os
>>
>>
>> class Pin(models.Model):
>>
>> url = models.SlugField(blank=True, null=True)
>> title = models.TextField(blank=False,null=False,default='Untitled')
>> description = models.TextField(blank=True, null=True)
>> is_pro = models.BooleanField(default=False)
>> is_hidden = models.BooleanField(default=False)
>> is_for_sale = models.BooleanField(default=False)
>> is_pro = models.BooleanField(default=False)
>> price = models.DecimalField(blank=True, null=True, max_digits=10,
>> decimal_places=2 ,default=0)
>> price_in_rs = models.BooleanField(default=False)
>> size_in_inches = models.BooleanField(default=True)
>> medium = models.TextField(blank=True, null=True)
>> length = models.DecimalField(blank=True, null=True, max_digits=10,
>> decimal_places=2 ,default=0)
>> width = models.DecimalField(blank=True, null=True, max_digits=10,
>> decimal_places=2 ,default=0)
>> hearts = models.IntegerField(blank=True, null=True, default=0)
>> image = models.ImageField(upload_to='pins/pin/originals/')
>> thumbnail = models.ImageField(upload_to='pins/pin/thumbnails/')
>> published = models.DateTimeField(auto_now_add=True)
>> #tags = TaggableManager()
>>
>> def __unicode__(self):
>> return self.url
>>
>> def save(self):
>> from PIL import Image
>> from cStringIO import StringIO
>> from django.core.files.uploadedfile import SimpleUploadedFile
>>
>> # Set our max thumbnail size in a tuple (max width, max height)
>> THUMBNAIL_SIZE = (50, 50)
>>
>> # Open original photo which we want to thumbnail using PIL's Image
>> # object
>> image = Image.open(self.image.name)
>>
>> # Convert to RGB if necessary
>> # Thanks to Limodou on DjangoSnippets.org
>> # http://www.djangosnippets.org/snippets/20/
>> if image.mode not in ('L', 'RGB'):
>> image = image.convert('RGB')
>>
>> # We use our PIL Image object to create the thumbnail, which
>> already
>> # has a thumbnail() convenience method that contrains proportions.
>> # Additionally, we use Image.ANTIALIAS to make the image look
>> better.
>> # Without antialiasing the image pattern artifacts may result.
>> image.thumbnail(THUMBNAIL_SIZE, Image.ANTIALIAS)
>>
>> # Save the thumbnail
>> temp_handle = StringIO()
>> image.save(temp_handle, 'png')
>> temp_handle.seek(0)
>>
>> # Save to the thumbnail field
>> suf = SimpleUploadedFile(os.path.split(self.image.name)[-1],
>> temp_handle.read(), content_type='image/png')
>> self.thumbnail.save(suf.name+'.png', suf, save=False)
>>
>> # Save this photo instance
>> super(Pin, self).save()
>>
>> Can anyone figure out the problem here? Why is it not creating thumbnails?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/13e46569-3641-438d-9201-fa079f7f89b2%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
>   Md. Sadaf Noor (@sadaf2605 )
>  www.sadafnoor.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" 

Re: Celery to process task and modify the model fields

2015-07-14 Thread Robin Lery
Yes. That time you were the one to guide me. I was looking at other
projects after that.

I am just confused on how to get the video.mp4_720 to be the converted
video. Will you please help.

Thank you.

On Wed, Jul 15, 2015 at 1:15 AM, Vijay Khemlani <vkhem...@gmail.com> wrote:

> I remember this question from... february I think, what's changed since
> then?
>
> On Tue, Jul 14, 2015 at 3:29 PM, Robin Lery <robinl...@gmail.com> wrote:
>
>> I would like to convert video into mp4 using ffmpeg and celery for the
>> asynchronous task. When user uploads a video, it will be for the
>> original_video and save it. After that I want celery to convert it into
>> a different version for the mp4_720 field. However I am confused on how
>> to apply that logic using celery.
>>
>> app.models.py:
>>
>> class Video(models.Model):
>> title = models.CharField(max_length=75)
>> pubdate = models.DateTimeField(default=timezone.now)
>> original_video = models.FileField(upload_to=get_upload_file_name)
>> mp4_720 = models.FileField(upload_to=get_upload_file_name,
>> blank=True, null=True)
>> converted = models.BooleanField(default=False)
>>
>> app.views.py:
>>
>> def upload_video(request):
>> if request.POST:
>> form = VideoForm(request.POST, request.FILES)
>> if form.is_valid():
>> video = form.save(commit=False)
>> video.save()
>>
>> // Celery to convert the video
>> convert_video.delay(video)
>>
>> return HttpResponseRedirect('/')
>> else:
>> form = VideoForm()
>> return render(request, 'upload_video.html', {
>> 'form':form
>> })
>>
>> app.tasks.py:
>>
>> @app.task
>> def convert_video(video):
>>
>> // Convert the original video into required format and save it in
>> the mp4_720 field using the following command:
>> //subprocess.call('ffmpeg -i (path of the original_video) (video
>> for mp4_720)')
>>
>> // Change the converted boolean field to True
>>
>> // Save
>>
>> Basically my question is how to save the converted video in mp4_720. Your
>> help and guidance will be very much 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
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CA%2B4-nGrKucaFSi7oZoOcHtOXdSsnPEac2_LXLZ2TccRCaWUhzA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CA%2B4-nGrKucaFSi7oZoOcHtOXdSsnPEac2_LXLZ2TccRCaWUhzA%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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALn3ei3nZcbL5REM75Q1DVgoQud5oUMf%3Dhv3qLxuzJT1EiJ4wg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CALn3ei3nZcbL5REM75Q1DVgoQud5oUMf%3Dhv3qLxuzJT1EiJ4wg%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGonX%2BQf7KuHE495AsAmBWto0X8UpSSYy8cNWJYFEXiz6w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Celery to process task and modify the model fields

2015-07-14 Thread Robin Lery
I would like to convert video into mp4 using ffmpeg and celery for the
asynchronous task. When user uploads a video, it will be for the
original_video and save it. After that I want celery to convert it into a
different version for the mp4_720 field. However I am confused on how to
apply that logic using celery.

app.models.py:

class Video(models.Model):
title = models.CharField(max_length=75)
pubdate = models.DateTimeField(default=timezone.now)
original_video = models.FileField(upload_to=get_upload_file_name)
mp4_720 = models.FileField(upload_to=get_upload_file_name,
blank=True, null=True)
converted = models.BooleanField(default=False)

app.views.py:

def upload_video(request):
if request.POST:
form = VideoForm(request.POST, request.FILES)
if form.is_valid():
video = form.save(commit=False)
video.save()

// Celery to convert the video
convert_video.delay(video)

return HttpResponseRedirect('/')
else:
form = VideoForm()
return render(request, 'upload_video.html', {
'form':form
})

app.tasks.py:

@app.task
def convert_video(video):

// Convert the original video into required format and save it in
the mp4_720 field using the following command:
//subprocess.call('ffmpeg -i (path of the original_video) (video
for mp4_720)')

// Change the converted boolean field to True

// Save

Basically my question is how to save the converted video in mp4_720. Your
help and guidance will be very much 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 email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGrKucaFSi7oZoOcHtOXdSsnPEac2_LXLZ2TccRCaWUhzA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Add multiple objects of same model at the same time in admin

2015-06-15 Thread Robin Lery
Thank you.

On Mon, Jun 15, 2015 at 10:37 PM, carlos <crocha09...@gmail.com> wrote:

> Hello, use two model and the second model inline one model example
>
> class ModelA(...):
> name = charfield(...)
>
> class ModelB():
> fk(ModelA)
>image = imagefiel(...)
>caption = bla bla bla
>   date = datefield
>
> and them in admin.py
>
> class ModelBInline(admin.TabularInline):
> model = ModelB
> extra = 1
>
> class ModelAAdmin(admin.ModelAdmin):
> inlines = [ModelBInline]
>
> admin.site.register(ModelA, ModelAAdmin)
>
> Cheers
>
>
>
>
>
>
> On Sun, Jun 14, 2015 at 1:08 AM, Carlos Arturo Sanchez Rivera <
> ing.c...@gmail.com> wrote:
>
>> It is easier with decorators
>>
>> @admin.register(Transfer)
>> class TransferAdmin(admin.ModelAdmin):
>> pass
>>
>>
>>
>> El sábado, 13 de junio de 2015, 4:28:38 (UTC-5), Robin Lery escribió:
>>>
>>> I have a model to upload pictures:
>>>
>>> models.py:
>>>
>>>
>>>> class Snap(models.Model):
>>>> image = models.ImageField(upload_to=get_upload_file_name)
>>>> caption = models.CharField(max_length=150, blank=True, null=True)
>>>> date = models.DateField(default=date.today)
>>>>
>>>
>>> admin.py:
>>>
>>> class SnapAdmin(admin.ModelAdmin):
>>>> class Meta:
>>>> model = Snap
>>>>
>>>> admin.site.register(Snap, SnapAdmin)
>>>>
>>>
>>> In the admin it contains all the Snap's field (i.e. one field to upload
>>> an image ,its caption and the pubdate) which is as expected. How do I add
>>> multiple record of Snap's in one go, without having to save it one by
>>> one. I hope I was clear, if not please ask. Your help and guidance will be
>>> very much 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
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/5f3a3841-6605-4250-9299-ff4922c8421f%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/5f3a3841-6605-4250-9299-ff4922c8421f%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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAM-7rO3ubHWOHVJT6wMjxrPag9G1-OBXDGev9g-RG8PWakzUtQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAM-7rO3ubHWOHVJT6wMjxrPag9G1-OBXDGev9g-RG8PWakzUtQ%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGrbmmOrgCxjSUGdmwhBbbugvk%3DOYEBi-SXfswiNm5nS%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Get the first image src from a post

2015-06-15 Thread Robin Lery
I have a model to write blogs. In that I'm using a wysiwyg editor for the
Blog's descritpion, through which I can insert an image within the
description.

class Blog(models.Model):
title = models.CharField(max_length=150, blank=True)
description = models.TextField()
pubdate = models.DateTimeField(default=timezone.now)
publish = models.BooleanField(default=False)

In the admin it looks like this:

[image: enter image description here]

What I want is to get first image inside the description of the blog, and
present it in the template like this:

[image: enter image description here]

How do get the img src from the description of the blog to use it in the
template? Your help and guidance will be very much appreciated. Thank you.

views.py:

def blog(request):
blogs = Blog.objects.all()

return render(request, 'blogs.html', {
'blogs':blogs
})

template:

  {% for blog in blogs %}
  
   {{blog.pubdate}} 
   {{blog.title}} 
  


  Read more
  
  ***
  
  
  {% endfor %}

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


Add multiple objects of same model at the same time in admin

2015-06-13 Thread Robin Lery
I have a model to upload pictures:

models.py:


> class Snap(models.Model):
> image = models.ImageField(upload_to=get_upload_file_name)
> caption = models.CharField(max_length=150, blank=True, null=True)
> date = models.DateField(default=date.today)
>

admin.py:

class SnapAdmin(admin.ModelAdmin):
> class Meta:
> model = Snap
>
> admin.site.register(Snap, SnapAdmin)
>

In the admin it contains all the Snap's field (i.e. one field to upload an
image ,its caption and the pubdate) which is as expected. How do I add
multiple record of Snap's in one go, without having to save it one by one.
I hope I was clear, if not please ask. Your help and guidance will be very
much 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 email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGqOazpPRAhafULpN4HW1ohPAoHUoxne6vyK02s53O21PQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Transcode video using celery and ffmpeg in django

2015-02-20 Thread Robin Lery
So mp4_480 and mp4_720 should be blank=True and null=True. And then pass
the video instance object to the delay() ???

And also, could you please show me how to write the tasks.py, so that I can
use ffmpeg code (subprocess.call('ffmpeg -i path/.../original
path/.../mp4_720') to transcode.

Thank you.

On Fri, Feb 20, 2015 at 6:49 PM, Vijay Khemlani <vkhem...@gmail.com> wrote:

> Then in your task function you can get the file from the video model
> instance, trascode it, and store it in the corresponding fields of the
> object (mp4_480, mp4_720)
>
> On Fri, Feb 20, 2015 at 10:18 AM, Vijay Khemlani <vkhem...@gmail.com>
> wrote:
>
>> I would do something like this
>>
>> video = Video()
>> video.original = form.cleaned_data['video']  # Assuming the form field is
>> "video"
>> video.user = user
>> video.title = form.cleaned_data['title']  # Assuming the form field is
>> "title"
>> video.save()  # You might need to make the mp4_480 and
>> mp4_720 fields "nullable" on the model
>> yourapp.tasks.transcode_video.delay(video)   # Assuming the task is the
>> "transcode_video" function.
>>
>> return HttpResponseRedirect('/')
>>
>> Then
>>
>>
>> On Fri, Feb 20, 2015 at 10:04 AM, Robin Lery <robinl...@gmail.com> wrote:
>>
>>> I would like to transcode user uploaded videos using celery. I think
>>> first I should upload the video, and spawn a celery task for transcoding.
>>>
>>> Maybe something like this in the tasks.py:
>>>
>>> subprocess.call('ffmpeg -i path/.../original path/.../output')
>>>>
>>>
>>> Just completed First steps with celery
>>> <http://docs.celeryproject.org/en/latest/getting-started/first-steps-with-celery.html#first-steps>,
>>> so confused how to do so in the `views.py` and `tasks.py`. Also is it a
>>> good solution? I would really appreciate your help and advice. Thank you.
>>>
>>> models.py:
>>>
>>> class Video(models.Model):
>>>> user = models.ForeignKey(User)
>>>> title = models.CharField(max_length=100)
>>>> original = models.FileField(upload_to=get_upload_file_name)
>>>> mp4_480 = models.FileField(upload_to=get_upload_file_name)
>>>> mp4_720 = models.FileField(upload_to=get_upload_file_name)
>>>> privacy = models.CharField(max_length=1,choices=PRIVACY,
>>>> default='F')
>>>> pub_date = models.DateTimeField(auto_now_add=True,
>>>> auto_now=False)
>>>>
>>>
>>> my incomplete views.py:
>>>
>>>
>>> @login_required
>>>> def upload_video(request):
>>>> if request.method == 'POST':
>>>> form = VideoForm(request.POST, request.FILES)
>>>> if form.is_valid():
>>>> if form.cleaned_data:
>>>> user = request.user
>>>> #
>>>> #
>>>> # No IDEA WHAT TO DO NEXT
>>>> #
>>>> #
>>>> return HttpResponseRedirect('/')
>>>>
>>>> else:
>>>> form = VideoForm()
>>>> return render(request, 'upload_video.html', {
>>>> 'form':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+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CA%2B4-nGoz%3D_qCx%2BbSnOfNFLYiufqUUES3S3T9y4GXoZiaBV9tyw%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CA%2B4-nGoz%3D_qCx%2BbSnOfNFLYiufqUUES3S3T9y4GXoZiaBV9tyw%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 fro

Transcode video using celery and ffmpeg in django

2015-02-20 Thread Robin Lery
I would like to transcode user uploaded videos using celery. I think first
I should upload the video, and spawn a celery task for transcoding.

Maybe something like this in the tasks.py:

subprocess.call('ffmpeg -i path/.../original path/.../output')
>

Just completed First steps with celery
,
so confused how to do so in the `views.py` and `tasks.py`. Also is it a
good solution? I would really appreciate your help and advice. Thank you.

models.py:

class Video(models.Model):
> user = models.ForeignKey(User)
> title = models.CharField(max_length=100)
> original = models.FileField(upload_to=get_upload_file_name)
> mp4_480 = models.FileField(upload_to=get_upload_file_name)
> mp4_720 = models.FileField(upload_to=get_upload_file_name)
> privacy = models.CharField(max_length=1,choices=PRIVACY,
> default='F')
> pub_date = models.DateTimeField(auto_now_add=True, auto_now=False)
>

my incomplete views.py:


@login_required
> def upload_video(request):
> if request.method == 'POST':
> form = VideoForm(request.POST, request.FILES)
> if form.is_valid():
> if form.cleaned_data:
> user = request.user
> #
> #
> # No IDEA WHAT TO DO NEXT
> #
> #
> return HttpResponseRedirect('/')
>
> else:
> form = VideoForm()
> return render(request, 'upload_video.html', {
> 'form':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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGoz%3D_qCx%2BbSnOfNFLYiufqUUES3S3T9y4GXoZiaBV9tyw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Return to the requested page after successfull @login_required by the next variable

2015-01-08 Thread Robin Lery
Suppose this is the url after
`@login_required(login_url='/accounts/required_login/')`:

http://ngoksy.com/accounts/login_required/?next=/article/

view for the login_require:


*def required_login(request):return render(request,
'required_login.html')*

I tried adding 'next', like it [here][1]:



*def required_login(request):c = {'next' :
request.GET.get('next', '/')}return render(request,
'login_required.html', c)*

But it didn't help.

I have different template for login and another template for anonymous user
which is redirected by `@login_required`.

required_login.html:
















*   Login required! You must login to view the content.{%
if form.error %}Sorry, invalid
username/password!{% endif %}{%csrf_token%}
Username:Password:*

I want to pass the `next` variable after successful login of
`login_required()`, and land into Articles page after that. How do I do
that? Please help me understand. Your help will be greatly 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 email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGqds1Ex9Rrw9temyN2D7utJ0FkF7b_sTcOyO7strxt2nw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Guidance needed - Real time and django

2014-09-02 Thread Robin Lery
Thank you Amirouche! I will surely look onto that. And I saw many tutorials
on django + node.js and socket.io, and was just curious as to what your
thoughts are on this as the new version of socket.io has also been released?


On Mon, Sep 1, 2014 at 3:09 AM, Amirouche Boubekki <
amirouche.boube...@gmail.com> wrote:

> Hello,
>
>
> 2014-08-29 17:26 GMT+02:00 Aamu Padi :
>
>  Hello,
>> I would like to build a real time web application, but have little idea
>> of where to start to from. It will have notification and feed system like
>> facebook or instagram. Would really appreciate if anyone who have already
>> done this type of web application could kindly guide me through. I will be
>> very grateful.
>>
>
> I never done such things besides small experiments and research...
>
> Here are some pointers:
>
> - search://django+gevent
> - search://django+asyncio among other things django-c10k-demo
>  created by Aymeric
> Augustin django core contributor which use websockets
> - search://tornado
> - search://django+SSE
> - search://django+webRTC
> - search://django+pjax
>
> HTH,
>
> Amirouche
>
>>
>> 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 http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAHSNPWuiOJ5m%3DcCUFOc-j%3DRR3LHSAOyhd4Uk7HOaR78cQB-V4A%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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAL7_Mo9Tfqi_BsM2KCLX7aVNZFZcC0vMO6eu1tMtrY-H6L8GKg%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGpvDaKasrw_f-Bj6-B7UW6WRtDd17b%2BMk9BJ-WbKtwDJg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Feeling some serious timezone pain

2014-08-20 Thread Robin

Guys
The UK is currently on British Summer Time (BST) so

2014-08-30 16:00:00 BST
2014-08-30 11:00:00 Toronto (Summer)

Greenwich Mean Time (GMT) as a term is not used as frequently as 
previously. The preferred term is Universal Coordinated Time (UTC), as 
some overseas users confusingly equate GMT with the current time in 
Britain, after any adjustment for summer time.



Robin St.Clair
On 20/08/2014 13:32, Geoffrey S. Knauth wrote:

|2014-08-30 16:00:00+00:00 GMT|
|2014-08-30 12:00:00-04:00Toronto (Summer)|
||
||This looks correct to me.  Maybe you were expecting the timezone to 
be -05:00?  That would be standard time (winter).  Daylight savings 
time is -04:00.

--
Geoffrey S. Knauth | http://knauth.org/gsk
On Wed, Aug 20, 2014, at 08:22, christophw wrote:

Hi there,
I'm feeling some pain while wrangling with timezones in an office 
room booking application.  I'm storing bookings in a MySQL database 
and want to display them in the timezone local to the office room, so 
it is not necessarily local to the user's local machine timezone.

Here is my model's datetime definition:
|
classBooking(models.Model):
 date_time =models.DateTimeField()
|
When the booking is stored, it comes back from a post and I store it 
in the DB as such:

|
dt =datetime.datetime.strptime(request.POST["date"]+" 
"+request.POST["time"],"%Y-%m-%d %H:%M")

dt =pytz.timezone("America/Toronto").localize(dt)
|
Printing the value of dt after that call, it looks correct.
Later on, I pull that booking out of my database by ID and render it 
in my template, rendering the datetime like this:

|
{{booking.date_time}}
|
I've tried re-interpreting the timezone after pulling it out of the 
database, to no avail. When I print the datetime object directly 
after it is pulled out of MySQL, I get it in UTC like so:

|
2014-08-3016:00:00+00:00
|
Re-interpreting it to force it into the office's local timezone, I 
get the correct result but 1 hour off is still rendered in the web 
browser

|
# returns 2014-08-30 12:00:00-04:00
booking.date_time 
=pytz.timezone("America/Toronto").normalize(booking.date_time)

|
The result of this is the time is rendered /1 hour behind/ the actual 
time.  This is consistent across all datetimes I've tried, and I seem 
to be unable to get Django to render the correct time.
My question is this: Why is my datetime consistently rendering 1 hour 
off, and how do I wrangle it into rendering at the true time?



--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, 
send an email to django-users+unsubscr...@googlegroups.com 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto:django-users@googlegroups.com>.

Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2dbd562a-5db3-4787-80d2-5a0f93f07860%40googlegroups.com 
<https://groups.google.com/d/msgid/django-users/2dbd562a-5db3-4787-80d2-5a0f93f07860%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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto:django-users@googlegroups.com>.

Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1408537967.3259961.154775081.30E70C64%40webmail.messagingengine.com 
<https://groups.google.com/d/msgid/django-users/1408537967.3259961.154775081.30E70C64%40webmail.messagingengine.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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/BLU436-SMTP1622B2A3A78EBAA5CF38D34E2D20%40phx.gbl.
For more options, visit https://groups.google.com/d/optout.


Re: dba designer consulting needed

2014-08-15 Thread Robin

Mike

I hope you find a local person who can do the job. If you need to get in 
touch, please do.

Kind Regards

Robin St.Clair
PS I wouldn't mind an excuse to be in Melbourne first week in November
On 15/08/2014 14:37, Mike Dewhirst wrote:

Robin

Thanks for responding ... I have a couple of local people to see and I 
expect to engage one of them. If that doesn't work out may I get back 
in touch with you?


Thanks

Mike

On 15/08/2014 3:21 PM, Robin wrote:

Mike

Firstly, I must say how nice it is to see somebody being concerned to
get the data model correct, it happens less and less frequently, these
days.

Whilst it is important to have a DBA onboard, I must point out that i
have met few DBAs who have the necessary  abstraction skills do do the
design job single handed. Somebody who is used to switching between
logical and physical design, with a view to creating the most efficient
and cost effective design rarely spends much time working as a DBA.

If you were to consider a consultant from outside Melbourne, I would be
interested in offering my services. I have extensive experience in
various industries including Healthcare, Telecoms, Banking, Primary
Industries and Transportation. Several of the projects I have undertaken
involved database tuning and optimisation. One that springs to mind
involved a process that provisioned only 7 customers' mobile phones a
second when the work orders were arriving at the rate of 76 per second.
Fortunately, six weeks later we had eliminated the backlog and the
system could comfortably handle all foreseeable demand, which was
considerable.

I have attached my CV, in case you are interested.

Presently I am based in Britain. Communications should not be a problem,
I have a fibre broadband connection as I work from home on the South
Coast, about an hour from Heathrow. Skype works pretty well for me and I
have VoIP available,  so phoning and video conferencing should work from
my end.

i would be most interested to learn further about your project.

Kind Regards

Robin St.Clair

On 15/08/2014 05:19, Mike Dewhirst wrote:

I'm looking for a DBA designer in Melbourne for some paid consulting.

I have a Django 1.6 prototype system working nicely with Postgres 9.1.

But it was designed as a proof-of-concept rather than a production
system. I figured the project wouldn't actually get off the ground
without funding and then I'd be able to hire someone to get serious
about design perfection. In particular, distributed database versus
monolithic and optional integration of external systems by some users
plus parts which are shared among all users.

Well, it didn't work out the way I planned. Funding is still a way off
and now I have people who want to use the prototype.

The consulting task is to determine if the design can be tweaked so it
can be put into production. And if so, to so tweak it.

If I can't find someone in Melbourne I'll consider a remote consultant
but I think the conversation bandwidth required would make remote less
than ideal.

Thanks for any sympathy

Cheers

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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/BLU436-SMTP14088D9DC32611EF68A40E2E2E90%40phx.gbl.
For more options, visit https://groups.google.com/d/optout.


Django and Long Polling

2014-03-22 Thread Robin Lery
Hello,
I need to implement long polling in my application to retrieve the events.
But I have no idea how to do it. I know the concept of long polling, i.e to
leave the connection open, until an event occurs. But how do I do implement
this in my project. If you could give me a simple long polling example of
client side and the views i guess, I would really appreciate.

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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGpvKHcMg-mMRbf7%2BVceCAkRwipt_8NvojEw43ALhC2YBw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Custom Login page in Django

2014-03-20 Thread Robin Lery
do you have {% csrf_token % } in your forms?


On Thu, Mar 20, 2014 at 7:36 PM, Aryak Sengupta wrote:

> I am new to Django (but not new to python) and I am looking forward to
> create a customized  page using django.  I have read about django's inbuilt
> authentication system but I want build it from scratch So here are the few
> ideas I am stumbling upon :
>
>
>1. Creating a *users* class in the models.py with username and
>password as the fields (both are CharField)
>
>2. Creating  two views one named *LoginView*, which will depict the
>initial login page (such as a *form* imported from a *module named
> forms.py*) and another view named *LoggedInView* which will show only
>the username of the logged user
>
>3. Mapping them into corresponding URLs
>
> I tried creating it with above mentioned thoughts but I got stuck with an
> error as follows:
>
> Forbidden (403)
>
> CSRF verification failed. Request aborted.
> Help
>
> Reason given for failure:
>
> CSRF cookie not set.
>
>
> I couldn't figure out why possibly I am getting this error for
> incorporating such a simple(and basic) functionality.
>
> *I want to understand the best way/approach to go about this (for
> implementing this functionality). I am not worrying about the error for the
> time being since I didn't spend much time thinking about it (So I am not
> posting any code). I want to get my approach right first. I want to be
> flawless while implementing such basic and elementary stuffs.  *
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4f18d65c-8e85-434f-b584-0ab7017f6cf9%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGq8taHb%2B9%2Bz3%3DxJq-Qitnuf0%3D127O9esk8LZygSQLeSZA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


problem in setting up gunicorn and django

2014-03-17 Thread Robin Lery
I am trying to set up gunicorn for Django by following this
blog.
I created the *gunicorn_start* script and gave it permission:

*$ sudo chown -R hello:users /webapps/hello_django*
*$ sudo chmod -R g+w /webapps/hello_django*

Made it executable:

*$ sudo chmod u+x bin/gunicorn_start*

But when I run this comman:

*advenio@advenio-VirtualBox:~$ sudo su - hello*
*$ bin/gunicorn_start*

It gives me an error:

*advenio@advenio-VirtualBox:~$ sudo su - hello*
*$ bin/gunicorn_start*
*Starting hello_app as hello*
*bin/gunicorn_start: line 26:
/webapps/hello_django/hello/../bin/gunicorn: No such file or directory*

This the `gunicorn_start` script:

#!/bin/bash

*NAME="hello_app" * # Name of the
application
*DJANGODIR=/webapps/hello_django/hello* # Django project
directory
*SOCKFILE=/webapps/hello_django/run/gunicorn.sock * # we will communicte
using this unix socket
*USER=hello*# the user to run as
*GROUP=webapps *# the group to run as
*NUM_WORKERS=3 *# how many worker
processes should Gunicorn spawn
*DJANGO_SETTINGS_MODULE=hello.settings *# which settings file
should Django use
*DJANGO_WSGI_MODULE=hello.wsgi *# WSGI module name

*echo "Starting $NAME as `whoami`"*

# Activate the virtual environment
*cd $DJANGODIR*
* source ../bin/activate*
* export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE*
* export PYTHONPATH=$DJANGODIR:$PYTHONPATH*

# Create the run directory if it doesn't exist
*RUNDIR=$(dirname $SOCKFILE)*
* test -d $RUNDIR || mkdir -p $RUNDIR*

# Start your Django Unicorn
# Programs meant to be run under supervisor should not daemonize themselves
(do not use --daemon)
*exec ../bin/gunicorn ${DJANGO_WSGI_MODULE}:application \*
*  --name $NAME \*
*  --workers $NUM_WORKERS \*
*  --user=$USER --group=$GROUP \*
*  --log-level=debug \*
*  --bind=unix:$SOCKFILE*

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


Different content type objects in django template

2014-03-06 Thread Robin Lery
I am having a hard time to understand ContentType. I am learning from a
tutorial, this is the link . I have synced the database, and its working in
the admin. But when I try to load the ContentType objects in the template,
I get nothing. When I see the page source, the get_rendered_method is not
loading the rendered template in the homepage.html.

*These are my models:*


class Photo(models.Model):

user = models.ForeignKey(User)

description = models.TextField()

image = models.ImageField(upload_to=get_upload_file_name)

photo_upload = models.DateTimeField(auto_now=True, auto_now_add=False)

is_public = models.BooleanField(default=True)


class Meta:

verbose_name = 'Photo'

verbose_name_plural = 'Photos'

ordering = ['-photo_upload']


class Status(models.Model):

user = models.ForeignKey(User)

state = models.CharField(max_length=200)

status_upload = models.DateTimeField(auto_now=True, auto_now_add=False)

is_public = models.BooleanField(default=True)


class StreamItem(models.Model):

content_type = models.ForeignKey(ContentType)

object_id = models.PositiveIntegerField()

pub_date = models.DateTimeField()

content_object = generic.GenericForeignKey('content_type','object_id')


# The get_rendered_html method simply passes the retrieved object to a
template with that object's name

def get_rendered_html(self):

template_name = 'stream_item_%s.html' % (self.content_type.name)

return render(request, template_name,
{'object':self.content_object})


*These are the template for content_type.name :*

*stream_item_Photo.html:*






{{ object.pub_date|date:"F jS Y, P" }}

{{ object.user }}




*stream_item_Status.html:*




{{ object.state }}

{{ object.time|date:"F jS Y, P" }}

User: {{ object.user }}




Where am I doing the mistake? How do I load different content_type objects
in the template? I would really appreciate if you could help me solve this.
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGpg3-btzb5r9en9MVipb9zY_O2_B989%3DxE0sm3VgT8Lyg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: "Authenticating Users" where should I put the code?

2014-03-06 Thread Robin Lery
This should be in your views.py.


On Thu, Mar 6, 2014 at 8:15 PM, Jack Yan  wrote:

> in the tutorial and section "Authenticating Users":
> https://docs.djangoproject.com/en/1.6/topics/auth/default/
>
> where can I put code:
>
> from django.contrib.auth import authenticateuser = 
> authenticate(username='john', password='secret')if user is not None:
> # the password verified for the user
> if user.is_active:
> print("User is valid, active and authenticated")
> else:
> print("The password is valid, but the account has been 
> disabled!")else:
> # the authentication system was unable to verify the username and password
> print("The username and password were incorrect.")
>
> in what file or what folder?
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/0654812d-74d5-48a1-a977-26958f417a61%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

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


  1   2   3   >