Re: Student Club Management Web App: Seeking Collaboration and Advice from Experts

2024-03-12 Thread Alex Goyzueta
Interesado


El lun., 11 mar. 2024 14:44, Bayodele Oguntomiloye <
oguntomiloyebayod...@gmail.com> escribió:

> I'm interested. Add me with this WhatsApp number 09129350024
>
> On Sun, Mar 10, 2024 at 11:16 PM Galuh Akbar Putra 
> wrote:
>
>> Contact me
>> 0881025905276
>>
>> Pada Sab, 2 Mar 2024 22.58, SOLTAN NOURELDIEN 
>> menulis:
>>
>>>
>>> Hello, I am currently working on my Django Project for a specific course
>>> at my university. I have already finished reading "Django for Beginners" by
>>> William S. Vincent. Now, I am eager to start this project, but I am still
>>> in the learning and research phase. Therefore, I will provide the
>>> requirements for the project and would appreciate feedback or any tips from
>>> anyone with experience in such projects.
>>>
>>> For example, this will be my first time implementing a multi-user
>>> system. After doing extensive research, I learned about Django's model
>>> group concept managing this approach. Additionally, I discovered Django
>>> Channels and signals, which I have never heard of before. I would
>>> appreciate any advice or guidance on how to approach such a project.
>>>
>>> Furthermore, if anyone is interested in joining me on this journey, it
>>> would be wonderful. We can learn a lot from this project together. The
>>> deadline is less than two months, so please provide your Discord or
>>> WhatsApp number, and we can create a group to collaborate on this project.
>>>
>>> *The requirements for the project are as follows:*
>>>
>>> An app for student clubs:
>>> *SKS Admin:*
>>>
>>>-
>>>   - Create Club Page
>>>   - Delete Club Page
>>>   - Assign Club Manager
>>>   - Activity Form (Approve, Reject)
>>>   - Receive notifications (Whenever a change occurs in the club
>>>   page) (Approve Change, Reject Change)
>>>   - Request for Publishing Activity Post (Approve, Reject)
>>>   - Search Club Page
>>>   - Announce All Activities (Will be displayed on the main page)
>>>
>>> *Club Manager:*
>>>
>>>-
>>>   - Fill out the activity form
>>>   - Request for publishing Activity Post (Sending it to admin, and
>>>   after approval, the activity will appear on the club main page)
>>>   - Receive Notification (The response to the Activity Form &
>>>   Activity Post publishing request)
>>>   - Edit Activity Post (Admin manager will receive a notification)
>>>
>>> *Student:*
>>>
>>>-
>>>   - Display weekly Activity Table
>>>   - Display Clubs Main Page
>>>   - Search (by category, by date)
>>>
>>> I will only focus on the backend development and integrate it into the
>>> template. I have other team members who will provide the Static HTML, CSS &
>>> JS files. I will incorporate them into the Django templates and work on
>>> making them interactive.
>>>
>>> Additionally, if time allows, I can implement additional features such
>>> as:
>>>
>>>- Manager:
>>>   - Submit an application to SKS to assign a club
>>>   - Initiate a chat conversation between the manager and the SKS
>>>- Student:
>>>   - Become a member of a club
>>>   - Follow Clubs
>>>   - Follow the club pages
>>>   - Like and comment on a post
>>>
>>> If you have any ideas or know of existing projects that could serve as
>>> inspiration, please feel free to comment. I would greatly appreciate it.
>>>
>>> Also, if you would like to collaborate with me for learning purposes and
>>> to work as a team, please don't hesitate to provide your contact
>>> information, and I will reach out to you. Thank you very 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/19da6a17-4c28-41d5-acb1-171fb052c9a1n%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/CADdZx%3DRPso%3Dv5eB9m0SvxCRCsd5hBvuAZu4ibXkMac6GFUWbGw%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
> 

Finding the last modified timestamp for a group of Models

2024-02-27 Thread Alex Guetsche
I have an application which contains more than one Model, all descended 
from an abstract one. All the operational Models have created and modified 
fields 
with datetime timestamps. [How] can I get the Django ORM to bring me the 
last modified timestamp that will be the maximum of all createds and 
modifieds of all Models? Right now I have to use itertools for a quite 
convoluted expression over query sets of all the models involved.

It seems quite an obvious use case, and it can be implemented in pure SQL 
quite easily.

-- 
You received this message because you are subscribed to the Google Groups 
"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/bff16a54-c807-4e21-977b-f10af338200bn%40googlegroups.com.


Re: How to create an individual instagram message into threads?

2023-11-17 Thread Alex Shibly


While I don't have specific knowledge about implementations in Instagram 
clones in Django applications, I can provide you with guidance on how you 
might approach implementing the features you described. Implementing a 
messaging system with thread-like conversations can be achieved by creating 
models and views in Django.

Here's a general outline of how you might structure your models:

   1. 
   
   MarketplaceItem Model:
   - Fields: Title, Description, Seller, Buyer, etc.
   2. 
   
   Message Model:
   - Fields: Sender, Receiver, Content, Timestamp, MarketplaceItem (foreign 
  key), etc.
   
With these models, you can link messages to specific marketplace items, 
allowing you to organize conversations by item. Each message will have a 
foreign key reference to the corresponding marketplace item.

Next, you can create views and templates to display the messages. For 
example, when a user clicks on a marketplace item, you could retrieve all 
the messages related to that item and display them in a threaded view.

Here's a simplified example:

# models.py
from django.db import models
from django.contrib.auth.models import User

class MarketplaceItem(models.Model):
title = models.CharField(max_length=255)
description = models.TextField()
seller = models.ForeignKey(User, related_name='selling_items', 
on_delete=models.CASCADE)
buyer = models.ForeignKey(User, related_name='buying_items', 
on_delete=models.CASCADE, blank=True, null=True)

class Message(models.Model):
sender = models.ForeignKey(User, related_name='sent_messages', 
on_delete=models.CASCADE)
receiver = models.ForeignKey(User, related_name='received_messages', 
on_delete=models.CASCADE)
content = models.TextField()
timestamp = models.DateTimeField(auto_now_add=True)
item = models.ForeignKey(MarketplaceItem, related_name='item_messages', 
on_delete=models.CASCADE)

You would then create views and templates to handle the display of 
messages. When a user clicks on a marketplace item, you retrieve the 
messages related to that item and display them in a threaded view.

For example, in your view:

# views.py
from django.shortcuts import render, get_object_or_404
from .models import MarketplaceItem

def item_messages(request, item_id):
item = get_object_or_404(MarketplaceItem, pk=item_id)
messages = item.item_messages.all()
return render(request, 'item_messages.html', {'item': item, 'messages': 
messages})
And in your template (item_messages.html), you can iterate through the 
messages and display them: {% for message in messages %}
{{ message.sender.username }}: {{ message.content }}
{% endfor %}
This is a basic example, and you may need to add more features and error 
handling depending on your specific requirements. Additionally, consider 
adding security measures, such as checking user permissions, to ensure that 
users can only access messages related to items they are involved with. By 
https://786news.com/ 
On Monday, August 28, 2023 at 7:56:27 PM UTC+5 Steven Mapes wrote:

> I've not used that app but creating email of messaging chains is quite 
> easy. How I normally do it is to generate a unique identifier by using a 
> uuid4 plus some custom values when a new thread/conversation is created and 
> then this is passed and maintained during replies.  There's probably 
> something similar in that app. Emails tend to call it a Conversation ID
>
> On Sunday, 27 August 2023 at 22:19:46 UTC+1 Ram wrote:
>
>> Hi,
>>
>> We are using Instagram clone messaging in our ecommerce application where 
>> users contact each other about market place item (sell/buy items). Once the 
>> messaging started between two users on an item
>> 1. we want to keep the further messaging regarding that item to be 
>> continued like an email thread so that all the messaging about that item 
>> will be in one thread.
>> 2. New messaging on new market place item will be again new thread.
>> 3. It would be nice each thread has a title of the market place item so 
>> that same users can go back to previous history of messages on that 
>> particular item whenever they want.
>>
>> I'm wondering whether anyone has implemented the above features using 
>> instagram clone in your Django application?
>>
>> Best regards,
>> ~Ram
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/ebeda2fc-395b-45ca-9045-7d8b0d010e1fn%40googlegroups.com.


Django Channels with Queue (Lobby) Manager

2023-07-11 Thread Alex R
Hello dear Community!

I need help with Django channels and Websockets (i guess) for an 
application I am building. The project is online Chess game with Django as 
a backend and vanilla JavaScript (ajax, jQuey and some bootstrap). We are 
using custom chess engine written in python.  

Previously we succesfully built flask application with single view to play 
chess game hand-to-hand. I wanted to improve our backend and introduce game 
lobbies - general online. This would also be a great practice and learning. 
Or so I thought.
I have gone through the Django Channels docs and followed simple tutorial 
to create a chat application - more or less the concept is understood. 

My goal is to create a lobby like system as in other online games:

   - User has to be autorized and only authorized users can do anything
   - You can click on "New game" - it will put you in waiting or lobby 
   room. If you match with another user who has right conditions (for now: 
   oppotise pieces color) - you two are put in a game and game starts
   - If there are no games available after some timeout - it will through 
   you out to main screen and ask to "Try later"

I have some ideas and questions, but I would like to hear how this idea can 
be coded and what would be the right plan for realisation first. Maybe my 
questions and ideas are completely irrelevant.

P.S.: We are using custom written chess engine in Python via OOP. It worked 
very poorly in Flask by just creating Game object from a class in View 
function. This you should not do... What would be the best practice to 
actually access it and when we should create it? I have seen examples with 
TicTacToe game and logic stored as a model, but i think it would be very 
heavy on database

Looking forward for replies :) 

-- 
You received this message because you are subscribed to the Google Groups 
"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/ca46cb38-d3a7-4d24-b5f2-b7fda612f445n%40googlegroups.com.


Re: TypeError at /register User() got unexpected keyword arguments: 'name1', 'name2', 'country'

2023-03-30 Thread Alex Sonar
Hi Ebenezer, Could I ask you to show the content of the model file, please?

On Thursday, March 30, 2023 at 5:21:06 AM UTC+3 Ebenezer Otchere wrote:

> I am trying to collect user information and save in my database but i keep 
> getting this error
> and i dont know the way around it so help me the codes and the error page 
> are below
> [image: Screenshot (3).png][image: Screenshot (4).png][image: Screenshot 
> (5).png] 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/65480c4f-7d81-49ea-a735-4576a8315080n%40googlegroups.com.


The problem of versioning a large project.

2023-03-29 Thread Alex Sonar


The problem of versioning a large project.

Hi guys, I really got stuck with the challenge, with the design of 
versioning for a large project.

Now we have organized versioning, where our project is divided into 
separate GIT repositories which are created for each application.

The new necessity point is to split some of them for front-end and back-and 
developers.

The task looks like bad practice, where we have to create a repository 
within another one.

Or redesign the file structures of the application itself, to meet this 
requirement.

If someone has a similar challenge or practice and helps me make the right 
decision, I will be very grateful.

-- 
You received this message because you are subscribed to the Google Groups 
"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/43b193b9-00f2-4fe5-963c-5770a41e7964n%40googlegroups.com.


Re: Dear participants of Django Users Group, could you take part in our survey, please?

2023-01-24 Thread Alex Sonar
Hey folks
When rushing with adding new features it is easy to forget something or 
loose the big picture.
Why not just ask what are the common issues that Django developers have 
faced?
Like most of the solutions we are searching for. Like: tons of filtering 
issues, queries and sub-queries, advanced search models, ORM-auto-generated 
staff related...ext
Ask about CBVs issues also
On Monday, January 23, 2023 at 3:52:09 PM UTC+3 oranged...@gmail.com wrote:

>
> We on the way to create new tools for Python developers, and to confirm 
> the functionality we develop, we created this survey. Django framework 
> survey 
> Helpfully your participation that we make useful things for the entire 
> Python community.
> This survey is addressed primarily to software development, business 
> owners, project managers, DevOps, stakeholders, a party that has an 
> interest in a company and can either affect or be affected by the 
> business. and owners of multiple disparate projects, using the Django 
> framework.
> Independent and team developers whose projects are implemented in Django.
>
> There are no product ads here and the purpose of this survey is only to 
> determine the relevance of the problems that developers most often face.
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/56af18b9-41e7-4908-90cc-1d0887974778n%40googlegroups.com.


Re: How to access the value of a field that failed validation

2023-01-02 Thread Alex Sonar
Hi Noel! 
Have you looked at the problem in context CSRF Protection?
Please check it out 

   - How to use Django’s CSRF protection   
   https://docs.djangoproject.com/en/4.1/howto/csrf/

It might be as a solution...
On Monday, January 2, 2023 at 3:27:01 AM UTC+3 Noel Duffy wrote:

> I'm new to Django, though not to programming. I'm using Django 4.1.4 on 
> AlmaLinux 9.
>
> My question is this. Is it possible to access a ModelForm field's value 
> if that form field failed validation?
>
> I'm writing a small ticketing system for a helpdesk to handle spam 
> reports. Users submit spam messages which the system will then process. 
> I'm using a ModelForm, and the database schema specifies that the spam 
> message is unique. That is, each spam message can be reported only once, 
> so there's just one ticket but possibly many different actions taken 
> depending on what's in the spam.
>
> This is the model:
>
> class AbuseReport(models.Model):
> report_date = models.DateTimeField(auto_now_add=True)
> report_subject = models.CharField(max_length=255)
> report_msgid = models.CharField(max_length=255, unique = True)
> report_spam_text = models.TextField(unique = True)
> def __str__(self):
> return report_subject
>
> class Meta:
> ordering = ['-report_date']
>
> Now, the problem is that a spam message will fail form validation in the 
> form.is_valid call if the spam message fails the "unique" constraint. 
> Why is this a problem? Because I want to get my hands on the spam 
> message if it's already in the DB so that instead of just re-showing my 
> form with an error message saying the spam already exists, I want to 
> redirect to the existing ticket. But so far I've not been able to figure 
> out how to do this, and when I dump the contents of the form in 
> debugging, the spam message just isn't there.
>
> I should add that the ModelForm only creates a field for the 
> report_spam_text field. I.e,
>
> class AbuseReportForm(ModelForm):
> def __init__(self, *args, **kwargs):
> super(ModelForm, self).__init__(*args, **kwargs)
>
> def clean(self):
> [...]
>
> class Meta:
> model = AbuseReport
> fields = ['report_spam_text']
> widgets = {'report_spam_text':
> Textarea(attrs={
> 'rows': 20,
> 'class':'textarea',
> 'placeholder':'Paste spam with full headers here..'
> }),}
>
>
> This is what my view looks like (stripped down for simplicity):
>
> def spamsubmit(request):
> # if this is a POST request we need to process the form data
> if request.method == 'POST':
> # create a form instance and populate it with data from the 
> request:
> form = AbuseReportForm(request.POST)
> # check whether it's valid:
> if form.is_valid():
> # process the data in form.cleaned_data as required
> [.]
> else:
> ## show the form again with errors displayed
> ## if spam already exists this is what gets run.
> return render(request, 'abuse/spam_form.html',{'form':form})
>
> As I understand it, fields aren't bound to data until is_valid is 
> called, and if is_valid fails then only fields that didn't fail validity 
> go into cleaned_data. But it seems everything else is lost. But I'm not 
> 100% sure about this and this is why I'm asking.
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/2bf8db16-56f7-44f4-bfda-fa9aea477a41n%40googlegroups.com.


Re:

2022-09-27 Thread Alex Murithi
My no is +254713315968

On Tue, Sep 27, 2022, 12:08 Abdul Madebari 
wrote:

> I am available too +255622166483
>
> On Tue, 27 Sep 2022, 11:46 Shittu Abdulrasheed, <
> rasheedshittushi...@gmail.com> wrote:
>
>> i am available too +2347049978495
>>
>> On Tue, Sep 27, 2022 at 3:21 AM André Lewis 
>> wrote:
>>
>>> Hi! could you add me as well,
>>> +18762382482
>>>
>>> On Mon, 26 Sept 2022 at 20:45, Adolfo Duque León Fresneda
>>> (MisterRevenue)  wrote:
>>>
 hello if you can send me the link or add me +529381108109.. greeting
 from Mexico

 El lunes, 26 de septiembre de 2022 a las 7:54:05 UTC-5,
 farid...@gmail.com escribió:

> Hello fellow developers, I will be creating a WhatsApp group chat
> later in the day, So I will like my fellow Python Django Developers to 
> join
> the group. It will be much easier to discuss there and I will sacrifice
> myself out for anyone who need my service.
>
> God bless you all
> Enjoy your day
> Biliaminu
>
 --
 You received this message because you are subscribed to the Google
 Groups "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/1e19374b-65cb-4fd0-8533-7cc5751fc1f2n%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/CAJN6x_jJ8w_QBGWOEaXjgO9fChofhZ28fBZ5t9b%2BWyGipSvmsw%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/CAM%3D4UykrfgBmYFUywLA%3Dntt46k_9yaY9%2B_rr095KXs%2BGdRmT1A%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/CANPdr5Ht2eg-cE8zA6TnxzKvPFk0OpP2KQt-dnBwmRWonZ1TCg%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/CANj%3DtAk1EB1XUsT_JCf5P087U%3DpSNf17zOJ-yAnE4arMW5oa-w%40mail.gmail.com.


Class based views with forms

2022-04-26 Thread alex smolyakov
Can anyone explain me how to make send email form on page.

So my forms.py
class ContactForm(forms.Form): 
name = forms.CharField(required=True)
last_name = forms.CharField()
adults = forms.IntegerField() children = forms.IntegerField() 
email = forms.EmailField(required=True)
message = forms.CharField(widget=forms.Textarea) 

views.py
class TourDetailView(DetailView):
model = models.Tour 
template_name = 'tours/tour-detail.html' 
form_class = forms.ContactForm
success_url = 'tours.html' 

As far as i understand i need to get data from request , but i dont know 
how to do it. There are a lot of information in function based views, but i 
didnt get how to do it in class based views.

And it would be nice of you to explain where should i put send_mail 
function. Any help will be appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/18a42d87-5c8a-46d6-b0ae-01ef8575eb96n%40googlegroups.com.


Re: web page blank

2022-02-04 Thread Alex Dénho
Thanks

Le mer. 2 févr. 2022 à 13:37, kka kar  a écrit :

> I recreated the project and changed the view function to the below, and it
> now works fine for me:
>
> def home(request):
> context = {
> 'posts': post
> }
> return render(request, 'home.html', context)
>
> On Wednesday, February 2, 2022 at 8:23:46 AM UTC devfem...@gmail.com
> wrote:
>
>> Is it working fine for you?
>>
>>
>> If not url blog/home.html?
>>
>> On Wed, Feb 2, 2022, 08:08 Sebastian Jung  wrote:
>>
>>> Hello,
>>>
>>> Please try:
>>>
>>> context = {
>>> 'posts': post
>>> }
>>>
>>> 'Delvin Alexander' via Django users 
>>> schrieb am Mi., 2. Feb. 2022, 06:59:
>>>
 Hello everyone,

 I am currently following a django tutorial regarding applications. I
 have followed through completely but for some reason, when I run server, i
 incur no errors but the web page is blank. Why would this be?

 Here is what is not displayed:

 from my Home.html file:
 
 
 
 
 
 
 {% for post in posts %}
 {{ post.title }}
 By {{ post.author }} on {{ post.date_posted}}
 {{ post.content }}
 {% endfor %}

 
 

 from my views.py file:
 from django.shortcuts import render

 post = [
 {
 'author': 'CoreyMS',
 'title': 'Blog Post',
 'content': 'First Post Content',
 'date_posted': 'August 27, 2018'
 },
 {
 'author': 'Jane Doe',
 'title': 'Blog Post 2',
 'content': 'Second Post Content',
 'date_posted': 'August 28, 2018'
 }
 ]

 def home(request):
 context = {
 'post': post
 }
 return render(request, 'blog/home.html', context)

 def about(request):
 return render(request, 'blog/about.html')

 My urls.py:
 from django.urls import path
 from . import views

 urlpatterns = [
 path('', views.home, name='blog-home'),
 path('about/', views.about, name='blog-about'),
 ]


 --
 You received this message because you are subscribed 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 view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/e9b557a6-403b-46ce-bc18-8d19b0091f2an%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...@googlegroups.com.
>>>
>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAKGT9mzFaC4Eq9B_76nb0N2%2BRW-%2BNkbLMdfJT0Vph2qWuGefOw%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/c2f8ef77-d0ef-4868-8680-0314442952f9n%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/CAKvw4qy5WGaOaSPxZp27nZH-jFZps4nJreNE29w%3DgDaGNAJyPg%40mail.gmail.com.


Declarative mechanism for Django model rows

2021-12-08 Thread Alex Dehnert
With some frequency, I end up with models who contents are approximately 
constant. Are there good ways of handling this?


For example, I might have a set of plans that users can sign up 
for, with various attributes -- ID, name, order in the list of plans, 
cost, whether the purchaser needs to be a student/FOSS project/etc.. I'm 
going to rarely add/remove/change rows, and when I do there's likely going 
to be code changes too (eg, to change landing pages), so I'd like the 
contents of the model (not just the schema) to be managed in the code 
rather than through the Django admin (and consequently use pull requests 
to manage them, make sure test deploys are in sync, etc.). I'd also like 
it to be in the database, though, so I can select them using any column of 
the model, filter for things like "show me any project owned by a paid 
account", etc..


I think my ideal would be something like "have a list of model instances 
in my code, and either Django's ORM magically pretends they're actually in 
the database, or makemigrations makes data migrations for me", but I don't 
think that exists?


The two workable approaches that come to mind are to either write data 
migrations by hand or use regular classes (or dicts) and write whatever 
getters and filters I actually want by hand.


Data migrations give me all the Django ORM functionality I might want, but 
any time I change a row I need to write a migration by hand, and figuring 
out the actual state involves either looking in the Django admin or 
looking through all the data migrations to figure out their combined 
impact. (Oh, and if somebody accidentally deletes the objects in the 
database (most likely on a test install...) or a migration is screwy 
recovering will be a mess.)


Just using non-ORM classes in the source is a clearer, more declarative 
approach, but I need to add replacements for many things I might normally 
do in the ORM (.objects.get(...), __plan__is_student, 
.values(plan__is_student).annotate(...), etc.).


Which of these approaches is better presumably depends on how much ORM 
functionality I actually want and how often I expect to be changing 
things.


Are there other good approaches for this? Am I missing some Django feature 
(or add-on) that makes this easier?


Thanks,
Alex

P.S. I previously asked this on StackOverflow at 
https://stackoverflow.com/questions/70204467/declarative-mechanism-for-django-model-rows, 
but I'm realising this list is probably better.


--
You received this message because you are subscribed to the Google Groups "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/alpine.DEB.2.21.2112081409120.12786%40novgorod.mit.edu.


Re: Has anyone connected Django with AWS cognito in multi-tenant environment?

2021-11-03 Thread Alex Fernandes

Heey Mike,

I was wondering if you found a solution to this?

Cheers,
Alex
Op vrijdag 1 februari 2019 om 04:21:43 UTC+1 schreef mike hennessy:

> I'm new to Django, but not new to web development. I'm picking up 
> Django/Python and I'm interested in setting up a SaaS multi-tenant 
> application which leverages AWS's Cognito Identity/Infrastructure for 
> scaling a SaaS Web application.
>
> In googling this, I found very little. There was a thread about a wrapper 
> for Cognito called warrant, but from what I read, it's no longer supported 
> and it didn't seem stable.
> Has anyone else gotten a multi-tenant Django app setup with AWS Cognito as 
> your Identity/Authorization provider?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/68579c8d-c796-40f1-b462-be7883b8d0d5n%40googlegroups.com.


Re: HELP me: "a beginner's questions"

2021-08-18 Thread Alex B
Hello,

There are a few ways to deploy a Django site to a production server. Tools
like Ansible and Docker help a lot.

One way to transfer files is via git push and pull through a repository.
There are other ways as well.

Once the files are on the server, the server needs all the services set up
and running for database, static files, http server, caching, environment
variables etc. There can be a lot more to this.

I had the same questions as yours about a year ago, and can empathize..
I've since learned a couple different reliable deployment methods using
Dokker/dokku and Ansible. Happy to help more if you'd like, hit me up here
or directly.

Alex B



On Wed, Aug 18, 2021, 7:02 AM  wrote:

> Hi
>
> I am now starting to work in Django.
>
> I built a development environment on my laptop. I experimented there,
> things work.
>
> I have a web server on the net. With multiple hosted domains.
>
>
>
> I would put my attempt on one. But things don't work.
>
> - python is installed, updated
>
> - I installed django
>
> - "python3 manage.py runserver" seems to work, but nothing comes out
>
>
>
> Questions:
>
> - how do I transfer the developed file there?
>
> - what do I need to do to run as a web server?
>
>
>
> Thanks for the 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/001e01d7940e%24095cd210%241c167630%24%40gmail.com
> <https://groups.google.com/d/msgid/django-users/001e01d7940e%24095cd210%241c167630%24%40gmail.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/CALyOw5h%3D24yn9vv5DSs279he_rytJAoOZauirt8oX5tg8y--gQ%40mail.gmail.com.


RE: Help me with the view please

