These are chat archives for django/django

Jun 2016
Jared Mackey
Jun 17 2016 02:12 UTC
After several of my most recent projects I have come to the conclusion that i could really used a trimmed down version of Django that is just the ORM.
Stripped of all the web stuff.
Has anyone seen a project like this before? Would this be possible? Has there been mention of interest in something like this before?
Ajay Yadava
Jun 17 2016 03:56 UTC
@mackeyja92 Sqlalchemy?
Jun 17 2016 06:14 UTC
I'm in a similar situation where I want to use react with django, I don't want to use react router thou and just stick to django router and the orm, haven't gotten to far in figuring that one out
Anton Tokar
Jun 17 2016 06:27 UTC
str1 = 'aldjflaksdjfoaivhoadsvhaiouh'
def s(x):
    num = x.index('a') + x.index('e') + x.index('i') + x.index('o') + x.index('u')
    return num
print "Number of vowels:" + s(str1)
help) why it doesn't work
Jun 17 2016 06:40 UTC
What error @AntonTokar ?
Jun 17 2016 06:54 UTC
@AntonTokar this will work
str1 = 'aldjflaksdjfoaivhoadsvhaiouh' 

def s(x):
 for n in x: 
  if (n=='a' or n=='e' or n=='i' or n=='o' or n=='u'):
   num = num+1
 return num 

print "Number of vowels:" , s(str1)
Anton Tokar
Jun 17 2016 06:59 UTC
@QbasicFan thanks
str1 = 'aldjflaksdjfoaivhoadsvhaiouh'
print str1.count('a') + str1.count('e') + str1.count('i') + str1.count('o') \
    + str1.count('u')
@QbasicFan I've found a better variant , I think)
Jun 17 2016 07:01 UTC
@AntonTokar even better :+1:
Anton Tokar
Jun 17 2016 07:01 UTC
@mpachas the error has been "ValueError: substring not found"
@QbasicFan I'm going through MIT course about Python now =)
and I want to be programmer and to use django in future , but now I'm only at beginning and I'm learning the basis's of Python
something like "Let me introduce myself" =)
Jun 17 2016 07:07 UTC
@AntonTokar good try pygame also , if you want to make little games
Anton Tokar
Jun 17 2016 07:11 UTC
s= 'bobobobxboboobcobooo'
print "Number of times 'bob' occurs is:" + s.count('bob')
here the right answer might be 4, but my program has said 3
@QbasicFan it does't count letters that are repeated, and are the first and last letter of "bob"
@QbasicFan here the right answer should* be 4
Anton Tokar
Jun 17 2016 07:17 UTC
s= 'bobobobxboboobcobooo'
print "Number of times 'bob' occurs is: " + str(s.count('bob'))
because 'count' is for non-overlapping occurrences of subsequence sub
Anton Tokar
Jun 17 2016 07:23 UTC
but I need something similar 'count' but for overlapping chars
Jun 17 2016 07:24 UTC

hello i want to use geos for one project.
i have install successful gdal and leaflet and djgeojson.
i try to open and show me that error :
point import sqlite3_create_function_v2 not
find in library dynamic connection c:programs files (x86)\GDAL\spatialite.dll(i have this dll in my files)


if i remove leaflet from INSTALLED_APPS then dont show me error,
i have windows 10 ,python 2.7.11 32 bit
any idea ?i need help

Jun 17 2016 09:10 UTC

Hi, everyone! Here is my problem: i have an HTML template and standalone JS script. Inside script i do AJAX requests to my app, so to not to harcode urls i want to use django's{% url %}, but i cannot simply use it in JS.
I have found one solution: generate urls in HTML in <script>and store them in var, but my urls have parameters, so i have to do something like

var url = "{% url 'someapp:somename' param='99999' %}";

in HTML (where '99999' is magic number), and

url.replace('99999', param);

in JS. But i think its quite ugly :worried:
So, what is the best way to do it?

Filip Figiel
Jun 17 2016 11:05 UTC
@mmosharov that's the most common way to do that
you could use '0' because 999 seems very off-putting
there's this library but I didn't like amount of effort required to configure it
@cs89gr your best bet is to seek help with the library you're trying to integrate with django. I don't know what's the problem but it's definitely not on django side
Jun 17 2016 11:09 UTC
@megapctr Thank a lot! :smile:
Jun 17 2016 12:07 UTC
str1 = 'aldjflaksdjfoaivhoadsvhaiouh' 
chars = 'aeiou'
if any((c in chars) for c in str1):
     num += 1
Jun 17 2016 13:12 UTC
Hello, Everyone!
I am going to build the authentication(sign up/ sign in) using python / django.
Here is the detail of the project I am goint to build;
In summary, AngularJS landing page; Django w/RESTful endpoints for login/signup/and social login (Twitter & Facebook); use django-rest-framework and allauth for social login; and any other framework (as specified in job description) that would aid in doing Twitter & Facebook logins.
Can someone help me to build this project?
Jared Mackey
Jun 17 2016 13:25 UTC
@ajayyadava Yes I have looked at that but I love Django's ORM. I really just want that as a seperate piece
Ajay Yadava
Jun 17 2016 13:26 UTC
Aah. Got it.
Filip Figiel
Jun 17 2016 14:05 UTC
@mackeyja92 I think you should contact django devs directly in this case
@webscrapy-expert use django rest framework and restframework-jwt
Jared Mackey
Jun 17 2016 14:06 UTC
@megapctr just wanted to see if there was interest
Jun 17 2016 14:14 UTC
@megapctr have you got any sample for the prject?
actually am a new to django and would like you to help me in the project.
Filip Figiel
Jun 17 2016 14:21 UTC
not really, sorry
Jun 17 2016 14:22 UTC
just found the github link;
is it smiliar to my project?
Filip Figiel
Jun 17 2016 15:02 UTC
I havent used it
Patrick Harding
Jun 17 2016 15:48 UTC
@mackeyja92 hey man
Joseph Muli
Jun 17 2016 16:46 UTC

down vote
I have a shopping cart rendered by view method A, I want to get the details in the cart to be submitted to the pesapal api. I'm using the same method as the sandbox app, PaymentView. The shopping cart has a checkout button which is intended to submit the data to the api. The Sandbox method simlpy gets the data as a dictionary (order_info) and feeds to the url, thus when I open the template, the api's iframe dictates I am withrawing the amout specified in the dictionary. How can I submit data via the cart?

Sandbox method submitting data to the api

class PaymentView(TemplateView, PaymentRequestMixin):
template_name = 'payment/payment.html'

# how the sandbox app submits data to api:

def get_context_data(self, **kwargs):
    ctx = super(PaymentView, self).get_context_data(**kwargs)

    order_info = {
    'amount': '1000',
    'description': 'Ad Payment for adlink',
    'reference': 2,
    'email': ''

ctx['pesapal_url'] = self.get_payment_url(**order_info)
return ctx

view method A:

def show_cart(request, template_name="payment/cart.html"):
if request.method == 'POST':
data = {}
postdata = data
postdata = request.POST.copy()
if postdata['submit'] == 'Remove':
if postdata['submit'] == 'Update':
if postdata['submit'] == 'Checkout':

        # submission to api should occur here 
cart_items = cart.get_cart_items(request)
cart_subtotal = cart.cart_subtotal(request)
return render_to_response(template_name, locals(), context_instance=RequestContext(request))
Jared Mackey
Jun 17 2016 16:47 UTC
@senorpatricio No way! How’s it going man!
sorry the first one doesn't make much sense