These are chat archives for django/django

17th
Jun 2016
Jared Mackey
@mackeyja92
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
@ajayyadava
Jun 17 2016 03:56 UTC
@mackeyja92 Sqlalchemy?
Evita
@webel
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
@AntonTokar
Jun 17 2016 06:27 UTC
hello
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
mpachas
@mpachas
Jun 17 2016 06:40 UTC
What error @AntonTokar ?
QbasicFan
@QbasicFan
Jun 17 2016 06:54 UTC
@AntonTokar this will work
str1 = 'aldjflaksdjfoaivhoadsvhaiouh' 

def s(x):
 num=0
 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
@AntonTokar
Jun 17 2016 06:59 UTC
@QbasicFan thanks
@QbasicFan
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)
QbasicFan
@QbasicFan
Jun 17 2016 07:01 UTC
@AntonTokar even better :+1:
Anton Tokar
@AntonTokar
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" =)
QbasicFan
@QbasicFan
Jun 17 2016 07:07 UTC
@AntonTokar good try pygame also , if you want to make little games
Anton Tokar
@AntonTokar
Jun 17 2016 07:11 UTC
@QbasicFan
s= 'bobobobxboboobcobooo'
print "Number of times 'bob' occurs is:" + s.count('bob')
@QbasicFan
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
@AntonTokar
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
@AntonTokar
Jun 17 2016 07:23 UTC
but I need something similar 'count' but for overlapping chars
cs89gr
@cs89gr
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 manage.py 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)

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.gis',
    'leaflet',
    'djgeojson'

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

mmosharov
@mmosharov
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?
Thanks!

Filip Figiel
@megapctr
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 https://github.com/ierror/django-js-reverse
@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
mmosharov
@mmosharov
Jun 17 2016 11:09 UTC
@megapctr Thank a lot! :smile:
Oleksiy
@doubledare704
Jun 17 2016 12:07 UTC
@QbasicFan
str1 = 'aldjflaksdjfoaivhoadsvhaiouh' 
chars = 'aeiou'
if any((c in chars) for c in str1):
     num += 1
webscrapy-expert
@webscrapy-expert
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
@mackeyja92
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
@ajayyadava
Jun 17 2016 13:26 UTC
Aah. Got it.
Filip Figiel
@megapctr
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
@mackeyja92
Jun 17 2016 14:06 UTC
@megapctr just wanted to see if there was interest
webscrapy-expert
@webscrapy-expert
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
@megapctr
Jun 17 2016 14:21 UTC
not really, sorry
webscrapy-expert
@webscrapy-expert
Jun 17 2016 14:22 UTC
just found the github link; https://github.com/Tivix/django-rest-auth
is it smiliar to my project?
Filip Figiel
@megapctr
Jun 17 2016 15:02 UTC
I havent used it
Patrick Harding
@senorpatricio
Jun 17 2016 15:48 UTC
@mackeyja92 hey man
Joseph Muli
@josephmuli
Jun 17 2016 16:46 UTC

down vote
favorite
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': 'you@email.com'
}

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':
cart.remove_from_cart(request)
if postdata['submit'] == 'Update':
cart.update_cart(request)
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
@mackeyja92
Jun 17 2016 16:47 UTC
@senorpatricio No way! How’s it going man!
sorry the first one doesn't make much sense