Re: drop-in replacement for admin module foreign key relation UI

2015-02-16 Thread Jani Tiainen
On Mon, 16 Feb 2015 15:03:05 -0800 (PST)
Jani Kajala  wrote:

> Hi all,
> 
> I have tons of objects referenced by ForeignKey in Django Admin module UI, 
> and I would like to replace it with something more optimal, e.g. auto-fill 
> input box or something.
> 
> My model looks something like this:
> 
> class SoapCall(models.Model):
> customer = models.ForeignKey(Customer, null=True, blank=True)
> created = models.DateTimeField(default=now)
> wsdl = models.CharField(max_length=255)
> func = models.CharField(max_length=63)
> request = models.TextField()
> response = models.TextField()
> 
> Now, this works great, but if I have 10 Customer objects it's not very 
> nice to generate one huge ... element for every page load.
> 
> There seems to be many possible plugins/implementations for this, but I was 
> just wondering if anyone would have up-to-date recommendations in this 
> mailing list. I'm on Python 3.4.2 and Django 1.7.4.

I would start with built-in implementation, a.k.a. rawid_id_fields 



-- 
Jani Tiainen

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


ImportError

2015-02-16 Thread Petar Pilipovic
Hello all, I am trying to build and e_commerc django app, but I have 
encounter an confusing error.
Mine Error is:
Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/

Django Version: 1.7.4
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'profiles')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')


Template error:
In template 
/home/petarp/Documents/Udemy/Learn_Django/static/templates/navbar.html, 
error at line 15
   cannot import name contactForm
   5 :   


   6 : Toggle navigation


   7 : 


   8 : 


   9 : 


   10 :   


   11 :   Bootstrap theme


   12 : 


   13 : 


   14 :   


   15 : {% url 'home' as home %} 


   16 :{% url 'about' as about %}


   17 :{% url 'contact' as contact %}


   18 : Home


   19 : About


   20 : Contact


   21 : 


   22 :   Dropdown 


   23 :   


   24 : Action


   25 : Another action


Traceback:
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/core/handlers/base.py"
 
