Re: How do I get Django to ignore javascript code because its throwing an exception

2014-07-30 Thread Camilo Torres
Hello, you can use 'verbatim':
https://docs.djangoproject.com/en/1.6/ref/templates/builtins/#verbatim

On Wednesday, July 30, 2014 6:59:05 PM UTC-4:30, G Z wrote:
>
> so im using the following java script
>
> var cpuChart = document.getElementById('cpu').getContext('2d');
> new Chart(cpuChart).Line(cpuData,{
> bezierCurve: false,
> datasetFill : false,
> legendTemplate : "-legend\"><% 
> for (var i=0; i style=\"background-color:<%=datasets[i].lineColor%>\"><%if(datasets[i].label){%><%=datasets[i].label%><%}%><%}%>"
> 
> });
>
> django will see the % signs and think it is block content as it says below 
> i copy and pasted the error, how i get django to ignore a section of my 
> code and not parse the tags for that section.
>
>
> Request Method:POSTRequest URL:http://127.0.0.1:8000/vmstats/Django 
> Version:1.6.5Exception Type:TemplateSyntaxErrorException Value:
>
> Invalid block tag: '>
> Exception 
> Location:/usr/local/lib/python2.7/dist-packages/django/template/base.py 
> in invalid_block_tag, line 332Python Executable:/usr/bin/pythonPython 
> Version:2.7.5Python Path:
>
> ['/home/grant/workspace/Django Projects/trunk/holon',
>  '/usr/lib/python2.7',
>  '/usr/lib/python2.7/plat-x86_64-linux-gnu',
>  '/usr/lib/python2.7/lib-tk',
>  '/usr/lib/python2.7/lib-old',
>  '/usr/lib/python2.7/lib-dynload',
>  '/usr/local/lib/python2.7/dist-packages',
>  '/usr/lib/python2.7/dist-packages',
>  '/usr/lib/python2.7/dist-packages/PILcompat',
>  '/usr/lib/python2.7/dist-packages/gtk-2.0',
>  '/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
>  '/usr/lib/python2.7/dist-packages/ubuntuone-client',
>  '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',
>  '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol']
>
> Server time:Wed, 30 Jul 2014 23:27:32 +
> Error during template rendering
>
> In template /home/grant/workspace/Django 
> Projects/trunk/holon/portal/templates/vmstats.html, error at line *162*
> Invalid block tag: '> document.getElementById('iops').getContext('2d'); 153 new 
> Chart(iopsChart).Line(iopsData,{ 154 bezierCurve: false, 155 datasetFill 
> : false, 156 }); 157 158 var cpuChart = 
> document.getElementById('cpu').getContext('2d'); 159 new 
> Chart(cpuChart).Line(cpuData,{ 160 bezierCurve: false, 161 datasetFill : 
> false, 162 legendTemplate : " class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; 
> i style=\"background-color:<%=datasets[i].lineColor%>\"><%if(datasets[i].label){%><%=datasets[i].label%><%}%><%}%>"
>  
> 163 164 }); 165 }
>

-- 
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/35781377-7220-4559-a417-45d23417fa55%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


multiple projects on same database

2014-08-07 Thread Camilo Torres
Hello.

You can use the same DB, but different schema or different user. You can also 
use the same schema as long as table names (and other objects names) din't 
match.

I recomend to use diferent schemas for different web apps.

Camilo.

-- 
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/a463b1a0-5596-4b42-92c7-853243d277c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: multiple projects on same database

2014-08-13 Thread Camilo Torres
Hello Hector,

It seems that using 2 different databases will cause duplicate schema (tables) 
and duplicate data. So in your case I prefer to change my mind and recomend you 
to use a single database. In general I don't see any problem with that.

Regards,
Camilo.

-- 
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/ffb1875f-1200-4c9c-8cf0-f8946fd3dd2e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problems with "Hello World" Debian Wheezy Django 1.6.5

2014-08-19 Thread Camilo Torres


On Tuesday, August 19, 2014 11:59:31 AM UTC-4:30, Andrew Koller wrote:
>
> curl: (52) Empty reply from server
>
> On Tuesday, August 19, 2014 9:21:34 AM UTC-7, Tom Evans wrote:
>>
>> On Tue, Aug 19, 2014 at 5:07 PM, Andrew Koller  
>> wrote: 
>> > Yes they are on the same computer and no, I don't get any additional 
>> output 
>> > to the console. I know that something is sort of working because the 
>> chrome 
>> > error message changes from "This webpage is not available" to "No data 
>> > received" on 127.0.0.1:8000 
>> > 
>>
>> From another console on the same machine: 
>>
>> telnet 127.0.0.1 8000 
>>
>> If it then says "Connected to localhost." type this in and hit return 
>> twice afterwards 
>>
>> GET / HTTP/1.1 
>> Host: 127.0.0.1 
>>
>> Alternatively, if you have curl installed: 
>>
>> curl -I http://127.0.0.1:8000/ 
>>
>> Show the full output of either command please. 
>>
>> Cheers 
>>
>> Tom 
>>
>
Paste here the content of your urls.py 

-- 
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/69cbdb18-4adb-4fcd-a6e9-6466bc838c27%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


TypeError: "Source code string cannot contain null bytes"

2014-08-27 Thread Camilo Torres
As it says: you have a null character in your  source code script. That is an 
invalid character for a python script; this does not seems to be related with 
Django.

Open your source code script with a powerfull text editor capable of showing 
hidden/special characters, then look for a 'null' character somewhere in your 
code.

If you pasted a text, assure you correctly copy the source.

-- 
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/cb1ae209-1bd6-4ab4-afdd-2515c57ea5f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Error importing dbapi2...

2014-08-27 Thread Camilo Torres
If you are running inside a virtualenv, assure you have the sqlite3 module 
installed inside the v-env, or run toggleglobalsitepackages inside the v-env.

-- 
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/91d24a6a-0364-40d9-a593-7b3e081063fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: muliple pagination on same page

2014-08-27 Thread Camilo Torres
This is basically a DB query issue. Follow these general directions:

1. In your page add a form with a select with the filtering options.
2. In your view, instead of getting all the instance of your model, filter by 
the selected option.

-- 
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/ff014ba5-d10c-4a54-9039-799794278a00%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie Question - Where to store application constants?

2014-02-15 Thread Camilo Torres
To round this, for the price of gold, and if you are using the 
django.contrib.admin interface, you can use Django Solo or similar 
singleton model. That way you can edit your "business properties" within 
the admin interface:
https://pypi.python.org/pypi/django-solo


On Friday, February 14, 2014 12:24:09 PM UTC-4:30, ke1g wrote:
>
> It depends on the complexity of the issue.
>
> The price of gold does fluctuate.  On the grounds that I might want to 
> change it more often than I would want to ssh in, edit a file, and restart, 
> I would tend to put price of gold in the database, that is, in a model of 
> which there may only be one instance.  Implementing limits on who has 
> permission to change it is a separate fun topic, which may not be needed if 
> very few people have admin logins.
>
> Then there are application specific configuration options, which tent to 
> never change once an installation is up and running.  You can require that 
> they be set in settings.py if the constants are highly likely to differ 
> site to site (or if there is only one site in the world using this app), 
> but it is probably worthwhile providing defaults which can be overridden in 
> settings.py .  A common way to do the latter is to have another settings 
> file in the app directory (usually also called settings.py, since it can be 
> qualified with the app name) which defines constants as the result of 
> calling gettattr on the main settings object, and providing the default 
> value as teh third argument to getattr.  The other parts of the app get the 
> constants from the app specific settings file.
>
> Another kind of constant is truly never expected to change, such as 
> physical or algorithmic constants, defined so that they can be used 
> symbolically.  Sometimes they are only used quite locally, and can be 
> defined in that module, but if they are used by two or more modules, they 
> should probably be defined once, and imported in modules that use them.  
> While it is possible to define them in any module (such as the one that 
> uses them the most) and to import from that module in others that need the 
> constant(s), you must beware of circular import problems, so it is often 
> easier to create a constants.py or the like (if you already have an app 
> specific settings module, it is a fine place for you constants).  But your 
> models.py module, if you have only one, is a pretty safe place to put 
> constants, since it doesn't tend to import your other modules (unless you 
> have an app specific settings module), so you won't (typically)  have 
> circularity if you import from it.
>
> Bill
>
>
> On Fri, Feb 14, 2014 at 11:13 AM, Mark Phillips <
> ma...@phillipsmarketing.biz > wrote:
>
>> Where should one put application specific constants - those that change 
>> sometimes(1) and those that never change? For example, I am creating a 
>> simple inventory application for my mother's estate. Several quotes for 
>> her jewelry are based on the weight of the jewelry and the current price of 
>> gold.
>>
>> In the Estimate model, I have a field for weight, and then a property 
>> that looks something like:
>>
>> @property
>> def estimate_by_weight():
>> return self.weight * PRICE_OF GOLD
>>
>> Where would I put the PRICE_OF_GOLD constant? Some ideas that came to 
>> mind:
>>
>> 1. Settings.py - but then I have to edit that file every time I want to 
>> update the price of gold
>>
>> 2. Maybe a model so I can update it in the admin screens?
>>
>> 3. A form somewhere? But I think this would mean a model, so this is 
>> probably the same as #2.
>>
>> Where would one put a non-changing constant like the speed of light in a 
>> django application? 
>>
>> Thanks!
>>
>> Mark
>>
>> (1) Yes, I realize that terms 'constant' and 'changes sometimes' are 
>> mutually exclusive, but I hope you get the gist of what I am asking 
>> regardless of my imprecise description..
>>  
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CAEqej2OuRC%3D5c2AwKkLRV0%2BGQJMBd6g2wM41mRZB1RCpMtOshw%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+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/djan

Re: Aptana Studio 3 + PyDev + Git

2014-02-15 Thread Camilo Torres
On Friday, February 14, 2014 12:28:42 PM UTC-4:30, Віталій Лисенко wrote:
>
> I badly speak and write English, but i have question:
>
> 1. describe the main advantages of development in Aptana Studio 3 
> Django proects
> 2.write a detailed ìnfstrukcìû of how to lay out a project on github, 
> I have nothing
>

1. You can get it right from the Aptana site:
http://www.aptana.com/products/studio3

2. Read this:
 
http://www.jeffknupp.com/blog/2013/08/16/open-sourcing-a-python-project-the-right-way/

-- 
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/303421de-d24f-4086-ad0f-0c32c770e7cf%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Creating database in windows

2014-02-15 Thread Camilo Torres
On Friday, February 14, 2014 1:20:09 PM UTC-4:30, Nicholas Perez wrote:
>
> Hello. I am currently using Django version 1.6.2 trying to learn to use 
> Geodjango on a windows machine.
> My issue is that i have followed Geodjango installation for windows to the 
> letter(everything is installed in the default directory). my geodjango 
> folder is on my desktop
>
> As i follow the tutorial it tells me to run this command in my terminal: 
>
> createdb -T template_postgis geodjango
>
> how it says that createdb command is not recognized
>
> i skip that downloaded my zip to my world\data folder in my geodjango 
> folder(and by skip i mean continuing to the next instruction)
> and run this command:ogrinfo world/data/TM_WORLD_BORDERS-0.3.shp
>
> and it says ogrinfo command is not recognized 
>
> Please help out. I would be appreciate it.
>
>
1. createdb is a Postgres utility for the command line. May be you don't 
have Postgres propertly installed or configured in your system.
2. ogrinfo is an utility from the GDAL project:
 http://www.gdal.org/ogrinfo.html
may be you don't have it properly installed or configured

-- 
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/f8be2a72-fc4d-430c-9e5f-79c4f613e57f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: or-ing to QuerySets turns INNER into LEFT OUTER joins?

2014-02-15 Thread Camilo Torres
On Friday, February 14, 2014 4:58:21 PM UTC-4:30, sha wrote:
>
> What I would like to know is: 
> 1. Is there a reason why mysql performance is so slow on left outer join? 
> (even with indexes)
>
>>
>>
That is not a MySQL issue with outher joins, nor any other RDBMS issue with 
outher join. That depends so much in the way you wrote your query and the 
conditions for joining you are putting in; you can be doing a full table 
scan or cartesian product of two (or more) relations. The index are used 
whenever possible or whenever the RDBMS is able to use them.

Carsten's manual optimization seems better than that of the ORM for this 
case.

-- 
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/122ba3f2-3d9f-4059-8da1-0ce7364bd28c%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Login at the end of form wizard

2014-02-16 Thread Camilo Torres

On Friday, February 14, 2014 6:30:46 AM UTC-4:30, parnigot wrote:
>
> To work around the problem I’m now trying to include the login form as a 
> step of the wizard view.
>
> But I’ve encountered another problem. How can i login the user after it 
> completed the login step? 
> Does WizardView have a method executed at the end of each step that I can 
> override to do this?
>

See the method:

WizardView.render_goto_step(*step*, *goto_step*, ***kwargs*) 
in
https://docs.djangoproject.com/en/dev/ref/contrib/formtools/form-wizard/

-- 
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/0101d389-e347-4bbb-a7e2-b870af0bb529%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: First tutorial - 404

2014-02-16 Thread Camilo Torres
On Saturday, February 15, 2014 4:41:34 PM UTC-4:30, Steve Booth wrote:
>
> I'm just trying to run through the very first tutorial, and frankly, it's 
> been a nightmare. Running under Fedora 18, Python 2.7, Django version is 
> 1.4.5.
>
> So, I got the 1.4 tutorial up, created the site.. all works fine.  Fire up 
> the server -- looks great.  Browse to http://127.0.0.1:800..
>
> And I do NOT get the nice, blue Django page, I get a Page Not Found 404 
> error telling me the URLconf in mysite.urls does not match '^admin/'
>
> Well... YEA!  So either the 1.4 tutorial doc's are wrong, or the default 
> site doesnt work, or I dont know what I'm doing.
>

You're right!!

How do you installed Django 1.4? did you a 'pip install django==1.4'?

I did installed via pip and gave the same result as yours. That is because 
the version installed via pip have the admin url configured by default. 
Please, edit your mysite/urls.py, and comment line 11 to be like this:

#url(r'^admin/', include(admin.site.urls)),

then reload your page and continue with the tutorial.

-- 
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/3be0804c-a93c-499e-b758-7eba9e057b7b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Admin - search_fields + related fields

2014-02-21 Thread Camilo Torres
On Thursday, February 20, 2014 4:58:59 PM UTC-4:30, Ivan Goncalves wrote:
>
> I have these two models below: 
>
> class business(models.Model):
> name=models.CharField(max_length=40, blank=True, null=True)
> 
> class phone(models.Model):
> business=models.ForeignKey(business, 
> verbose_name='Business',blank=False)
> phone=models.CharField(max_length=40, blank=True, null=True)
>
> in the admin.py
>
> class businessAdmin(admin.ModelAdmin):
> model=business
> search_fields = phone__phone
>
> How do we make this search work fine ? Ie, bring me all companies that 
> possess the phone number entered by the User in the search of the form 
> (Admin). ?
>

 Hello,

search_fields is a list of names (strings), so you must put:

search_fields = ['phone__phone']

You can also add more field names to this list for the search to include 
those fields. See your same example, working, here:
https://gist.github.com/camilotorresf/9143399

Regards,
Camilo 

-- 
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/acab39de-87b6-460f-868f-ac5269782b49%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: API rest for https://docs.djangoproject.com/en/dev/intro/tutorial01/ help

2014-02-21 Thread Camilo Torres
On Thursday, February 20, 2014 6:23:27 PM UTC-4:30, Antonio Villavicencio 
wrote:
>
> I am trying just to do an API REST with the project of:
> https://docs.djangoproject.com/en/dev/intro/tutorial01/
>
> specifically with the model of Question
>
> class Question(models.Model):
> question_text = models.CharField(max_length=200)
> pub_date = models.DateTimeField('date published')
>
> class Choice(models.Model):
> question = models.ForeignKey(Question)
> choice_text = models.CharField(max_length=200)
> votes = models.IntegerField(default=0)
>
>
> I want to apply a serializer with question's choices but I don't know how 
> to do it
>
> class QuestionSerializer(serializers.HyperlinkedModelSerializer):
> class Meta:
> model = Question
> fields = (*'id', 'question_text'*, ? ) 
>
>
> I need some suggestion to solve this problem.
>

Should you append 'choices' to the list?

Regards,

Camilo.

-- 
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/9009490e-04c7-4031-908f-b3be4296fbde%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Printing things to the server console in Django?

2014-02-21 Thread Camilo Torres
On Friday, February 21, 2014 4:30:11 PM UTC-4:30, wasingej wrote:
>
> how I can print out information to my console that I started my web 
> application on using "python manage.py runserver".
>

