Thursday, October 31, 2013
Multiple logins
registering two different clients then both the clients are added
under the same client id but it should register under different client
ids. So what should I do for that.
--
Amanjot Kaur
Blog: kauramanjot35.wordpress.com
--
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+unsubscribe@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/CAOUPv3%3DLEBN%3DU6OJ-m_k8maaOtFBWS5huvLz2%2BAkUK%3DgL%3DgC-A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
Re: slice QuerySet and keep as QuerySet
> *How do I slice a QuerySet and keep it as a QuerySet*
>
https://docs.djangoproject.com/en/1.5/ref/models/querysets/#when-querysets-are-evaluated
https://docs.djangoproject.com/en/1.5/ref/models/querysets/#methods-that-return-new-querysets
>
> *If I do*
>
> *a = qs[:3]*
>
> *then I get a list back. I want a QuerySet. *
>
>
> *I'm wanting to get the first x items in the query set and the last x
> items in the query set.*
>
> --
> 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+unsubscribe@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/b349138c-47f7-41fd-9fcf-db3fba7c40f9%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
--
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+unsubscribe@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/52730A0A.9040202%40dewhirst.com.au.
For more options, visit https://groups.google.com/groups/opt_out.
Re: Speed Improvements: Properties, Database Denormalization, Caching, Connection Pooling, etc.
http://www.jeffknupp.com/blog/2012/02/14/profiling-django-applications-a-journey-from-1300-to-2-queries/
http://gun.io/blog/fast-as-fuck-django-part-1-using-a-profiler/
ymmv
Mike
On 31/10/2013 2:47pm, Carlos D. wrote:
> So, first thing: I come from a C++ background and I've been building my
> first site with Django. As I normally try to do in C++, I don't want to
> store any more information than I have to since that can lead to big
> problems with data consistency. In C++, I do this with private members
> / methods, and a defined public interface. For my Django project, I've
> been using properties since it seems like a nice way to be able to
> access data as if it were a member, but not actually store that
> information. However, that brings me to my problem. Since so much of
> the database querying has been abstracted away from me, I definitely
> haven't been thinking about overhead with database access time. This is
> definitely not a knock on Django, I find it to be a great thing -- I
> only need to think about this now that I have some speed issues.
> Anyway, I have multiple properties that end up calling a method that
> is something like:
>
> def _get_item_total(self, prop_id):
> total = 0
> for item in self.item_set.all():
> att1 = item.att1 #Did this for speed? I thought this would
> save a couple of hits on the DB.
> total +=
> (item.one_to_one.one_to_one.m2mfield_set.all().get(id=prop_id).value
> * att1.quantity * att1.weight)
>
> Note: I understand that the first two 1-1 fields seem redundant. We're
> using an existing DB that we're slowly adding additional information to
> some of the entries (we probably won't do all of them, even in a final
> product). We don't want any entry that we haven't identified the
> additional information for to be displayed in a drop down on another
> model. Maybe there's a better way to do this, but that's what I've
> implemented for now. If there are any other additional problems with
> that line of code, I'd love to hear it!
>
> Anyway, In some views, I'm looking at ~5 instances of models that each
> have a 5 or so properties that use this method. Each the item set has,
> on average, 5 items. This means that the line:
>
> (item.one_to_one.one_to_one.m2mfield_set.all().get(id=specified_prop_id).value
> * att1.quantity * att1.weight)
>
> Is being hit 5*5*5 = 125 times for some views. If I assumed 5ms per
> connection (is this reasonable??) this is ~0.6 seconds by itself just
> for overhead opening and closing connections to the DB. There's also
> whatever time is associated with executing this query (which seems like
> it may be substantial given the number of tables I'm moving through).
>
> The great news is that there seems to be many ways I might be able to
> address this:
>
> 1. DB Connection pooling. (Might address time associated with opening
> / closing connection)
> 2. It sounds like Django may soon be supporting keeping a connection
> open for a set period of time. (Same as above)
> 3. Switching my properties to actual columns in the DB. I should be
> able to keep these consistent since many of the tables are actually
> static information. I think there's one point where saving occurs
> for any of the dynamic DB information that goes into
> the calculation. (Should help with some overhead -- a complex query
> would be reduced to a simple query).
> 4. Django's cache framework. (Could make significant improvements --
> but this cache is only kept for a certain period of time. Some
> users will still have to wait.)
> 5. Database tuning (Don't know much about this...)
> 6. It seems like it might be inefficient that each property is
> individually moving through the first three tables (is this the
> right way to say this??) since the prop_id isn't used until we get
> to m2mfield_set_all(). I could condense the number of tables that
> need to be traversed However, it seems like this would make the #
> of calls to the DB equal to 2*n+1 rather than 2*n where n is the
> number of prop_ids I'm using.
> 7. Maybe I need to check out the query this is making and write my own
> custom query if it's being inefficient?
>
> I guess my questions are:
>
> * Is that line of code terrible? Should I be doing this a better way?
> * If not, how do I do some time profiling to determine which of the
> above I should do? Or should I just do each one and see if it improves?
>
> --
> 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+unsubscribe@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/9f1ff8a8-140a-4071-9c9f-551b55a2b204%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
--
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+unsubscribe@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/52730952.6030308%40dewhirst.com.au.
For more options, visit https://groups.google.com/groups/opt_out.
slice QuerySet and keep as QuerySet
How do I slice a QuerySet and keep it as a QuerySet
If I do
a = qs[:3]
then I get a list back. I want a QuerySet.
I'm wanting to get the first x items in the query set and the last x items in the query set.
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+unsubscribe@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/b349138c-47f7-41fd-9fcf-db3fba7c40f9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Request to review the patch
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+unsubscribe@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/8229a3f9-4ace-4e16-82f6-b69d30065209%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
ValidationError code attribute
ValidationError(_('Error 1'), code='error1'),
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+unsubscribe@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/7988fe19-3a8e-4afe-ba9b-3c72b7824a66%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Re: relative URLs in redirects
> Hi,
>
> If I return an HttpRedirect() with a relative URL in it, I notice that
> Django fully qualifies the redirect with a hostname and scheme.
>
> ie.
>
> Location /foo/bar/
>
> goes to
>
> Location https:myserver.mysite.com/foo/bar/
>
> Is there a reason to fully qualify like this? I've found relative URLs much
> more portable in the past, and they work through proxies, make no
> assumptions about SSL on or off, etc.
The Location header must always be a fully qualified URI, according to
every single version of the HTTP RFC from RFC 1945 onwards.
Cheers
Tom
--
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+unsubscribe@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/CAFHbX1%2Buju2ZbJyZRNS4x_2Zmfr8qeGkRaFG2G2UsK_93t8yXA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
Unable to save records in a table
In a multidatabase project (two databases':default' and 'noe') I have the following model in 'default' database
class MovimentoOrdineDettaglio(models.Model):
id_ordine = models.ForeignKey(MovimentoOrdine,db_column='id_ordine')
codarticolo = models.ForeignKey(ArticoliLista, db_index=True,verbose_name='Articolo')
numerounita = models.IntegerField(db_column='NumeroUnita',blank=True,default=0,
verbose_name=u'Numero Unità')
and the following in 'noe' database
class specifica_noe(models.Model):
nome_db = 'noe'
id_ordine = models.ForeignKey(ordini_magazzino, db_column='ID_ORDINE', to_field='id_ordine')
cod_magazzino_ext = models.CharField(max_length=48, db_column='COD_MAGAZZINO_EXT')
qta = models.IntegerField(null=False, blank=False, db_column='QTA')
def __unicode__(self):
return u"%s art. %s" % (self.id_ordine, self.cod_magazzino_ext)
I draw your attention on field 'id_ordine' and 'codarticolo' of model MovimentoOrdineDettaglio which are connected via foreign keys to a model MovimentoOrdine and ArticoliLista also in 'default' database.
I'm trying to load records using data from model specifica_noe in 'noe' database by means of a loop intoMovimentoOrdineDettaglio in 'default' . In doing so I create the instances art and ord (see below) to take into account the ForeignKey fields. I've introduced two print commands to check if everything is ok.
Here it is a snippet of my shell session.
-----------------------
>>> det = specifica_noe.objects.all()
>>> #
>>> for d in det:
... art = ArticoliLista.objects.get(codice=d.cod_magazzino_ext)
... ord = MovimentoOrdine.objects.get(id_ordine=d.id_ordine_id)
... if not MovimentoOrdineDettaglio.objects.filter(id_ordine=d.id_ordine_id, codarticolo=d.cod_magazzino_ext):
... print("Order %s for article %s does not exist-load now") % (d.id_ordine_id,d.cod_magazzino_ext)
... rec = MovimentoOrdineDettaglio(id_ordine=ord, codarticolo=art,numerounita=d.qta)
... print('%s %s %s') % (rec.id_ordine,rec.codarticolo,rec.numerounita)
... rec.save()
... #
...
Order 1 for article 0005201 does not exist-load now
Ord.1 per BONAPARTE NAPOLEONE ABBA*12BUST 875MG+125MG 10
Order 1 for article MAS105 does not exist-load now
Ord.1 per BONAPARTE NAPOLEONE ACTISORB 10,5X10,5CM 5
Order 3 for article 0000004 does not exist-load now
Ord.3 per MANZONI ALESSANDRO ADALAT CRONO 30MG 14 CPR RIV. 7
Order 3 for article 0060000140 does not exist-load now
Ord.3 per MANZONI ALESSANDRO ACQUA OSSIGENATA 10VOL 1000ML 1
Order 2 for article 0005201 does not exist-load now
Ord.2 per CESARE GIULIO ABBA*12BUST 875MG+125MG 8
Order 6 for article 0060000140 does not exist-load now
Ord.6 per MANZONI ALESSANDRO ACQUA OSSIGENATA 10VOL 1000ML 2
Order 5 for article MAS105 does not exist-load now
Ord.5 per LINCOLN ABRAMO ACTISORB 10,5X10,5CM 15
Order 5 for article MAS190 does not exist-load now
Ord.5 per LINCOLN ABRAMO ACTISORB 10,5X19 12
Order 4 for article 8016629001115 does not exist-load now
Ord.4 per EINAUDI LUIGI ABBASSALINGUA IN LEGNO DOC N/ST CF.100 25
>>>
-----------------------
Everything seems ok
for instance, just to doublecheck, for the last rec of the loop I have
>>> rec.id_ordine
<MovimentoOrdine: Ord.4 per EINAUDI LUIGI>
>>> rec.codarticolo
<ArticoliLista: ABBASSALINGUA IN LEGNO DOC N/ST CF.100>
>>> rec.numerounita
25
>>>
BUT.... if I issue:
>>> f=MovimentoOrdineDettaglio.objects.all()
>>> f
[]
No records at all in the table!
Nothing anomalous is signalled by python/django.
Help please.
Ciao from Rome
Vittorio
--
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+unsubscribe@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/609C9977-68D5-4909-AFBD-5D0C4D5DB8B9%40de-martino.it.
For more options, visit https://groups.google.com/groups/opt_out.
Re: django - default value name for the ForeignKey
I have a model for uploading photos in an album by the users. But if the user don't want to create an album, and just upload photos, I want it to be uploaded in a default album, namely 'Default album'. So that, whenever the user uploads photo without creating a new album, the 'Default album should be updated by that photos. For that, I thought about giving a
default value
in the title of the Album, but I also don't want to create a new album with name 'Default album' whenever the user doesn't create a new album to upload photo. I just want to update the 'Default Album'. Please suggest me how to achieve the above mentioned. And also is it okay to just give theForeignKey field
of the User to the Album class and not the Photo class??? Thank you!models.py:
class Album(models.Model): title = models.CharField(max_length=200) pub_date = models.DateTimeField(default=datetime.now) user = models.ForeignKey(User) class Photo(models.Model): album = models.ForeignKey(Album) title = models.CharField(max_length=200) image = models.ImageField(upload_to=get_upload_file_name, blank=True) pub_date = models.DateTimeField(default=datetime.now)
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+unsubscribe@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/CAHSNPWsH%3DsVO7WJFRp2t8BZzu170-fD_ytamp-arN%2BCkEG639g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
Re: New to django,need help! just trying to retrieve values from a template to a view.py (ie user may input text, make choice selection, select a radio button value)
On Wednesday, 30 October 2013 20:17:17 UTC, pete wrote:
HiNew to django,need help! just trying to retrieve values from a template to a view.py (ie user may input text, make choice selection, select a radio button value)like to know the poll list section, market selection, coupon code, and discount text, and poll choice selection from radio buttonviewdef current_datetime(request):current_date = datetime.datetime.now()
latest_poll_list = Poll.objects.filter( pub_date__lte=timezone.now()).order_by( '-pub_date')[:5]
all_entries = FStatistics.objects.all()
return render_to_response('polls/current_datetime.html', locals()) ===================================================== current_datetime.html' Template like{% load staticfiles %}<link rel="stylesheet" type="text/css" href="{% static 'polls/style.css' %}" />{% if latest_poll_list %}
<ul>
{% for poll in latest_poll_list %}
<li><a href="{% url 'polls:detail' poll.id %}">{{ poll.question }}</a></li>
{% endfor %}
</ul>
{% else %}
<p>No polls are available.</p>
{% endif %}
<br>
<html><body>Markets</body></html><br>
<select name="market" id="marketid" size="2" multiple="multiple">
<option value="0">All</option>
{% for stat in all_entries %}
<option value="{{ stat.id }}">{{ stat.market }}</option>
{% endfor %}
</select><label for="user">Coupon code :</label>
<input type="text" id="coupon_Code" maxlength="100" />
<br>
<label for="user">Discount :</label>
<textarea rows="2" cols="19" minlength="15" id="coupon_Discount"></textarea>
<br>
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+unsubscribe@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/bc844e4e-753c-410f-a488-d2452b61ef44%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
relative URLs in redirects
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+unsubscribe@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/ac90be77-fa18-4577-8839-dce95cdec09d%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Re: django - default value name for the ForeignKey
--I have a model for uploading photos in an album by the users. But if the user don't want to create an album, and just upload photos, I want it to be uploaded in a default album, namely 'Default album'. So that, whenever the user uploads photo without creating a new album, the 'Default album should be updated by that photos. For that, I thought about giving a
default value
in the title of the Album, but I also don't want to create a new album with name 'Default album' whenever the user doesn't create a new album to upload photo. I just want to update the 'Default Album'. Please suggest me how to achieve the above mentioned. And also is it okay to just give theForeignKey field
of the User to the Album class and not the Photo class??? Thank you!models.py:
class Album(models.Model): title = models.CharField(max_length=200) pub_date = models.DateTimeField(default=datetime.now) user = models.ForeignKey(User) class Photo(models.Model): album = models.ForeignKey(Album) title = models.CharField(max_length=200) image = models.ImageField(upload_to=get_upload_file_name, blank=True) pub_date = models.DateTimeField(default=datetime.now)
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+unsubscribe@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/CAHSNPWs-6Lx%3Dtwwb0Y%2B7zd4wn-7DEqXUR7%2BE4Ttz4C3wukqFgQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
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+unsubscribe@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/CABqSV%3D%2BDDOhW%3DfbWZTdqpONZRdLPY3Db_dBCiqUGQxFne5_NqA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
django - default value name for the ForeignKey
I have a model for uploading photos in an album by the users. But if the user don't want to create an album, and just upload photos, I want it to be uploaded in a default album, namely 'Default album'. So that, whenever the user uploads photo without creating a new album, the 'Default album should be updated by that photos. For that, I thought about giving a default value
in the title of the Album, but I also don't want to create a new album with name 'Default album' whenever the user doesn't create a new album to upload photo. I just want to update the 'Default Album'. Please suggest me how to achieve the above mentioned. And also is it okay to just give the ForeignKey field
of the User to the Album class and not the Photo class??? Thank you!
models.py:
class Album(models.Model): title = models.CharField(max_length=200) pub_date = models.DateTimeField(default=datetime.now) user = models.ForeignKey(User) class Photo(models.Model): album = models.ForeignKey(Album) title = models.CharField(max_length=200) image = models.ImageField(upload_to=get_upload_file_name, blank=True) pub_date = models.DateTimeField(default=datetime.now)
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+unsubscribe@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/CAHSNPWs-6Lx%3Dtwwb0Y%2B7zd4wn-7DEqXUR7%2BE4Ttz4C3wukqFgQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
Re: Django mysql over ssl (2026, 'SSL connection error: Failed to set ciphers to use')
> Hi,
>
> Summary:
> I'm getting this error "(2026, 'SSL connection error: Failed to set
> ciphers to use')", on the django error page and I don't know what i
> happening!!!
>
>
> I'm using apache / wsgi and my aplication it's on a virtualenv.
>
> The main problem is that I can't connect to a remote mysql over ssl.
>
> The first think checked was the ssl configuration... but it's all rigth
> becouse I can run all django commands, (runserver too) without any problem,
> and the aplications it's connecting to the remote database over ssl
> correctly.
>
> The next think checked was runserver response and the application doesn't
> raise any error... it works perfectly...
>
> With that two points i can see that the problem is in the wsgi,
> specifically with the libraries that load to run the application becouse
> it's the only think that I can see that is diferent from a runserver
> (executed inside the virtualenv)
>
> Anyone have had the same problem or can give me ant clue, I'm spending a lot
> of hours tryng to solve that.
>
> The next test will be change to nginx to see if the problem persist..
>
Sounds like libmysqlclient is linked to a different libssl than
httpd/mod_ssl is linked to.
ldd /path/to/libmysqlclient.so
ldd /path/to/mod_ssl.so
If so, fix it - upgrade one or the other.
Cheers
Tom
--
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+unsubscribe@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/CAFHbX1Ld%2BCf3gGPCE32zqmxnHtExOs75SZp45NFB8y%2BAgnu6fg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
Re: New to django,need help! just trying to retrieve values from a template to a view.py (ie user may input text, make choice selection, select a radio button value)
HiNew to django,need help! just trying to retrieve values from a template to a view.py (ie user may input text, make choice selection, select a radio button value)like to know the poll list section, market selection, coupon code, and discount text, and poll choice selection from radio buttonviewdef current_datetime(request):current_date = datetime.datetime.now()
latest_poll_list = Poll.objects.filter( pub_date__lte=timezone.now()).order_by( '-pub_date')[:5]
all_entries = FStatistics.objects.all()
return render_to_response('polls/current_datetime.html', locals()) ===================================================== current_datetime.html' Template like{% load staticfiles %}<link rel="stylesheet" type="text/css" href="{% static 'polls/style.css' %}" />{% if latest_poll_list %}
<ul>
{% for poll in latest_poll_list %}
<li><a href="{% url 'polls:detail' poll.id %}">{{ poll.question }}</a></li>
{% endfor %}
</ul>
{% else %}
<p>No polls are available.</p>
{% endif %}
<br>
<html><body>Markets</body></html><br>
<select name="market" id="marketid" size="2" multiple="multiple">
<option value="0">All</option>
{% for stat in all_entries %}
<option value="{{ stat.id }}">{{ stat.market }}</option>
{% endfor %}
</select><label for="user">Coupon code :</label>
<input type="text" id="coupon_Code" maxlength="100" />
<br>
<label for="user">Discount :</label>
<textarea rows="2" cols="19" minlength="15" id="coupon_Discount"></textarea>
<br>
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+unsubscribe@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/8e41088b-cd19-468f-8c73-0a67e4d847b4%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Django mysql over ssl (2026, 'SSL connection error: Failed to set ciphers to use')
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+unsubscribe@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/1cc91575-3657-41f8-b68d-50bb5d4e4ef8%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Wednesday, October 30, 2013
Re: User names not support Unicode in 1.5
> See https://code.djangoproject.com/ticket/20694 for a discussion of this.
>
> In summary: "[Allowing unicode in user names] would be considered a
> regression for anyone who relies on Django to validate that usernames
> are ASCII-only. A custom user model (introduced in 1.5) is the way to go."
In view of the fact that the new top level domains can contain non Latin
characters maybe that decision should be reviewed?
--
Regards
Alex
--
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+unsubscribe@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/5271FCD3.5040605%40mweb.co.za.
For more options, visit https://groups.google.com/groups/opt_out.
Re: Django Outbox Released
Thanks,
_Nik
--Hi guys,
If you want a better way to debug and evaluate emails while coding your application, please, take a look at http://blog.paulopoiati.com/2013/10/31/django-outbox-released/.
Any feedback will be appreciated.
=)
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+unsubscribe@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/CABqSV%3DJZZJxXj%3DrcHNbZOzWNLw%3DH8dTw4r8jiqZxUq6hXSA-ag%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
Re: Speed Improvements: Properties, Database Denormalization, Caching, Connection Pooling, etc.
> Note: one other thing is that the legacy DB we're using has a character
> varying (PostGres) type as its primary key, even though it's really just
> an integer that should probably be auto incrementing serial type.
If you install South you should be able to adjust that varchar to
integer. I haven't tried it myself but South is definitely magical and
is the way I'd try first. Otherwise, I'd practise dump, edit the data
and reload until I could happily script the conversion.
I would say there are definite speed benefits if you can delegate
primary key increments to the ORM/database.
Also, install django-debug-toolbar which will count all your queries for
you as you try different approaches.
Good luck
Mike
We're
> not adding anything new to this DB so the auto behavior isn't a big
> deal. It seems like this might be just another speed penalty (although
> it doesn't seem like that would be what's really limiting us right now).
>
> --
> 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+unsubscribe@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/4f330629-3d27-4edd-af2a-59c0900fdf81%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
--
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+unsubscribe@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/5271DDB0.6090407%40dewhirst.com.au.
For more options, visit https://groups.google.com/groups/opt_out.
Re: Speed Improvements: Properties, Database Denormalization, Caching, Connection Pooling, etc.
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+unsubscribe@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/4f330629-3d27-4edd-af2a-59c0900fdf81%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Speed Improvements: Properties, Database Denormalization, Caching, Connection Pooling, etc.
- DB Connection pooling. (Might address time associated with opening / closing connection)
- It sounds like Django may soon be supporting keeping a connection open for a set period of time. (Same as above)
- Switching my properties to actual columns in the DB. I should be able to keep these consistent since many of the tables are actually static information. I think there's one point where saving occurs for any of the dynamic DB information that goes into the calculation. (Should help with some overhead -- a complex query would be reduced to a simple query).
- Django's cache framework. (Could make significant improvements -- but this cache is only kept for a certain period of time. Some users will still have to wait.)
- Database tuning (Don't know much about this...)
- It seems like it might be inefficient that each property is individually moving through the first three tables (is this the right way to say this??) since the prop_id isn't used until we get to m2mfield_set_all(). I could condense the number of tables that need to be traversed However, it seems like this would make the # of calls to the DB equal to 2*n+1 rather than 2*n where n is the number of prop_ids I'm using.
- Maybe I need to check out the query this is making and write my own custom query if it's being inefficient?
- Is that line of code terrible? Should I be doing this a better way?
- If not, how do I do some time profiling to determine which of the above I should do? Or should I just do each one and see if it improves?
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+unsubscribe@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/9f1ff8a8-140a-4071-9c9f-551b55a2b204%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Django Outbox Released
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+unsubscribe@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/CABqSV%3DJZZJxXj%3DrcHNbZOzWNLw%3DH8dTw4r8jiqZxUq6hXSA-ag%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
django - differentiate users in the template
So, I am trying to create a user page, and its url will be associated with its username, something like this
And in that page, I want all the photo's uploaded by that user (here 'robin') to be displayed in the template. And another thing is, in the menu bar, there's an link for the the profile page for the request.user, i.e. the logged in user, suppose the user is 'kevin', and it will also direct it to the request.user's url like:
Somehow I managed to get the desired output. But what I also wanted was that, even if I change the url to something different other than the request.user's name, I wanted the request.user and the other username to be differentiated easily, so that I can manipulate them in the templates. And so I hopefully came with this solution. But I really don't know that this is an appropriate solution. Because what if I change the username to something other than the request.user and come up with all its information. Please help me if there's any better way to do it. And feel free to ask me if you didn't understand the question. Any suggestion will be much appreciated! Thank you.
test.html:
<body> <div> <ul> <li><a href="/photo/">Photos</a></li> <li><a href="/accounts/profile/{{user_1}}/">{{user_1.username}}</a></li> </ul> </div> <div id="wrapper"> {% block content %} {% endblock %} </div> </body>
profile_page.html:
{% extends 'test.html' %} {% block content %} <p>{{user.username}}</p> <div id="container"> {% for photo in photos %} <img src="{{MEDIA_URL}}{{photo.image}}" width="300px" /> {% endfor %} </div> {% endblock %}
models.py:
class Photo(models.Model): title = models.CharField(max_length=200) image = models.ImageField(upload_to=get_upload_file_name, blank=True) pub_date = models.DateTimeField(default=datetime.now) creator = models.ForeignKey(User, related_name="creator_set") likes = models.ManyToManyField(User, through="Like") class Meta: ordering = ['-pub_date'] verbose_name_plural = ('Photos') def __unicode__(self): return self.title
app's urls.py:
url(r'^profile/(?P<username>\w+)/$', 'userprofile.views.profile_page'),
views.py:
@login_required def profile_page(request, username): if request.user.is_authenticated: user_1 = request.user user = User.objects.get(username=username) user_photos = user.creator_set.all() return render(request, 'profile_page.html', {'user':user,'photos':user_photos, 'user_1':user_1})
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+unsubscribe@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/CA%2B4-nGownkbHyhDVrmq6iZ2fDxmc-jY-5uGCQR74%3D7MdcXak6A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.