Re: more than one field as a primary key

2008-01-15 Thread Remco Gerlich
As far as I know, it's currently not possible in Django.

The solution would be to add a (auto-increment) ingestQueueId field as a
primary key, and in the meantime 1) declare your current primary key fields
to be unique, 2) create an index for those fields in MySQL.

To make multiple fields unique together, use (as an inner class inside your
model class):

   class Meta:
  unique_together = [("datasetID","filename","timeOfRemoteMOD")]


Remco Gerlich

On Jan 15, 2008 12:52 PM, Nader <[EMAIL PROTECTED]> wrote:

>
> Hallo,
>
> I have a "MySQL" table which has more than one field ad a primary key:
>
> CREATE TABLE `ingestQueue` (
>  `datasetID` int(11) NOT NULL,
>  `filename` varchar(80) NOT NULL default '',
>  `timeOfRemoteMOD` datetime NOT NULL default '-00-00 00:00:00',
>  `ingestModuleID` int(11) NOT NULL,
>  `dataSourceID` int(11) NOT NULL,
>  `timeOfEntry` datetime NOT NULL default '-00-00 00:00:00',
>  `status` varchar(80) default NULL,
>  `timeOfLastStatusUpdate` datetime NOT NULL default '-00-00
> 00:00:00',
>  `PID` int(11) NOT NULL,
>  PRIMARY KEY  (`datasetID`,`filename`,`timeOfRemoteMOD`)
> ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
>
>
> How can define a model in Djano with a primary key which has to have
> more than one fields?
>
> The "python manage.py inspectdb" give the following Django model:
>
> class Ingestqueue(models.Model):
>datasetID = models.IntegerField(primary_key=True)
>filename = models.CharField(primary_key=True, maxlength=240)
>timeOfRemoteMOD = models.DateTimeField(primary_key=True)
>ingestModuleID = models.IntegerField()
>dataSourceID = models.IntegerField()
>timeOfEntry = models.DateTimeField()
>status = models.CharField(blank=True, maxlength=240)
>timeOfLastStatusUpdate = models.DateTimeField()
>PID = models.IntegerField()
>class Meta:
>db_table = 'ingestQueue'
>
> Regards,
> Nader
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How can I parse and process the contents of an URL?

2008-01-28 Thread Remco Gerlich
On Jan 28, 2008 5:28 PM, Thomas Guettler <[EMAIL PROTECTED]> wrote:

> def url_head(request):
>c=urllib.urlopen(request.GET['url'])
>content=c.read()
>

http://example.com/url_head?url=file:/etc/passwd

It's very important to do some basic sanity checking on the url. Just saying
:-)

Remco Gerlich

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: converting string to list

2008-01-29 Thread Remco Gerlich
Hi,

Apparently you want an empty list if query has a value, and a list with one
element otherwise (so the "if query" works).

query_string = request.POST.get('q', '')
if query_string:
   query = [ query_string ]
else:
   query = []

Reading the Python tutorial probably wouldn't hurt.

Remco



On Jan 29, 2008 2:19 PM, MariusB <[EMAIL PROTECTED]> wrote:

>
> In the view take an URL from the query:
>query = request.POST.get('q', '')
>
> and in the template I want to print it out in a list
>{% if query %}
>
>{% for url in query %}
>{{ url }}
>{% endfor %}
>
>{% else %}
>No urls found
>{% endif %}
>
> How do I turn query from a string into a list with one element
> (['']) in the view?
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Will there be a django 0.97 release ?

2007-11-09 Thread Remco Gerlich
On Nov 9, 2007 11:07 AM, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
>
> Malcolm Tredinnick napisał(a):
 > The next release will almost certainly be written as "1.0".
>
> Bad news. We have a policy to use only published versions of libraries,
> so our way from 0.96.x to all sweet improvements like unicode will be
> longer...

Basically, the current policy means that they're doing lots of
different releases - every trunk revision is a release :-(

At least, that's how I see it when one app is written against r,
another against r...

Surely if it's stable enough to recommend to people that they just use
trunk, it's stable enough to release a 0.97? Any huge issue that comes
up can always be a 0.97.x. All the objections earlier also apply to
people using trunk.

Remco Gerlich

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Model advice, i18n and content

2007-12-12 Thread Remco Gerlich
Hi,

Let's say I want to create yet another blog app, and I want to write
articles in multiple languages - English and Dutch, in this case.

Some articles will be English-only, some will be Dutch-only. Many articles
will be available in both languages.

People browsing in one language should see indexes, lists of articles,
categories, 'newest posts' things etc only for that language.

But it should be easy to connect the same article in both languages - if I'm
looking at an article and switch languages, and if it has a version
in the other language, the result should be to see that page.

I want to have the language code in the URL, because they're separate pages.
e.g. mysite.com/blog/en/2007/12/12/some-slug/ and
mysite.com/blog/nl/2007/12/12/een-of-andere-slug , or at some
other place in the URL (I'm totally undecided, from using the subdomain for
this to having it as the last part of the URL).

Somewhere in the back of my mind is that I might want to add a language
sometime in the future, but it's vague enough and uncertain enough that we
can ignore that possibility for now.

Comments are an issue. In principle I'd want comments to one article also
appear under the other, language doesn't matter. But I'm not sure.

Now, the question. I see two obvious way to model this. Say my blog has an
'Article' model.

Then:

- Either two different versions are separate Articles, the article has a
language code, and it has optional fields 'this_article_in_dutch' and
'this_article_in_english', that lead to the other version, if it exists.

or

- One article holds both versions; they share a creation date, and have
separate fields for 'context_dutch' and 'content_english', same for title
and slug.



I think it should be the first. But I was wondering what other approaches
others have taken, I can't be the first one with this sort of issue.

Greetings,
Remco Gerlich

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Generation of Session IDs in Django

2016-04-28 Thread Remco Gerlich
Yes, it randomly chooses a 32-character string with characters from
VALID_KEY_CHARS (which contains the lower-case characters 'a' to 'z', plus
digits '0' to '9', so 36 elements).

It uses Python's random.SystemRandom if available (/dev/urandom on Linux,
CryptGenRandom() on Windows), and otherwise Python's default Mersenne
Twister PRNG is used, and reseeded before every call to get_random_string
so it doesn't become predictable. See the source of get_random_string (
https://github.com/django/django/blob/master/django/utils/crypto.py)