Hello

With runserver you can use print() function calls, like:

print("Some output")

Regard 

-- 
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/2a7d6273-87e7-4f23-bc35-cfeece4eed3f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django test client encoding of JSON Booleans

2014-02-22 Thread Camilo Torres
On Friday, February 21, 2014 6:14:14 PM UTC-4:30, Daniel Smith wrote:
>
> I'm using Django version 1.5.5. Here is a short snippet of the test I'm 
> writing:
>
> from django.test import TestCase
>
> class MyTest(TestCase):
>
>   def my_test(self):
> url = ... location of my view ...
> self.client.post(url, data={'active': False}, format='json')
>
>
> The problem I'm running into is that when I inspect request.POST inside my 
> view, I get: {'active': [u'False']}. The workaround I have right now is to 
> use json.loads(request.raw_post_data), but I'm wondering if this is a bug 
> or if I am just missing something. Any help would be greatly appreciated.
>
Hello,

The test client is not converting the data to json.

1. In your test module, you must convert the data to json and tell the 
correct content-type application/json:
json_data = json.dumps({'active': False})
data = self.client.post(path=url, data=json_data, 
content_type='application/json')

I notice that you use a format='json' parameter to post; I can't find 
anything about that parameter in the documentation or the code. You should 
use content_type='application/json' instead.

2. In the views module, you should parse the json data:
if request.method == 'POST':
body = request.body.decode('UTF-8')
json_data = json.loads(body)
print('views 12', json_data['active'])

Kindly note that you should be using request.body instead of the deprecated 
raw_post_data.

Regards,
Camilo

-- 
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/61dc3c96-6572-479a-b4c0-7717e071aed9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Inconsistency in form_class behavior, is this a Django ticket?

2014-02-22 Thread Camilo Torres

On Saturday, February 22, 2014 6:20:35 AM UTC-4:30, Jopr wrote:
>
> I'm wondering whether the following should be a Django ticket and would 
> like your opinion on it. 
>
> When I forget to set a value for 'template_name' using the TemplateMixin 
> it returns a useful exception:
> "TemplateResponseMixin requires either a definition of 'template_name' or 
> an implementation of 'get_template_names()'"
>
> Though when I forget to set the form_class while using the FormView, it 
> returns the following unhelpful exception:
> "'NoneType' object is not callable"
>
> The behavior doesn't seem consistent to me and a more helpful message 
> would have saved me some trouble. Is it worth creating a ticket for this?
>
Hello,

I think you can file a ticket on this, should be a quick fix candidate to 
be included in future releases. Please post here the ticket number after 
you do.

Regards,
Camilo. 

-- 
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/17abc946-8f1a-4555-b22d-1e7353278488%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How to return Random items from a Mongodb Resource

2014-02-24 Thread Camilo Torres
On Monday, February 24, 2014 8:28:23 AM UTC-4:30, Anuj Chauhan wrote:
>
> Hi Friends,
>
> I need to return random items from a tastypie resource which is 
> a resources.MongoEngineResource.
>
> I have already tried using MyClass.objects.all().order_by('?'), but it 
> simply keep returning the same rows always. Following is the code of my 
> resource.
>
Hello,

You should use the Python's built-in random module. See random.sample()

Regards,
Camilo

-- 
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/485cabc9-86f1-4a2e-8e09-0fc744e76c43%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: View function and URL Conf basic question

2014-02-27 Thread Camilo Torres
On Wednesday, February 26, 2014 9:24:51 AM UTC-4:30, Daniel Roseman wrote:
>
> On Wednesday, 26 February 2014 08:10:40 UTC, ApathyBear wrote:
>>
>> Here is my urls.py:
>>
>> from django.conf.urls.defaults import *from mysite.views import hello, 
>> current_datetime, hours_ahead
>> urlpatterns = patterns('',
>> url(r'^hello/$', hello),
>> url(r'^time/$', current_datetime),
>> url(r'^time/plus/(\d{1,2})/$', hours_ahead),)
>>
>> And here is my View function associated with hours_ahead
>>
>> from django.http import Http404, HttpResponseimport datetime
>> def hours_ahead(request, offset):
>> try:
>> offset = int(offset)
>> except ValueError:
>> raise Http404()
>> dt = datetime.datetime.now() + datetime.timedelta(hours=offset)
>> html = "In %s hour(s), it will be %s." % 
>> (offset, dt)
>> return HttpResponse(html)
>>
>> Now what is throwing me off is how 'offset' is a second argument to  the 
>> hours_ahead function. Yet I am not quite sure how it being the second 
>> argument makes it the case that it is associated with whatever is entered 
>> as a URL. Let me use an example to illustrate my confusion.
>>
>> Say I request the URL:  http://127.0.0.1:8000/time/plus/2/ . Why is it 
>> the case that offset is '2'? I am not seeing why '2' is plucked out? What 
>> happened with 'time' and 'plus'? How does python/django know that the '2' 
>> is referring to offset?
>>
> That is what the regular expression does in your first snippet. `time` and 
> `plus` are just matched, but not captured: the only thing that is captured 
> is `(\d{1,2})`, because it is surrounded in parentheses.
>
> If that's not clear for you, you should read a guide to regexes: 
> http://regular-expressions.info  is a good one.
>
Hello,

As Daniel points out, this is related to regular expressions. You can read 
a full explanation here:
https://docs.djangoproject.com/en/1.6/topics/http/urls/#how-django-processes-a-request

You sholud also take a look at the 're' Python module. 

Regards,
Camilo.

-- 
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/e7e7aace-49f6-47e4-8094-8c492c0987d4%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django with rabbit (but without async celery) - can be done?

2014-02-27 Thread Camilo Torres

On Tuesday, February 25, 2014 10:58:47 AM UTC-4:30, Alon Nisser wrote:
>
> I need to implement a quite simple Django server that server some http 
> requests *and *listens to a rabbitmq message queue that streams 
> information into the Django app (that should be written to the db). the 
> data *must* be written to the db in a synchronized order , So I can't use 
> the obvious celery/rabbit configuration.  I was told that there is no way 
> to do this in the same Django project. since Django would listen to http 
> requests on It's process. and It can't handle another process to listen for 
> Rabbit - forcing me to to add Another python/django project for the 
> rabbit/db writes part - working with the same models The http bound django 
> project works with.. You can smell the trouble with this config from here. 
> .. Any Ideas how to solve this?
>
Hello,

What you has been told seems to be the right way of solving this. You 
should have another python (not Django) application listening to the queue 
to process incoming messages. You can use Django models to insert the data 
into the database. That queue does not really streams data to _the 
application_ but to _the database_ via a third running application. I don't 
have any smell here, only curious of what 'written to the db in a 
_synchronized order_' means ;)

If you are going to receive a stream of data, split in messages in a queue, 
then I assume you may need to store the data in the DB in an ordered 
fashion, in a way that can then easily be retrieved in the right order or 
sequence to play or use the data. That is a different problem with many 
solutions with the tools you have, and has nothing to do with Django, but 
programming in general :) You can have an order field in your models. You 
can cache the data in your queue listener application and write to the DB 
only portions that make sense according to order and keep the data that is 
out of order in memory until it can be written.

Regards,
Camilo

-- 
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/3f50643c-fc7a-45f6-9ef8-a51ad74c3452%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Using Django without templates?

2014-02-27 Thread Camilo Torres
On Wednesday, February 26, 2014 6:16:39 PM UTC-4:30, ApathyBear wrote:
>
> He mentioned something that I hadn't really gotten a chance to ask him 
> more about
> He told me to be careful with django templates because in terms of scale, 
> they can cause problems and almost always need to be re-written. Rather he 
> mentioned something like using a 'full stack'.
> I think back, and I don't exactly follow what he means by that. Is their a 
> way to use Django without templates? Is it better ? Why or why not?
>
Hello,

A web application is based on the HTTP protocol, that is text based. The 
purpose of the protocol is that a web browser request a document, and the 
server responds with a document text (may be other kind of content types, 
like images). Django manages this protocol through the use of views and url 
configurations: each url is managed by a view. The view responsibility is 
to deliver a (text) document, and do so via a 
django.http.response.HttpResponse object. So you only need to return, in 
your views, HttpResponse objects.

You can simply return in every view something like this:
return HttpResponse('hello world')

and it will work, without using templates. This is faster than loading a 
template with the text 'hello world', render and pass it to the view.

You can do that to return complex HTML (or other types of) documents of 
your site. Or you can use a template system and manage the HTML more easily 
with a bit more processing overhead. You can use other template systems 
besides the provided by Django, like Jinja (that has shown to be faster in 
some benchmarks compared to Django's).

Regards,
Camilo

-- 
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/4f03f506-202a-4fce-92d4-e3dceb832ffa%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Javascript and sessions

2014-02-27 Thread Camilo Torres
On Wednesday, February 26, 2014 10:41:38 PM UTC-4:30, Luke Baker wrote:
>
> My web application is heavily based around form input. I'd like to update 
> the user's session with each form input that they update or change while 
> working with a form. I'm thinking of implementing some simple javascript 
> that listens for 'change' events on each form input. When the 'change' 
> event fires, I'd like to make an ajax request to update the users session 
> with that form input name and value. To do this, I would have to write a 
> view that would allow the user to POST any thing they wanted (essentially) 
> to their session - is this safe? It makes me think twice.
>

Yes you must write that view. Sanitize the inputs.

-- 
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/187995d9-0a47-4e00-9b93-f17490d7ba96%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: "No such table" error.

2014-03-02 Thread Camilo Torres

On Saturday, March 1, 2014 3:29:01 PM UTC-4:30, Omar Acevedo wrote:
>
> Hello, I'm having an issue in/with Django, which is on a shared hosting, 
> and I'm using virtualenv and fastcgi.  (<- saying this, just in case it 
> helps in something)
>
> I'm getting
> "OperationalError at /admin/
> no such table: auth_user" 
> after entering my credentials (username & pw) that were set when asked 
> after running the syncdb.
> Yes, I created a project (django-admin.py startproject the_project),  then 
> ran python manage.py syncdb.
> So it's supposed (which it says it does) to create the tables for the 
> admin, but still, I'm getting that error when going to the admin through 
> mydomain.com/admin.
>
> I'm a first-timer hosting a django app, so, what else I'm supposed to 
> know, to do?  
>

May be you are using a different settings file when you ran the command 
than when you deploy the application.

-- 
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/c14a45af-7bd8-40b0-8faa-2ec7bb7bebe4%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Trouble with Django in production server.

2014-03-02 Thread Camilo Torres
You also should be activating your virtualenv to run the server.

On Saturday, March 1, 2014 8:46:10 PM UTC-4:30, jondbaker wrote:
>
> Instead of hard-coding paths, check out os.path, os.abspath and os.sep 
> (and the rest of the os module) for such needs. I usually declare a 
> PROJECT_ROOT var at the top of my settings.py using the aforementioned os 
> module, and then hang paths (like your db path) off of that instead of 
> building each path individually.
>
> Glad you figured it out.
>
> Sent from my iPhone
>
> On Mar 1, 2014, at 5:41 PM, Omar Acevedo > 
> wrote:
>
> To see if it worked, and yes it did!
> So, I'm just having trouble with the paths.
> I'm using a virtual environment.
> So I guess I'll have to deal with the paths.
> Thank you a lot anyways!!! :)
>
>
> On Sat, Mar 1, 2014 at 8:39 PM, Omar Acevedo 
> > wrote:
>
>> I explicitly wrote '/home/catacafe/.env/env/lib/python2.7/db.sqlite3' in 
>> the NAME option of the DATABASES dictionary.
>>
>
>  -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users...@googlegroups.com .
> To post to this group, send email to django...@googlegroups.com
> .
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAH_X0gMnjh%2BOy5AQC2rw_LtKEjnWU-YVY_yBH3AzTMoSP%2BCiXw%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+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/649003b5-d9c0-40db-ab4d-eefff7df579c%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: about installed_apps and manage.py ( no module named oztrend)

2014-03-02 Thread Camilo Torres
On Sunday, March 2, 2014 12:35:58 PM UTC-4:30, 董健 wrote:
>
> My error is something like ImportError: no module named oztrend. 
> I know that apps in the list of installed_apps can be searched in 
> python/lib/site-packages or the app directory. however, i cannot figure out 
> the search order. now, python/lib/site-packages are searched in the first 
> place and the error above appears.
> the second question is the location of manage.py. it seems that the loc of 
> manage.py is related to the app directory.Can someone give me some 
> instructions or some related articles?
> thanks in advance.
>

You should provide more information, like:

* The directory structure of your project 
* The stack trace for the error
* How are you running your application
* How do you installed this oztrend module or where do you put it

Here you can see information about the location and usage of manage.py:

* https://docs.djangoproject.com/en/1.6/intro/tutorial01/

-- 
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/23b6226e-ec9a-46e7-93e1-e769f4d7%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: django - commenting app for all other apps

2014-03-02 Thread Camilo Torres
On Sunday, March 2, 2014 5:30:01 AM UTC-4:30, Robin Lery wrote:
>
> I have an app for forum. It has three classes *Tag*, *Question* and 
> *Answer*.
>
> I also want to have comments for *Question*, *Answers* and also for *other 
> parts* of my apps. What is the best way to achieve this? I mean, what is 
> the right way to design the django models for this use case? Do I have to 
> use *content types* for this?
>

You can use multiple table inheritance. See this question and study how a 
similar case like yours was solved in another domain, but with the same 
need for comments:

https://groups.google.com/forum/#!topic/django-users/KOebQtRnYt0

Regards,
Camilo

-- 
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/fdddbd07-f9eb-4eea-8e66-16118e111954%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Using inlines on a one to many but not seeing "add another" link

2014-03-02 Thread Camilo Torres
On Saturday, 1 March 2014 15:53:41 UTC-8, Dennis Marwood wrote:
>
> Hello. 
> Here are my models and admin.py  dpaste.de 
> And here is the what I am referring to 
> https://docs.djangoproject.com/en/1.6/intro/tutorial02/#customize-the-admin-form
> But I my not seeing the link to add another. 
>
On Sunday, March 2, 2014 5:27:17 PM UTC-4:30, Dennis Marwood wrote:
>
> The only difference between the two apps that I can see is that I created 
> the old one w/ django 1.4.
>

 That is a really _big_ difference, and surely is the cause for your error 
:)

Regards,
Camilo

-- 
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/f1d72c1f-afed-4181-a287-cd4ba74ced18%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Trouble with Django in production server.

2014-03-03 Thread Camilo Torres
On Sunday, March 2, 2014 10:36:51 PM UTC-4:30, Omar Acevedo wrote:
>
> I have inside a file called .bashrc, 
> source /home/userName/.env/env/bin/active, 
> which makes me be in in a virtual environment already, no?
> It has a (env) to the left all the time.
> I presume that that is "activating virtualenv to run the server", right?
> On Sun, Mar 2, 2014 at 7:19 PM, Camilo Torres 
> 
> > wrote:
>
>> You also should be activating your virtualenv to run the server.
>>
>
No. You are running your commands in a virtualenv, but I don't know if you 
are running your server in a virtualenv. For server I mean the software 
that is serving your web application. You wrote in a previous message that 
you are using a  shared hosting service, that it means that the same web 
server is serving for every domain or account? You don't mention what 
server you are using, for example: apache, lighttpd, nginx. Does the server 
instance runs in the virtualenv? May be not.

Try to install your application and dependencies out of a virtualenv, 
server wide.

-- 
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/97e6134f-1ea7-4f44-8c68-4f6151e7dd6b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: create user define groups via interface

2014-03-03 Thread Camilo Torres
On Monday, March 3, 2014 11:52:13 AM UTC-4:30, django-newb wrote:
>
> I have build a simple site which is similar to a regular forum. I want to 
> create a functionality where any user of the system can create a group via 
> user interface. The functionality that I am thinking as follows: Interface 
> allow a user to enter group name and three email address. Then when group 
> get created system will email the invitation to those email address that 
> creator of the group entered to join the site and the group. I am not an 
> expert in django and it would be great if someone can point me towards 
> right direction on this. Also I would like to give group creator to remove 
> users from group.
>
Hello,

You must start from the beginning, with the overview of the framework, the 
tutorial, and the basic documentation. Please, start here:
https://docs.djangoproject.com/en/1.6/

Regards,
Camilo

-- 
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/ebe3e4b0-dbec-4798-822d-1b09189687c0%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: django 1.6.1 raw_id_fields open a 'change' popup instead of 'select' popup