2020-09-23 Thread fadhil alex
I cant seem to put together this template for adding fee, for roll#, tuition fee and remaining fee, I have managed only to create the form, can you help me with thatSent from Mail for Windows 10 From: coolguySent: Tuesday, September 22, 2020 6:10 PMTo: Django usersSubject: Re: Help me with the view please how about following outputs... On Tuesday, September 22, 2020 at 4:44:45 AM UTC-4 dex9...@gmail.com wrote:Thanks for your previous tips, and I have already created the get_absolute_url for my DetailView and It is working just finedef get_absolute_url(self):return reverse("student_detail", kwargs={"pk": self.pk})I think now I can learn from you how use views to generate my output Sent from Mail for Windows 10 From: coolguySent: Tuesday, September 22, 2020 4:32 AMTo: Django usersSubject: Re: Help me with the view please I have made some changes to the model.py and now methods/functions are properties(@property). It's of personal preference and you will find programmers prefer properties and functions for their own understanding.    google it you will see... Since these functions are not doing big calculations with no parameter/argument and are very basic so we can use property instead.  What you need to do is.. wherever you called the method with () brackets... remove them like example below... fee = self.student.get_remaining_fee()tofee = self.student.get_remaining_fee There is one get_absolute_url method that you can use to reverse to student_detail view (if you have create one). We can later talk about how you are using views to generate your output...On Monday, September 21, 2020 at 2:58:14 PM UTC-4 dex9...@gmail.com wrote:Hi @coolguy, thanks for your attachments,  have created all the views and templates, and I have been working on them for my new web app, for this new models will it be easy for more implement or auto check paid all checkbox all payments have been completed, please, how? Sent from Mail for Windows 10 From: coolguySent: Thursday, September 17, 2020 6:26 AMTo: Django usersSubject: Re: Help me with the view please If you are using sqllite3 then make a copy of it and delete the existing sqllite3 file from your project. Keep the old file as you may need it. Here are project files... i quickly make them but these are working..On Wednesday, September 16, 2020 at 3:57:22 PM UTC-4 dex9...@gmail.com wrote:Since model design is where I very much struggle, and I think  my fee management system models are not well design, so I need your help in redesigning my models please Sent from Mail for Windows 10 From: coolguySent: Wednesday, September 16, 2020 5:31 PMTo: Django usersSubject: Re: Help me with the view please There are a lot of courses but those are very basic and keep on talking about same thing that you might have learned before... even after taking courses you will have to think yourself how to structure your tables I would suggest don't start any big project rather start with a simple Student, Payment and Class models. Keep master information in your Student and class models and all transaction in Payment model. I can help you in designing the models. Let me know... On Wednesday, September 16, 2020 at 12:43:06 AM UTC-4 dex9...@gmail.com wrote:Thanks for your valuable information, it seems my models are not well constructed, I will first work on them.Don’t you have a YouTube channel or website or paid course somewhere like Udemy where I can learn more Sent from Mail for Windows 10 From: coolguySent: Tuesday, September 15, 2020 10:57 PMTo: Django usersSubject: Re: Help me with the view please Isn't this 'paid_fee' used to record the quarterly/monthly payments from students? and this field will have multiple records?  It seems you are looking to save an accumulated paid_fee (total_paid_fees) somewhere in table. If i am corrected then... this type of structure is okay when you are working on spreadsheet solution e.g. microsoft excel, and save/calculate the result in a separate column for the user info but when we deal with the database and UI solution we don't use this approach... rather we show such calculation on template. We persist initial setup values like student name, school_fees etc and the recurring transactions in database. If you really want to save this type of information in your database you get to change your database structure and create a parent and child relationship between Fee (being parent) and Student_Payments (being child). 'Fee' would have all setup information as well as calculated fields like total_fees, total_paid_fees, remaining_fees etc. 'Student_payments' would only carry number of payments over the periods. When you have this structure ready then you can think of maintaining totals in parent table per student. anyways, to your question following line would not work in save() method>>> self.paid_fees = student.fee_set.aggregate(total_paid_fees=sum('paid_fees'))   since you don't have >>> student = Student.objects.get(id=pk) even if you want to 

RE: Help me with the view please

2020-09-22 Thread fadhil alex
Thanks for your previous tips, and I have already created the get_absolute_url for my DetailView and It is working just finedef get_absolute_url(self):return reverse("student_detail", kwargs={"pk": self.pk})I think now I can learn from you how use views to generate my output Sent from Mail for Windows 10 From: coolguySent: Tuesday, September 22, 2020 4:32 AMTo: Django usersSubject: Re: Help me with the view please I have made some changes to the model.py and now methods/functions are properties(@property). It's of personal preference and you will find programmers prefer properties and functions for their own understanding.    google it you will see... Since these functions are not doing big calculations with no parameter/argument and are very basic so we can use property instead.  What you need to do is... wherever you called the method with () brackets... remove them like example below... fee = self.student.get_remaining_fee()tofee = self.student.get_remaining_fee There is one get_absolute_url method that you can use to reverse to student_detail view (if you have create one). We can later talk about how you are using views to generate your output...On Monday, September 21, 2020 at 2:58:14 PM UTC-4 dex9...@gmail.com wrote:Hi @coolguy, thanks for your attachments,  have created all the views and templates, and I have been working on them for my new web app, for this new models will it be easy for more implement or auto check paid all checkbox all payments have been completed, please, how? Sent from Mail for Windows 10 From: coolguySent: Thursday, September 17, 2020 6:26 AMTo: Django usersSubject: Re: Help me with the view please If you are using sqllite3 then make a copy of it and delete the existing sqllite3 file from your project. Keep the old file as you may need it. Here are project files... i quickly make them but these are working..On Wednesday, September 16, 2020 at 3:57:22 PM UTC-4 dex9...@gmail.com wrote:Since model design is where I very much struggle, and I think  my fee management system models are not well design, so I need your help in redesigning my models please Sent from Mail for Windows 10 From: coolguySent: Wednesday, September 16, 2020 5:31 PMTo: Django usersSubject: Re: Help me with the view please There are a lot of courses but those are very basic and keep on talking about same thing that you might have learned before... even after taking courses you will have to think yourself how to structure your tables I would suggest don't start any big project rather start with a simple Student, Payment and Class models. Keep master information in your Student and class models and all transaction in Payment model. I can help you in designing the models. Let me know... On Wednesday, September 16, 2020 at 12:43:06 AM UTC-4 dex9...@gmail.com wrote:Thanks for your valuable information, it seems my models are not well constructed, I will first work on them.Don’t you have a YouTube channel or website or paid course somewhere like Udemy where I can learn more Sent from Mail for Windows 10 From: coolguySent: Tuesday, September 15, 2020 10:57 PMTo: Django usersSubject: Re: Help me with the view please Isn't this 'paid_fee' used to record the quarterly/monthly payments from students? and this field will have multiple records?  It seems you are looking to save an accumulated paid_fee (total_paid_fees) somewhere in table. If i am corrected then... this type of structure is okay when you are working on spreadsheet solution e.g. microsoft excel, and save/calculate the result in a separate column for the user info but when we deal with the database and UI solution we don't use this approach... rather we show such calculation on template. We persist initial setup values like student name, school_fees etc and the recurring transactions in database. If you really want to save this type of information in your database you get to change your database structure and create a parent and child relationship between Fee (being parent) and Student_Payments (being child). 'Fee' would have all setup information as well as calculated fields like total_fees, total_paid_fees, remaining_fees etc. 'Student_payments' would only carry number of payments over the periods. When you have this structure ready then you can think of maintaining totals in parent table per student. anyways, to your question following line would not work in save() method>>> self.paid_fees = student.fee_set.aggregate(total_paid_fees=sum('paid_fees'))   since you don't have >>> student = Student.objects.get(id=pk) even if you want to save then which record in the table would you update... so logically its wrong. On Tuesday, September 15, 2020 at 2:04:57 AM UTC-4 dex9...@gmail.com wrote:def save(self, *args, **kwargs):self.paid_fees = student.fee_set.aggregate(total_paid_fees=sum('paid_fees'))self.school_fees = first_record.school_feesself.remaining_fees = self.school_fees - self.paid_feesif 

RE: Help me with the view please

2020-09-21 Thread fadhil alex
Hi @coolguy, thanks for your attachments,  have created all the views and templates, and I have been working on them for my new web app, for this new models will it be easy for more implement or auto check paid all checkbox all payments have been completed, please, how? Sent from Mail for Windows 10 From: coolguySent: Thursday, September 17, 2020 6:26 AMTo: Django usersSubject: Re: Help me with the view please If you are using sqllite3 then make a copy of it and delete the existing sqllite3 file from your project. Keep the old file as you may need it. Here are project files... i quickly make them but these are working..On Wednesday, September 16, 2020 at 3:57:22 PM UTC-4 dex9...@gmail.com wrote:Since model design is where I very much struggle, and I think  my fee management system models are not well design, so I need your help in redesigning my models please Sent from Mail for Windows 10 From: coolguySent: Wednesday, September 16, 2020 5:31 PMTo: Django usersSubject: Re: Help me with the view please There are a lot of courses but those are very basic and keep on talking about same thing that you might have learned before... even after taking courses you will have to think yourself how to structure your tables I would suggest don't start any big project rather start with a simple Student, Payment and Class models. Keep master information in your Student and class models and all transaction in Payment model. I can help you in designing the models. Let me know... On Wednesday, September 16, 2020 at 12:43:06 AM UTC-4 dex9...@gmail.com wrote:Thanks for your valuable information, it seems my models are not well constructed, I will first work on them.Don’t you have a YouTube channel or website or paid course somewhere like Udemy where I can learn more Sent from Mail for Windows 10 From: coolguySent: Tuesday, September 15, 2020 10:57 PMTo: Django usersSubject: Re: Help me with the view please Isn't this 'paid_fee' used to record the quarterly/monthly payments from students? and this field will have multiple records?  It seems you are looking to save an accumulated paid_fee (total_paid_fees) somewhere in table. If i am corrected then... this type of structure is okay when you are working on spreadsheet solution e.g. microsoft excel, and save/calculate the result in a separate column for the user info but when we deal with the database and UI solution we don't use this approach... rather we show such calculation on template. We persist initial setup values like student name, school_fees etc and the recurring transactions in database. If you really want to save this type of information in your database you get to change your database structure and create a parent and child relationship between Fee (being parent) and Student_Payments (being child). 'Fee' would have all setup information as well as calculated fields like total_fees, total_paid_fees, remaining_fees etc. 'Student_payments' would only carry number of payments over the periods. When you have this structure ready then you can think of maintaining totals in parent table per student. anyways, to your question following line would not work in save() method>>> self.paid_fees = student.fee_set.aggregate(total_paid_fees=sum('paid_fees'))   since you don't have >>> student = Student.objects.get(id=pk) even if you want to save then which record in the table would you update... so logically its wrong. On Tuesday, September 15, 2020 at 2:04:57 AM UTC-4 dex9...@gmail.com wrote:def save(self, *args, **kwargs):self.paid_fees = student.fee_set.aggregate(total_paid_fees=sum('paid_fees'))self.school_fees = first_record.school_feesself.remaining_fees = self.school_fees - self.paid_feesif self.remaining_fees == 0:self.completed = Trueelse:self.completed = Falsesuper().save(*args, **kwargs)I have tried doing it like this, perhaps maybe you can see what I’m trying to doSent from Mail From: coolguySent: Monday, September 14, 2020 11:53 PMTo: Django usersSubject: Re: Help me with the view please not sure what are you looking for.. but based on your model setup... school fees is setup once so we picked it up from first object/record from table, while paid fees are collected quarterly or whatever means there will be more than one transaction in fee table. We have already calculated the "paid_fees" from fee table like this>>>    paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees')) I definitely want to help as long as i know what you are looking for :)  On Monday, September 14, 2020 at 4:26:48 PM UTC-4 dex9...@gmail.com wrote:Thanks it has worked, but it doesn’t work with my total_paid_fees, I want to be automatically checked when school_fees substracts summation of all paid_fees, just like this solution you provided me with the last timefirst_record = student.fee_set.first() school_fees = first_record.school_fees  paid_fees = 

RE: Help me with the view please

2020-09-16 Thread fadhil alex
Since model design is where I very much struggle, and I think  my fee management system models are not well design, so I need your help in redesigning my models please Sent from Mail for Windows 10 From: coolguySent: Wednesday, September 16, 2020 5:31 PMTo: Django usersSubject: Re: Help me with the view please There are a lot of courses but those are very basic and keep on talking about same thing that you might have learned before... even after taking courses you will have to think yourself how to structure your tables I would suggest don't start any big project rather start with a simple Student, Payment and Class models. Keep master information in your Student and class models and all transaction in Payment model. I can help you in designing the models. Let me know... On Wednesday, September 16, 2020 at 12:43:06 AM UTC-4 dex9...@gmail.com wrote:Thanks for your valuable information, it seems my models are not well constructed, I will first work on them.Don’t you have a YouTube channel or website or paid course somewhere like Udemy where I can learn more Sent from Mail for Windows 10 From: coolguySent: Tuesday, September 15, 2020 10:57 PMTo: Django usersSubject: Re: Help me with the view please Isn't this 'paid_fee' used to record the quarterly/monthly payments from students? and this field will have multiple records?  It seems you are looking to save an accumulated paid_fee (total_paid_fees) somewhere in table. If i am corrected then... this type of structure is okay when you are working on spreadsheet solution e.g. microsoft excel, and save/calculate the result in a separate column for the user info but when we deal with the database and UI solution we don't use this approach... rather we show such calculation on template. We persist initial setup values like student name, school_fees etc and the recurring transactions in database. If you really want to save this type of information in your database you get to change your database structure and create a parent and child relationship between Fee (being parent) and Student_Payments (being child). 'Fee' would have all setup information as well as calculated fields like total_fees, total_paid_fees, remaining_fees etc. 'Student_payments' would only carry number of payments over the periods. When you have this structure ready then you can think of maintaining totals in parent table per student. anyways, to your question following line would not work in save() method>>> self.paid_fees = student.fee_set.aggregate(total_paid_fees=sum('paid_fees'))   since you don't have >>> student = Student.objects.get(id=pk) even if you want to save then which record in the table would you update... so logically its wrong. On Tuesday, September 15, 2020 at 2:04:57 AM UTC-4 dex9...@gmail.com wrote:def save(self, *args, **kwargs):self.paid_fees = student.fee_set.aggregate(total_paid_fees=sum('paid_fees'))self.school_fees = first_record.school_feesself.remaining_fees = self.school_fees - self.paid_feesif self.remaining_fees == 0:self.completed = Trueelse:self.completed = Falsesuper().save(*args, **kwargs)I have tried doing it like this, perhaps maybe you can see what I’m trying to doSent from Mail From: coolguySent: Monday, September 14, 2020 11:53 PMTo: Django usersSubject: Re: Help me with the view please not sure what are you looking for.. but based on your model setup... school fees is setup once so we picked it up from first object/record from table, while paid fees are collected quarterly or whatever means there will be more than one transaction in fee table. We have already calculated the "paid_fees" from fee table like this>>>    paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees')) I definitely want to help as long as i know what you are looking for :)  On Monday, September 14, 2020 at 4:26:48 PM UTC-4 dex9...@gmail.com wrote:Thanks it has worked, but it doesn’t work with my total_paid_fees, I want to be automatically checked when school_fees substracts summation of all paid_fees, just like this solution you provided me with the last timefirst_record = student.fee_set.first() school_fees = first_record.school_fees  paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))   balance_fees =  school_fees - paid_fees["total_paid_fees"]   Sent from Mail for Windows 10 From: coolguySent: Monday, September 14, 2020 9:09 PMTo: Django usersSubject: Re: Help me with the view please Its simple... in your fee models' save method check that self.remaining_fees is zero then make self.completed field to true... I added else clause in case if admin make changes to paid fees and after changes student still has some dues.     def save(self, *args, **kwargs): self.remaining_fees = self.school_fees - self.paid_feesif self.remaining_fees == 0:self.completed = Trueelse:self.completed = Falsesuper().save(*args, 

RE: Help me with the view please

2020-09-15 Thread fadhil alex
Thanks for your valuable information, it seems my models are not well constructed, I will first work on them.Don’t you have a YouTube channel or website or paid course somewhere like Udemy where I can learn more Sent from Mail for Windows 10 From: coolguySent: Tuesday, September 15, 2020 10:57 PMTo: Django usersSubject: Re: Help me with the view please Isn't this 'paid_fee' used to record the quarterly/monthly payments from students? and this field will have multiple records?  It seems you are looking to save an accumulated paid_fee (total_paid_fees) somewhere in table. If i am corrected then... this type of structure is okay when you are working on spreadsheet solution e.g. microsoft excel, and save/calculate the result in a separate column for the user info but when we deal with the database and UI solution we don't use this approach... rather we show such calculation on template. We persist initial setup values like student name, school_fees etc and the recurring transactions in database. If you really want to save this type of information in your database you get to change your database structure and create a parent and child relationship between Fee (being parent) and Student_Payments (being child). 'Fee' would have all setup information as well as calculated fields like total_fees, total_paid_fees, remaining_fees etc. 'Student_payments' would only carry number of payments over the periods. When you have this structure ready then you can think of maintaining totals in parent table per student. anyways, to your question following line would not work in save() method>>> self.paid_fees = student.fee_set.aggregate(total_paid_fees=sum('paid_fees'))   since you don't have >>> student = Student.objects.get(id=pk) even if you want to save then which record in the table would you update... so logically its wrong. On Tuesday, September 15, 2020 at 2:04:57 AM UTC-4 dex9...@gmail.com wrote:def save(self, *args, **kwargs):self.paid_fees = student.fee_set.aggregate(total_paid_fees=sum('paid_fees'))self.school_fees = first_record.school_feesself.remaining_fees = self.school_fees - self.paid_feesif self.remaining_fees == 0:self.completed = Trueelse:self.completed = Falsesuper().save(*args, **kwargs)I have tried doing it like this, perhaps maybe you can see what I’m trying to doSent from Mail From: coolguySent: Monday, September 14, 2020 11:53 PMTo: Django usersSubject: Re: Help me with the view please not sure what are you looking for... but based on your model setup... school fees is setup once so we picked it up from first object/record from table, while paid fees are collected quarterly or whatever means there will be more than one transaction in fee table. We have already calculated the "paid_fees" from fee table like this>>>    paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees')) I definitely want to help as long as i know what you are looking for :)  On Monday, September 14, 2020 at 4:26:48 PM UTC-4 dex9...@gmail.com wrote:Thanks it has worked, but it doesn’t work with my total_paid_fees, I want to be automatically checked when school_fees substracts summation of all paid_fees, just like this solution you provided me with the last timefirst_record = student.fee_set.first() school_fees = first_record.school_fees  paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))   balance_fees =  school_fees - paid_fees["total_paid_fees"]   Sent from Mail for Windows 10 From: coolguySent: Monday, September 14, 2020 9:09 PMTo: Django usersSubject: Re: Help me with the view please Its simple... in your fee models' save method check that self.remaining_fees is zero then make self.completed field to true... I added else clause in case if admin make changes to paid fees and after changes student still has some dues.     def save(self, *args, **kwargs): self.remaining_fees = self.school_fees - self.paid_feesif self.remaining_fees == 0:self.completed = Trueelse:self.completed = Falsesuper().save(*args, **kwargs) On Monday, September 14, 2020 at 7:11:51 AM UTC-4 dex9...@gmail.com wrote:Thank you brother @coolguy, I have put to work your latest solution and it has worked like a charm.I have been learning a lot from you lately, as you know i am still a beginner, i would love to learn one more thing from you..i have a boolean field "completed", and i want django to automatically check it when balance_fees or remaining_fees is equal to zero, Here is  my model my template  Sent from Mail for Windows 10 From: coolguySent: Friday, September 11, 2020 8:51 PMTo: Django usersSubject: Re: Help me with the view please Technically your Fee model is designed incorrectly. You should have separate models for 'fees' and 'fees_paid' where fee would have been the foreign key in 'fees_paid. Fee should have a property like annual fee etc for each student as fee may be 

RE: Help me with the view please

2020-09-15 Thread fadhil alex
def save(self, *args, **kwargs):self.paid_fees = student.fee_set.aggregate(total_paid_fees=sum('paid_fees'))self.school_fees = first_record.school_feesself.remaining_fees = self.school_fees - self.paid_feesif self.remaining_fees == 0:self.completed = Trueelse:self.completed = Falsesuper().save(*args, **kwargs)I have tried doing it like this, perhaps maybe you can see what I’m trying to doSent from Mail From: coolguySent: Monday, September 14, 2020 11:53 PMTo: Django usersSubject: Re: Help me with the view please not sure what are you looking for... but based on your model setup... school fees is setup once so we picked it up from first object/record from table, while paid fees are collected quarterly or whatever means there will be more than one transaction in fee table. We have already calculated the "paid_fees" from fee table like this>>>    paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees')) I definitely want to help as long as i know what you are looking for :)  On Monday, September 14, 2020 at 4:26:48 PM UTC-4 dex9...@gmail.com wrote:Thanks it has worked, but it doesn’t work with my total_paid_fees, I want to be automatically checked when school_fees substracts summation of all paid_fees, just like this solution you provided me with the last timefirst_record = student.fee_set.first() school_fees = first_record.school_fees  paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))   balance_fees =  school_fees - paid_fees["total_paid_fees"]   Sent from Mail for Windows 10 From: coolguySent: Monday, September 14, 2020 9:09 PMTo: Django usersSubject: Re: Help me with the view please Its simple... in your fee models' save method check that self.remaining_fees is zero then make self.completed field to true... I added else clause in case if admin make changes to paid fees and after changes student still has some dues.     def save(self, *args, **kwargs): self.remaining_fees = self.school_fees - self.paid_feesif self.remaining_fees == 0:self.completed = Trueelse:self.completed = Falsesuper().save(*args, **kwargs) On Monday, September 14, 2020 at 7:11:51 AM UTC-4 dex9...@gmail.com wrote:Thank you brother @coolguy, I have put to work your latest solution and it has worked like a charm.I have been learning a lot from you lately, as you know i am still a beginner, i would love to learn one more thing from you..i have a boolean field "completed", and i want django to automatically check it when balance_fees or remaining_fees is equal to zero, Here is  my model my template  Sent from Mail for Windows 10 From: coolguySent: Friday, September 11, 2020 8:51 PMTo: Django usersSubject: Re: Help me with the view please Technically your Fee model is designed incorrectly. You should have separate models for 'fees' and 'fees_paid' where fee would have been the foreign key in 'fees_paid. Fee should have a property like annual fee etc for each student as fee may be different based on student discounts etc. Then when student pays the fees, fees should go in a separate transactional table i.e. 'fees paid'. In your scenario, does each row in fee table carries the annual/school fee? if so then yes summing them up will definitely cause incorrect figure. Here is what i would do if i don't change my models structure. views.py===def student_detail(request, pk):student = Student.objects.get(id=pk)# in your case pick the first record from fee_setfirst_record = student.fee_set.first()school_fees = first_record.school_feespaid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))balance_fees =  school_fees - paid_fees["total_paid_fees"]  context = {"student": student,   "paid_fees": paid_fees,   "school_fees": school_fees,   "balance_fees": balance_fees, } return render(request, "student_details.html", context) template===Student DetailStudent name: {{ student.name }}School fees: {{ school_fees }}Paid fees: {{ paid_fees.total_paid_fees }}Remaining fees: {{ balance_fees }} Output:Student name: student1School fees: 10.0Paid fees: 35000.0Remaining fees: 65000.0 On Friday, September 11, 2020 at 5:25:28 AM UTC-4 dex9...@gmail.com wrote:Sorry for bothering you @coolguy, you’re the only person who seems to be nice to a Django beginner developer like me, and I would like to bother you one more timeYour solution for using methods in models is perfectly fineYou see I want school_fees to be a fixed amount, example $300So when a student pays more than once(student.fee_set), lets say this month student 1 pays $50 And another month pays $100 dollars, I want payments to added and subtracted from fixed schools_fees($300)Remainingfees to be $300 – (($50)+($100)) BUT what “ fees = 

RE: Help me with the view please

2020-09-14 Thread fadhil alex
Thanks it has worked, but it doesn’t work with my total_paid_fees, I want to be automatically checked when school_fees substracts summation of all paid_fees, just like this solution you provided me with the last timefirst_record = student.fee_set.first() school_fees = first_record.school_fees  paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))   balance_fees =  school_fees - paid_fees["total_paid_fees"]   Sent from Mail for Windows 10 From: coolguySent: Monday, September 14, 2020 9:09 PMTo: Django usersSubject: Re: Help me with the view please Its simple... in your fee models' save method check that self.remaining_fees is zero then make self.completed field to true... I added else clause in case if admin make changes to paid fees and after changes student still has some dues.     def save(self, *args, **kwargs): self.remaining_fees = self.school_fees - self.paid_feesif self.remaining_fees == 0:self.completed = Trueelse:self.completed = Falsesuper().save(*args, **kwargs) On Monday, September 14, 2020 at 7:11:51 AM UTC-4 dex9...@gmail.com wrote:Thank you brother @coolguy, I have put to work your latest solution and it has worked like a charm.I have been learning a lot from you lately, as you know i am still a beginner, i would love to learn one more thing from you..i have a boolean field "completed", and i want django to automatically check it when balance_fees or remaining_fees is equal to zero, Here is  my model my template  Sent from Mail for Windows 10 From: coolguySent: Friday, September 11, 2020 8:51 PMTo: Django usersSubject: Re: Help me with the view please Technically your Fee model is designed incorrectly. You should have separate models for 'fees' and 'fees_paid' where fee would have been the foreign key in 'fees_paid. Fee should have a property like annual fee etc for each student as fee may be different based on student discounts etc. Then when student pays the fees, fees should go in a separate transactional table i.e. 'fees paid'. In your scenario, does each row in fee table carries the annual/school fee? if so then yes summing them up will definitely cause incorrect figure. Here is what i would do if i don't change my models structure. views.py===def student_detail(request, pk):student = Student.objects.get(id=pk)# in your case pick the first record from fee_setfirst_record = student.fee_set.first()school_fees = first_record.school_feespaid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))balance_fees =  school_fees - paid_fees["total_paid_fees"]  context = {"student": student,   "paid_fees": paid_fees,   "school_fees": school_fees,   "balance_fees": balance_fees, } return render(request, "student_details.html", context) template===Student DetailStudent name: {{ student.name }}School fees: {{ school_fees }}Paid fees: {{ paid_fees.total_paid_fees }}Remaining fees: {{ balance_fees }} Output:Student name: student1School fees: 10.0Paid fees: 35000.0Remaining fees: 65000.0 On Friday, September 11, 2020 at 5:25:28 AM UTC-4 dex9...@gmail.com wrote:Sorry for bothering you @coolguy, you’re the only person who seems to be nice to a Django beginner developer like me, and I would like to bother you one more timeYour solution for using methods in models is perfectly fineYou see I want school_fees to be a fixed amount, example $300So when a student pays more than once(student.fee_set), lets say this month student 1 pays $50 And another month pays $100 dollars, I want payments to added and subtracted from fixed schools_fees($300)Remainingfees to be $300 – (($50)+($100)) BUT what “ fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'), total_school_fees=Sum('school_fees'))” does is that it sums both paid fees school fees every time a student pays, I want only paid fees to added every time a student pays but not school fees   Sent from Mail for Windows 10 From: coolguySent: Friday, September 11, 2020 4:27 AMTo: Django usersSubject: Re: Help me with the view please If i choose to go with your way of calculation, i would do this... def student_detail(request, pk):student = Student.objects.get(id=pk)fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'), total_school_fees=Sum('school_fees')) balance_fees = fees["total_school_fees"] - fees["total_paid_fees"] context = {"student": student, "fees": fees, "balance_fees": balance_fees, } return render(request, "student_details.html", context) Template e.g.Student DetailStudent name: {{ student.name }}School fees: {{ fees.total_school_fees }}Paid fees: {{ fees.total_paid_fees }}Remaining fees: {{ balance_fees }} Result:Student DetailStudent name: student1School fees: 10.0Paid fees: 25000.0Remaining fees: 75000.0I hope this helps!On Thursday, September 10, 2020 at 2:16:27 PM UTC-4 

