Re: Am I being hacked?

2021-05-07 Thread Stephen J. Butler
Unlikely. The local connection is in a high port range and the remote connection's port is 443, which indicates your machine made an outbound HTTPS connection to that IP. Does your code make any HTTP requests? Does it use anything like OpenID Connect for auth? Do you have SSL certs it is checking

Re: Apple M1 Silicon + Django = weird results

2020-12-21 Thread Stephen J. Butler
Looking at that code for RangedFileResponse, I'm kind of skeptical that it properly implements the Range header. Try removing that bit and see if it works. Have you tried the download with various browsers? I wonder if Safari or Chrome released at the same time as the M1 chips is causing

Re: Security issue in django.db.models

2020-08-08 Thread Stephen J. Butler
If you look at the documentation for 'blank' it says: """ Note that this is different than null. null is purely database-related, whereas blank is validation-related. If a field has blank=True, *form validation* will allow entry of an empty value. If a field has blank=False, the field will be

Re: Trouble getting kwargs into filter

2020-07-05 Thread Stephen J. Butler
get_queryset() isn't documented as taking any args at all, let alone the kwargs of the request. You sometimes see people do "def get_queryset(self, **kwargs)" to future-proof themselves in case get_queryset does, one day, accept args. But it doesn't right now. To get the kwargs for the request

Re: Ajax and Django and jQuery - .attr()

2020-05-31 Thread Stephen J. Butler
This isn't a jQuery issue, it's a JavaScript/ECMAScript issue. When you use the "arrow function" style like "() => { ...code... }" then certain variables are not bound into the function contact, including "this".

Re: Forienkey to same table

2020-03-29 Thread Stephen J. Butler
Instead of using the model class, or string name of the model class, use the string value 'self'. https://docs.djangoproject.com/en/3.0/ref/models/fields/#foreignkey On Sun, Mar 29, 2020 at 9:44 PM Mohsen Pahlevanzadeh < m.pahlevanza...@gmail.com> wrote: > I have table A with my following

Re: keep getting the Fatal Python error with mod_wsgi and apache

2020-03-26 Thread Stephen J. Butler
Did you recreate the virtualenv on the server, or did you copy it from your development machine? You should recreate virtualenv's when deploying to a different server. On Thu, Mar 26, 2020 at 8:53 AM Fateh Budwal wrote: > Yes python 3.8.2 is installed > > On Wednesday, March 25, 2020 at 8:30:35

Re: Running django admin separately

2020-02-29 Thread Stephen J. Butler
I think so. Haven't tested, one way should be be to have have two url.py's, one that includes only the admin URLs and one that includes only your project URLs. Then have two settings modules that look like this: # main site settings from .settings import * ROOT_URLCONF = 'myproject.urls_main' #

Re: Why can't Nginx find Django's static files?

2020-02-21 Thread Stephen J. Butler
like you should have. On Fri, Feb 21, 2020 at 11:49 AM Robert F. wrote: > > > On Thursday, February 20, 2020 at 8:52:31 AM UTC-8, Stephen J. Butler > wrote: >> >> Django only serves up static files itself when run using runserver. This >> is meant for develop

Re: Why can't Nginx find Django's static files?

2020-02-20 Thread Stephen J. Butler
Django only serves up static files itself when run using runserver. This is meant for development and not production use. When you run it through gunicorn the Django framework won't serve up static files. That's why you connections to :8000 (gunicorn directly, bypassing nginx) don't work right.

Re: Django query with few data(1,000-3,000) takes too long(1min) to load

2020-02-07 Thread Stephen J. Butler
You've got a lot of foreign key fields where the fetch is being deferred until template render time, and it being done individually for each row instead of in bulk. I think if you added this attribute to your ListView subclass you'd see better performance: queryset =

Re: How to express `foo = (bar < quox)` as a constraint

2020-01-27 Thread Stephen J. Butler
Frankly, if is_on_sale has such a tight constraint I wouldn't have it as its own column. Why not just make it an annotated field with an F expression? https://docs.djangoproject.com/en/3.0/ref/models/expressions/#using-f-with-annotations Item.objects.annotate(is_on_sale=(F('price') <

Re: Error: Key 'groups' not found in 'UserForm'

2020-01-05 Thread Stephen J. Butler
Take another look at the doc's example on formfield_for_manytomany: https://docs.djangoproject.com/en/3.0/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_manytomany You need to call super() and this isn't the right way to override the widget. def formfield_for_manytomany(self,

Re: SyntaxError SECRET_KEY

2020-01-05 Thread Stephen J. Butler
My guess is that you have an unbalanced '(' on a previous line and the error doesn't get thrown until here (when it thinks maybe SECRET_KEY is a kwarg to the function call). What does the previous setting or two look like? On Sun, Jan 5, 2020 at 3:06 PM 'Dash LaLonde' via Django users <

Re: SyntaxError SECRET_KEY

2020-01-05 Thread Stephen J. Butler
On Sun, Jan 5, 2020 at 3:13 PM Mohamed A wrote: > Be careful your secret key contains a # > > Which comment everything after > > Not when it's quoted as part of a string. It should be fine in this case. -- You received this message because you are subscribed to the Google Groups "Django

Re: get user that is member of two different group

2020-01-02 Thread Stephen J. Butler
I don't think that's what the he asked for. It will return users who are members of either test1 OR test2, but I read the question as returning users who are members of both test1 AND test2. I think the proper query would be: User.objects.filter(groups__name='test1').filter(groups__name='test2')

Re: Error in function to return permissions

2018-10-31 Thread Stephen J. Butler
@login_required needs "request" as the first parameter. On Wed, Oct 31, 2018 at 11:58 AM Joel Mathew wrote: > I have a custom function to check if a user is authorized to do > certain functions: > > @login_required > def checkpermission(request, permiss): > username = request.user.username

Re: __init__.py Won't Upload To Github Respository

2018-09-01 Thread Stephen J. Butler
GitHub has an excellent set of gitignore files. My first commit to a project is always one of these: https://github.com/github/gitignore In particular: https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore On Sat, Sep 1, 2018 at 10:52 AM Kasper Laudrup wrote: > Hi Sandy,

Re: Decorator function argument woes

2018-04-30 Thread Stephen J. Butler
M, Mike Dewhirst <mi...@dewhirst.com.au> wrote: > On 30/04/2018 3:35 PM, Stephen J. Butler wrote: > >> @login_required doesn't take a test function. You need to use >> @user_passes_test directly. >> > > Thank you Stephen. > > I thought I'd start another th

Re: Decorator function argument woes

2018-04-29 Thread Stephen J. Butler
@login_required doesn't take a test function. You need to use @user_passes_test directly. On Mon, Apr 30, 2018 at 12:26 AM, Mike Dewhirst wrote: > I'm pretty sure this is a not-understanding-python problem rather than a > Django problem but here goes ... > > In a (FBV)

Re: Django and Oracle12C Connection Error

2018-01-20 Thread Stephen J. Butler
Your Django settings 'NAME' is neither a SID nor a service name. Try: 'NAME': 'testdb', 'USERNAME': 'C##TDBUSER', 'PASSWORD': 'testdb', 'HOST': 'localhost', 'PORT': 1521 On Fri, Jan 19, 2018 at 11:37 PM, Rishab Kumar wrote: >

Re: Channels - unbalanced load for threaded workers

2017-05-17 Thread Stephen J. Butler
CPython uses a global interpreter lock, which means that only one thread per process can ever be running Python code. Where threading really helps is if your python project is mostly I/O bound (waiting on database work, network connections, etc). If it's CPU bound then you probably won't see much

Re: How can I access obj in admin.py

2017-05-03 Thread Stephen J. Butler
You want to override get_inline_instances: https://docs.djangoproject.com/en/1.11/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_inline_instances On Wed, May 3, 2017 at 12:33 AM, Mike Dewhirst wrote: > I want to adjust inlines based on a property of the object. >

Re: What is meaning of '[::1]'?

2016-11-20 Thread Stephen J. Butler
"::1" is the IPv6 loopback address. If you haven't seen IPv6 addresses before, they separate the parts of an address with ":" instead of ".". Using two together ("::") is a shorthand for "fill all these bits with zero" and it can appear only once in an address. You see the brackets "[]" in URLs

Re: how to display JSON data in template

2016-06-27 Thread Stephen J. Butler
Your json_obj is just a collection of python data structures (dictionaries, arrays, strings, ints, etc)... it isn't JSON. You need to serialize it to a string first using DjangoJSONEncoder. https://docs.djangoproject.com/en/1.9/topics/serialization/ On Mon, Jun 27, 2016 at 12:41 PM,

Re: Date() in Django query

2016-06-14 Thread Stephen J. Butler
Assuming "obj" is an instance of a Model class for this table: obj.jointime.date() On Tue, Jun 14, 2016 at 8:52 AM, Galil wrote: > Hi, > > How can I convert this SQL query into a Django query? > > SELECT DATE(JoinTime) FROM table > > Please keep in mind that JoinTime is in

Re: Django and jQuery, I don't get it

2016-06-10 Thread Stephen J. Butler
Specifically, this style is called an Immediately Invoked Function Expression, or IIFE. https://en.wikipedia.org/wiki/Immediately-invoked_function_expression On Fri, Jun 10, 2016 at 3:36 AM, ludovic coues wrote: > > (function($) { > > 'use strict'; > > > >

Re: Non Ascii character in upload file crash in python 3

2016-06-08 Thread Stephen J. Butler
Whats the stack trace? On Wed, Jun 8, 2016 at 3:01 AM, Luis Zárate <luisz...@gmail.com> wrote: > $ python manage.py shell > > >>> import sys > >>> sys.getfilesystemencoding() > 'utf-8' > > > > 2016-06-08 1:57 GMT-06:00 Stephen J. But

Re: Non Ascii character in upload file crash in python 3

2016-06-08 Thread Stephen J. Butler
Have you tried this? https://docs.djangoproject.com/en/1.9/ref/unicode/#files You probably have a system setup where ASCII is the filesystem encoding. It tells you a way to fix that on Linux/Unix. On Wed, Jun 8, 2016 at 2:44 AM, Luis Zárate wrote: > Hi, > > I am having

Re: authenticate a user without databse

2016-06-07 Thread Stephen J. Butler
Another option is to do all the authentication in Apache and use the Django RemoteUser backend. This would require writing an Apache authnz module to talk to the c++ server, and adjusting your Apache configs to require valid-user. Or, if not Apache, whatever server you are using. Nothing about

Re: authenticate a user without databse

2016-06-02 Thread Stephen J. Butler
Did you use the login_required decorator on your view? Authentication is something you have to specify you want for a page, it is not assumed. https://docs.djangoproject.com/en/1.9/topics/auth/default/#the-login-required-decorator On Thu, Jun 2, 2016 at 3:54 AM, prabhat jha

Re: Views.py & template (queryset)

2016-06-02 Thread Stephen J. Butler
Add date2016 to your context: { 'test': test, 'date2016': date2016 } Then it's just {{ date2016 }} in your template. On Thu, Jun 2, 2016 at 6:36 AM, Franck wrote: > Hello Stephen, > Thanks for your help, ok I think it's better to used views for what I need > to do. > Last

Re: Views.py & template (queryset)

2016-06-01 Thread Stephen J. Butler
>From the template language reference: < https://docs.djangoproject.com/en/1.9/ref/templates/language/#accessing-method-calls > """ Because Django intentionally limits the amount of logic processing available in the template language, it is not possible to pass arguments to method calls accessed