2014-03-04 Thread Camilo Torres
On Tuesday, March 4, 2014 4:47:58 AM UTC-4:30, Vittorio wrote:
>
> In an admin form I input all data for a specific invoice (client, date of 
> issue, number of invoice) and, by means of inlines, the ordered items. In 
> these inlines I defined a raw_id_fields referring to the 'items' model 
> which is showing correctly in the form, BUT ... when I click on it  a 
> "change"   page is  often (not always) popping up instead of the expected 
> "select" one. 
> Tis happens both in development and in production. 
>
> Surfing the net I saw a message with the same subject as mine 
> http://stackoverflow.com/questions/21009319/django-1-6-1-raw-id-fields-open-a-change-popup-instead-of-select-popupwith
>  a somewhat cryptic only answer... 
>
Hello,

Try to delete your browser cache.

Regards,
Camilo 

-- 
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/8df6ef61-02cb-4b6f-a503-2f91c38d1d87%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Ajax Request on Admin Edit Form

2014-03-05 Thread Camilo Torres
On Wednesday, March 5, 2014 8:18:03 AM UTC-4:30, Jonathan Querubina wrote:
>
> How can i edit the Admin Default Edit Form on django to insert my custom 
> JS on the page? 
> I mean, when i am editing a model, i need to insert some JS code on it 
> Is this possible? 
>
Hello,

See if this may help:
https://docs.djangoproject.com/en/1.6/ref/contrib/admin/#templates-which-may-be-overridden-per-app-or-model

Regards,
Camilo 

-- 
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/cfa69efd-83ba-42b4-8ac0-6cbad5ff29c9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Trying to set up hashed versioning in Django for static files

2014-03-07 Thread Camilo Torres
On Thursday, March 6, 2014 11:38:07 PM UTC-4:30, Vernon Burt wrote:
>
> I've pretty quikly found out in my DJango adventure that I need to have 
> some kind of versioning for my static css and javascript files. After 
> talking to some web developers I was directed to use Django's 
> CachedStaticFilesStorage app to append an md5 hash to the static files 
> path. No matter how I set my static settings the files don't seem to get 
> the has appended and  I can no longer link to any of my static files, 
> either directly or using the static directive. I was wondering if anyone 
> might know what I am doing wrong.
>
> My  Settings:
>
> STATIC_ROOT = 'staticfiles'
>
> STATIC_URL = ''
> # Additional locations of static files
> STATICFILES_DIRS = ()
>
> STATICFILES_FINDERS = (
> 'django.contrib.staticfiles.finders.FileSystemFinder',
> 'django.contrib.staticfiles.finders.AppDirectoriesFinder',)
>
> STATICFILES_STORAGE = 
> 'django.contrib.staticfiles.storage.CachedStaticFilesStorage'
>
>
> My Template entry:
>
> {% block cssfiles %}{% load static%}{% endblock %}
>
> Anything that can point me in the right direction would help.If intrested, 
> I've also had this question up on StackOverflow for a few days: 
> http://stackoverflow.com/questions/22130697/djangos-cachedstaticfilesstorage-not-hashing-file-urls
>  
>
> Hello,

You should put a path in your STATIC setting:
https://docs.djangoproject.com/en/1.6/howto/static-files/

Your static path should be pointing to a real path accessible from  the 
path you are running your app.

Camilo.

-- 
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/6f77ea3a-53ca-4d90-bd86-b55ae5835fe2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: problem with integrating bootstrap 3.1.1 and django 1.6

2014-03-09 Thread Camilo Torres
On Sunday, March 9, 2014 12:11:11 PM UTC-4:30, rafiee.nima wrote:
>
> I am new to bootstarp and I want to use it in my django project.
> I put the needed folder's(css , js , img) in my project static folder and 
> config my setting.py to access static directory
> I can access bootstrap.css from http:///..myprojecet/static/bootstrap.css 
> which means I correctly config setting.py
> but the problem is that no bootstrap style applied to my temeplates. (I 
> also check in  firebug if css and js files been inclueded )
>
> here is my base.html code that other templates inhierent from it
>
> {% load static %}
> 
> 
> 
> 
> 
>   media="screen">
> 
>  
> 
> 
>   Dropup
>data-toggle="dropdown">
> 
> Toggle Dropdown
>   
>   
>   
> 
> {% block body_block %}
> {% endblock %}
>
> 
> 
> 
> 
>
Hello,

This URL looks bad:  http:///..myprojecet/static/bootstrap.css
What is in your settings.py?
Should it be: {% static 'bootstrap.min.css'% }?

-- 
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/7c7fb06b-67f2-4a8a-b3f8-cc11ef0cedfe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: problem with integrating bootstrap 3.1.1 and django 1.6

2014-03-13 Thread Camilo Torres

On Sunday, March 9, 2014 3:59:02 PM UTC-4:30, rafiee.nima wrote:
>
> On Sunday, March 9, 2014 10:29:37 PM UTC+3:30, Camilo Torres wrote:
>>
>> On Sunday, March 9, 2014 12:11:11 PM UTC-4:30, rafiee.nima wrote:
>>>
>>> I am new to bootstarp and I want to use it in my django project.
>>> I put the needed folder's(css , js , img) in my project static folder 
>>> and config my setting.py to access static directory
>>> I can access bootstrap.css from 
>>> http:///..myprojecet/static/bootstrap.css which means I correctly config 
>>> setting.py
>>> but the problem is that no bootstrap style applied to my temeplates. (I 
>>> also check in  firebug if css and js files been inclueded )
>>>
>>> here is my base.html code that other templates inhierent from it
>>>
>>> {% load static %}
>>> 
>>> 
>>> 
>>> 
>>> 
>>>  >> media="screen">
>>> 
>>>  
>>> 
>>> 
>>>   Dropup
>>>   >> data-toggle="dropdown">
>>> 
>>> Toggle Dropdown
>>>   
>>>   
>>>   
>>> 
>>> {% block body_block %}
>>> {% endblock %}
>>>
>>> 
>>> 
>>> 
>>> 
>>>
>> Hello,
>>
>> This URL looks bad:  http:///..myprojecet/static/bootstrap.css
>> What is in your settings.py?
>> Should it be: {% static 'bootstrap.min.css'% }?
>>
>
>
> tnx for reply 
> the actual ulr was http://127.0.0.1:8000/static/css/bootstrap.min.csswhich I 
> use to test if I correctly configure static path and url in my 
> setting.py 
> I attached my setting.py  
>
Hello,

Your configuration seems OK to serve static content from withing 
application directories.

Where in the file system are you putting your static file 
(css/bootstrap.min.css)?

Try this:
if you already have an application, use that, else create one like this:

python manage.py startapp testapp

Inside the newly created test app directory, create static/css/ and put 
your file there. Now try to reload your template to see if the template 
loads.

This may make it work for you, but in your case, is not the final solution. 
You may need to actually put these static files that are 'site global' in a 
central location in your filesystem, let's say: /var/www/static/(css|js|etc)

To do that, you need to add a setting to your settings.py:

STATICFILES_DIRS = (
'/var/www/static/',)

That way you put all of your static site wide files inside subdirectories 
in a common path.

Regards,
Camilo

-- 
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/37c0d7de-776b-4078-b915-b66235f934a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Documentation of modules

2014-03-13 Thread Camilo Torres
Hello,

I don't know of the existence of that reference documentation. You can try 
the source code documentation:
https://github.com/django/django

On Wednesday, March 12, 2014 4:13:38 AM UTC-4:30, Christian Waterkeyn wrote:
>
> Thanks.
> But this is not reference documentation!
> For example, the link django.core.management points to information for 
> "Writing custom django-admin commands"
> What I am looking for is the documentation of the classes, methods and 
> properties in the management module. This is visible in the link I gave in 
> my initial message, but I want something up-to-date, and certified by 
> djangoproject.
>
> UTC+1, C. Kirby a écrit :
>>
>> There is a link to the module index on the django project site.
>> Direct link: https://docs.djangoproject.com/en/1.6/py-modindex/
>>
>> On Tuesday, March 11, 2014 11:33:24 AM UTC-5, Christian Waterkeyn wrote:
>>>
>>> Hello,
>>>
>>> I am looking for a reference documentation of the django modules.
>>> For example django.core.management
>>> I found by google the url: 
>>> http://docs.nullpobug.com/django/trunk/django.core.management-module.html
>>> But I am not sure it is up-to-date, and surprised not to find it inside 
>>> the djangoproject.com site
>>>
>>> Where is the best place to browse the modules reference documentation?
>>>
>>> Thank you for your help!
>>>
>>> Christian
>>>
>>

-- 
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/2332b18d-2a70-41a2-a381-d3fba379d2df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django-quiz modification

2014-03-14 Thread Camilo Torres
On Wednesday, March 12, 2014 9:39:16 AM UTC-4:30, orchid barua wrote:
>
> The view portion has this:
> def question_check_anon(request, quiz):
> """
> check if a question is correct, adds to score if needed and return the 
> previous questions details
> """
> quiz_id = str(quiz.id)
> guess = request.GET['guess']
> answer = Answer.objects.get(id=guess)
> question = answer.question  #  the id of the question
> 
> if answer.correct == True:
> outcome = "correct"
> score = quiz_id + "_score"
> current = request.session[score]
> current = int(current) + 1
> request.session[score] = current  #  add 1 to the score
> anon_session_score(request, 1, 1)
> else:
> outcome = "incorrect"
> anon_session_score(request, 0, 1)
> 
> if quiz.answers_at_end != True:  #  display answer after each question
> return {'previous_answer': answer, 'previous_outcome': outcome, 
> 'previous_question': question, }
> else:  #  display all answers at end
> return {}
> Related template :
> 
>
> 
> 
> 
>
>
> {% for answer in answers %}
> 
> 
> 
>  class="form-radio">
> {{ answer.content }}
> 
> 
> 
> {% endfor %}
> 
> 
> 
> 
>
> I guess I will change the template to
>
> 
>class="form-radio"> True  False ||
> 
>{{ answer.content }}
>  
>
> and view to:
> if answer.correct == True:
> outcome = "correct"
> score = quiz_id + "_score"
> current = request.session[score]
> current = int(current) + 1
> request.session[score] = current  #  add 1 to the score
> anon_session_score(request, 1, 1)
> elif answer.incorrect == True:
> outcome = "correct"
> score = quiz_id + "_score"
> current = request.session[score]
> current = int(current) + 1
> request.session[score] = current
> anon_session_score(request, 1, 1)
> else:
> outcome = "incorrect"
> anon_session_score(request, 0, 1)
>
>
> but the result is not what I expected.
>
>
>
> On Monday, March 10, 2014 12:04:35 PM UTC+6, orchid barua wrote:
>>
>> I want to modify the django-quiz application.
>> https://github.com/tomwalker/django_quiz
>>
>> The quesiton will be a multiple true false type. Each question will have 
>> 5 stem, each will be tested for true/false. Each will carry partial marks 
>> eg. 1 will be awarded for a correct ans. And there will be a system for 
>> penalty eg. deduct 0.5 marks for a wrong answer of a stem. 
>>
> Hello

For what I understand you only like to apply a penalty of 0.5 to incorrect 
answers, so, does calling anon_session_score(request, -0.5, 1) works for 
this?

Yours,
Camilo 

-- 
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/eab0ea31-4e94-470a-9800-1ce782d819df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django-nested-inlines

2014-03-14 Thread Camilo Torres

On Wednesday, March 12, 2014 4:18:05 PM UTC-4:30, Thiago borges dos reis 
wrote:
>
> from django.contrib import admin
> from nested_inlines.admin import 
> NestedStackedInline,NestedModelAdmin,NestedTabularInline
> from models import Dieta, Cliente,Refeicao,Opcao
>
>
> admin.site.register(Cliente)
>
>
> class OpcaoInLine(NestedStackedInline):
> model = Opcao
> extra = 1
>
> class RefeicaoInLine(NestedStackedInline):
> model = Refeicao
> extra = 1
> inlines = [OpcaoInLine,]
>
>
> class DietaAdmin(NestedModelAdmin):
>
> fields= ('cliente','data_de_publicacao')
>
> inlines = [RefeicaoInLine,]
>
>
>
>
> admin.site.register(Dieta,DietaAdmin)
>
>
>
> ---Didn't work
>
Hello,

You forgot to indicate here:
* What is your error? (backtrace)
* Version of Django, etc.

Regards,
Camilo

-- 
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/9f7daa37-60ee-48e1-88d1-bf45dc289af1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I start with this project with django

2014-03-14 Thread Camilo Torres
On Friday, March 14, 2014 1:52:44 AM UTC-4:30, Rob L wrote:
>
> The feature list of the project I am wishing to do is:
>
>- Let users upload some images(a folder contains image files)
>- Backend generates static htmls to present those images, basically as 
>a gallery, via an generated url
>- User can select from default themes(templates)
>   - The template I am talking about here is not django template, they 
>   are a bunch of xhtml, css and js files can be choose from default or 
>   uploaded by user. 
>- User can upload and use their customized templates
>   - I made a local Python program that can work for the purpose here: 
>   https://github.com/viewplatgh/pgal, maybe can help you understand 
>   the feature I am trying to implement on the django project
>- The workflow is quite similar to http://codepen.io, but what user 
>inputs are images, optionally templates, css and js files, rather than 
> html 
>file itself. The htmls are generated by django app, and create a short url 
>for people who uploaded/built their resources to view the gallery.
>
> I know this app don't have to be implemented by using django. I 
> choose django because Python is the language I'm familiar with and it's the 
> framework I have a little experience with, but to implement such a site I 
> have so many questions and don't know where to start. I don't expect an 
> exact answer to this post, but just hope to collect more helpful 
> information, resources and ideas from experienced programmers to help me 
> kick my project off...
>
> Here is some questions in my mind currently:
>
>- Would django allow me to write a bunch of files at backend? 
>- Unlike php, django's urls don't map to server's folders. But I need 
>that feature to let user view the generated statics. How do I work through 
>this. Should I generate django templates?
>- How to prevent user from uploading malicious stuff to backend...
>
> Hello,

* Would django allow me to write a bunch of files at backend?

Yes, as any python program does. You only need to manage how to upload 
files to your application and the you can put these files wherever you need 
in your server file system.

*Unlike php, django's urls don't map to server's folders. But I need that 
feature to let user view the generated statics. How do I work through this. 
Should I generate django templates?

That is right. You should generate your static content in a static 
directory outside of Django, and that static directory will be served by a 
web server, not Django directly. See:
https://docs.djangoproject.com/en/1.6/howto/static-files/

* How to prevent user from uploading malicious stuff to backend...

By filtering the content in some way. There is no way that Django knows 
what is malicious by itself. You should write code (or user existing tools) 
to inspect the content uploaded by users and filter what you consider 
malicious.

Regards,
Camilo

-- 
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/4edef3c2-e6ff-423e-84ce-cd1d63f73063%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Admin Multiupload Field

2014-03-15 Thread Camilo Torres

On Saturday, March 15, 2014 11:18:05 AM UTC-4:30, Jonathan Querubina wrote:
>
> how can i have a Multiupload Field on a Model for the Django Admin? 
>
> I Found this: https://github.com/TND/django-files-widget 
>
Hello,

I don't fully understand your needs, but may be you can use inlines:
https://docs.djangoproject.com/en/1.6/ref/contrib/admin/#inlinemodeladmin-objects

Regards,
Camilo

-- 
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/4d360c3b-b977-4f6c-b626-1e5bb238a3ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [newbie] -- Regex-matching ("Tango with Django")