RE: Help me with the view please

2020-09-11 Thread fadhil alex
Sorry for bothering you @coolguy, you’re the only person who seems to be nice to a Django beginner developer like me, and I would like to bother you one more timeYour solution for using methods in models is perfectly fineYou see I want school_fees to be a fixed amount, example $300So when a student pays more than once(student.fee_set), lets say this month student 1 pays $50 And another month pays $100 dollars, I want payments to added and subtracted from fixed schools_fees($300)Remainingfees to be $300 – (($50)+($100)) BUT what “ fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'), total_school_fees=Sum('school_fees'))” does is that it sums both paid fees school fees every time a student pays, I want only paid fees to added every time a student pays but not school fees   Sent from Mail for Windows 10 From: coolguySent: Friday, September 11, 2020 4:27 AMTo: Django usersSubject: Re: Help me with the view please If i choose to go with your way of calculation, i would do this... def student_detail(request, pk):student = Student.objects.get(id=pk)fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'), total_school_fees=Sum('school_fees')) balance_fees = fees["total_school_fees"] - fees["total_paid_fees"] context = {"student": student, "fees": fees, "balance_fees": balance_fees, } return render(request, "student_details.html", context) Template e.g.Student DetailStudent name: {{ student.name }}School fees: {{ fees.total_school_fees }}Paid fees: {{ fees.total_paid_fees }}Remaining fees: {{ balance_fees }} Result:Student DetailStudent name: student1School fees: 10.0Paid fees: 25000.0Remaining fees: 75000.0I hope this helps!On Thursday, September 10, 2020 at 2:16:27 PM UTC-4 dex9...@gmail.com wrote:Thanks for helping me @coolguy,but it seems I ran into another problem, the school fees and remaining fees somehow sums together, I want students to pay school fees in phases, i.e, first quarter, second etc, and I want remaining fee to be the difference between the initial school fees which is 100 and total fee paid.Thanks in advance My views.py for studentSent from Mail for Windows 10 From: coolguySent: Tuesday, September 8, 2020 11:58 PMTo: Django usersSubject: Re: Help me with the view please I see now what you are asking... I never do such calculations in views rather I create methods in models.py to do so and call them in the template... Like what you could do is.. class Student(models.Model):name = models.CharField(max_length=200, null=True, blank=True)classroom = models.ForeignKey(Classroom,  _on_delete_=models.DO_NOTHING, blank=True, null=True) def __str__(self):return self.name     def get_total_fee(self):return sum(student.school_fees for student in self.fee_set.all()) def get_total_paid_fee(self):return sum(student.paid_fees for student in self.fee_set.all()) def get_remaining_fee(self):total_fee = self.get_total_fee()total_paid = self.get_total_paid_fee()return float(total_fee - total_paid) and in template you can call...{{ student.get_remaining_fee }}On Tuesday, September 8, 2020 at 1:35:56 PM UTC-4 dex9...@gmail.com wrote:Thank you for your help @coolguy..but my real problem lies in writing the code for “fee_remaining”, can you help me with that also..thanks Sent from Mail for Windows 10 From: coolguySent: Tuesday, September 8, 2020 7:45 PMTo: Django usersSubject: Re: Help me with the view please In your return line of code, you are referring to context variable but I don't see you assigned any value to this context variable in your code.Or if you want to send three variables i.e. "fees", "total_fees" and "fee_remaining"... you need to send them separately like return render(request, 'website/students.html', {"fees": fees, "total_fees": total_fees, "fee_remaining": fee_remaining }) then use these variables on your students.html template.   On Tuesday, September 8, 2020 at 12:21:21 PM UTC-4 dex9...@gmail.com wrote:My Modelsclass Student(models.Model):name = models.CharField(max_length=200, null=True, blank=True)classroom = models.ForeignKey(‘Classroom’,_on_delete_=models.DO_NOTHING,blank=True, null=True)class Classroom(models.Model):name = models.CharField(max_length=40,blank=True, null=True)class Fee(models.Model):student = models.ForeignKey(Student, _on_delete_=models.CASCADE, null=True,)classroom = models.ForeignKey(Classroom, _on_delete_=models.CASCADE, null=True)school_fees = models.FloatField(default=100)paid_fees = models.FloatField(null=False)remaining_fees = models.FloatField(blank=True)completed = models.BooleanField(null=False, default=False)views.pydef student(request, pk):student = Student.objects.get(id=pk)fees = student.fee_set.all().order_by('-publish_date') total_fees = student.fee_set.all().filter(student__id=pk) .aggregate(sum=Sum('paid_fees', flat=True)['sum'] fees_remaining = () return render(request, 

RE: Help me with the view please

2020-09-08 Thread fadhil alex
Thank you for your help @coolguy..but my real problem lies in writing the code for “fee_remaining”, can you help me with that also..thanks Sent from Mail for Windows 10 From: coolguySent: Tuesday, September 8, 2020 7:45 PMTo: Django usersSubject: Re: Help me with the view please In your return line of code, you are referring to context variable but I don't see you assigned any value to this context variable in your code.Or if you want to send three variables i.e. "fees", "total_fees" and "fee_remaining"... you need to send them separately like return render(request, 'website/students.html', {"fees": fees, "total_fees": total_fees, "fee_remaining": fee_remaining }) then use these variables on your students.html template.   On Tuesday, September 8, 2020 at 12:21:21 PM UTC-4 dex9...@gmail.com wrote:My Modelsclass Student(models.Model):name = models.CharField(max_length=200, null=True, blank=True)classroom = models.ForeignKey(‘Classroom’,_on_delete_=models.DO_NOTHING,blank=True, null=True)class Classroom(models.Model):name = models.CharField(max_length=40,blank=True, null=True)class Fee(models.Model):student = models.ForeignKey(Student, _on_delete_=models.CASCADE, null=True,)classroom = models.ForeignKey(Classroom, _on_delete_=models.CASCADE, null=True)school_fees = models.FloatField(default=100)paid_fees = models.FloatField(null=False)remaining_fees = models.FloatField(blank=True)completed = models.BooleanField(null=False, default=False)views.pydef student(request, pk):student = Student.objects.get(id=pk)fees = student.fee_set.all().order_by('-publish_date') total_fees = student.fee_set.all().filter(student__id=pk) .aggregate(sum=Sum('paid_fees', flat=True)['sum'] fees_remaining = () return render(request, 'website/students.html', context)  -- You received this message because you are subscribed to the Google Groups "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/e026b778-bac8-4522-ad1f-2ea4b33ad1efn%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/22CCCFA9-83C9-45FF-A2E7-413F1221FE49%40hxcore.ol.


Using subprocess in Django to run Java (HelloWorld) file

2020-08-03 Thread Alex Wan
Was looking at this link 
https://www.geeksforgeeks.org/python-subprocess-module-to-execute-programs-written-in-different-languages/
 and 
am trying to translate it into Django.

Upon form submission from index.html in templates, I want to call the view 
function to run HelloWorld.java (in same directory as the admin, apps, 
models, etc files) and return the result onto the webpage.

So the form code would be something like




The view function (same as from the link)

import subprocess

def executeJava(): 
  
s = subprocess.check_output("javac HelloWorld.java;java HelloWorld", 
shell = True) 
print(s.decode("utf-8")) 


How do I translate the driver function into Django? Insert into a function 
in views similar to this?

def form_submit(request):
if request.method == 'POST'
executeJava()
return render(request, 'templates/index.html')

Do I have to map this into urls.py? If so, how?

-- 
You received this message because you are subscribed to the Google Groups 
"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/65ead62a-d2e3-4655-87c2-4077d9d0baf2o%40googlegroups.com.


Re: select_related() and RawQuerySet

2020-04-27 Thread Alex Scott
This is an insanely old thread, but I couldn't find any updates so was 
curious if anyone had advice on implementing select_related with a 
RawQuerySet?  It seems prefetch_related() works just fine.

On Friday, March 2, 2012 at 11:22:52 AM UTC-8, akaariai wrote:
>
> On Friday, March 2, 2012 7:24:00 PM UTC+2, Tom Evans wrote:
>>
>> Hi all
>>
>> I have a particular query that requires me to use a RawQuerySet - I
>> need to left join the table to itself in order to select the highest
>> 'priority' row from the table for each distinct value of a foreign key
>> on the model, and I need to join to the related table in order to
>> filter the results.
>>
>> Having generated the queryset, I then want to make a dictionary of {
>> foreign_key_object : model_object }. So I have this working, but I
>> cannot use select_related() with a RawQuerySet, and so this runs N+1
>> queries, where N is the number of distinct foreign keys.
>>
>> Here is some code, which might explain it better:
>>
>> connection.queries=[]
>> base_products_qs = Product.objects.raw(
>> """
>> SELECT idp_product.*, idp_productclass.*
>> FROM idp_product
>> JOIN idp_productclass
>> ON idp_product.product_class_id = idp_productclass.id
>> LEFT JOIN idp_product p2
>> ON idp_product.product_class_id = p2.product_class_id
>> AND p2.class_priority < idp_product.class_priority
>> WHERE p2.id IS NULL and idp_productclass.product_type != 4
>> """)
>> base_products = dict([ (p.product_class, p) for p in base_products_qs ])
>> len(connection.queries) # 7 queries (6 product classes)
>>
>> Is there any simple way around this? I can reduce it to two queries
>> already, but it seems wrong to select out the info I want, throw it
>> away, and then fetch it again.
>>
>  Some suggestions:
>   - If the 2-query version is fast enough, use it. Premature optimization 
> and all that... :)
>   - You could of course manually iterate through the SQL and instantiate 
> the models by hand.
>   - Beware of the left join, it seems if you have a lot of rows with 
> different class_priorities for each product_class_id you might be in 
> trouble. The filtering on IS NULL happens after doing the join, so before 
> the filter you could have a lot of intermediate rows. It might be there is 
> no problem depending of the amount of rows and SQL vendor. Hard to know 
> without testing. There are a couple of other ways to do the query, either 
> by subquery doing a select min(class_priority), product_class_id or if you 
> are using PostgreSQL, distinct on would do the job for you, too.
>
> All that being said, I would really like the ability to have 
> select_related available for RawQuerySet. It might be judged to be a 
> feature not needed commonly enough, so it is possible it would not get in 
> even with a good quality patch. However, if it had a nice API, and the 
> implementation reused the code of QuerySet select_related, I think it could 
> have a chance to get in.
>
>  - Anssi
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/0c29de0a-7bbb-41f6-b6cd-f06dae3545c1%40googlegroups.com.


Re: CSRF token still needed today?

2020-04-19 Thread Alex Heyden
Django supports samesite on session cookies now, and it's on (set to lax)
by default. Whether or not that completely covers your surface risk to CSRF
attacks is a somewhat different question.

On Sun, Apr 19, 2020 at 3:12 PM guettli 
wrote:

> iI look at this page: https://docs.djangoproject.com/en/3.0/ref/csrf/
> ... and then I look at this page: https://scotthelme.co.uk/csrf-is-dead/
>
> Is a CSRF token still needed today?
>
> All my users use a modern browser.
>
> It would be very nice if I could get rid of the CSRF token.
>
> Is there a safe way to avoid CSRF tokens in  my Django project?
>
> Regards,
>   Thomas
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/487c7392-e874-4a1e-a1ff-488ab933ae42%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/CA%2Bv0ZYX_UaskL%2BGXjusNreEQp6mkwu71k_qZsz2NCQ1ur8LVDA%40mail.gmail.com.


Re: Make a Django query filter at runtime

2020-01-08 Thread Alex Conselvan de Oliveira
Hi Ezequias,

You could use a dict:

data = {
  'name': 'John',
  'age': 42,
}

model.filter(**data)

Best Regards!

Em qua., 8 de jan. de 2020 às 18:09, Ezequias Rocha <
ezequias.ro...@gmail.com> escreveu:

> Hi everyone
>
> I am in a doubt about creating django filters dynamically.
>
> All you know a filter is made by using the parameters like:
>
> model.filter(name='John', age=42)
>
> But if I can't type all fields and values at design time but at runtime
> how to do that?
>
> Best regards
> Ezequias
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/9c843d02-235f-411f-8e83-7fea2156893b%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/CAFwLvGHneKLY8YJroSyxQwjorVB_N6pT%3DnTEe%2Bm%2BG60ZXgeUVQ%40mail.gmail.com.


Re: Using Unaccent in Model database function

2020-01-05 Thread Alex Scott
I was able to figure this out using...

from django.contrib.postgres.lookups import Unaccent

queryset.annotate(search_index=StrIndex(Unaccent(Lower('name')), Value(q)))


Might be nice to add to the documentation here:
https://docs.djangoproject.com/en/3.0/ref/contrib/postgres/lookups/#unaccent

On Sunday, January 5, 2020 at 11:12:45 AM UTC-8, Alex Scott wrote:
>
> Hi all,
>
> I just started using the Unaccent extension for Postgres and implementing 
> queryset filters with it like:
>
> q = 'hello'
> queryset.filter(name__unaccent__istartswith=q)
>
> I'm now trying to annotate the queryset result with the search index:
>
> queryset.annotate(search_index=StrIndex(Lower('name'), Value(q)))
>
> That works fine by itself for unaccented text, but I'm trying to figure 
> out a way to apply Unaccent to the name variable there, something like:
>
> queryset.annotate(search_index=StrIndex(Lower('name__unaccent'), Value(q)))
>
> --> This has no effect, does the same as the above.
>
> or
>
> queryset.annotate(search_index=StrIndex(Lower(Unaccent('name')), Value(q)))
>
> --> There doesn't seem to be an Unaccent function
>
> Is there a way to do this currently?
>
> Thanks,
> Alex
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/ee1d633e-366a-4d3e-832e-fe8f35fe2664%40googlegroups.com.


Using Unaccent in Model database function

2020-01-05 Thread Alex Scott
Hi all,

I just started using the Unaccent extension for Postgres and implementing 
queryset filters with it like:

q = 'hello'
queryset.filter(name__unaccent__istartswith=q)

I'm now trying to annotate the queryset result with the search index:

queryset.annotate(search_index=StrIndex(Lower('name'), Value(q)))

That works fine by itself for unaccented text, but I'm trying to figure out 
a way to apply Unaccent to the name variable there, something like:

queryset.annotate(search_index=StrIndex(Lower('name__unaccent'), Value(q)))

--> This has no effect, does the same as the above.

or

queryset.annotate(search_index=StrIndex(Lower(Unaccent('name')), Value(q)))

--> There doesn't seem to be an Unaccent function

Is there a way to do this currently?

Thanks,
Alex

-- 
You received this message because you are subscribed to the Google Groups 
"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/0c069ce3-a79f-48ab-860f-147ed2fc5ddf%40googlegroups.com.


Re: [Django] How to retrieve the saved password in raw format

2019-10-21 Thread Alex Heyden
Password tables should never be human-readable. Never ever. No exceptions.

If the intent is to power automation, store that password where the test
agent can read it. If you don't know the password, reset it, then save it.
Don't expect your web server to leak a password, though. Not even if you
ask it nicely.

On Mon, Oct 21, 2019 at 1:16 PM Dilipkumar Noone  wrote:

> Dear Django group,
>
> In one of my View i need UserName & Password details in raw format but
> Django uses *PBKDF2*  algorithm to
> store the password.
>
> I would like to know how to retrieve the saved password from
> Authentication Form.
>
> Using these Username and password details from my Django app , i need to
> use the same credentials to access another website to perform web
> automation on it using selenium chrome webdriver.
>
> Please let us know how to get the password in raw format once user
> authenticated using below LoginForm and login_view.
>
> *My forms.py:*
> *===*
>
> forms.py:
> ===
>
> class LoginForm(AuthenticationForm):
>
> remember_me = forms.BooleanField(required=True, initial=False)
>
> def __init__(self, *args, **kwargs):
>
> super(LoginForm, self).__init__(*args, **kwargs)
> self.helper = FormHelper()
> self.helper.form_action = '.'
> self.helper.layout = Layout(
> Field('username', placeholder="Enter Username", autofocus=""),
> Field('password', placeholder="Enter Password"),
> Field('remember_me'),
> Submit('sign_in', 'Log in',
>css_class="btn btn-lg btn-primary btn-block"),
> )
>
> def apply_gsp_request_form(request, id=None):
>
> if id:
> action = 'edit'
> model = get_object_or_404(ApplyGSP, pk=id)
> else:
> action = 'submit'
> model = ApplyGSP()
>
> message = ""
>
> if request.method == 'POST':
> form = ApplyGSPForm(request.POST, instance=model)
>
> if form.is_valid():
> form.save()
> username = request.user.username
> print("password:", request.user.password)
>* # How to get password details ? If i get pwd here using
> request.user.password it is displaying
> in $$$ format.*
> * # but i need in raw(clear text format)*
> *applyselenium*(username,password*)*
>
> *def applyselenium():*
>   ---
>   --
>
>
> My Views.py:
> ===
> views.py:
> 
> def login_view(request):
> logout(request)
>
> username = password = ''
> redirect_to = request.GET.get('next', '/gspapp/')
>
> form = LoginForm()
>
> if request.POST:
>
> form = LoginForm(request.POST)
>
> username = request.POST['username']
> password = request.POST['password']
>
> user = authenticate(request, username=username, password=password)
>
>
> if user is not None:
> login(request, user)
>
> remember_me = request.POST.get('remember_me', False)
>
> if remember_me == "on":
> ONE_MONTH = 30 * 24 * 60 * 60
> expiry = getattr(settings, "KEEP_LOGGED_DURATION",
> ONE_MONTH)
> request.session.set_expiry(expiry)
> else:
> request.session.set_expiry(0)
>
> return HttpResponseRedirect(redirect_to)
>
> context = {'form': form, 'page_title': page_title,
> 'loginpage_heading': loginpage_heading}
> return render(request, 'login.html', context)
>
>
>
>
> Regards
> N.Dilip Kumar.
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/11a515fc-8b06-4130-8a0d-5ab6c9a21497%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/CA%2Bv0ZYVQUxqqRbKM-2Wbiuia7d5uWFNWTAyuGH200LmnmnK2kg%40mail.gmail.com.


Re: Postgre sql problem

2019-09-10 Thread acema alex
Try to follow these steps;
- Install PostgreSQL,
-install psycopg2 binary version ,
-create the database in the PostgreSQL,
- then go to your settings.py of your project and do these on the database
setting
DATABASES = {
'defaults': {
   'ENGINE': 'Django.db.backends.postgresql_psycopg2',
'NAME': ('DB_NAME'),
'USER': ('DB_USER'),
   'PASSWORD': ('DB_PASS'),
   'HOST' : 'localhost',
   'PORT': '5432',
}
}
Wish you the best in Codding.



On Tue, Sep 10, 2019 at 5:34 PM Team Infinity 
wrote:

> You must have postresql installed so as to install psycopg2 :)
>
> On Saturday, September 7, 2019 at 1:34:31 AM UTC+5:45, Elmaco7 wrote:
>>
>> *Hello, I'm trying to use Postresql with my django project, but when i
>> try to install psycopg2(with this command 'pip3 install psycopg2')  this
>> problem appears:*
>>
>> Collecting psycopg2
>>   Using cached
>> https://files.pythonhosted.org/packages/5c/1c/6997288da181277a0c29bc39a5f9143ff20b8c99f2a7d059cfb55163e165/psycopg2-2.8.3.tar.gz
>> Building wheels for collected packages: psycopg2
>>   Building wheel for psycopg2 (setup.py) ... error
>>   ERROR: Command errored out with exit status 1:
>>command: /home/user/myproject/myprojectenv/bin/python3 -u -c 'import
>> sys, setuptools, tokenize; sys.argv[0] =
>> '"'"'/tmp/pip-install-t391_oat/psycopg2/setup.py'"'"';
>> __file__='"'"'/tmp/pip-install-t391_oat/psycopg2/setup.py'"'"';f=getattr(tokenize,
>> '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"',
>> '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))'
>> bdist_wheel -d /tmp/pip-wheel-mkc6kj2i --python-tag cp36
>>cwd: /tmp/pip-install-t391_oat/psycopg2/
>>   Complete output (40 lines):
>>   running bdist_wheel
>>   running build
>>   running build_py
>>   creating build
>>   creating build/lib.linux-x86_64-3.6
>>   creating build/lib.linux-x86_64-3.6/psycopg2
>>   copying lib/pool.py -> build/lib.linux-x86_64-3.6/psycopg2
>>   copying lib/_range.py -> build/lib.linux-x86_64-3.6/psycopg2
>>   copying lib/_lru_cache.py -> build/lib.linux-x86_64-3.6/psycopg2
>>   copying lib/sql.py -> build/lib.linux-x86_64-3.6/psycopg2
>>   copying lib/extensions.py -> build/lib.linux-x86_64-3.6/psycopg2
>>   copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.6/psycopg2
>>   copying lib/errorcodes.py -> build/lib.linux-x86_64-3.6/psycopg2
>>   copying lib/tz.py -> build/lib.linux-x86_64-3.6/psycopg2
>>   copying lib/extras.py -> build/lib.linux-x86_64-3.6/psycopg2
>>   copying lib/_json.py -> build/lib.linux-x86_64-3.6/psycopg2
>>   copying lib/errors.py -> build/lib.linux-x86_64-3.6/psycopg2
>>   copying lib/compat.py -> build/lib.linux-x86_64-3.6/psycopg2
>>   copying lib/__init__.py -> build/lib.linux-x86_64-3.6/psycopg2
>>   running build_ext
>>   building 'psycopg2._psycopg' extension
>>   creating build/temp.linux-x86_64-3.6
>>   creating build/temp.linux-x86_64-3.6/psycopg
>>   x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g
>> -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time
>> -D_FORTIFY_SOURCE=2 -fPIC -DPSYCOPG_VERSION=2.8.3 (dt dec pq3 ext lo64)
>> -DPG_VERSION_NUM=100010 -DHAVE_LO64=1 -I/usr/include/python3.6m
>> -I/home/user/myproject/myprojectenv/include/python3.6m -I.
>> -I/usr/include/postgresql -I/usr/include/postgresql/10/server -c
>> psycopg/psycopgmodule.c -o
>> build/temp.linux-x86_64-3.6/psycopg/psycopgmodule.o
>> -Wdeclaration-after-statement
>>   In file included from psycopg/psycopgmodule.c:27:0:
>>   ./psycopg/psycopg.h:34:10: fatal error: Python.h: No such file or
>> directory
>>#include 
>> ^~
>>   compilation terminated.
>>
>>   It appears you are missing some prerequisite to build the package from
>> source.
>>
>>   You may install a binary package by installing 'psycopg2-binary' from
>> PyPI.
>>   If you want to install psycopg2 from source, please install the packages
>>   required for the build and try again.
>>
>>   For further information please check the 'doc/src/install.rst' file
>> (also at
>>   ).
>>
>>   error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
>>   
>>   ERROR: Failed building wheel for psycopg2
>>   Running setup.py clean for psycopg2
>> Failed to build psycopg2
>> Installing collected packages: psycopg2
>>   Running setup.py install for psycopg2 ... error
>> ERROR: Command errored out with exit status 1:
>>  command: /home/user/myproject/myprojectenv/bin/python3 -u -c 'import
>> sys, setuptools, tokenize; sys.argv[0] =
>> '"'"'/tmp/pip-install-t391_oat/psycopg2/setup.py'"'"';
>> __file__='"'"'/tmp/pip-install-t391_oat/psycopg2/setup.py'"'"';f=getattr(tokenize,
>> '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"',
>> '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))'
>> install 

Django Admin autocomplete with diacritic support (transliteration / accent support)

2019-07-15 Thread Alex Scott
Hello,

I'm using the built-in autocomplete for my admin section which I believe 
uses the Select2 <https://select2.org/> package.  In the documentation of 
Select2 <https://select2.org/i18n#transliteration-support-diacritics>, it 
says diacritic-modified letters will be translated into ASCII counterparts 
by default.  They give a nice example there.

But that doesn't seem to be the case in the Django admin.  I type in "bene" 
and it doesn't match bénédictine.

Any help to fix this would be appreciated!

Thanks,
Alex

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


Re: Import circular

2019-06-07 Thread 'Alex Mesias Diaz Toro' via Django users
Thanks for the information.

El jue., 6 jun. 2019 a las 16:29, Fabio O da silva ()
escribió:

> not
>
>
>
> [image: Mailtrack]
> <https://mailtrack.io?utm_source=gmail_medium=signature_campaign=signaturevirality5;>
>  Remetente
> notificado por
> Mailtrack
> <https://mailtrack.io?utm_source=gmail_medium=signature_campaign=signaturevirality5;>
>  06/06/19,
> 06:28:46 PM
>
> On Thu, Jun 6, 2019 at 5:25 PM 'Alex Mesias Diaz Toro' via Django users <
> django-users@googlegroups.com> wrote:
>
>> Hi Fabio,
>> Did you solve this problem?
>> Ty
>>
>> El jue., 6 jun. 2019 a las 12:12, Fabio O da silva (<
>> fabio7silv...@gmail.com>) escribió:
>>
>>> urls.py
>>>
>>>
>>>
>>> [image: Mailtrack]
>>> <https://mailtrack.io?utm_source=gmail_medium=signature_campaign=signaturevirality5;>
>>>  Remetente
>>> notificado por
>>> Mailtrack
>>> <https://mailtrack.io?utm_source=gmail_medium=signature_campaign=signaturevirality5;>
>>>  06/06/19,
>>> 02:11:53 PM
>>>
>>> On Thu, Jun 6, 2019 at 11:47 AM Joe Reitman 
>>> wrote:
>>>
>>>> Can you post your views.py, urls.py and template?
>>>>
>>>> On Thursday, June 6, 2019 at 9:18:22 AM UTC-5, Fabio O da silva wrote:
>>>>>
>>>>> django.core.exceptions.ImproperlyConfigured: The included URLconf
>>>>> 'simplemooc.urls' does not appear to have any patterns in it. If you see
>>>>> valid patterns in the file then the issue is probably caused by a circular
>>>>> import.
>>>>>
>>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Django users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to django-users+unsubscr...@googlegroups.com.
>>>> To post to this group, send email to django-users@googlegroups.com.
>>>> Visit this group at https://groups.google.com/group/django-users.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/django-users/480664b9-d779-419d-8cbe-c4ea2aadb8a4%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/django-users/480664b9-d779-419d-8cbe-c4ea2aadb8a4%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/CAFZF8WdSdWVQpN7HeTVNyMXoj%3DXhPa8ryx2bsMW3HeiQB8JOHQ%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAFZF8WdSdWVQpN7HeTVNyMXoj%3DXhPa8ryx2bsMW3HeiQB8JOHQ%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/CAGSrrc6g2NMugAv8Q2%2B7Sk0r_6nfEN9X%3DEXqTKA%2BFaOn4b-cYA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAGSrrc6g2NMugAv8Q2%2B7Sk0r_6nfEN9X%3DEXqTKA%2BFaOn4b-cYA%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 w

Re: Import circular

2019-06-06 Thread 'Alex Mesias Diaz Toro' via Django users
Hi Fabio,
Did you solve this problem?
Ty

El jue., 6 jun. 2019 a las 12:12, Fabio O da silva ()
escribió:

> urls.py
>
>
>
> [image: Mailtrack]
> 
>  Remetente
> notificado por
> Mailtrack
> 
>  06/06/19,
> 02:11:53 PM
>
> On Thu, Jun 6, 2019 at 11:47 AM Joe Reitman  wrote:
>
>> Can you post your views.py, urls.py and template?
>>
>> On Thursday, June 6, 2019 at 9:18:22 AM UTC-5, Fabio O da silva wrote:
>>>
>>> django.core.exceptions.ImproperlyConfigured: The included URLconf
>>> 'simplemooc.urls' does not appear to have any patterns in it. If you see
>>> valid patterns in the file then the issue is probably caused by a circular
>>> import.
>>>
>>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/480664b9-d779-419d-8cbe-c4ea2aadb8a4%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/CAFZF8WdSdWVQpN7HeTVNyMXoj%3DXhPa8ryx2bsMW3HeiQB8JOHQ%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/CAGSrrc6g2NMugAv8Q2%2B7Sk0r_6nfEN9X%3DEXqTKA%2BFaOn4b-cYA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Watch "Django on pythonanywhere." on YouTube

2019-06-06 Thread Alex Kimeu
https://youtu.be/3B2yALSpqFg

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


Re: python manage.py makemirations

2019-05-29 Thread Alex Kimeu
You have to add your app in the settings.py file then migrate.

On Wed, 29 May 2019, 21:22 Robert Wahoo,  wrote:

> Regardless, it’s not an issue. Just migrate
>
>
>
>
>
> *From: *"django-users@googlegroups.com" 
> on behalf of sagar ninave 
> *Reply-To: *"django-users@googlegroups.com"  >
> *Date: *Wednesday, May 29, 2019 at 2:17 PM
> *To: *Django users 
> *Subject: *python manage.py makemirations
>
>
>
> i have created new project and i am defining model and doing makemigratins
> but it is showing no changes detected what is problem i don't understand
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e30905f2-77c4-4b07-9d75-47f9d645a1e0%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/BL0PR01MB4354D13EBF33AE997483EE3DF41F0%40BL0PR01MB4354.prod.exchangelabs.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/CACYP3VE7HQ%2BBiurmQH1BMtKTFWqgaEhG2sbT109%2BMguoNXsPaw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: python manage.py makemirations

2019-05-29 Thread Alex Kimeu
That's ok. There's no any problem. Just go ahead and migrate.

On Wed, 29 May 2019, 21:18 Robert Wahoo,  wrote:

> Did you make model changes?
>
>
>
> *From: *"django-users@googlegroups.com" 
> on behalf of sagar ninave 
> *Reply-To: *"django-users@googlegroups.com"  >
> *Date: *Wednesday, May 29, 2019 at 2:17 PM
> *To: *Django users 
> *Subject: *python manage.py makemirations
>
>
>
> i have created new project and i am defining model and doing makemigratins
> but it is showing no changes detected what is problem i don't understand
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e30905f2-77c4-4b07-9d75-47f9d645a1e0%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/BL0PR01MB4354271DF09678BD7C241D00F41F0%40BL0PR01MB4354.prod.exchangelabs.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/CACYP3VFbkf9bWvtWgQe9oCFuBJ-mP49vJbfYc__x5X4Uw5uzdQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Rails to Django Application Architecture Question

2019-05-24 Thread Alex Heyden
What you're describing is how you'd lay out the models in an app. It sounds
like you may have one Django app. If I were writing this in Django, I might
try to spin the workflow and task logic off into its own application if I
thought that the core ideas of users and projects might feed some other bit
of logic elsewhere, but YAGNI may apply.

On Fri, May 24, 2019 at 12:19 PM Steve R  wrote:

> Hi All -
>
> I am a new Django user, coming from RoR. I am having some difficulty
> wrapping my head around the whole 'apps' thing.
>
> Here is my specific use case, and I would appreciate feedback on if I am
> thinking about this correctly, and if not, how to think about it.
>
> I have a project management application I built in RoR that I am
> reimplementing in Django.
>
> A User has one or more Projects, each Project has one or more Workflows,
> and each Workflow has one or more Tasks. Tasks are assigned to users, who
> may or may not be the Project owner.
>
> In Django, a User would be an app, but...
>
> Would a Project be an app, with all the functionality of Workflow and Task
> below it? Separate apps 'feels' wrong, because a task is such a minor
> element (for example), but if I squint, I could see why someone might want
> a Task for something else.
>
> Or
>
> Would I have an app each for Projects, Workflows and Tasks, then set up
> logic linking the apps together?
>
> I thing the question for me is, at what point are the reusable apps in
> Django intended to be independent - I get the impression, the answer is
> 'wherever possible', but does that apply even to very small apps, as Task
> would be?
>
> Thanks in advance for your insight.
>
> SR
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/eed74b23-f8a7-44ee-8e9f-bc19a56e50c0%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%2Bv0ZYV7NseBC69JdDocz_pC%2BZcoGEu7Q7q5RhfOcAMu9j6jVA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Model Forms.

2019-05-17 Thread Alex Kimeu
Thanks. Makes sense. Let me try it. Thanks.

On Fri, 17 May 2019, 14:18 Joe Reitman,  wrote:

> In your template you can identify each field by its name and use a table
> to render them in columns. e.g.
>
> table
>   table row
> table data {{ form.username }}
> table data {{ form.password }}
>
> On Friday, May 17, 2019 at 2:23:14 AM UTC-5, kimeualexis wrote:
>>
>> Hello, guys.
>> Is there a way to lay out Django Model form fields across the Browser
>> rather than top-down?
>>
>> Kindly assist.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/91849286-5271-48be-ae7d-b90c5ab59ea5%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/CACYP3VEqNWAukvQSf1DJOZ784oODbTxGxn0dZ71yOP6DNKzoPg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Info

2019-05-06 Thread Alex Heyden
When a message goes out to here, it's sent to everyone on the group. When
you reply to it, it also goes out to the group. What you're seeing is
someone's auto-reply. I couldn't say for sure if it's a malicious attempt
to passively get some money or if it's someone not realizing his personal
spam filter is spamming a bunch of people in the group. Either way, just
block the sender and ignore it.

On Mon, May 6, 2019 at 1:49 PM Soumen Khatua 
wrote:

> Then why one bit bounce application is coming everytime after sending any
> problem and saying if you will pay the we will allow your request to our
> inbox.
>
> Thanks buddy for help.
>
>
>
> On Mon, 6 May 2019, 23:25 charan,  wrote:
>
>> No folk
>>
>> No need to pay
>>
>>
>>
>> Sent from Mail  for
>> Windows 10
>>
>>
>>
>> *From: *Soumen Khatua 
>> *Sent: *06 May 2019 16:52
>> *To: *django-users@googlegroups.com
>> *Subject: *Info
>>
>>
>>
>> Hi Folks,
>>
>>
>>
>> Should I need to pay for asking questions or problem in this group?
>>
>>
>>
>>
>>
>> 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/CAPUw6WaUeKf%3D9%2BAgkXbek46gNhL7dWzSOZHdk6pTXPrvam8gVA%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/5cd0752a.1c69fb81.cdc85.081b%40mx.google.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAPUw6WaRX4GwZ2ru7-T5u9%2BQRntpEq6rLYg1EYuDFV_0KgApBw%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%2Bv0ZYWD62dqujZoQ7EbhFZvXXCfNeFhT%2BbHnQuQiBXBE9kyFg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Website slowed down drasticaly

2019-05-03 Thread Alex Heyden
Definitely echoing Scott's sentiment here. Start with what changed.

In my personal experience, if the answer is "nothing," you can narrow it
down very quickly. Start by reloading with the browser network monitor in
the foreground. If the first response comes back very quickly, Django
itself is off the hook and you proceed with front-end optimizations. If it
doesn't, and you're really sure that no one changed anything (check top or
the process manager to make sure there's nothing new running!), it's your
database. You need your data set to be shrunk, indices to be improved, or
queries to be optimized. Django Debug Toolbar will help you see which of
these apply to you. If you see hundreds of queries where you expected just
one or two, look for any model reference in a loop, including template code.

If you'd like extra reassurance that that's the problem, point your config
to an empty database, run the migrations, and see the difference.

On Fri, May 3, 2019 at 10:59 AM Scott Miesbauer 
wrote:

> I apologize if I missed it but did someone find out what started happening
> in Feb that might have some impact on the performance lag?
>
> The very first thing I ask when troubleshooting is “What changed?”
>
> So what changed in your environment in February?  Other teams changes?
> Application? Network?
>
> If you find what changed then the solution might end up being right there
> in front of you.
>
> Good luck!
>
> Sent from my iPhone
>
> On May 3, 2019, at 1:26 AM, Saurabh Adhikary 
> wrote:
>
> Hello Uri,
>
> The project I handle is quite big , so before taking it up as a major
> task, I wish to get it from the experts that is the django version the
> issue or python version or am I missing out on something major.
>
> The issue started to escalate from Feb '19 , after which even a new
> powerful server could'nt give us good performance.
> *Now after adding extra indexes , at least the website is loading.*
>
> We are still not sure if we can handle around 5K - 10K concurrent request
> with a 128GB SSD server.
>
> On Thursday, 2 May 2019 18:11:05 UTC+5:30, Uri Even-Chen wrote:
>>
>> Why don't you upgrade Django at least to 1.11? Django 1.8 extended
>> support ended last year.
>>
>> https://www.djangoproject.com/download/
>> אורי
>> u...@speedy.net
>>
>>
>> On Thu, May 2, 2019 at 2:39 PM Saurabh Adhikary 
>> wrote:
>>
>>> Hello ,
>>>
>>> I'm using Django version 1.8.1  and Python version 2.7.12 . Suddenly
>>> since Feb '19 there has been a drastic decrease in my website's response
>>> rate.
>>> For sure , there has been some minor increase in the no of hits, but the
>>> performance is too bad.
>>>
>>> Initially , the thought came that the hardware of the server was old ,
>>> so a new server with high configuration was bought.
>>> We have done the new indexing also on it.
>>> Still the sought for a higher performance is awaited.
>>>
>>>
>>> Is it that the Django support for 1.8.1 or Python support for 2.7.12 has
>>> reduced and that is casing the website to slow down or I am missing out on
>>> something ?
>>> Kindly 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...@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/238a6da2-8f34-4b8b-939c-e20d4306545b%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/08bc1409-322e-41ce-a94b-5dd9db888e86%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> 

Re: In the browser it looks ugly, why?

2019-04-06 Thread Alex Heyden
Short answer, it's giving you exactly what you asked for: the query set
inside  tags.
What you probably want is to loop through the ingredients and place them
inside  tags. Something like:

{% for ingredient in object.ingredientes.all %}
{{ ingredient.cantidad }} {{ ingredient.nombre }}
{% endfor %}


On Sat, Apr 6, 2019 at 4:28 PM Barkalez XX  wrote:

> Why does this happen to me?
>
>
>
>  https://pasteboard.co/I8VU79E.png
>
>
>
>  html:https://dpaste.de/AVti
>
>
>  views.py:https://dpaste.de/44Jz
>
>
>  models.py: https://dpaste.de/Dfwy
>
>
>
> I want to list all the ingredients in that recipe and make it look
> beautiful.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/07ff0403-914f-46ae-a418-6c42a9de8ac2%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%2Bv0ZYUMiGD0ZWXwWXOih%2BbGuWoX8nSDAKkC5V75scuDcs2JhQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: google chrome extension

2019-04-03 Thread Alex Chiaranda
Greetings,

for Chrome Extension, you must use Javascript, or Javascript + Native Code 
(compiling for the target platform, and distributing it with the 
extension). So the quick answer is "You shouldn't do it", but it might be 
possible. I don't think it would be approved thought, because you would 
have to distribute a python interpreter with you extension, the extension 
size would be huge.


However, if your extension is meant to communicate with a server side 
application, this part can be whatever you want, providing a REST API for 
your extension.

Hope it helps !

Regards,

Alex


On Wednesday, April 3, 2019 at 8:33:20 AM UTC-3, Abhineet Baranwal wrote:
>
>
> *Can i create a chrome extension in django or flask ? I have already 
> created an extension in javascript but i didn't know how to start creating 
> it in django . Can anyone tell me how to do it with some example?*
>

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


Re: Connection Reset by Peer

2019-03-11 Thread Alex Snyder
There's no browser involved. Just another server. If I manually post it 
works fine.

On Monday, March 11, 2019 at 2:17:22 PM UTC-5, Jani Tiainen wrote:
>
> Hi.
>
> Usually error means that client (browser) terminated connection before 
> request was completely handled and returned to client.
>
>
>
>
> ma 11. maalisk. 2019 klo 17.58 Alex Snyder  > kirjoitti:
>
>> Hello,
>> I'm working on a webhook receiver and all was working fine the other day. 
>> Now I'm receiving connection reset by peer errors. The data being posted is 
>> getting received so and I can't figure out why it all of a sudden started 
>> giving errors.
>>
>> Could it be that connections are coming in too quickly? It didn't have a 
>> problem with it before.
>>
>> I'm getting the following:
>> Exception happened during processing of request from ('redacted', 58812)
>> Traceback (most recent call last):
>>   File 
>> "/Users/myuser/anaconda3/envs/myenv/lib/python3.7/socketserver.py", line 
>> 650, in process_request_thread
>> self.finish_request(request, client_address)
>>   File 
>> "/Users/myuser/anaconda3/envs/myenv/lib/python3.7/socketserver.py", line 
>> 360, in finish_request
>>
>> self.RequestHandlerClass(request, client_address, self)
>>   File 
>> "/Users/myuser/anaconda3/envs/myenv/lib/python3.7/socketserver.py", line 
>> 720, in __init__
>> self.handle()
>>   File 
>> "/Users/myuser/anaconda3/envs/myenv/lib/python3.7/site-packages/django/core/servers/basehttp.py",
>>  
>> line 171, in han
>> dle
>> self.handle_one_request()
>>   File 
>> "/Users/myuser/anaconda3/envs/myenv/lib/python3.7/site-packages/django/core/servers/basehttp.py",
>>  
>> line 179, in han
>> dle_one_request
>> self.raw_requestline = self.rfile.readline(65537)
>>   File "/Users/myuser/anaconda3/envs/myenv/lib/python3.7/socket.py", line 
>> 589, in readinto
>> return self._sock.recv_into(b)
>> ConnectionResetError: [Errno 54] Connection reset by peer
>>
>>
>> My View
>>
>> @require_POST
>> @csrf_exempt
>> def computer_checkin(request):
>> if request.method == 'POST':
>> #ip = get_client_ip(request)
>> print(request)
>> #request_data = json.loads(request.body.decode("utf-8"))
>> #print(ip)
>> return HttpResponse(201)
>> else:
>> return HttpResponse(400)
>> # if ip in allowed_ip:
>> # #print(request_data['webhook']['webhookEvent'])
>> # return HttpResponse('Pong')
>> # else
>> # return HttpResponseForbidden('Permissions denied')
>>
>>
>> This is what the sending server gives for an error:
>> Exception while trying to post event to 
>> http://redacted:8000/webhooks/ComputerCheckIn - I/O error on POST 
>> request for "http://redacted:8000/webhooks/ComputerCheckIn":Connect to 
>> redacted:8000 [/redacted] failed: connect timed out; nested exception is 
>> org.apache.http.conn.ConnectTimeoutException: Connect to redacted:8000 
>> [/redacted] failed: connect timed 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...@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/343df769-44f3-4316-882e-a701280b358a%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/343df769-44f3-4316-882e-a701280b358a%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/12b526ed-da4c-4473-b813-7bbb2c787dfb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Connection Reset by Peer

2019-03-11 Thread Alex Snyder
Hello,
I'm working on a webhook receiver and all was working fine the other day. 
Now I'm receiving connection reset by peer errors. The data being posted is 
getting received so and I can't figure out why it all of a sudden started 
giving errors.

Could it be that connections are coming in too quickly? It didn't have a 
problem with it before.

I'm getting the following:
Exception happened during processing of request from ('redacted', 58812)
Traceback (most recent call last):
  File "/Users/myuser/anaconda3/envs/myenv/lib/python3.7/socketserver.py", 
line 650, in process_request_thread
self.finish_request(request, client_address)
  File "/Users/myuser/anaconda3/envs/myenv/lib/python3.7/socketserver.py", 
line 360, in finish_request

self.RequestHandlerClass(request, client_address, self)
  File "/Users/myuser/anaconda3/envs/myenv/lib/python3.7/socketserver.py", 
line 720, in __init__
self.handle()
  File 
"/Users/myuser/anaconda3/envs/myenv/lib/python3.7/site-packages/django/core/servers/basehttp.py",
 
line 171, in han
dle
self.handle_one_request()
  File 
"/Users/myuser/anaconda3/envs/myenv/lib/python3.7/site-packages/django/core/servers/basehttp.py",
 
line 179, in han
dle_one_request
self.raw_requestline = self.rfile.readline(65537)
  File "/Users/myuser/anaconda3/envs/myenv/lib/python3.7/socket.py", line 
589, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [Errno 54] Connection reset by peer


My View

@require_POST
@csrf_exempt
def computer_checkin(request):
if request.method == 'POST':
#ip = get_client_ip(request)
print(request)
#request_data = json.loads(request.body.decode("utf-8"))
#print(ip)
return HttpResponse(201)
else:
return HttpResponse(400)
# if ip in allowed_ip:
# #print(request_data['webhook']['webhookEvent'])
# return HttpResponse('Pong')
# else
# return HttpResponseForbidden('Permissions denied')


This is what the sending server gives for an error:
Exception while trying to post event to 
http://redacted:8000/webhooks/ComputerCheckIn - I/O error on POST request 
for "http://redacted:8000/webhooks/ComputerCheckIn":Connect to 
redacted:8000 [/redacted] failed: connect timed out; nested exception is 
org.apache.http.conn.ConnectTimeoutException: Connect to redacted:8000 
[/redacted] failed: connect timed 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/343df769-44f3-4316-882e-a701280b358a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ModuleNotFoundError: No module named 'sample,'

2019-03-07 Thread Alex Kimeu
Do you have a model named Sample in your models.py file of your app??

On Thu, 7 Mar 2019, 13:00 Robin Riis,  wrote:

> 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.
>

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


Re:

2019-02-23 Thread Alex Kimeu
I think the issue is in your models.py . Kindly share your polls models.

On Fri, 22 Feb 2019, 16:18 Vivek Bhavsar,  wrote:

> You should put the dot(period) after the polls
> For eg:. python manage.py makemigrations polls .
>
> NOTE: There is space between polls and dot(period)
>
>
> Thanks
>
> On Feb 21, 2019 1:40 PM, "bhushan patil"  wrote:
>
> I am running the command 'python manage.py makemigrations polls' but it's
> showing that django.db.models has no attribute model.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAJ%3Ds-Myumw2o8mxYcbjQXjG0Zy%2BVao6kPjmL7dxaajaGDG5MsA%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/CAMvtZS7V7fGEfyiifdhcAydi_Y16ByrW1VUL3PkA_PLLpKsymw%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/CACYP3VHMnRti%3DaDRzucn2fgq9VtAoC0-rynrTBLcHJhec6w%3DyA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: TemplateDoesNotExist at /vmail/inbox/

2019-02-04 Thread Alex Kimeu
It means the template you are trying to render is either not created or not
in the location where Django expects to be. Django does not see the
template you are trying to render.

On Tue, 5 Feb 2019, 04:28 senthu nithy  I am doing a project using Django. I got this error. I don't understand
> what this error really means.
> Thanks in advance!
> K.Senthuja
> Undergraduate Student (UOJ),
> https://www.linkedin.com/in/senthuja/
> https://medium.com/@senthujakarunanithy
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALEaTU5PQaiOuekpgJS7B6gQkZeQEz-x8--RMmLvC9mjJDnFNw%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/CACYP3VHVfVCm7LHqt7x6bNN78%2BwjXnVaC4YQEzaXxQygwz1HFg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: AES Encryption

2019-01-19 Thread Alex Heyden
PyCrypto would be the Python-side library if you wanted to handle this in
application code, but personally, I'd prefer to handle it in my database of
choice. A lot of us use Postgres, and there's a django-pgcrypto library for
that.

That being said, reversible ciphers are hard to do meaningfully. You'd need
some sort of attack vector that includes getting unauthorized access to the
database, but not via the authorized application, an authorized user, or
access to the machine where the keys are readable. Often enough, that means
you messed up the auth rules on your database, RBAC in your application
code, or your OS read permissions, and you can't cipher your way out of
those issues. A lot of that isn't really Django-centric, and because it's
so rare to have a risk that's mitigated like that, most developers just
don't do it, and not just out of laziness.

What you might actually want is row-level read access, and something like
django-guardian would help you manage object-level permissions in the admin
screen.

If you're looking for further reading, OWASP really is the gold standard
for web security information. The site looks like amateur hour, but it's
not maintained by UI experts, it's maintained by security experts. It's
practically required reading in most security-conscious corporate
environments.

And finally, when in doubt, throw it away. It's a lot harder to have a
breach of data you didn't store anywhere.

On Sat, Jan 19, 2019 at 8:59 PM  wrote:

> Is there a blog or website dedicated to helping Django developers handle
> PII? I'd like to use AES 256 encryption to store all of our fields but have
> no guidance on the best practices for implementing security measures.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/64a50014-df54-4ec7-a4b1-f60879385c15%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%2Bv0ZYWCuj5%3DjH8hmC%2BV2cPY%2BxFNP8go6dNnW%2BpTsRLjpPVgkw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re:

2019-01-19 Thread Alex Heyden
You missed the +unsubscribe in the email name to accomplish that. From the
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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/BL0PR0102MB3524B2BC6D8F8BBF9DC7B624F39E0%40BL0PR0102MB3524.prod.exchangelabs.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.


On Sat, Jan 19, 2019 at 6:34 PM Vikash Verma 
wrote:

> Please remove me
>
> Get Outlook for iOS 
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/BL0PR0102MB3524B2BC6D8F8BBF9DC7B624F39E0%40BL0PR0102MB3524.prod.exchangelabs.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%2Bv0ZYVBC1i%2BZaMjkg8qotKE4XvUE6jwFMpddnpDoncAjJOpCw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: User profile

2019-01-17 Thread Alex Kimeu
First you need to create a model for the User Profile.

On Thu, 17 Jan 2019, 17:49 ANi  Do you mean you want to create your custom user model?
> Two ways to do it,
> 1. create a profile model and use foreign key to the user model that
> Django provided.
> 2. create a custom user model like this
> https://wsvincent.com/django-custom-user-model-tutorial/
>
>
> senthu nithy於 2019年1月17日星期四 UTC+8下午8時47分41秒寫道:
>>
>> I am new Django framework. I want to create a user profile for my app.
>> But i start to create the user profile then i direct to create Admin
>> profile which is already created in Django. I want to create a user
>> Profile. Can you direct 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/94a197bc-1440-43cf-9af7-0c31da09cf4b%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/CACYP3VG4PsTMPd7Sj0LGkbqNUdU135K2D9Ven-VXV91vMiJhTw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Log into existing Django site

2019-01-16 Thread Alex Heyden
The last Mac I owned had 512kB of memory and no hard drive, but it did have
that newfangled 3.5" floppy drive.

The wider internet probably knows. You might try
https://accc.uic.edu/answer/how-do-i-use-ssh-and-sftp-mac-os-x

On Wed, Jan 16, 2019 at 9:41 AM TheShoff  wrote:

> Also, how would I access the server with SSH (I have a MAC and can use
> Terminal)? I have already set up private and public keys and provided the
> public key to the hosting provider, however I used FTP to login into the
> server. Do you know how I would go about logging in with Terminal?
>
> On Tuesday, January 15, 2019 at 7:59:24 PM UTC-7, Alex Heyden wrote:
>>
>> The server that is hosting the site. The one you're trying to FTP onto.
>> Your quality of life will be greatly improved if you can SSH onto the
>> machine rather than using FTP, because the actual server software that
>> hosts Python processes usually needs to be restarted. It's unlikely (but
>> not unheard of) that you have anything like CPanel controlling a Django
>> instance. It's *probably* going to be GUnicorn or uWSGI, but there's a
>> half dozen options on that front too.
>>
>> I know that all sounds really wishy-washy, but I don't want to mislead
>> you accidentally. The overall architecture isn't that different from a PHP
>> app, but you might not recognize the configuration and file server
>> technologies being used. The further along you get, the easier it'll be for
>> people to figure out what's going on and help you at least figure out what
>> files need to be changed.
>>
>> On Tue, Jan 15, 2019 at 6:39 PM TheShoff  wrote:
>>
>>> Thank you for your response! By host machine, do you mean the machine
>>> (computer) the site was created on or the server that is hosting the site?
>>> I have always worked in PHP and HTML and am used to downloading/uploading
>>> files to the server to make changes.
>>>
>>> On Tuesday, January 15, 2019 at 2:30:44 PM UTC-7, Alex Heyden wrote:
>>>>
>>>> Assuming you're familiar with web technologies in general, you'd make
>>>> these changes on the host machine itself, ideally through the same
>>>> mechanism that handles deployments of source code. Code for application
>>>> logic is often in files called "views.py" or similar, and the HTML will be
>>>> in a folder called "templates" by convention, either near the top of the
>>>> code or contained within the directories (called "applications" in Django)
>>>> that hold server code.
>>>>
>>>> The FTP client is probably the closest you've gotten so far, but
>>>> "denied access" can mean anything from permissions to authentication
>>>> issues. You might want to start there.
>>>>
>>>> On Tue, Jan 15, 2019 at 3:04 PM TheShoff  wrote:
>>>>
>>>>> I am trying to add reCaptcha to an existing Django website that was
>>>>> created by a company we no longer work with. I have server access to the
>>>>> website, but cannot figure out how to edit the files or add the reCaptcha
>>>>> form (I tried to manually add the code into the HTML and .py files and
>>>>> uploading it on my FTP client and was denied access). Do I need to login 
>>>>> to
>>>>> the website using Python to add the reCaptcha form? If so, can someone 
>>>>> tell
>>>>> me how? I am not looking to make any other changes at this time.
>>>>>
>>>>> ***Please note I am new to Django and trying to figure out how it
>>>>> works.***
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed 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/da98679f-180b-4433-9c94-faa13e27ec3d%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/django-users/da98679f-180b-4433-9c94-faa13e27ec3d%40googlegroups.com?utm_medium=email_source=footer>
>>>>> .
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>> --
>>> You received this message

Re: Log into existing Django site

2019-01-15 Thread Alex Heyden
The server that is hosting the site. The one you're trying to FTP onto.
Your quality of life will be greatly improved if you can SSH onto the
machine rather than using FTP, because the actual server software that
hosts Python processes usually needs to be restarted. It's unlikely (but
not unheard of) that you have anything like CPanel controlling a Django
instance. It's *probably* going to be GUnicorn or uWSGI, but there's a half
dozen options on that front too.

I know that all sounds really wishy-washy, but I don't want to mislead you
accidentally. The overall architecture isn't that different from a PHP app,
but you might not recognize the configuration and file server technologies
being used. The further along you get, the easier it'll be for people to
figure out what's going on and help you at least figure out what files need
to be changed.

On Tue, Jan 15, 2019 at 6:39 PM TheShoff  wrote:

> Thank you for your response! By host machine, do you mean the machine
> (computer) the site was created on or the server that is hosting the site?
> I have always worked in PHP and HTML and am used to downloading/uploading
> files to the server to make changes.
>
> On Tuesday, January 15, 2019 at 2:30:44 PM UTC-7, Alex Heyden wrote:
>>
>> Assuming you're familiar with web technologies in general, you'd make
>> these changes on the host machine itself, ideally through the same
>> mechanism that handles deployments of source code. Code for application
>> logic is often in files called "views.py" or similar, and the HTML will be
>> in a folder called "templates" by convention, either near the top of the
>> code or contained within the directories (called "applications" in Django)
>> that hold server code.
>>
>> The FTP client is probably the closest you've gotten so far, but "denied
>> access" can mean anything from permissions to authentication issues. You
>> might want to start there.
>>
>> On Tue, Jan 15, 2019 at 3:04 PM TheShoff  wrote:
>>
>>> I am trying to add reCaptcha to an existing Django website that was
>>> created by a company we no longer work with. I have server access to the
>>> website, but cannot figure out how to edit the files or add the reCaptcha
>>> form (I tried to manually add the code into the HTML and .py files and
>>> uploading it on my FTP client and was denied access). Do I need to login to
>>> the website using Python to add the reCaptcha form? If so, can someone tell
>>> me how? I am not looking to make any other changes at this time.
>>>
>>> ***Please note I am new to Django and trying to figure out how it
>>> works.***
>>>
>>> --
>>> You received this message because you are subscribed 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/da98679f-180b-4433-9c94-faa13e27ec3d%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/da98679f-180b-4433-9c94-faa13e27ec3d%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/ce4b4cc7-0082-4474-a6c3-d393665f6e32%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/ce4b4cc7-0082-4474-a6c3-d393665f6e32%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%2Bv0ZYWmL5FYdhAi63Jx_RKNevEU6CySJWD3SsEZwMnbni14pg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Log into existing Django site

2019-01-15 Thread Alex Heyden
Assuming you're familiar with web technologies in general, you'd make these
changes on the host machine itself, ideally through the same mechanism that
handles deployments of source code. Code for application logic is often in
files called "views.py" or similar, and the HTML will be in a folder called
"templates" by convention, either near the top of the code or contained
within the directories (called "applications" in Django) that hold server
code.

The FTP client is probably the closest you've gotten so far, but "denied
access" can mean anything from permissions to authentication issues. You
might want to start there.

On Tue, Jan 15, 2019 at 3:04 PM TheShoff  wrote:

> I am trying to add reCaptcha to an existing Django website that was
> created by a company we no longer work with. I have server access to the
> website, but cannot figure out how to edit the files or add the reCaptcha
> form (I tried to manually add the code into the HTML and .py files and
> uploading it on my FTP client and was denied access). Do I need to login to
> the website using Python to add the reCaptcha form? If so, can someone tell
> me how? I am not looking to make any other changes at this time.
>
> ***Please note I am new to Django and trying to figure out how it works.***
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/da98679f-180b-4433-9c94-faa13e27ec3d%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%2Bv0ZYV_QbGojTrmAZ3qfh6MY_cUtBbvXmyQiOStK-Gfnn8i5A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django UserForm Help Texts

2019-01-14 Thread Alex Kimeu
from django.shortcuts import render, redirect
from django.contrib.auth.decorators import login_required
from .forms import UserRegisterForm, UserUpdateForm, ProfileUpdateForm
from django.contrib import messages
from .models import Profile
from quiz.models import Question


def register(request):
if request.method == 'POST':
form = UserRegisterForm(request.POST)
if form.is_valid():
form.save()
username = form.cleaned_data.get('username')
messages.success(request, f'Account Created for {username}!')
return redirect('quiz:quiz-index')

else:
form = UserRegisterForm()
return render(request, 'users/register.html', {'form': form})


On Mon, Jan 14, 2019 at 11:39 PM Alex Kimeu  wrote:

> *views.py*
>
>
> On Mon, Jan 14, 2019 at 11:36 PM Nebojsa Hajdukovic <
> nebojsa.zero...@gmail.com> wrote:
>
>> can you show your views.py?
>>
>> пон, 14. јан 2019. у 19:52 kimeualexis  је
>> написао/ла:
>>
>>> Hello, guys.
>>>
>>> Anyone with an idea how to hide help texts in Django User Registration
>>> Form?
>>>
>>> Regards.
>>>
>>> [image: Screenshot from 2019-01-14 21-48-53.png]
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/331219f5-b547-456c-a7c4-759c0574d82b%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/331219f5-b547-456c-a7c4-759c0574d82b%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/CAJ60hW2T%3DVnYyXGwhaFS-SyK5kg7Voi7at9N-c%2BTiGkpJ4EMVg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAJ60hW2T%3DVnYyXGwhaFS-SyK5kg7Voi7at9N-c%2BTiGkpJ4EMVg%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
>
>
> *"It's when nothing happens that anything can happen."*
> *https://kodenaut.github.io/ <https://kodenaut.github.io/>**+
> <https://kodenaut.github.io/>254 723494571*
>
>

-- 


*"It's when nothing happens that anything can happen."*
*https://kodenaut.github.io/ <https://kodenaut.github.io/>**+
<https://kodenaut.github.io/>254 723494571*

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


Re: working fine with sqllite but not showing result in mysql

2019-01-14 Thread Alex Kimeu
Kindly post your urls mappings.

On Mon, Jan 14, 2019 at 10:22 PM tribhuvan kishor <
tribhuvankishor...@gmail.com> wrote:

> yes all things are working fine like post list are working fine
>
> from django.shortcuts import render, get_object_or_404
> from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
> from django.views.generic import ListView
> from .models import Post
>
> def post_list(request):
> object_list = Post.published.all()
> paginator = Paginator(object_list, 3) # 3 posts in each page
> page = request.GET.get('page')
> try:
> posts = paginator.page(page)
> except PageNotAnInteger:
> # If page is not an integer deliver the first page
> posts = paginator.page(1)
> except EmptyPage:
> # If page is out of range deliver last page of results
> posts = paginator.page(paginator.num_pages)
> return render(request,
>   'blog/post/list.html',
>   {'page': page,
>'posts': posts})
>
> # Create your views here.
> def post_detail(request, year, month, day, post):
> post = get_object_or_404(Post, slug=post,
>  status='published',
>  publish__year=year,
>  publish__month=month,
>  publish__day=day)
>
> return render(request,
>   'blog/post/details.html',
>   {'post': post})
>
> class PostListView(ListView):
> queryset = Post.published.all()
> context_object_name = 'posts'
> paginate_by = 3
> template_name = 'blog/post/list.html'
>
> def test_test(request):
> return render(request,'blog/post/test.html')
>
>
> On Tue, Jan 15, 2019 at 12:24 AM Alex Kimeu  wrote:
>
>> Have you configured MySQL correctly?
>>
>> On Mon, Jan 14, 2019 at 9:07 PM tribhuvan kishor <
>> tribhuvankishor...@gmail.com> wrote:
>>
>>> this view is retrieving data with SQlite but not fetching data in
>>> MySQL saying no data found.
>>>
>>>
>>> def post_detail(request, year, month, day, post):
>>> post = get_object_or_404(Post, slug=post,
>>>  status='published',
>>>  publish__year=year,
>>>  publish__month=month,
>>>  publish__day=day)
>>>
>>> return render(request,
>>>   'blog/post/details.html',
>>>   {'post': post})
>>>
>>> --
>>> regards
>>> Tribhuvan Kishor Bhaskar
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CACiphSVVyMgpNmgFj16ROZGqpohaq0fYJKV2bES4D1aVeg1LbA%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CACiphSVVyMgpNmgFj16ROZGqpohaq0fYJKV2bES4D1aVeg1LbA%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> --
>>
>>
>> *"It's when nothing happens that anything can happen."*
>> *https://kodenaut.github.io/ <https://kodenaut.github.io/>**+
>> <https://kodenaut.github.io/>254 723494571*
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CACYP3VGYe96j6vYWYC8-7GCzODUfu8b5xc1qo2Lh6KhHevKgYQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CACYP3VGYe96j6vYWYC8-7GCzODUfu8b5xc1qo2Lh6KhHevKgYQ%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> regards
> Tribhuvan Kishor Bhaskar
>

Re: working fine with sqllite but not showing result in mysql

2019-01-14 Thread Alex Kimeu
Have you configured MySQL correctly?

On Mon, Jan 14, 2019 at 9:07 PM tribhuvan kishor <
tribhuvankishor...@gmail.com> wrote:

> this view is retrieving data with SQlite but not fetching data in
> MySQL saying no data found.
>
>
> def post_detail(request, year, month, day, post):
> post = get_object_or_404(Post, slug=post,
>  status='published',
>  publish__year=year,
>  publish__month=month,
>  publish__day=day)
>
> return render(request,
>   'blog/post/details.html',
>   {'post': post})
>
> --
> regards
> Tribhuvan Kishor Bhaskar
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CACiphSVVyMgpNmgFj16ROZGqpohaq0fYJKV2bES4D1aVeg1LbA%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 


*"It's when nothing happens that anything can happen."*
*https://kodenaut.github.io/ **+
254 723494571*

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


Re: Best way to run a shell script, using input value from Django?

2019-01-02 Thread Alex Heyden
So, a lot of this doesn't have much to do with Django, but I'm not sure how
familiar you are with web server best practices in general, so apologies if
some of this is remedial for you.

If something takes two minutes to finish, you don't want it being handled
on the request handler itself. Split the job off into a separate worker,
then return *something* to the user. Ideally, that something will allow the
user to continue polling for job updates.

Sounds simple, but the details can be obnoxious. First, you have to figure
out how to track the job. Personally, I prefer to not have to watch a
worker directly. I'd rather watch the results come through. For example, if
your script takes two minutes because it's updating a few thousand items
somewhere, I'd rather watch the items change by OS mtime or auto_now on a
model or whatever makes sense in your context. That means less complexity
in my workers and less complexity in my database. You might not be so
lucky. If one user can kick off a dozen or so of these jobs, and they only
do one thing each, you're probably going to have to track Celery workers
individually by sending to the user a job identifier and storing them in
your database with a foreign key out to your User model. Regardless of how
you decide to do it, the job of the initial request handler is to take care
of this piece of the puzzle: how am I going to track this, kick off the
job, send the tracking information to the user.

The script itself is probably pretty easy. A Celery worker using subprocess
from the standard library will be sufficient, with maybe a little bit
watching stdout to figure out how far along the job is if you need to. Have
the worker write its progress to the database row associated with the job,
or use celery-progress if you'd rather use someone else's implementation of
that idea.

In your UI, you'll want some sort of AJAX loop so the user can watch the
job go. This is usually pretty simple too: just an endpoint that queries
the job's status as recorded in the database and returns it without fanfare.

You probably don't want to automatically delete the database entry for the
job once its done, because you don't know if the user was there to see the
end of it. Save that for a periodic task or a response to the user
acknowledging the end of the job run.

On Wed, Jan 2, 2019 at 4:01 PM Chris Robinson  wrote:

>
> Hello,
>
> I'm going to attempt to generalize my question to make this easier to
> answer.
>
> Lets say I have a simple terminal based shell script (e.g.
> multiply_by_two) that takes a number argument, then multiplies that number
> by 2, and returns the result into a result.txt file.
>
> I would enter something like this:
> multiply_by_two -n 6
>
> The -n flag asks what number I would like to multiply by 2. The result of
> this would be a result.txt, containing the number 12 inside.
>
>
> What I would like to do is develop a simple Djano application that
> contains a text field allowing me to input the number 6, then click
> "Submit."
>
> This job will start on the server by running my custom multiply_by_two
> application with my input parameter (6), but when the job is finished and
> the result.txt is available, the browser will automatically download the
> file.
>
> To make this a tad bit more complex, lets say that the job takes 2 minutes
> to run. What would be the best way to monitor the job? Maybe I accidentally
> close the window.
>
> Not looking for anyone to solve this, I'm just new to Django and want to
> know if someone can give me any pointers on where to start. Are there any
> apps existing that will help me not need to write everything from scratch,
> especially if 'monitoring' is needed? Would Celery be ideal for this?
>
> Thanks for any input!
>
> Regards,
> Chris
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/7da4b068-ac58-4c26-a0bc-ed4925f8a4f9%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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

Re:

2019-01-02 Thread Alex Kimeu
Is your server running?

On Wed, Jan 2, 2019 at 6:30 PM Joseph Gichuki 
wrote:

>
>
> Here it is
>
> Sent from Mail  for
> Windows 10
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5c2cce87.1c69fb81.2d099.3b97%40mx.google.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 


*"It's when nothing happens that anything can happen."*
*https://kodenaut.github.io/ **+
254 723494571*

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


Re: Django on IIS

2018-12-17 Thread Alex Heyden
I have recently, and it was equal parts misery and pain. FastCGI via
wfastcgi, as outlined at
http://blog.mattwoodward.com/2016/07/running-django-application-on-windows.html

I also had to downgrade from Python 3.7 to Python 3.6

I wouldn't really consider myself an expert on the subject. All I can say
is that it is possible.

On Mon, Dec 17, 2018 at 5:19 PM Larry Martell 
wrote:

> Anyone have any experience setting up a Django app to work with IIS? I
> have inherited what I was told is a working system, but it's not
> working. Before I post details of my issues and questions I wanted to
> see if anyone here has successfully got a Django app to run with IIS.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CACwCsY7bk-c7Za-PGUbaEkftA8Xxqd%2BaCUPkaQryW-1kXX0_nQ%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%2Bv0ZYVWO5bFTx%3D6im_dLWwPWz1FoDcFVDN9GXREj%3Dp49f2FcA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why does my Django project open the same home page irrespective or which url I type?

2018-11-13 Thread Alex Callaway
Thanks!

On Monday, November 12, 2018 at 7:06:37 PM UTC-8, Jason wrote:
>
> you have an ending slash on your login urls, and no ending slash in your 
> links defined.  try adding a trailing slash
>

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


Why does my Django project open the same home page irrespective or which url I type?

2018-11-12 Thread Alex Callaway
In my urlpatterns in the url.py file of my app, I have two pages:

from django.urls import path, re_path
from django.conf.urls import url
from . import views
from django.contrib.auth.views import LoginView

urlpatterns=[
re_path(r'^$',views.home, name='home'),
path('login/', LoginView.as_view(template_name='accounts/login.html'), name=
'login'),
]

When I visit : `http://127.0.0.1:8000/home` I see whats in my `index.html`. 

But when I visit : 

`http://127.0.0.1:8000/accounts/login` or 
`http://127.0.0.1:8000/accounts/login.html` or 
`http://127.0.0.1:8000/accounts/login/login` or 
`http://127.0.0.1:8000/accounts/login/login/login.html` 

I still see what's in my `index.html`. Wtf?


Ok. I did say in my views.py I have told it to render `home/index.html` 
like this :

def home(request):
return render(request, 'home/index.html')

But I also have this function in views.py as well :


def login(request):
c = {}
c.update(csrf(request))
return render(request, 'accounts/login.html', c)

So what's the problem? Why won't it render `accounts/login.html` page when 
I visit `http://127.0.0.1:8000/accounts/login`

By the way, In my main url.py file in the project, I have url patterns this 
way *(every django project has two urls.py)*:
urlpatterns = [
path('admin/', admin.site.urls),
path('home/', include('clientview.urls')),
path('accounts/login/', include('clientview.urls')),
]

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


Re: TypeError at /users/login/ login() got an unexpected keyword argument 'template_name'

2018-11-12 Thread Alex Callaway

>
> path('login/', auth_views.LoginView.as_view(), name='login'),


How does it re-direct to which page to open in above method? How does it 
open the template the user wanted here? He is trying to open the page 
'users/login.html'  when users type: http://127.0.0.1/login/ on the browser.

I have the same issue as OP. I am never directed to open the page 
*login.html*. I am using Django version 2.1.2.

My* `urls.py` (in the app) *is like this :

from django.urls import path, re_path
from django.conf.urls import url
from . import views
from django.contrib.auth import views as auth_views
#from django.contrib.auth import login
from django.contrib.auth.views import LoginView

urlpatterns=[
re_path(r'^$',views.home, name='home'),
path('login/', auth_views.LoginView, {'template_name':'accounts/login.html'} 
name='login'),
]
And I get this error :


*TypeError at /accounts/login/login/__init__() takes 1 positional argument 
but 2 were given*

Request Method: GET
Request URL: http://127.0.0.1:8000/accounts/login/login/
Django Version: 2.1.2
Exception Type: TypeError
Exception Value: __init__() takes 1 positional argument but 2 were given

Exception Location: 
C:\Python3\lib\site-packages\django\core\handlers\base.py in _get_response, 
line 124
Python Executable: C:\Python3\python.exe
Python Version: 3.6.4
Python Path: ['C:\\Git\\projects\\projectname', 
'C:\\Python3\\python36.zip', 'C:\\Python3\\DLLs', 'C:\\Python3\\lib', 
'C:\\Python3', 'C:\\Python3\\lib\\site-packages', 
'/projectname/projectname']

Server time: Tue, 13 Nov 2018 00:11:05 +
Traceback said :

File "C:\Python3\lib\site-packages\django\core\handlers\exception.py" in 
inner
  34. response = get_response(request)

File "C:\Python3\lib\site-packages\django\core\handlers\base.py" in 
_get_response
  126. response = self.process_exception_by_middleware(e, 
request)

File "C:\Python3\lib\site-packages\django\core\handlers\base.py" in 
_get_response
  124. response = wrapped_callback(request, *callback_args, 
**callback_kwargs)

*Exception Type: TypeError at /accounts/login/login/*
*Exception Value: __init__() takes 1 positional argument but 2 were given*

My *url.py *in my project *(not in the app)* is like this :

urlpatterns = [
path('admin/', admin.site.urls),
path('home/', include('clientview.urls')),
path('accounts/login/', include('clientview.urls')),
]

On Monday, August 27, 2018 at 8:47:05 AM UTC-7, kimeualexis wrote:
>
> *#Import auth views*
>
> from django.contrib.auth import views as auth_views
>
> *#Use the views in the url*
>
> path('login/', auth_views.LoginView.as_view(), name='login'),
>
> Happy coding!
>
>
> On Mon, Aug 27, 2018 at 6:29 PM Tim Vogt (Tim Vogt)  > wrote:
>
>> Hi Jason, 
>> Thank !
>>
>> my urls.py in /users looks like this
>>
>> This is the error I get with amusement.
>>
>> How to change the old import? I suppose this is the way. Because the 
>> admin is imported from django. 
>>
>>
>>
>>
>>
>>
>> """Defines URL patterns for users"""
>>
>> from django.conf.urls import url
>> from . import views
>> # from django.contrib.auth import login
>> from django.contrib.auth.views import LoginView
>>
>> app_name='users'
>>
>>
>> urlpatterns = [
>>   # Login page
>> url('login/', LoginView, {'template_name': 'users/login.html'}, 
>> name='login'),
>> # Logout page
>> url('logout/', views.logout_view, name='logout'),
>> ]
>>
>>
>>
>>
>> TypeError at /users/login/
>>
>> __init__() takes 1 positional argument but 2 were given
>>
>> Request Method: GET
>> Request URL: http://localhost:8000/users/login/
>> Django Version: 2.0.7
>> Exception Type: TypeError
>> Exception Value: 
>>
>> __init__() takes 1 positional argument but 2 were given
>>
>> Exception Location: 
>> /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/handlers/base.py
>>  
>> in _get_response, line 126
>> Python Executable: 
>> /Library/Frameworks/Python.framework/Versions/3.6/bin/python3
>> Python Version: 3.6.5
>> Python Path: 
>>
>> ['/Users/timvogt/Software_projects/learning_log',
>>  '/Library/Frameworks/Python.framework/Versions/3.6/lib/python36.zip',
>>  '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6',
>>  
>> '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload',
>>  '/Users/timvogt/Library/Python/3.6/lib/python/site-packages',
>>  
>> '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages']
>>
>> Server time: Mon, 27 Aug 2018 15:26:32 +
>> Traceback Switch to copy-and-paste view 
>> 
>>
>>- 
>>
>> /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/handlers/exception.py
>> in inner
>>1. 
>>   
>>   response = get_response(request)
>>   
>>   ...
>>▶ Local vars 
>>- 
>>
>> 

Re: TypeError at /users/login/ login() got an unexpected keyword argument 'template_name'

2018-08-27 Thread Alex Kimeu
*#Import auth views*

from django.contrib.auth import views as auth_views

*#Use the views in the url*

path('login/', auth_views.LoginView.as_view(), name='login'),

Happy coding!


On Mon, Aug 27, 2018 at 6:29 PM Tim Vogt (Tim Vogt) 
wrote:

> Hi Jason,
> Thank !
>
> my urls.py in /users looks like this
>
> This is the error I get with amusement.
>
> How to change the old import? I suppose this is the way. Because the admin
> is imported from django.
>
>
>
>
>
>
> """Defines URL patterns for users"""
>
> from django.conf.urls import url
> from . import views
> # from django.contrib.auth import login
> from django.contrib.auth.views import LoginView
>
> app_name='users'
>
>
> urlpatterns = [
>   # Login page
> url('login/', LoginView, {'template_name': 'users/login.html'}, name='login'),
> # Logout page
> url('logout/', views.logout_view, name='logout'),
> ]
>
>
>
>
> TypeError at /users/login/
>
> __init__() takes 1 positional argument but 2 were given
>
> Request Method: GET
> Request URL: http://localhost:8000/users/login/
> Django Version: 2.0.7
> Exception Type: TypeError
> Exception Value:
>
> __init__() takes 1 positional argument but 2 were given
>
> Exception Location: 
> /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/handlers/base.py
> in _get_response, line 126
> Python Executable:
> /Library/Frameworks/Python.framework/Versions/3.6/bin/python3
> Python Version: 3.6.5
> Python Path:
>
> ['/Users/timvogt/Software_projects/learning_log',
>  '/Library/Frameworks/Python.framework/Versions/3.6/lib/python36.zip',
>  '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6',
>  
> '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload',
>  '/Users/timvogt/Library/Python/3.6/lib/python/site-packages',
>  
> '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages']
>
> Server time: Mon, 27 Aug 2018 15:26:32 +
> Traceback Switch to copy-and-paste view
> 
>
>-
>
> /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/handlers/exception.py
> in inner
>1.
>
>   response = get_response(request)
>
>   ...
>▶ Local vars 
>-
>
> /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/handlers/base.py
> in _get_response
>1.
>
>   response = self.process_exception_by_middleware(e, 
> request)
>
>   ...
>▶ Local vars 
>-
>
> /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/handlers/base.py
> in _get_response
>1.
>
>   response = wrapped_callback(request, *callback_args, 
> **callback_kwargs)
>
>   ...
>▶ Local vars 
>
> Request informationUSER
> AnonymousUser
> GET
> No GET data
> POST
> No POST data
> FILES
> No FILES data
> COOKIES
> VariableValue
> csrftoken
>
> 'zKJ7uZOTcHNiYr4arCV6YjzR36mq7Ie2HpK607EMlKDhQcxObqHBTFSRrtkyaNZa'
>
> snipcart_order_token
>
> '142952d7-baae-4ab2-b2b0-ac5462367122'
>
> _xsrf
>
> '2|878cf834|c449d16f85d12cdef7046b0ac6567a54|1534532218'
>
> username-localhost-
>
> '2|1:0|10:1534532218|23:username-localhost-|44:YWY3N2MyNDAxYzQ0NDI3NmIxNWY4ZjUyNTI5Y2Y4YTY=|060151f0b69a6428ef01d3516fe0550735f7c8e205b9f59bf602134027e9'
>
> _ga
>
> 'GA1.1.581090691.1515705617'
>
> pretix_csrftoken
>
> '4D01Mhbc4oN2AvqmkxKaDPdzh040pxwHykOr0hc5afYoMMWtYpFcukamsEO2j3lg'
>
> __stripe_mid
>
> 'c72941fc-ac1e-4460-b838-5c87b673'
>
> Pycharm-77c83f85
>
> '1f4c7cc4-a97c-4bdc-b2cc-4c190f485abd'
>
> META
> VariableValue
> Apple_PubSub_Socket_Render
>
> '/private/tmp/com.apple.launchd.v0QRbL5XFB/Render'
>
> CONTENT_LENGTH
>
> ''
>
> CONTENT_TYPE
>
> 'text/plain'
>
> CSRF_COOKIE
>
> 'zKJ7uZOTcHNiYr4arCV6YjzR36mq7Ie2HpK607EMlKDhQcxObqHBTFSRrtkyaNZa'
>
> DISPLAY
>
> '/private/tmp/com.apple.launchd.n1qjsNP13q/org.macosforge.xquartz:0'
>
> DJANGO_SETTINGS_MODULE
>
> 'learning_log.settings'
>
> GATEWAY_INTERFACE
>
> 'CGI/1.1'
>
> HOME
>
> '/Users/timvogt'
>
> HTTP_ACCEPT
>
> 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
>
> HTTP_ACCEPT_ENCODING
>
> 'gzip, deflate'
>
> HTTP_ACCEPT_LANGUAGE
>
> 'nl-nl'
>
> HTTP_CONNECTION
>
> 'keep-alive'
>
> HTTP_COOKIE
>
> ('csrftoken=zKJ7uZOTcHNiYr4arCV6YjzR36mq7Ie2HpK607EMlKDhQcxObqHBTFSRrtkyaNZa; 
> '
>  'snipcart_order_token=142952d7-baae-4ab2-b2b0-ac5462367122; '
>  '_xsrf=2|878cf834|c449d16f85d12cdef7046b0ac6567a54|1534532218; '
>  
> 'username-localhost-="2|1:0|10:1534532218|23:username-localhost-|44:YWY3N2MyNDAxYzQ0NDI3NmIxNWY4ZjUyNTI5Y2Y4YTY=|060151f0b69a6428ef01d3516fe0550735f7c8e205b9f59bf602134027e9";
>  '
>  '_ga=GA1.1.581090691.1515705617; '
>  
> 'pretix_csrftoken=4D01Mhbc4oN2AvqmkxKaDPdzh040pxwHykOr0hc5afYoMMWtYpFcukamsEO2j3lg;
>  '
>  

Re: How to create dynamic form field? Django 2.0

2018-07-20 Thread alex eckert
There is no simple solution to this problem. I'm going to try and break 
this explanation down into simpler parts for you, but please remember this 
is pretty hard stuff if you're not familiar with Django. I would second 
@Melvyn's advice, but if you really need to get this done you need to be 
patient and read. 

The general idea is that you create a form, and then you make a formset 
which is a form of forms. The formset holds multiple forms at the same 
time, so in your case, you would need a form for a 'Tax' such as 'TaxForm' 
and then you also would need a formset to hold all the TaxForms such as 
'TaxFormset'. 

Django formsets (mentioned above) are only the backend part of how this 
solution comes together. Spend some time reading the documentation 

 
that @C Kirby linked. They explain that a formset contains two parts: the 
management forms and x number of forms. The management form will say to 
Django "okay we're entering three forms, which is one more than we used to 
have." This management form allows Django to match up each of the forms to 
their respective objects. All these parts get entered in in variables of 
the POST request.

Now, the problem is that Django only helps you on the backend here. Django 
expects the management form to be filled out correctly, and the data in the 
formsets to be lined up. To achieve this, you have to do work on the 
frontend to create things like an 'add' button or a 'remove' button. The 
javascript on the front end is responsible for turning a button press 
(something like 'click to add tax' into "tax-INITIAL-FORMS=1" and 
"tax-TOTAL-FORMS=2." 

Personally, I've used this JQuery script: 
https://github.com/elo80ka/django-dynamic-formset which has allowed me to 
have an 'add' and 'remove' buttons similar to what you have shown. It will 
handle the heavy lifting of making this translation of button presses to 
management form data.

Hope this helps.

On Friday, July 20, 2018 at 12:51:13 AM UTC-5, Django Lover wrote:
>
> @Melvyn Sopacua Can you please give me simple solution of this problem?
>
> On Friday, July 20, 2018 at 11:15:06 AM UTC+5:30, Melvyn Sopacua wrote:
>>
>> On donderdag 19 juli 2018 16:18:07 CEST Django Lover wrote: 
>> > This is hard for me understand can you please give some code. I am new 
>> in 
>> > Django. PLEASE HELP ME 
>>
>> If you're new to Django don't try to do this and learn more about Django 
>> first. 
>> You don't have the knowledge to break down your problem into the right 
>> components, which for a Django developer up to the task would be very 
>> simple 
>> (as shown by the replies). 
>> Walk before your run. 
>> -- 
>> Melvyn Sopacua 
>>
>

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


Re: how to add radiobuttons to my ModelForm

2018-06-25 Thread alex eckert
Can you include your template code? The issue could be in there.

On Sunday, June 24, 2018 at 10:15:50 AM UTC-5, Saloni Kalra wrote:
>
> I wish to add radio buttons fill in each parameter of my model and also to 
> convert it to integer on the backend. But somehow its not changing. Kindly 
> help.
> Thanks and regards,
> Saloni
>
>
> *Forms.py*
>
> class PostForm(forms.ModelForm):
>
> class Meta:
> fields = ("teacher","subject","param1","param2","param3","param4",
> 
> "param5","param6","param7","param8","param9","param10",)
> model = models.Post
> choices = (
> (1,'Unsatisfactory'),
> (2,'Satisfactory'),
> (3,'Good'),
> (4,'Very Good'),
> (5,'Outstanding')
> )
> widgets = {
> 'param1':forms.TypedChoiceField(choices=choices, 
> widget=forms.RadioSelect, coerce=int),
>
> }
>
> *Models.py*
>
> class Post(models.Model):
>
> user = models.ForeignKey(User, related_name="posts", 
> on_delete=models.CASCADE)
> teacher = models.ForeignKey(Teacher, related_name="posts", 
> on_delete=models.CASCADE)
> subject = models.ForeignKey(Subject, related_name="posts", 
> on_delete=models.CASCADE)
> created_at = models.DateTimeField(auto_now=True)
> param1 = models.PositiveIntegerField(blank=False, null=False, 
> verbose_name = "The objectives of this course were made clear to me by this 
> teacher.")
> param2 = models.PositiveIntegerField(blank=False, null=False, 
> verbose_name = "The teacher speaks, articulates and explains concepts 
> clearly.")
> param3 = models.PositiveIntegerField(blank=False, null=False, 
> verbose_name = "The teacher adheres to the timings schedule and enforces 
> discipline in the class.")
> param4 = models.PositiveIntegerField(blank=False, null=False, 
> verbose_name = "Interest generated by the teacher.")
> param5 = models.PositiveIntegerField(blank=False, null=False, 
> verbose_name = "The lectures were well structured and focused on the 
> topics.")
> param6 = models.PositiveIntegerField(blank=False, null=False, 
> verbose_name = "Accessibility of the teacher in and out of the class.")
> param7 = models.PositiveIntegerField(blank=False, null=False, 
> verbose_name = "The teacher has fair knowledge on the subject matter.")
> param8 = models.PositiveIntegerField(blank=False, null=False, 
> verbose_name = "Effective use of teaching aids.")
> param9 = models.PositiveIntegerField(blank=False, null=False, 
> verbose_name = "Time spend on lecturing by teacher for course coverage was 
> sufficient and lesson plan was followed.")
> param10 = models.PositiveIntegerField(blank=False, null=False, 
> verbose_name = "The teacher encourage students to raise pertinent questions 
> and answer them.")
>
> def __str__(self):
> return self.teacher.teacher_name
>
> def get_absolute_url(self):
> return reverse(
> "posts:single",
> kwargs={
> "username": self.user.username,
> "pk": self.pk
> }
> )
>
> class Meta:
> ordering = ["-created_at"]
> unique_together = ["user", "teacher", "subject"]
>

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


Re: Django multiple Model Forms in template

2018-06-23 Thread alex eckert
This is likely not the answer you're looking for, but my two cents...

I've never been successful in writing the templates for formsets on my own, 
as they tend to end up looking rather clunky. I've been using this 
js
 
library to help me out as it lets you set up some basic variables and 
modify the appearance of the form rather easily. From my understanding, the 
delete and add buttons don't work very well if you simply render them in 
the template, but this library makes them work a little better. 

I've found formsets to be very frustrating so I hope you manage to do 
better than me!



On Friday, June 22, 2018 at 7:19:28 PM UTC-5, martin@gmail.com wrote:
>
> It would be highly appreciated if you could advise how the template should 
> be modified to scale model forms as per the code below. There are around 30 
> item models which are the same as parent model. Also, those model forms 
> have to be saved to database separately so I assume there should be the 
> same amount of model forms as there are models. Thank you very much in 
> advance and looking forward to your insights.
>
>
> *forms.py*
>
>
> from django import forms
>
> from django.forms import modelformset_factory, ModelForm
>
> from .models import Assumptions
>
>  
>
> class AssumptionsForm(ModelForm):
>
>  
>
> class Meta:
>
> model = Assumptions
>
> fields = ['Bad', 'Likely', 'Best']
>
> exclude = ()
>
>
> *models.py*
>
>
> from django.db import models
>
> from django.forms import ModelForm
>
>  
>
> class Assumptions(models.Model):
>
>  
>
> Bad = models.FloatField(null=True, blank=True, default=None)
>
> Likely = models.FloatField(null=True, blank=True, default=None)
>
> Best = models.FloatField(null=True, blank=True, default=None)
>
>  
>
> class Meta:
>
> abstract = True
>
>  
>
> class Item1(Assumptions):
>
>  pass
>
>  
>
> class Item2(Assumptions):
>
>  pass 
>
>  
>
> class ItemN(Assumptions):
>
>  pass 
>
>
> *views.py*
>
>
> from django.shortcuts import render
>
> from .forms import  modelformset_factory, AssumptionsForm
>
> from .models import Item1, Item2, Assumptions
>
>  
>
> model_names = [item1, item2 ... itemN]
>
>  
>
> def get_assumptions(request):
>
>  
>
>for name in model_names:
>
>  
>
> AssumptionsFormSet = modelformset_factory(name, form = AssumptionsForm, 
>
>
> extra = 5)
>
>  
>
> if request.method == 'POST':   
>
>  
>
> formset = AssumptionsFormSet(request.POST, prefix = str(name))
>
>  
>
> if formset.is_valid():
>
>  
>
> print('valid form')
>
>  
>
> for form in formset:
>
>  
>
> print('in for loop after valid form1')
>
>  
>
> name =  form.save()
>
>  
>
>  
>
>   else:
>
>  
>
> formset = AssumptionsFormSet
>
>  
>
> print('reached else')
>
>  
>
>   return render(request, 'assumptions.html', {'formset': formset})
>
>
> *assumptions.html*
>
>
> 
>
> {%for name in model_names%}
>
> 
>
> {{name}}
>
> {% csrf_token %}
>
>  
>
> {{ name }}
>
> {{ formset.management_form }}
>
> {{ formset.non_form_errors.as_ul }}
>
> 
>
> {% for form in formset.forms %}
>
>  {% if forloop.first %}
>
>  
>
>  {% for field in form.visible_fields %}
>
>  {{ field.label|capfirst }}
>
>  {% endfor %}
>
>   
>
>   {% endif %}
>
>   
>
>   {% for field in form.visible_fields %}
>
> 
>
>{# Include the hidden fields in the form #}
>
>{% if forloop.first %}
>
>   {% for hidden in form.hidden_fields %}
>
>   {{ hidden }}
>
>   {% endfor %}
>
>   {% endif %}
>
>   {{ field.errors.as_ul }}
>
>   {{ field }}
>
>  
>
>  {% endfor %}
>
>  
>
> {% endfor %}
>
>  
>
>  
>
>  
>
>  
>
> 
>
> 
>
> {% 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/dac1d075-6b98-4597-8c94-9e09d04999be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Message from a django beginner user

2018-05-20 Thread Alex Stelmakh
Hi, Francis. Did you try mozilla developer network ? I consider this for my 
further learning. 

вторник, 15 мая 2018 г., 23:01:59 UTC+3 пользователь Francis F. Massaquoi, 
Jr. написал:
>
> Hi, I'm Francis F. Massaquoi, Jr. with great interest in learning django 
> 2.0, which is the latest version, I have been searching on youtube for a 
> channel that have the latest version tutorial, I have not really find one, 
> can someone please help me with a pdf or website, where I can learn django 
> to the best, I have been reading some pdf, I have the basic knowledge, but 
> I need to advance my knowledge. Or if you can connect with me on skype, 
> this is my skype username: francisfmassaquoijr, or if you have a skype 
> group, you can please add me, or give me your skype username...
>
> Your urgent response will highly be appreciated. 
>
> Thanks to the admin for accepting me..
>
> We do it the django way, because it's the best way to web app 
> development.
>

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


django.forms -- unable to display default values in form fields for edit form

2018-04-25 Thread Alex Volkov
Hello everyone,

I'm having some problem with django.forms edit dialog and I believe it 
might be a bug in django that's causing this.

I created a project with Django 2.0.4 running on Python 3.6.5 with 
cookiecutter django template.

I created an app (survey) then created a form using a model with model form 
interface view and template. Everything works except when I added a form 
for editing existing model values, the form fields with default values 
don't get populated. Here's a snippet from my implementation:

#models.py

from django.db import models

class Survey(models.Model):

class Meta:
"""Set composite key for file_number/location fields"""
unique_together = (('file_number', 'court_location', ))

file_number = models.CharField(max_length=127)
location = models.ForeignKey(Location, on_delete=models.PROTECT)

# forms.py
from django import forms

class SurveyForm(forms.ModelForm):
"""Survey Form along with customizations"""

def __init__(self, *args, **kwargs):
self.user = kwargs.pop('user', None)
super().__init__(*args, **kwargs)
# Only show locations available to the user
locations = Location.objects.filter(contract__user_id=self.user.id)
self.fields['location'].queryset = locations

class Meta:
model = Survey
fields = '__all__'

# views.py

class SurveyEdit(View):
"""Edit form for SurveyForm class"""

def get(self, request, survey_id):
survey_obj = Survey.objects.get(id=survey_id)
survey_form = SurveyForm(
request.GET, user=request.user, instance=survey_obj)
return render(
request,
'survey_edit_form.html',
{'survey_form': survey_form, 'survey_id': survey_id}
)

def post(self, request, survey_id):
sf = SurveyForm(
request.POST,
user=request.user,
instance=Survey.objects.get(id=survey_id))
if sf.is_valid():
sf.save()
messages.add_message(
request,
messages.SUCCESS,
"Survey {} was 
updated".format(sf.cleaned_data['file_number'])
)
return HttpResponseRedirect('/survey/list')
error_message(sf, request)
return render(
request,
'survey_edit_form.html',
{'survey_form': sf, 'survey_id': survey_id}
)

# survey_edit_form.html template

{% extends "base.html" %}

{% block title %}
  {% block head_title %}
  Edit Survey
  {% endblock head_title %}
{% endblock title %}

{% block content %}

  

  {% csrf_token %}
  {% for field in survey_form %}

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

  {% endfor %}
  

  

{% endblock %}

# urls.py

path('edit/', login_required(SurveyEdit.as_view()), 
name='edit'),

I also have the following test case, which verifiees that the data is 
loaded into the form

def test_006_edit_data_is_loaded(self):
"""When editing a survey through SurveyForm, verify Survey data is 
loaded"""
client = Client()
client.force_login(self.user)
# create survey object from generated data
edit_survey_data = copy(gen_survey_data(self))
edit_survey = Survey(**edit_survey_data)
edit_survey.save()
# go to edit page
edit_url = '/survey/edit/{}'.format(edit_survey.id)
resp = client.get(edit_url)
# verify that field values were loaded 
content = str(resp.content)
self.assertIn(edit_survey_data['file_number'], content)


The problem seems to be somewhere either in django.forms.boundfield

https://github.com/django/django/blob/c591bc3ccece1514d6b419826c7fa36ada9d9213/django/forms/boundfield.py#L126

def value(self):
data = self.initial
if self.form.is_bound:
data = self.field.bound_data(self.data, data)
return self.field.prepare_value(data)

Where data is correctly assigned from self.initial value (which is taken 
from instance param passed to SurveyForm). However, self.field.bound_data 
method seems to return wrong value,

https://github.com/django/django/blob/c591bc3ccece1514d6b419826c7fa36ada9d9213/django/forms/fields.py#L161

In this code snippet:

if self.disabled:
return initial
return data

The initial value returned only when the field is disabled, which should 
not be the case, I want default data to be displayed when request.GET is 
passed to render ModelForm, in my case the check should be, if there's no 
updated data, return initial data i.e.

if data:
return data
return initial


This seems to fix the issue I have and when I make the change the default 
values are displayed in edit field, however I looked at history of these 
two files (git blame) and didn't find anything that's been changed recently 
(all the changes are from 2-3 years ago), so I'm not sure if this is 
something I'm doing wrong or there was a bug introduced in django.forms in 
some other way.

Please help.

-- 

Re: Django 1.11 and Python 3 SQLite Migration "table already exists"

2018-04-03 Thread Alex Laird
Finally found the solution. I have marked it as the answer on my 
Stackoverflow question here: https://stackoverflow.com/a/49641729/1128413

On Tuesday, April 3, 2018 at 2:52:55 PM UTC-7, Alex Laird wrote:
>
> I've recently started receiving an error that I'm having trouble 
> identifying with a Django 1.11 project using SQLite in development. The 
> project linked below was/is previously Python 2/3 compatible, though I 
> primarily ran it using Python 2. Recently, I switched over most of my 
> computers and projects to default to using Python 3. Additionally, I 
> upgraded the project from Django 1.7 to 1.11. After this, the project 
> started receiving the table already exists error, but *only* when running 
> the migrate command using python3.
>
> I also *only* get the error when running python3 manage.py migrate. For 
> instance, python3 manage.py test works just fine, which is a bit baffling 
> given test first runs the migrations. Running python2 manage.py migrate works 
> just fine, no errors.
>
> I am running Python 3.6.4, installed via Homebrew on a Mac, and the error 
> I received is:
>
> File 
> "/usr/local/lib/python3.6/site-packages/django/db/migrations/recorder.py", 
> line 59, in ensure_schema
>raise MigrationSchemaMissing("Unable to create the django_migrations table 
> (%s)" % exc)
> django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the 
> django_migrations table (table "django_migrations" already exists)
>
> I run into this exact same issue—broken with Python 3 but working with 
> Python 2—on multiple computers, so I'd imagine anyone else will see the 
> same issue. You should be able to reproduce the issue with the following 
> steps:
>
>1. git clone 
>
> g...@github.com:alexdlaird/django-bootstrap-authentication-template-project.git
>  
>&& cd django-bootstrap-authentication-template-project
>2. make install
>3. python2 manage.py migrate - note that it works just fine
>4. rm db.sqlite for a fresh start
>5. python3 manage.py migrate - note that it fails with the error shown 
>above 5x. rm db.sqlitefor a fresh start 5x. python3 manage.py test - 
>note that it works just fine
>
> To see the migrations run against a MySQL instance (the project assumes 
> you have a default Homebrew MySQL instance running locally, but this can be 
> configured in .env if not), run python3 manage.py migrate and observe 
> that this works just fine with Python 2 or 3, so the issue appears isolated 
> to SQLite migrations.
>
> I have done a bit of debugging with this issue myself, swapping back and 
> forth between Python 2.7 and Python 3.6. What I'm seeing is that I believe 
> the issue is related to Unicode strings and table names in Python 3, but 
> I'm not sure where the best place to address this would be. For example, 
> watching the returned get_tables_list in value of in 
> python3.6/django/db/backends/sqlite3/introspection.py shows an empty list 
> (I believe because of the b'' preceding the string, which is hijacking what 
> otherwise should be an array index), whereas in the same file and function 
> in python2.7 all the existing tables are properly return.
>
> Am I doing something wrong? Is this a valid bug? I have also written about 
> it on Stackoverflow here: 
> https://stackoverflow.com/questions/49503235/table-django-migrations-already-exists-error-with-python-3-and-sqlite3/49505445?noredirect=1#comment86058087_49505445
>

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


Django 1.11 and Python 3 SQLite Migration "table already exists"

2018-04-03 Thread Alex Laird
I've recently started receiving an error that I'm having trouble 
identifying with a Django 1.11 project using SQLite in development. The 
project linked below was/is previously Python 2/3 compatible, though I 
primarily ran it using Python 2. Recently, I switched over most of my 
computers and projects to default to using Python 3. Additionally, I 
upgraded the project from Django 1.7 to 1.11. After this, the project 
started receiving the table already exists error, but *only* when running 
the migrate command using python3.

I also *only* get the error when running python3 manage.py migrate. For 
instance, python3 manage.py test works just fine, which is a bit baffling 
given test first runs the migrations. Running python2 manage.py migrate works 
just fine, no errors.

I am running Python 3.6.4, installed via Homebrew on a Mac, and the error I 
received is:

File "/usr/local/lib/python3.6/site-packages/django/db/migrations/recorder.py", 
line 59, in ensure_schema
   raise MigrationSchemaMissing("Unable to create the django_migrations table 
(%s)" % exc)
django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the 
django_migrations table (table "django_migrations" already exists)

I run into this exact same issue—broken with Python 3 but working with 
Python 2—on multiple computers, so I'd imagine anyone else will see the 
same issue. You should be able to reproduce the issue with the following 
steps:

   1. git clone 
   
g...@github.com:alexdlaird/django-bootstrap-authentication-template-project.git 
   && cd django-bootstrap-authentication-template-project
   2. make install
   3. python2 manage.py migrate - note that it works just fine
   4. rm db.sqlite for a fresh start
   5. python3 manage.py migrate - note that it fails with the error shown 
   above 5x. rm db.sqlitefor a fresh start 5x. python3 manage.py test - 
   note that it works just fine

To see the migrations run against a MySQL instance (the project assumes you 
have a default Homebrew MySQL instance running locally, but this can be 
configured in .env if not), run python3 manage.py migrate and observe that 
this works just fine with Python 2 or 3, so the issue appears isolated to 
SQLite migrations.

I have done a bit of debugging with this issue myself, swapping back and 
forth between Python 2.7 and Python 3.6. What I'm seeing is that I believe 
the issue is related to Unicode strings and table names in Python 3, but 
I'm not sure where the best place to address this would be. For example, 
watching the returned get_tables_list in value of in 
python3.6/django/db/backends/sqlite3/introspection.py shows an empty list 
(I believe because of the b'' preceding the string, which is hijacking what 
otherwise should be an array index), whereas in the same file and function 
in python2.7 all the existing tables are properly return.

Am I doing something wrong? Is this a valid bug? I have also written about 
it on Stackoverflow here: 
https://stackoverflow.com/questions/49503235/table-django-migrations-already-exists-error-with-python-3-and-sqlite3/49505445?noredirect=1#comment86058087_49505445

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


Re: How to run an external command that must run with the server

2018-04-03 Thread 'Alex' via Django users
Yes, it runs constantly, whenever the server is up. Ok, I'll stick with the 
management command as a supervisor process, thank you!

On Tuesday, 3 April 2018 14:09:40 UTC+1, Ken Whitesell wrote:
>
> There's an aspect of your situation which isn't entirely clear to me - is 
> this management command one that remains running all the time, like a 
> Celery task would be; or is it one that starts, runs a process for a period 
> of time, and then ends - only to be restarted at a later time? If the 
> former, then yes, running the management command from supervisor makes 
> sense to me. If the latter, then I'd probably be looking at doing something 
> different.
>
>
> Ken
>
>
> On April 3, 2018 at 6:15 AM 'Alex' via Django users <
> django...@googlegroups.com > wrote:
>
> That makes sense. So leave the source as a management command (as it is 
> now), and just run python manage.py source through supervisor?
>
>
> On Sunday, 1 April 2018 13:16:38 UTC+1, Ken Whitesell wrote:
>
> We set up all our Django-related processes as a group under supervisor. 
> This includes our celery-based processes. (We have some long-running tasks 
> that are kicked off by the web site.) By setting it up as a group, we can 
> manage all the different processes as a set.
>
> Whether or not that's the "best" way is possibly debatable. But it works 
> for us and doesn't give us any problems.
>
> Ken
>
> On 4/1/2018 7:06 AM, 'Alex' via Django users wrote:
>
> I have a daphne server running a django channels application. I also have 
> a python script that aggregates data from various sources, and sticks it 
> into the channel layer (called source.py). At the moment, I run it as a 
> management command (python manage.py source). It is nearly time for 
> deployment(!), so I'm moving towards production solutions. Daphne itself 
> currently runs under supervisor.
>
> My question is, what is the best way to run source.py? As a management 
> command, also under supervisor? Using celery? In some other way? Since 
> source.py feeds into the channel layer, it needs access to settings.py in 
> order to identify the details of the channel layer etc.
> -- 
> You received this message because you are subscribed 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/b3c22939-b520-4c9c-90f9-ef8cb7b8c661%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/b3c22939-b520-4c9c-90f9-ef8cb7b8c661%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>  
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users...@googlegroups.com .
> To post to this group, send email to django...@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/432d449c-d089-43cd-a739-702847729b6b%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/432d449c-d089-43cd-a739-702847729b6b%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/bfa13b9b-8a7a-41e4-8d40-cf21cf6448b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to run an external command that must run with the server

2018-04-03 Thread 'Alex' via Django users
That makes sense. So leave the source as a management command (as it is 
now), and just run python manage.py source through supervisor?


On Sunday, 1 April 2018 13:16:38 UTC+1, Ken Whitesell wrote:
>
> We set up all our Django-related processes as a group under supervisor. 
> This includes our celery-based processes. (We have some long-running tasks 
> that are kicked off by the web site.) By setting it up as a group, we can 
> manage all the different processes as a set.
>
> Whether or not that's the "best" way is possibly debatable. But it works 
> for us and doesn't give us any problems.
>
> Ken
>
> On 4/1/2018 7:06 AM, 'Alex' via Django users wrote:
>
> I have a daphne server running a django channels application. I also have 
> a python script that aggregates data from various sources, and sticks it 
> into the channel layer (called source.py). At the moment, I run it as a 
> management command (python manage.py source). It is nearly time for 
> deployment(!), so I'm moving towards production solutions. Daphne itself 
> currently runs under supervisor. 
>
> My question is, what is the best way to run source.py? As a management 
> command, also under supervisor? Using celery? In some other way? Since 
> source.py feeds into the channel layer, it needs access to settings.py in 
> order to identify the details of the channel layer etc.
> -- 
> You received this message because you are subscribed 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/b3c22939-b520-4c9c-90f9-ef8cb7b8c661%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/b3c22939-b520-4c9c-90f9-ef8cb7b8c661%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/432d449c-d089-43cd-a739-702847729b6b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to run an external command that must run with the server

2018-04-01 Thread 'Alex' via Django users
I have a daphne server running a django channels application. I also have a 
python script that aggregates data from various sources, and sticks it into 
the channel layer (called source.py). At the moment, I run it as a 
management command (python manage.py source). It is nearly time for 
deployment(!), so I'm moving towards production solutions. Daphne itself 
currently runs under supervisor.

My question is, what is the best way to run source.py? As a management 
command, also under supervisor? Using celery? In some other way? Since 
source.py feeds into the channel layer, it needs access to settings.py in 
order to identify the details of the channel layer etc.

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


Re: Overriding channel-layer's group_send and group_add to add persistence

2018-04-01 Thread 'Alex' via Django users
I have a partial solution to this, if anybody is interested. For some 
reason, creating a new version of the core.py file in which 
RedisChannelLayer is defined, and editing it directly, gave the desired 
results. It was something about overriding only part of it, but I have no 
idea what!

On Friday, 23 March 2018 09:56:13 UTC, Alex wrote:
>
> I've been trying to add persistence to channel layers, such that each new 
> consumer joining a group is sent the most recent message from that group, 
> on connect. Below are my attempts. For some reason, the message in the 
> highlighted line always seems to be of type 'None'. Am I going about this 
> completely incorrectly? I'd be really grateful for any help.
>
>
> from channels_redis.core import RedisChannelLayer
> from channels.exceptions import ChannelFull
> import time
>
>
> class RedisChannelLayerGroupPersistence(RedisChannelLayer):
>
>
>
>
> async def group_send(self, group, message):
> """
> Sends a message to the entire group.
> """
> assert self.valid_group_name(group), "Group name not valid"
> # Retrieve list of all channel names
> key = self._group_key(group)
> pers_key = str(key) + "_PERS"
> async with self.connection(self.consistent_hash(group)) as 
> connection:
> # Discard old channels based on group_expiry
> await connection.zremrangebyscore(key, min=0, max=int(time.
> time()) - self.group_expiry)
> # Return current lot
> channel_names = [
> x.decode("utf8") for x in
> await connection.zrange(key, 0, -1)
> ]
> # TODO: More efficient implementation (lua script per shard?) 
>  try:
> await connection.persist(pers_key)
> await connection.set(pers_key, str(message))
> print("TYPE = 
>  {}".format(type(str(
> message
>
>
> for channel in channel_names:
> try:
> await self.send(channel, message)
> except ChannelFull:
> pass
>
>
> async def group_add(self, group, channel):
>
>
> """
> Adds the channel name to a group.
> """
> # Check the inputs
> assert self.valid_group_name(group), "Group name not valid"
> assert self.valid_channel_name(channel), "Channel name not valid"
> # Get a connection to the right shard
> group_key = self._group_key(group)
> pers_key = str(group_key) + "_PERS"
> async with self.connection(self.consistent_hash(group)) as 
> connection:
> message = await connection.get(pers_key) #ISSUE HERE 
> -- MESSAGE IS NONE
> # Add to group sorted set with creation time as timestamp
> await connection.zadd(
> group_key,
> time.time(),
> channel,
> )
> # Set expiration to be group_expiry, since everything in
> # it at this point is guaranteed to expire before that
> try:
> await self.send(channel, str(message))
> except ChannelFull:
> pass
>
>
>
>
> await connection.expire(group_key, self.group_expiry)
>
>
>

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


Re: Overriding channel-layer's group_send and group_add to add persistence

2018-03-23 Thread 'Alex' via Django users
I've just checked, and self.consistent_hash(group) returns '0' in both 
functions, so it should be connecting to the same db...

On Friday, 23 March 2018 16:05:16 UTC, Andrew Godwin wrote:
>
> I would check the connection is going to the right server/database as 
> well? But past that, I can't help you - I'd try doing some things with 
> plain aioredis to see if you can replicate it there.
>
> Andrew
>
> On Fri, Mar 23, 2018 at 9:01 AM, 'Alex' via Django users <
> django...@googlegroups.com > wrote:
>
>> Hi,
>>
>> I've used the redis-cli to get the contents of the key, and it has filled 
>> it properly, so the information is definitely in redis under that key. The 
>> issue seems to be that message = await connection.get(pers_key) always 
>> returns none. One thing I'm certain of is that it's in redis!
>>
>> Alex
>>
>> On Friday, 23 March 2018 15:58:37 UTC, Andrew Godwin wrote:
>>>
>>> It looks correct at first glance - I would insert a debugger there and 
>>> see what the Redis database contained manually at that point.
>>>
>>> Andrew
>>>
>>> On Fri, Mar 23, 2018 at 2:56 AM, 'Alex' via Django users <
>>> django...@googlegroups.com> wrote:
>>>
>>>> I've been trying to add persistence to channel layers, such that each 
>>>> new consumer joining a group is sent the most recent message from that 
>>>> group, on connect. Below are my attempts. For some reason, the message in 
>>>> the highlighted line always seems to be of type 'None'. Am I going about 
>>>> this completely incorrectly? I'd be really grateful for any help.
>>>>
>>>>
>>>> from channels_redis.core import RedisChannelLayer
>>>> from channels.exceptions import ChannelFull
>>>> import time
>>>>
>>>>
>>>> class RedisChannelLayerGroupPersistence(RedisChannelLayer):
>>>>
>>>>
>>>>
>>>>
>>>> async def group_send(self, group, message):
>>>> """
>>>> Sends a message to the entire group.
>>>> """
>>>> assert self.valid_group_name(group), "Group name not valid"
>>>> # Retrieve list of all channel names
>>>> key = self._group_key(group)
>>>> pers_key = str(key) + "_PERS"
>>>> async with self.connection(self.consistent_hash(group)) as 
>>>> connection:
>>>> # Discard old channels based on group_expiry
>>>> await connection.zremrangebyscore(key, min=0, max=int(time.
>>>> time()) - self.group_expiry)
>>>> # Return current lot
>>>> channel_names = [
>>>> x.decode("utf8") for x in
>>>> await connection.zrange(key, 0, -1)
>>>> ]
>>>> # TODO: More efficient implementation (lua script per shard?) 
>>>>  try:
>>>> await connection.persist(pers_key)
>>>> await connection.set(pers_key, str(message))
>>>> print("TYPE = 
>>>>  {}".format(type(str(
>>>> message
>>>>
>>>>
>>>> for channel in channel_names:
>>>> try:
>>>> await self.send(channel, message)
>>>> except ChannelFull:
>>>> pass
>>>>
>>>>
>>>> async def group_add(self, group, channel):
>>>>
>>>>
>>>> """
>>>> Adds the channel name to a group.
>>>> """
>>>> # Check the inputs
>>>> assert self.valid_group_name(group), "Group name not valid"
>>>> assert self.valid_channel_name(channel), "Channel name not 
>>>> valid"
>>>> # Get a connection to the right shard
>>>> group_key = self._group_key(group)
>>>> pers_key = str(group_key) + "_PERS"
>>>> async with self.connection(self.consistent_hash(group)) as 
>>>> connection:
>>>> message = await connection.get(pers_key) #ISSUE HERE 
>>>> -- MESSAGE IS NONE
>>>> # Add to group sorted set with creation time as times

Re: Overriding channel-layer's group_send and group_add to add persistence

2018-03-23 Thread 'Alex' via Django users
That did occur to me, but both connect using the function below, so unless 
they're somehow referring to different groups, I'm not sure how they could 
be going to different servers/databases...
async with self.connection(self.consistent_hash(group)) as connection:


On Friday, 23 March 2018 16:05:16 UTC, Andrew Godwin wrote:
>
> I would check the connection is going to the right server/database as 
> well? But past that, I can't help you - I'd try doing some things with 
> plain aioredis to see if you can replicate it there.
>
> Andrew
>
> On Fri, Mar 23, 2018 at 9:01 AM, 'Alex' via Django users <
> django...@googlegroups.com > wrote:
>
>> Hi,
>>
>> I've used the redis-cli to get the contents of the key, and it has filled 
>> it properly, so the information is definitely in redis under that key. The 
>> issue seems to be that message = await connection.get(pers_key) always 
>> returns none. One thing I'm certain of is that it's in redis!
>>
>> Alex
>>
>> On Friday, 23 March 2018 15:58:37 UTC, Andrew Godwin wrote:
>>>
>>> It looks correct at first glance - I would insert a debugger there and 
>>> see what the Redis database contained manually at that point.
>>>
>>> Andrew
>>>
>>> On Fri, Mar 23, 2018 at 2:56 AM, 'Alex' via Django users <
>>> django...@googlegroups.com> wrote:
>>>
>>>> I've been trying to add persistence to channel layers, such that each 
>>>> new consumer joining a group is sent the most recent message from that 
>>>> group, on connect. Below are my attempts. For some reason, the message in 
>>>> the highlighted line always seems to be of type 'None'. Am I going about 
>>>> this completely incorrectly? I'd be really grateful for any help.
>>>>
>>>>
>>>> from channels_redis.core import RedisChannelLayer
>>>> from channels.exceptions import ChannelFull
>>>> import time
>>>>
>>>>
>>>> class RedisChannelLayerGroupPersistence(RedisChannelLayer):
>>>>
>>>>
>>>>
>>>>
>>>> async def group_send(self, group, message):
>>>> """
>>>> Sends a message to the entire group.
>>>> """
>>>> assert self.valid_group_name(group), "Group name not valid"
>>>> # Retrieve list of all channel names
>>>> key = self._group_key(group)
>>>> pers_key = str(key) + "_PERS"
>>>> async with self.connection(self.consistent_hash(group)) as 
>>>> connection:
>>>> # Discard old channels based on group_expiry
>>>> await connection.zremrangebyscore(key, min=0, max=int(time.
>>>> time()) - self.group_expiry)
>>>> # Return current lot
>>>> channel_names = [
>>>> x.decode("utf8") for x in
>>>> await connection.zrange(key, 0, -1)
>>>> ]
>>>> # TODO: More efficient implementation (lua script per shard?) 
>>>>  try:
>>>> await connection.persist(pers_key)
>>>> await connection.set(pers_key, str(message))
>>>> print("TYPE = 
>>>>  {}".format(type(str(
>>>> message
>>>>
>>>>
>>>> for channel in channel_names:
>>>> try:
>>>> await self.send(channel, message)
>>>> except ChannelFull:
>>>> pass
>>>>
>>>>
>>>> async def group_add(self, group, channel):
>>>>
>>>>
>>>> """
>>>> Adds the channel name to a group.
>>>> """
>>>> # Check the inputs
>>>> assert self.valid_group_name(group), "Group name not valid"
>>>> assert self.valid_channel_name(channel), "Channel name not 
>>>> valid"
>>>> # Get a connection to the right shard
>>>> group_key = self._group_key(group)
>>>> pers_key = str(group_key) + "_PERS"
>>>> async with self.connection(self.consistent_hash(group)) as 
>>>> connection:
>>>> message = await connection.get(pers_k

Re: Overriding channel-layer's group_send and group_add to add persistence

2018-03-23 Thread 'Alex' via Django users
Hi,

I've used the redis-cli to get the contents of the key, and it has filled 
it properly, so the information is definitely in redis under that key. The 
issue seems to be that message = await connection.get(pers_key) always 
returns none. One thing I'm certain of is that it's in redis!

Alex

On Friday, 23 March 2018 15:58:37 UTC, Andrew Godwin wrote:
>
> It looks correct at first glance - I would insert a debugger there and see 
> what the Redis database contained manually at that point.
>
> Andrew
>
> On Fri, Mar 23, 2018 at 2:56 AM, 'Alex' via Django users <
> django...@googlegroups.com > wrote:
>
>> I've been trying to add persistence to channel layers, such that each new 
>> consumer joining a group is sent the most recent message from that group, 
>> on connect. Below are my attempts. For some reason, the message in the 
>> highlighted line always seems to be of type 'None'. Am I going about this 
>> completely incorrectly? I'd be really grateful for any help.
>>
>>
>> from channels_redis.core import RedisChannelLayer
>> from channels.exceptions import ChannelFull
>> import time
>>
>>
>> class RedisChannelLayerGroupPersistence(RedisChannelLayer):
>>
>>
>>
>>
>> async def group_send(self, group, message):
>> """
>> Sends a message to the entire group.
>> """
>> assert self.valid_group_name(group), "Group name not valid"
>> # Retrieve list of all channel names
>> key = self._group_key(group)
>> pers_key = str(key) + "_PERS"
>> async with self.connection(self.consistent_hash(group)) as 
>> connection:
>> # Discard old channels based on group_expiry
>> await connection.zremrangebyscore(key, min=0, max=int(time.
>> time()) - self.group_expiry)
>> # Return current lot
>> channel_names = [
>> x.decode("utf8") for x in
>> await connection.zrange(key, 0, -1)
>> ]
>> # TODO: More efficient implementation (lua script per shard?) 
>>  try:
>> await connection.persist(pers_key)
>> await connection.set(pers_key, str(message))
>> print("TYPE = 
>>  {}".format(type(str(
>> message
>>
>>
>> for channel in channel_names:
>> try:
>> await self.send(channel, message)
>> except ChannelFull:
>> pass
>>
>>
>> async def group_add(self, group, channel):
>>
>>
>> """
>> Adds the channel name to a group.
>> """
>> # Check the inputs
>> assert self.valid_group_name(group), "Group name not valid"
>> assert self.valid_channel_name(channel), "Channel name not valid"
>> # Get a connection to the right shard
>> group_key = self._group_key(group)
>> pers_key = str(group_key) + "_PERS"
>> async with self.connection(self.consistent_hash(group)) as 
>> connection:
>> message = await connection.get(pers_key) #ISSUE HERE 
>> -- MESSAGE IS NONE
>> # Add to group sorted set with creation time as timestamp
>> await connection.zadd(
>> group_key,
>> time.time(),
>> channel,
>> )
>> # Set expiration to be group_expiry, since everything in
>> # it at this point is guaranteed to expire before that
>> try:
>> await self.send(channel, str(message))
>> except ChannelFull:
>> pass
>>
>>
>>
>>
>> await connection.expire(group_key, self.group_expiry)
>>
>>
>> -- 
>> You received this message because you are subscribed 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/abc8747d-8d80-4ec4-a2ca-d5e91c161c08%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/abc8747d-8d80-4ec4-a2ca-d5e91c161c08%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/24613c4d-c566-4631-97cd-e858d286aadf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Overriding channel-layer's group_send and group_add to add persistence

2018-03-23 Thread 'Alex' via Django users
I've been trying to add persistence to channel layers, such that each new 
consumer joining a group is sent the most recent message from that group, 
on connect. Below are my attempts. For some reason, the message in the 
highlighted line always seems to be of type 'None'. Am I going about this 
completely incorrectly? I'd be really grateful for any help.


from channels_redis.core import RedisChannelLayer
from channels.exceptions import ChannelFull
import time


class RedisChannelLayerGroupPersistence(RedisChannelLayer):




async def group_send(self, group, message):
"""
Sends a message to the entire group.
"""
assert self.valid_group_name(group), "Group name not valid"
# Retrieve list of all channel names
key = self._group_key(group)
pers_key = str(key) + "_PERS"
async with self.connection(self.consistent_hash(group)) as 
connection:
# Discard old channels based on group_expiry
await connection.zremrangebyscore(key, min=0, max=int(time.time
()) - self.group_expiry)
# Return current lot
channel_names = [
x.decode("utf8") for x in
await connection.zrange(key, 0, -1)
]
# TODO: More efficient implementation (lua script per shard?)  try:
await connection.persist(pers_key)
await connection.set(pers_key, str(message))
print("TYPE =  
{}".format(type(str(message


for channel in channel_names:
try:
await self.send(channel, message)
except ChannelFull:
pass


async def group_add(self, group, channel):


"""
Adds the channel name to a group.
"""
# Check the inputs
assert self.valid_group_name(group), "Group name not valid"
assert self.valid_channel_name(channel), "Channel name not valid"
# Get a connection to the right shard
group_key = self._group_key(group)
pers_key = str(group_key) + "_PERS"
async with self.connection(self.consistent_hash(group)) as 
connection:
message = await connection.get(pers_key) #ISSUE HERE 
-- MESSAGE IS NONE
# Add to group sorted set with creation time as timestamp
await connection.zadd(
group_key,
time.time(),
channel,
)
# Set expiration to be group_expiry, since everything in
# it at this point is guaranteed to expire before that
try:
await self.send(channel, str(message))
except ChannelFull:
pass




await connection.expire(group_key, self.group_expiry)


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


Listening to a django channel from outside a consumer

2018-03-12 Thread Alex


Hi,


The docs explain that it is possible to publish to the channel layer from 
outside of a consumer: 
https://channels.readthedocs.io/en/latest/topics/channel_layers.html#using-outside-of-consumers
 I 
need to do the opposite. I have a fairly complex python script that reads 
live data from pubnub, processes it, and pushes it to consumers via groups 
on the channel_layer. This works fine, but I need consumers to be able to 
announce their presence to this script so that it can push them data (it 
currently pushes to the channel layer only when it gets new data from 
pubnub, which could be every 24 hours).


I've decided to solve this by having the consumers publish to a 'presence' 
channel on connect. I now need the pubnub source script to listen to this 
channel. I've tried adding the below to the script, and it no longer throws 
errors, but it doesn't actually respond to messages. It successfully joins 
the channel layer, but the message handler 'receive_json', never fires.


This is the class, and then the initiation further down in the code:
from channels.generic.websocket import JsonWebsocketConsumer


class channelConsumer(JsonWebsocketConsumer):

def __init__(self):
self.channel_name = 'source'
def join(self):
async_to_sync(channel_layer.group_add)('presence', self.channel_name
)
def receive_json(self, message):
print("Presence Detected")
# do some stuff

global channel_layer
channel_layer = get_channel_layer()

global listener
listener = channelConsumer()
listener.join()




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


Re: Failing to configure Django correctlly (conflict in settings between models.py and manage.py usage).

2018-01-05 Thread alex Tarasiuk
The only thing I need from Django (at this point) is to have the ability to 
communicate with my DB.
(person = models.Person.objects.filter(phone_number= phone_number) from my 
previous example)
I'm planning to use the admin page and I might add a GUI in some point.

Regards,
Alex

On Friday, January 5, 2018 at 5:10:20 PM UTC+2, Andréas Kühne wrote:
>
> Ah, 
>
> OK.
>
> Now it is a bit more clear. 
>
> What you are doing is not supported by django. You don't use the django 
> models OUTSIDE of the django project. That is not a supported usecase. You 
> can probably set it up, so that you CAN do that, but I would not recommend 
> it.
>
> What are you trying to accomplish by reading the models OUTSIDE of the 
> django project?
>
> Regards,
>
> Andréas
>
> 2018-01-05 15:50 GMT+01:00 alex Tarasiuk <alex...@gmail.com >
> :
>
>> Here is what I've done so far (it is a new project and I did followed the 
>> tutorial until it didn't worked for me any more).
>>
>> Here are the steps of how I created the project:
>>
>> 1. django-admin startproject MY_DGANGO
>>
>> 2.  python manage.py startapp my_django
>>
>> 3.  edited the models.py
>>
>> 4. python manage.py makemigrations my_django
>>
>> 5. python manage.py sqlmigrate my_django 0001
>>
>> 6.  python manage.py migrate
>>
>>  
>>
>> Now after the tables in the DB was created, I want to use it 
>> (add/remove/update date) from my project.
>>
>>
>> 7.  So from my project I’m importing models so I’ll be able to use the 
>> classes I’ve created to extract and add information to/from the DB.
>>
>> For example:
>>
>> · In models.py:
>>
>> Class Person(models.Model):
>>
>> first_name = models.CharField(max_length=100, null=False)
>>
>> last_name = models.CharField(max_length=100, null=False)
>>
>> phone_number = models.CharField(max_length=100, null=False)
>>
>> …
>>
>>  
>>
>> · In some file in my project:
>>
>> from MY_DGANGO.my_django import models
>>
>> ….
>>
>> def add_person(first_name, last_name, phone_number):
>>
>> …
>>
>> person = models.Person(first_name= first_name, last_name= last_name, 
>>
>> phone_number= phone_number)
>>
>> person.save()
>>
>> …
>>
>> …
>>
>> …
>>
>> def get_person_by_phone_number(phone_number):
>>
>> …
>>
>> person = models.Person.objects.filter(phone_number= phone_number)
>>
>> …
>>
>>
>> P.S. I'm runnig it without starting any Django server.
>>
>>
>>
>> On Friday, January 5, 2018 at 4:29:11 PM UTC+2, Andréas Kühne wrote:
>>>
>>> Ok,
>>>
>>> So are you in the folder where the manage.py file resides when you run 
>>> your commands? You have to be in that directory when running manage.py 
>>> commands.
>>>
>>> Also - as long as you haven't done too much already - I would recommend 
>>> starting fresh and looking into the tutorials in the django docs pages on 
>>> how to start a project. See 
>>> https://docs.djangoproject.com/en/2.0/intro/tutorial01/ or 
>>> https://tutorial.djangogirls.org/en/.
>>>
>>> The settings you have changed there are very strange (as Ramiro pointed 
>>> out) and should definitely not be required. Have you set the 
>>> DEFAULT_INDEX_TABLESPACE 
>>> setting anywhere? Because that is also something that shouldn't be 
>>> required
>>>
>>> Med vänliga hälsningar,
>>>
>>> Andréas
>>>
>>> 2018-01-05 15:17 GMT+01:00 alex Tarasiuk <alex...@gmail.com>:
>>>
>>>> Hi Andréas,
>>>> Thanks for your response.
>>>>
>>>> When I'm removing the lines you've talked about I'm having the 
>>>> following error:
>>>>
>>>> django.core.exceptions.ImproperlyConfigured: Requested setting 
>>>> DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either 
>>>> define the environment variable DJANGO_SETTINGS_MODULE or call 
>>>> settings.configure() before accessing settings.
>>>>
>>>> This is why I've added those settings in the first place.
>>>>
>>>>
>>>>
>>>> On Friday, January 5, 2018 at 3:59:31 PM UTC+2, Andréas Kühne wrote:
>>>>>
>>>>> Hi Alex,
&

Re: Failing to configure Django correctlly (conflict in settings between models.py and manage.py usage).

2018-01-05 Thread alex Tarasiuk
Here is what I've done so far (it is a new project and I did followed the 
tutorial until it didn't worked for me any more).

Here are the steps of how I created the project:

1. django-admin startproject MY_DGANGO

2.  python manage.py startapp my_django

3.  edited the models.py

4. python manage.py makemigrations my_django

5. python manage.py sqlmigrate my_django 0001

6.  python manage.py migrate

 

Now after the tables in the DB was created, I want to use it 
(add/remove/update date) from my project.


7.  So from my project I’m importing models so I’ll be able to use the 
classes I’ve created to extract and add information to/from the DB.

For example:

· In models.py:

Class Person(models.Model):

first_name = models.CharField(max_length=100, null=False)

last_name = models.CharField(max_length=100, null=False)

phone_number = models.CharField(max_length=100, null=False)

…

 

· In some file in my project:

from MY_DGANGO.my_django import models

….

def add_person(first_name, last_name, phone_number):

…

person = models.Person(first_name= first_name, last_name= last_name, 

phone_number= phone_number)

person.save()

…

…

…

def get_person_by_phone_number(phone_number):

…

person = models.Person.objects.filter(phone_number= phone_number)

…


P.S. I'm runnig it without starting any Django server.



On Friday, January 5, 2018 at 4:29:11 PM UTC+2, Andréas Kühne wrote:
>
> Ok,
>
> So are you in the folder where the manage.py file resides when you run 
> your commands? You have to be in that directory when running manage.py 
> commands.
>
> Also - as long as you haven't done too much already - I would recommend 
> starting fresh and looking into the tutorials in the django docs pages on 
> how to start a project. See 
> https://docs.djangoproject.com/en/2.0/intro/tutorial01/ or 
> https://tutorial.djangogirls.org/en/.
>
> The settings you have changed there are very strange (as Ramiro pointed 
> out) and should definitely not be required. Have you set the 
> DEFAULT_INDEX_TABLESPACE 
> setting anywhere? Because that is also something that shouldn't be 
> required
>
> Med vänliga hälsningar,
>
> Andréas
>
> 2018-01-05 15:17 GMT+01:00 alex Tarasiuk <alex...@gmail.com >
> :
>
>> Hi Andréas,
>> Thanks for your response.
>>
>> When I'm removing the lines you've talked about I'm having the following 
>> error:
>>
>> django.core.exceptions.ImproperlyConfigured: Requested setting 
>> DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either 
>> define the environment variable DJANGO_SETTINGS_MODULE or call 
>> settings.configure() before accessing settings.
>>
>> This is why I've added those settings in the first place.
>>
>>
>>
>> On Friday, January 5, 2018 at 3:59:31 PM UTC+2, Andréas Kühne wrote:
>>>
>>> Hi Alex,
>>>
>>> You shouldn't have anything regarding the settings in models.py.
>>>
>>> Remove:
>>> import os
>>> import django
>>> os.environ["DJANGO_SETTINGS_MODULE"] = "MY_DJANGO.MY_DJANGO.settings"
>>> django.setup()
>>>
>>> from your models.py file. You should never have any settings in the 
>>> models.py file at all. Also, you should never reference the django project 
>>> folder (your first MY_DJANGO here) in the project. It always has that 
>>> folder anyway.
>>>
>>> In settings.py, your INSTALLED_APPS should look like this:
>>>
>>> INSTALLED_APPS = [
>>> 'django.contrib.admin',
>>> 'django.contrib.auth',
>>> 'django.contrib.contenttypes',
>>> 'django.contrib.sessions',
>>> 'django.contrib.messages',
>>> 'django.contrib.staticfiles',
>>> 'django.contrib.sites',
>>> 'django.contrib.admindocs',
>>>
>>> 'my_django',
>>>
>>> ]
>>>
>>>
>>> Everything should then work as expected.
>>>
>>> Regards,
>>>
>>> Andréas
>>>
>>> 2018-01-05 13:07 GMT+01:00 alex Tarasiuk <alex...@gmail.com>:
>>>
>>>> Hi, I'm new to Django and having some trouble to configure it.
>>>> I'm using Django 1.11.9 (1.11.5 at first but then upgraded with hopes 
>>>> it will solve the issue) and Python 2.7.12 from virtualenv.
>>>>
>>>> Here is my project structure (Please pay attention to upper/lower case 
>>>> letters - it is intentionally):
>>>>
>>>> :
>>>>
>>>> module 1
>>>>

Re: Failing to configure Django correctlly (conflict in settings between models.py and manage.py usage).

2018-01-05 Thread alex Tarasiuk
Hi Andréas,
Thanks for your response.

When I'm removing the lines you've talked about I'm having the following 
error:

django.core.exceptions.ImproperlyConfigured: Requested setting 
DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either 
define the environment variable DJANGO_SETTINGS_MODULE or call 
settings.configure() before accessing settings.

This is why I've added those settings in the first place.



On Friday, January 5, 2018 at 3:59:31 PM UTC+2, Andréas Kühne wrote:
>
> Hi Alex,
>
> You shouldn't have anything regarding the settings in models.py.
>
> Remove:
> import os
> import django
> os.environ["DJANGO_SETTINGS_MODULE"] = "MY_DJANGO.MY_DJANGO.settings"
> django.setup()
>
> from your models.py file. You should never have any settings in the 
> models.py file at all. Also, you should never reference the django project 
> folder (your first MY_DJANGO here) in the project. It always has that 
> folder anyway.
>
> In settings.py, your INSTALLED_APPS should look like this:
>
> INSTALLED_APPS = [
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'django.contrib.sites',
> 'django.contrib.admindocs',
>
> 'my_django',
>
> ]
>
>
> Everything should then work as expected.
>
> Regards,
>
> Andréas
>
> 2018-01-05 13:07 GMT+01:00 alex Tarasiuk <alex...@gmail.com >
> :
>
>> Hi, I'm new to Django and having some trouble to configure it.
>> I'm using Django 1.11.9 (1.11.5 at first but then upgraded with hopes it 
>> will solve the issue) and Python 2.7.12 from virtualenv.
>>
>> Here is my project structure (Please pay attention to upper/lower case 
>> letters - it is intentionally):
>>
>> :
>>
>> module 1
>>
>> module 2
>>
>> ...
>>
>> ...
>>
>> MY_DJANGO:
>>
>> MY_DJANGO:
>>
>> __init__.py
>>
>> settings.py
>>
>> urls.py
>>
>> wsgi.py
>>
>> my_django:
>>
>> migrations
>>
>> __init__.py
>>
>> admin.py
>>
>> apps.py
>>
>> models.py
>>
>> tests.py
>>
>> views.py
>>
>> __init__.py
>>
>> manage.py
>>  
>> in models.py I've added:
>>
>> import os
>> import django
>> os.environ["DJANGO_SETTINGS_MODULE"] = "MY_DJANGO.MY_DJANGO.settings"
>> django.setup()
>>
>> before the models import from django.db.
>>
>> in manage.py, in the main
>>
>> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MY_DJANGO.settings")
>>
>> was auto generated by Django 
>>
>> in settings.py, in INSTALLED_APPS:
>>
>> INSTALLED_APPS = [
>> 'django.contrib.admin',
>> 'django.contrib.auth',
>> 'django.contrib.contenttypes',
>> 'django.contrib.sessions',
>> 'django.contrib.messages',
>> 'django.contrib.staticfiles',
>> 'django.contrib.sites',
>> 'django.contrib.admindocs',
>>
>> ==>>>>'MY_DJANGO.my_django', or 'my_django', <<<<= Here is 
>> the problem
>>
>> ]
>>
>>
>> Problem description:
>>
>> if I use 'MY_DJANGO.my_django' in INSTALLED_APPS then running 'python 
>> manage.py check' command yields:
>>
>>  ImportError: No module named MY_DJANGO.settings
>>
>>
>>  
>>
>> and if I use 'my_django' in INSTALLED_APPS then I have an import error 
>> while importing models:
>>
>>  from MY_DJANGO.my_django import models (in some file) yields:
>>
>> ImportError: No module named my_django 
>>
>>
>> Also tried to add  ''my_django.apps.MyDjangoConfig' to INSTALLED_APPS, 
>> and it didn't helped.
>>
>> What am I doing wrong??
>>
>> Thanks in advance,
>> Alex.
>>
>>  
>>
>>
>>
>>
>>
>>
>>  
>>
>> -- 
>> You received this message because you are subscribed 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/bb9251bb-7bce-4eec-b8ac-90b031db1284%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/bb9251bb-7bce-4eec-b8ac-90b031db1284%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/31d7a9d0-a861-4814-a4d5-9771ba828918%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Failing to configure Django correctlly (conflict in settings between models.py and manage.py usage).

2018-01-05 Thread alex Tarasiuk
Hi, I'm new to Django and having some trouble to configure it.
I'm using Django 1.11.9 (1.11.5 at first but then upgraded with hopes it 
will solve the issue) and Python 2.7.12 from virtualenv.

Here is my project structure (Please pay attention to upper/lower case 
letters - it is intentionally):

:

module 1

module 2

...

...

MY_DJANGO:

MY_DJANGO:

__init__.py

settings.py

urls.py

wsgi.py

my_django:

migrations

__init__.py

admin.py

apps.py

models.py

tests.py

views.py

__init__.py

manage.py
 
in models.py I've added:

import os
import django
os.environ["DJANGO_SETTINGS_MODULE"] = "MY_DJANGO.MY_DJANGO.settings"
django.setup()

before the models import from django.db.

in manage.py, in the main

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MY_DJANGO.settings")

was auto generated by Django 

in settings.py, in INSTALLED_APPS:

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.admindocs',

==>>>>'MY_DJANGO.my_django', or 'my_django', <<<<= Here is the 
problem

]


Problem description:

if I use 'MY_DJANGO.my_django' in INSTALLED_APPS then running 'python 
manage.py check' command yields:

 ImportError: No module named MY_DJANGO.settings


 

and if I use 'my_django' in INSTALLED_APPS then I have an import error 
while importing models:

 from MY_DJANGO.my_django import models (in some file) yields:

ImportError: No module named my_django 


Also tried to add  ''my_django.apps.MyDjangoConfig' to INSTALLED_APPS, and 
it didn't helped.

What am I doing wrong??

Thanks in advance,
Alex.

 






 

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


Re: What's the simple way to implement a chat system in Django?

2017-10-05 Thread Alex Chiaranda
is use Firebase for the chat part an option ?

On Monday, October 2, 2017 at 12:39:48 PM UTC-3, Kishore Srinivas wrote:
>
> I want to make a chat system in Django, but all those channel stuffs looks 
> difficult , so are there any other simpler way to implement a chat system, 
> thanks 
>

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


{% csrf_token %}

2017-09-26 Thread Alex Kleider
I'm using test driven development (going through Harry J.W. Percival's 
book) and have found that the following code fails because the template tag 
( {% csrf_token %} ) is rendered by the home_page view function but not by 
the django.template.loader.render_to_string function (and so the 
assertEqual test fails.)

...templates/home.html:
...

 
{% csrf_token %}
 
...

Testing code:

def test_home_page_returns_correct_html(self):
request = HttpRequest()
response = home_page(request)
returned_html = response.content.decode()
expected_html = render_to_string('home.html')
self.assertEqual(returned_html , expected_html)

returned_html and expected_html are the same except that returned_html 
contains the following line (and the other doesn't:)

Infact, expected_html doesn't even contain the
{% csrf_token %}
line.

Can anyone suggest a work around?
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/c424de1a-4866-4f29-b93f-c06f46651ea2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Channels compatibility with Google App/Compute Engine?

2017-07-07 Thread Alex Z
Hello! I'm really new here, and also relatively new to Django, and I've 
been researching different ways to incorporate real-time updates with 
Django without specifically using AJAX. I dug around and found out about 
Django Channels, and I'm learning the basics right now. What I'm trying to 
do is develop a card game app, and I wanted each player to be able to play 
a card on their computer, and it would show up for everyone else playing 
(on different computers) without refreshing the page. I think I can figure 
something out to accomplish this with Django Channels, but I have a 
different issue: is Django Channels easily compatible with Google 
App/Compute Engine? I want to deploy it using Google Compute Engine, but I 
couldn't find many resources on the topic or any that answered my 
questions. For example, how would I deploy my Django app with a specific 
channel layer (Redis, RabbitMQ, etc.)? What other precautions should I take 
before I deploy a Django project that uses Channels? Any input on this 
would be fantastic, even any information on deploying a Django project that 
uses Channels via Google Compute Engine. Thanks!

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


Google analytics and request.resolver_match.url_name

2017-07-07 Thread Alex Riina
I'm getting familiar with google analytics and stumbled 
upon 
https://developers.google.com/analytics/devguides/collection/analyticsjs/pages#modifying_page_urls
 
in which the google docs recommend regexing out some unique ids. In django, 
it's a lot simpler to get something like /user/account/ from 
/user/USER_ID/account/ by using

  ga('set', 'page', "{{ request.resolver_match.url_name }}");


Is there any reason I should rethink that?

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


Catching errors inside transaction.atomic()

2017-06-13 Thread Alex Krupp
The Django documentation gives a warning 

 
to avoid catching errors inside transaction.atomic() blocks, and to use 
nested transactions if you need to do so. But in the case where we have 
code like:

with transaction.atomic():
# Create and save some models here

try:
SomeModel.objects.get(id=NON_EXISTENT_ID)
except SomeModel.DoesNotExist:
raise SomeCustomError()

Will anything bad actually happen if we just immediately raise a custom 
error without doing any other error handling? The expected behavior in this 
case would be that the entire transaction gets rolled back, and so nothing 
before or after the exception is committed.

I'm just wondering in cases like these there is any reason for using the 
recommended nested transaction, or if it's just extra code that's not 
serving any purpose. The examples only speak to cases where there is there 
would otherwise be database queries getting executed in between the first 
database error and the end of the transaction, which isn't the case 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/8765cfc1-6083-4f6e-8f86-ace888a0ad21%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Should I store offline calculation results in the cache?

2017-05-27 Thread Alex Heyden
Seven years ago, that may very well have been a true statement. I wouldn't
stand by it today. Disk caching should be perfectly stable, even if it's a
pretty poor solution for the average use case.

The part that hasn't changed is memcached. Memcached should be everyone's
default caching solution, not just on Django, but everywhere. You use
memcached until you've proven you have a use case that makes memcached
explicitly the wrong choice, and even then, you have someone else sanity
check your assumptions.

On Sat, May 27, 2017 at 9:17 AM, Alexandre Pereira da Silva <
aletes@gmail.com> wrote:

> Redis caching is a good solution for this. You can have persistence, it's
> fast and only limited by your available RAM.
>
> Your implementation should be more robust about missing itens from the
> cache. If for any reason the cache is lost, your code should rebuild the
> values in a background task.
>
>
>
> On Sat, May 27, 2017 at 6:25 AM, Antonis Christofides <
> anto...@djangodeployment.com> wrote:
>
>> Hello all,
>>
>> I have an application that calculates and tells you whether a specific
>> crop at a specific piece of land needs to be irrigated, and how much. The
>> calculation lasts for a few seconds, so I'm doing it offline with Celery.
>> Every two hours new meteorological data comes in and all the pieces of land
>> are recalculated.
>>
>> The question is where to store the results of the calculation. I thought
>> that since they are re-creatable, the cache would be the appropriate place.
>> However, there is a difference with the more common use of the cache: they
>> are re-creatable, but they are also necessary. You can't just go and delete
>> any item in the cache. This will cripple the website, which expects to find
>> the calculation results in the cache. Viewing something on the site will
>> never trigger a recalculation (and if I make it trigger, it will be a
>> safety procedure for edge cases and not the normal way of doing things).
>> The results must also survive reboots, so I chose the file-based cache.
>>
>> I didn't know about culling, so when the pieces of land grew to 100, and
>> the items in the cache to 400 (4 items need to be stored for each piece of
>> land), I spent a few hours trying to find out what the heck is going on. I
>> solved the problem by tweaking the culling parameters. However all this has
>> raised a few issues:
>>
>>1. The filesystem cache can't grow too much because of issue 11260
>>, which is marked
>>wontfix. According to Russell Keith-Magee
>>,
>>
>> "the filesystem cache is intended as an easy way to test caching, not as
>> a serious caching strategy. The default cache size and the cull strategy
>> implemented by the file cache should make that obvious. If you need a cache
>> capable of holding 10 items, I strongly recommend you look at memcache.
>> If you insist on using the filesystem as a cache, it isn't hard to subclass
>> and extend the existing cache."
>>
>> If these comments are correct, then the documentation needs some fixing,
>> because not only does in not say that the filesystem cache is not for
>> serious use, but it implies the opposite:
>>
>> "Without a really compelling reason, ... you should stick to the cache
>> backends included with Django. They’ve been well-tested and are easy to
>> use."
>>
>> Is Russell not entirely correct perhaps, or is the documentation? Or am I
>> missing something?
>>
>>
>>1. In the end, is it a bad idea to use the cache for this particular
>>case? I also have a similar use case in an unrelated app: a page that 
>> needs
>>about a minute to render. Although I've implemented a quick-and-dirty
>>solution of increasing the web server's timeout and caching the page, I
>>guess the correct way would be to produce that page offline with Celery or
>>so. Where would I store such a page if not in the cache?
>>
>> --
>> Antonis Christofideshttp://djangodeployment.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 post to this group, send email to django-users@googlegroups.com.
>> 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/a5a8d1ab-f4e0-a6b5-b1da-acc9dc2dbf9d%40djan
>> godeployment.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
> 

Re: Django Channels, Nginx, Daphne - Not working?

2017-05-04 Thread Alex Elson
I was able to get it working with the development server, python manage.py 
runserver, with an addition to the firewall on Google Cloud.

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


Re: Django Channels, Nginx, Daphne - Not working?

2017-05-03 Thread Alex Elson
Here is my nginx default configuration if that could be it.

server {
listen 80 default_server;
listen [::]:80 default_server;

root /var/www/html;
charset utf-8;

index index.html index.htm index.nginx-debian.html;

server_name _;

location / {

proxy_pass http://localhost:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
try_files $uri $uri/ =404;
}
}

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


Re: Django Channels, Nginx, Daphne - Not working?

2017-05-03 Thread Alex Elson
I am trying to only use Daphne for websockets  I believe, following the 
deployment tutorial in the Channel documentation. And yes I am running both 
processes on the same machine. 

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


Re: Django Channels, Nginx, Daphne - Not working?

2017-05-03 Thread Alex Elson
I have  "socket = new Websocket("ws:// ...", "socket.onopen," and 
"socket.send" commands in my Javascript code, and although the Javascript 
works, it seems to not be able to run these commands, or it is unable to 
access my functions in consumer.py, althought it works flawlessly if I run 
my project locally.

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


Re: Django Channels, Nginx, Daphne - Not working?

2017-05-03 Thread Alex Elson
Andrew, it doesn't seem to have fixed my problem. I type the following 
command, and am able to connect to my public ip, and although my page 
loads, only the frontend does anything. Channels does not work.

$ daphne -b 0.0.0.0 firstproject.asgi:channel_layer
2017-05-03 06:11:51,196 INFO Starting server at 
tcp:port=8000:interface=0.0.0.0, channel layer 
firstproject.asgi:channel_layer.
2017-05-03 06:11:51,197 INFO HTTP/2 support enabled
2017-05-03 06:11:51,197 INFO Using busy-loop synchronous mode on 
channel layer
2017-05-03 06:11:51,197 INFO Listening on endpoint 
tcp:port=8000:interface=0.0.0.0
127.0.0.1:51076 - - [03/May/2017:06:11:57] "GET /" 200 5801

Is there anything else I may be doing wrong? Is it because I have 
"localhost" in my CHANNEL_LAYERS in CONFIG?

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


Django Channels, Nginx, Daphne - Not working?

2017-05-02 Thread Alex Elson
I am using Google Cloud to host my Django project, and I'm trying to run it 
with Nginx. I open two instances of the terminal, one with the command 
"python manage.py runworker" and the other with "daphne 
firstproject.asgi:channel_layer". I am able to connect to my public ip, and 
the page loads the clientside Javascript, but all the 'Channels' parts do 
not seem to work despite all this. What could be wrong? What am I 
forgetting? Thanks for any help. 

Here is my response to these commands, as well as my CHANNELS_LAYER in my 
settings file.

$ daphne firstproject.asgi:channel_
layer
2017-05-02 07:01:04,853 INFO Starting server 
attcp:port=8000:interface=127.0.0.1, channel layer 
firstproject.asgi:channel_layer.
2017-05-02 07:01:04,853 INFO HTTP/2 support enabled
2017-05-02 07:01:04,853 INFO Using busy-loop synchronous mode on 
channel layer
2017-05-02 07:01:04,854 INFO Listening on endpoint 
tcp:port=8000:interface=127.0.0.1
127.0.0.1:47296 - - [02/May/2017:07:01:17] "GET /" 200 5801

$ python manage.py runworker
2017-05-02 07:06:12,589 - INFO - runworker - Using single-threaded worker.
2017-05-02 07:06:12,589 - INFO - runworker - Running worker against channel 
layer default (asgi_redis.core.RedisChannelLayer)
2017-05-02 07:06:12,590 - INFO - worker - Listening on channels 
http.request, websocket.connect, websocket.disconnect, websocket.receive

CHANNEL_LAYERS = {
"default": {
"BACKEND": "asgi_redis.RedisChannelLayer",
"CONFIG": {
"hosts": [("localhost", 6379)],
},
"ROUTING": "firstproject.routing.channel_routing",
},
}

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


Re: GeoDjango

2017-03-26 Thread Alex Mandel
I'll add that you could also use Geonode http://geonode.org/ which is a
Django front-end to a Geoserver instance.

I've also run Tilestache directly on GeoDjango tables stored in Postgis
to generate TMS style services.

Enjoy,
Alex

PS: GeoDjango has it's own mailing list.

On 03/20/2017 01:05 AM, Jani Tiainen wrote:
> Hi,
> 
> There are several options how to actually server maps.
> 
> Few simplest options are running seperate server that serves maps like
> MapServer, GeoServer or Mapnik.
> 
> Of course if you want to serve maps from Django directly that maybe tricky.
> 
> That django-wms package seems to leverage MapServer mapscript to publish
> maps. Not sure how mature that project is.
> 
> On 18.03.2017 14:51, Samuel Brunel wrote:
>> Hello,
>>
>> I’m new on GeoDjango, I need to known If I can use GeoDjango as  WMS ?
>>
>> Best regards,
>>
>> Samuel
>>
> 

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


Privacy settings like Facebook in Django.

2017-02-22 Thread Alex Richards
I want to implement privacy settings on my extended UserProfile Model where 
the user can decide who can see his field (say email for now).
The options looks something like this,

*public* - any one can view his email
*friends_of_friends* - only friends and friends of friends can view his 
email
*friends* - only his friends can view his email
*friend_list* - only a list of friends (pre defined) can view his email.

I want to implement the same for n fields in the Model (phone number, work, 
education, etc..).

I don't need code but some directions to solve it. Code examples won't 
hurt. 

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


How do I implement a Facebook like privacy settings for extended User?

2017-02-22 Thread Alex Richards
I have an extended UserProfile to which I want to add some privacy settings 
as in Facebook. 

the options for a single field  (say email for now) should be,

*public *- any one can view his email
*friends_of_friends* - only friends and friends of friends can view his 
email
*friends *- only his friends can view his email
*friend_list* - only a list of friends (pre defined) can view his email.

The same should be applicable for other fields too (say phone, education, 
work, likes, activity etc .. ).
Can anyone guide me on the right path? I don't need code but ideas would 
help.
Thanks.

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


Re: browser testing

2017-01-04 Thread Alex Heyden
Everyone who wants into that space compares themselves to Selenium, because
Selenium is that good and has that much market share. It's obnoxious to
use, excludes some less technical users, but behaves very predictably in
skilled hands and has plenty of community support.

If I needed to include less technically inclined testers, I'd pursue Kantu
from https://a9t9.com/. I don't have any direct experience with iMacros,
but out in the wild, I see more people asking how to migrate their iMacros
scripts to Selenium than the other way around. This could be because of the
difference in relative difficulty between the two. Selenium has a learning
curve that makes it better suited to professional testers than, say, random
client representatives doing UAT.

On Wed, Jan 4, 2017 at 6:30 PM, Mike Dewhirst  wrote:

> Does anyone have any recommendations for testing via the browser?
>
> I have heard Selenium mentioned and saw a feature contrast between
> Selenium and Imacro which indicated Imacro is the best choice. Before I do
> the right thing and dig into it myself, are there any war stories or
> testimonials out there?
>
> The objective is to help users to automate their acceptance testing and,
> like unit tests, keep adding new tests as new features are delivered.
>
> Thanks for any advice
>
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/ms
> gid/django-users/c98cdb60-8490-cc58-f614-e64dd4384faa%40dewhirst.com.au.
> For more options, visit https://groups.google.com/d/optout.
>

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


  1   2   3   4   5   6   7   8   9   10   >