log2(36 ** 32) =~ about 165 bits of entropy (fewer when using the PRNG).

Greetings,
Remco Gerlich


On Thu, Apr 28, 2016 at 7:23 AM, Arun S  wrote:

>
> Hi,
>
> Just trying to get a few answers on the Session IDs in Django.
>
> > how does Django Generate Session IDs/Session Keys.
> It seems that Django does the following for Session Keys:
>
> def _get_new_session_key(self):
> "Returns session key that isn't being used."
> while True:
> session_key = get_random_string(32, VALID_KEY_CHARS)
> if not self.exists(session_key):
> break
> return session_key
>
> Does this mean that only a RANDOM string is chosen from the set of Valid
> Key Chars ??
> If the Above is not the case, then
> Does Django Support any Cryptographic Algorithms for Genearting Session
> IDs?
> in that case
> Which Cryptographic Algorithm does Django Uses for Session IDs and how
> many Bits of Entropy is used.??
>
> Any information on this would be very helpful.
>
> Thanks
> Arun
>
> --
> 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/eba81953-c59f-4aba-b733-e320cc6fdef8%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/eba81953-c59f-4aba-b733-e320cc6fdef8%40googlegroups.com?utm_medium=email&utm_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/CAFAGLK2i1OfvyAFK4hFT5V4Ty2zJPfpAiOh33J2TFo9SiSspDA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django query returns nothing for legacy databse

2016-06-09 Thread Remco Gerlich
Do you have a database router set up to tell Django which models are stored
in which database?

Greetings,
Remco Gerlich

On Thu, Jun 9, 2016 at 2:13 PM, Galil  wrote:

> Hello,
>
> I am using two databses for my Django app and one of them is an existing
> MySQL database:
>
> DATABASES = {
>  'default': {
>  'ENGINE': 'django.db.backends.sqlite3',
>  'NAME': os.path.join(BASE_DIR, 'users.sqlite3'),
>  },
>  'calls': {
>  'ENGINE': 'django.db.backends.mysql',
>  'NAME': 'portal2',
>  'USER': 'cdraccess',
>  'PASSWORD': '**',
>  'HOST': '[MY_HOST]',
>  },
>
> }
>
>
> I used inspectdb to create the models for the call and they look like:
>
> class Calls(models.Model):
>  callid = models.AutoField(db_column='CallID', primary_key=True) # Field
> name made lowercase.
>  conferencename = models.CharField(db_column='ConferenceName', max_length=
> 200) # Field name made lowercase.
>  jointime = models.DateTimeField(db_column='JoinTime') # Field name made
> lowercase.
>  leavetime = models.DateTimeField(db_column='LeaveTime', blank=True, null=
> True) # Field name made lowercase.
>
>  class Meta:
>  managed = True
>  db_table = 'ConferenceCall2'
>
>
> I called makemigrations and then migrate and everything looks fine.
>
> However, when I run a query like Calls.objects.all() the result is: [].
>
> Or when I tried Calls..objects.count() the result was: 0. The MySQL database 
> is not empty, but apparently Django ORM believes that it is.
>
> Am I missing something?
>
> --
> 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/c7052a27-e3ac-41fa-90a1-a1c266cd1c71%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/c7052a27-e3ac-41fa-90a1-a1c266cd1c71%40googlegroups.com?utm_medium=email&utm_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/CAFAGLK2EU10QrxMdEUAVcwv7LYW7-_VvczPhFLakRWUE8Q7Ugg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Best Practices URL Patterns

2016-07-07 Thread Remco Gerlich
Why is it a problem if the URLs are guessable? In a vacuum, I would
consider that a good thing.

Remco Gerlich


On Wed, Jul 6, 2016 at 4:09 PM, 'davidt' via Django users <
django-users@googlegroups.com> wrote:

> I am looking for advice with regard to the following:
>
> I have a model which has as part of the structure these two fields
>
> job_id = models.AutoField(primary_key=True,)
> job_reference = job_id = ShortUUIDField()
>
> My question is if I include the job_id in the url, which is public facing
> then it is easy to guess the rest of the urls within the site.
> Beacuse there are a number of items that will have the same url structure,
> and are posted on the same day, using the id is what makes them unique.
>
> My questions are is this right way to proceed or is there a better
> alternative?
>
> 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/caa61056-35de-4e03-b161-888631de9ccd%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/caa61056-35de-4e03-b161-888631de9ccd%40googlegroups.com?utm_medium=email&utm_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/CAFAGLK2bKOPA2q7e7LBttB3AjMxpwMXy8aJt6g3UAYVBA1CAHw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Migrating an unmigrated database from 1.6 to 1.7