2014-03-15 Thread Camilo Torres
On Friday, March 14, 2014 8:14:57 PM UTC-4:30, David wrote:
>
> I am wodering whether my implementation is incorrect or whether there is 
> a typo in the textbook. My question is how I can make sense of these 
> instructions: "The regular expression to match about/ is r'^about/'". 
>
> I was following the "Tango with Django" book. 
>
> In the exercises of chapter 3 I am asked to 
>
> """ 
> Now map the view ['about', which we just created] to /rango/about/. For 
> this step, you’ll only need to edit the urls.py of the rango application. 
> """ 
>
> Later, the author givessome hints, specifically: 
>
>
> """ 
> The regular expression to match about/ is r'^about/' 
> """ 
>
> Now, there was no way to do this. I finally managed to get 
>
> http://127.0.0.1:8000/rango/and 
> http://127.0.0.1:8000/rango/about/ 
>
> running satisfactorily (my code is below), but I was not even sure this 
> was intended. The author possibly wanted to create 
>
> http://127.0.0.1:8000/about/instead of 
> http://127.0.0.1:8000/rango/about/ 
>
> Thanks for clarifying this issue for me! 
>
> Cheers, 
>
> David 
>
>
>
>
> Here is my project/urls.py 
>
> from django.conf.urls import patterns, include, url 
>
> from django.contrib import admin 
> admin.autodiscover() 
>
> urlpatterns = patterns('', 
> # Examples: 
> # url(r'^$', 'justnow.views.home', name='home'), 
> # url(r'^blog/', include('blog.urls')), 
>
> # url(r'^admin/', include(admin.site.urls)), 
> url(r'^rango/', include('rango.urls')),  # ADD THIS NEW TUPLE! 
> url(r'^about/', include('rango.urls')),  # ADD THIS NEW TUPLE! 
> ) 
>
>
>
> The app urls.py: 
>
> from django.conf.urls import patterns, include, url 
> from rango import views 
>
> urlpatterns = patterns('', 
> url(r'^$', views.index, name='Rangos index'), 
> url(r'about', views.about, name='About page'), 
> ) 
>
> The app views.py: 
>
> from django.http import HttpResponse 
>
> def index(request): 
> return HttpResponse("Rango says hello.  href='/rango/about/'>About") 
>
> def about(request): 
> return HttpResponse("Here is the about page.  href='/rango/'>Index") 
>
>
>
>
>
>
>
> david@ubuntu:~/[...]/django_project$ tree 
> . 
> ├── manage.py 
> ├── notes.txt 
> ├── rango 
> │   ├── admin.py 
> │   ├── admin.pyc 
> │   ├── __init__.py 
> │   ├── __init__.pyc 
> │   ├── models.py 
> │   ├── models.pyc 
> │   ├── tests.py 
> │   ├── urls.py 
> │   ├── urls.pyc 
> │   ├── views.py 
> │   └── views.pyc 
> └── tango_with_django_project 
> ├── __init__.py 
> ├── __init__.pyc 
> ├── settings.py 
> ├── settings.pyc 
> ├── urls.py 
> ├── urls.pyc 
> ├── wsgi.py 
> └── wsgi.pyc 
>
Hello,

To point the about view to  http://127.0.0.1:8000/about/, in you 
project/urls.py, you should change:
url(r'^about/', include('rango.urls')),  # ADD THIS NEW TUPLE!
to
url(r'^about/',  rango.views.about, name='About page'),
(of course, you have to import rango.views)

With your current configuration, these two links:
http://127.0.0.1:8000/rango/and 
http://127.0.0.1:8000/rango/about/ 

points to the same as:
http://127.0.0.1:8000/about/ and 
http://127.0.0.1:8000/about/about/  

Because you included the same urls for 'rango/' and 'about/'

Yours,
Camilo

-- 
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/809b5684-ce25-469a-bb4b-13571bcc01f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: messaging

2014-03-15 Thread Camilo Torres
On Friday, March 14, 2014 4:02:08 PM UTC-4:30, Ankit Singh wrote:
>
> i want to know that for certain task i want to send some message to user 
> on his cellphone .
> is there any way that i can do so in django with importing costly 
> application.
>
Hello,

You can do with a third party module/API/application. Django is not for 
sending SMSs, but for web front end.

You can do what you need inside a Django application. Your Django 
application can connect or use third party service to send the SMS.

Regards,
Camilo

-- 
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/7aed31aa-6a03-4805-8bdc-d6f3ffe48c1d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can please someone explain this code from the docs?

2014-03-15 Thread Camilo Torres
On Friday, March 14, 2014 5:33:37 PM UTC-4:30, Voyager wrote:
>
> On 03/14/2014 11:49 PM, Shawn Milochik wrote: 
> > That's just the syntax for calling a method on the base class. 
> > 
> > 1. MultiEmailField is a subclass of forms.Field. 
> > 2. forms.Field has a method named validate. 
> > 3. MultiEmailField also has a method named validate, so it overrides the 
> > one on forms.Field. 
> > 
>
> Thank you. It seemed odd that the calling class name is used to call the 
> parent but the more I think about it the more it makes sense. super in 
> it self is a function that returns the parent of a given class. So it is 
> logical to include class in arguments list. 
>
Hello,

This has nothing to do with Django; *super() is a Python built-in* to 
manage calling/accessing attributes of the super class taking in account 
that Python supports multiple inheritance.

Regards,
Camilo

-- 
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/8b1ff3d5-f805-4c13-81a1-1ff80f8f7ba0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using Redis as a DB backend for some models (not a caching backend!)

2014-03-15 Thread Camilo Torres
On Friday, March 14, 2014 3:10:09 PM UTC-4:30, Alon Nisser wrote:
>
> Can I use redis as a django database for some of my models? I'm aware (and 
> using) caching with django and redis, but I'm looking for something else 
> here: Something I can use at least some of the orm features with, handle a 
> django Model, etc.  I found 
> django-redis-enginebut 
> it doesn't look like an active project (pre alpha commits 3 years ago) 
> and django-nonrel  which doesn't 
> support redis and is actually a django fork and not Django proper. Any 
> ideas how to proceed from here? Thanks!
>
Hello

A simple search with 'django redis' gives me this in the firsts results:
http://niwibe.github.io/django-redis/

Yours,
Camilo

-- 
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/e75fe08c-60da-4890-9e98-4aa4a2f84d0a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: problem with integrating bootstrap 3.1.1 and django 1.6

2014-03-16 Thread Camilo Torres
On Sunday, March 16, 2014 1:58:50 AM UTC-4:30, rafiee.nima wrote:
>
> I'm using development server . and when i use   href="{{STATIC_URL}}css/bootstrap.css" rel="stylesheet" media="screen"> it 
> seems work correctly but when I use  media="screen">  my project file and directory structure is like :
>
>1. root project folder
>1. app folder
>2. static
>   1. css
>  1. bootstarp.css
>  2. js
>   3. img
>   3. media 
>4. template
>   1. app 
>   1. base.html
>   
> Hello,

 

should be:



Camilo

-- 
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/f01e1098-fbfd-47dc-aca3-69ffbb1de06a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Use custom HTML to render forms

2014-03-31 Thread Camilo Torres
You must think on what is the output HTML you need to generate. Depending 
on that, you may be able to figure where to put the {% block content %} 
tags. What is the output HTML you expect?

On Thursday, March 27, 2014 9:18:47 AM UTC-4:30, Fred DJar wrote:
>
> Hello, 
> I am a beginner in python and django programming, i have a question that 
> already have been asked in stackoverflow and many forums, but i couldnt 
> solve my own.
>
> this exactly my situation:
>
> this the code in my app html page:
>
> *{% extends 'base.html' %}*
>
> *{% block content %}*
>
> * {% csrf_token %}*
> *{{ form.as_p }} *
> **
> *Confirmer*
> **
> **
>
> *{% endblock %}*
>
>
>
> but in my base.html i have already this form and this classes:
>
>
> **
> **
> **
> **
> *Retaper votre mot 
> de passe*
> **
> **
> *.*
> *.*
> *.*
> *.*
> **
>
>
> where should i put *{% block content %}* and *{% endblock %}* in my 
> base.html!!
>
> i've also followed the tutorial from the official docs, but it did,'t work 
> out for me
>
> i'm sorry if my question seem silly!
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e94b706c-29e7-4b52-8312-cf0f030d9987%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ManyToMany quick question

2014-03-31 Thread Camilo Torres
On Monday, March 31, 2014 5:37:05 PM UTC-4:30, willyhakim wrote:
>
> when creating your models, how do you know which field to assign the 
> ManyToManyField ?
>

 from django.db import models


class Student(models.Model):
name = models.TextField()


class Course(models.Model):
name = models.TextField()
students = models.ManyToManyField(Student, related_name='courses')

>>> from testapp import models
>>> a = models.Student(name='a')
>>> a.save()
>>> b = models.Student(name='b')
>>> b.save()
>>> c = models.Course(name='')
>>> c.save()
>>> c.students.add(a)
>>> c.students.add(b)
>>> c.students.all()
[, ]

>>> a = models.Student.objects.get(name='a')
>>> a.name
'a'
>>> a.courses.all()
[]


Is this what you are asking?

-- 
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/9e05634b-4784-4cfe-beb9-9e0a52218edb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django python checkbox

2014-03-31 Thread Camilo Torres
Hello,

You should start with the basics:
https://docs.djangoproject.com/en/1.6/topics/http/file-uploads/

You are using request.FILES and that is for file upload, no file download. 
To upload a file to the server, you must have a  in 
your template, which you don't have.

To download files from the server to the browser (to the user computer), 
you should do:
https://docs.djangoproject.com/en/1.6/ref/contrib/staticfiles/
or, if the user uploaded the content:
https://docs.djangoproject.com/en/1.6/topics/files/

Hope this put you in the right direction.

Camilo