in get_response
  111. response = wrapped_callback(request, 
*callback_args, **callback_kwargs)
File "/home/petarp/Documents/Udemy/Learn_Django/source/profiles/views.py" 
in home
  7. return render(request, tempalte, context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/shortcuts.py"
 
in render
  50. return HttpResponse(loader.render_to_string(*args, **kwargs),
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/loader.py"
 
in render_to_string
  178. return t.render(context_instance)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py"
 
in render
  148. return self._render(context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py"
 
in _render
  142. return self.nodelist.render(context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py"
 
in render
  844. bit = self.render_node(node, context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/debug.py"
 
in render_node
  80. return node.render(context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/loader_tags.py"
 
in render
  126. return compiled_parent._render(context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py"
 
in _render
  142. return self.nodelist.render(context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py"
 
in render
  844. bit = self.render_node(node, context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/debug.py"
 
in render_node
  80. return node.render(context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/loader_tags.py"
 
in render
  150. return template.render(context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py"
 
in render
  148. return self._render(context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py"
 
in _render
  142. return self.nodelist.render(context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py"
 
in render
  844. bit = self.render_node(node, context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/debug.py"
 
in render_node
  80. return node.render(context)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/defaulttags.py"
 
in render
  444. url = reverse(view_name, args=args, kwargs=kwargs, 
current_app=context.current_app)
File 
"/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/core/urlresolvers.py"
 
in reverse
  551. return iri_to_uri(resolver._reverse_with_prefix(view, prefix, 
*args, **kwargs))
File 

Django Inline formset with jquery

2015-02-16 Thread Ajay Kumar


Hello all,

I'm trying to build this following link feature in django, 
http://demo.smarttutorials.net/jquery-autocomplete/

Here by choosing serial_no and the rest of the fields name and author 
should be auto populate. Auto populate works for first inline formset and 
able to save it but when I add another inline formset auto populate is not 
working plus I'm unable to delete it or save it.

models.py
from django.db import models
class Book(models.Model):
serial_no = models.IntegerField(max_length = 100, unique = True)
name = models.CharField(max_length = 50)
author = models.CharField(max_length = 50)

def __unicode__(self):
return self.name

class CustomerOrder(models.Model):
name = models.CharField(max_length=256)

def __unicode__(self):
return self.name

class Order(models.Model):
customer  =  models.ForeignKey(CustomerOrder)
serial_no = models.IntegerField(max_length = 100, unique = True)
name = models.CharField(max_length = 50)
author = models.CharField(max_length = 50)
quantity = models.IntegerField(max_length = 100)

def __unicode__(self):
return self.name


forms.py

from django import forms
from bookapp.models import CustomerOrder


class CustomerOrderForm(forms.ModelForm):
class Meta:
model = CustomerOrder
exclude = ('customer',)


views.py

from django.http import HttpResponse
from django.shortcuts import render
from bookapp.models import *
from bookapp.forms import CustomerOrderForm
import json
from django.core.exceptions import ObjectDoesNotExist
from django.http import HttpResponseRedirect
from django.template import RequestContext
from django.core.context_processors import csrf
from django.shortcuts import render_to_response, get_object_or_404
from django.forms.models import inlineformset_factory


def home(request):
context =  RequestContext(request)
OrderFormSet =   inlineformset_factory(CustomerOrder, Order  ,extra=1, 
exclude=('customer',))
if request.method == "POST":
customerorderform = CustomerOrderForm(request.POST)
orderformset = OrderFormSet(request.POST)
if customerorderform.is_valid() and orderformset.is_valid():
a = customerorderform.save()
orderformset.save(commit=False)
orderformset.instance = a
orderformset.save()
return HttpResponse('Added')
else:
customerorderform = CustomerOrderForm()
orderformset = OrderFormSet()
for orderform in orderformset:
orderform.fields['serial_no'].widget.attrs = {'id' : 'sno', 
'onkeydown':"myFunction()"}
orderform.fields['name'].widget.attrs = {'id' : 'bname'}
orderform.fields['author'].widget.attrs = {'id' : 'bauthor'}

args = {}
args.update(csrf(request))
args = {'customerorderform':customerorderform, 'orderformset':orderformset}
return render_to_response('home.html',args,context)

def fetch_serial_nos(request):
serial_nos = map(lambda x: str(x.serial_no), Book.objects.all())
return HttpResponse(content = json.dumps({'serial_nos': serial_nos}), 
content_type = "application/json; charset=UTF-8")

def get_entry_corresponds_to_serial_no(request):
serial_no = request.GET['serial_no']
try: 
entry = Book.objects.get(serial_no=int(serial_no))
data = {'name': entry.name, 'author': entry.author}
except (ObjectDoesNotExist, ValueError):
data = {'name': '', 'author': ''}
return HttpResponse(content = json.dumps(data), content_type = 
"application/json; charset=UTF-8")


home.html




Enter S.NO

$(function() {
$(".inline.{{ orderformset.prefix }}").formset({
prefix: "{{ orderformset.prefix }}",
})
})



Orders
{% csrf_token %}

Customer
{{customerorderform}}

   
Order
{{ orderformset.management_form }}
{{ orderformset.non_form_errors }}
{% for form in orderformset %}
{{ form.id }}

{{form}}

{% endfor %}









$(function(){
$.ajax({
type: "GET",
url: '/serial_nos/',
success: function (response) {
serial_nos = response['serial_nos'];
$( "#sno" ).autocomplete({
source: serial_nos
 });
},
});   
});
function myFunction(){ 
var sno = document.getElementById("sno").value;
console.log(sno)
document.getElementById("demo").innerHTML = "You selected: " + sno;
$.ajax({
type: "GET",
url: '/entry/',
data : {
serial_no : sno,
},
success: function (response) {
console.log('success') 
bname.value = response['name'];
bauthor.value = 

drop-in replacement for admin module foreign key relation UI

2015-02-16 Thread Jani Kajala
Hi all,

I have tons of objects referenced by ForeignKey in Django Admin module UI, 
and I would like to replace it with something more optimal, e.g. auto-fill 
input box or something.

My model looks something like this:

class SoapCall(models.Model):
customer = models.ForeignKey(Customer, null=True, blank=True)
created = models.DateTimeField(default=now)
wsdl = models.CharField(max_length=255)
func = models.CharField(max_length=63)
request = models.TextField()
response = models.TextField()

Now, this works great, but if I have 10 Customer objects it's not very 
nice to generate one huge ... element for every page load.

There seems to be many possible plugins/implementations for this, but I was 
just wondering if anyone would have up-to-date recommendations in this 
mailing list. I'm on Python 3.4.2 and Django 1.7.4.

Thanks beforehand. :) 


Br,
Jani

P.S. <3 Django

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


Re: Implementing a grammar checker on the web

2015-02-16 Thread Ricardo Daniel Quiroga
security disable CORS, and add CSRF tokken verification..
if only going to implement the grammar interpreter is way too django uses
something simpler like bottle or flask

2015-02-16 16:02 GMT-03:00 Ricardo Daniel Quiroga :

> Hi
>
> html + textarea + javascript +  AJAX?
>
>
>
> 2015-02-16 9:58 GMT-03:00 Kelvin Nyota :
>
> I have built a grammar checker in Python. It works well in the terminal,
>> but i don't know how to implement it on the web. How can I implement a
>> grammar checker on the web, like Grammarly or spellcheckerplus? I could not
>> find any article that talked about that at all.Most of it was errelevant.
>> Infact, what I have done with Javascript for my grammarchecker
>>  interface is
>> better. Please help guys.
>>
>> I will not need a database because I have a text file for replacing
>> words. What I don't know is if I will need some sort of a server to
>> communicate back and forth for reading, checking, and retrieving. The link
>> on the grammar checker button should also be protected to prevent people
>> from using my code to do their grammar checking functionality on their
>> websites.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/b7817512-cdad-460d-b0b9-a643e303d490%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
>
> Ricardo Daniel Quiroga
>
>


-- 

Ricardo Daniel Quiroga

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


Re: Implementing a grammar checker on the web

2015-02-16 Thread Ricardo Daniel Quiroga
Hi

html + textarea + javascript +  AJAX?



2015-02-16 9:58 GMT-03:00 Kelvin Nyota :

> I have built a grammar checker in Python. It works well in the terminal,
> but i don't know how to implement it on the web. How can I implement a
> grammar checker on the web, like Grammarly or spellcheckerplus? I could not
> find any article that talked about that at all.Most of it was errelevant.
> Infact, what I have done with Javascript for my grammarchecker
>  interface is better.
> Please help guys.
>
> I will not need a database because I have a text file for replacing words.
> What I don't know is if I will need some sort of a server to communicate
> back and forth for reading, checking, and retrieving. The link on the
> grammar checker button should also be protected to prevent people from
> using my code to do their grammar checking functionality on their websites.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b7817512-cdad-460d-b0b9-a643e303d490%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Ricardo Daniel Quiroga

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


Re: my mysite/templates/admin/base_site.html is ignored (tutorial unclear?)

2015-02-16 Thread Djarum Tujuhenam
I am using Debian 7 and Python 2.7, Django version 1.7

Reading the Tutorial on the exactly same page : 
https://docs.djangoproject.com/en/1.7/intro/tutorial02/

The result is our admin template completely ignored.


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


Re: how to get a link to an absolute hyperlink

2015-02-16 Thread dk
doing the http at the front did work!  thanks.

On Friday, February 13, 2015 at 5:09:15 PM UTC-6, Vijay Khemlani wrote:
>
> Try adding "http://; at the start
>
> Also, consider that the format is 111.111.111.111: (the port is after 
> a colon, not a dot)
>
> On Fri, Feb 13, 2015 at 8:03 PM, dk  
> wrote:
>
>> its just a string with an ip address and that's it.  
>>
>>  {{ j }} 
>> so at the end should be something like
>> 11.111.11. 
>>
>> instead I get the hole path of my url + /11.111.11.   
>> I just want to go to 11.111.11.
>>
>>
>>
>>
>> On Friday, February 13, 2015 at 4:46:44 PM UTC-6, daniel.franca wrote:
>>
>>> How's the hyperlink saved in the column? If it's a relative one this is 
>>> what is going to happen, to change that you need an absolute link, i.e: 
>>> http://google.com
>>> On Fri 13 Feb 2015 at 23:40 dk  wrote:
>>>
 this is my template
 I do have this address
 http://127.0.0.1:8000/mes/show_table/
 and show a table where the second colum is a link to somewhere else,  
 the problem is when I click it lunch me to
 http://127.0.0.1:8000/mes/show_table/clickedLinkand doesn't work.

 as an example if one of my links in the table is pointing to google
 o do get 
 http://127.0.0.1:8000/mes/show_table/google
 instead of just
 google

 is there a tag or some magic in django to say  just send me here?

 thanks  guys.


  
  {% for i in lista %}
  
 {% for j in i %}
{% if forloop.counter == 4 %}
>>> >{{ j }}  
{% else %}
   {{ j }}

{% endif %}
 {% 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...@googlegroups.com.
 To post to this group, send email to django...@googlegroups.com.
 Visit this group at http://groups.google.com/group/django-users.
 To view this discussion on the web visit https://groups.google.com/d/
 msgid/django-users/c6ccb7e1-e202-45cc-a458-02b6c9029eea%
 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/04c2d8ae-8ea5-4847-bbdc-0dc1e323eff7%40googlegroups.com
>>  
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


Re: Chess App

2015-02-16 Thread dravid rahul
Thank you Cal,

Right now i am working on that .Anywhere if i get stuck please help me with 
this


On Monday, February 16, 2015 at 7:03:24 PM UTC+5:30, Cal Leeming wrote:
>
> Hello, 
>
> This should help; 
> https://www.facebook.com/help/110919988996182 
>
> As for chess, you can look at; 
> https://pypi.python.org/pypi/python-chess 
>
> Also, try and use Google in future to answer questions like these, I 
> was able to find this first time by searching for "how to make a 
> facebook app" followed by "python chess". 
>
> If you have any specific questions you want answering, feel free to ask 
>
> Cal 
>
> On Mon, Feb 16, 2015 at 3:39 AM, dravid rahul  > wrote: 
> > Hi Experts , 
> > 
> > How can i build a chess app and deploy it on facebook.Can anyone please 
> > help me on this ,i had done google but i cant find it. 
> > 
> > Thanks 
> > Karthik 
> > 
> > 
> > 
> > 
> > -- 
> > You received this message because you are subscribed 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 http://groups.google.com/group/django-users. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/django-users/d9d4a7f5-26d5-45b9-84f6-c0746b79ee5e%40googlegroups.com.
>  
>
> > For more options, visit https://groups.google.com/d/optout. 
>

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


Re: Chess App

2015-02-16 Thread Cal Leeming
Hello,

This should help;
https://www.facebook.com/help/110919988996182

As for chess, you can look at;
https://pypi.python.org/pypi/python-chess

Also, try and use Google in future to answer questions like these, I
was able to find this first time by searching for "how to make a
facebook app" followed by "python chess".

If you have any specific questions you want answering, feel free to ask

Cal

On Mon, Feb 16, 2015 at 3:39 AM, dravid rahul  wrote:
> Hi Experts ,
>
> How can i build a chess app and deploy it on facebook.Can anyone please
> help me on this ,i had done google but i cant find it.
>
> Thanks
> Karthik
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d9d4a7f5-26d5-45b9-84f6-c0746b79ee5e%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

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


Implementing a grammar checker on the web

2015-02-16 Thread Kelvin Nyota
 

I have built a grammar checker in Python. It works well in the terminal, 
but i don't know how to implement it on the web. How can I implement a 
grammar checker on the web, like Grammarly or spellcheckerplus? I could not 
find any article that talked about that at all.Most of it was errelevant. 
Infact, what I have done with Javascript for my grammarchecker 
 interface is better. 
Please help guys.

I will not need a database because I have a text file for replacing words. 
What I don't know is if I will need some sort of a server to communicate 
back and forth for reading, checking, and retrieving. The link on the 
grammar checker button should also be protected to prevent people from 
using my code to do their grammar checking functionality on their websites.

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


Re: File upload error

2015-02-16 Thread Amirouche Boubekki
Héllo Sola,


Can you post the full stacktrace not only the error?


Regards

On Mon Feb 16 2015 at 11:20:42 AM Sola Chong  wrote:

> I having a error "*expected string or buffer*" when submit to upload
> avatar when edit profile. Can't figure out what is the problem..
>
> *Model:*
> class MyProfile(models.Model):
> user = models.ForeignKey(User)
> dob = models.DateField(null=True, blank=True)
> address = models.CharField(max_length=100, blank=True)
> contact = models.CharField(max_length=50, blank=True)
> bio = models.TextField(blank=True)
> avatar_url = FileField(_("Avatar"), max_length=200, format="Image",
>  upload_to='user/avatar', blank=True)
> banner_url = FileField(_("Cover"), max_length=200, format="Image",
>  upload_to='user/cover', blank=True)
> created = models.DateTimeField(auto_now_add=True)
> last_modified = models.DateTimeField(auto_now=True)
>
> *Forms:*
> class UserModelForm(forms.ModelForm):
> class Meta:
> model = User
> fields = ('first_name', 'last_name', 'email')
> widgets = {
> 'email': forms.TextInput(attrs={'readonly':'readonly'}),
> }
>
>
> class UserProfileModelForm(forms.ModelForm):
> dob = forms.DateField(widget=forms.DateInput(format = '%d/%m/%Y'),
>input_formats=('%d/%m/%Y',),
>required=True, help_text='dd/mm/')
> avatar_url = forms.FileField()
>
> class Meta:
> model = MyProfile
> fields = ('dob', 'address', 'contact', 'bio', 'avatar_url')
>
>
> *Views:*
> def editProfileView(request, template="controlpanel/cp_edit_profile.html"
> ):
>
> myprofiles = MyProfile.objects.all()
> myprofile = get_object_or_404(myprofiles, user=request.user)
>
> if request.method == "POST":
> form = UserProfileModelForm(request.POST, request.FILES, instance=
> myprofile)
> userForm = UserModelForm(request.POST, request.FILES, instance=
> request.user)
>
> if form.is_valid() and userForm.is_valid():
> user = userForm.save()
> profile = form.save(commit = False)
> profile.user = user
> profile.save()
>
>
> info(request, _("Successfully Edit"))
> else:
> userForm = UserModelForm(instance=request.user)
> form = UserProfileModelForm(instance=myprofile)
>
>
> context = {"cpprofile": myprofile, 'userForm':userForm, 'form':form}
>
> return render(request, template, context)
>
> *Template:*
> 
> 
> {{ title }}
> {% fields_for userForm %}
> {% fields_for form %}
> 
> {% block account_form_actions %}
>  "submit" value="Submit">
> {% endblock %}
> 
> 
> 
>
>
> Thank you 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c34f91dc-20a8-4195-ba8d-134287e1f9ae%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


File upload error

2015-02-16 Thread Sola Chong
I having a error "*expected string or buffer*" when submit to upload avatar 
when edit profile. Can't figure out what is the problem..

*Model:*
class MyProfile(models.Model):
user = models.ForeignKey(User)
dob = models.DateField(null=True, blank=True)
address = models.CharField(max_length=100, blank=True)
contact = models.CharField(max_length=50, blank=True)
bio = models.TextField(blank=True)
avatar_url = FileField(_("Avatar"), max_length=200, format="Image",
 upload_to='user/avatar', blank=True)
banner_url = FileField(_("Cover"), max_length=200, format="Image",
 upload_to='user/cover', blank=True)
created = models.DateTimeField(auto_now_add=True)
last_modified = models.DateTimeField(auto_now=True)

*Forms:*
class UserModelForm(forms.ModelForm):
class Meta:
model = User
fields = ('first_name', 'last_name', 'email')
widgets = {
'email': forms.TextInput(attrs={'readonly':'readonly'}),
}


class UserProfileModelForm(forms.ModelForm):
dob = forms.DateField(widget=forms.DateInput(format = '%d/%m/%Y'), 
   input_formats=('%d/%m/%Y',), 
   required=True, help_text='dd/mm/')
avatar_url = forms.FileField()

class Meta:
model = MyProfile
fields = ('dob', 'address', 'contact', 'bio', 'avatar_url')


*Views:*
def editProfileView(request, template="controlpanel/cp_edit_profile.html"):

myprofiles = MyProfile.objects.all()
myprofile = get_object_or_404(myprofiles, user=request.user)

if request.method == "POST":
form = UserProfileModelForm(request.POST, request.FILES, instance=
myprofile)
userForm = UserModelForm(request.POST, request.FILES, instance=
request.user)

if form.is_valid() and userForm.is_valid():
user = userForm.save()
profile = form.save(commit = False)
profile.user = user
profile.save()


info(request, _("Successfully Edit"))
else:
userForm = UserModelForm(instance=request.user)
form = UserProfileModelForm(instance=myprofile)


context = {"cpprofile": myprofile, 'userForm':userForm, 'form':form}

return render(request, template, context)

*Template:*


{{ title }}
{% fields_for userForm %}
{% fields_for form %}

{% block account_form_actions %}

{% endblock %}





Thank you 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c34f91dc-20a8-4195-ba8d-134287e1f9ae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.