2016-07-07 Thread Remco Gerlich
If it's a single database and a single field, is it feasible to just add
the field by hand using SQL?

Greetings,
Remco Gerlich

On Thu, Jul 7, 2016 at 1:05 PM, bobhaugen  wrote:

> We're upgrading an app from django 1.4 step-by-step through all the
> versions at least to 1.8. Got a self-inflicted problem with the new
> migrations in 1.7.
>
> Before we went to 1.7, we added a new field to a model, and migrated the
> db using South. Then when we went to 1.7, we restarted all the migrations.
>
> Unfortunately, we had one database that did not get the South migration
> with the new field.
>
> When we merge in the new code with the new field and try a migrate on the
> unmigrated database, it does nothing. I suppose because all we got now is
> the new-in-1.7 initial migration.
>
> And of course when I try to run the new code against the unmigrated db, I
> get an error about the missing field.
>
> I know we did wrong to leave that db unmigrated. But do we have any
> options for recovery now? Other than dump the data, recreate the db, and
> reload?
>
> --
> 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/3b316785-23c0-4d49-9150-49da28d301ac%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/3b316785-23c0-4d49-9150-49da28d301ac%40googlegroups.com?utm_medium=email&utm_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/CAFAGLK0xUdCTNVFDsBENC%3Dorh4fCGRVc%3D98WHy8AeyMAWeqZ3A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Turn off migrations completely in Django 1.7

2015-08-26 Thread Remco Gerlich
On Tue, Aug 25, 2015 at 5:27 PM, Carl Meyer  wrote:

> To my knowledge, out of the many hundreds of
> thousands of Django users, you are the first and only one to request a
> way to turn off migrations entirely.
>

I think that's a little unfair, given that migrations are only in Django
since 1.7, which isn't even a year old yet. On older versions it was just a
matter of not using South. I think there are quite a lot of < 1.7 projects
that don't use South.

That said, another way not mentioned yet: database routers have an
allow_migrate method. Maybe use a two-database solution with a router, one
database for the Django-internal tables that want to be able to migrate,
and one for your company's data that always returns allow_migrate False?

Greetings,
Remco Gerlich

-- 
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/CAFAGLK2ErvRLwJYD%3DXt7NxbxAaJ%2Ba54dC7951o_LDG0mfy4mPA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to serve any static directory?

2015-09-03 Thread Remco Gerlich
Do you use a webserver "in front" of Django, like Nginx or Apache?

What we do:
- In *development* (when DEBUG=True), use django.views.static.serve to
serve a file:
https://docs.djangoproject.com/en/1.8/ref/views/#django.views.static.serve

- In *production*, let Django do what it needs to do (like authorisation,
or in your case the dynamic translation of the URL to a file path) and then
send headers to the webserver to let it return the file, freeing up the
Django worker.

Under Nginx, we have a bit of nginx.conf in the server {} part like:

location /protected/ {
  internal;
  alias /the/directory/root/of/the/files/
}

And we create a path that starts with /protected/. For Apache, you simply
need the full absolute path.

Then do

response = http.HttpResponse()
response['X-Sendfile'] = full_absolute_path  # Apache
response['X-Accel-Redirect'] = path_starting_with_protected  # Nginx
response['Content-Type'] = ''  # So the webserver will decide it
return respone

Hope this helps.


On Wed, Sep 2, 2015 at 5:41 PM, Yann Salaün  wrote:

> Hi,
>
> The main reason I try to serve those static files with django is because I
> would like to use django to configure the route.
>
> Trying to clarify my question:
>
> 1. The url (http:///site//) doesn't match the
> directory name (which could be anything, like `XYZ_html/`).
> 2. Administrators must be able to upload new archives, which should be
> extracted and served automatically.
>
> For those two reasons, I don't have any idea how to serve this content
> using the webserver, because how is it possible to configure the routes
> then?
>
> Thank you for your answer
>
> On Tue, Sep 1, 2015 at 4:43 PM, Florian Schweikert 
> wrote:
>
>> On 01/09/15 16:34, Yann Salaün wrote:
>> > In summary : is there a way to put something like `return
>> > serve_this_static_directory()` in the view? or is there any workaround
>> > there?
>>
>> Not sure if I get you right, you want to serve static files with django?
>> Is there any reason why it's not possible to serve them with nginx/apache?
>>
>> regards,
>> Florian
>>
>> --
>> 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/55E5B97B.3070607%40ist-total.org
>> .
>> 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/CAHDVCz7udUn-Fo542FUwcLVz-6NSvoHh6qFLf8aGnKUOTp%3Dagw%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFAGLK1bK_t5RomS0cLg2UPkXrQqoH0mkbd8tPjB_UY7z9YL-g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Reverse for 'post_detail' with arguments '()' and keyword arguments '{'pk': 1}' not found. 1 pattern(s) tried:

2015-09-22 Thread Remco Gerlich
According to the error, your pattern starts with $, which is an obvious
mistake.

But the "url.py" you quote has ^.

Maybe it was using an old version, or you haven't copied the right one.

Greetings,
Remco Gerlich


On Sat, Sep 19, 2015 at 9:42 AM, sankar vasu  wrote:

> Hi All,
>
> I got below error, please advise. please look at the following link:
> http://pysan.pythonanywhere.com/
>
> [image: Inline image 1]
>
>
>
>
> *url.py*from django.conf.urls import url
> from . import views
>
> urlpatterns = [
> url(r'^$', views.post_list, name='post_list'),
> url(r'^post/(?P[0-9]+)/$', views.post_detail, name='post_detail'),
> ]
>
>
>
>
> *view.py*from django.shortcuts import render, get_object_or_404
> from django.utils import timezone
> from .models import Post
>
> def post_list(request):
> posts =
> Post.objects.filter(published_date__lte=timezone.now()).order_by('published_date')
> return render(request, 'blog/post_list.html', {'posts': posts})
>
> def post_detail(request, pk):
> post = get_object_or_404(Post, pk=pk)
> return render(request, 'blog/post_detail.html', {'post': post})
>
>
> Thanks in advance,
> Sankar B
>
> --
> 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/CAPzi0vCzoaSN%2B6xEL%3D%2BPSu_vQMpqG6i8oFw9y4_mtPvO8xtoeg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAPzi0vCzoaSN%2B6xEL%3D%2BPSu_vQMpqG6i8oFw9y4_mtPvO8xtoeg%40mail.gmail.com?utm_medium=email&utm_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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFAGLK1hvR4aU%3DsJ-YFrxivs6QxdpZk1LsgDZKN5JbZ3h6sOnA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Using South in Django 1.7+

2015-10-08 Thread Remco Gerlich
I want to run South migrations in a Django 1.7+ installation. I know that's
now how it's usually done, but we have a special needs use case.

Our users have SQLite files that model their project; the SQL schema used
has changed over time, and users are on many different versions.

Our application is a Django 1.6 site. They provide their files to our
application, it changes the Django settings so that one of the databases
refers to their SQLite file, and we run South on it to get the schema to
the current version. Then our app does its actual work. The users continue
to refine their models with their old-schema sqlite files.

Now we want to upgrade our Django version, but we need continue to be able
to apply our old migrations :-(.

Can South run on Django 1.7+ at all?

If not, maybe we have to keep some 1.6 installation running somewhere on
the backend to upgrade a file to the current situation, and then apply new
migrations from there...

Greetings,
Remco Gerlich

-- 
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/CAFAGLK12AWrkq8Wc5Y7SQF885H6apNymQW1C5H8wAjjVpDBDSw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: can I write Django a client consuming RESTfull api from elsewhere

2015-11-03 Thread Remco Gerlich
Django code is just normal Python. Python can call REST APIs, sure (a nice
library is Requests: docs.python-requests.org/en/latest/ )

Doing this in the view means that the user has to wait until the request
ends before he gets a response. Possibly this will make the view too slow.
You could also do the API requests in the background using Celery, and show
the results some other way.

Remco Gerlich


On Tue, Nov 3, 2015 at 12:44 PM, kk  wrote:

> Dear all,
> I wish to know if I need to do some thing special for consuming a RESTfull
> server from some other provider?
> What should I do in the views?
> Do I need the complete DRF to do this?
> Can I do this with just Django's views and then send data across to
> templates?
> I mean, can I write views to connect and call the API, send and receive
> data and then send the output to the templates?
> The encoding is in json when interacting with the remote REST API.
> happy hacking.
> Krishnakant.
>
> --
> 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/56389E08.10105%40gmail.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/CAFAGLK1rzNjgB2XxckRkZJqgOppwS6CiMxxwMd%2BmChnvKuy1Lw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Bi-directional ManyToMany with through gets broken when creating test database

2015-12-04 Thread Remco Gerlich
One, from that error message alone I can't figure out what is happening and
why when you run tests, so I can't help there.

But two: you don't have a ManyToManyField, you have TWO ManyToManyFields.
If you define a many to many field on one model, than it's automatically
also defined on the other (if you only have the one on Pizza, then you can
do topping.pizza_set.all() from the other side.

So your current code is almost certainly wrong, but if these are your exact
models than I don't think they are related to your error.

Remco

On Fri, Dec 4, 2015 at 9:54 AM, filias  wrote:

> Hi,
>
> I have recently upgraded to sjango 1.8 and I have 2 models with a
> bi-directional ManyToMany field. It looks like this
>
> class Pizza(Model):
> available_toppings = ManyToManyField('Topping')
>
> class Topping(Model):
>all_pizzas = ManyToManyField(Pizza,
> through=Pizza.available_stoppings.through, verbose_name='available pizzas')
>
> Everything was fine in django 1.7 but right now when running tests,
> specifically when creating the test database, I get this exception:
>
> self =  0x7fd24fca4b00>
>
> def execute(self, query, params=None):
> if params is None:
>
> >   return Database.Cursor.execute(self, query)
> E   OperationalError: table "products_pizza_available_toppings"
> already exists
>
> So it looks like the creation of the test database is trying to re-create
> the intermediate table for the ManyToMany.
>
> I do not get any exception when running my site.
>
> Does anyone know how can I fix this?
>
> 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/4b8bb3c4-c0bd-4315-9cb6-004db2fa2355%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/CAFAGLK2HoLREAMCL8cFP%3D1raEotF_rD%2Bym-bBVuCDaQd6PKGtg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Windows browser vs Django app running on Ubuntu in a VirtualBox

2015-12-05 Thread Remco Gerlich
He is running it with "./manage.py runserver", which listens to the local
interface only (the 127.0.0.1 IP address).

To get it to listen to the external address instead, use "./manage.py
runserver 192.168.56.101:8000" and then it will work. Or "0.0.0.0:8000" to
listen to all interfaces.

Greetings,
Remco Gerlich

On Sat, Dec 5, 2015 at 10:07 PM, bobhaugen  wrote:

> Our friend Chris Troutner installed our Django 1.4 app on Windows  in
> a VirtualBox running Ubuntu.
>
> He could access the Django app from the browser in Ubuntu, but not from
> the Windows browser.
>
> He writes:
>
>- While you can access the front end in the Ubuntu VM, you can't
>access it from the windows desktop. You should be able to by pointing your
>Windows browser at http://192.168.56.101:8000, but that didn't work
>for me. 192.168.56.101 was the IP address Virtual Box assigned to its
>Host-Adapter. I can ping that address and SSH to it, but I can't bring up
>Django.
>
>This is most likely a simple fix with the network settings, but as of
>this writing, I haven't figured out a fix yet.
>
> Here's his whole story:
> http://christroutner.com/blog/post/open-value-networks
>
> Anybody got any ideas so he can finish the story?
> Thanks for any help you can offer.
>
> --
> 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/3cc31a21-fd27-4f3f-a4a7-767a028b72b5%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/3cc31a21-fd27-4f3f-a4a7-767a028b72b5%40googlegroups.com?utm_medium=email&utm_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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFAGLK2a54hs2JxfX12KwfHFbr0%2BFMaSw9B1CYCaeYid2z8OEw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Debugging Django with Debug set to False

2016-01-05 Thread Remco Gerlich
If it is the exception tracebacks you are after, consider setting up a
Sentry ( https://getsentry.com/ ) server to send the error / exception logs
of all your sites to. Whenever something bad happens, it'll show up there,
with full tracebacks.

Greetings,
Remco Gerlich

On Mon, Jan 4, 2016 at 6:33 PM, Web Architect  wrote:

> Hi,
>
> Is there a way to debug Django when DEBUG is set to False in settings.py
> (for example on production)?
>
> The reason for asking the above is if we face any issue with DEBUG set to
> False and if we need to debug.
>
> We are new to Django and we are building an ecommerce platform based on
> Django.
>
> Would appreciate if anyone could help with the above?
>
> 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/c4f16aba-f0e0-4aae-a6c0-1513571c7a97%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/c4f16aba-f0e0-4aae-a6c0-1513571c7a97%40googlegroups.com?utm_medium=email&utm_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/CAFAGLK0c2qZbAwdtHhWL5SNe6ag-bD%2BizDBxbm4PK6FmcMtxRQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Scaling Django

2016-02-03 Thread Remco Gerlich
There is a book (ebook) named "High Performance Django" that has many
useful tips.

Also, new software developers are _always_ skeptical when they start a new
job. They have an old way of doing things from their previous job, "that's
not how we work here!" reflexes also from that old job, and they take a
while to adjust to the new tools.

 First let them get productive with what exists, _then_ let them gather
real statistics about real problems when they want to change something.

You can have scalibility issues and solve them with whatever framework,
Django included.

Remco Gerlich


On Wed, Feb 3, 2016 at 4:30 PM, Joshua Pokotilow 
wrote:

> At the startup where I work, we've written a lot of our server code in
> Django. So far, we've adopted a "build it fast" mentality, so we invested
> very little time in optimizing our code. A small amount of load testing has
> revealed our codebase / infrastructure as it stands today needs to run
> faster and support more users.
>
> We recently hired some new engineers who are extremely skeptical that we
> should optimize our existing code. Their main concerns are:
>
> - We need to move to a service-oriented infrastructure because Django is
> too monolithic (monolithic = technology lock-in & difficult to troubleshoot)
> - It's too easy to write slow queries using the Django ORM
> - It's hard to hire Django engineers
> - While Instagram and DISQUS use Django to service large numbers of
> people, they don't use it for any serious backend work
>
> After having worked with Django for the last 3 years, I'm a big believer
> in it, and I believe it would scale. To defend my position, I've pointed
> out to my colleagues that it's easy to identify bottlenecks with tools like
> the Django Debug Toolbar and Yet Another Django Profiler. With my
> colleagues present, I've isolated and fixed significant speed problems
> inside of a few hours. I don't believe the Django ORM is inherently bad,
> although I do think that coders who use it should Know What They're Doing.
> Finally, I've referenced blog entries that talk about how Instagram and
> Disqus use Django on the backend for backend-y tasks.
>
> Despite my best efforts, my colleagues are still pushing to have us
> rewrite large portions of our infrastructure as separate services before we
> try to fix them. For example, we have one slow REST endpoint that returns a
> boatload of user data, and so there's talk about using a new microservice
> for users in lieu of our existing Django models. Even if we are able to fix
> bottlenecks we encounter in a timely fashion, my colleagues fear that
> Django won't scale with the business.
>
> I'm writing this post to garner additional evidence that Django will
> scale. Anything compelling (and preferably not obvious) that would help
> shed some light on Django's ability to scale would be *greatly*
> appreciated, as it's very difficult for me to defend my position that
> Django is a viable long-term solution without solid evidence to back up my
> claims. It certainly doesn't help that I don't have any experience scaling
> Django myself!
>
> 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/83968c41-d415-4189-b33b-9f99b10b1c41%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/83968c41-d415-4189-b33b-9f99b10b1c41%40googlegroups.com?utm_medium=email&utm_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/CAFAGLK3wfsrqeDLcHX%2B3iaLVGoJb5ypXjoUdKKcjpm_UYakj1A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ID for users of Speedy Net

2016-02-05 Thread Remco Gerlich
The key is to start out your project with a different User model than the
default model -- see
https://docs.djangoproject.com/en/1.9/topics/auth/customizing/#specifying-a-custom-user-model
. Create your own User model that inherits from AbstractBaseUser, and set
AUTH_USER_MODEL = YourCustomUser.

It's key to do this at the beginning of the project, since it's really hard
to migrate to this later. You can always change your custom model, but
switching from the default to a custom model is nontrivial.

Remco Gerlich


On Fri, Feb 5, 2016 at 9:22 PM, Uri Even-Chen  wrote:

> Hi James,
>
> Thanks for your feedback. My question was how do I change the primary key
> of a Django model such as User - a model I didn't write myself (it's
> already written by Django). Is it possible? Because I prefer the id/pk to
> be 15-digits randomly generated and not auto-increment. I don't see any
> logic in using auto-increment, I don't want the id/primary key to be short
> (such as zuck's id on Facebook - https://www.facebook.com/messages/4) but
> 15-digits long. And by the way, users who already signed up to Speedy Net
> already have a 15-digits id (randomly generated) and I want to preserve
> this id when converting Speedy Net from PHP/MySQL to Django and PostgreSQL.
>
> I hope I clarified my question now.
>
> Thanks,
> Uri.
>
> *Uri Even-Chen*
> [image: photo] Phone: +972-54-3995700
> Email: u...@speedy.net
> Website: http://www.speedysoftware.com/uri/en/
> <http://www.facebook.com/urievenchen>
> <http://plus.google.com/+urievenchen>
> <http://www.linkedin.com/in/urievenchen>  <http://twitter.com/urievenchen>
>
> On Fri, Feb 5, 2016 at 8:22 PM, James Schneider 
> wrote:
>
>>
>> On Feb 4, 2016 10:59 AM, "Uri Even-Chen"  wrote:
>> >
>> > Hi James,
>> >
>> > Thanks for your feedback. Actually I was thinking that this randomly
>> generated number with 15 digits will be used in urls, for example of pages
>> which don't have slugs etc. I saw similar urls in Facebook for pages who
>> don't have a username (Facebook calls it a username), Facebook generates a
>> slug which contains a 15-digits number. I found out that Facebook
>> redirects to this url when entering the url with only the number (for
>> example https://www.facebook.com/342076035998592/ - with or without the
>> trailing slash, even with several slashes). So the UUID will be too long
>> for this, unless I generate it with 15 digits (decimal). And how do I make
>> it a primary key of model User? Is there a way to change the primary keys
>> of Django models and how? I think we will use PostgreSQL anyway, thanks!
>> >
>>
>> You have total control over what field is used as the primary key.
>>
>> https://docs.djangoproject.com/en/1.9/ref/models/fields/#primary-key
>>
>> The model.id field that is automatically generated is for convenience
>> and convention. It is not generated/available when a different primary key
>> is specified, unless of course you name the field 'id'.
>>
>> This is also why it is important to use model.ok when referring to the
>> primary key for a model, rather than model.I'd, since model.pk is always
>> made available as an alias to whatever primary key that the model it's
>> using (be it an integer or a UUID).
>>
>> Unless your code performs some operation on a model's primary key that is
>> specific to an integer data type (ie using \d+ to look for primary keys in
>> your urls.py), using model.pk is pretty universal and shouldn't require
>> many changes to move from an integer to something else as your PK.
>>
>> As far as the number that FB generates for their URL's, I'm sure it is
>> some type of account number that is assigned upon creation, probably along
>> the lines of what you were mentioning.
>>
>> I suppose you could have the same ID between the two systems, but I
>> wouldn't necessarily make that a hard requirement. It's pretty easy to add
>> an extra correlation table that would keep track of the user in each system
>> with a different PK. While this could incur an extra join or extra queries,
>> it does make the system much more flexible, with the possibility to
>> integrate with other authentication systems such as LDAP or Shibboleth
>> where the customer may not be able to easily modify/add the DB attribute to
>> match your account number/PK.
>>
>> Also keep in mind that the PK and account number can, and probably should
>> be, separate. Changing an account number (due to a typo, perhaps) could be
>> disas

Running a Django site on a standalone Windows laptop

2016-02-16 Thread Remco Gerlich
Hi,

We have a web application that usually runs on Ubuntu servers on the
Internet. In the background it calls software that runs on Windows servers,
over a network.

For a new project, this application must run standalone on a laptop, in the
field, used by not very technical users. We can make the Python/Django code
Windows compatible pretty easily, but not the background software, so it
will be a Windows laptop that will run everything.

What's the best way to run Django as a service under Windows? Is Apache /
ModWSGI feasible?

Remco Gerlich

-- 
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/CAFAGLK2KyoCgHJnXiHQAYiPo8o7FdDDEWWy_s5n2cX1_bawvOg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Running a Django site on a standalone Windows laptop

2016-02-16 Thread Remco Gerlich
We thought about that and it's certainly an option, but 1) the
communication with the background tasks running on the Windows host is
going to be tricky and 2) I have no experience with running it as a service.

So I'd prefer running on Windows directly.

Remco Gerlich


On Tue, Feb 16, 2016 at 3:47 PM, m1chael  wrote:

> I would vote for a Virtualbox instance depending on your performance
> requirements
>
> On Tue, Feb 16, 2016 at 9:36 AM, Remco Gerlich  wrote:
>
>> Hi,
>>
>> We have a web application that usually runs on Ubuntu servers on the
>> Internet. In the background it calls software that runs on Windows servers,
>> over a network.
>>
>> For a new project, this application must run standalone on a laptop, in
>> the field, used by not very technical users. We can make the Python/Django
>> code Windows compatible pretty easily, but not the background software, so
>> it will be a Windows laptop that will run everything.
>>
>> What's the best way to run Django as a service under Windows? Is Apache /
>> ModWSGI feasible?
>>
>> Remco Gerlich
>>
>> --
>> 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/CAFAGLK2KyoCgHJnXiHQAYiPo8o7FdDDEWWy_s5n2cX1_bawvOg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAFAGLK2KyoCgHJnXiHQAYiPo8o7FdDDEWWy_s5n2cX1_bawvOg%40mail.gmail.com?utm_medium=email&utm_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/CAAuoY6O4Dz3W%2BtOuBeJ63PQ2a0FMEGOYFePvYk2X7ox3Knbx8w%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAAuoY6O4Dz3W%2BtOuBeJ63PQ2a0FMEGOYFePvYk2X7ox3Knbx8w%40mail.gmail.com?utm_medium=email&utm_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/CAFAGLK0_PyicqwwzaFhz3WqioJgELBk3aExF4zqWxzFzfTj6yw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Parsing PHP-style GET parameters for lists and dicts in Django

2016-02-26 Thread Remco Gerlich
I need to work with DataTables, a jQuery-plugin for sortable HTML tables.

It sends Ajax GET requests with parameters like the following (but
urlencoded, of course):

columns[0][data]=0
columns[0][name]=
columns[0][searchable]=true
columns[0][orderable]=true
columns[0][search][value]=
columns[0][search][regex]=false
columns[1][data]=1
columns[1][name]=
columns[1][searchable]=true
columns[1][orderable]=true
columns[1][search][value]=
columns[1][search][regex]=false
columns[2][data]=2
columns[2][name]=
columns[2][searchable]=true
columns[2][orderable]=true
columns[2][search][value]=
columns[2][search][regex]=false

I think this plugin was written with PHP in mind, and that PHP can
automatically convert that into a list of dicts that would in Python look
something like

columns = [
{"data": 0, "name": '', "searchable": True, "orderable": True,
"search": {"value": '', "regex": False}},
{"data": 1, "name": '', "searchable": True, "orderable": True,
"search": {"value": '', "regex": False}},
{"data": 2, "name": '', "searchable": True, "orderable": True,
"search": {"value": '', "regex": False}},
]

Does anybody know of any Python or Django app / library that does this?

Would it be possible to do this in a FormField? (convert many GET
parameters into one field)

Does anybody know what this technique is called? My Google-fu is failing,
and if I'm going write a field for this I need to name it.

Thanks,
Remco Gerlich

-- 
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/CAFAGLK3rG6mEGaNf4QHQ3xffhtkyDm9QrwmfNxTr%3DQpeqkBNTA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Running a Django site on a standalone Windows laptop

2016-02-26 Thread Remco Gerlich
Thank you all for the comments and links!

We are going to try to simply run Apache/WSGI on Windows, as that seems to
be the most normal and best supported option.

I hadn't thought of Cygwin, if we run into trouble maybe we can use
something that is part of that.

And as a third option there are dockers and virtual machines et cetera, but
I'm optimistic we can simply use Windows.

Thanks,
Remco Gerlich

On Tue, Feb 16, 2016 at 10:34 PM, Mike Dewhirst 
wrote:

> I agree with James. Apache and mod_wsgi is fine on Windows. There may be
> some Windows-specific Apache conf tweaks but running single-user on a
> laptop should be easy.
>
> On 17/02/2016 6:55 AM, James Schneider wrote:
>
>> On Tue, Feb 16, 2016 at 6:36 AM, Remco Gerlich > <mailto:re...@gerlich.nl>> wrote:
>>
>> Hi,
>>
>> We have a web application that usually runs on Ubuntu servers on the
>> Internet. In the background it calls software that runs on Windows
>> servers, over a network.
>>
>> For a new project, this application must run standalone on a laptop,
>> in the field, used by not very technical users. We can make the
>> Python/Django code Windows compatible pretty easily, but not the
>> background software, so it will be a Windows laptop that will run
>> everything.
>>
>> What's the best way to run Django as a service under Windows? Is
>> Apache / ModWSGI feasible?
>>
>>
>> I would first try a native installation of Apache/mod_wsgi. Apache
>> installs as a service and can easily be made available on both the
>> laptop and other machines on the same network. Adding other complexity
>> layers like virtualization, containers, or Cygwin (which I'm not even
>> sure how to classify, lol) will almost certainly give you trouble with a
>> portable server environment like you are trying to establish. Not that
>> it isn't possible to do it with those technologies, but your level of
>> complexity increases immensely, and the ratio of complexity layers to
>> end-user issues is usually exponential in nature.Â
>>
>> Having never dealt with Django/Python on Windows myself, I'm afraid I
>> can't speak to how well supported such a setup is (although it seems to
>> be per the Apache/WSGI pages).
>>
>> This guide seems reasonable and appears to be close to what you want.
>> https://frepple.com/docs/2.2/installation-guide/windows-apache.html
>>
>> Also happened to just stumble across this on a Googling expedition:
>>
>> https://code.djangoproject.com/wiki/WindowsInstall
>>
>> Good luck!
>>
>> -James
>>
>>
>> --
>> 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
>> <mailto:django-users+unsubscr...@googlegroups.com>.
>> To post to this group, send email to django-users@googlegroups.com
>> <mailto: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%2Be%2BciXsZw5-CqL4px93vUM8LAofKATeFSLcmov3fKNesnE0bw%40mail.gmail.com
>> <
>> https://groups.google.com/d/msgid/django-users/CA%2Be%2BciXsZw5-CqL4px93vUM8LAofKATeFSLcmov3fKNesnE0bw%40mail.gmail.com?utm_medium=email&utm_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/56C395F7.8090205%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/CAFAGLK0QjvcZ%3DicOqSkY7j0FYvwwTtcpb-5whW6EFa0gCku1Qg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Parsing PHP-style GET parameters for lists and dicts in Django

2016-02-26 Thread Remco Gerlich
Hi James,

I agree with the general dirtyness of PHP and I have used Django
exclusively for years.

The type of parameter I mean is where, say a list of two elements [1,2] is
sent as

http://example.com/?list[0]=1&list[1]=2

So instead of two parameters with the same name, this has two parameters
with different names ("list[0]" and "list[1]"). PHP automatically
recognizes such parameters and turns them into an list under the name
"list", I seem to recall vaguely. The same works for dictionaries and for
nested lists and dictionaries. I don't think Django does this and I don't
see anything about it in the docs you linked to.

I can use [request.GET.get("list[0]"), request.GET.get("list[1]")] etc but
the structure can get quite involved ("columns[2][search][regex]") and so I
was wondering if someone had written something like that already.

Greetings,
Remco


On Fri, Feb 26, 2016 at 11:24 AM, James Schneider 
wrote:

>
> On Feb 26, 2016 1:21 AM, "Remco Gerlich"  wrote:
> >
> > I need to work with DataTables, a jQuery-plugin for sortable HTML tables.
> >
> > It sends Ajax GET requests with parameters like the following (but
> urlencoded, of course):
> >
> > columns[0][data]=0
> > columns[0][name]=
> > columns[0][searchable]=true
> > columns[0][orderable]=true
> > columns[0][search][value]=
> > columns[0][search][regex]=false
> > columns[1][data]=1
> > columns[1][name]=
> > columns[1][searchable]=true
> > columns[1][orderable]=true
> > columns[1][search][value]=
> > columns[1][search][regex]=false
> > columns[2][data]=2
> > columns[2][name]=
> > columns[2][searchable]=true
> > columns[2][orderable]=true
> > columns[2][search][value]=
> > columns[2][search][regex]=false
> >
> > I think this plugin was written with PHP in mind, and that PHP can
> automatically convert that into a list of dicts that would in Python look
> something like
>
> PHP is a dirty word in this forum. :-P
>
> >
> > columns = [
> > {"data": 0, "name": '', "searchable": True, "orderable": True,
> "search": {"value": '', "regex": False}},
> > {"data": 1, "name": '', "searchable": True, "orderable": True,
> "search": {"value": '', "regex": False}},
> > {"data": 2, "name": '', "searchable": True, "orderable": True,
> "search": {"value": '', "regex": False}},
> > ]
> >
> > Does anybody know of any Python or Django app / library that does this?
>
> Easy. It's called Django. :-D
>
> The HttpRequest object is automatically populated with both GET and POST
> values when Django parses the request from the browser, and handles
> multiple values for the same key just fine.
>
>
> https://docs.djangoproject.com/en/1.9/ref/request-response/#django.http.HttpRequest.GET
>
> Usually this object is made available as a variable called request in a
> function-based view, or is available via self.request in a class-based view.
>
> To get multiple values for the same key, simply access that key multiple
> times (see the QueryDict link in the section I linked above), usually as
> part of a loop. The QueryDict (request.GET) acts like a Python generator.
>
> Usually you access the keys using .get() calls so that a missing or empty
> key return None instead of raising an exception:
>
> fn = self.request.GET.get('first_name')
>
> This part of the tutorial has example usage:
> https://docs.djangoproject.com/en/1.9/intro/tutorial04/#write-a-simple-form
>
> It uses request.POST, but it works exactly the same way.
>
> On a side note, nothing you've mentioned is specific to PHP, rather it is
> all part of the HTTP protocol. The languages/frameworks just have different
> methods of accessing the same information. A form generated by a PHP
> process can submit to a Django view with no issue, and vice versa.
>
> -James
>
> --
> 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%2Be%2Bci