On Monday, March 31, 2014 1:31:24 AM UTC-4:30, Choro H wrote:
>
> Hello,
>
> i wan to do download file of a checkbox ;
> Please help me
>
> this is my viewspy:
>
> def export_selected_dataqq(request):
> if request.method == 'POST':
> _selected_action = request.FILES("_selected_action")
>
> response = HttpResponse(mimetype='application/vnd.ms-excel; 
> charset="Shift_JIS"')
> response['Content-Disposition'] = 'attachment; filename=file.csv'
> writer = csv.writer(response)
> _selected_action = []
> writer.writerow(_selected_action)
>
> for obj in _selected_action:
> 
> row=[]
> for field in User._meta.fields:
> row.append(unicode(getattr(obj,field.name)).encode("cp932"))
> writer.writerow(row)
> return response
>
> this is mmy html:
>
> 
> 
> 
> Check  
> 名前
> 会社名
> 法人電話
> 
> 
> 
> {% if articles.count > 0 %}
> {% for user in articles %}
> 
>  ="_selected_action" type="checkbox" value="{{user.id }}" type="submit" 
> class="button">
> {{ user.user_name  
> }}
> {{ user.company }}
> {{ user.number }} 
> 
> {% endfor %}
>
> 
> 
> 
> {% else %}
> None
> {% endif %}
>
>

-- 
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/129bfa86-8215-4bfe-9c7e-84a3fbef6017%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ManyToMany quick question

2014-04-01 Thread Camilo Torres
Hello,

By using default table names and default (or automatic) many to many field 
management, you get a join table like countries_products, but in your case, 
you are doing the many to many field management through the Imports model, 
so in the DB you should see data in the imports table for each relation 
between Countries and Products.

When doing many to many in a relational model, as in a RDBMS or SQL 
database, that relation must be modeled by using a third table. This is in 
a normalized schema. So, you will not see a join field, but a join table. 
Note: in a non-normalized schema it is possible to have a field for a many 
to many relation, but with data duplication, not the case of the Django ORM.

So in your model you will never see a country_name field. Think of this: if 
the country table had a country_name field, you can only put one value in 
that field for every row, so only one value for any Django model in the 
ORM, and this is not many to many, but one to many.

In your case, the relation is in the Imports model and hence in the imports 
database table.

Regards,
Camilo

On Tuesday, April 1, 2014 5:51:18 AM UTC-4:30, willyhakim wrote:
>
> Below is my models.py
> My problem is when I syncdb (I have dropped the db couple times to start 
> over)
> the *country_name* field with m2m never shows in the db. what am I doing 
> wrong? I am using postgres
>
> class Products(models.Model):
>
> hs_number = models.CharField(primary_key=True, blank=True, 
> max_length=4)
> product_descript = models.CharField(max_length=250)
>
> class Meta:
> db_table = "Products"
>
> def __unicode__(self):
> return self.hs_number
>
>
> class Countries(models.Model):
> country_id = models.CharField(primary_key=True, max_length=2, 
> blank=True)
>* country_name = models.ManyToManyField(Products, through="Imports", 
> blank=True)*
> region = models.CharField(max_length=200)
>
> class Imports(models.Model):
> hs_number = models.ForeignKey(Products)
> country_id = models.ForeignKey(Countries)
> imported_value2008 = models.DecimalField(max_digits=12, 
> decimal_places=2, default=0.00)
> imported_value2009 = models.DecimalField(max_digits=12, 
> decimal_places=2, default=0.00)
>
>

-- 
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/0fb3823a-414e-4255-85f8-48acfa21878a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ManyToManyField and Multi Table Inheritance

2014-04-01 Thread Camilo Torres
I tested this with SQLite3 and it worked, using your models:

>>> a.users = User.objects.all()
>>> a.save()
>>> a.delete()
>>> a = AccountTypeA(name='')
>>> a.save()
>>> a.users = User.objects.all()

After that:
sqlite> select * from testapp_accounttype_users;
1|1|1

Which is what I should expect considering I have only one user and only one 
account. Could you have an issue in another part of the code?

Regards,
Camilo.

On Tuesday, April 1, 2014 6:38:40 AM UTC-4:30, Izidor Matušov wrote:
>
> Hi,
>
> I've run into interesting issue and I'm not sure if I do something wrong 
> or this is Django issue. I'm using Multi Table Inheritance:
>
> 
> from django.db import models
> from django import forms
>
> class AccountType(models.Model):
> users = models.ManyToManyField('auth.User', related_name='accounts')
>
>
> class AccountTypeA(AccountType):
> name = models.CharField(max_length=255)
>
>
> class AccountTypeAForm(forms.ModelForm):
> class Meta:
> model = AccountTypeA
> fields = ('name', 'users')
> 
>
> However, users are not saved in database. Find out that ModelForm calls 
> `self.instance.users = ` but that's not get saved. Even 
>
> 
> account = AccountTypeA(name='something')
> account.save()
> account.users = User.objects.all()
> 
>
> is not propagated. However, account.accounttype.users works perfectly 
> fine. Do I do something wrong?
>
> P.S: I'm using Django 1.6
>
> Izidor
>

-- 
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/42408986-0366-49e5-a8fe-d80b783d8def%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django python checkbox

2014-04-01 Thread Camilo Torres
Lets suppose you need the user to select which files to download:
--choro_checkbox.html



Choro's quertion about checkboxes


Select files to download

{% csrf_token %}

File A
File B
File C
File D
File E
File F






Now, you must watch which of the files the user selected, but you have a 
problem: if the user selected more than one file to download you cannot 
send the files directly to the user in the view as a response, instead, you 
must present them with a page to download the files:

def choro_checkbox_question(request):
if request.method == 'GET':
return render_to_response('testapp/choro_checkbox.html', 
context_instance=RequestContext(request))
elif request.method == 'POST':
selected_checkboxes = request.POST.getlist('selected_file', [])
generated_filenames = []
for selected_file in selected_checkboxes:
filename = generate_file_for(selected_file)
generated_filenames.append(filename)
return render_to_response('testapp/choro_files_download.html', 
{'checks': selected_checkboxes,

'files': generated_filenames})

def generate_file_for(name):
filename = os.path.join(settings.MEDIA_ROOT, name)
filename = '{}.csv'.format(filename)
with open(filename, mode='w') as f:
f.write(name)
return os.path.split(filename)[1]

-- choro_files_download.html
{% load static %}
{% get_media_prefix as MEDIA_URL %}



Choro's quertion about checkboxes


Select files to download
{{ checks }}


{% for file in files %}
{{ file }}
{% endfor %}





You must correctly configure MEDIA_ROOT and MEDIA_URL in your settings, and 
may be use a better sub-directory schema to generate the files, but you can 
get the general idea.

Anyway, you still can verify if the user selected only one file and 
download that only file directly instead of presenting a page to download; 
you only present the page when the user selects more than one file to 
download.

Regards,
Camilo

On Monday, March 31, 2014 11:52:31 PM UTC-4:30, Choro H wrote:
>
> Thank you very much!
> I'm Sorry, i'm missing write comments,
> I want to do download have been checboxd file  from html, then i write to 
> views.py this code, so i don't know how do write !
> Please help me!
> this is my right code:
> def export_selected_data(request):
> #if request.method == 'POST':
> #_selected_action = request.POST.getlist("_
> selected_action")
>
> response = HttpResponse(mimetype='application/vnd.ms-excel; 
> charset="Shift_JIS"')
> response['Content-Disposition'] = 'attachment; filename=file.csv'
> writer = csv.writer(response)
> if request.method == 'POST':
> _selected_action = request.POST.getlist("_selected_action")
>
> _selected_action = User.objects.all()
> for obj in _selected_action:
> row=[]
> for field in User._meta.fields:
> row.append(unicode(getattr(obj,field.name
> )).encode("cp932"))
> writer.writerow(row)
> return response
> This is my html:
>
> 
> 
> selected_export
> 
> 
> 
> 
> 
> Check  
> 名前
> 会社名
> 法人電話
> 
> 
> 
> {% if articles.count > 0 %}
> {% for user in articles %}
> 
>  ="_selected_action" type="checkbox" value="{{user.id }}" type="submit" 
> class="button">
> {{ user.user_name  
> }}
> {{ user.company }}
> {{ user.number }} 
> 
> {% endfor %}
> 
> 
> {% else %}
> None
> {% endif %}
>
> 2014年4月1日火曜日 12時47分08秒 UTC+9 Camilo Torres:
>>
>> Hello,
>>
>> You should start with the basics:
>> https://docs.djangoproject.com/en/1.6/topics/http/file-uploads/
>>
>> You are using request.FILES and that is for file upload, no file 
>> download. To upload a file to the server, you must have a > type="file" ...> in your template, which you don't have.
>>
>> To download files from the server to the browser (to the user computer), 
>> you should do:
>> https://docs.djangoproject.com/en/1.6/ref/contrib/staticfiles/
>> or, if the user uploaded the content:
>> https://docs.djangoproject.com/en/1.6/topics/files/
>>
>> Hope this put you in the right direction.
>>
>> Camilo
>>
>> On Monday, March 31, 2014 1:31:24 AM UTC-4:30, Choro H wrote:
>&

Re: Add poll to the django tutorial polls

2014-04-06 Thread Camilo Torres
On Saturday, April 5, 2014 8:13:04 AM UTC-4:30, Christo bale wrote:
>
> I would like to make it possible to add a poll on the index.html, so one 
> don't need the admin. 
> I added a forms.py.
> Right now when I click enter after typing the new poll, the sites goes 
> blank and I need to refresh it. And no polls have been added. I am pretty 
> new to django, so I hope that you can help me.  
>
> forms.py
> class ComposePoll(forms.ModelForm):
> class Meta:
> fieldsets = [
> (None,   {'fields': ['question']}),
> ('Date information', {'fields': ['pub_date'], 'classes': 
> ['collapse']}), 
> ]
>
> index.html
>
>  {% csrf_token %}
> {{ form.add_poll }}
> 
> 
>
> views.py
> class IndexView(generic.ListView):
> template_name = 'polls/index.html'
> context_object_name = 'latest_poll_list'
>
> def get_queryset(self):
> """
> Return the last five published polls (not including those set to be
> published in the future).
> """
> return Poll.objects.filter(
> pub_date__lte=timezone.now()
> ).order_by('-pub_date')[:5]
> 
> add_poll = ComposePoll(request.POST or None)
> if add_poll.is_valid():
> create_poll = Poll.save(commit=False)
> create_poll.sent = datetime.datetime.now()
> create_poll.save()
> return HttpResponseRedirect('/polls/')
> 
> poll = Poll.objects.filter()
> 
> return render_to_response('polls/index.html', locals(), 
> context_instance=RequestContext(request))
>
Hello,

You should add a 'post' method to your view to get the data from the form 
and store it in your models.

Regards,

Camilo.

-- 
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/4ce00fee-daf9-498e-b502-46c68b62f95d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Saving forms with ManyToMany relationships

2014-04-06 Thread Camilo Torres
On Saturday, April 5, 2014 10:12:36 PM UTC-4:30, Jason S wrote:
>
> I've seen quite a few examples showing various ways to create a form using 
> manytomany relationships and save the data, but i'm still missing a key 
> piece of the puzzle.
> I've created a form and it "works", meaning the form creates a new Item 
> object and associates the user.
> However i'm not sure how to go about saving the item category and item 
> components selected in the form.
>
> I've tried quite a few things over the last week and i know its quite 
> easy, but just haven't quite gotten there yet and would appreciate some 
> guidance.
>
> FORM:
> class NewItemForm(ModelForm):
>
> class Meta:
> model = Item
> fields = ('name', 'desc', 'img','category','components')
>
> def save(self, user, component commit = True):
> """Append the component list to the item"""
> new_item = super(NewItemForm, self).save(commit = Fals
>
> if commit:
> new_item.save()
> #new_item.save_m2m()
> new_item.user.add(user)
> if component != "none":
> new_item.category.add(new_item)
> new_item.components.add(new_item)
>
> return new_item
>
> VIEW:
> def create_item(request):
>
> if request.method == "POST":
> form = NewItemForm(request.POST, instance=item())
> if form.is_valid():
> form.save(request.user, "none")
> return HttpResponseRedirect(reverse('nav.views.dashboard'))
> else:
> form = CategoryForm(instance=item())
> return render_to_response('objects/create_item.html', 
> {'item_Form': form}, context_instance=RequestContext(request))
>
> MODEL:
> class Item(models.Model):
> # 
> def __unicode__(self):  # Python 3: def __str__(self):
> return self.name
>
> name  = models.CharField(max_length=32)
> desc  = models.CharField(max_length=254)
> img   = models.CharField(max_length=32)
> user  = models.ManyToManyField(User) 
> components = models.ManyToManyField(component)
> category  = models.ManyToManyField(Category)
>
Hello,

1. This code does not compiles, only to note in case you already didn't 
tested

2. In your view: why do you instantiate a different form for POST request 
and any other kind of requests: NewItemForm in one case, CategoryForm in 
the rest.

3. In your view: You are using the string "none" instead the built-in None. 
I recommend you to use Python built-in None.

4. ModelForm's save method actually saves the related many to many data. 
Why are you doing these?
new_item.category.add(new_item)
new_item.components.add(new_item)

You are adding a Item where a component and a Category is expected. This 
does not make sense. You add(new_item) where you should be add(component()) 
or 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bede4d94-15c7-40ff-a8ca-f2dfb642f50f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Saving forms with ManyToMany relationships

2014-04-07 Thread Camilo Torres
Hello,

This works for me, saving the related objects in the many to many 
relationship. You can start from there to build yours:

models.py:

class Student(models.Model):
name = models.TextField()


class Course(models.Model):
name = models.TextField()
students = models.ManyToManyField(Student, related_name='courses')

forms.py.

class NewItemForm(ModelForm):

class Meta:
model = Course
fields = ('name', 'students')

view.py:

def create_item(request):
if request.method == 'POST':
form = NewItemForm(request.POST)
if form.is_valid():
form.save()
return HttpResponse('saved')
return HttpResponse('Form not valid')
else:
form = NewItemForm()
return render_to_response('testapp/create_item.html', {'form': 
form}, context_instance=RequestContext(request))


create_item.html:

{% csrf_token %}
{{ form.as_p }}





Regards,
Camilo

On Monday, April 7, 2014 7:51:30 PM UTC-4:30, Jason S wrote:
>
> Hi Camilo,
> I really appreciate your response.
> I had another go at this last night, particularly trying to use the 
> add(component()) snippet.
>
> To respond to your notes:
> 1. I simplified and used a find-replace to replace the model names which 
> is likely why it dosn't compile, sorry about that. Mine compiles and i'm 
> happy to PM you the code if you'd like.
> 2. I have very limited programming experience at this point and my project 
> is the cumulation of experimentation, examples and documentation i've 
> read... I believe your saying I don't need to use the "instance"s?
> 3. Good point, thank you.
> 4. I've added the lines which try to ensure the m2m relationships are 
> added, such as  
> new_item.category.add(new_item)
> new_item.components.add(new_item)
> during my attempts to get the form to save the many to many data.
>
> What i'm trying to do is create a basic form which allows a user to fill 
> in the name, desc, img, category and component fields
> When they save this form, i'd like the "item" to be saved (which is 
> happening) as well as the user, category and component data to be 
> associated to the item.
> Currently only the user is being associated to the item when I complete 
> the form and save it.
>
> Once I can do that, i'll move on to using widgets to make the category 
> field a drop down and the component field/s tick boxes and continue adding 
> form validation etc but i've been stuck on this saving issue for some time.
>
> Thanks again for your time and help. 
>
>
>
> On Monday, 7 April 2014 10:58:21 UTC+12, Camilo Torres wrote:
>>
>> On Saturday, April 5, 2014 10:12:36 PM UTC-4:30, Jason S wrote:
>>>
>>> I've seen quite a few examples showing various ways to create a form 
>>> using manytomany relationships and save the data, but i'm still missing a 
>>> key piece of the puzzle.
>>> I've created a form and it "works", meaning the form creates a new Item 
>>> object and associates the user.
>>> However i'm not sure how to go about saving the item category and item 
>>> components selected in the form.
>>>
>>> I've tried quite a few things over the last week and i know its quite 
>>> easy, but just haven't quite gotten there yet and would appreciate some 
>>> guidance.
>>>
>>> FORM:
>>> class NewItemForm(ModelForm):
>>>
>>> class Meta:
>>> model = Item
>>> fields = ('name', 'desc', 'img','category','components')
>>>
>>> def save(self, user, component commit = True):
>>> """Append the component list to the item"""
>>> new_item = super(NewItemForm, self).save(commit = Fals
>>>
>>> if commit:
>>> new_item.save()
>>> #new_item.save_m2m()
>>> new_item.user.add(user)
>>> if component != "none":
>>> new_item.category.add(new_item)
>>> new_item.components.add(new_item)
>>>
>>> return new_item
>>>
>>> VIEW:
>>> def create_item(request):
>>>
>>> if request.method == "POST":
>>> form = NewItemForm(request.POST, instance=item())
>>> if form.is_valid():
>>> form.save(request.user, "none")
>>> return Ht

Re: Saving forms with ManyToMany relationships

2014-04-09 Thread Camilo Torres
Hello,

update your models.py:

class Course(models.Model):
name = models.TextField()
students = models.ManyToManyField(Student, related_name='courses')
*users = models.ManyToManyField(User)*


Update your views.py:

def create_item(request):
if request.method == 'POST':
form = NewItemForm(request.POST)
if form.is_valid():
*item = form.save()*
*item.users.add(request.user)*
return HttpResponse('saved')
return HttpResponse('Form not valid')
else:
form = NewItemForm()
return render_to_response('testapp/create_item.html', {'form': 
form}, context_instance=RequestContext(request))

Note that ModelForm.save() returns the saved model instance, so you can 
associate the user.

Regards,
Camilo.

On Tuesday, April 8, 2014 5:47:46 AM UTC-4:30, Jason S wrote:
>
> Hi,
> Thanks very much, I can now save the item.component and item.category many 
> to many fields.
> However I can't save the user as request.user and it still boils down to 
> not quite understanding how to specify a field value to be saved.
>
> I've tried variations of my original code and suggestions online including 
> setting the field using cleaned_data, without success.
> If you could please let me know how to do that then I should be fine form 
> there.
>
> Thanks again,
> J
>
> On Tuesday, 8 April 2014 14:40:13 UTC+12, Camilo Torres wrote:
>>
>> Hello,
>>
>> This works for me, saving the related objects in the many to many 
>> relationship. You can start from there to build yours:
>>
>> models.py:
>>
>> class Student(models.Model):
>> name = models.TextField()
>>
>>
>> class Course(models.Model):
>> name = models.TextField()
>> students = models.ManyToManyField(Student, related_name='courses')
>>
>> forms.py.
>>
>> class NewItemForm(ModelForm):
>> 
>> class Meta:
>> model = Course
>> fields = ('name', 'students')
>>
>> view.py:
>>
>> def create_item(request):
>> if request.method == 'POST':
>> form = NewItemForm(request.POST)
>> if form.is_valid():
>> form.save()
>> return HttpResponse('saved')
>> return HttpResponse('Form not valid')
>> else:
>> form = NewItemForm()
>> return render_to_response('testapp/create_item.html', {'form': 
>> form}, context_instance=RequestContext(request))
>>
>>
>> create_item.html:
>>
>> {% csrf_token %}
>> {{ form.as_p }}
>> 
>> 
>>
>>
>>
>> Regards,
>> Camilo
>>
>> On Monday, April 7, 2014 7:51:30 PM UTC-4:30, Jason S wrote:
>>>
>>> Hi Camilo,
>>> I really appreciate your response.
>>> I had another go at this last night, particularly trying to use the 
>>> add(component()) snippet.
>>>
>>> To respond to your notes:
>>> 1. I simplified and used a find-replace to replace the model names which 
>>> is likely why it dosn't compile, sorry about that. Mine compiles and i'm 
>>> happy to PM you the code if you'd like.
>>> 2. I have very limited programming experience at this point and my 
>>> project is the cumulation of experimentation, examples and documentation 
>>> i've read... I believe your saying I don't need to use the "instance"s?
>>> 3. Good point, thank you.
>>> 4. I've added the lines which try to ensure the m2m relationships are 
>>> added, such as  
>>> new_item.category.add(new_item)
>>> new_item.components.add(new_item)
>>> during my attempts to get the form to save the many to many data.
>>>
>>> What i'm trying to do is create a basic form which allows a user to fill 
>>> in the name, desc, img, category and component fields
>>> When they save this form, i'd like the "item" to be saved (which is 
>>> happening) as well as the user, category and component data to be 
>>> associated to the item.
>>> Currently only the user is being associated to the item when I complete 
>>> the form and save it.
>>>
>>> Once I can do that, i'll move on to using widgets to make the category 
>>> field a drop down and the component field/s tick boxes and continue adding 
>>> form validation etc but i've been stuck on this saving issue for some time.
>>>
>>>

Re: Question on a resembling function on truncatewords

2014-04-12 Thread Camilo Torres
On Saturday, April 12, 2014 1:10:34 AM UTC-4:30, Kimitaka wrote:
>
> I wrote the function in my Product class in my models.py:
> class Product(models.Model):
> title = models.CharField(max_length=220)
> description = models.CharField(max_length=3000, null=True, blank=True)
> price = models.DecimalField(max_digits=1000, decimal_places=2, null=True, 
> blank=True)
> slug = models.SlugField()
> timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
> updated = models.DateTimeField(auto_now_add=True, auto_now=False)
> active = models.BooleanField(default=True)
>
> def __unicode__(self):
> return self.title
> class Meta:
> ordering = ['title',]
>
> *def shorten_words(self):*
> * if len(self.description) > 20:*
> * print self.desciption[0:20]*
> * else:*
> * print self.desciption*
>
>
> and I added a code in my products.html page:
> {{ product.description*.shorten_words()* }}
>
Hello,

Should it be?:
{{ product.shorten_words }} 

Regards,
Camilo

-- 
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/070e50c3-73bb-4f99-a425-8ed2125fc005%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Help with testing of custom Django admin actions

2016-04-23 Thread Camilo Torres
On Thursday, April 21, 2016 at 9:16:25 AM UTC-4:30, Derek wrote:
>
> Hi
>
> I am looking for help with writing tests for custom Django admin actions; 
> both with and without intermediate pages (ones containing forms).
>
> I confess (hangs head in shame) that I have written lots of actions, but 
> not added any tests for these to my test suite.  It would be great if there 
> were official docs for how to write tests (are there?) but, failing that, a 
> link to some kind of "definitive" tutorial would be great.  Googling seems 
> to produce lots of StackOverflow Q&A or snippets from personal blogs, but 
> no fully worked / comprehensive examples.
>
> Any help or Useful Pointers appreciated.
>
> Thanks
> Derek
>

Hi,
* https://docs.djangoproject.com/en/1.9/intro/tutorial05/
* https://docs.djangoproject.com/en/1.9/topics/testing/ 

-- 
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/962972c3-61d4-44da-80cc-8825e0834d06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: remove ./ from commands

2016-04-23 Thread Camilo Torres
On Thursday, April 21, 2016 at 6:55:53 AM UTC-4:30, 
ken@catapultconsulting.net wrote:
>
> I just installed django 1.9.5.  Now I have to type ./manage.py when I used 
> to just type manage.py.  How do I get rid of the need to type ./ 
> osx el capitan
>

Hi,
export PAHT=$PATH:.
then run your command. 

-- 
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/cd5705c4-6121-4479-8d0b-2ce61350c644%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Authentication for mobile apps

2016-04-23 Thread Camilo Torres
On Friday, April 22, 2016 at 8:41:07 AM UTC-4:30, Deep Shah wrote:
>
> I am new to Django. I want to know how does authentication work for mobile 
> apps. How do I keep the user logged in? Is there any in-built way in Django 
> to manage tokens or something similar for mobile apps?
>

Hi,
1. If you are talking about 'native' mobile apps, like Android apps or iOS 
apps, these apps have nothing to do with django. These apps have their own 
authentication systems you should investigate for each platform.
1. If you are talkin about 'mobile web apps', these are apps running in a 
webserver and accessed through a web browser. Being run in a web server 
means you can use django and you can use the same authentication mechanism 
used for desktop web apps. There is no difference.

-- 
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/c7f9e1d9-a12f-41ef-a325-97c83ca68eb0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Question about admin.StackedInline

2016-04-23 Thread Camilo Torres


On Friday, April 22, 2016 at 12:37:40 PM UTC-4:30, Said Akhmedbayev wrote:
>
> Thank you in advance!
>
> I am new to Django, trying to build a small app for my friend. The app 
> mock-up is here  
>
> Basically, the app will include Units/Lessons with Subsection, each 
> Subsection will end with several questions.
>
> Here my models.py
>
> from django.db import models
>
>
> # Create your models here.
> class Unit(models.Model):
> title = models.CharField(max_length=150, blank=True, null=True)
> unit_number = models.PositiveIntegerField(blank=True, null=True, 
> default=1)
>
> def __str__(self):
> return self.title
>
>
>
> class SubSection(models.Model):
> subsection_text = models.TextField(default='SUBSECTION TEXT')
> question = models.ForeignKey(Unit, 
> related_name='subsection_to_question')
>
>
> class Question(models.Model):
> question_text = models.CharField(max_length=2000, default='QUESTION 
> TEXT')
> subsection = models.ForeignKey(SubSection, 
> related_name='question_to_subsection',)
>
> And here is my admin.py
>
> from django.contrib import admin
> from .models import Unit, SubSection
>
>
> # Register your models here.
> class SubSectionInline(admin.StackedInline):
> model = SubSection
>
>
> @admin.register(Unit)
> class UnitAdmin(admin.ModelAdmin):
> inlines = [
> SubSectionInline,
> ]
>
> Here is what I see in the admin 
>
>
> 
> It is all nice, but it is not exactly what I want :-). Here is what I want 
> to see, it is photoshop mock-up
>
>
> 
>
> My questions are:
>
> Is this even possible to do with the approach I took?
>
> If it is possible, can you please help me to figure out how to make it?
>

Hi,
You should take a look at the django-nested-admin project: 
https://pypi.python.org/pypi/django-nested-admin/3.0.0
 

-- 
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/b00157dd-9ade-4f6d-a462-c433ba1f8ad3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Help with defining Models for ManyToMany and OneToMany relationships...

2016-04-23 Thread Camilo Torres
On Saturday, April 23, 2016 at 10:00:45 AM UTC-4:30, Bruce Whealton wrote:
>
> Hello all,
>   So, I setup django in a virtualenv on my Ubuntu environment.  I 
> was reading the docs and thought I had things right 
> for creating the 3 models I wanted with this application. I am using 
> Postgresql.  I have the Postgresql driver for Python/Django installed
> in the virtualenv.  It is a "Contacts" app.  
> First question: Do django model fields default to required unless you use 
> blank=True, null=True?
> Many of my fields, I want to have optional.
>
> I have a class called Contact, a class called Organization and a class 
> called Connection.  
> I wanted to use the Organization as a foreign key on the Contact model.  I 
> could have more than one contact from
> an Organization.  The Connection model is inspired by the Google Plus idea 
> of "Circles" - e.g. friends,
> family, following, etc.   So, this would be a many-to-many relationship.  
>
> My problems are (1) I cannot create connections without specifying a 
> contact.  
> (2) If I was adding a contact using the admin interface, how do I allow no 
> value for that foreign field
> or allow for some kind of ajax type of text completion?  If a person is 
> family or friend, I may not need
> to list an Organization for them.
> (3) I would like to support multiple connection types - e.g. following, 
> employer, etc.
>
> So, here is my apps models.py file:
> 
>
> from django.db import models
>
>
> class Contact(models.Model):
> name = models.CharField(max_length=40)
> Organization = models.CharField(max_length=50)
> street_line1 = models.CharField("Street Line 1", max_length=50)
> street_line2 = models.CharField("Street Line 2", max_length=50)
> city = models.CharField(max_length=40)
> state = models.CharField(max_length=40)
> zipcode = models.CharField(max_length=20, blank=True, null=True)
> phone1 = models.CharField(max_length=20)
> phone2 = models.CharField(max_length=20)
> email = models.EmailField(max_length=60)
>
>
> class Organization(models.Model):
> name = models.CharField(max_length=60)
> street_line1 = models.CharField("Street Line 1", max_length=50)
> street_line2 = models.CharField("Street Line 2", max_length=50)
> city = models.CharField(max_length=40)
> state = models.CharField(max_length=40)
> zipcode = models.CharField(max_length=20, blank=True, null=True,)
> phone = models.CharField(max_length=20)
> email = models.EmailField(max_length=60)
> website = models.URLField(max_length=90)
> contact_name = models.ForeignKey(Contact, on_delete=models.CASCADE)
>
>
> class Connection(models.Model):
> type = models.CharField(max_length=60)
> contact_name = models.ManyToManyField(Contact)   
>
> >>>
> Thanks in advance for any suggestions,
> Bruce 
>

Hi,
1.  Do django model fields default to required unless you use blank=True, 
null=True?
This may help you understand 
that: 
http://stackoverflow.com/questions/8609192/differentiate-null-true-blank-true-in-django

2. I think you need a foreign key on Contact to Organization:

class Contact(models.Model):
name = 

organization = models.ForeignKey('Organization', null=True, blank=True)

That way you can have many contacts to a single organization. The 
contact_name in Organizations allows only 1 Contact, but you said you need 
many.

3. I cannot create connections without specifying a contact.
I don't see why not. Do you get any error?

4. If I was adding a contact using the admin interface, how do I allow no 
value for that foreign field
By setting null=True, blank=True for the ForeignKey field. Notice Contact 
do not have any ForeignKey in your example.

5. or allow for some kind of ajax type of text completion?
I have used this in the 
past: https://django-autocomplete-light.readthedocs.org/en/master/

6.  I would like to support multiple connection types - e.g. following, 
employer, etc.
You already have a 'type' field in Connections model. First I suggest to 
use a different name for the field: type is a reserved Python word.
Second, you can add choices to the field.

from django.utils.translation import ugettext as _
...
class Connection(models.Model):
CHOICES = (('follower', _('Follower')),
   ('employer', _('Employer')),
   ('unspecified', _('Unspecified')),
  )
connection_type = models.CharField(max_length=20, choices=CHOICES)
contact_name = models.ManyToManyField(Contact)  



-- 
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/6918823e-

Re: [django1.9] Url template tag, dotted path and decorator

2016-04-23 Thread Camilo Torres
On Saturday, April 23, 2016 at 1:17:26 PM UTC-4:30, François Magimel wrote:
>
> Hi! 
>
> I'm facing an issue reversing a dotted path with django 1.9.4. Here are 
> more details. 
>
> I pass a dotted path to the django template tag "url": 
> "{% url 'my.app.view.func' arg %}" 
> And the function "my.app.view.func" has a decorator which is using "arg". 
> My problem is : when displaying my template, I get a NoReverseMatch error. 
> But I don't have any error: 
>   - when I use the name of the url (defined in my urls.py file) or 
>   - when I use the dotted path and remove my (simple) decorator. 
>
> I know that passing a dotted path to url is deprecated since django 1.8 
> [0][1], but not removed yet. So, I think there is something wrong with 
> dotted path and decorators, but I can't find what… 
>
> PS: my decorator only redirects to another view… 
>
> Thanks, 
> François 
>
>
> [0] 
> https://docs.djangoproject.com/en/1.8/releases/1.8/#passing-a-dotted-path-to-reverse-and-url
>  
> [1] https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#url 
>

Hi,
May be you can use functools.wraps from Python standard library.

-- 
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/31e70c60-a119-4bba-a903-6af4affd5bbe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


CSRF_COOKIE_SECURE and SESSION_COOKIE_SECURE to True when terminating SSL on load balancer

2016-09-07 Thread Camilo Torres
Hi.

As you are currently using HTTPS, setting these to true make sense.

These settings are used by the browser to ensure encripted cookies. It does not 
matter if you are using haproxy with ssl termination.

Camilo Torres.

-- 
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/265e1900-da24-435a-a64a-77bc1dca0410%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django queryset High CPU Usage

2017-03-11 Thread Camilo Torres
Hi.

You can probably use another web framework for that report, or even rethink 
your architecture and put the report creation outside Django and the web server 
without Django ORM.

You may be interested in evaluating Celery and Django Celery. You can create a 
separate task outside Django to create such report, call the task from within 
Django with Celery, create the report and email to the user.

Regards.

-- 
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/3828e090-9f99-4a34-a6eb-aef2a9386e8e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Simple Join with no matching primary keys

2017-03-11 Thread Camilo Torres
You can also create a database view from the join of the two tables.

-- 
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/58dca968-5611-40fc-aec0-bce131298e19%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error running Django tutorial

2017-03-16 Thread Camilo Torres
Hi.

You may have a strange, non-visible character in your file just before the line 
giving error.

-- 
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/f9e098eb-2362-4cc1-bc41-0b5a03f64172%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


new bee - starting to build web application based on python - Django - PostgreSQL (or) MYSQL

2017-03-16 Thread Camilo Torres
I recommend you the django tutorial:

https://docs.djangoproject.com/en/1.10/intro/

-- 
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/95ec951f-54ae-4424-87e9-278f40dba9b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


drop down multi checkbox with bootstraps selet

2017-03-18 Thread Camilo Torres
Hi,

You have to properly construct the  element.

Take a look at these sections of the manual:

https://docs.djangoproject.com/en/1.10/topics/forms/#rendering-fields-manually

https://docs.djangoproject.com/en/1.10/topics/forms/#looping-over-the-form-s-fields

Take a special look at field html_name; you should be using that as the name of 
your select element. The name is used to map the posted data to the form in the 
code.

Camilo.

-- 
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/c4cd95be-65c9-4435-b6bf-c90bde523079%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


migrations error

2017-03-20 Thread Camilo Torres
Hi,

Do you have the virtual environment active when you run the migrate command?

-- 
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/45c81c1e-4127-42e7-8b2f-9e5e38cc7f68%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django admin custom filter: ProgrammingError: more than one row returned by a subquery used as an expression

2017-03-22 Thread Camilo Torres
Hi,

The problem with your approach is the SQL will actually be something like 
this:

select ,
(select id from web_quote WHERE character_length(quote_text) < 30) as val
from ;

That will fail in RDMS like Postgres if there are more than one 
"quote_text" with length < 30.

May be you want is something like this:
select 
from 
where character_length(quote_text) < 30

If that is the case, then you probably will need something like:

return queryset.extra(where=['character_length(quote_text) < 30'])

or even better:
from django.db.models.functions import Length
return 
quryset.annotate(quote_len=Length('quote_text')).filter(quote_len__lt=30)

Notice extra() is deprecated.

On Wednesday, March 22, 2017 at 12:25:02 AM UTC-4, kholidfu wrote:
>
> Hi, I'm trying this custom filter query for django admin
>
> return queryset.extra(select = {'val': "select id from web_quote WHERE 
> character_length(quote_text) < 30"})
>
>
> and I got something like this:
>
> Programming error: more than one row returned by a subquery used as an 
> expression
>
> Basically I'm trying to filter quote_text column which length of the 
> string less than 30...
>
> Any ideas?
>

-- 
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/5f69d75e-f70e-473c-828a-5a66b3baaf75%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Captcha or MathCaptcha application

2017-03-23 Thread Camilo Torres
May be you are missing a data base migration?

-- 
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/d764a469-2dd8-44c7-8cae-32b586c20147%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


inspectDB and 'id' can only be used as a field name if the field also sets 'primary_key=True'.

2017-03-23 Thread Camilo Torres
Hi.

You should rename the "id" field in your model to something else. You can edit 
your models.py and put another name, like "dbid" or something.

Django models reserve the "id" field for primary key; your table has another 
field as primary key.

-- 
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/588c12ad-a29e-477d-bfcb-985c61fb658c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


unable to create a new project in django got error. Fatal error in launcher: Unable to create process using '"'

2017-03-27 Thread Camilo Torres
I think this have nothing to do with django.
I suspect this is a bad python installation or bad django installation.

I have no experience with installing python nor django on Windows 10, even 
though I can suggest you uninstall and clean both from your system, then do a 
fresh reinstall of python and django.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/90fc82a5-9e0e-4f3d-80fe-22b24be8ff20%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


unable to create a new project in django got error. Fatal error in launcher: Unable to create process using '"'

2017-03-27 Thread Camilo Torres
I think this have nothing to do with django.
I suspect this is a bad python installation or bad django installation.

I have no experience with installing python nor django on Windows 10, even 
though I can suggest you uninstall and clean both from your system, then do a 
fresh reinstall of python and django.

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


Ajax Call is sending empty request.POST or request.body

2017-03-31 Thread Camilo Torres
Hi.

The difference is explained here:
https://docs.djangoproject.com/en/1.10/ref/request-response/

You are sending the data in the ajax call as Jason (I suppose, from the content 
type), then in your view you should probably use request.body to read the json 
document.

I also noticed you are using a django form. In that case you can change your 
ajax call to send a form encoding content type and serialize the html form as 
the data. In your view you can then use your django form to process the data 
from request.POST.

-- 
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/d30946f0-6403-4549-91e9-43536c129df1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Filter list dict in JsonField Postgres

2017-04-06 Thread Camilo Torres
Hi,
What is JSONField? Is it part of Django or from a third party package?

On Monday, April 3, 2017 at 10:34:18 AM UTC-4, Martin Peveri wrote:
>
> Hi, I have this model:
>
> class ItemCampaign(models.Model):
>
>campaign = models.ForeignKey(
>Campaign, related_name="itemscampaign", verbose_name="Item campaña"
>)
>data = JSONField(default=dict)
>
>def __str__(self):
>return self.campaign.name 
>
> With a record with this data: 
>
> [{'number': '1160188479', 'id': 0, 'content': 'hello', 'processed': True},
>  {'number': '1160188479', 'id': 1, 'content': 'hello', 'processed': False
> }, {'number': '1160188479', 'id': 2,'content': 'hello', 'processed': False
> }, {'number': '1162341721', 'id': 3, 'content': 'hello', 'processed': 
> False}, {'number': '1162341721', 'id': 4, 'content': 'hello', 'processed':
> False}, {'number': '1162341721', 'id': 5, 'content': 'hello', 'processed':
>  False}]
>
> I want filter this list dict, like this:
>
> c.itemscampaign.filter(data__processed=True)
>
> But not work. That does not give me back anything.
>
> The content type of data is:
>
> >>> type(c.itemscampaign.all()[0].data)
> 
>
> I understand that it has to be a dict, but how can I insert many 
> dictionaries in the field, as I have in my data if it is not in a list?
>
> 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/19039bdc-6c9d-405f-95a7-34c78cf6a715%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Filter list dict in JsonField Postgres

2017-04-08 Thread Camilo Torres
Hi.
I have been thinking more about this.
I think you cannot filter the list in the query with the JSONField from 
django. At most, you can get the object and filter the field in the 
resulting list.

Example with this simple model:
from django.db import models
from django.contrib.postgres.fields import JSONField
class DataModel(models.Model):
data_field = JSONField(default=dict)

You can do:
DataModel.objects.create(data_field=[{'number': '1160188479', 'id': 0, 
'content': 'hello', 'processed': True}, {'number': '1160188479', 'id': 1, 
'content': 'hello', 'processed': False}, {'number': '1160188479', 'id': 2 
,'content': 'hello', 'processed': False}, {'number': '1162341721', 'id': 3, 
'content': 'hello', 'processed': False}, {'number': '1162341721', 'id': 4, 
'content': 'hello', 'processed':False}, {'number': '1162341721', 'id': 5, 
'con tent': 'hello', 'processed': False}])
Then you can query the database to get that record:
o = DataModel.objects.get()
processed = [x for x in o.data_field if x['processed']]
Variable 'processed' will have the processed data.


If you want to query your models by having the 'processed' field to true, I 
found you can do it if you change the way you save your data, one option 
may be:
DataModel.objects.create(data_field={'*processed*': [{'number': 
'1160188479', 'id': 0, 'content': 'hello', 'processed': True}], '
*not_processed'*: [{'number': '1160188479', 'id': 1, 'content': 'hello', 
'processed': False}, {'number': '1160188479', 'id': 2 ,'content': 'hello', 
'processed': False}, {'number': '1162341721', 'id': 3, 'content': 'hello', 
'processed': False}, {'number': '1162341721', 'id': 4, 'content': 'hello', 
'processed':False}, {'number': '1162341721', 'id': 5, 'con tent': 'hello', 
'processed': False}]})
Notice I saved the data separeting the processed and the not_processed. The 
you can query objects with any of these keys:
queryset = DataModel.objects.filter(data_field__has_key='processed')
Then you can iterate over the queryset and the the data from every dict.

Anyway, to do advanced queries over that data you may be forced to save it 
in a different way. You can even save the "processed" and "not processed" 
data in different list in different JSONFields on the same model, and query 
like this:
queryset = DataModel.objects.filter(processed__isnull=False)


On Monday, April 3, 2017 at 10:34:18 AM UTC-4, Martin Peveri wrote:
>
> Hi, I have this model:
>
> class ItemCampaign(models.Model):
>
>campaign = models.ForeignKey(
>Campaign, related_name="itemscampaign", verbose_name="Item campaña"
>)
>data = JSONField(default=dict)
>
>def __str__(self):
>return self.campaign.name 
>
> With a record with this data: 
>
> [{'number': '1160188479', 'id': 0, 'content': 'hello', 'processed': True},
>  {'number': '1160188479', 'id': 1, 'content': 'hello', 'processed': False
> }, {'number': '1160188479', 'id': 2,'content': 'hello', 'processed': False
> }, {'number': '1162341721', 'id': 3, 'content': 'hello', 'processed': 
> False}, {'number': '1162341721', 'id': 4, 'content': 'hello', 'processed':
> False}, {'number': '1162341721', 'id': 5, 'content': 'hello', 'processed':
>  False}]
>
> I want filter this list dict, like this:
>
> c.itemscampaign.filter(data__processed=True)
>
> But not work. That does not give me back anything.
>
> The content type of data is:
>
> >>> type(c.itemscampaign.all()[0].data)
> 
>
> I understand that it has to be a dict, but how can I insert many 
> dictionaries in the field, as I have in my data if it is not in a list?
>
> 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/4d4c0b43-d357-4dca-9677-73d93896bf7b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Binding data to one o many forms from one view - BadHeaderError at - Header values can't contain newlines ()

2017-04-08 Thread Camilo Torres
Hi,

Inside your "post" method, you have this line:
context = super(AccountProfilesView, self).post(request, *args, **kwargs)
in that case "context" is a HttpResponse object[0]. May be, from the name 
you use for the variable, you think this is a simple dict as those used to 
pass context to render functions; it is not.
You can use HttpResponse as a dictionary to put HTTP headers in the 
response [1], so line 184 is setting an HTTP header with a value of the 
HTML to render the form; that is not what you want.
You have to remove that line and create your context with something like:
context = {}
And you have to return an HttpResponse object, probably by calling one of 
the render functions [2].


[0] 
https://docs.djangoproject.com/en/1.11/ref/request-response/#httpresponse-objects
[1] 
https://docs.djangoproject.com/en/1.11/ref/request-response/#setting-header-fields
[2] https://docs.djangoproject.com/en/1.11/topics/http/shortcuts/#render

On Saturday, April 8, 2017 at 5:06:34 PM UTC-4, Bernardo Garcia wrote:
>
>
> I have the following forms to each user profile
>
> class UserUpdateForm(forms.ModelForm):
> class Meta:
> widgets = {'gender':forms.RadioSelect,}
> fields = ("username", "email", "is_student",   
> "is_professor", "is_executive",)
> model = get_user_model() #My model User
> 
> class StudentProfileForm(forms.ModelForm):
> class Meta:
> model = StudentProfile
> fields = ('origin_education_school',current_education_school',
> 'extra_occupation')
> 
> class ProfessorProfileForm(forms.ModelForm):
> class Meta:
> model = ProfessorProfile
> fields = ('occupation',)
> 
> class ExecutiveProfileForm(forms.ModelForm):
> class Meta:
> model = ExecutiveProfile
> fields = ('occupation', 'enterprise_name', 
> 'culturals_arthistic','ecological')
>
> I have an URL which call to my AccountProfilesView class based view which 
> create an instance of the previous forms according to the user profile:
>
> url(r"^profile/(?P[\w\-]+)/$",
> views.AccountProfilesView.as_view(),
> name='profile'
> ),
>
>
> My AccountProfilesView  is this:
>
> I this moment, from the AccountProfilesView class based view I am create 
> the different instances of each one of these forms, according to the 
> user profile, then, if an user have the is_student profile their related 
> form will be generated, and so, of this way to is_professor  and 
> is_executive profiles
>
> If an user have the three profiles (is_student, is_professor,is_executive ) 
> in one single form will be created or rendered the fields of the three 
> forms associated to each user profile related.
>
> class AccountProfilesView(LoginRequiredMixin, UpdateView):
> # All users can access this view
> model = get_user_model()
> #success_url = reverse_lazy('dashboard')
> template_name = 'accounts/profile_form.html'
> fields = '__all__'
> 
> def get_context_data(self, **kwargs):
> context = super(AccountProfilesView, 
> self).get_context_data(**kwargs)
> user = self.request.user
> 
> if not self.request.POST:
> if user.is_student:
> profile = user.get_student_profile()
> context['userprofile'] = profile
> context['form_student'] = forms.StudentProfileForm()
> if user.is_professor:
> profile = user.get_professor_profile()
> context['userprofile'] = profile
> context['form_professor'] = 
> forms.ProfessorProfileForm()
> print ("profesor form is", context['form_professor'])
> if user.is_executive:
> profile = user.get_executive_profile()
> context['userprofile'] = profile
> context['form_executive'] = 
> forms.ExecutiveProfileForm()
> return context
> 
> def post(self, request, *args, **kwargs):
> self.object = self.get_object()
> context = super(AccountProfilesView, self).post(request, 
> *args, **kwargs)
> user = self.request.user
> # if self.request.method == 'POST':
> if user.is_student:
> context['form_student'] = forms.StudentProfileForm(
> self.request.POST)
> elif user.is_professor:
> context['form_professor'] = forms.ProfessorProfileForm(
> self.request.POST)
> elif user.is_executive:
> context['form_executive'] = forms.ExecutiveProfileForm(
> self.request.POST)
> return context
> 
> def form_valid(self, form):
> context = self.get_context_data(form=form)
>

Re: Django Music streaming

2017-04-08 Thread Camilo Torres
Hi, you forgot to include the error you get and probably other relevant 
information.
You may be interested in reading these articles:

https://developer.jboss.org/wiki/HowToAskAForumQuestion?_sscc=t

https://www.biostars.org/p/75548/

On Saturday, April 8, 2017 at 12:38:57 PM UTC-4, IaMtheMcee wrote:
>
> setting up audiotracks in a new project.. im forced to use the example 
>> project, whose structure i don't fully understand.. 
>
>
> the documentation says..
>
> Add ``audiotracks`` to your app
> ~~~
>
> Edit ``settings.py`` and add ``audiotracks`` to your list of
> ``INSTALLED_APPS``. Then synchronize your database with::
>
> $ python manage.py syncdb
>
> Edit your ROOT_URLCONF_ and add a piece of code similar to::
>
> urlpatterns += patterns('',
> # Here we mount the app under /music. Feel free to use something 
> else
> url("^music", include("audiotracks.urls")),
> # Some URLs require a Django username
> url("^(?P[\w\._-]+)/music", include("audiotracks.urls")),
> )
>
> Visit the URL ``/music/upload`` to upload your first track.
>
>
> but i get an error everytime i try 
>

-- 
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/8da5ca14-3735-4247-8298-006fcff46bc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How i can hide statements {% IF hide %} on html template ... also {{ model.name }}

2017-04-09 Thread Camilo Torres
Can you show an example of one of these templates and the corresponding 
view?

On Sunday, April 9, 2017 at 1:41:27 PM UTC-4, ZS ELECTRONICA wrote:
>
> Hello 
>
>
> I have a problem, i have a page with backbone + jquery+bootstrap+css, with 
> templates  but , i don't now why when i see the "source of page" i can see 
> the statments  
>
> {%  IF some %} ... .also  {{ tag.title }}   , i need hide this , in other 
> pages i cant see this. 
>
> please help me
>

-- 
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/137009a0-152d-45cb-8851-cf64361d520e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


what do i have to do first

2017-04-10 Thread Camilo Torres
Hi,

Read the First Steps section:

https://docs.djangoproject.com/en/1.11/

-- 
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/e9791e60-8340-47a3-9bc0-78f58912c8d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Yet Another Can't get static files to show up in shared linux website on Godaddy

2017-04-10 Thread Camilo Torres
Hi
You may want to review:
https://docs.djangoproject.com/en/1.11/howto/static-files/deployment/

You may also want to make sure your server supports wsgi deployments:
https://docs.djangoproject.com/en/1.11/howto/deployment/

-- 
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/9119cbe3-bac0-4408-8a50-784b0ef8ded0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


using HTTPHandler cause Django server side shows http 400 and Invalid HTTP_HOST header message

2017-04-10 Thread Camilo Torres
Hi,
Try with this configuration instead:
_TARGET = 'http://192.168.8.100:8000'

Notice you missed http:// there.

-- 
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/8a6fcb79-dbf6-44f1-9971-7da02af85f27%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Inheritance models from Django 1.8.2 to Django 1.11

2017-04-10 Thread Camilo Torres
Hi,
May be you can define your field usind "db_column":

manufact = models.ForeignKey(Manufacture, verbose_name=u'Manufacture', 
db_column='manufacture')

https://docs.djangoproject.com/en/1.11/ref/models/fields/#db-column

-- 
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/935b1fb4-5ee8-40d0-994c-fba20631dc88%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: New to django and ORM. So a basic question about data inserts

2017-04-11 Thread Camilo Torres
Hi,
Lets suppose we simplify your problem and we have these 2 django models:
from django.db import models


class Person(models.Model):
name = models.CharField(max_length=255, null=False, blank=False)

def __str__(self):
return self.name


class Residence(models.Model):
address = models.CharField(max_length=255, null=False, blank=False)
person = models.ForeignKey('Person', null=False, blank=False)

def __str__(self):
return '%s: %s' % (self.person.name, self.address)

Notice I simplified the data so save in each model.

This is how you create data for these models. I ran these command in the 
django shell (python manage.py shell):
In [1]: from residence.models import Person, Residence
In [3]: p = Person.objects.create(name='Abu UIfreoledo')
In [4]: p
Out[4]: 
In [6]: r1 = Residence.objects.create(address='yyy', person=p)
In [7]: r2 = Residence.objects.create(address='', person=p)

This is another way of creating and saving models:
In [8]: other_person = Person()
In [9]: other_person.name = 'Jekolaw Yhjosw'
In [10]: other_person.save()
In [11]: res1 = Residence()
In [12]: res1.address = 'keikdioekekdiekecnchdhwe'
In [13]: res1.person = other_person
In [14]: res1.save()

Notice this generates these 2 tables in Postgres:
temp2=# \d residence_person
 Table "public.residence_person"
 Column |  Type  |   
Modifiers   
++---
 id | integer| not null default 
nextval('residence_person_id_seq'::regclass)
 name   | character varying(255) | not null
Indexes:
"residence_person_pkey" PRIMARY KEY, btree (id)
Referenced by:
TABLE "residence_residence" CONSTRAINT 
"residence_residence_person_id_d4f422a8_fk_residence_person_id" FOREIGN KEY 
(person_id) REFERENCES residence_person(id) DEFERRABLE INITIALLY DEFERRED

temp2=# \d residence_residence
  Table "public.residence_residence"
  Column   |  Type  |
Modifiers 
---++--
 id| integer| not null default 
nextval('residence_residence_id_seq'::regclass)
 address   | character varying(255) | not null
 person_id | integer| not null
Indexes:
"residence_residence_pkey" PRIMARY KEY, btree (id)
"residence_residence_person_id_d4f422a8" btree (person_id)
Foreign-key constraints:
"residence_residence_person_id_d4f422a8_fk_residence_person_id" FOREIGN 
KEY (person_id) REFERENCES residence_person(id) DEFERRABLE INITIALLY 
DEFERRED

In this example the Residence instances are not reused or shared across 
Persons.


Now suppose one want to reuse the residences, meaning we will use 3 tables 
instead of 2, One for Persona, as before, one for Residence (without the 
foreign key to the Person) and a third relation to relate both and hold the 
dates.

from django.db import models


class Person(models.Model):
name = models.CharField(max_length=255, null=False, blank=False)
residences = models.ManyToManyField('Residence', 
through='ResidenceDates')

def __str__(self):
return self.name


class Residence(models.Model):
address = models.CharField(max_length=255, null=False, blank=False)

def __str__(self):
return self.address


class ResidenceDates(models.Model):
dates = models.CharField(max_length=255, null=False, blank=False)
person = models.ForeignKey('Person', null=False, blank=False)
residence = models.ForeignKey('Residence', null=False, blank=False)

Notice the join table ResidenceDates, it has foreign keys to both Person 
and Residence models. Also notices the many to many field. This generates 
the 3 tables you need (not shown here).

In [3]: p1 = Person.objects.create(name='p1')
In [4]: p2 = Person.objects.create(name='p2')
In [5]: p3 = Person.objects.create(name='p3')
In [6]: res1 = Residence.objects.create(address='a1')
In [7]: res2 = Residence.objects.create(address='a2')
In [8]: res3 = Residence.objects.create(address='a3')
In [9]: res4 = Residence.objects.create(address='a4')
In [10]: res5 = Residence.objects.create(address='a5')
In [11]: ResidenceDates.objects.create(person=p1, residence=res1, 
dates='2003-2005')
Out[11]: 
In [12]: ResidenceDates.objects.create(person=p1, residence=res2, 
dates='2005-2008')
Out[12]: 
In [13]: ResidenceDates.objects.create(person=p1, residence=res4, 
dates='2009-2017')
Out[13]: 
In [15]: ResidenceDates.objects.create(person=p2, residence=res4, 
dates='2000-2001')
Out[15]: 
In [16]: ResidenceDates.objects.create(person=p2, residence=res5, 
dates='2002-2010')
Out[16]: 
In [17]: ResidenceDates.objects.create(person=p2, residence=res4, 
dates='2011-2016')
Out[17]: 

Hope this help.
Please read the django tu

Re: Django relationships and the admin page

2017-04-11 Thread Camilo Torres
Hi,
Seems you need here admin inlines, these allow you to insert/edit related 
objects inline when editing the main object. For example, when editing a 
Site, you will be able to also edit Images and Locations, though it only 
supports 1 level, so with default configuration you may probably not be 
able to also edit LocImages.
Start reading here:
http://localhost/Python/django-docs-1.10-en/ref/contrib/admin/index.html#django.contrib.admin.ModelAdmin.inlines

To support more levels, you can use django-nested-admin package:
https://pypi.python.org/pypi/django-nested-admin

On Monday, April 10, 2017 at 7:48:37 PM UTC-4, Liam H wrote:
>
> Hi,
>
> I'm new to Django, programming, web apps, the whole lot. I've been working 
> on an app for a while now, but I'm having trouble figuring out how to 
> organise my models in an effective way. Im using Django 1.10 and Python 2.7.
>
> Here's a rough example of the structure I'm trying:
>
> class Site(models.Model):
> #...
> def __unicode__(self):
> return self.name
>
> class Image(models.Model):
> #...
> site = models.ForeignKey(Site, ...)
> def __unicode__(self):
> return self.name
>
> class Location(models.Model):
> #...
> site = models.ForeignKey(Site, ...)
> def __unicode__(self):
> return self.name
>
> class LocImage(models.Model):
> #...
> location = models.ForeignKey(Location, ...)
> def __unicode__(self):
> return self.name
>
>
>
> The idea is to have a site (like a castle or other area the user might 
> want to visit), and then each site will have various Images like aerial 
> photographs associated with it. Each site will also have various locations 
> around it with multiple images associated with that location.
>
> So it works something like this:
>
> Site
>
> Images
>
> Location
>
> LocImages 
>
>
>
> I've tried doing it this way, but I don't know how to get the admin page 
> to show this, for one. I read a post that said that Django's admin page 
> can't have nested related items like this, but I'm not sure if that's 
> actually true. I was able to run migrations on this code when I removed the 
> references to it in the admin page, but I don't know how to access the 
> LocImages model in the API, like I can with the Location and Images models 
> using something like 
> "Site.objects.get(pk=2).location_set.get(id=2).locimage_set.all()".
>
> So, is this how I should be structuring the models? And if it works in the 
> database is there any way to get this to show on a single page in the 
> Django admin?
>
> The reason I decided to structure it this way is so each location can have 
> multiple attributes that are all fields of the same model, making it easier 
> to link them together in the templates.
>
> Any help would be appreciated, 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/1a6c9dff-e7e8-41a2-96b5-7f6d08c88f77%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: form wizard

2017-04-11 Thread Camilo Torres
Hi,
What is "form wizard"?
Can you provide a link or an explanation, example?

On Tuesday, April 11, 2017 at 9:29:39 AM UTC-4, Pranay Verma wrote:
>
> Hi
> Is there any way to use form wizard in Django 1.10 ao above
>

-- 
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/3b2a1e3e-d7b0-40df-ba10-99a719d4d55f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: getting error "Project matching query does not exist."

2017-04-11 Thread Camilo Torres
Hi
1) How did you solved the first issue? You should be supposed to solve it 
by adding a row to a database table (the one related to your Project model) 
with id=1.
2) You have not pasted enough information for your ValidationError issue, 
please don't paste screen shots (at least, not only a screen shot). Please 
paste the entire stack trace you get in the terminal running the server. 
You may also consider pasting relevant code you think is related to the 
error, though someone can ask for the code or configuration after looking 
at the entire stack trace.