Re: Simultaneous Web Requests appending responses in function based views

2016-05-31 Thread Stephen J. Butler
The code and output you've shown us don't make any sense. You're really going to have to provide a complete, minimal project. On Tue, May 31, 2016 at 9:40 AM, cr katz wrote: > Thanks Stephen. As suggested, below is the output. 'p' is being > overwritten before the first

Re: Simultaneous Web Requests appending responses in function based views

2016-05-30 Thread Stephen J. Butler
Ohhh... you're looking at the server logs? Those are never going to be sequential. Your requests operate in parallel. That's why you see interleaved outputs. Modify your print statement like this to see what's happening: print " {1}".format(id(request), func) You should see the proper results,

Re: Simultaneous Web Requests appending responses in function based views

2016-05-30 Thread Stephen J. Butler
I don't see anything in your pasted code that would cause that in the browser. Have you provided us a complete example that exhibits that behavior? Reduce your project down to the smallest set of code that exhibits the problem and then upload it somewhere we can see it. On Mon, May 30, 2016 at

Re: Simultaneous Web Requests appending responses in function based views

2016-05-30 Thread Stephen J. Butler
What's your actual output vs. what's your desired output? Also, the RequestContext is meant for the render() function. If you just want to access request.GET then you can do it directly (request is passed in as the first parameter to your view func). You also don't need to pre-assign qList and