On Tuesday, April 11, 2017 at 9:52:27 AM UTC-4, ni...@linkites.com wrote:
>
> Hi,
>
> Previous error solve and thanks for that.
>
> now i am getting new error of ValidationError Please see below screen shot.
> Please let me know of what is the problem now.
>
>
> 
>
>
> On Tuesday, April 11, 2017 at 4:38:30 PM UTC+5:30, ni...@linkites.com 
> wrote:
>>
>> Hi,
>>
>> I have setup existing django project at localsystem and its migrate 
>> successfully.
>> after migrate i have run following "python manage.py runserver" to run 
>> django project.
>>
>> After that i am getting error message "Project matching query does not 
>> exist." on terminal and as well as browser.
>>
>> Please let me know of what is problem.
>>
>>
>>
>> Please help me to solve this issue.
>>
>> 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/b4d4b39f-a223-44a5-b1b4-18b63f4ba3bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Permissions in views

2017-04-15 Thread Camilo Torres
Hi,
Confirmed with Django 1.11, Python 3.4.3.
I strongly think this is a case you can report in bug tracker. Please tell 
if you will do.
I have been trying to find some time to test this since I read your message.

On Wednesday, April 12, 2017 at 4:12:30 AM UTC-4, Meiyer wrote:
>
> Just yesterday I bumped into an issue that left me puzzled for a while, 
> and I want to verify if this is indeed the case before opening a bug ticket.
>
> The documentation 
>  
> states the we can use either the {{ perms.my_app.update_obj }} tag  to 
> display the result of a check for a specific permission "update_obj" within 
> the my_app module/app, or the {{ perms.my_app }} tag to display the 
> result of a check if the user has any permissions in the my_app module/app. 
> Yet, when using the second variant, I suddenly had the whole permission set 
> of the user dumped to the page. This is quite obvious when looking at 
> the contrib\auth\context_processors.py code: when doing a {% if "my_app" 
> in perms %} check it will land into the __contains__ method 
> of PermWrapper while for an output such as {{ perms.my_app }}, it will 
> land into the __getitem__ method that returns a PermLookupDict, in turn 
> triggering the __repr__ method when displayed:
>
> def __repr__(self):
> return str(self.user.get_all_permissions()) 
>
> This is clearly in odds with the documentation. So what is the expected 
> result? Should {{ perms.my_app }} display a True or (at least, no more 
> than) the permissions the user has in the my_app module/app?
>

-- 
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/d4673c2a-a10f-4cba-a93a-f3f04eeda053%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: getting error "Project matching query does not exist."

2017-04-15 Thread Camilo Torres
Hi,
I agree with Ludovic in "your application may be badly installed". But it 
is very hard to tell what is going wrong without actually knowing what your 
app should show (what view function) for URL path /brickly/home
I cannot tell you what view is that without knowing about your code nor 
your business rules for that page.
You have to ask the original developers what view should show there, and 
try to writhe the url conf for that.

On Wednesday, April 12, 2017 at 7:02:09 AM UTC-4, ludovic coues wrote:
>
> I would search the function doing the redirection and look at what 
> information it use to make that redirection.
>
> Either it is redirecting to a wrong url or something have gone wrong when 
> installing the brickly application.
>
> 2017-04-12 12:46 GMT+02:00 >:
>
>> Hi,
>>
>> I have solved validationError on django and now project redirecting on 
>> url "http://127.0.0.1:8000/brickly/home"; and its not found. so please 
>> let me know how to create it on django.
>>
>> here are page not found error coming. please let me know of what is the 
>> problem.
>>
>>
>> Page not found (404) 
>> Request Method: GET 
>> Request URL: http://127.0.0.1:8000/brickly/home
>>
>>
>> On Tuesday, April 11, 2017 at 4:38:30 PM UTC+5:30, ni...@linkites.com 
>> wrote:
>>>
>>> Hi,
>>>
>>> I have setup existing django project at localsystem and its migrate 
>>> successfully.
>>> after migrate i have run following "python manage.py runserver" to run 
>>> django project.
>>>
>>> After that i am getting error message "Project matching query does not 
>>> exist." on terminal and as well as browser.
>>>
>>> Please let me know of what is problem.
>>>
>>>
>>>
>>> Please help me to solve this issue.
>>>
>>> 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...@googlegroups.com .
>> To post to this group, send email to django...@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/7f1af12d-50ba-48fb-8774-4c4f6c47be58%40googlegroups.com
>>  
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
>
> Cordialement, Ludovic Coues 
> +33 6 14 87 43 42
>