Re: Regular Expression with Variables.

2016-05-19 Thread Stephen J. Butler
You can't provide multiple regex's to the RegexField. What you were doing before is exactly equivalent to this: r'^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!$%^&*?@#-_+=]).*$' So for my suggestion, just do this:

Re: Regular Expression with Variables.

2016-05-18 Thread Stephen J. Butler
I think I'd just use format() on the regex, being careful to escape '{' and '}': regex_f=r'^.*(?=.*{{{MIN},{MAX}}}*)(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!$%^ &*?@#-_+=])' regex=regex_f.format(MIN=settings.MY_RE_MIN, MAX=settings.MY_RE_MAX) On Thu, May 19, 2016 at 12:37 AM, Arun S

Re: timezone application aware

2016-05-17 Thread Stephen J. Butler
I'm only experienced with the Oracle backend, but I believe only Postgres stores datetimes with timezone information. Otherwise, Django assumes all datetimes in the database are UTC. For the most portability you should assume that database values will be in UTC. The user's local timezone is

Re: Possible bug with transaction.on_commit

2016-05-16 Thread Stephen J. Butler
I believe that's as designed. There's this part in the documentation of "Database transactions": Callbacks are not run until autocommit is restored on the connection following the commit (because otherwise any queries done in a callback would open an implicit transaction, preventing the

Re: Can't get initial value into form correctly.

2016-05-14 Thread Stephen J. Butler
quot;add_product_forms.update"? Im missing something. . . > > On Sun, May 15, 2016 at 1:00 AM, Stephen J. Butler < > stephen.but...@gmail.com> wrote: > >> You assign to context every loop iteration. So at the end, only the last >> add_product_form c

Re: Can't get initial value into form correctly.

2016-05-14 Thread Stephen J. Butler
You assign to context every loop iteration. So at the end, only the last add_product_form constructed is ever used. Try this: def show_cart(request): cart_id = _cart_id(request) cart_items = CartItem.objects.filter(cart_id=cart_id) add_product_forms = {} for item in cart_items:

Re: Django apparently can't handle that error.

2016-04-25 Thread Stephen J. Butler
Damn. It did work once, but now I can't reproduce it. But turning on SQL logging it's clear that what's happening isn't what I said it was. I get a sequence essentially like this at acct.delete(): -- Django selecting all the things it needs to cascade/update b/c of m2m SELECT * FROM "myapp_car"

Re: __init__() got an unexpected keyword argument 'timeout' #4069

2016-04-25 Thread Stephen J. Butler
Look in your settings.py file for the TEMPLATES line. Do you have a 'timeout' under OPTIONS? Remove that. On Mon, Apr 25, 2016 at 8:34 AM, Khaled Al-Ansari wrote: > Hello, I'm having a problem with djangorest > > when i runserver everything looks fine but when I open

Re: Django apparently can't handle that error.

2016-04-23 Thread Stephen J. Butler
Ahh, Postgres is the problem. When your exception is thrown then Postgres aborts the rest of the transaction. That's how its transaction handling works. Even though you ignore the exception in the myapp code, it will still cause the transaction to abort when Django tries to call commit(). When I

Re: Why redirects to foo.com/?next=/some/folder show up as foo.com/?next=%2Fsome%2Ffolder in browser? (i.e. how remove the %2F's? )

2016-04-23 Thread Stephen J. Butler
You mean on the standard login form? The hidden "next" form value? That value isn't part of a URL so it isn't URL escaped. It's part of the HTML attribute value, so it is HTML attribute escaped. On Sat, Apr 23, 2016 at 6:19 PM, Chris Seberino wrote: > But I still don't see

Re: Why redirects to foo.com/?next=/some/folder show up as foo.com/?next=%2Fsome%2Ffolder in browser? (i.e. how remove the %2F's? )

2016-04-23 Thread Stephen J. Butler
URLs have different parts or components. The different parts use different escaping rules. foo.com/?next=/some/folder foo.com: uses DNS escaping rules /: uses path escaping rules, which allows / as a path separator next=%2Fsome%2Ffolder: uses query parameter escaping rules, which does not

Re: Django apparently can't handle that error.

2016-04-23 Thread Stephen J. Butler
Sorry, I did miss that. I created a quick test project in 1.9 and ran your sample. It works fine for me. The delete() returns that it deleted 4 objects: the Account, Car, Log, and CarLog. There's something else in your project that is causing the error. On Sat, Apr 23, 2016 at 3:42 PM, Neto

Re: Django apparently can't handle that error.

2016-04-23 Thread Stephen J. Butler
Look a little closer at the error message: Error: > > insert or update on table "myapp_log" violates foreign key constraint > "myapp_log_account_id_6ea8d7a6_fk_myapp_account_id" > DETAIL: Key (account_id)=(11) is not present in table "myapp_account". > > It's happening this error rather than

Re: Any way to tolerate Unicode w/o changing '' to u''?...

2016-04-14 Thread Stephen J. Butler
from __future__ import unicode_literals On Thu, Apr 14, 2016 at 5:26 PM, Fred Stluka wrote: > Django users, > > In my Django app, I want to allow users to enter Unicode > strings. But if they do, I get UnicodeEncodeError when I call > format() to embed their string into

Re: UnicodeEncodeError: 'ascii' codec can't encode characters in position,,, on handling serialized post data

2016-03-25 Thread Stephen J. Butler
What happens if you don't pass POST['f'] through unquote first? I don't believe that should be necessary. return QueryDict(request.POST["f"]) On Thu, Mar 24, 2016 at 2:57 PM, Paul Bormans wrote: > I have been puzzled for some time now on a UnicodeEncodeError exception >

Re: Write django log to different.

2015-11-09 Thread Stephen J. Butler
That's not going to work because all of this stuff... On Sun, Nov 8, 2015 at 9:40 PM, tolerious feng wrote: > TODAY_STRING = datetime.datetime.now().strftime("%F") > TODAY_LOG_DIR = os.path.dirname(__file__) + "/log/" + TODAY_STRING > # TODAY_LOG_DIR = "/log/" +

Re: how to copy data per user

2015-10-08 Thread Stephen J. Butler
Lots of ways to do it. Maybe most efficient is: UserProfile.objects.filter(user__in=u_dst).update(url=up_src.url, home_address=up_src.home_address, phone_number=up_src.phone_number) Where u_dst is a list/tuple/iterable of destination users, and up_src is the UserProfile of the source user. On

Re: About local apps communication

2015-08-16 Thread Stephen J. Butler
These are all in the same project, right? In your app2 just do: from app1.models import MyUserModel Or maybe factor out the logic of app1/resources/user to a function and do from app2: from app1.utils import get_user_logic There's no special communication between Django apps required. All the

Re: DB Design question

2015-08-01 Thread Stephen J. Butler
Why not use a BigIntegerField? On Sat, Aug 1, 2015 at 12:06 AM, jordi collell wrote: > Hi all! > > I have to store spreadsheet info on a db. Some kind of quotes where the > user can store distinct prices for every zone. > > After modeling the data, i have a Cell like row.

Re: Using git to control the version for an app in my project

2015-07-22 Thread Stephen J. Butler
Are you saying that the entire project is already a git repo, but you want to have a seperate repo for just one of the apps? In that case, you should do a git submodule: http://git-scm.com/docs/git-submodule On Wed, Jul 22, 2015 at 9:51 AM, wrote: > Hello, I'm trying to

Re: @transaction.atomic ignored?

2015-06-26 Thread Stephen J. Butler
@transaction.atomic will only look at the default database. Since you're using multiple ones I think you want something like: @transaction.atomic(using=DB1) @transaction.atomic(using=DB2) def process_all(): # On Fri, Jun 26, 2015 at 10:27 AM, Lene Preuss wrote:

Re: Trying to do a 'return redirect' from one view to another (python 2.7.8, django1.7)

2015-06-24 Thread Stephen J. Butler
Who sends the data_required signal? It would have to handle the return value of "send" to look for HttpResponse subclasses. On Wed, Jun 24, 2015 at 3:42 PM, Henry Versemann wrote: > Here's an abbreviated look at some code I have: > > @receiver(data_required) > def

Re: Errors with django-rest-auth and django-allauth

2015-06-20 Thread Stephen J. Butler
One of your other apps needs django.contrib.sites, so you need to put it in your INSTALLED_APPS. That's what this means here: Model class django.contrib.sites.models.Site doesn't declare an explicit app_label and either *isn't in an application in INSTALLED_APPS* or else was imported before its

Re: Upgrade Confusion with ForeignKey

2015-06-06 Thread Stephen J. Butler
I don't know if this is the problem, but... On Fri, Jun 5, 2015 at 4:44 PM, Tim Sawyer wrote: > class Venue(models.Model): > """ > A venue for a contest > """ > last_modified = > models.DateTimeField(default=datetime.now,editable=False) > created =

Re: utf-16le encode generic view object_list

2015-05-22 Thread Stephen J. Butler
I think that looks fine. I would change the mimetype to "text/plain; charset=UTF-16LE" just to play nice, but it probably will never matter with your Content-Disposition. Also, HttpResponse's mimetype parameter has been deprecated since 1.5; use content_type instead. On Thu, May 21, 2015 at 3:04

Re: How do I patch django.core.mail.send_mail for testing?

2015-05-19 Thread Stephen J. Butler
I think you instead want to use self.modify_settings() or self.override_settings() to change EMAIL_BACKEND to locmem: https://docs.djangoproject.com/en/1.8/topics/email/#in-memory-backend Then you can inspect django.core.mail.outbox to verify recipients, message, etc. On Tue, May 19, 2015 at

Re: Scaling/Parallel patterns for a View executing complex database transaction

2015-05-14 Thread Stephen J. Butler
If it's just key-value storage, adding a memcached layer sounds like a good thing to investigate. Do the tuples frequently change? On Thu, May 14, 2015 at 11:30 PM, Me Sulphur wrote: > Hi Russ, > > Thanks! While there are some pointers that we can pick up from your answer, >

Re: coffin.shortcuts error

2015-05-14 Thread Stephen J. Butler
The developer of coffin released v2.0 which is pretty much a simple stub. He recommends you switch to django-jinja. You probably want to limit your requirements.txt to coffin<2.0. On Thu, May 14, 2015 at 1:28 AM, wrote: > Hi, first of all i'm sorry for my bad english. >

Re: How to pass arguments when deleting an object? ex: object.delete(deleted_by=someone)

2015-05-13 Thread Stephen J. Butler
Model.delete doesn't take any arguments other than "using". If you want to pass more context, you'll have to override Model.delete in your project, create your own signal, and then pass the extra arguments to it. Same with QuerySet.delete if you want to override mass deletion also. Or, even

Re: TemplateDoesNotExist

2015-05-13 Thread Stephen J. Butler
See where it says "Django tried loading these templates, in this order"? Move your index.html template to the appropriate place. On Wed, May 13, 2015 at 11:12 AM, Rashmi Ranjan Kar wrote: > Hi > > Please go through the attachment. It contains settings.py, urls.py and >

Re: Getting self.request.user for form cleaning

2015-05-13 Thread Stephen J. Butler
If you're using FormMixin then you can also override get_form_kwargs: def get_form_kwargs(self): kwargs = super(MyForm, self).get_form_kwargs() kwargs['creator'] = self.request.user.pk return kwargs Then let FormMixin instantiate the form instance itself. On Wed, May 13, 2015 at

Re: inspectdb on different Oracle schemas

2015-05-06 Thread Stephen J. Butler
Yes, I've done this with a schema from a vendor app I wanted to read. Define additional database aliases, one per schema, and then when running inspectdb use the "--database" parameter with the alias name. On Wed, May 6, 2015 at 2:42 AM, Shekar Tippur wrote: > > > Hello, > >

Re: Django restframework based app on heroku showing error HTTP/1.1 505 HTTP Version Not Supported

2015-04-25 Thread Stephen J. Butler
Your HTTP Request is malformed. You have 2 spaces between the URI and the HTTP version (rfc says only 1). Also, after your Content-Length header you have an extra \r\n which will terminate the set of headers and put the rest in the body. On Fri, Apr 24, 2015 at 11:50 AM, Anand Singh

Re: ModelForm not creating field with required options

2015-04-25 Thread Stephen J. Butler
You need to set Form.required_css_class https://docs.djangoproject.com/en/1.8/ref/forms/api/#styling-required-or-erroneous-form-rows On Fri, Apr 24, 2015 at 2:30 PM, victor menezes wrote: > Hi all, > > I'm using Django 1.8 and having trouble to because my form does not

Re: Difficulty in passing positional arguments in url !!!

2015-04-21 Thread Stephen J. Butler
ess , > it doesn't work !! > > I don't know what's the pblm > Plzz help !! > > On Apr 22, 2015 2:16 AM, "Stephen J. Butler" <stephen.but...@gmail.com> > wrote: >> >> \w won't match emails addresses. It doesn't include the "." or "@" &

Re: Difficulty in passing positional arguments in url !!!

2015-04-21 Thread Stephen J. Butler
\w won't match emails addresses. It doesn't include the "." or "@" characters. On Tue, Apr 21, 2015 at 3:41 PM, HIMANSHU RANJAN wrote: > Thanks for replying Bill :D > Ooops !! > i removed the question mark but it is till not working !! > The problem is that i dont

Re: Choices as a callable.. but no parameters?

2015-04-20 Thread Stephen J. Butler
On Mon, Apr 20, 2015 at 9:45 PM, Vijay Khemlani wrote: > Overwrite the constructor of the form (__init__), pass the user or whatever > parameters you may need and overwrite the choices of the field in the body > of the method. This is the same strategy I've used to filter

Re: Possible bug with django site frameworks swapping between 2 sites every request

2015-04-18 Thread Stephen J. Butler
I wasn't suggesting that disabling caching was the fix, but just a way to start debugging the issue. Did it go away when you completely disabled the cache? Next step is to enable the cache again and progressively remove caching statements from your app till you find the culprit. For example: 1.

Re: invalid literal for int() with base 10 trying to access uploaded image

2015-04-17 Thread Stephen J. Butler
On Fri, Apr 17, 2015 at 8:16 AM, Jyothi Naidu wrote: > > if 'audit_info_manage' in request.POST: > 192 #fullname = Employee.objects.get(emp_id=request.POST['emp_id']) > 193 audit_manage_key = request.POST.get('audit_info_getdata') > 194 if

Re: Graceful Reloading for Schema Changes - UWSGI - Gunicorn?

2015-04-16 Thread Stephen J. Butler
I'm not familiar with uWSGI. On gunicorn you send it SIGHUP (kill -HUP pid) and it will reload w/o interrupting requests. Looks like uWSGI supports something similar: https://uwsgi-docs.readthedocs.org/en/latest/Management.html#signals-for-controlling-uwsgi On Thu, Apr 16, 2015 at 11:32 AM,

Re: Trying to avoid using the "eval" command/statement

2015-04-15 Thread Stephen J. Butler
Or, if you know all the Model classes are in the same module that you've imported, it should be as easy as: from myapp import models model_class = getattr(models, tableName) On Wed, Apr 15, 2015 at 11:50 AM, Stephen J. Butler <stephen.but...@gmail.com> wrote: > Classes (MyModel) are a

Re: Trying to avoid using the "eval" command/statement

2015-04-15 Thread Stephen J. Butler
Classes (MyModel) are attributes of the module (myapp.models). No reason to use eval. You can get the module from importlib and then the class from using getattr() on the module. http://stackoverflow.com/questions/10773348/get-python-class-object-from-string On Wed, Apr 15, 2015 at 11:45 AM,

Re: Possible bug with django site frameworks swapping between 2 sites every request

2015-04-15 Thread Stephen J. Butler
https://docs.djangoproject.com/en/1.8/topics/cache/#dummy-caching-for-development On Wed, Apr 15, 2015 at 8:47 AM, Joe wrote: > How do you set it to the dummy cache? > > On Saturday, April 11, 2015 at 2:06:10 PM UTC-7, Stephen Butler wrote: >> >> What happens if you disable

Re: MEDIA_URL doesnt work in windows but works on linux

2015-04-14 Thread Stephen J. Butler
How doesn't it work? 1. Does the uploaded file appear where you expect it to? 2. If you construct the URL properly in your browser, can you access it directly? 3. What is the URL being output in your templates? On Tue, Apr 14, 2015 at 9:44 AM, dk wrote: > maybe I need to

Re: Possible bug with django site frameworks swapping between 2 sites every request

2015-04-11 Thread Stephen J. Butler
What happens if you disable all caching (try setting it to the dummy cache). Also, you really shouldn't put your python code in your server's DocumentRoot. There's absolutely no reason to do it that way. You're just asking to have your settings.py file exposed by a misconfigured apache instance.

Moving from coffin to django-jinja

2015-04-06 Thread Stephen J. Butler
I'm looking at moving one of my projects from coffin to django-jinja because that project has already hooked into the new 1.8 multiple template engine support. But reading through the docs I came across this: """ django-jinja does not works properly with django’s TemplateResponse class, widely

Re: Migration on new project fails under 1.8, works under 1.7.7

2015-04-05 Thread Stephen J. Butler
The avatar app is unmigrated and has a reference to the auth.User model. References from umigrated apps to migrated apps (which now is all of Django core and contrib) isn't supported: https://docs.djangoproject.com/en/1.8/topics/migrations/#dependencies """Even if things appear to work with

Re: Is blind carbon copy implemented?

2015-04-01 Thread Stephen J. Butler
BCC recipients don't get included in the message headers. If they were stuffed there, then they wouldn't be "bilnd", they would appear in every copy of the message! The code that includes them is here: https://github.com/django/django/blob/stable/1.6.x/django/core/mail/message.py#L263 You say it

Re: Global access to request.user

2015-04-01 Thread Stephen J. Butler
On Wed, Apr 1, 2015 at 3:43 AM, Thomas Güttler wrote: > Headache makes the code which gets called outside the request-response > cycle. > For example cron jobs. > > Example: We create reports for users in cron jobs. Here we need a user > object > and have no context. You still

Re: login error: hostname doesn't match .... but it does!!!

2015-03-31 Thread Stephen J. Butler
This error doesn't appear in the Django sources for 1.6 or 1.7. I don't think the error is being generated by Django, so ALLOWED_HOSTS isn't the culprit. Plus, another clue is that "*.doba.com" isn't an actual value in your ALLOWED_HOSTS. If you search it appears related to Python SSL. Do you

Re: QueryDict and its .dict() method - why does it do that?

2015-03-28 Thread Stephen J. Butler
For those interested, here's some code that does this in Django as request.PARAMS: https://github.com/sbutler/django-nestedparams It is extremely alpha. I wouldn't use it in your code. I did it as a proof of concept, but if other want to hack on it I'd be happy to accept pull requests. On Thu,

Re: QueryDict and its .dict() method - why does it do that?

2015-03-28 Thread Stephen J. Butler
On Fri, Mar 27, 2015 at 2:50 PM, Carl Meyer wrote: > Hi Gabriel, > > On 03/27/2015 01:34 PM, Gabriel Pugliese wrote: >> @Masklinn >> That input is from jQuery's default serializer. It sends the data with >> contentType 'application/x-www-form-urlencoded; charset=UTF-8'. I just

Re: Global access to request.user

2015-03-27 Thread Stephen J. Butler
On Fri, Mar 27, 2015 at 10:30 AM, Thomas Güttler wrote: > You have an instance method to render one row of a search result (a custom > paginator). > > One column of this row displays a link. Some users are allowed to follow the > link, > some are not. You need to check the (row

Re: Django accepting other applications ports

2015-03-25 Thread Stephen J. Butler
On Wed, Mar 25, 2015 at 2:27 PM, Sven Mäurer wrote: > backend.conf > > Listen 8787 > > WSGIScriptAlias / /var/www/html/backend/API/wsgi.py > WSGIPythonPath > /var/www/html/backend:/var/www/html/backend/venv/lib/python2.7/site-packages > WSGIPassAuthorization On

Re: templates tags works in scripts sections of the html?

2015-03-20 Thread Stephen J. Butler
They do work. But did you check the generated page? I bet you get an error in your browser's JavaScript console about syntax. On Fri, Mar 20, 2015 at 4:59 PM, dk wrote: > I am trying to create an autocomplete tag with jquery UI > http://jqueryui.com/autocomplete/ > > > > in my

Re: {{STATIC_URL }} or {% static "...." %} What`s the correct to use?

2015-03-19 Thread Stephen J. Butler
Some questions you need to answer then: 1. Does the URL to the static resource appear properly in your rendered HTML? 2. Did you configure your web server properly so that the STATIC_ROOT appears at the right location? 3. After running collectstatic does the STATIC_ROOT directory have the

Re: {{STATIC_URL }} or {% static "...." %} What`s the correct to use?

2015-03-19 Thread Stephen J. Butler
It says right in the docs what to do: https://docs.djangoproject.com/en/1.7/howto/static-files/ On Thu, Mar 19, 2015 at 7:57 PM, Fellipe Henrique wrote: > Hi, > > In my template, when I made a reference to my Static folder.. what's the > correct usage? > > {{STATIC_URL }} or

Re: Problem with sitemap.xml in django project.

2015-02-01 Thread Stephen J. Butler
site map requires the sites app. Make sure: 1. 'django.contrib.sites' is in INSTALLED_APPS 2. Your site has the proper domain (look in /admin/ and fix it if needed) 3. In your settings.py make sure SITE_ID matches the site you configured in /admin/ On Sun, Feb 1, 2015 at 12:08 PM, José Luis

Re: Is is possible to have a distributed database with Django?

2015-01-31 Thread Stephen J. Butler
Sure, it's possible. But this is a really hard problem. One way is to let the database do all the heavy lifting. But you'll have to forget about using simple databases like SQLite or MySQL. Oracle's advanced replication documentation talks about exactly this type of situation w/r/t materialized

Re: How to get hold of a session after getting signaled?

2015-01-31 Thread Stephen J. Butler
You still could store the do_something_after_badge_awarded result in a database table, but cache the lookups from the view for something short, like 5 minutes. How quickly after a badge is awarded do people need to be notified? Also, you could use a memcached library to store/fetch the awards by

Re: Redirect to external url with parameters in django

2015-01-26 Thread Stephen J. Butler
Use django.utils urlencode. return HttpResponseRedirect(base_url + '?' + urlencode(params)) Note that a redirect is always turned into a GET request, never a POST. If you really need POST you'll have to construct a page with the proper form elements, and then either have the user submit it

Re: django views error

2015-01-26 Thread Stephen J. Butler
Not all your lines have the same indent level in your profile method. Line 52. On Tue, Jan 27, 2015 at 1:03 AM, Mosharof sabu wrote: > my view > > > def index(request): > category_list = Status.objects.filter(comment__startswith="d") > context_dict = {'categories':

Re: forloop

2015-01-26 Thread Stephen J. Butler
Do you have a default ordering on the Model object? That is, an ordering option on newleave.Meta? Because otherwise this query "newleave.objects.all()" is not at all guaranteed to return rows in the order they were added. It may, by coincidence, in your current environment behave that way. But

  1   2   >