-- 
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/9844ce13-61d3-46e8-8a91-5d0deb74f3c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Activating VirtualEnv on Windows

2017-04-15 Thread Camilo Torres
Hi.
Try to run the .bat. May be it is a documentation error?

On Friday, April 14, 2017 at 2:04:42 PM UTC-4, Lorenz Schümann wrote:
>
> Hey, newbie here. 
> I've followed the instructions on 
> https://docs.djangoproject.com/en/1.11/intro/contributing/ regarding 
> Virtualenv. And at the point where it says for Windows, to activate the 
> Virtualenv, type $ source ~/virtualenvs/djangodev/Scripts/activate, I found 
> out through StackExchange that indeed it's just the activate.bat you need 
> to run, as I don't have a source command in my Windows distro. Now isn't 
> that the most straight forward way anyway and should replace the method, 
> which is written down in the tutorial.
>

-- 
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/0841d851-9f27-4253-b965-ac8e164ab5fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Automatic reverse migrations

2017-04-15 Thread Camilo Torres
Hi,
May both of you try to implement "blue-green deployments", and switch only 
if all tests are OK.
You may also be interested in running a test deployment in a testing 
environment prior to production.
Don't know of a solution integrated into django.

On Friday, April 14, 2017 at 2:26:51 PM UTC-4, Andrew Godwin wrote:
>
> Hi Paul,
>
> I have tried this in the past, but it's basically an unsolvable problem in 
> the generic case. Databases do not take well to snapshotting or changing 
> schema, and some operations are naturally irreversible. If you find a way 
> that works well, I suggest you write it up so others can learn from it!
>
> Andrew
>
> On Fri, Apr 14, 2017 at 10:33 AM, > wrote:
>
>> In a modern Continuous Delivery environment, it's expected that there is 
>> an automated process for deploying code, and therefore performing database 
>> migrations. This is all straightforward.
>>
>> I haven't been able to find any good solutions for automatic rollback 
>> though. The main problem that I see is that there is (AFAIK) no easy way to 
>> definitively know which migrations to unapply to roll back to the previous 
>> verison. If you try to rollback from the new N+1 version, you have the 
>> migrations, but no recording of the previous version's state. If you 
>> rollback from the previous N version, you don't have the new migration 
>> files to do the DB rollback.
>>
>> What I'd really like is a way of recording a 'db migration checkpoint' 
>> which could be generated per-release (or whenever else you care to 
>> checkpoint your migration state), and would say something like `v1: 
>> {app1:0002,0003, app2: 0004}, v2: {app1:0004, app2: 0005, 0006}`, thus 
>> letting me roll back all of the migrations in the v2 deploy with a single 
>> command.
>>
>> Does anyone have suggestions or references here? I may try rolling the 
>> above solution if there is no prior art, but I want to avoid reinventing 
>> the wheel here, as it seems that this issue must have been hit by many 
>> other users before me.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/6cafecca-2c71-4a6f-b93b-fe3e64847bc2%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/362cbdc0-9dee-4c1b-a68d-b671eed49336%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: safe perfect and reliable app for verification email

2017-04-15 Thread Camilo Torres
Hi,
Here are some: https://www.google.com/search?q=django+email+verification

On Saturday, April 15, 2017 at 8:22:21 AM UTC-4, shahab emami wrote:
>
> hello
> I want to verify user's email while user is registering  .
>
> can you introduce me a few safe perfect  and reliable app for verification 
> email?
>
> 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/f330779a-64ce-4deb-a395-166023a3d94e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Creating multiple objects with one request in Django Rest Framework

2017-04-18 Thread Camilo Torres
Hi,

May be you can create a new Serializer, including a ListField to get 
multiple seat IDs:

class ManyMovieTicketsSerializer(serializers.Serializer):
show = serializers.IntegerField
user = serializers.IntegerField
seats = serializers.ListField(child=serializers.IntegerFields)

def create(self, validated_data):
iterate over seats and save every instance.

On Monday, April 17, 2017 at 1:19:23 AM UTC-4, Aamu Padi wrote:
>
> I am using Django as the backend server and Vue.js for the front end Movie 
> app.
>
> I have a Ticket model
>
> class MovieTicket(models.Model):
> show = models.ForeignKey(Show)
> seat = models.ForeignKey(Seat)
> user = models.ForeignKey(User)
> purchased_at = models.DateTimeField(default=timezone.now)
> qrcode = models.ImageField(upload_to='qrcode', blank=True, null=True)
> qrcode_data = models.CharField(max_length=255, unique=True, blank=True)
>
> class Meta:
> unique_together = ('show', 'seat')
>
> And its related Serializer
>
> class MovieTicketSerializer(serializers.ModelSerializer):
> class Meta:
> model = MovieTicket
> fields = '__all__'
>
> To buy a new Ticket there's a view which is mapped to this url 
> *http://dev.site.com/api/movies/buy-ticket/ 
> :*
>
> @api_view(['POST'])@permission_classes([IsAuthenticated])def 
> buy_ticket(request):
> serialized = MovieTicketSerializer(data=request.data)
> if serialized.is_valid():
> serialized.save()
> return Response(serialized.data, status=status.HTTP_201_CREATED)
> return Response(serialized._errors, status=status.HTTP_400_BAD_REQUEST)
>
> Now from the front end (Vue.js) I can create a new movie ticket like this:
>
> const formBody = {
> show: this.$store.state.showSelected.showTime.id,
> user: this.$store.state.user.id,
>
> // selectedSeats is an array of seats that have been selected by the 
> user. Here I am passing the first seat object.
> seat: this.$store.state.selectedSeats[0].seat.id};
> this.$http.post("http://dev.site.com/api/movies/buy-ticket/";, formBody)
> .then(function (response) {
> console.log(response.data);
> })
> .catch(function (response) {
> console.log(response);
> });return;
>
> If the form was valid, this will create a new MovieTicket Object.
>
> Now, suppose if the user selected multiple seats, I can loop through each 
> selectedSeats array and get the seat ids. But what I am confused is how 
> can I pass multiple seat.id if Django rest framework is only accepting 
> one seat per request?
>

-- 
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/b8c28522-cf21-4081-9563-97a869f4fa7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Mysql/Models

2017-04-18 Thread Camilo Torres
Hi,

You can use a Meta class for your models and add a db_table property to 
control the table name related to the model, that way, you can name your 
model as you like (and differently from the DB table name).
You can also use the db_column parameter to Fields to control the name of 
the column in the table you are associating the model fields. That allows 
you to use lowercase field names as customary for Python, for example:

class Organism(models.Model):
author = models.CharField(max_length=200, db_column='Author')
...

Please, read this documentation:
https://docs.djangoproject.com/en/1.11/ref/models/options/
https://docs.djangoproject.com/en/1.11/ref/models/fields/#db-column


On Sunday, April 16, 2017 at 6:01:16 PM UTC-4, alkha...@mymail.vcu.edu 
wrote:
>
> Hello everyone,
>
> Again, I'm super new to django so please bare with me. 
>
> I have just connected my mysql database to my django project in 
> settings.py. I then manually made models for the tables in my database. I 
> originally used inspectdb to do this, but I was getting a bunch of errors. 
> I decided to just do it manually from there, although I'm not necessarily 
> sure if it is correct yet. Do my models have to perfectly match my sql 
> relations? My tables already have unique ids as a field. I now that django 
> automatically does this, that is, make unique ids? Will this be a problem. 
>
> Anyway, I then ran makemigrations and migrate (which worked wonderfully), 
> and now I am trying to simply view some data from my database in the 
> manage.py shell. I am not exactly sure how to do this, so any help would be 
> great. Further, am I missing any steps as far connecting the mysql database 
> to my django project? Lastly, a rather huge disconnect I am having with all 
> of this is simply understanding how exactly the models.py in my apps are 
> actually connected to my database?
>
> Here are a few snapshots of my files:
>
> Models.py 
>
>
> 
>  
>
> manage.py shell
>
>
>
> 
>

-- 
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/a0345dda-370e-40f8-8e68-0fbf37e4c422%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: take select request from django from

2017-04-18 Thread Camilo Torres
Hi,

I think you can do what you need with your current model and form and using 
FormSets, but then you should change your view and template:
https://docs.djangoproject.com/en/1.11/topics/forms/formsets/

On Sunday, April 16, 2017 at 3:41:04 PM UTC-4, Xristos Xristoou wrote:
>
> hello i have create a select django form with list of images for per user.
>
> How to take that select request in my views.py ?
>
> i have success only to create correct that select list but i need take 
> that select request but i dont know how.
>
> models.py
>
> class MyModel(models.Model):
> user = models.ForeignKey(User, unique=True)
> upload = models.ImageField(upload_to='upload')
>
> views.py
>
>@login_required(login_url="login/")
> def carlist(request):
> Myform = MyModelForm(user=request.user)
> return render(request,'about.html',{'Myform':Myform})
>
> select django form :
>
> class MyModelForm(ModelForm):
> def __init__(self, *args, **kwargs):
> # extract "user" from kwrags (passed upon form init)
> if 'user' in kwargs:
> self.user = kwargs.pop('user')
> super(MyModelForm, self).__init__(*args, **kwargs)
> # generate the choices as (display, value). 
> # Display is the one that'll be shown to user, value is 
> # the one that'll be sent upon submitting 
> # (the "value" attribute of )
> choices = 
> MyModel.objects.filter(user=self.user).values_list('upload', 'id')
> self.fields['upload'].widget = Select(choices=choices)
>
> class Meta:
> model = MyModel
> fields = ('upload',)
>
> html :
>
> {% 
> csrf_token %}
>   {{ Myform}}
>
> for example Myform now have a list of user images that is correct but 
> after from that i need the select images from the form.
>
> can do it that with my code or not ?
>

-- 
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/ec7723ac-5c48-4745-9ebe-e16347598926%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Meu site esta com problema com decode messagem erro AttributeError at str object has no atribute 'decode' sera alguem pode me ajudar?

2017-04-18 Thread Camilo Torres
Hi,
You have not pasted enough information for me to know the error. You can 
paste the entire stack trace (as text, no need for a screen shot), or even 
better, if you have access to the server logs (django logs), you can see 
the entire stack trace there. You can also paste the relevant code if you 
need more help.

   - http://www.wikihow.com/Ask-a-Question-Intelligently
   - 
   
https://support.microsoft.com/en-us/help/555375/suggestions-for-asking-a-question-on-help-forums

For now, I can only recommend you to watch at line 68 of file 
.../web_server_moip.py, your error is being detected there. You are using a 
'decode' attribute of some variable, but that variable contains a str 
object (string text), and do not have such 'decode' property. The problem 
is probably because you are expecting another type of object like bytes or 
bytearray.

On Tuesday, April 18, 2017 at 8:11:38 AM UTC-4, Marcio Shochi wrote:
>
>
>1. erro AttributeError at   str object has no atribute  'decode' sera 
>alguem pode me ajudar?
>
>
>
>
> 
>

-- 
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/09559516-cbfa-4a07-a0c2-68abd70ca294%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multiple Profiles in Django 1.11

2017-04-18 Thread Camilo Torres
Hi,

I think you can use the default authentication system and create 2 
different groups: 'students' and 'teachers', give 'students' group 
permissions to all the parts of the application for students; similarly, 
give the 'teachers' group permissions to all the parts of the teachers 
application; you can do this with the admin. When you create new users, you 
should put them in any of the 2 groups; you can do this with the admin or 
programmatically.
Then, in your application views, remember to check for permissions by using 
the already available mixins or function decorators.
Please, read this part of the documentation:

   - https://docs.djangoproject.com/en/1.11/topics/auth/
   - https://docs.djangoproject.com/en/1.11/topics/auth/default/

Hope this helps.

On Tuesday, April 18, 2017 at 9:14:39 AM UTC-4, Bujj wrote:
>
> Hi guys i am new to django and i need some help here, i have created two 
> apps inside my django project namely students and teachers, how do i create 
> an authentication system for each one of them?  where they can register and 
> login to their backend, which will have a totaly different look from one 
> another
>

-- 
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/9268f190-33f6-449b-93ae-95b3504fc7ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.